docs: update imports and package names across docs (#9375)

* docs: update imports and package names across docs
+ reference configs

* generate files

* fix import

* change preview to rc
This commit is contained in:
Shahed Nasser authored and GitHub committed 2024-10-01 11:03:42 +02:00
1 parent c726ed54f5
commit 2e16949979
196 files changed
+1379 -1491

No files matched your search

@@ -12,26 +12,26 @@ Using the Emailpass auth module provider, you allow users to register and login
---
## Install the Emailpass Auth Module Provider
## Register the Emailpass Auth Module Provider
The Emailpass auth provider is registered by default with the Auth Module.
If you want to pass options to the provider, add the provider to the `providers` option of the Auth Module:
```js title="medusa-config.js"
const { Modules } = require("@medusajs/utils")
const { Modules } = require("@medusajs/framework/utils")
// ...
const modules = {
// ...
[Modules.AUTH]: {
resolve: "@medusajs/auth",
resolve: "@medusajs/medusa/auth",
options: {
providers: [
// other providers...
{
resolve: "@medusajs/auth-emailpass",
resolve: "@medusajs/medusa/auth-emailpass",
id: "emailpass",
options: {
// options...
@@ -18,7 +18,7 @@ Learn about the authentication flow in [this guide](../../authentication-route/p
---
## Install the Github Auth Module Provider
## Register the Github Auth Module Provider
<Prerequisites
items={[
@@ -33,28 +33,22 @@ Learn about the authentication flow in [this guide](../../authentication-route/p
]}
/>
To install the GitHub auth module provider, run the following command in the directory of your Medusa application:
```bash npm2yarn
npm install @medusajs/auth-github@preview
```
Next, add the module to the array of providers passed to the Auth Module:
Add the module to the array of providers passed to the Auth Module:
```js title="medusa-config.js"
const { Modules } = require("@medusajs/utils")
const { Modules } = require("@medusajs/framework/utils")
// ...
const modules = {
// ...
[Modules.AUTH]: {
resolve: "@medusajs/auth",
resolve: "@medusajs/medusa/auth",
options: {
providers: [
// other providers...
{
resolve: "@medusajs/auth-github",
resolve: "@medusajs/medusa/auth-github",
id: "github",
options: {
clientId: process.env.GITHUB_CLIENT_ID,
@@ -18,7 +18,7 @@ Learn about the authentication flow in [this guide](../../authentication-route/p
---
## Install the Google Auth Module Provider
## Register the Google Auth Module Provider
<Prerequisites
items={[
@@ -33,28 +33,22 @@ Learn about the authentication flow in [this guide](../../authentication-route/p
]}
/>
To install the Google auth module provider, run the following command in the directory of your Medusa application:
```bash npm2yarn
npm install @medusajs/auth-google@preview
```
Next, add the module to the array of providers passed to the Auth Module:
Add the module to the array of providers passed to the Auth Module:
```js title="medusa-config.js"
const { Modules } = require("@medusajs/utils")
const { Modules } = require("@medusajs/framework/utils")
// ...
const modules = {
// ...
[Modules.AUTH]: {
resolve: "@medusajs/auth",
resolve: "@medusajs/medusa/auth",
options: {
providers: [
// other providers...
{
resolve: "@medusajs/auth-google",
resolve: "@medusajs/medusa/auth-google",
id: "google",
options: {
clientId: process.env.GOOGLE_CLIENT_ID,
@@ -13,7 +13,7 @@ Before creating an actor type, you must define a data model the actor type belon
The rest of this guide uses this `Manager` data model as an example:
```ts title="src/modules/manager/models/manager.ts"
import { model } from "@medusajs/utils"
import { model } from "@medusajs/framework/utils"
const Manager = model.define("manager", {
id: model.id().primaryKey(),
@@ -49,10 +49,10 @@ import {
createStep,
StepResponse,
WorkflowResponse,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import {
setAuthAppMetadataStep,
} from "@medusajs/core-flows"
} from "@medusajs/medusa/core-flows"
import ManagerModuleService from "../modules/manager/service"
type CreateManagerWorkflowInput = {
@@ -106,7 +106,7 @@ This workflow accepts the manager’s data and the associated auth identity’s
The workflow has two steps:
1. Create the manager using the `createManagerStep`.
2. Set the `app_metadata` property of the associated auth identity using the `setAuthAppMetadataStep` step imported from `@medusajs/core-flows`. You specify the actor type `manager` in the `actorType` property of the step’s input.
2. Set the `app_metadata` property of the associated auth identity using the `setAuthAppMetadataStep` step imported from `@medusajs/medusa/core-flows`. You specify the actor type `manager` in the `actorType` property of the step’s input.
---
@@ -127,7 +127,7 @@ import type {
AuthenticatedMedusaRequest,
MedusaResponse,
} from "@medusajs/medusa"
import { MedusaError } from "@medusajs/utils"
import { MedusaError } from "@medusajs/framework/utils"
import createManagerWorkflow from "../../workflows/create-manager"
type RequestBody = {
@@ -308,7 +308,7 @@ For example, create the following workflow that deletes a manager and updates it
import {
createStep,
StepResponse,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import ManagerModuleService from "../modules/manager/service"
export type DeleteManagerWorkflow = {
@@ -348,17 +348,17 @@ export const deleteHighlights = [
```ts title="src/workflows/delete-manager.ts" collapsibleLines="1-15" expandButtonLabel="Show Imports" highlights={deleteHighlights}
// other imports
import { MedusaError } from "@medusajs/utils"
import { MedusaError } from "@medusajs/framework/utils"
import {
WorkflowData,
WorkflowResponse,
createWorkflow,
transform,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import {
setAuthAppMetadataStep,
useRemoteQueryStep,
} from "@medusajs/core-flows"
} from "@medusajs/medusa/core-flows"
// ...
@@ -24,9 +24,9 @@ This example uses the [jsonwebtoken NPM package](https://www.npmjs.com/package/j
import {
IAuthModuleService,
AuthenticationInput,
} from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { MedusaError } from "@medusajs/utils"
} from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
import { MedusaError } from "@medusajs/framework/utils"
import jwt from "jsonwebtoken"
export async function POST(
@@ -69,7 +69,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeAuthModule } from "@medusajs/auth"
import { initialize as initializeAuthModule } from "@medusajs/medusa/auth"
export async function POST(request: Request) {
const authModuleService = await initializeAuthModule()
@@ -127,9 +127,9 @@ This example uses the [jsonwebtoken NPM package](https://www.npmjs.com/package/j
import {
IAuthModuleService,
AuthenticationInput,
} from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { MedusaError } from "@medusajs/utils"
} from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
import { MedusaError } from "@medusajs/framework/utils"
import jwt from "jsonwebtoken"
export async function POST(
@@ -174,7 +174,7 @@ export async function POST(
```ts collapsibleLines="1-7" expandButtonLabel="Show Imports"
import { NextResponse } from "next/server"
import { initialize as initializeAuthModule } from "@medusajs/auth"
import { initialize as initializeAuthModule } from "@medusajs/medusa/auth"
export async function POST(request: Request) {
const authModuleService = await initializeAuthModule()
@@ -226,8 +226,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IAuthModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IAuthModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
req: MedusaRequest,
@@ -253,7 +253,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeAuthModule } from "@medusajs/auth"
import { initialize as initializeAuthModule } from "@medusajs/medusa/auth"
export async function POST(request: Request) {
const authModuleService = await initializeAuthModule()
@@ -282,8 +282,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IAuthModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IAuthModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
@@ -305,7 +305,7 @@ export async function GET(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeAuthModule } from "@medusajs/auth"
import { initialize as initializeAuthModule } from "@medusajs/medusa/auth"
export async function GET(request: Request) {
const authModuleService = await initializeAuthModule()
@@ -328,8 +328,8 @@ export async function GET(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IAuthModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IAuthModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
req: MedusaRequest,
@@ -358,7 +358,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeAuthModule } from "@medusajs/auth"
import { initialize as initializeAuthModule } from "@medusajs/medusa/auth"
type ContextType = {
params: {
@@ -394,8 +394,8 @@ export async function POST(request: Request, { params }: ContextType) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IAuthModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IAuthModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function DELETE(
req: MedusaRequest,
@@ -417,7 +417,7 @@ export async function DELETE(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeAuthModule } from "@medusajs/auth"
import { initialize as initializeAuthModule } from "@medusajs/medusa/auth"
type ContextType = {
params: {
@@ -21,18 +21,18 @@ When the Medusa application starts, these providers are registered and can be us
For example:
```js title="medusa-config.js"
const { Modules } = require("@medusajs/utils")
const { Modules } = require("@medusajs/framework/utils")
// ...
module.exports = defineConfig({
// ...
modules: {
resolve: "@medusajs/auth",
resolve: "@medusajs/medusa/auth",
options: {
providers: [
{
resolve: "@medusajs/auth-emailpass",
resolve: "@medusajs/medusa/auth-emailpass",
id: "emailpass",
options: {
// provider options...
@@ -6,11 +6,11 @@ export const metadata = {
# {metadata.title}
The Auth Module is the `@medusajs/auth` NPM package that provides authentication-related features in your Medusa and Node.js applications.
The Auth Module is the `@medusajs/medusa/auth` NPM package that provides authentication-related features in your Medusa and Node.js applications.
## How to Use Auth Module's Service
You can use the Auth Module's main service by resolving from the Medusa container the resource `Modules.AUTH` imported from `@medusajs/utils`.
You can use the Auth Module's main service by resolving from the Medusa container the resource `Modules.AUTH` imported from `@medusajs/framework/utils`.
For example:
@@ -19,8 +19,8 @@ For example:
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IAuthModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IAuthModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
@@ -41,8 +41,8 @@ export async function GET(
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/medusa"
import { IAuthModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IAuthModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export default async function subscriberHandler({ container }: SubscriberArgs) {
const authModuleService: IAuthModuleService = container.resolve(
@@ -57,9 +57,9 @@ export default async function subscriberHandler({ container }: SubscriberArgs) {
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/workflows-sdk"
import { IAuthModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { createStep } from "@medusajs/framework/workflows-sdk"
import { IAuthModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
const step1 = createStep("step-1", async (_, { container }) => {
const authModuleService: IAuthModuleService = container.resolve(