docs: edits and fixes to commerce module docs (#7468)

Apply edits and fixes to the commerce modules docs
This commit is contained in:
Shahed Nasser
2024-05-29 11:08:06 +00:00
committed by GitHub
parent 130de74d6d
commit 2c5ba408d4
160 changed files with 6400 additions and 3790 deletions
@@ -10,10 +10,11 @@ import { rootPathPrefix } from "./general.js"
import { modules } from "./references.js"
const customOptions: Record<string, Partial<TypeDocOptions>> = {
entities: getOptions({
entryPointPath: "packages/medusa/src/models/index.ts",
tsConfigName: "medusa.json",
name: "entities",
"auth-provider": getOptions({
entryPointPath: "packages/core/utils/src/auth/abstract-auth-provider.ts",
tsConfigName: "utils.json",
name: "auth-provider",
parentIgnore: true,
}),
file: getOptions({
entryPointPath: "packages/core/utils/src/file/abstract-file-provider.ts",
@@ -21,10 +22,10 @@ const customOptions: Record<string, Partial<TypeDocOptions>> = {
name: "file",
parentIgnore: true,
}),
"fulfillment-service": getOptions({
entryPointPath: "packages/medusa/src/interfaces/fulfillment-service.ts",
tsConfigName: "medusa.json",
name: "fulfillment-service",
"fulfillment-provider": getOptions({
entryPointPath: "packages/core/utils/src/fulfillment/provider.ts",
tsConfigName: "utils.json",
name: "fulfillment-provider",
parentIgnore: true,
}),
"js-client": getOptions({
@@ -84,24 +85,12 @@ const customOptions: Record<string, Partial<TypeDocOptions>> = {
name: "notification",
parentIgnore: true,
}),
"payment-processor": getOptions({
entryPointPath: "packages/medusa/src/interfaces/payment-processor.ts",
tsConfigName: "medusa.json",
name: "payment-processor",
}),
"payment-provider": getOptions({
entryPointPath:
"packages/core/utils/src/payment/abstract-payment-provider.ts",
tsConfigName: "utils.json",
name: "payment-provider",
}),
"price-selection": getOptions({
entryPointPath:
"packages/medusa/src/interfaces/price-selection-strategy.ts",
tsConfigName: "medusa.json",
name: "price-selection",
parentIgnore: true,
}),
search: getOptions({
entryPointPath: "packages/core/utils/src/search/abstract-service.ts",
tsConfigName: "utils.json",
@@ -112,24 +101,11 @@ const customOptions: Record<string, Partial<TypeDocOptions>> = {
tsConfigName: "medusa.json",
name: "services",
}),
"tax-calculation": getOptions({
entryPointPath:
"packages/medusa/src/interfaces/tax-calculation-strategy.ts",
tsConfigName: "medusa.json",
name: "tax-calculation",
parentIgnore: true,
}),
"tax-provider": getOptions({
entryPointPath: "packages/core/types/src/tax/provider.ts",
tsConfigName: "types.json",
name: "tax-provider",
}),
"tax-service": getOptions({
entryPointPath: "packages/medusa/src/interfaces/tax-service.ts",
tsConfigName: "medusa.json",
name: "tax-service",
parentIgnore: true,
}),
types: getOptions({
entryPointPath: "packages/core/types/src/index.ts",
tsConfigName: "types.json",
@@ -0,0 +1,84 @@
import { FormattingOptionsType } from "types"
const authProviderOptions: FormattingOptionsType = {
"^auth_provider/.*AbstractAuthModuleProvider": {
reflectionGroups: {
Properties: false,
},
reflectionDescription: `In this document, youll learn how to create an auth provider module and the methods you must implement in its main service.`,
frontmatterData: {
slug: "/references/auth/provider",
},
reflectionTitle: {
fullReplacement: "How to Create an Auth Provider Module",
},
shouldIncrementAfterStartSections: true,
expandMembers: true,
startSections: [
`## 1. Create Module Directory
Start by creating a new directory for your module. For example, \`src/modules/my-auth\`.`,
`## 2. Create the Auth Provider Service
Create the file \`src/modules/my-auth/service.ts\` that holds the module's main service. It must extend the \`AbstractAuthModuleProvider\` class imported from \`@medusajs/utils\`:
\`\`\`ts title="src/modules/my-auth/service.ts"
import { AbstractAuthModuleProvider } from "@medusajs/utils"
class MyAuthProviderService extends AbstractAuthModuleProvider {
// TODO implement methods
}
export default MyAuthProviderService
\`\`\``,
],
endSections: [
`## 3. Create Module Definition File
Create the file \`src/modules/my-auth/index.ts\` with the following content:
\`\`\`ts title="src/modules/my-auth/index.ts"
import MyAuthProviderService from "./service"
export default {
service: MyAuthProviderService,
}
\`\`\`
This exports the module's definition, indicating that the \`MyAuthProviderService\` is the main service of the module.`,
`## 4. Use Module
To use your Auth Provider Module, add it to the \`providers\` array of the Auth Module:
\`\`\`js title="medusa-config.js"
const { Modules } = require("@medusajs/modules-sdk")
// ...
const modules = {
// ...
[Modules.AUTH]: {
resolve: "@medusajs/auth",
options: {
providers: [
{
resolve: "./dist/modules/my-auth",
options: {
config: {
"my-auth": {
// provider options...
},
},
},
},
],
},
},
}
\`\`\`
`,
],
},
}
export default authProviderOptions
@@ -1,16 +1,11 @@
import { FormattingOptionsType } from "types"
const fileOptions: FormattingOptionsType = {
"^file": {
frontmatterData: {
displayed_sidebar: "core",
},
},
"^file/.*AbstractFileProviderService": {
reflectionGroups: {
Properties: false,
},
reflectionDescription: `In this document, youll learn how to create a file provider module and the methods you must implement in it.`,
reflectionDescription: `In this document, youll learn how to create a file provider module and the methods you must implement in its main service.`,
frontmatterData: {
slug: "/references/file-provider-module",
},
@@ -25,9 +20,7 @@ const fileOptions: FormattingOptionsType = {
Start by creating a new directory for your module. For example, \`src/modules/my-file\`.`,
`## 2. Create the File Provider Service
Create the file \`src/modules/my-file/service.ts\` that holds the implementation of the file service.
The File Provider Module's main service must extend the \`AbstractFileProviderService\` class imported from \`@medusajs/utils\`:
Create the file \`src/modules/my-file/service.ts\` that holds the implementation of the module's main service. It must extend the \`AbstractFileProviderService\` class imported from \`@medusajs/utils\`:
\`\`\`ts title="src/modules/my-file/service.ts"
import { AbstractFileProviderService } from "@medusajs/utils"
@@ -0,0 +1,84 @@
import { FormattingOptionsType } from "types"
const fulfillmentProviderOptions: FormattingOptionsType = {
"^fulfillment_provider/.*AbstractFulfillmentProviderService": {
reflectionGroups: {
Properties: false,
},
reflectionDescription: `In this document, youll learn how to create a fulfillment provider module and the methods you must implement in its main service.`,
frontmatterData: {
slug: "/references/fulfillment/provider",
},
reflectionTitle: {
fullReplacement: "How to Create a Fulfillment Provider Module",
},
shouldIncrementAfterStartSections: true,
expandMembers: true,
startSections: [
`## 1. Create Module Directory
Start by creating a new directory for your module. For example, \`src/modules/my-fulfillment\`.`,
`## 2. Create the Fulfillment Provider Service
Create the file \`src/modules/my-fulfillment/service.ts\` that holds the module's main service. It must extend the \`AbstractFulfillmentProviderService\` class imported from \`@medusajs/utils\`:
\`\`\`ts title="src/modules/my-fulfillment/service.ts"
import { AbstractFulfillmentProviderService } from "@medusajs/utils"
class MyFulfillmentProviderService extends AbstractFulfillmentProviderService {
// TODO implement methods
}
export default MyFulfillmentProviderService
\`\`\``,
],
endSections: [
`## 3. Create Module Definition File
Create the file \`src/modules/my-fulfillment/index.ts\` with the following content:
\`\`\`ts title="src/modules/my-fulfillment/index.ts"
import MyFulfillmentProviderService from "./service"
export default {
service: MyFulfillmentProviderService,
}
\`\`\`
This exports the module's definition, indicating that the \`MyFulfillmentProviderService\` is the main service of the module.`,
`## 4. Use Module
To use your Fulfillment Provider Module, add it to the \`providers\` array of the Fulfillment Module:
\`\`\`js title="medusa-config.js"
const { Modules } = require("@medusajs/modules-sdk")
// ...
const modules = {
// ...
[Modules.FULFILLMENT]: {
resolve: "@medusajs/fulfillment",
options: {
providers: [
{
resolve: "./dist/modules/my-fulfillment",
options: {
config: {
"my-fulfillment": {
// provider options...
},
},
},
},
],
},
},
}
\`\`\`
`,
],
},
}
export default fulfillmentProviderOptions
@@ -1,5 +1,7 @@
import { FormattingOptionsType } from "types"
import authProviderOptions from "./auth-provider.js"
import fileOptions from "./file.js"
import fulfillmentProviderOptions from "./fulfillment-provider.js"
import jsClientOptions from "./js-client.js"
import medusaConfigOptions from "./medusa-config.js"
import medusaReactOptions from "./medusa-react.js"
@@ -11,7 +13,9 @@ import taxProviderOptions from "./tax-provider.js"
import workflowsOptions from "./workflows.js"
const mergerCustomOptions: FormattingOptionsType = {
...authProviderOptions,
...fileOptions,
...fulfillmentProviderOptions,
...jsClientOptions,
...medusaConfigOptions,
...medusaReactOptions,
@@ -21,10 +21,10 @@ export const modules = [
const allReferences = [
...modules,
"auth-provider",
"file",
// "js-client",
"fulfillment-provider",
"medusa-config",
// "medusa-react",
"medusa",
"notification",
"payment-provider",