docs: TSDoc + reference of fulfillment service (#5761)

This commit is contained in:
Shahed Nasser
2023-11-29 11:58:08 +00:00
committed by GitHub
parent 8f25ed8a10
commit f802e2460f
1479 changed files with 30259 additions and 16135 deletions
+1 -1
View File
@@ -33,7 +33,7 @@
"typedoc-plugin-missing-exports": "^2.1.0",
"typedoc-plugin-reference-excluder": "1.1.3",
"typedoc-plugin-rename-defaults": "^0.6.6",
"typescript": "^5.2.2"
"typescript": "5.2"
},
"devDependencies": {
"@types/randomcolor": "^0.5.8"
@@ -0,0 +1,64 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require("path")
const globalTypedocOptions = require("./_base")
const pathPrefix = path.join(__dirname, "..", "..", "..")
module.exports = {
...globalTypedocOptions,
entryPoints: [
path.join(
pathPrefix,
"packages/medusa/src/interfaces/fulfillment-service.ts"
),
],
out: [path.join(pathPrefix, "www/apps/docs/content/references/fulfillment")],
tsconfig: path.join(__dirname, "extended-tsconfig", "medusa.json"),
name: "Fulfillment Provider Reference",
indexTitle: "Fulfillment Provider Reference",
entryDocument: "_index.mdx",
hideInPageTOC: true,
hideBreadcrumbs: true,
formatting: {
"*": {
showCommentsAsHeader: true,
sections: {
member_sources_definedIn: false,
reflection_hierarchy: false,
member_sources_inheritedFrom: false,
member_sources_implementationOf: false,
reflection_implementedBy: false,
member_signature_sources: false,
reflection_callable: false,
reflection_indexable: false,
reflection_implements: false,
member_signature_title: false,
member_signature_returns: false,
},
parameterStyle: "component",
parameterComponent: "ParameterTypes",
mdxImports: [
`import ParameterTypes from "@site/src/components/ParameterTypes"`,
],
reflectionGroups: {
Properties: false,
},
frontmatterData: {
displayed_sidebar: "modules",
},
},
AbstractFulfillmentService: {
reflectionDescription: `In this document, youll learn how to create a fulfillment provider to a Medusa backend and the methods you must implement in it. If youre unfamiliar with the Shipping architecture in Medusa, make sure to [check out the overview first](https://docs.medusajs.com/modules/carts-and-checkout/shipping).`,
frontmatterData: {
displayed_sidebar: "modules",
slug: "/modules/carts-and-checkout/backend/add-fulfillment-provider",
},
reflectionTitle: {
fullReplacement: "How to Create a Fulfillment Provider",
},
},
},
objectLiteralTypeDeclarationStyle: "component",
mdxOutput: true,
maxLevel: 2,
}
@@ -23,7 +23,7 @@
},
"devDependencies": {
"@types/node": "^16.11.10",
"typescript": "^4.6"
"typescript": "5.2"
},
"keywords": [
"typedocplugin",
@@ -23,7 +23,7 @@
"devDependencies": {
"@types/node": "^16.11.10",
"copyfiles": "^2.4.1",
"typescript": "^4.6"
"typescript": "5.2"
},
"keywords": [
"typedocplugin",
@@ -45,6 +45,10 @@ import commentTagHelper from "./resources/helpers/comment-tag"
import exampleHelper from "./resources/helpers/example"
import ifFeatureFlagHelper from "./resources/helpers/if-feature-flag"
import featureFlagHelper from "./resources/helpers/feature-flag"
import decrementCurrentTitleLevelHelper from "./resources/helpers/decrement-current-title-level"
import incrementCurrentTitleLevelHelper from "./resources/helpers/increment-current-title-level"
import hasMoreThanOneSignatureHelper from "./resources/helpers/has-more-than-one-signature"
import ifCanShowConstructorsTitleHelper from "./resources/helpers/if-can-show-constructors-title"
import { MarkdownTheme } from "./theme"
// test
@@ -120,4 +124,8 @@ export function registerHelpers(theme: MarkdownTheme) {
exampleHelper()
ifFeatureFlagHelper()
featureFlagHelper()
decrementCurrentTitleLevelHelper(theme)
incrementCurrentTitleLevelHelper(theme)
hasMoreThanOneSignatureHelper()
ifCanShowConstructorsTitleHelper()
}
@@ -6,7 +6,7 @@ import { MarkdownTheme } from "../../theme"
export default function (theme: MarkdownTheme) {
Handlebars.registerHelper(
"commentTag",
function (tag: CommentTag, commentLevel = 4, parent = null) {
function (tag: CommentTag, parent = null) {
const { showCommentsAsHeader, showCommentsAsDetails } =
theme.getFormattingOptionsForLocation()
if (tag.tag === "@schema") {
@@ -19,8 +19,7 @@ export default function (theme: MarkdownTheme) {
if (showCommentsAsHeader) {
return `${Handlebars.helpers.titleLevel.call(
parent,
commentLevel
parent
)} ${tagTitle}\n\n${tagContent}`
} else if (showCommentsAsDetails) {
return `<details>\n<summary>\n${tagTitle}\n</summary>\n\n${tagContent}\n\n</details>`
@@ -10,7 +10,6 @@ export default function () {
comment: Comment,
showSummary = true,
showTags = true,
commentLevel = 4,
parent = null
) {
const md: string[] = []
@@ -24,11 +23,7 @@ export default function () {
(tag) => !EXCLUDED_TAGS.includes(tag.tag)
)
const tags = filteredTags.map((tag) => {
return Handlebars.helpers.commentTag(
tag,
commentLevel,
parent || comment
)
return Handlebars.helpers.commentTag(tag, parent || comment)
})
md.push(tags.join("\n\n"))
}
@@ -0,0 +1,9 @@
import { MarkdownTheme } from "../../theme"
import * as Handlebars from "handlebars"
export default function (theme: MarkdownTheme) {
Handlebars.registerHelper("decrementCurrentTitleLevel", function () {
const { currentTitleLevel } = theme
theme.setCurrentTitleLevel(currentTitleLevel - 1)
})
}
@@ -2,18 +2,15 @@ import * as Handlebars from "handlebars"
import { Reflection } from "typedoc"
export default function () {
Handlebars.registerHelper(
"example",
function (reflection: Reflection, commentLevel = 4) {
const exampleTag = reflection.comment?.blockTags.find(
(tag) => tag.tag === "@example"
)
Handlebars.registerHelper("example", function (reflection: Reflection) {
const exampleTag = reflection.comment?.blockTags.find(
(tag) => tag.tag === "@example"
)
if (!exampleTag) {
return ""
}
return Handlebars.helpers.commentTag(exampleTag, commentLevel, reflection)
if (!exampleTag) {
return ""
}
)
return Handlebars.helpers.commentTag(exampleTag, reflection)
})
}
@@ -0,0 +1,11 @@
import { DeclarationReflection } from "typedoc"
import * as Handlebars from "handlebars"
export default function () {
Handlebars.registerHelper(
"hasMoreThanOneSignature",
function (model: DeclarationReflection) {
return (model.signatures?.length || 0) > 1
}
)
}
@@ -0,0 +1,14 @@
import * as Handlebars from "handlebars"
import { ReflectionGroup } from "typedoc"
export default function () {
Handlebars.registerHelper(
"ifCanShowConstructorTitle",
function (this: ReflectionGroup, options: Handlebars.HelperOptions) {
return this.title.toLowerCase() !== "constructors" ||
this.children.length > 1
? options.fn(this)
: options.inverse(this)
}
)
}
@@ -0,0 +1,9 @@
import { MarkdownTheme } from "../../theme"
import * as Handlebars from "handlebars"
export default function (theme: MarkdownTheme) {
Handlebars.registerHelper("incrementCurrentTitleLevel", function () {
const { currentTitleLevel } = theme
theme.setCurrentTitleLevel(currentTitleLevel + 1)
})
}
@@ -10,6 +10,10 @@ export default function (theme: MarkdownTheme) {
function (this: PageEvent<any>, shouldEscape = true) {
const { reflectionTitle } = theme.getFormattingOptionsForLocation()
if (reflectionTitle?.fullReplacement?.length) {
return reflectionTitle.fullReplacement
}
const title: string[] = [""]
if (
reflectionTitle?.kind &&
@@ -13,11 +13,15 @@ export default function (theme: MarkdownTheme) {
function (this: SignatureReflection, accessor?: string, standalone = true) {
const { sections, expandMembers = false } =
theme.getFormattingOptionsForLocation()
if (sections && sections.member_signature_title === false) {
const parentHasMoreThanOneSignature =
Handlebars.helpers.hasMoreThanOneSignature(this.parent)
if (
sections &&
sections.member_signature_title === false &&
!parentHasMoreThanOneSignature
) {
// only show title if there are more than one signatures
if (!this.parent.signatures || this.parent.signatures.length <= 1) {
return ""
}
return ""
}
const md: string[] = []
@@ -36,12 +40,12 @@ export default function (theme: MarkdownTheme) {
if (accessor) {
md.push(
`${accessor}${
expandMembers ? `${Handlebars.helpers.titleLevel(4)} ` : "**"
expandMembers ? `${Handlebars.helpers.titleLevel()} ` : "**"
}${this.name}${!expandMembers ? "**" : ""}`
)
} else if (this.name !== "__call" && this.name !== "__type") {
md.push(
`${expandMembers ? `${Handlebars.helpers.titleLevel(4)} ` : "**"}${
`${expandMembers ? `${Handlebars.helpers.titleLevel()} ` : "**"}${
this.name
}${!expandMembers ? "**" : ""}`
)
@@ -1,44 +1,18 @@
import { MarkdownTheme } from "../../theme"
import * as Handlebars from "handlebars"
import { SignatureReflection, Reflection } from "typedoc"
import { Reflection } from "typedoc"
export default function (theme: MarkdownTheme) {
Handlebars.registerHelper(
"titleLevel",
function (this: Reflection, originalLevel = 3): string {
const { expandMembers, sections } =
theme.getFormattingOptionsForLocation()
Handlebars.registerHelper("titleLevel", function (this: Reflection): string {
const { currentTitleLevel } = theme
if (!expandMembers) {
return Array(originalLevel).fill("#").join("")
}
// let titleLevel = currentTitleLevel
const { allReflectionsHaveOwnDocument } = theme
// if (isChild) {
// titleLevel++
// theme.setCurrentTitleLevel(titleLevel + 1)
// }
let isSignatureChild = false
if (
sections &&
sections.member_signature_title === false &&
(this instanceof SignatureReflection || this.variant === "signature")
) {
// only show title if there are more than one signatures
isSignatureChild =
this.parent !== undefined &&
"signatures" in this.parent &&
(this.parent.signatures as SignatureReflection[]).length > 1
}
const numberToSubtract = allReflectionsHaveOwnDocument
? isSignatureChild
? 1
: 2
: isSignatureChild
? 0
: 1
const level = originalLevel - numberToSubtract
return Array(level).fill("#").join("")
}
)
return Array(currentTitleLevel).fill("#").join("")
})
}
@@ -4,7 +4,7 @@
{{#if hasVisibleComponent}}
{{{comments this true true 4 model}}}
{{{comments this true true model}}}
{{/if}}
@@ -12,7 +12,7 @@
{{#if (sectionEnabled "member_declaration_example")}}
{{{example this 4}}}
{{{example this}}}
{{/if}}
@@ -20,7 +20,7 @@
{{#if typeParameters}}
{{{titleLevel 4}}} Type Parameters
{{{titleLevel}}} Type Parameters
{{#with typeParameters}}
@@ -40,7 +40,7 @@
{{#with type.declaration.indexSignature}}
{{titleLevel 4}} Index signature
{{titleLevel}} Index signature
{{{indexSignatureTitle}}}
@@ -58,17 +58,21 @@
{{#if type.declaration.children}}
{{{titleLevel 4}}} Call signature
{{{titleLevel}}} Call signature
{{else}}
{{{titleLevel 4}}} Type declaration
{{{titleLevel}}} Type declaration
{{/if}}
{{#each type.declaration.signatures}}
{{> member.signature showSources=false commentLevel=5 }}
{{incrementCurrentTitleLevel}}
{{> member.signature showSources=false }}
{{decrementCurrentTitleLevel}}
{{/each}}
@@ -82,7 +86,7 @@
{{#with type.declaration}}
{{{titleLevel 4}}} Type declaration
{{{titleLevel}}} Type declaration
{{/with}}
@@ -4,7 +4,7 @@
{{#with getSignature}}
{{> member.signature accessor="get" showSources=true commentLevel=4 }}
{{> member.signature accessor="get" showSources=true }}
{{/with}}
@@ -18,7 +18,7 @@
{{#with setSignature}}
{{> member.signature accessor="set" showSources=true commentLevel=4 }}
{{> member.signature accessor="set" showSources=true }}
{{/with}}
@@ -2,7 +2,9 @@
{{#if name}}
{{titleLevel 4}} {{#ifNamedAnchors}}<a id="{{anchor}}" name="{{this.anchor}}"></a> {{/ifNamedAnchors}}{{ escape name }}
{{titleLevel}} {{#ifNamedAnchors}}<a id="{{anchor}}" name="{{this.anchor}}"></a> {{/ifNamedAnchors}}{{ escape name }}
{{incrementCurrentTitleLevel}}
{{/if}}
@@ -14,7 +16,7 @@
{{#each signatures}}
{{> member.signature showSources=true commentLevel=../commentLevel }}
{{> member.signature showSources=true }}
{{/each}}
@@ -59,3 +61,13 @@
___
{{/unless}}
{{/unless}}
{{#unless hasOwnDocument}}
{{#if name}}
{{decrementCurrentTitleLevel}}
{{/if}}
{{/unless}}
@@ -1,5 +1,15 @@
{{{signatureTitle accessor}}}
{{#if (getFormattingOption "expandMembers")}}
{{#if (hasMoreThanOneSignature parent)}}
{{incrementCurrentTitleLevel}}
{{/if}}
{{/if}}
{{#if (sectionEnabled "member_signature_comment")}}
{{#with comment}}
@@ -16,7 +26,7 @@
{{#if (sectionEnabled "member_signature_example")}}
{{{example this commentLevel}}}
{{{example this}}}
{{/if}}
@@ -24,7 +34,7 @@
{{#if typeParameters}}
{{{titleLevel commentLevel}}} Type Parameters
{{{titleLevel}}} Type Parameters
{{#with typeParameters}}
@@ -40,7 +50,7 @@
{{#if parameters}}
{{{titleLevel commentLevel}}} Parameters
{{{titleLevel}}} Parameters
{{#with parameters}}
@@ -56,7 +66,7 @@
{{#if type}}
{{{titleLevel commentLevel}}} Returns
{{{titleLevel}}} Returns
{{#if (sectionEnabled "member_signature_returns")}}
@@ -76,12 +86,16 @@
{{#if declaration.signatures}}
{{incrementCurrentTitleLevel}}
{{#each declaration.signatures}}
{{> member.signature showSources=false commentLevel=commentLevel }}
{{> member.signature showSources=false }}
{{/each}}
{{decrementCurrentTitleLevel}}
{{/if}}
{{/if}}
@@ -112,7 +126,7 @@
{{#if hasVisibleComponent}}
{{{comments this false true commentLevel ..}}}
{{{comments this false true ..}}}
{{/if}}
@@ -124,8 +138,22 @@
{{#if showSources}}
{{incrementCurrentTitleLevel}}
{{> member.sources}}
{{decrementCurrentTitleLevel}}
{{/if}}
{{/if}}
{{#if (getFormattingOption "expandMembers")}}
{{#if (hasMoreThanOneSignature parent)}}
{{decrementCurrentTitleLevel}}
{{/if}}
{{/if}}
@@ -2,7 +2,7 @@
{{#if implementationOf}}
{{titleLevel 4}} Implementation of
{{titleLevel}} Implementation of
{{#with implementationOf}}
@@ -18,7 +18,7 @@
{{#if inheritedFrom}}
{{titleLevel 4}} Inherited from
{{titleLevel}} Inherited from
{{#with inheritedFrom}}
@@ -34,7 +34,7 @@
{{#if overwrites}}
{{titleLevel 4}} Overrides
{{titleLevel}} Overrides
{{#with overwrites}}
@@ -50,7 +50,7 @@
{{#if sources}}
{{titleLevel 4}} Defined in
{{titleLevel}} Defined in
{{#each sources}}
@@ -10,7 +10,13 @@ ___
{{#unless (getFormattingOption "expandMembers")}}
## {{title}} {{../title}}
{{#ifCanShowConstructorTitle}}
{{titleLevel}} {{title}} {{../title}}
{{incrementCurrentTitleLevel}}
{{/ifCanShowConstructorTitle}}
{{/unless}}
@@ -26,19 +32,35 @@ ___
{{#each children}}
{{> member commentLevel=5}}
{{> member }}
{{/each}}
{{/if}}
{{#unless (getFormattingOption "expandMembers")}}
{{#ifCanShowConstructorTitle}}
{{decrementCurrentTitleLevel}}
{{/ifCanShowConstructorTitle}}
{{/unless}}
{{/each}}
{{else}}
{{#unless (getFormattingOption "expandMembers")}}
## {{title}}
{{#ifCanShowConstructorTitle}}
{{titleLevel}} {{title}}
{{incrementCurrentTitleLevel}}
{{/ifCanShowConstructorTitle}}
{{/unless}}
@@ -54,12 +76,22 @@ ___
{{#each children}}
{{> member commentLevel=5}}
{{> member}}
{{/each}}
{{/if}}
{{#unless (getFormattingOption "expandMembers")}}
{{#ifCanShowConstructorTitle}}
{{decrementCurrentTitleLevel}}
{{/ifCanShowConstructorTitle}}
{{/unless}}
{{/if}}
{{/if}}
@@ -8,7 +8,9 @@
{{#unless (getFormattingOption "expandMembers")}}
## {{title}}
{{{titleLevel}}} {{title}}
{{incrementCurrentTitleLevel}}
{{/unless}}
@@ -16,12 +18,18 @@
{{#unless hasOwnDocument}}
{{> member commentLevel=4}}
{{> member}}
{{/unless}}
{{/each}}
{{#unless (getFormattingOption "expandMembers")}}
{{decrementCurrentTitleLevel}}
{{/unless}}
{{/unless}}
{{/each}}
@@ -32,6 +40,10 @@
{{#unless allChildrenHaveOwnDocument}}
{{#unless @first}}
___
{{/unless}}
{{> members.group}}
{{/unless}}
@@ -1,9 +1,13 @@
{{#if showSources}}
{{{titleLevel 4}}} {{{title}}}
{{incrementCurrentTitleLevel}}
{{else}}
{{/if}}
{{{titleLevel 5}}} {{{title}}}
{{{titleLevel}}} {{{title}}}
{{#if showSources}}
{{decrementCurrentTitleLevel}}
{{/if}}
@@ -1,6 +1,6 @@
{{#ifShowPageTitle}}
# {{{reflectionTitle true}}}
{{titleLevel}} {{{reflectionTitle true}}}
{{/ifShowPageTitle}}
@@ -1,5 +1,7 @@
{{> header}}
{{incrementCurrentTitleLevel}}
{{#with model.readme}}
{{{comment this}}}
@@ -2,6 +2,8 @@
{{> title}}
{{incrementCurrentTitleLevel}}
{{#with model}}
{{#if (sectionEnabled "reflection_comment")}}
@@ -18,7 +20,7 @@
{{#if (sectionEnabled "reflection_example")}}
{{{example model 2}}}
{{{example model}}}
{{/if}}
@@ -26,7 +28,7 @@
{{#if model.typeParameters}}
## Type parameters
{{{titleLevel}}} Type parameters
{{#with model.typeParameters}}
@@ -42,7 +44,7 @@
{{#ifShowTypeHierarchy}}
## Hierarchy
{{{titleLevel}}} Hierarchy
{{#with model.typeHierarchy}}
@@ -58,7 +60,7 @@
{{#if model.implementedTypes}}
## Implements
{{{titleLevel}}} Implements
{{#each model.implementedTypes}}
- {{{type}}}
@@ -72,7 +74,7 @@
{{#if model.implementedBy}}
## Implemented by
{{{titleLevel}}} Implemented by
{{#each model.implementedBy}}
- {{{type}}}
@@ -86,18 +88,26 @@
{{#if model.signatures}}
## Callable
{{{titleLevel}}} Callable
{{#with model}}
{{incrementCurrentTitleLevel}}
{{#each signatures}}
### {{name}}
{{{titleLevel}}} {{name}}
{{> member.signature showSources=true commentLevel=4 }}
{{incrementCurrentTitleLevel}}
{{> member.signature showSources=true }}
{{decrementCurrentTitleLevel}}
{{/each}}
{{decrementCurrentTitleLevel}}
{{/with}}
{{/if}}
@@ -108,16 +118,20 @@
{{#if model.indexSignature}}
## Indexable
{{{titleLevel}}} Indexable
{{#with model}}
{{#with indexSignature}}
{{incrementCurrentTitleLevel}}
{{{indexSignatureTitle}}}
{{> comment}}
{{decrementCurrentTitleLevel}}
{{/with}}
{{/with}}
@@ -4,6 +4,10 @@
{{#with model}}
{{> member showSources=false commentLevel=4}}
{{incrementCurrentTitleLevel}}
{{> member showSources=false}}
{{decrementCurrentTitleLevel}}
{{/with}}
@@ -54,6 +54,7 @@ export class MarkdownTheme extends Theme {
reflection?: DeclarationReflection
location!: string
anchorMap: Record<string, string[]> = {}
currentTitleLevel = 1
static URL_PREFIX = /^(http|ftp)s?:\/\//
@@ -355,6 +356,8 @@ export class MarkdownTheme extends Theme {
* @param page An event object describing the current render operation.
*/
protected onBeginPage(page: PageEvent) {
// reset header level counter
this.currentTitleLevel = 1
this.location = page.url
this.reflection =
page.model instanceof DeclarationReflection ? page.model : undefined
@@ -403,6 +406,10 @@ export class MarkdownTheme extends Theme {
return `modules.${this.mdxOutput ? "mdx" : "md"}`
}
setCurrentTitleLevel(value: number) {
this.currentTitleLevel = value
}
getFormattingOptionsForLocation(): FormattingOptionType {
if (!this.location) {
return {}
@@ -67,6 +67,7 @@ export type FormattingOptionType = {
kind: boolean
typeParameters: boolean
suffix?: string
fullReplacement?: string
}
reflectionDescription?: string
expandMembers?: boolean
@@ -109,7 +109,7 @@ export function reflectionComponentFormatter(
? getType(reflection.type, "object")
: getReflectionType(reflection, "object", true),
description: comments
? stripLineBreaks(Handlebars.helpers.comments(comments, true, false))
? Handlebars.helpers.comments(comments, true, false)
: "",
optional,
defaultValue,
@@ -230,8 +230,8 @@ export function getDefaultValue(
parameter.defaultValue !== "..."
? `${parameter.defaultValue}`
: defaultComment
? defaultComment.content.map((content) => stripCode(content.text)).join()
: null
? defaultComment.content.map((content) => stripCode(content.text)).join()
: null
}
export function hasDefaultValues(parameters: ReflectionParameterType[]) {
+1 -1
View File
@@ -18,7 +18,7 @@
},
"devDependencies": {
"@types/node": "^16.11.10",
"typescript": "^4.6"
"typescript": "5.2"
},
"dependencies": {
"rimraf": "^5.0.5"
@@ -21,7 +21,7 @@
"@mermaid-js/mermaid-cli": "^10.6.1",
"commander": "^11.1.0",
"ts-node": "^10.9.1",
"typescript": "^5.1.6"
"typescript": "5.2"
},
"devDependencies": {
"@types/node": "^20.9.4"
@@ -4,6 +4,7 @@ import * as path from "path"
import { existsSync, mkdirSync, rmSync, writeFileSync } from "fs"
import registerWorkflows from "../utils/register-workflows.js"
import DiagramBuilder from "../classes/diagram-builder.js"
// @ts-expect-error mermaid typing issue
import { run as runMermaid } from "@mermaid-js/mermaid-cli"
type Options = {
+13 -33
View File
@@ -3730,7 +3730,7 @@ __metadata:
typedoc-plugin-missing-exports: ^2.1.0
typedoc-plugin-reference-excluder: 1.1.3
typedoc-plugin-rename-defaults: ^0.6.6
typescript: ^5.2.2
typescript: 5.2
languageName: unknown
linkType: soft
@@ -4232,7 +4232,7 @@ __metadata:
eslint: ^8.53.0
glob: ^10.3.10
typedoc-plugin-markdown: ^3.16.0
typescript: ^4.6
typescript: 5.2
utils: "*"
yaml: ^2.3.3
peerDependencies:
@@ -4256,7 +4256,7 @@ __metadata:
"@types/node": ^16.11.10
copyfiles: ^2.4.1
handlebars: ^4.7.8
typescript: ^4.6
typescript: 5.2
utils: "*"
peerDependencies:
typedoc: 0.25.x
@@ -4337,43 +4337,23 @@ __metadata:
languageName: node
linkType: hard
"typescript@npm:^4.6":
version: 4.9.5
resolution: "typescript@npm:4.9.5"
"typescript@npm:5.2":
version: 5.2.2
resolution: "typescript@npm:5.2.2"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 5f6cad2e728a8a063521328e612d7876e12f0d8a8390d3b3aaa452a6a65e24e9ac8ea22beb72a924fd96ea0a49ea63bb4e251fb922b12eedfb7f7a26475e5c56
checksum: 91ae3e6193d0ddb8656d4c418a033f0f75dec5e077ebbc2bd6d76439b93f35683936ee1bdc0e9cf94ec76863aa49f27159b5788219b50e1cd0cd6d110aa34b07
languageName: node
linkType: hard
"typescript@npm:^5.1.6, typescript@npm:^5.2.2":
version: 5.3.2
resolution: "typescript@npm:5.3.2"
"typescript@patch:typescript@5.2#~builtin<compat/typescript>":
version: 5.2.2
resolution: "typescript@patch:typescript@npm%3A5.2.2#~builtin<compat/typescript>::version=5.2.2&hash=7ad353"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: d7dbe1fbe19039e36a65468ea64b5d338c976550394ba576b7af9c68ed40c0bc5d12ecce390e4b94b287a09a71bd3229f19c2d5680611f35b7c53a3898791159
languageName: node
linkType: hard
"typescript@patch:typescript@^4.6#~builtin<compat/typescript>":
version: 4.9.5
resolution: "typescript@patch:typescript@npm%3A4.9.5#~builtin<compat/typescript>::version=4.9.5&hash=7ad353"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 897c8ac656e01b132fa82be6a8e34c4507b19be63dbf1ff1d8287d775519081a7c91dd0ca3ec62536c8137228141d65b238dfb2e8987a3f5182818f58f83e7d7
languageName: node
linkType: hard
"typescript@patch:typescript@^5.1.6#~builtin<compat/typescript>, typescript@patch:typescript@^5.2.2#~builtin<compat/typescript>":
version: 5.3.2
resolution: "typescript@patch:typescript@npm%3A5.3.2#~builtin<compat/typescript>::version=5.3.2&hash=7ad353"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: c81b9bd20c6dbe90fa43e876c586021447f2b47baede9fa542b1f56715835c043e23b2eaf19c42c067cc6f5ae512bd9a9be28a67b3a1d9807f8c9cfb1269875e
checksum: 303979762f9b8932c53f8149e866521a1265168b5c0fde8cc8ad83ac3d0e8ede8096cb02dff5f2de048e7f118a6f61902f81da12d5972c7fb582f09f2f18d169
languageName: node
linkType: hard
@@ -4499,7 +4479,7 @@ __metadata:
dependencies:
"@types/node": ^16.11.10
rimraf: ^5.0.5
typescript: ^4.6
typescript: 5.2
peerDependencies:
typedoc: 0.25.x
languageName: unknown
@@ -4586,7 +4566,7 @@ __metadata:
"@types/node": ^20.9.4
commander: ^11.1.0
ts-node: ^10.9.1
typescript: ^5.1.6
typescript: 5.2
bin:
workflow-diagrams-generator: dist/index.js
languageName: unknown
@@ -7,33 +7,107 @@ type ShippingOptionData = Record<string, unknown>
type ShippingMethodData = Record<string, unknown>
/**
* Fulfillment Provider interface
* Fullfillment provider plugin services should extend the AbstractFulfillmentService from this file
* ## Overview
*
* A fulfillment provider is the shipping provider used to fulfill orders and deliver them to customers. An example of a fulfillment provider is FedEx.
*
* By default, a Medusa Backend has a `manual` fulfillment provider which has minimal implementation. It allows you to accept orders and fulfill them manually. However, you can integrate any fulfillment provider into Medusa, and your fulfillment provider can interact with third-party shipping providers.
*
* A fulfillment provider is a service that extends the `AbstractFulfillmentService` and implements its methods. So, adding a fulfillment provider is as simple as creating a service file in `src/services`.
* The file's name is the fulfillment provider's class name as a slug and without the word `Service`. For example, if you're creating a `MyFulfillmentService` class, the file name is `src/services/my-fulfillment.ts`.
*
* ```ts title=src/services/my-fulfillment.ts
* import { AbstractFulfillmentService } from "@medusajs/medusa"
*
* class MyFulfillmentService extends AbstractFulfillmentService {
* // methods here...
* }
* ```
*
* ---
*
* ## Identifier Property
*
* The `FulfillmentProvider` entity has 2 properties: `identifier` and `is_installed`. The `identifier` property in the class is used when the fulfillment provider is created in the database.
*
* The value of this property is also used to reference the fulfillment provider throughout Medusa. For example, it is used to [add a fulfillment provider](https://docs.medusajs.com/api/admin#regions_postregionsregionfulfillmentproviders) to a region.
*
* ```ts
* class MyFulfillmentService extends AbstractFulfillmentService {
* static identifier = "my-fulfillment"
*
* // ...
* }
* ```
*
* ---
*/
export interface FulfillmentService {
/**
* @ignore
*
* Return a unique identifier to retrieve the fulfillment plugin provider
*/
getIdentifier(): string
/**
* Called before a shipping option is created in Admin. The method should
* return all of the options that the fulfillment provider can be used with,
* and it is here the distinction between different shipping options are
* enforced. For example, a fulfillment provider may offer Standard Shipping
* and Express Shipping as fulfillment options, it is up to the store operator
* to create shipping options in Medusa that are offered to the customer.
* This method is used when retrieving the list of fulfillment options available in a region, particularly by the [List Fulfillment Options API Route](https://docs.medusajs.com/api/admin#regions_getregionsregionfulfillmentoptions).
* For example, if youre integrating UPS as a fulfillment provider, you might support two fulfillment options: UPS Express Shipping and UPS Access Point. Each of these options can have different data associated with them.
*
* @returns {Promise<any[]>} The list of fulfillment options. These options don't have any required format. Later on, these options can be used when creating a shipping option,
* such as when using the [Create Shipping Option API Route](https://docs.medusajs.com/api/admin#shipping-options_postshippingoptions). The chosen fulfillment option, which is one of the
* items in the array returned by this method, will be set in the `data` object of the shipping option.
*
* @example
* class MyFulfillmentService extends AbstractFulfillmentService {
* // ...
* async getFulfillmentOptions(): Promise<any[]> {
* return [
* {
* id: "my-fulfillment",
* },
* {
* id: "my-fulfillment-dynamic",
* },
* ]
* }
* }
*/
getFulfillmentOptions(): Promise<any[]>
/**
* Called before a shipping method is set on a cart to ensure that the data
* sent with the shipping method is valid. The data object may contain extra
* data about the shipment such as an id of a drop point. It is up to the
* fulfillment provider to enforce that the correct data is being sent
* through.
* @return the data to populate `cart.shipping_methods.$.data` this
* is usually important for future actions like generating shipping labels
* This method is called when a shipping method is created. This typically happens when the customer chooses a shipping option during checkout, when a shipping method is created
* for an order return, or in other similar cases. The shipping option and its data are validated before the shipping method is created.
*
* You can use the provided parameters to validate the chosen shipping option. For example, you can check if the `data` object passed as a second parameter includes all data needed to
* fulfill the shipment later on.
*
* If any of the data is invalid, you can throw an error. This error will stop Medusa from creating a shipping method and the error message will be returned as a result of the API Route.
*
* @param {ShippingOptionData} optionData - The data object of the shipping option selected when creating the shipping method.
* @param {FulfillmentProviderData} data - The `data` object passed in the body of the request.
* @param {Cart} cart - The customer's cart details. It may be empty if the shipping method isn't associated with a cart, such as when it's associated with a claim.
* @returns {Promise<Record<string, unknown>>} The data that will be stored in the `data` property of the shipping method to be created.
* Make sure the value you return contains everything you need to fulfill the shipment later on. The returned value may also be used to calculate the price of the shipping method
* if it doesn't have a set price. It will be passed along to the {@link calculatePrice} method.
*
* @example
* class MyFulfillmentService extends AbstractFulfillmentService {
* // ...
* async validateFulfillmentData(
* optionData: Record<string, unknown>,
* data: Record<string, unknown>,
* cart: Cart
* ): Promise<Record<string, unknown>> {
* if (data.id !== "my-fulfillment") {
* throw new Error("invalid data")
* }
*
* return {
* ...data,
* }
* }
* }
*/
validateFulfillmentData(
optionData: ShippingOptionData,
@@ -42,18 +116,95 @@ export interface FulfillmentService {
): Promise<Record<string, unknown>>
/**
* Called before a shipping option is created in Admin. Use this to ensure
* that a fulfillment option does in fact exist.
* Once the admin creates the shipping option, the data of the shipping option will be validated first using this method. This method is called when the [Create Shipping Option API Route](https://docs.medusajs.com/api/admin#shipping-options_postshippingoptions) is used.
*
* @param {ShippingOptionData} data - the data object that is sent in the body of the request, basically, the data object of the shipping option. You can use this data to validate the shipping option before it is saved.
* @returns {Promise<boolean>} Whether the fulfillment option is valid. If the returned value is false, an error is thrown and the shipping option will not be saved.
*
* @example
* For example, you can use this method to ensure that the `id` in the `data` object is correct:
*
* ```ts
* class MyFulfillmentService extends AbstractFulfillmentService {
* // ...
* async validateOption(
* data: Record<string, unknown>
* ): Promise<boolean> {
* return data.id == "my-fulfillment"
* }
* }
* ```
*/
validateOption(data: ShippingOptionData): Promise<boolean>
/**
* Used to determine if a shipping option can have a calculated price
* This method is used to determine whether a shipping option is calculated dynamically or flat rate. It is called if the `price_type` of the shipping option being created is set to calculated.
*
* @param {ShippingOptionData} data - The `data` object of the shipping option being created. You can use this data to determine whether the shipping option should be calculated or not.
* This is useful if the fulfillment provider you are integrating has both flat rate and dynamically priced fulfillment options.
* @returns {Promise<boolean>} If this method returns `true`, that means that the price can be calculated dynamically and the shipping option can have the `price_type` set to calculated.
* The amount property of the shipping option will then be set to null. The amount will be created later when the shipping method is created on checkout using the {@link calculatePrice} method.
* If the method returns `false`, an error is thrown as it means the selected shipping option is invalid and it can only have the `flat_rate` price type.
*
* @example
* class MyFulfillmentService extends AbstractFulfillmentService {
* // ...
* async canCalculate(
* data: Record<string, unknown>
* ): Promise<boolean> {
* return data.id === "my-fulfillment-dynamic"
* }
* }
*/
canCalculate(data: ShippingOptionData): Promise<boolean>
/**
* Used to calculate a price for a given shipping option.
* This method is used in different places, including:
*
* 1. When the shipping options for a cart are retrieved during checkout. If a shipping option has their `price_type` set to calculated, this method is used to set the amount of the returned shipping option.
* 2. When a shipping method is created. If the shipping option associated with the method has their `price_type` set to `calculated`, this method is used to set the `price` attribute of the shipping method in the database.
* 3. When the cart's totals are calculated.
*
* @param {ShippingOptionData} optionData - The `data` object of the selected shipping option.
* @param {FulfillmentProviderData} data -
* A `data` object that is different based on the context it's used in:
*
* 1. If the price is being calculated for the list of shipping options available for a cart, it's the `data` object of the shipping option.
* 2. If the price is being calculated when the shipping method is being created, it's the data returned by the {@link validateFulfillmentData} method used during the shipping method creation.
* 3. If the price is being calculated while calculating the cart's totals, it will be the data object of the cart's shipping method.
* @param {Cart} cart - Either the Cart or the Order object.
* @returns {Promise<number>} Used to set the price of the shipping method or option, based on the context the method is used in.
*
* @example
* An example of calculating the price based on some custom logic:
*
* ```ts
* class MyFulfillmentService extends AbstractFulfillmentService {
* // ...
* async calculatePrice(
* optionData: Record<string, unknown>,
* data: Record<string, unknown>,
* cart: Cart
* ): Promise<number> {
* return cart.items.length * 1000
* }
* }
* ```
*
* If your fulfillment provider does not provide any dynamically calculated rates you can return any static value or throw an error. For example:
*
* ```ts
* class MyFulfillmentService extends AbstractFulfillmentService {
* // ...
* async calculatePrice(
* optionData: Record<string, unknown>,
* data: Record<string, unknown>,
* cart: Cart
* ): Promise<number> {
* throw new Error("Method not implemented.")
* }
* }
* ```
*/
calculatePrice(
optionData: ShippingOptionData,
@@ -62,8 +213,38 @@ export interface FulfillmentService {
): Promise<number>
/**
* Create a fulfillment using data from shipping method, line items, and fulfillment. All from the order.
* The returned value of this method will populate the `fulfillment.data` field.
* This method is used when a fulfillment is created for an order, a claim, or a swap.
*
* @param {ShippingMethodData} data -
* The `data` object of the shipping method associated with the resource, such as the order.
* You can use it to access the data specific to the shipping option. This is based on your implementation of previous methods.
* @param {LineItem[]} items - The line items in the order to be fulfilled. The admin can choose all or some of the items to fulfill.
* @param {Order} order -
* The details of the created resource, which is either an order, a claim, or a swap:
* - If the resource the fulfillment is being created for is a claim, the `is_claim` property in the object will be `true`.
* - If the resource the fulfillment is being created for is a swap, the `is_swap` property in the object will be `true`.
* - Otherwise, the resource is an order.
* @param {Fulfillment} fulfillment - The fulfillment being created.
* @returns {Promise<FulfillmentProviderData>} The data that will be stored in the `data` attribute of the created fulfillment.
*
* @example
* Here is a basic implementation of `createFulfillment` for a fulfillment provider that does not interact with any third-party provider to create the fulfillment:
*
* ```ts
* class MyFulfillmentService extends AbstractFulfillmentService {
* // ...
* async createFulfillment(
* data: Record<string, unknown>,
* items: LineItem,
* order: Order,
* fulfillment: Fulfillment
* ) {
* // No data is being sent anywhere
* // No data to be stored in the fulfillment's data object
* return {}
* }
* }
* ```
*/
createFulfillment(
data: ShippingMethodData,
@@ -73,32 +254,133 @@ export interface FulfillmentService {
): Promise<FulfillmentProviderData>
/**
* Cancel a fulfillment using data from the fulfillment
* This method is called when a fulfillment is cancelled by the admin. This fulfillment can be for an order, a claim, or a swap.
*
* @param {FulfillmentProviderData} fulfillmentData - The `data` attribute of the fulfillment being canceled
* @returns {Promise<any>} The method isn't expected to return any specific data.
*
* @example
* This is the basic implementation of the method for a fulfillment provider that doesn't interact with a third-party provider to cancel the fulfillment:
*
* ```ts
* class MyFulfillmentService extends FulfillmentService {
* // ...
* async cancelFulfillment(
* fulfillment: Record<string, unknown>
* ): Promise<any> {
* return {}
* }
* }
* ```
*/
cancelFulfillment(fulfillmentData: FulfillmentProviderData): Promise<any>
/**
* Used to create a return order. Should return the data necessary for future
* operations on the return; in particular the data may be used to receive
* documents attached to the return.
* Fulfillment providers can also be used to return products. A shipping option can be used for returns if the `is_return` property is true or if an admin creates a Return Shipping Option from the settings.
* This method is used when the admin [creates a return request](https://docs.medusajs.com/api/admin#orders_postordersorderreturns) for an order,
* [creates a swap](https://docs.medusajs.com/api/admin#orders_postordersorderswaps) for an order, or when the
* [customer creates a return of their order](https://docs.medusajs.com/api/store#returns_postreturns). The fulfillment is created automatically for the order return.
*
* @param {CreateReturnType} returnOrder - the return that the fulfillment is being created for.
* @returns {Promise<Record<string, unknown>>} Used to set the value of the `shipping_data` attribute of the return being created.
*
* @example
* This is the basic implementation of the method for a fulfillment provider that does not contact with a third-party provider to fulfill the return:
*
* ```ts
* class MyFulfillmentService extends AbstractFulfillmentService {
* // ...
* async createReturn(
* returnOrder: CreateReturnType
* ): Promise<Record<string, unknown>> {
* return {}
* }
* }
* ```
*/
createReturn(returnOrder: CreateReturnType): Promise<Record<string, unknown>>
/**
* Used to retrieve documents associated with a fulfillment.
* This method is used to retrieve any documents associated with a fulfillment. This method isn't used by default in the backend, but you can use it for custom use cases such as allowing admins to download these documents.
*
* @param {FulfillmentProviderData} data - The `data` attribute of the fulfillment that you're retrieving the documents for.
* @returns {Promise<any>} There are no restrictions on the returned response. If your fulfillment provider doesn't provide this functionality, you can leave the method empty or through an error.
*
* @example
* class MyFulfillmentService extends FulfillmentService {
* // ...
* async getFulfillmentDocuments(
* data: Record<string, unknown>
* ): Promise<any> {
* // assuming you contact a client to
* // retrieve the document
* return this.client.getFulfillmentDocuments()
* }
* }
*/
getFulfillmentDocuments(data: FulfillmentProviderData): Promise<any>
/**
* Used to retrieve documents related to a return order.
* This method is used to retrieve any documents associated with a return. This method isn't used by default in the backend, but you can use it for custom use cases such as allowing admins to download these documents.
*
* @param {Record<string, unknown>} data - The data attribute of the return that you're retrieving the documents for.
* @returns {Promise<any>} There are no restrictions on the returned response. If your fulfillment provider doesn't provide this functionality, you can leave the method empty or through an error.
*
* @example
* class MyFulfillmentService extends FulfillmentService {
* // ...
* async getReturnDocuments(
* data: Record<string, unknown>
* ): Promise<any> {
* // assuming you contact a client to
* // retrieve the document
* return this.client.getReturnDocuments()
* }
* }
*/
getReturnDocuments(data: Record<string, unknown>): Promise<any>
/**
* Used to retrieve documents related to a shipment.
* This method is used to retrieve any documents associated with a shipment. This method isn't used by default in the backend, but you can use it for custom use cases such as allowing admins to download these documents.
*
* @param {Record<string, unknown>} data - The `data` attribute of the shipment that you're retrieving the documents for.
* @returns {Promise<any>} There are no restrictions on the returned response. If your fulfillment provider doesn't provide this functionality, you can leave the method empty or through an error.
*
* @example
* class MyFulfillmentService extends FulfillmentService {
* // ...
* async getShipmentDocuments(
* data: Record<string, unknown>
* ): Promise<any> {
* // assuming you contact a client to
* // retrieve the document
* return this.client.getShipmentDocuments()
* }
* }
*/
getShipmentDocuments(data: Record<string, unknown>): Promise<any>
/**
* This method is used to retrieve any documents associated with an order and its fulfillments. This method isn't used by default in the backend, but you can use it for
* custom use cases such as allowing admins to download these documents.
*
* @param {FulfillmentProviderData} fulfillmentData - The `data` attribute of the order's fulfillment.
* @param documentType - The type of document to retrieve.
* @returns {Promise<any>} There are no restrictions on the returned response. If your fulfillment provider doesn't provide this functionality, you can leave the method empty or through an error.
*
* @example
* class MyFulfillmentService extends FulfillmentService {
* // ...
* async retrieveDocuments(
* fulfillmentData: Record<string, unknown>,
* documentType: "invoice" | "label"
* ): Promise<any> {
* // assuming you contact a client to
* // retrieve the document
* return this.client.getDocuments()
* }
* }
*/
retrieveDocuments(
fulfillmentData: FulfillmentProviderData,
documentType: "invoice" | "label"
@@ -106,13 +388,42 @@ export interface FulfillmentService {
}
export abstract class AbstractFulfillmentService implements FulfillmentService {
/**
* You can use the `constructor` of your fulfillment provider to access the different services in Medusa through dependency injection.
* You can also use the constructor to initialize your integration with the third-party provider. For example, if you use a client to connect to the third-party providers APIs, you can initialize it in the constructor and use it in other methods in the service.
* Additionally, if youre creating your fulfillment provider as an external plugin to be installed on any Medusa backend and you want to access the options added for the plugin, you can access it in the constructor.
*
* @param {MedusaContainer} container - An instance of `MedusaContainer` that allows you to access other resources, such as services, in your Medusa backend.
* @param {Record<string, unknown>} config - If this fulfillment provider is created in a plugin, the plugin's options are passed in this parameter.
*
* @example
* class MyFulfillmentService extends AbstractFulfillmentService {
* static identifier = "my-fulfillment"
*
* // ...
* }
*/
protected constructor(
protected readonly container: MedusaContainer,
protected readonly config?: Record<string, unknown> // eslint-disable-next-line @typescript-eslint/no-empty-function
) {}
/**
* The `FulfillmentProvider` entity has 2 properties: `identifier` and `is_installed`. The `identifier` property in the class is used when the fulfillment provider is created in the database.
* The value of this property is also used to reference the fulfillment provider throughout Medusa. For example, it is used to [add a fulfillment provider](https://docs.medusajs.com/api/admin#regions_postregionsregionfulfillmentproviders) to a region.
*
* @example
* class MyFulfillmentService extends AbstractFulfillmentService {
* static identifier = "my-fulfillment"
*
* // ...
* }
*/
public static identifier: string
/**
* @ignore
*/
public getIdentifier(): string {
const ctr = this.constructor as typeof AbstractFulfillmentService
@@ -202,7 +202,7 @@ export interface UpdatePriceListDTO {
}
/**
* @inteface
* @interface
*
* Filters to apply on price lists.
*/
@@ -1,507 +0,0 @@
---
description: 'Learn how to create a fulfillment provider in the Medusa backend. This guide explains the different methods in the fulfillment provider.'
addHowToData: true
---
# How to Add a Fulfillment Provider
In this document, youll learn how to add a fulfillment provider to a Medusa backend. If youre unfamiliar with the Shipping architecture in Medusa, make sure to [check out the overview first](../shipping.md).
## Overview
A fulfillment provider is the shipping provider used to fulfill orders and deliver them to customers. An example of a fulfillment provider is FedEx.
By default, a Medusa Backend has a `manual` fulfillment provider which has minimal implementation. It allows you to accept orders and fulfill them manually. However, you can integrate any fulfillment provider into Medusa, and your fulfillment provider can interact with third-party shipping providers.
Adding a fulfillment provider is as simple as creating one [service](../../../development/services/create-service.mdx) file in `src/services`. A fulfillment provider is essentially a service that extends the `AbstractFulfillmentService`. It requires implementing 4 methods:
1. `getFulfillmentOptions`: used to retrieve available fulfillment options provided by this fulfillment provider.
2. `validateOption`: used to validate the shipping option when its being created by the admin.
3. `validateFulfillmentData`: used to validate a shipping method's data before it's created, typically during checkout.
4. `createFulfillment`: used to perform any additional actions when fulfillment is being created for an order, such as communicating with a third-party service.
There are other [useful methods](#useful-methods) that can be implemented based on your fulfillment provider's use case.
Also, the fulfillment provider class should have a static property `identifier`. It is the name that will be used to install and refer to the fulfillment provider throughout Medusa.
Fulfillment providers are loaded and installed on the backend startup.
---
## Create a Fulfillment Provider
The first step is to create a JavaScript or TypeScript file under `src/services`. For example, create the file `src/services/my-fulfillment.ts` with the following content:
```ts title="src/services/my-fulfillment.ts"
import {
AbstractFulfillmentService,
Cart,
Fulfillment,
LineItem,
Order,
} from "@medusajs/medusa"
import {
CreateReturnType,
} from "@medusajs/medusa/dist/types/fulfillment-provider"
class MyFulfillmentService extends AbstractFulfillmentService {
async getFulfillmentOptions(): Promise<any[]> {
throw new Error("Method not implemented.")
}
async validateFulfillmentData(
optionData: { [x: string]: unknown },
data: { [x: string]: unknown },
cart: Cart
): Promise<Record<string, unknown>> {
throw new Error("Method not implemented.")
}
async validateOption(
data: { [x: string]: unknown }
): Promise<boolean> {
throw new Error("Method not implemented.")
}
async canCalculate(
data: { [x: string]: unknown }
): Promise<boolean> {
throw new Error("Method not implemented.")
}
async calculatePrice(
optionData: { [x: string]: unknown },
data: { [x: string]: unknown },
cart: Cart
): Promise<number> {
throw new Error("Method not implemented.")
}
async createFulfillment(
data: { [x: string]: unknown },
items: LineItem,
order: Order,
fulfillment: Fulfillment
) {
throw new Error("Method not implemented.")
}
async cancelFulfillment(
fulfillment: { [x: string]: unknown }
): Promise<any> {
throw new Error("Method not implemented.")
}
async createReturn(
returnOrder: CreateReturnType
): Promise<Record<string, unknown>> {
throw new Error("Method not implemented.")
}
async getFulfillmentDocuments(
data: { [x: string]: unknown }
): Promise<any> {
throw new Error("Method not implemented.")
}
async getReturnDocuments(
data: Record<string, unknown>
): Promise<any> {
throw new Error("Method not implemented.")
}
async getShipmentDocuments(
data: Record<string, unknown>
): Promise<any> {
throw new Error("Method not implemented.")
}
async retrieveDocuments(
fulfillmentData: Record<string, unknown>,
documentType: "invoice" | "label"
): Promise<any> {
throw new Error("Method not implemented.")
}
}
export default MyFulfillmentService
```
Fulfillment provider services must extend the `AbstractFulfillmentService` class imported from `@medusajs/medusa`.
:::note
Following the naming convention of Services, the name of the file should be the slug name of the fulfillment provider, and the name of the class should be the camel case name of the fulfillment provider suffixed with “Service”. You can learn more in the [service documentation](../../../development/services/create-service.mdx).
:::
### Identifier
As mentioned in the overview, fulfillment providers should have a static `identifier` property.
The `FulfillmentProvider` entity has 2 properties: `identifier` and `is_installed`. The `identifier` property in the class will be used when the fulfillment provider is created in the database.
The value of this property will also be used to reference the fulfillment provider throughout Medusa. For example, it is used to [add a fulfillment provider](https://docs.medusajs.com/api/admin#regions_postregionsregionfulfillmentproviders) to a region.
```ts
class MyFulfillmentService extends AbstractFulfillmentService {
static identifier = "my-fulfillment"
// ...
}
```
### constructor
You can use the `constructor` of your fulfillment provider to have access to different services in Medusa through dependency injection. You can access any services you create in Medusa in the first parameter.
You can also use the constructor to initialize your integration with the third-party provider. For example, if you use a client to connect to the third-party providers APIs, you can initialize it in the constructor and use it in other methods in the service.
Additionally, if youre creating your fulfillment provider as an external plugin to be installed on any Medusa backend and you want to access the options added for the plugin, you can access it in the constructor. The options are passed as a second parameter.
For example:
```ts
class MyFulfillmentService extends AbstractFulfillmentService {
// ...
constructor(container, options) {
super()
// you can access options here
}
}
```
### getFulfillmentOptions
This method is used when retrieving the list of fulfillment options available in a region, particularly by the [List Fulfillment Options API Route](https://docs.medusajs.com/api/admin#regions_getregionsregionfulfillmentoptions).
For example, if youre integrating UPS as a fulfillment provider, you might support two fulfillment options: UPS Express Shipping and UPS Access Point. Each of these options can have different data associated with them.
This method is expected to return an array of options. These options don't have any required format.
Later on, these options can be used when creating a shipping option, such as when using the [Create Shipping Option API Route](https://docs.medusajs.com/api/admin#shipping-options_postshippingoptions). The chosen fulfillment option, which is one of the items in the array returned by this method, will be set in the `data` object of the shipping option.
For example:
```ts
class MyFulfillmentService extends AbstractFulfillmentService {
// ...
async getFulfillmentOptions(): Promise<any[]> {
return [
{
id: "my-fulfillment",
},
{
id: "my-fulfillment-dynamic",
},
]
}
}
```
### validateOption
Once the admin creates the shipping option, the data of the shipping option will be validated first using this method. This method is called when the [Create Shipping Option API Route](https://docs.medusajs.com/api/admin#shipping-options_postshippingoptions) is used.
This method accepts the `data` object that is sent in the body of the request, basically, the `data` object of the shipping option. You can use this data to validate the shipping option before it is saved.
This method returns a boolean. If the returned value is `false`, an error is thrown and the shipping option will not be saved.
For example, you can use this method to ensure that the `id` in the `data` object is correct:
```ts
class MyFulfillmentService extends AbstractFulfillmentService {
// ...
async validateOption(
data: { [x: string]: unknown }
): Promise<boolean> {
return data.id == "my-fulfillment"
}
}
```
If your fulfillment provider doesn't need to run any validation, you can simply return `true`.
### validateFulfillmentData
This method is called when a shipping method is created. This typically happens when the customer chooses a shipping option during checkout, when a shipping method is created for an order return, or in other similar cases. The shipping option and its data are validated before the shipping method is created.
This method accepts three parameters:
1. The first parameter is the `data` object of the shipping option selected when creating the shipping method.
2. The second parameter is `data` object passed in the body of the request.
3. The third parameter is an object indicating the customers cart data. It may be empty if the shipping method isn't associated with a cart, such as when it's associated with a claim.
You can use these parameters to validate the chosen shipping option. For example, you can check if the `data` object passed as a second parameter includes all data needed to fulfill the shipment later on.
If any of the data is invalid, you can throw an error. This error will stop Medusa from creating a shipping method and the error message will be returned as a result of the API Route.
If everything is valid, this method must return an object that will be stored in the `data` property of the shipping method to be created. So, make sure the value you return contains everything you need to fulfill the shipment later on.
The returned value may also be used to calculate the price of the shipping method if it doesn't have a set price. It will be passed along to the [calculatePrice](#calculateprice) method.
Here's an example implementation:
```ts
class MyFulfillmentService extends AbstractFulfillmentService {
// ...
async validateFulfillmentData(
optionData: { [x: string]: unknown },
data: { [x: string]: unknown },
cart: Cart
): Promise<Record<string, unknown>> {
if (data.id !== "my-fulfillment") {
throw new Error("invalid data")
}
return {
...data,
}
}
}
```
### createFulfillment
This method is used when a fulfillment is created for an order, a claim, or a swap.
It accepts four parameters:
1. The first parameter is the `data` object of the shipping method associated with the resource, such as the order.
2. The second parameter is the array of line item objects in the order to be fulfilled. The admin can choose all or some of the items to fulfill.
3. The third parameter is an object that includes data related to the order, claim, or swap this fulfillment is being created for.
1. If the resource the fulfillment is being created for is a claim, the `is_claim` property in the object will be `true`.
2. If the resource the fulfillment is being created for is a swap, the `is_swap` property in the object will be `true`.
3. Otherwise, the resource is an order.
4. The fourth parameter is an object of type [Fulfillment](../../../references/entities/classes/Fulfillment.mdx), which is the fulfillment being created.
You can use the `data` property in the shipping method (first parameter) to access the data specific to the shipping option. This is based on your implementation of previous methods.
This method must return an object of data that will be stored in the `data` attribute of the created fulfillment.
Here is a basic implementation of `createFulfillment` for a fulfillment provider that does not interact with any third-party provider to create the fulfillment:
```ts
class MyFulfillmentService extends AbstractFulfillmentService {
// ...
async createFulfillment(
data: { [x: string]: unknown },
items: LineItem,
order: Order,
fulfillment: Fulfillment
) {
// No data is being sent anywhere
// No data to be stored in the fulfillment's data object
return {}
}
}
```
### Useful Methods
The above-detailed methods are the required methods for every fulfillment provider. However, there are additional methods that you can use in your fulfillment provider to customize it further or add additional features.
#### canCalculate
This method is used to determine whether a shipping option is calculated dynamically or flat rate. It is called if the `price_type` of the shipping option being created is set to `calculated`.
This method accepts an object as a parameter, which is the `data` object of the shipping option being created. You can use this data to determine whether the shipping option should be calculated or not. This is useful if the fulfillment provider you are integrating has both flat rate and dynamically priced fulfillment options.
If this method returns `true`, that means that the price can be calculated dynamically and the shipping option can have the `price_type` set to `calculated`. The `amount` property of the shipping option will then be set to `null`. The amount will be created later when the shipping method is created on checkout using the [calculatePrice method](#calculateprice).
If the method returns `false`, an error is thrown as it means the selected shipping option is invalid and it can only have the `flat_rate` price type.
For example:
```ts
class MyFulfillmentService extends AbstractFulfillmentService {
// ...
async canCalculate(
data: { [x: string]: unknown }
): Promise<boolean> {
return data.id === "my-fulfillment-dynamic"
}
}
```
#### calculatePrice
This method is used in different places, including:
1. When the shipping options for a cart are retrieved during checkout. If a shipping option has their `price_type` set to `calculated`, this method is used to set the `amount` of the returned shipping option.
2. When a shipping method is created. If the shipping option associated with the method has their `price_type` set to `calculated`, this method is used to set the `price` attribute of the shipping method in the database.
3. When the cart's totals are calculated.
This method receives three parameters:
1. The first parameter is the `data` object of the selected shipping option.
2. The second parameter is a `data` object that is different based on the context it's used in:
1. If the price is being calculated for the list of shipping options available for a cart, it's the `data` object of the shipping option.
2. If the price is being calculated when the shipping method is being created, it's the data returned by the [validateFulfillmentData](#validatefulfillmentdata) method used during the shipping method creation.
3. If the price is being calculated while calculating the cart's totals, it will be the `data` object of the cart's shipping method.
3. The third parameter is either the [Cart](../../../references/entities/classes/Cart.mdx) or the [Order](../../../references/entities/classes/Order.mdx) object.
The method is expected to return a number that will be used to set the price of the shipping method or option, based on the context it's used in.
If your fulfillment provider does not provide any dynamically calculated rates you can return any static value or throw an error. For example:
```ts
class MyFulfillmentService extends AbstractFulfillmentService {
// ...
async calculatePrice(
optionData: { [x: string]: unknown },
data: { [x: string]: unknown },
cart: Cart
): Promise<number> {
throw new Error("Method not implemented.")
}
}
```
Otherwise, you can use it to calculate the price with custom logic. For example:
```ts
class MyFulfillmentService extends AbstractFulfillmentService {
// ...
async calculatePrice(
optionData: { [x: string]: unknown },
data: { [x: string]: unknown },
cart: Cart
): Promise<number> {
return cart.items.length * 1000
}
}
```
#### createReturn
Fulfillment providers can also be used to return products. A shipping option can be used for returns if the `is_return` property is `true` or if an admin creates a Return Shipping Option from the settings.
This method is used when the admin [creates a return request](https://docs.medusajs.com/api/admin#orders_postordersorderreturns) for an order, [creates a swap](https://docs.medusajs.com/api/admin#orders_postordersorderswaps) for an order, or when the customer [creates a return of their order](https://docs.medusajs.com/api/store#returns_postreturns). The fulfillment is created automatically for the order return.
The method receives as a parameter the [Return](../../../references/entities/classes/Return.mdx) object, which is the return that the fulfillment is being created for.
The method must return an object that will be used to set the value of the `shipping_data` attribute of the return being created.
This is the basic implementation of the method for a fulfillment provider that does not contact with a third-party provider to fulfill the return:
```ts
class MyFulfillmentService extends AbstractFulfillmentService {
// ...
async createReturn(
returnOrder: CreateReturnType
): Promise<Record<string, unknown>> {
return {}
}
}
```
#### cancelFulfillment
This method is called when a fulfillment is cancelled by the admin. This fulfillment can be for an order, a claim, or a swap.
The method receives the `data` attribute of the fulfillment being canceled. The method isn't expected to return any specific data.
This is the basic implementation of the method for a fulfillment provider that doesn't interact with a third-party provider to cancel the fulfillment:
```ts
class MyFulfillmentService extends FulfillmentService {
// ...
async cancelFulfillment(
fulfillment: { [x: string]: unknown }
): Promise<any> {
return {}
}
}
```
#### retrieveDocuments
This method is used to retrieve any documents associated with an order and its fulfillments. This method isn't used by default in the backend, but you can use it for custom use cases such as allowing admins to download these documents.
The method accepts two parameters:
1. The first parameter is the `data` attribute of the order's fulfillment.
2. The second parameter is a string indicating the type of document to retrieve. Possible values are `invoice` and `label`.
There are no restrictions on the returned response. If your fulfillment provider doesn't provide this functionality, you can leave the method empty or through an error.
For example:
```ts
class MyFulfillmentService extends FulfillmentService {
// ...
async retrieveDocuments(
fulfillmentData: Record<string, unknown>,
documentType: "invoice" | "label"
): Promise<any> {
// assuming you contact a client to
// retrieve the document
return this.client.getDocuments()
}
}
```
#### getFulfillmentDocuments
This method is used to retrieve any documents associated with a fulfillment. This method isn't used by default in the backend, but you can use it for custom use cases such as allowing admins to download these documents.
The method accepts the `data` attribute of the fulfillment that you're retrieving the documents for.
There are no restrictions on the returned response. If your fulfillment provider doesn't provide this functionality, you can leave the method empty or through an error.
For example:
```ts
class MyFulfillmentService extends FulfillmentService {
// ...
async getFulfillmentDocuments(
data: { [x: string]: unknown }
): Promise<any> {
// assuming you contact a client to
// retrieve the document
return this.client.getFulfillmentDocuments()
}
}
```
#### getReturnDocuments
This method is used to retrieve any documents associated with a return. This method isn't used by default in the backend, but you can use it for custom use cases such as allowing admins to download these documents.
The method accepts the `data` attribute of the return that you're retrieving the documents for.
There are no restrictions on the returned response. If your fulfillment provider doesn't provide this functionality, you can leave the method empty or through an error.
For example:
```ts
class MyFulfillmentService extends FulfillmentService {
// ...
async getReturnDocuments(
data: Record<string, unknown>
): Promise<any> {
// assuming you contact a client to
// retrieve the document
return this.client.getReturnDocuments()
}
}
```
#### getShipmentDocuments
This method is used to retrieve any documents associated with a shipment. This method isn't used by default in the backend, but you can use it for custom use cases such as allowing admins to download these documents.
The method accepts the `data` attribute of the shipment that you're retrieving the documents for.
There are no restrictions on the returned response. If your fulfillment provider doesn't provide this functionality, you can leave the method empty or through an error.
For example:
```ts
class MyFulfillmentService extends FulfillmentService {
// ...
async getShipmentDocuments(
data: Record<string, unknown>
): Promise<any> {
// assuming you contact a client to
// retrieve the document
return this.client.getShipmentDocuments()
}
}
```
---
## See Also
- Example Implementations: [Webshipper plugin](https://github.com/medusajs/medusa/tree/master/packages/medusa-fulfillment-webshipper) and the [manual fulfillment plugin](https://github.com/medusajs/medusa/tree/master/packages/medusa-fulfillment-manual)
@@ -153,5 +153,5 @@ The `ShippingMethod` instance holds a `price` attribute, which will either b
## See Also
- [Create a Fulfillment Provider](./backend/add-fulfillment-provider.md)
- [Create a Fulfillment Provider](../../references/fulfillment/classes/AbstractFulfillmentService.mdx)
- [Available shipping plugins](https://github.com/medusajs/medusa/tree/master/packages)
@@ -10,7 +10,7 @@ In this document, youll learn about Fulfillments, how theyre used in your
Fulfillments are used to ship items, typically to a customer. Fulfillments can be used in orders, returns, swaps, and more.
Fulfillments are processed within Medusa by a [fulfillment provider](../carts-and-checkout/backend/add-fulfillment-provider.md). The fulfillment provider handles creating, validating, and processing the fulfillment, among other functionalities. Typically, a fulfillment provider would be integrated with a third-party service that handles the actual shipping of the items.
Fulfillments are processed within Medusa by a [fulfillment provider](../../references/fulfillment/classes/AbstractFulfillmentService.mdx). The fulfillment provider handles creating, validating, and processing the fulfillment, among other functionalities. Typically, a fulfillment provider would be integrated with a third-party service that handles the actual shipping of the items.
When a fulfillment is created for one or more item, shipments can then be created for that fulfillment. These shipments can then be tracked using tracking numbers, providing customers and merchants accurate details about a shipment.
@@ -2,6 +2,6 @@ import DocCardList from '@theme/DocCardList';
# Fulfillment Plugins
If you can't find your fulfillment provider, try checking the [Community Plugins Library](https://medusajs.com/plugins/?filters=Shipping&categories=Shipping). You can also [create your own fulfillment provider](../../modules/carts-and-checkout/backend/add-fulfillment-provider.md).
If you can't find your fulfillment provider, try checking the [Community Plugins Library](https://medusajs.com/plugins/?filters=Shipping&categories=Shipping). You can also [create your own fulfillment provider](../../references/fulfillment/classes/AbstractFulfillmentService.mdx).
<DocCardList />
@@ -10,7 +10,7 @@ The scope that the discount should apply to.
## Enumeration Members
#### ITEM
### ITEM
**ITEM** = `"item"`
@@ -18,7 +18,7 @@ The discount should be applied to applicable items in the cart.
___
#### TOTAL
### TOTAL
**TOTAL** = `"total"`
@@ -8,42 +8,42 @@ import ParameterTypes from "@site/src/components/ParameterTypes"
## Enumeration Members
#### CANCELED
### CANCELED
**CANCELED** = `"canceled"`
___
#### COMPLETED
### COMPLETED
**COMPLETED** = `"completed"`
___
#### CONFIRMED
### CONFIRMED
**CONFIRMED** = `"confirmed"`
___
#### CREATED
### CREATED
**CREATED** = `"created"`
___
#### FAILED
### FAILED
**FAILED** = `"failed"`
___
#### PRE\_PROCESSED
### PRE\_PROCESSED
**PRE\_PROCESSED** = `"pre_processed"`
___
#### PROCESSING
### PROCESSING
**PROCESSING** = `"processing"`
@@ -8,30 +8,30 @@ import ParameterTypes from "@site/src/components/ParameterTypes"
## Enumeration Members
#### CLAIM
### CLAIM
**CLAIM** = `"claim"`
___
#### DEFAULT
### DEFAULT
**DEFAULT** = `"default"`
___
#### DRAFT\_ORDER
### DRAFT\_ORDER
**DRAFT\_ORDER** = `"draft_order"`
___
#### PAYMENT\_LINK
### PAYMENT\_LINK
**PAYMENT\_LINK** = `"payment_link"`
___
#### SWAP
### SWAP
**SWAP** = `"swap"`
@@ -10,7 +10,7 @@ The claim's fulfillment status.
## Enumeration Members
#### CANCELED
### CANCELED
**CANCELED** = `"canceled"`
@@ -18,7 +18,7 @@ The claim's fulfillments are canceled.
___
#### FULFILLED
### FULFILLED
**FULFILLED** = `"fulfilled"`
@@ -26,7 +26,7 @@ The claim's replacement items are fulfilled.
___
#### NOT\_FULFILLED
### NOT\_FULFILLED
**NOT\_FULFILLED** = `"not_fulfilled"`
@@ -34,7 +34,7 @@ The claim's replacement items are not fulfilled.
___
#### PARTIALLY\_FULFILLED
### PARTIALLY\_FULFILLED
**PARTIALLY\_FULFILLED** = `"partially_fulfilled"`
@@ -42,7 +42,7 @@ Some of the claim's replacement items, but not all, are fulfilled.
___
#### PARTIALLY\_RETURNED
### PARTIALLY\_RETURNED
**PARTIALLY\_RETURNED** = `"partially_returned"`
@@ -50,7 +50,7 @@ Some of the claim's items, but not all, are returned.
___
#### PARTIALLY\_SHIPPED
### PARTIALLY\_SHIPPED
**PARTIALLY\_SHIPPED** = `"partially_shipped"`
@@ -58,7 +58,7 @@ Some of the claim's replacement items, but not all, are shipped.
___
#### REQUIRES\_ACTION
### REQUIRES\_ACTION
**REQUIRES\_ACTION** = `"requires_action"`
@@ -66,7 +66,7 @@ The claim's fulfillment requires action.
___
#### RETURNED
### RETURNED
**RETURNED** = `"returned"`
@@ -74,7 +74,7 @@ The claim's items are returned.
___
#### SHIPPED
### SHIPPED
**SHIPPED** = `"shipped"`
@@ -10,7 +10,7 @@ The claim's payment status
## Enumeration Members
#### NA
### NA
**NA** = `"na"`
@@ -18,7 +18,7 @@ The payment status isn't set, which is typically used when the claim's type is `
___
#### NOT\_REFUNDED
### NOT\_REFUNDED
**NOT\_REFUNDED** = `"not_refunded"`
@@ -26,7 +26,7 @@ The payment isn't refunded.
___
#### REFUNDED
### REFUNDED
**REFUNDED** = `"refunded"`
@@ -8,24 +8,24 @@ import ParameterTypes from "@site/src/components/ParameterTypes"
## Enumeration Members
#### MISSING\_ITEM
### MISSING\_ITEM
**MISSING\_ITEM** = `"missing_item"`
___
#### OTHER
### OTHER
**OTHER** = `"other"`
___
#### PRODUCTION\_FAILURE
### PRODUCTION\_FAILURE
**PRODUCTION\_FAILURE** = `"production_failure"`
___
#### WRONG\_ITEM
### WRONG\_ITEM
**WRONG\_ITEM** = `"wrong_item"`
@@ -10,7 +10,7 @@ The claim's type.
## Enumeration Members
#### REFUND
### REFUND
**REFUND** = `"refund"`
@@ -18,7 +18,7 @@ The claim refunds an amount to the customer.
___
#### REPLACE
### REPLACE
**REPLACE** = `"replace"`
@@ -10,7 +10,7 @@ The possible operators used for a discount condition.
## Enumeration Members
#### IN
### IN
**IN** = `"in"`
@@ -18,7 +18,7 @@ The discountable resources are within the specified resources.
___
#### NOT\_IN
### NOT\_IN
**NOT\_IN** = `"not_in"`
@@ -10,7 +10,7 @@ The discount condition's type.
## Enumeration Members
#### CUSTOMER\_GROUPS
### CUSTOMER\_GROUPS
**CUSTOMER\_GROUPS** = `"customer_groups"`
@@ -18,7 +18,7 @@ The discount condition is used for customer groups.
___
#### PRODUCTS
### PRODUCTS
**PRODUCTS** = `"products"`
@@ -26,7 +26,7 @@ The discount condition is used for products.
___
#### PRODUCT\_COLLECTIONS
### PRODUCT\_COLLECTIONS
**PRODUCT\_COLLECTIONS** = `"product_collections"`
@@ -34,7 +34,7 @@ The discount condition is used for product collections.
___
#### PRODUCT\_TAGS
### PRODUCT\_TAGS
**PRODUCT\_TAGS** = `"product_tags"`
@@ -42,7 +42,7 @@ The discount condition is used for product tags.
___
#### PRODUCT\_TYPES
### PRODUCT\_TYPES
**PRODUCT\_TYPES** = `"product_types"`
@@ -10,7 +10,7 @@ The possible types of discount rules.
## Enumeration Members
#### FIXED
### FIXED
**FIXED** = `"fixed"`
@@ -18,7 +18,7 @@ Discounts that reduce the price by a fixed amount.
___
#### FREE\_SHIPPING
### FREE\_SHIPPING
**FREE\_SHIPPING** = `"free_shipping"`
@@ -26,7 +26,7 @@ Discounts that sets the shipping price to `0`.
___
#### PERCENTAGE
### PERCENTAGE
**PERCENTAGE** = `"percentage"`
@@ -10,7 +10,7 @@ The draft order's status.
## Enumeration Members
#### COMPLETED
### COMPLETED
**COMPLETED** = `"completed"`
@@ -18,7 +18,7 @@ The draft order is completed, and an order has been created from it.
___
#### OPEN
### OPEN
**OPEN** = `"open"`
@@ -10,7 +10,7 @@ The order's fulfillment status.
## Enumeration Members
#### CANCELED
### CANCELED
**CANCELED** = `"canceled"`
@@ -18,7 +18,7 @@ The order's fulfillments are canceled.
___
#### FULFILLED
### FULFILLED
**FULFILLED** = `"fulfilled"`
@@ -26,7 +26,7 @@ The order's items are fulfilled.
___
#### NOT\_FULFILLED
### NOT\_FULFILLED
**NOT\_FULFILLED** = `"not_fulfilled"`
@@ -34,7 +34,7 @@ The order's items are not fulfilled.
___
#### PARTIALLY\_FULFILLED
### PARTIALLY\_FULFILLED
**PARTIALLY\_FULFILLED** = `"partially_fulfilled"`
@@ -42,7 +42,7 @@ Some of the order's items, but not all, are fulfilled.
___
#### PARTIALLY\_RETURNED
### PARTIALLY\_RETURNED
**PARTIALLY\_RETURNED** = `"partially_returned"`
@@ -50,7 +50,7 @@ Some of the order's items, but not all, are returned.
___
#### PARTIALLY\_SHIPPED
### PARTIALLY\_SHIPPED
**PARTIALLY\_SHIPPED** = `"partially_shipped"`
@@ -58,7 +58,7 @@ Some of the order's items, but not all, are shipped.
___
#### REQUIRES\_ACTION
### REQUIRES\_ACTION
**REQUIRES\_ACTION** = `"requires_action"`
@@ -66,7 +66,7 @@ The order's fulfillment requires action.
___
#### RETURNED
### RETURNED
**RETURNED** = `"returned"`
@@ -74,7 +74,7 @@ The order's items are returned.
___
#### SHIPPED
### SHIPPED
**SHIPPED** = `"shipped"`
@@ -10,7 +10,7 @@ The type of the order edit item change.
## Enumeration Members
#### ITEM\_ADD
### ITEM\_ADD
**ITEM\_ADD** = `"item_add"`
@@ -18,7 +18,7 @@ A new item to be added to the original order.
___
#### ITEM\_REMOVE
### ITEM\_REMOVE
**ITEM\_REMOVE** = `"item_remove"`
@@ -26,7 +26,7 @@ An existing item to be removed from the original order.
___
#### ITEM\_UPDATE
### ITEM\_UPDATE
**ITEM\_UPDATE** = `"item_update"`
@@ -10,7 +10,7 @@ The order edit's status.
## Enumeration Members
#### CANCELED
### CANCELED
**CANCELED** = `"canceled"`
@@ -18,7 +18,7 @@ The order edit is canceled.
___
#### CONFIRMED
### CONFIRMED
**CONFIRMED** = `"confirmed"`
@@ -26,7 +26,7 @@ The order edit is confirmed.
___
#### CREATED
### CREATED
**CREATED** = `"created"`
@@ -34,7 +34,7 @@ The order edit is created.
___
#### DECLINED
### DECLINED
**DECLINED** = `"declined"`
@@ -42,7 +42,7 @@ The order edit is declined.
___
#### REQUESTED
### REQUESTED
**REQUESTED** = `"requested"`
@@ -10,7 +10,7 @@ The order's status.
## Enumeration Members
#### ARCHIVED
### ARCHIVED
**ARCHIVED** = `"archived"`
@@ -18,7 +18,7 @@ The order is archived.
___
#### CANCELED
### CANCELED
**CANCELED** = `"canceled"`
@@ -26,7 +26,7 @@ The order is canceled.
___
#### COMPLETED
### COMPLETED
**COMPLETED** = `"completed"`
@@ -36,7 +36,7 @@ has been captured.
___
#### PENDING
### PENDING
**PENDING** = `"pending"`
@@ -44,7 +44,7 @@ The order is pending.
___
#### REQUIRES\_ACTION
### REQUIRES\_ACTION
**REQUIRES\_ACTION** = `"requires_action"`
@@ -10,7 +10,7 @@ The payment collection's status.
## Enumeration Members
#### AUTHORIZED
### AUTHORIZED
**AUTHORIZED** = `"authorized"`
@@ -18,7 +18,7 @@ The payment colleciton is authorized.
___
#### AWAITING
### AWAITING
**AWAITING** = `"awaiting"`
@@ -26,7 +26,7 @@ The payment collection is awaiting payment.
___
#### CANCELED
### CANCELED
**CANCELED** = `"canceled"`
@@ -34,7 +34,7 @@ The payment collection is canceled.
___
#### NOT\_PAID
### NOT\_PAID
**NOT\_PAID** = `"not_paid"`
@@ -42,7 +42,7 @@ The payment collection isn't paid.
___
#### PARTIALLY\_AUTHORIZED
### PARTIALLY\_AUTHORIZED
**PARTIALLY\_AUTHORIZED** = `"partially_authorized"`
@@ -10,7 +10,7 @@ The payment collection's type.
## Enumeration Members
#### ORDER\_EDIT
### ORDER\_EDIT
**ORDER\_EDIT** = `"order_edit"`
@@ -8,30 +8,30 @@ import ParameterTypes from "@site/src/components/ParameterTypes"
## Enumeration Members
#### AUTHORIZED
### AUTHORIZED
**AUTHORIZED** = `"authorized"`
___
#### CANCELED
### CANCELED
**CANCELED** = `"canceled"`
___
#### ERROR
### ERROR
**ERROR** = `"error"`
___
#### PENDING
### PENDING
**PENDING** = `"pending"`
___
#### REQUIRES\_MORE
### REQUIRES\_MORE
**REQUIRES\_MORE** = `"requires_more"`
@@ -10,7 +10,7 @@ The order's payment status.
## Enumeration Members
#### AWAITING
### AWAITING
**AWAITING** = `"awaiting"`
@@ -18,7 +18,7 @@ The order's payment is awaiting capturing.
___
#### CANCELED
### CANCELED
**CANCELED** = `"canceled"`
@@ -26,7 +26,7 @@ The order's payment is canceled.
___
#### CAPTURED
### CAPTURED
**CAPTURED** = `"captured"`
@@ -34,7 +34,7 @@ The order's payment is captured.
___
#### NOT\_PAID
### NOT\_PAID
**NOT\_PAID** = `"not_paid"`
@@ -42,7 +42,7 @@ The order's payment is not paid.
___
#### PARTIALLY\_REFUNDED
### PARTIALLY\_REFUNDED
**PARTIALLY\_REFUNDED** = `"partially_refunded"`
@@ -50,7 +50,7 @@ Some of the order's payment amount is refunded.
___
#### REFUNDED
### REFUNDED
**REFUNDED** = `"refunded"`
@@ -58,7 +58,7 @@ The order's payment amount is refunded.
___
#### REQUIRES\_ACTION
### REQUIRES\_ACTION
**REQUIRES\_ACTION** = `"requires_action"`
@@ -8,12 +8,12 @@ import ParameterTypes from "@site/src/components/ParameterTypes"
## Enumeration Members
#### ACTIVE
### ACTIVE
**ACTIVE** = `"active"`
___
#### DRAFT
### DRAFT
**DRAFT** = `"draft"`
@@ -8,12 +8,12 @@ import ParameterTypes from "@site/src/components/ParameterTypes"
## Enumeration Members
#### OVERRIDE
### OVERRIDE
**OVERRIDE** = `"override"`
___
#### SALE
### SALE
**SALE** = `"sale"`
@@ -10,7 +10,7 @@ The status of a product.
## Enumeration Members
#### DRAFT
### DRAFT
**DRAFT** = `"draft"`
@@ -18,7 +18,7 @@ The product is a draft. It's not viewable by customers.
___
#### PROPOSED
### PROPOSED
**PROPOSED** = `"proposed"`
@@ -26,7 +26,7 @@ The product is proposed, but not yet published.
___
#### PUBLISHED
### PUBLISHED
**PUBLISHED** = `"published"`
@@ -34,7 +34,7 @@ The product is published.
___
#### REJECTED
### REJECTED
**REJECTED** = `"rejected"`
@@ -10,7 +10,7 @@ The reason of the refund.
## Enumeration Members
#### CLAIM
### CLAIM
**CLAIM** = `"claim"`
@@ -18,7 +18,7 @@ The refund is applied because of a created claim.
___
#### DISCOUNT
### DISCOUNT
**DISCOUNT** = `"discount"`
@@ -26,7 +26,7 @@ The refund is applied as a discount.
___
#### OTHER
### OTHER
**OTHER** = `"other"`
@@ -34,7 +34,7 @@ The refund is created for a custom reason.
___
#### RETURN
### RETURN
**RETURN** = `"return"`
@@ -42,7 +42,7 @@ The refund is applied because of a created return.
___
#### SWAP
### SWAP
**SWAP** = `"swap"`
@@ -10,7 +10,7 @@ The type of shipping option requirement.
## Enumeration Members
#### MAX\_SUBTOTAL
### MAX\_SUBTOTAL
**MAX\_SUBTOTAL** = `"max_subtotal"`
@@ -18,7 +18,7 @@ The shipping option can only be applied if the subtotal is less than the require
___
#### MIN\_SUBTOTAL
### MIN\_SUBTOTAL
**MIN\_SUBTOTAL** = `"min_subtotal"`
@@ -10,7 +10,7 @@ The return's status.
## Enumeration Members
#### CANCELED
### CANCELED
**CANCELED** = `"canceled"`
@@ -18,7 +18,7 @@ The return is canceled.
___
#### RECEIVED
### RECEIVED
**RECEIVED** = `"received"`
@@ -26,7 +26,7 @@ The return is received.
___
#### REQUESTED
### REQUESTED
**REQUESTED** = `"requested"`
@@ -34,7 +34,7 @@ The return is requested.
___
#### REQUIRES\_ACTION
### REQUIRES\_ACTION
**REQUIRES\_ACTION** = `"requires_action"`
@@ -10,7 +10,7 @@ The type of the shipping option price.
## Enumeration Members
#### CALCULATED
### CALCULATED
**CALCULATED** = `"calculated"`
@@ -18,7 +18,7 @@ The shipping option's price is calculated. In this case, the `amount` field is t
___
#### FLAT\_RATE
### FLAT\_RATE
**FLAT\_RATE** = `"flat_rate"`
@@ -10,7 +10,7 @@ The shipping profile's type.
## Enumeration Members
#### CUSTOM
### CUSTOM
**CUSTOM** = `"custom"`
@@ -18,7 +18,7 @@ The profile used to ship custom items.
___
#### DEFAULT
### DEFAULT
**DEFAULT** = `"default"`
@@ -26,7 +26,7 @@ The default profile used to ship item.
___
#### GIFT\_CARD
### GIFT\_CARD
**GIFT\_CARD** = `"gift_card"`
@@ -10,7 +10,7 @@ The swap's fulfillment status.
## Enumeration Members
#### CANCELED
### CANCELED
**CANCELED** = `"canceled"`
@@ -18,7 +18,7 @@ The swap's fulfillments are canceled.
___
#### FULFILLED
### FULFILLED
**FULFILLED** = `"fulfilled"`
@@ -26,7 +26,7 @@ The swap's items are fulfilled.
___
#### NOT\_FULFILLED
### NOT\_FULFILLED
**NOT\_FULFILLED** = `"not_fulfilled"`
@@ -34,7 +34,7 @@ The swap's items aren't fulfilled.
___
#### PARTIALLY\_SHIPPED
### PARTIALLY\_SHIPPED
**PARTIALLY\_SHIPPED** = `"partially_shipped"`
@@ -42,7 +42,7 @@ Some of the swap's items are shipped.
___
#### REQUIRES\_ACTION
### REQUIRES\_ACTION
**REQUIRES\_ACTION** = `"requires_action"`
@@ -50,7 +50,7 @@ The swap's fulfillments require an action.
___
#### SHIPPED
### SHIPPED
**SHIPPED** = `"shipped"`
@@ -10,7 +10,7 @@ The swap's payment status.
## Enumeration Members
#### AWAITING
### AWAITING
**AWAITING** = `"awaiting"`
@@ -18,7 +18,7 @@ The swap is additional awaiting payment.
___
#### CANCELED
### CANCELED
**CANCELED** = `"canceled"`
@@ -26,7 +26,7 @@ The swap's additional payment is canceled.
___
#### CAPTURED
### CAPTURED
**CAPTURED** = `"captured"`
@@ -34,7 +34,7 @@ The swap's additional payment is captured.
___
#### CONFIRMED
### CONFIRMED
**CONFIRMED** = `"confirmed"`
@@ -42,7 +42,7 @@ The swap's additional payment is confirmed.
___
#### DIFFERENCE\_REFUNDED
### DIFFERENCE\_REFUNDED
**DIFFERENCE\_REFUNDED** = `"difference_refunded"`
@@ -50,7 +50,7 @@ The negative difference amount between the returned item(s) and the new one(s) h
___
#### NOT\_PAID
### NOT\_PAID
**NOT\_PAID** = `"not_paid"`
@@ -58,7 +58,7 @@ The swap's additional payment isn't paid.
___
#### PARTIALLY\_REFUNDED
### PARTIALLY\_REFUNDED
**PARTIALLY\_REFUNDED** = `"partially_refunded"`
@@ -66,7 +66,7 @@ Some of the negative difference amount between the returned item(s) and the new
___
#### REFUNDED
### REFUNDED
**REFUNDED** = `"refunded"`
@@ -74,7 +74,7 @@ The amount in the associated order has been refunded.
___
#### REQUIRES\_ACTION
### REQUIRES\_ACTION
**REQUIRES\_ACTION** = `"requires_action"`
@@ -10,7 +10,7 @@ The user's role. These roles don't change the user's capabilities or provide acc
## Enumeration Members
#### ADMIN
### ADMIN
**ADMIN** = `"admin"`
@@ -18,7 +18,7 @@ The user is an admin.
___
#### DEVELOPER
### DEVELOPER
**DEVELOPER** = `"developer"`
@@ -26,7 +26,7 @@ The user is a developer.
___
#### MEMBER
### MEMBER
**MEMBER** = `"member"`
@@ -135,13 +135,15 @@ import ParameterTypes from "@site/src/components/ParameterTypes"
- [BatchJobResultStatDescriptor](types/BatchJobResultStatDescriptor.mdx)
- [Record](types/Record.mdx)
___
## Functions
#### Boolean
### Boolean
`**Boolean**<TypeParameter T>(value?): boolean`
##### Type Parameters
#### Type Parameters
<ParameterTypes parameters={[
{
@@ -155,7 +157,7 @@ import ParameterTypes from "@site/src/components/ParameterTypes"
}
]} />
##### Parameters
#### Parameters
<ParameterTypes parameters={[
{
@@ -169,7 +171,7 @@ import ParameterTypes from "@site/src/components/ParameterTypes"
}
]} />
##### Returns
#### Returns
`boolean`
@@ -8,11 +8,11 @@ import ParameterTypes from "@site/src/components/ParameterTypes"
**BatchJobResultError**: `Object`
#### Index signature
## Index signature
▪ [key: `string`]: `unknown`
#### Type declaration
## Type declaration
<ParameterTypes parameters={[
{
@@ -8,7 +8,7 @@ import ParameterTypes from "@site/src/components/ParameterTypes"
**BatchJobResultStatDescriptor**: `Object`
#### Type declaration
## Type declaration
<ParameterTypes parameters={[
{
@@ -10,7 +10,7 @@ import ParameterTypes from "@site/src/components/ParameterTypes"
Construct a type with a set of properties K of type T
#### Type Parameters
## Type Parameters
<ParameterTypes parameters={[
{
@@ -0,0 +1 @@
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.
@@ -0,0 +1,180 @@
---
displayed_sidebar: modules
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# Fulfillment Provider Reference
## Enumerations
- [AllocationType](enums/AllocationType.mdx)
- [CartType](enums/CartType.mdx)
- [ClaimFulfillmentStatus](enums/ClaimFulfillmentStatus.mdx)
- [ClaimPaymentStatus](enums/ClaimPaymentStatus.mdx)
- [ClaimReason](enums/ClaimReason.mdx)
- [ClaimType](enums/ClaimType.mdx)
- [DiscountConditionOperator](enums/DiscountConditionOperator.mdx)
- [DiscountConditionType](enums/DiscountConditionType.mdx)
- [DiscountRuleType](enums/DiscountRuleType.mdx)
- [DraftOrderStatus](enums/DraftOrderStatus.mdx)
- [FulfillmentStatus](enums/FulfillmentStatus.mdx)
- [OrderEditItemChangeType](enums/OrderEditItemChangeType.mdx)
- [OrderEditStatus](enums/OrderEditStatus.mdx)
- [OrderStatus](enums/OrderStatus.mdx)
- [PaymentCollectionStatus](enums/PaymentCollectionStatus.mdx)
- [PaymentStatus](enums/PaymentStatus.mdx)
- [PriceListStatus](enums/PriceListStatus.mdx)
- [PriceListType](enums/PriceListType.mdx)
- [ProductStatus](enums/ProductStatus.mdx)
- [RequirementType](enums/RequirementType.mdx)
- [ReturnStatus](enums/ReturnStatus.mdx)
- [ShippingOptionPriceType](enums/ShippingOptionPriceType.mdx)
- [ShippingProfileType](enums/ShippingProfileType.mdx)
- [SwapFulfillmentStatus](enums/SwapFulfillmentStatus.mdx)
- [SwapPaymentStatus](enums/SwapPaymentStatus.mdx)
## Classes
- [AbstractFulfillmentService](classes/AbstractFulfillmentService.mdx)
- [Address](classes/Address.mdx)
- [BaseEntity](classes/BaseEntity.mdx)
- [Cart](classes/Cart.mdx)
- [ClaimImage](classes/ClaimImage.mdx)
- [ClaimItem](classes/ClaimItem.mdx)
- [ClaimOrder](classes/ClaimOrder.mdx)
- [ClaimTag](classes/ClaimTag.mdx)
- [Country](classes/Country.mdx)
- [Currency](classes/Currency.mdx)
- [Customer](classes/Customer.mdx)
- [CustomerGroup](classes/CustomerGroup.mdx)
- [Discount](classes/Discount.mdx)
- [DiscountCondition](classes/DiscountCondition.mdx)
- [DiscountRule](classes/DiscountRule.mdx)
- [DraftOrder](classes/DraftOrder.mdx)
- [Fulfillment](classes/Fulfillment.mdx)
- [FulfillmentItem](classes/FulfillmentItem.mdx)
- [FulfillmentProvider](classes/FulfillmentProvider.mdx)
- [GiftCard](classes/GiftCard.mdx)
- [GiftCardTransaction](classes/GiftCardTransaction.mdx)
- [Image](classes/Image.mdx)
- [LineItem](classes/LineItem.mdx)
- [LineItemAdjustment](classes/LineItemAdjustment.mdx)
- [LineItemTaxLine](classes/LineItemTaxLine.mdx)
- [MoneyAmount](classes/MoneyAmount.mdx)
- [Order](classes/Order.mdx)
- [OrderEdit](classes/OrderEdit.mdx)
- [OrderItemChange](classes/OrderItemChange.mdx)
- [Payment](classes/Payment.mdx)
- [PaymentCollection](classes/PaymentCollection.mdx)
- [PaymentProvider](classes/PaymentProvider.mdx)
- [PaymentSession](classes/PaymentSession.mdx)
- [PriceList](classes/PriceList.mdx)
- [Product](classes/Product.mdx)
- [ProductCategory](classes/ProductCategory.mdx)
- [ProductCollection](classes/ProductCollection.mdx)
- [ProductOption](classes/ProductOption.mdx)
- [ProductOptionValue](classes/ProductOptionValue.mdx)
- [ProductTag](classes/ProductTag.mdx)
- [ProductType](classes/ProductType.mdx)
- [ProductVariant](classes/ProductVariant.mdx)
- [ProductVariantInventoryItem](classes/ProductVariantInventoryItem.mdx)
- [Refund](classes/Refund.mdx)
- [Region](classes/Region.mdx)
- [Return](classes/Return.mdx)
- [ReturnItem](classes/ReturnItem.mdx)
- [ReturnReason](classes/ReturnReason.mdx)
- [SalesChannel](classes/SalesChannel.mdx)
- [SalesChannelLocation](classes/SalesChannelLocation.mdx)
- [ShippingMethod](classes/ShippingMethod.mdx)
- [ShippingMethodTaxLine](classes/ShippingMethodTaxLine.mdx)
- [ShippingOption](classes/ShippingOption.mdx)
- [ShippingOptionRequirement](classes/ShippingOptionRequirement.mdx)
- [ShippingProfile](classes/ShippingProfile.mdx)
- [SoftDeletableEntity](classes/SoftDeletableEntity.mdx)
- [Swap](classes/Swap.mdx)
- [TaxLine](classes/TaxLine.mdx)
- [TaxProvider](classes/TaxProvider.mdx)
- [TaxRate](classes/TaxRate.mdx)
- [TrackingLink](classes/TrackingLink.mdx)
## Interfaces
- [Boolean](interfaces/Boolean.mdx)
- [FulfillmentService](interfaces/FulfillmentService.mdx)
## Type Aliases
- [CreateReturnType](types/CreateReturnType.mdx)
- [Exclude](types/Exclude.mdx)
- [FulfillmentProviderData](types/FulfillmentProviderData.mdx)
- [MedusaContainer](types/MedusaContainer.mdx)
- [Omit](types/Omit.mdx)
- [Pick](types/Pick.mdx)
- [Record](types/Record.mdx)
- [ShippingMethodData](types/ShippingMethodData.mdx)
- [ShippingOptionData](types/ShippingOptionData.mdx)
## References
### default
Renames and re-exports [AbstractFulfillmentService](classes/AbstractFulfillmentService.mdx)
___
## Enumeration Members
### ORDER\_EDIT
**ORDER\_EDIT**: `"order_edit"`
The payment collection is used for an order edit.
___
## Functions
### Boolean
#### Type Parameters
<ParameterTypes parameters={[
{
"name": "T",
"type": "`object`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Parameters
<ParameterTypes parameters={[
{
"name": "value",
"type": "`T`",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
<ParameterTypes parameters={[
{
"name": "boolean",
"type": "`boolean`",
"optional": true,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
@@ -0,0 +1,33 @@
---
displayed_sidebar: modules
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# Address
An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.
## constructor
An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.
___
## Methods
### beforeInsert
#### Returns
<ParameterTypes parameters={[
{
"name": "void",
"type": "`void`",
"optional": true,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
@@ -0,0 +1,11 @@
---
displayed_sidebar: modules
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# BaseEntity
Base abstract entity for all entities
## constructor
@@ -0,0 +1,51 @@
---
displayed_sidebar: modules
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# Cart
A cart represents a virtual shopping bag. It can be used to complete an order, a swap, or a claim.
## constructor
A cart represents a virtual shopping bag. It can be used to complete an order, a swap, or a claim.
___
## Methods
### afterLoad
#### Returns
<ParameterTypes parameters={[
{
"name": "void",
"type": "`void`",
"optional": true,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### beforeInsert
#### Returns
<ParameterTypes parameters={[
{
"name": "void",
"type": "`void`",
"optional": true,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
@@ -0,0 +1,33 @@
---
displayed_sidebar: modules
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# ClaimImage
The details of an image attached to a claim.
## constructor
The details of an image attached to a claim.
___
## Methods
### beforeInsert
#### Returns
<ParameterTypes parameters={[
{
"name": "void",
"type": "`void`",
"optional": true,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
@@ -0,0 +1,33 @@
---
displayed_sidebar: modules
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# ClaimItem
A claim item is an item created as part of a claim. It references an item in the order that should be exchanged or refunded.
## constructor
A claim item is an item created as part of a claim. It references an item in the order that should be exchanged or refunded.
___
## Methods
### beforeInsert
#### Returns
<ParameterTypes parameters={[
{
"name": "void",
"type": "`void`",
"optional": true,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
@@ -0,0 +1,33 @@
---
displayed_sidebar: modules
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# ClaimOrder
A Claim represents a group of faulty or missing items. It consists of claim items that refer to items in the original order that should be replaced or refunded. It also includes details related to shipping and fulfillment.
## constructor
A Claim represents a group of faulty or missing items. It consists of claim items that refer to items in the original order that should be replaced or refunded. It also includes details related to shipping and fulfillment.
___
## Methods
### beforeInsert
#### Returns
<ParameterTypes parameters={[
{
"name": "void",
"type": "`void`",
"optional": true,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
@@ -0,0 +1,33 @@
---
displayed_sidebar: modules
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# ClaimTag
Claim Tags are user defined tags that can be assigned to claim items for easy filtering and grouping.
## constructor
Claim Tags are user defined tags that can be assigned to claim items for easy filtering and grouping.
___
## Methods
### beforeInsert
#### Returns
<ParameterTypes parameters={[
{
"name": "void",
"type": "`void`",
"optional": true,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
@@ -0,0 +1,13 @@
---
displayed_sidebar: modules
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# Country
Country details
## constructor
Country details
@@ -0,0 +1,13 @@
---
displayed_sidebar: modules
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# Currency
Currency
## constructor
Currency
@@ -0,0 +1,33 @@
---
displayed_sidebar: modules
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# Customer
A customer can make purchases in your store and manage their profile.
## constructor
A customer can make purchases in your store and manage their profile.
___
## Methods
### beforeInsert
#### Returns
<ParameterTypes parameters={[
{
"name": "void",
"type": "`void`",
"optional": true,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
@@ -0,0 +1,33 @@
---
displayed_sidebar: modules
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# CustomerGroup
A customer group that can be used to organize customers into groups of similar traits.
## constructor
A customer group that can be used to organize customers into groups of similar traits.
___
## Methods
### beforeInsert
#### Returns
<ParameterTypes parameters={[
{
"name": "void",
"type": "`void`",
"optional": true,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
@@ -0,0 +1,33 @@
---
displayed_sidebar: modules
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# Discount
A discount can be applied to a cart for promotional purposes.
## constructor
A discount can be applied to a cart for promotional purposes.
___
## Methods
### upperCaseCodeAndTrim
#### Returns
<ParameterTypes parameters={[
{
"name": "void",
"type": "`void`",
"optional": true,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
@@ -0,0 +1,33 @@
---
displayed_sidebar: modules
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# DiscountCondition
Holds rule conditions for when a discount is applicable
## constructor
Holds rule conditions for when a discount is applicable
___
## Methods
### beforeInsert
#### Returns
<ParameterTypes parameters={[
{
"name": "void",
"type": "`void`",
"optional": true,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
@@ -0,0 +1,33 @@
---
displayed_sidebar: modules
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# DiscountRule
A discount rule defines how a Discount is calculated when applied to a Cart.
## constructor
A discount rule defines how a Discount is calculated when applied to a Cart.
___
## Methods
### beforeInsert
#### Returns
<ParameterTypes parameters={[
{
"name": "void",
"type": "`void`",
"optional": true,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
@@ -0,0 +1,33 @@
---
displayed_sidebar: modules
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# DraftOrder
A draft order is created by an admin without direct involvement of the customer. Once its payment is marked as captured, it is transformed into an order.
## constructor
A draft order is created by an admin without direct involvement of the customer. Once its payment is marked as captured, it is transformed into an order.
___
## Methods
### beforeInsert
#### Returns
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;void&#62;",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
@@ -0,0 +1,33 @@
---
displayed_sidebar: modules
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# Fulfillment
A Fulfillment is created once an admin can prepare the purchased goods. Fulfillments will eventually be shipped and hold information about how to track shipments. Fulfillments are created through a fulfillment provider, which typically integrates a third-party shipping service. Fulfillments can be associated with orders, claims, swaps, and returns.
## constructor
A Fulfillment is created once an admin can prepare the purchased goods. Fulfillments will eventually be shipped and hold information about how to track shipments. Fulfillments are created through a fulfillment provider, which typically integrates a third-party shipping service. Fulfillments can be associated with orders, claims, swaps, and returns.
___
## Methods
### beforeInsert
#### Returns
<ParameterTypes parameters={[
{
"name": "void",
"type": "`void`",
"optional": true,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
@@ -0,0 +1,13 @@
---
displayed_sidebar: modules
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# FulfillmentItem
This represents the association between a Line Item and a Fulfillment.
## constructor
This represents the association between a Line Item and a Fulfillment.
@@ -0,0 +1,13 @@
---
displayed_sidebar: modules
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# FulfillmentProvider
A fulfillment provider represents a fulfillment service installed in the Medusa backend, either through a plugin or backend customizations. It holds the fulfillment service's installation status.
## constructor
A fulfillment provider represents a fulfillment service installed in the Medusa backend, either through a plugin or backend customizations. It holds the fulfillment service's installation status.
@@ -0,0 +1,33 @@
---
displayed_sidebar: modules
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# GiftCard
Gift Cards are redeemable and represent a value that can be used towards the payment of an Order.
## constructor
Gift Cards are redeemable and represent a value that can be used towards the payment of an Order.
___
## Methods
### beforeInsert
#### Returns
<ParameterTypes parameters={[
{
"name": "void",
"type": "`void`",
"optional": true,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
@@ -0,0 +1,33 @@
---
displayed_sidebar: modules
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# GiftCardTransaction
Gift Card Transactions are created once a Customer uses a Gift Card to pay for their Order.
## constructor
Gift Card Transactions are created once a Customer uses a Gift Card to pay for their Order.
___
## Methods
### beforeInsert
#### Returns
<ParameterTypes parameters={[
{
"name": "void",
"type": "`void`",
"optional": true,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
@@ -0,0 +1,33 @@
---
displayed_sidebar: modules
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# Image
An Image is used to store details about uploaded images. Images are uploaded by the File Service, and the URL is provided by the File Service.
## constructor
An Image is used to store details about uploaded images. Images are uploaded by the File Service, and the URL is provided by the File Service.
___
## Methods
### beforeInsert
#### Returns
<ParameterTypes parameters={[
{
"name": "void",
"type": "`void`",
"optional": true,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
@@ -0,0 +1,69 @@
---
displayed_sidebar: modules
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# LineItem
Line Items are created when a product is added to a Cart. When Line Items are purchased they will get copied to the resulting order, swap, or claim, and can eventually be referenced in Fulfillments and Returns. Line items may also be used for order edits.
## constructor
Line Items are created when a product is added to a Cart. When Line Items are purchased they will get copied to the resulting order, swap, or claim, and can eventually be referenced in Fulfillments and Returns. Line items may also be used for order edits.
___
## Methods
### afterUpdateOrLoad
#### Returns
<ParameterTypes parameters={[
{
"name": "void",
"type": "`void`",
"optional": true,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### beforeInsert
#### Returns
<ParameterTypes parameters={[
{
"name": "void",
"type": "`void`",
"optional": true,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### beforeUpdate
#### Returns
<ParameterTypes parameters={[
{
"name": "void",
"type": "`void`",
"optional": true,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />

Some files were not shown because too many files have changed in this diff Show More