diff --git a/docs-util/packages/typedoc-config/modules.js b/docs-util/packages/typedoc-config/modules.js index 3f2822ec66..c8b8acc6da 100644 --- a/docs-util/packages/typedoc-config/modules.js +++ b/docs-util/packages/typedoc-config/modules.js @@ -25,9 +25,8 @@ module.exports = ({ }, expandMembers: true, showCommentsAsHeader: true, - parameterStyle: "list", + parameterStyle: "component", useTsLinkResolution: false, - showReturnSignature: false, sections: { reflection_typeParameters: false, member_declaration_typeParameters: false, @@ -39,13 +38,30 @@ module.exports = ({ member_signature_sources: false, member_signature_title: false, title_reflectionPath: false, + member_sources_definedIn: false, + member_signature_returns: false, }, reflectionGroups: { Constructors: false, Properties: false, }, + parameterComponent: "ParameterTypes", + mdxImports: [ + `import ParameterTypes from "@site/src/components/ParameterTypes"`, + ], } - : {}), + : { + showCommentsAsHeader: true, + sections: { + member_sources_definedIn: false, + reflection_hierarchy: false, + }, + parameterStyle: "component", + parameterComponent: "ParameterTypes", + mdxImports: [ + `import ParameterTypes from "@site/src/components/ParameterTypes"`, + ], + }), ...additionalFormatting, } } @@ -73,6 +89,8 @@ module.exports = ({ hideMembersSymbol: true, formatting, allReflectionsHaveOwnDocument: true, + objectLiteralTypeDeclarationStyle: "component", + mdxOutput: true, ...extraOptions, } } diff --git a/docs-util/packages/typedoc-config/pricing.js b/docs-util/packages/typedoc-config/pricing.js index d67e42cb4d..e2c890aec6 100644 --- a/docs-util/packages/typedoc-config/pricing.js +++ b/docs-util/packages/typedoc-config/pricing.js @@ -18,7 +18,6 @@ module.exports = modulesConfig({ text: "Beta", }, slug: "/references/pricing", - // hide_table_of_contents: true, }, }, }, @@ -26,7 +25,7 @@ module.exports = modulesConfig({ pattern: "IPricingModuleService/methods", additionalFormatting: { reflectionDescription: - "This documentation provides a reference to the {{alias}} {{kind}}. This belongs to the Pricing Module.", + "This documentation provides a reference to the `{{alias}}` {{kind}}. This belongs to the Pricing Module.", frontmatterData: { displayed_sidebar: "pricingReference", badge: { diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/README.md b/docs-util/packages/typedoc-plugin-markdown-medusa/README.md index 05b48ff2bf..f2320dfcaa 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/README.md +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/README.md @@ -6,6 +6,7 @@ A plugin that forks and customizes the [typedoc-plugin-markdown](https://github. Aside from the options detailed in [typedoc-plugin-markdown](https://github.com/tgreyuk/typedoc-plugin-markdown/tree/master/packages/typedoc-plugin-markdown#options), the following options are accepted: +- `mdxImports`: A boolean value indicating whether the outputted files should be MDX files with the `.mdx` extension. - `formatting`: An object whose keys are string patterns used to target specific files. You can also use the string `*` to target all files. The values are objects having the following properties: - `sections`: (optional) an object whose keys are of type [`SectionKey`](./src/types.ts#L19) and values are boolean. This property is used to enable/disable certain sections in the outputted generated docs. - `reflectionGroups`: (optional) an object whose keys are titles of reflection groups (for example, `Constructors`), and values are boolean. This property is used to enable/disable reflection group from being documented. @@ -17,10 +18,11 @@ Aside from the options detailed in [typedoc-plugin-markdown](https://github.com/ - `expandMembers`: (optional) a boolean indicating whether members in a page should be expanded. When enabled, the member titles (for example, `Methods`) are removed and the heading level of nested titles whithin the member is elevated by `1`. - `showCommentAsHeader`: (optional) a boolean indicating whether comments, for example, a method's name, are represented as headers. - `showCommentsAsDetails`: (optional) a boolean indicating whether comments, for example, a method's name, are represented as details component. - - `parameterStyle`: (optional) a string indicating how parameters are displayed. Its value can be `table` (default) or `list`. + - `parameterStyle`: (optional) a string indicating how parameters are displayed. Its value can be `table` (default), `list`, or `component`. - `showReturnSignature`: (optional) a boolean indicating whether to show the signature for returned values. - `frontmatterData`: (optional) an object that will be injected as frontmatter to the pages matching specified pattern. - - + - `parameterComponent`: (optional) a string indicating the name of a React component to pass the parameters as an object to. This is only used if the `parameterStyle` option is set to `component`. This also must be used with the `mdxOutput` option enabled, and an import string for the component passed to the `mdxImports` option. The React component will receive a `parameters` prop, which is an array of type [Parameter](./src/types.ts#L95). + - `mdxImports`: (optional) an array of strings, each holding an import statement that will be added to the beginning of each page. For example, `["import ParameterTypes from "@site/src/components/ParameterTypes""]`. Must be used along with the `mdxOutput` option enabled. ## Build Plugin diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/index.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/index.ts index a2e847dc58..cb1d3864e1 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/index.ts +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/index.ts @@ -87,7 +87,7 @@ export function load(app: Application) { type: ParameterType.String, defaultValue: "table", validate: (x) => { - const availableValues = ["table", "list"] + const availableValues = ["table", "list", "component"] if (!availableValues.includes(x)) { throw new Error( `Wrong value for objectLiteralTypeDeclarationStyle, the expected value is one of ${availableValues}` @@ -102,5 +102,12 @@ export function load(app: Application) { type: ParameterType.Object, defaultValue: {}, }) + + app.options.addDeclaration({ + help: "[Markdown Plugin] Whether outputted files should have an mdx extension.", + name: "mdxOutput", + type: ParameterType.Boolean, + defaultValue: false, + }) } export { MarkdownTheme } diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/render-utils.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/render-utils.ts index c972332728..71ac109023 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/render-utils.ts +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/render-utils.ts @@ -37,8 +37,16 @@ import parameterHelper from "./resources/helpers/parameter" import debugHelper from "./resources/helpers/debug" import frontmatterHelper from "./resources/helpers/frontmatter" import reflectionDescriptionHelper from "./resources/helpers/reflection-description" +import mdxImportsHelper from "./resources/helpers/mdx-imports" +import parameterComponentHelper from "./resources/helpers/parameter-component" +import typeParameterComponentHelper from "./resources/helpers/type-parameter-component" +import showPropertiesAsComponentHelper from "./resources/helpers/show-properties-as-component" +import commentTagHelper from "./resources/helpers/comment-tag" +import exampleHelper from "./resources/helpers/example" import { MarkdownTheme } from "./theme" +// test + const TEMPLATE_PATH = path.join(__dirname, "resources", "templates") export const indexTemplate = Handlebars.compile( @@ -68,7 +76,7 @@ export function registerPartials() { export function registerHelpers(theme: MarkdownTheme) { breadcrumbsHelper(theme) commentHelper(theme) - commentsHelper(theme) + commentsHelper() declarationTitleHelper(theme) escapeHelper() hierarchyHelper() @@ -86,7 +94,7 @@ export function registerHelpers(theme: MarkdownTheme) { reflectionPathHelper() reflectionTitleHelper(theme) relativeUrlHelper(theme) - returns() + returns(theme) signatureTitleHelper(theme) tocHelper(theme) typeHelper() @@ -102,4 +110,10 @@ export function registerHelpers(theme: MarkdownTheme) { debugHelper() frontmatterHelper(theme) reflectionDescriptionHelper(theme) + mdxImportsHelper(theme) + parameterComponentHelper(theme) + typeParameterComponentHelper(theme) + showPropertiesAsComponentHelper(theme) + commentTagHelper(theme) + exampleHelper() } diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/comment-tag.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/comment-tag.ts new file mode 100644 index 0000000000..6b0242e334 --- /dev/null +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/comment-tag.ts @@ -0,0 +1,27 @@ +import * as Handlebars from "handlebars" +import { CommentTag } from "typedoc" +import { camelToTitleCase } from "../../utils" +import { MarkdownTheme } from "../../theme" + +export default function (theme: MarkdownTheme) { + Handlebars.registerHelper( + "commentTag", + function (tag: CommentTag, commentLevel = 4, parent = null) { + const { showCommentsAsHeader, showCommentsAsDetails } = + theme.getFormattingOptionsForLocation() + const tagTitle = camelToTitleCase(tag.tag.substring(1)), + tagContent = Handlebars.helpers.comment(tag.content) + + if (showCommentsAsHeader) { + return `${Handlebars.helpers.titleLevel.call( + parent, + commentLevel + )} ${tagTitle}\n\n${tagContent}` + } else if (showCommentsAsDetails) { + return `
\n\n${tagTitle}\n\n\n${tagContent}\n\n
` + } + + return `**${tagTitle}**\n\n${tagContent}` + } + ) +} diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/comments.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/comments.ts index 565b03e33f..cc791956ec 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/comments.ts +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/comments.ts @@ -1,9 +1,7 @@ import * as Handlebars from "handlebars" import { Comment } from "typedoc" -import { camelToTitleCase } from "../../utils" -import { MarkdownTheme } from "../../theme" -export default function (theme: MarkdownTheme) { +export default function () { Handlebars.registerHelper( "comments", function ( @@ -13,33 +11,23 @@ export default function (theme: MarkdownTheme) { commentLevel = 4, parent = null ) { - const { showCommentsAsHeader, showCommentsAsDetails } = - theme.getFormattingOptionsForLocation() const md: string[] = [] if (showSummary && comment.summary) { md.push(Handlebars.helpers.comment(comment.summary)) } - const filteredTags = comment.blockTags.filter( - (tag) => tag.tag !== "@returns" - ) + const filteredTags = comment.blockTags + .filter((tag) => tag.tag !== "@returns") + .filter((tag) => tag.tag !== "@example") if (showTags && comment.blockTags?.length) { const tags = filteredTags.map((tag) => { - const tagTitle = camelToTitleCase(tag.tag.substring(1)), - tagContent = Handlebars.helpers.comment(tag.content) - - if (showCommentsAsHeader) { - return `${Handlebars.helpers.titleLevel.call( - parent || comment, - commentLevel - )} ${tagTitle}\n\n${tagContent}` - } else if (showCommentsAsDetails) { - return `
\n\n${tagTitle}\n\n\n${tagContent}\n\n
` - } else { - return `**${tagTitle}**\n\n${tagContent}` - } + return Handlebars.helpers.commentTag( + tag, + commentLevel, + parent || comment + ) }) md.push(tags.join("\n\n")) } diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/example.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/example.ts new file mode 100644 index 0000000000..c62a662a1b --- /dev/null +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/example.ts @@ -0,0 +1,19 @@ +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" + ) + + if (!exampleTag) { + return "" + } + + return Handlebars.helpers.commentTag(exampleTag, commentLevel, reflection) + } + ) +} diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/mdx-imports.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/mdx-imports.ts new file mode 100644 index 0000000000..f3a3eaa20c --- /dev/null +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/mdx-imports.ts @@ -0,0 +1,14 @@ +import * as Handlebars from "handlebars" +import { MarkdownTheme } from "../../theme" + +export default function (theme: MarkdownTheme) { + Handlebars.registerHelper("mdxImports", function () { + if (!theme.mdxOutput) { + return "" + } + + const { mdxImports } = theme.getFormattingOptionsForLocation() + + return mdxImports?.join("\n") || "" + }) +} diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/parameter-component.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/parameter-component.ts new file mode 100644 index 0000000000..38ae8d258d --- /dev/null +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/parameter-component.ts @@ -0,0 +1,22 @@ +import * as Handlebars from "handlebars" +import { ReflectionParameterType } from "../../types" +import { parseParams } from "../../utils/params-utils" +import { MarkdownTheme } from "../../theme" +import { reflectionComponentFormatter } from "../../utils/reflection-formatter" + +export default function (theme: MarkdownTheme) { + Handlebars.registerHelper( + "parameterComponent", + function (this: ReflectionParameterType[]) { + const { parameterComponent } = theme.getFormattingOptionsForLocation() + const parameters = this.reduce( + (acc: ReflectionParameterType[], current) => parseParams(current, acc), + [] + ).map((parameter) => reflectionComponentFormatter(parameter, 1)) + + return `<${parameterComponent} parameters={${JSON.stringify( + parameters + )}} />` + } + ) +} diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/parameter-list.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/parameter-list.ts index 6765d1840c..3390872976 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/parameter-list.ts +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/parameter-list.ts @@ -1,7 +1,7 @@ import * as Handlebars from "handlebars" -import reflectionFomatter from "../../utils/reflection-formatter" import { ReflectionParameterType } from "../../types" import { parseParams } from "../../utils/params-utils" +import reflectionFormatter from "../../utils/reflection-formatter" export default function () { Handlebars.registerHelper( @@ -21,7 +21,7 @@ export default function () { function list(parameters: ReflectionParameterType[]) { const items = parameters.map((parameter) => { - return reflectionFomatter(parameter) + return reflectionFormatter(parameter, "list") }) return items.join("\n") diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/parameter-table.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/parameter-table.ts index 7993b6fade..748331ef47 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/parameter-table.ts +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/parameter-table.ts @@ -1,119 +1,31 @@ import * as Handlebars from "handlebars" -import { ParameterReflection, ReflectionType } from "typedoc" -import { stripLineBreaks } from "../../utils" -import { getReflectionType } from "./type" import { parseParams } from "../../utils/params-utils" import { ReflectionParameterType } from "../../types" +import { + getTableHeaders, + reflectionTableFormatter, +} from "../../utils/reflection-formatter" export default function () { Handlebars.registerHelper( "parameterTable", function (this: ReflectionParameterType[]) { - return table( - this.reduce( - (acc: ReflectionParameterType[], current: ReflectionParameterType) => - parseParams(current, acc), - [] - ) as ParameterReflection[] + const parameters = this.reduce( + (acc: ReflectionParameterType[], current: ReflectionParameterType) => + parseParams(current, acc), + [] ) + + const headers = getTableHeaders(parameters) + + const rows = parameters.map((parameter) => + reflectionTableFormatter(parameter) + ) + + return `\n| ${headers.join(" | ")} |\n| ${headers + .map(() => ":------") + .join(" | ")} |\n${rows.join("")}` } ) } - -function table(parameters: ParameterReflection[]) { - const showDefaults = hasDefaultValues(parameters) - - const comments = parameters.map( - (param: ParameterReflection) => !!param.comment?.hasVisibleComponent() - ) - const hasComments = !comments.every((value) => !value) - - const headers = ["Name", "Type"] - - if (showDefaults) { - headers.push("Default value") - } - - if (hasComments) { - headers.push("Description") - } - - const rows = parameters.map((parameter) => { - const row: string[] = [] - - const nbsp = " " // ? <== Unicode no-break space character - const rest = parameter.flags.isRest ? "..." : "" - const optional = parameter.flags.isOptional ? "?" : "" - - const isDestructuredParam = parameter.name == "__namedParameters" - const isDestructuredParamProp = - parameter.name.startsWith("__namedParameters.") - - if (isDestructuredParam) { - row.push(`\`${rest}«destructured»\``) - } else if (isDestructuredParamProp) { - row.push(`›${nbsp}\`${rest}${parameter.name.slice(18)}${optional}\``) - } else { - row.push(`\`${rest}${parameter.name}${optional}\``) - } - - row.push( - parameter.type - ? Handlebars.helpers.type.call(parameter.type, "object") - : getReflectionType(parameter, "object") - ) - - if (showDefaults) { - row.push(getDefaultValue(parameter)) - } - if (hasComments) { - const comments = getComments(parameter) - if (comments) { - row.push( - stripLineBreaks(Handlebars.helpers.comments(comments)).replace( - /\|/g, - "\\|" - ) - ) - } else { - row.push("-") - } - } - return `| ${row.join(" | ")} |\n` - }) - - const output = `\n| ${headers.join(" | ")} |\n| ${headers - .map(() => ":------") - .join(" | ")} |\n${rows.join("")}` - return output -} - -function getDefaultValue(parameter: ParameterReflection) { - return parameter.defaultValue && parameter.defaultValue !== "..." - ? `\`${parameter.defaultValue}\`` - : "`undefined`" -} - -function hasDefaultValues(parameters: ParameterReflection[]) { - const defaultValues = (parameters as ParameterReflection[]).map( - (param) => - param.defaultValue !== "{}" && - param.defaultValue !== "..." && - !!param.defaultValue - ) - - return !defaultValues.every((value) => !value) -} - -function getComments(parameter: ParameterReflection) { - if (parameter.type instanceof ReflectionType) { - if ( - parameter.type?.declaration?.signatures && - parameter.type?.declaration?.signatures[0]?.comment - ) { - return parameter.type?.declaration?.signatures[0]?.comment - } - } - return parameter.comment -} diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/parameter.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/parameter.ts index 0556c9d4e1..657be78252 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/parameter.ts +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/parameter.ts @@ -10,6 +10,8 @@ export default function (theme: MarkdownTheme) { if (parameterStyle === "list") { return Handlebars.helpers.parameterList.call(this) + } else if (parameterStyle === "component") { + return Handlebars.helpers.parameterComponent.call(this) } else { return Handlebars.helpers.parameterTable.call(this) } diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/properties-component.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/properties-component.ts new file mode 100644 index 0000000000..14e8e7f8cc --- /dev/null +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/properties-component.ts @@ -0,0 +1,12 @@ +import * as Handlebars from "handlebars" +import { MarkdownTheme } from "../../theme" +import { DeclarationReference } from "typedoc" + +export default function (theme: MarkdownTheme) { + Handlebars.registerHelper( + "propertiesComponent", + function (this: DeclarationReference) { + console.log(this) + } + ) +} diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/returns.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/returns.ts index 903e5f9e80..175d10e79d 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/returns.ts +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/returns.ts @@ -1,34 +1,106 @@ import * as Handlebars from "handlebars" -import { Comment, DeclarationReflection } from "typedoc" -import reflectionFomatter from "../../utils/reflection-formatter" +import { Comment, DeclarationReflection, SignatureReflection } from "typedoc" +import { MarkdownTheme } from "../../theme" +import reflectionFormatter from "../../utils/reflection-formatter" +import { returnReflectionComponentFormatter } from "../../utils/return-reflection-formatter" +import { Parameter } from "../../types" -export default function () { - Handlebars.registerHelper("returns", function (comment: Comment) { - const md: string[] = [] - - if (comment.blockTags?.length) { - const tags = comment.blockTags - .filter((tag) => tag.tag === "@returns") - .map((tag) => { - let result = Handlebars.helpers.comment(tag.content) - tag.content.forEach((commentPart) => { - if ( - "target" in commentPart && - commentPart.target instanceof DeclarationReflection - ) { - const content = commentPart.target.children?.map((childItem) => - reflectionFomatter(childItem) - ) - result += `\n\n
\n\n${ - commentPart.target.name - }\n\n\n${content?.join("\n")}\n\n
` - } - }) - return result - }) - md.push(tags.join("\n\n")) +export default function (theme: MarkdownTheme) { + Handlebars.registerHelper( + "returns", + function (reflection: SignatureReflection) { + if (reflection.variant === "signature" && "type" in reflection) { + return getReturnFromType(theme, reflection) + } else if (reflection.comment) { + return getReturnFromComment(theme, reflection.comment) + } else { + return "" + } } - - return md.join("") - }) + ) +} + +function getReturnFromType( + theme: MarkdownTheme, + reflection: SignatureReflection +) { + const { parameterStyle, parameterComponent } = + theme.getFormattingOptionsForLocation() + + if (!reflection.type) { + return "" + } + + const componentItems = returnReflectionComponentFormatter( + reflection.type, + reflection.project || theme.project, + reflection.comment, + 1 + ) + + if (parameterStyle === "component") { + return `<${parameterComponent} parameters={${JSON.stringify( + componentItems + )}} />` + } else { + return formatReturnAsList(componentItems) + } +} + +function formatReturnAsList(componentItems: Parameter[], level = 1): string { + const prefix = `${Array(level - 1) + .fill("\t") + .join("")}-` + return componentItems + .map( + (item) => + `${prefix}\`${item.name}\`: ${ + item.optional || item.defaultValue + ? `(${item.optional ? "optional" : ""}${ + item.optional && item.defaultValue ? "," : "" + }${item.defaultValue ? `default: ${item.defaultValue}` : ""}) ` + : "" + }${item.description}${ + item.children?.length + ? `\n${formatReturnAsList(item.children, level + 1)}` + : "" + }` + ) + .join("\n") +} + +function getReturnFromComment(theme: MarkdownTheme, comment: Comment) { + const md: string[] = [] + const { parameterStyle, parameterComponent } = + theme.getFormattingOptionsForLocation() + + if (comment.blockTags?.length) { + const tags = comment.blockTags + .filter((tag) => tag.tag === "@returns") + .map((tag) => { + let result = Handlebars.helpers.comment(tag.content) + tag.content.forEach((commentPart) => { + if ( + "target" in commentPart && + commentPart.target instanceof DeclarationReflection + ) { + const content = commentPart.target.children?.map((childItem) => + reflectionFormatter(childItem, parameterStyle, 1) + ) + result += + parameterStyle === "component" + ? `\n\n<${parameterComponent} parameters={${JSON.stringify( + content + )}} title={"${commentPart.target.name}"} />\n\n` + : `\n\n
\n\n${ + commentPart.target.name + }\n\n\n${content?.join("\n")}\n\n
` + } + }) + return result + }) + md.push(tags.join("\n\n")) + } + + return md.join("") } diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/show-properties-as-component.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/show-properties-as-component.ts new file mode 100644 index 0000000000..3dccec3c94 --- /dev/null +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/show-properties-as-component.ts @@ -0,0 +1,15 @@ +import * as Handlebars from "handlebars" +import { MarkdownTheme } from "../../theme" + +export default function (theme: MarkdownTheme) { + Handlebars.registerHelper( + "showPropertiesAsComponent", + function (title: string) { + const { parameterStyle } = theme.getFormattingOptionsForLocation() + + // console.log(parameterStyle, title) + + return parameterStyle === "component" && title === "Properties" + } + ) +} diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/type-declaration-object-literal.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/type-declaration-object-literal.ts index dd3514e7f5..df868b5c74 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/type-declaration-object-literal.ts +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/type-declaration-object-literal.ts @@ -2,14 +2,15 @@ import * as Handlebars from "handlebars" import { DeclarationReflection, ReflectionType } from "typedoc" import { MarkdownTheme } from "../../theme" import { escapeChars, stripLineBreaks } from "../../utils" -import reflectionFomatter from "../../utils/reflection-formatter" import { parseParams } from "../../utils/params-utils" import { ReflectionParameterType } from "../../types" +import reflectionFormatter from "../../utils/reflection-formatter" export default function (theme: MarkdownTheme) { Handlebars.registerHelper( "typeDeclarationMembers", function (this: DeclarationReflection[]) { + const { parameterComponent } = theme.getFormattingOptionsForLocation() const comments = this.map( (param) => !!param.comment?.hasVisibleComponent() ) @@ -27,6 +28,10 @@ export default function (theme: MarkdownTheme) { result = getListMarkdownContent(properties) break } + case "component": { + result = getComponentMarkdownContent(properties, parameterComponent) + break + } case "table": { result = getTableMarkdownContent(properties, hasComments) break @@ -38,11 +43,24 @@ export default function (theme: MarkdownTheme) { } function getListMarkdownContent(properties: DeclarationReflection[]) { - const items = properties.map((property) => reflectionFomatter(property)) + const items = properties.map((property) => + reflectionFormatter(property, "list") + ) return items.join("\n") } +function getComponentMarkdownContent( + properties: DeclarationReflection[], + parameterComponent?: string +) { + const parameters = properties.map((property) => + reflectionFormatter(property, "component") + ) + + return `<${parameterComponent} parameters={${JSON.stringify(parameters)}} />` +} + function getTableMarkdownContent( properties: DeclarationReflection[], hasComments: boolean diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/type-parameter-component.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/type-parameter-component.ts new file mode 100644 index 0000000000..910adbc756 --- /dev/null +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/type-parameter-component.ts @@ -0,0 +1,20 @@ +import * as Handlebars from "handlebars" +import { TypeParameterReflection } from "typedoc" +import { reflectionComponentFormatter } from "../../utils/reflection-formatter" +import { MarkdownTheme } from "../../theme" + +export default function (theme: MarkdownTheme) { + Handlebars.registerHelper( + "typeParameterComponent", + function (this: TypeParameterReflection[]) { + const { parameterComponent } = theme.getFormattingOptionsForLocation() + const parameters = this.map((parameter) => + reflectionComponentFormatter(parameter, 1) + ) + + return `<${parameterComponent} parameters={${JSON.stringify( + parameters + )}} />` + } + ) +} diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/type-parameter-list.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/type-parameter-list.ts index e705a9e145..2d9bf2b4e1 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/type-parameter-list.ts +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/type-parameter-list.ts @@ -1,6 +1,6 @@ import * as Handlebars from "handlebars" import { TypeParameterReflection } from "typedoc" -import reflectionFomatter from "../../utils/reflection-formatter" +import reflectionFormatter from "../../utils/reflection-formatter" export default function () { Handlebars.registerHelper( @@ -12,7 +12,9 @@ export default function () { } function list(parameters: TypeParameterReflection[]) { - const items = parameters.map((parameter) => reflectionFomatter(parameter)) + const items = parameters.map((parameter) => + reflectionFormatter(parameter, "list") + ) return items.join("\n") } diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/type-parameter-table.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/type-parameter-table.ts index e87d98a355..40e1b6f8b0 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/type-parameter-table.ts +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/type-parameter-table.ts @@ -1,82 +1,23 @@ import * as Handlebars from "handlebars" import { TypeParameterReflection } from "typedoc" -import { stripLineBreaks } from "../../utils" +import { + getTableHeaders, + reflectionTableFormatter, +} from "../../utils/reflection-formatter" +import { hasTypes } from "../../utils/type-utils" export default function () { Handlebars.registerHelper( "typeParameterTable", function (this: TypeParameterReflection[]) { - return table(this) + const showTypeCol = hasTypes(this) + const headers = getTableHeaders(this, showTypeCol) + + const rows = this.map((parameter) => reflectionTableFormatter(parameter)) + + return `\n| ${headers.join(" | ")} |\n| ${headers + .map(() => ":------") + .join(" | ")} |\n${rows.join("")}` } ) } - -function table(parameters: TypeParameterReflection[]) { - const showTypeCol = hasTypes(parameters) - - const comments = parameters.map( - (param: TypeParameterReflection) => !!param.comment?.hasVisibleComponent() - ) - - const hasComments = !comments.every((value) => !value) - - const headers = ["Name"] - - if (showTypeCol) { - headers.push("Type") - } - - if (hasComments) { - headers.push("Description") - } - - const rows = parameters.map((parameter: TypeParameterReflection) => { - const row: string[] = [] - - row.push(`\`${parameter.name}\``) - - if (showTypeCol) { - const typeCol: string[] = [] - if (!parameter.type && !parameter.default) { - typeCol.push(`\`${parameter.name}\``) - } - if (parameter.type) { - typeCol.push( - `extends ${Handlebars.helpers.type.call(parameter.type, "object")}` - ) - } - if (parameter.default) { - if (parameter.type) { - typeCol.push(" = ") - } - typeCol.push(Handlebars.helpers.type.call(parameter.default)) - } - row.push(typeCol.join("")) - } - - if (hasComments) { - if (parameter.comment?.summary) { - row.push( - stripLineBreaks( - Handlebars.helpers.comment(parameter.comment?.summary) - ).replace(/\|/g, "\\|") - ) - } else { - row.push("-") - } - } - return `| ${row.join(" | ")} |\n` - }) - - const output = `\n| ${headers.join(" | ")} |\n| ${headers - .map(() => ":------") - .join(" | ")} |\n${rows.join("")}` - return output -} - -function hasTypes(parameters: TypeParameterReflection[]) { - const types = (parameters as TypeParameterReflection[]).map( - (param) => !!param.type || !!param.default - ) - return !types.every((value) => !value) -} diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/type-parameter.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/type-parameter.ts index 4fd0707c18..7eeeff1497 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/type-parameter.ts +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/type-parameter.ts @@ -10,6 +10,8 @@ export default function (theme: MarkdownTheme) { if (parameterStyle === "list") { return Handlebars.helpers.typeParameterList.call(this) + } else if (parameterStyle === "component") { + return Handlebars.helpers.typeParameterComponent.call(this) } else { return Handlebars.helpers.typeParameterTable.call(this) } diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/type.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/type.ts index 4d6ae4dc6d..eca58a7b41 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/type.ts +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/type.ts @@ -2,26 +2,19 @@ import * as Handlebars from "handlebars" import { ArrayType, ConditionalType, - DeclarationReflection, IndexedAccessType, InferredType, IntersectionType, IntrinsicType, - LiteralType, PredicateType, QueryType, ReferenceType, - ReflectionType, - SignatureReflection, TupleType, TypeOperatorType, UnionType, UnknownType, } from "typedoc" -import { escapeChars } from "../../utils" -import { ReflectionParameterType } from "../../types" - -type Collapse = "object" | "function" | "all" | "none" +import getType, { Collapse } from "../../utils/type-utils" export default function () { Handlebars.registerHelper( @@ -46,267 +39,7 @@ export default function () { collapse: Collapse = "none", emphasis = true ) { - if (this instanceof ReferenceType) { - return getReferenceType(this, emphasis) - } - - if (this instanceof ArrayType && this.elementType) { - return getArrayType(this, emphasis) - } - - if (this instanceof UnionType && this.types) { - return getUnionType(this, emphasis) - } - - if (this instanceof IntersectionType && this.types) { - return getIntersectionType(this) - } - - if (this instanceof TupleType && this.elements) { - return getTupleType(this) - } - - if (this instanceof IntrinsicType && this.name) { - return getIntrinsicType(this, emphasis) - } - - if (this instanceof ReflectionType) { - return getReflectionType(this, collapse) - } - - if (this instanceof DeclarationReflection) { - return getReflectionType(this, collapse) - } - - if (this instanceof TypeOperatorType) { - return getTypeOperatorType(this) - } - - if (this instanceof QueryType) { - return getQueryType(this) - } - - if (this instanceof ConditionalType) { - return getConditionalType(this) - } - - if (this instanceof IndexedAccessType) { - return getIndexAccessType(this) - } - - if (this instanceof UnknownType) { - return getUnknownType(this) - } - - if (this instanceof InferredType) { - return getInferredType(this) - } - - if (this instanceof LiteralType) { - return getLiteralType(this) - } - - return this ? escapeChars(this.toString()) : "" + return getType(this, collapse, emphasis) } ) } - -function getLiteralType(model: LiteralType) { - if (typeof model.value === "bigint") { - return `\`${model.value}n\`` - } - return `\`\`${JSON.stringify(model.value)}\`\`` -} - -export function getReflectionType( - model: ReflectionParameterType, - collapse: Collapse -) { - const root = model instanceof ReflectionType ? model.declaration : model - if ("signatures" in root && root.signatures) { - return collapse === "function" || collapse === "all" - ? `\`fn\`` - : getFunctionType(root.signatures) - } - return collapse === "object" || collapse === "all" - ? `\`Object\`` - : getDeclarationType(root as DeclarationReflection) -} - -export function getDeclarationType(model: DeclarationReflection) { - if (model.indexSignature || model.children) { - let indexSignature = "" - const declarationIndexSignature = model.indexSignature - if (declarationIndexSignature) { - const key = declarationIndexSignature.parameters - ? declarationIndexSignature.parameters.map( - (param) => `\`[${param.name}: ${param.type}]\`` - ) - : "" - const obj = Handlebars.helpers.type.call(declarationIndexSignature.type) - indexSignature = `${key}: ${obj}; ` - } - const types = - model.children && - model.children.map((obj) => { - return `\`${obj.name}${ - obj.flags.isOptional ? "?" : "" - }\`: ${Handlebars.helpers.type.call( - obj.signatures || obj.children ? obj : obj.type - )} ${ - obj.defaultValue && obj.defaultValue !== "..." - ? `= ${escapeChars(obj.defaultValue)}` - : "" - }` - }) - return `{ ${indexSignature ? indexSignature : ""}${ - types ? types.join("; ") : "" - } }${ - model.defaultValue && model.defaultValue !== "..." - ? `= ${escapeChars(model.defaultValue)}` - : "" - }` - } - return "{}" -} - -export function getFunctionType(modelSignatures: SignatureReflection[]) { - const functions = modelSignatures.map((fn) => { - const typeParams = fn.typeParameters - ? `<${fn.typeParameters - .map((typeParameter) => typeParameter.name) - .join(", ")}\\>` - : [] - const params = fn.parameters - ? fn.parameters.map((param) => { - return `${param.flags.isRest ? "..." : ""}\`${param.name}${ - param.flags.isOptional ? "?" : "" - }\`: ${Handlebars.helpers.type.call(param.type ? param.type : param)}` - }) - : [] - const returns = Handlebars.helpers.type.call(fn.type) - return typeParams + `(${params.join(", ")}) => ${returns}` - }) - return functions.join("") -} - -export function getReferenceType(model: ReferenceType, emphasis: boolean) { - if (model.reflection || (model.name && model.typeArguments)) { - const reflection: string[] = [] - - if (model.reflection?.url) { - reflection.push( - emphasis - ? `[${`\`${model.reflection.name}\``}](${Handlebars.helpers.relativeURL( - model.reflection.url - )})` - : model.reflection.name - ) - } else { - reflection.push( - emphasis - ? model.externalUrl - ? `[${`\`${model.name}\``}]( ${model.externalUrl} )` - : `\`${model.name}\`` - : model.name - ) - } - if (model.typeArguments && model.typeArguments.length > 0) { - reflection.push( - `<${model.typeArguments - .map((typeArgument) => - Handlebars.helpers.type.call(typeArgument, "none", emphasis) - ) - .join(", ")}\\>` - ) - } - return reflection.join("") - } - return emphasis - ? model.externalUrl - ? `[${`\`${model.name}\``}]( ${model.externalUrl} )` - : `\`${model.name}\`` - : escapeChars(model.name) -} - -export function getArrayType(model: ArrayType, emphasis: boolean) { - const arrayType = Handlebars.helpers.type.call( - model.elementType, - "none", - emphasis - ) - return model.elementType.type === "union" - ? `(${arrayType})[]` - : `${arrayType}[]` -} - -export function getUnionType(model: UnionType, emphasis: boolean) { - return model.types - .map((unionType) => - Handlebars.helpers.type.call(unionType, "none", emphasis) - ) - .join(` \\| `) -} - -export function getIntersectionType(model: IntersectionType) { - return model.types - .map((intersectionType) => Handlebars.helpers.type.call(intersectionType)) - .join(" & ") -} - -export function getTupleType(model: TupleType) { - return `[${model.elements - .map((element) => Handlebars.helpers.type.call(element)) - .join(", ")}]` -} - -export function getIntrinsicType(model: IntrinsicType, emphasis: boolean) { - return emphasis ? `\`${model.name}\`` : escapeChars(model.name) -} - -export function getTypeOperatorType(model: TypeOperatorType) { - return `${model.operator} ${Handlebars.helpers.type.call(model.target)}` -} - -export function getQueryType(model: QueryType) { - return `typeof ${Handlebars.helpers.type.call(model.queryType)}` -} - -export function getInferredType(model: InferredType) { - return `infer ${escapeChars(model.name)}` -} - -export function getUnknownType(model: UnknownType) { - return escapeChars(model.name) -} - -export function getConditionalType(model: ConditionalType) { - const md: string[] = [] - if (model.checkType) { - md.push(Handlebars.helpers.type.call(model.checkType)) - } - md.push("extends") - if (model.extendsType) { - md.push(Handlebars.helpers.type.call(model.extendsType)) - } - md.push("?") - if (model.trueType) { - md.push(Handlebars.helpers.type.call(model.trueType)) - } - md.push(":") - if (model.falseType) { - md.push(Handlebars.helpers.type.call(model.falseType)) - } - return md.join(" ") -} - -export function getIndexAccessType(model: IndexedAccessType) { - const md: string[] = [] - if (model.objectType) { - md.push(Handlebars.helpers.type.call(model.objectType)) - } - if (model.indexType) { - md.push(`[${Handlebars.helpers.type.call(model.indexType)}]`) - } - return md.join("") -} diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/partials/header.hbs b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/partials/header.hbs index 6a46ac2abd..66908fca8f 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/partials/header.hbs +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/partials/header.hbs @@ -1,3 +1,11 @@ +{{#with model}} + +{{{frontmatter}}} + +{{/with}} + +{{{mdxImports}}} + {{#ifShowBreadcrumbs}} {{{breadcrumbs}}} diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/partials/member.declaration.hbs b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/partials/member.declaration.hbs index a17474edde..40b259ef54 100755 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/partials/member.declaration.hbs +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/partials/member.declaration.hbs @@ -2,6 +2,12 @@ {{> comment}} +{{#if (sectionEnabled "member_declaration_example")}} + +{{{example this 4}}} + +{{/if}} + {{#if (sectionEnabled "member_declaration_typeParameters")}} {{#if typeParameters}} diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/partials/member.signature.hbs b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/partials/member.signature.hbs index b5ff6f2553..b8d21bba97 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/partials/member.signature.hbs +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/partials/member.signature.hbs @@ -28,6 +28,12 @@ {{/if}} +{{#if (sectionEnabled "member_signature_example")}} + +{{{example this 4}}} + +{{/if}} + {{#if (sectionEnabled "member_signature_parameters")}} {{#if parameters}} @@ -66,7 +72,7 @@ {{/if}} -{{#if (getFormattingOption "showReturnSignature")}} +{{#if (sectionEnabled "member_signature_returns")}} {{#with type}} @@ -76,12 +82,8 @@ {{/if}} -{{#with comment}} - {{{returns this}}} -{{/with}} - {{#with type}} {{#if (sectionEnabled "member_signature_declarationSignatures")}} diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/partials/members.group.hbs b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/partials/members.group.hbs index 5e4c2b2ae2..89b24733a9 100755 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/partials/members.group.hbs +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/partials/members.group.hbs @@ -14,12 +14,24 @@ ___ {{/unless}} +{{#if (showPropertiesAsComponent title)}} + +{{#with children}} + +{{{parameterComponent}}} + +{{/with}} + +{{else}} + {{#each children}} {{> member}} {{/each}} +{{/if}} + {{/each}} {{else}} @@ -30,6 +42,16 @@ ___ {{/unless}} +{{#if (showPropertiesAsComponent title)}} + +{{#with children}} + +{{{parameterComponent}}} + +{{/with}} + +{{else}} + {{#each children}} {{> member}} @@ -38,4 +60,6 @@ ___ {{/if}} +{{/if}} + {{/if}} \ No newline at end of file diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/templates/index.hbs b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/templates/index.hbs index 659c738797..19a40da27f 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/templates/index.hbs +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/templates/index.hbs @@ -1,9 +1,3 @@ -{{#with model}} - -{{{frontmatter}}} - -{{/with}} - {{> header}} {{#with model.readme}} diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/templates/reflection.hbs b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/templates/reflection.hbs index 65df6ad136..7ae033c574 100755 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/templates/reflection.hbs +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/templates/reflection.hbs @@ -1,9 +1,3 @@ -{{#with model}} - -{{{frontmatter}}} - -{{/with}} - {{> header}} {{> title}} @@ -22,6 +16,12 @@ {{/with}} +{{#if (sectionEnabled "reflection_example")}} + +{{{example model 2}}} + +{{/if}} + {{#if (sectionEnabled "reflection_typeParameters")}} {{#if model.typeParameters}} diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/templates/reflection.member.hbs b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/templates/reflection.member.hbs index ffe2958f96..78129be63b 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/templates/reflection.member.hbs +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/templates/reflection.member.hbs @@ -1,9 +1,3 @@ -{{#with model}} - -{{{frontmatter}}} - -{{/with}} - {{> header}} {{> title}} diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/theme.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/theme.ts index ce4d4cc49a..38fdf250cd 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/theme.ts +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/theme.ts @@ -47,6 +47,7 @@ export class MarkdownTheme extends Theme { preserveAnchorCasing!: boolean objectLiteralTypeDeclarationStyle: ObjectLiteralDeclarationStyle formattingOptions: FormattingOptionsType + mdxOutput: boolean project?: ProjectReflection reflection?: DeclarationReflection @@ -83,6 +84,7 @@ export class MarkdownTheme extends Theme { this.formattingOptions = this.getOption( "formatting" ) as FormattingOptionsType + this.mdxOutput = this.getOption("mdxOutput") as boolean this.listenTo(this.owner, { [RendererEvent.BEGIN]: this.onBeginRenderer, @@ -162,7 +164,12 @@ export class MarkdownTheme extends Theme { } toUrl(mapping: Mapping, reflection: DeclarationReflection) { - return mapping.directory + "/" + this.getUrl(reflection) + ".md" + return ( + mapping.directory + + "/" + + this.getUrl(reflection) + + (this.mdxOutput ? ".mdx" : ".md") + ) } getUrl(reflection: Reflection, relative?: Reflection): string { @@ -364,7 +371,7 @@ export class MarkdownTheme extends Theme { } get globalsFile() { - return "modules.md" + return `modules.${this.mdxOutput ? "mdx" : "md"}` } getFormattingOptionsForLocation(): FormattingOptionType { diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/types.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/types.ts index fd911017a8..4fd7a4b6d2 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/types.ts +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/types.ts @@ -8,14 +8,14 @@ import { TypeParameterReflection, } from "typedoc" -export type ParameterStyle = "table" | "list" +export type ParameterStyle = "table" | "list" | "component" export type ReflectionTitleOptions = { typeParameters?: boolean kind?: boolean } -export type ObjectLiteralDeclarationStyle = "table" | "list" +export type ObjectLiteralDeclarationStyle = "table" | "list" | "component" export type SectionKey = | "comment" @@ -23,6 +23,7 @@ export type SectionKey = | "member_declaration_indexSignature" | "member_declaration_signatures" | "member_declaration_typeDeclaration" + | "member_declaration_example" | "member_getteSetter_getSignature" | "member_getteSetter_setSignature" | "member_signatures" @@ -33,10 +34,10 @@ export type SectionKey = | "member_signature_comment" | "member_signature_typeParameters" | "member_signature_parameters" - | "showReturnSignature" + | "member_signature_example" + | "member_signature_returns" | "member_signature_declarationSignatures" | "member_signature_declarationChildren" - | "member_signature_comment" | "member_signature_sources" | "member_sources_implementationOf" | "member_sources_inheritedFrom" @@ -70,8 +71,9 @@ export type FormattingOptionType = { showCommentsAsHeader?: boolean showCommentsAsDetails?: boolean parameterStyle?: ParameterStyle - showReturnSignature?: boolean frontmatterData?: Record + parameterComponent?: string + mdxImports?: string[] } export type FormattingOptionsType = { @@ -90,6 +92,15 @@ export type Mapping = { template: (pageEvent: PageEvent) => string } +export type Parameter = { + name: string + type: string + optional?: boolean + defaultValue?: string + description?: string + children?: Parameter[] +} + export class NavigationItem { title: string url: string diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/utils.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/utils.ts index b54d3166b7..2b5fc33c76 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/utils.ts +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/utils.ts @@ -18,6 +18,7 @@ export function formatContents(contents: string) { export function escapeChars(str: string) { return str + .replace(/>/g, "\\>") .replace(/>/g, "\\>") .replace(/_/g, "\\_") .replace(/`/g, "\\`") diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/utils/reflection-formatter.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/utils/reflection-formatter.ts index c7d8cce3e9..a327cecc22 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/utils/reflection-formatter.ts +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/utils/reflection-formatter.ts @@ -1,14 +1,38 @@ -import { Comment, DeclarationReflection, ReflectionType } from "typedoc" +import { + Comment, + DeclarationReflection, + ProjectReflection, + ReflectionType, + SomeType, +} from "typedoc" import * as Handlebars from "handlebars" import { stripLineBreaks } from "../utils" -import { ReflectionParameterType } from "../types" +import { Parameter, ParameterStyle, ReflectionParameterType } from "../types" +import getType, { getReflectionType } from "./type-utils" const MAX_LEVEL = 3 -export default function reflectionFomatter( +export default function reflectionFormatter( + reflection: ReflectionParameterType, + type: ParameterStyle = "table", + level = 1 +): string | Parameter { + switch (type) { + case "list": + return reflectionListFormatter(reflection, level) + case "component": + return reflectionComponentFormatter(reflection, level) + case "table": + return reflectionTableFormatter(reflection) + default: + return "" + } +} + +export function reflectionListFormatter( reflection: ReflectionParameterType, level = 1 -) { +): string { const prefix = `${Array(level - 1) .fill("\t") .join("")}-` @@ -25,16 +49,17 @@ export default function reflectionFomatter( if (comments) { item += stripLineBreaks(Handlebars.helpers.comments(comments)) + } + + const hasChildren = "children" in reflection && reflection.children?.length + + if ((reflection.type || hasChildren) && level + 1 <= MAX_LEVEL) { + const children = hasChildren + ? reflection.children + : getTypeChildren(reflection.type!, reflection.project) const itemChildren: string[] = [] - comments.summary.forEach((commentSummary) => { - if ("target" in commentSummary) { - const targetReflection = commentSummary.target as DeclarationReflection - if (targetReflection.children && level + 1 <= MAX_LEVEL) { - targetReflection.children.forEach((childItem) => { - itemChildren.push(reflectionFomatter(childItem, level + 1)) - }) - } - } + children?.forEach((childItem) => { + itemChildren.push(reflectionListFormatter(childItem, level + 1)) }) if (itemChildren.length) { // TODO maybe we should check the type of the reflection and replace @@ -50,7 +75,120 @@ export default function reflectionFomatter( return item } -function getDefaultValue(parameter: ReflectionParameterType): string | null { +export function reflectionComponentFormatter( + reflection: ReflectionParameterType, + level = 1 +): Parameter { + const defaultValue = getDefaultValue(reflection) || "" + const optional = reflection.flags.isOptional + const comments = getComments(reflection) + const componentItem: Parameter = { + name: reflection.name, + type: reflection.type + ? getType(reflection.type, "object") + : getReflectionType(reflection, "object"), + description: comments + ? stripLineBreaks(Handlebars.helpers.comments(comments)) + : "", + optional, + defaultValue, + children: [], + } + + const hasChildren = "children" in reflection && reflection.children?.length + + if ((reflection.type || hasChildren) && level + 1 <= MAX_LEVEL) { + const children = hasChildren + ? reflection.children + : getTypeChildren(reflection.type!, reflection.project) + children?.forEach((childItem) => { + componentItem.children?.push( + reflectionComponentFormatter(childItem, level + 1) + ) + }) + } + + return componentItem +} + +export function reflectionTableFormatter( + parameter: ReflectionParameterType +): string { + const showDefaults = hasDefaultValues([parameter]) + + const hasComments = !!parameter.comment?.hasVisibleComponent() + + const row: string[] = [] + + const nbsp = " " // ? <== Unicode no-break space character + const rest = parameter.flags.isRest ? "..." : "" + const optional = parameter.flags.isOptional ? "?" : "" + + const isDestructuredParam = parameter.name == "__namedParameters" + const isDestructuredParamProp = + parameter.name.startsWith("__namedParameters.") + + if (isDestructuredParam) { + row.push(`\`${rest}«destructured»\``) + } else if (isDestructuredParamProp) { + row.push(`›${nbsp}\`${rest}${parameter.name.slice(18)}${optional}\``) + } else { + row.push(`\`${rest}${parameter.name}${optional}\``) + } + + row.push( + parameter.type + ? Handlebars.helpers.type.call(parameter.type, "object") + : getReflectionType(parameter, "object") + ) + + if (showDefaults) { + row.push(getDefaultValue(parameter) || "") + } + if (hasComments) { + const comments = getComments(parameter) + if (comments) { + row.push( + stripLineBreaks(Handlebars.helpers.comments(comments)).replace( + /\|/g, + "\\|" + ) + ) + } else { + row.push("-") + } + } + return `| ${row.join(" | ")} |\n` +} + +export function getTableHeaders( + parameters: ReflectionParameterType[], + showTypeHeader?: boolean +): string[] { + const showDefaults = hasDefaultValues(parameters) + const hasComments = parameters.some( + (parameter) => !!parameter.comment?.hasVisibleComponent() + ) + const headers = ["Name"] + + if (showTypeHeader) { + headers.push("Type") + } + + if (showDefaults) { + headers.push("Default value") + } + + if (hasComments) { + headers.push("Description") + } + + return headers +} + +export function getDefaultValue( + parameter: ReflectionParameterType +): string | null { if (!("defaultValue" in parameter)) { return null } @@ -59,7 +197,21 @@ function getDefaultValue(parameter: ReflectionParameterType): string | null { : null } -function getComments(parameter: ReflectionParameterType): Comment | undefined { +export function hasDefaultValues(parameters: ReflectionParameterType[]) { + const defaultValues = (parameters as ReflectionParameterType[]).map( + (param) => + "defaultValue" in param && + param.defaultValue !== "{}" && + param.defaultValue !== "..." && + !!param.defaultValue + ) + + return !defaultValues.every((value) => !value) +} + +export function getComments( + parameter: ReflectionParameterType +): Comment | undefined { if (parameter.type instanceof ReflectionType) { if ( parameter.type?.declaration?.signatures && @@ -70,3 +222,28 @@ function getComments(parameter: ReflectionParameterType): Comment | undefined { } return parameter.comment } + +export function getTypeChildren( + reflectionType: SomeType, + project: ProjectReflection +) { + let children: DeclarationReflection[] = [] + + switch (reflectionType.type) { + case "reference": + // eslint-disable-next-line no-case-declarations + const referencedReflection = project.getChildByName(reflectionType.name) + + if ( + referencedReflection instanceof DeclarationReflection && + referencedReflection.children + ) { + children = referencedReflection.children + } + break + case "array": + children = getTypeChildren(reflectionType.elementType, project) + } + + return children +} diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/utils/return-reflection-formatter.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/utils/return-reflection-formatter.ts new file mode 100644 index 0000000000..d60efc9072 --- /dev/null +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/utils/return-reflection-formatter.ts @@ -0,0 +1,180 @@ +import { + Comment, + DeclarationReflection, + ProjectReflection, + ReflectionFlags, + SomeType, +} from "typedoc" +import * as Handlebars from "handlebars" +import getType from "./type-utils" +import { Parameter } from "../types" +import { + getDefaultValue, + reflectionComponentFormatter, +} from "./reflection-formatter" + +const MAX_LEVEL = 3 + +export function returnReflectionComponentFormatter( + reflectionType: SomeType, + project: ProjectReflection, + comment?: Comment, + level = 1 +): Parameter[] { + const typeName = getType(reflectionType, "object", false) + const type = getType(reflectionType, "object") + const componentItem: Parameter[] = [] + if (reflectionType.type === "reference") { + // put type name as a title and its referenced items as children. + if (reflectionType.typeArguments) { + const parentKey = componentItem.push({ + name: "name" in reflectionType ? reflectionType.name : typeName, + type, + optional: + "flags" in reflectionType + ? (reflectionType.flags as ReflectionFlags).isOptional + : false, + defaultValue: + "declaration" in reflectionType + ? getDefaultValue( + reflectionType.declaration as DeclarationReflection + ) || "" + : "", + description: comment ? getReturnComment(comment) : "", + children: [], + }) + if (!isOnlyVoid(reflectionType.typeArguments) && level + 1 <= MAX_LEVEL) { + reflectionType.typeArguments.forEach((typeArg) => { + const typeArgComponent = returnReflectionComponentFormatter( + typeArg, + project, + undefined, + level + 1 + ) + if (typeArgComponent.length) { + componentItem[parentKey - 1].children?.push(...typeArgComponent) + } + }) + } + } else if (reflectionType.reflection) { + componentItem.push( + reflectionComponentFormatter( + reflectionType.reflection as DeclarationReflection, + level + ) + ) + } else { + // try to retrieve reflection by its name + const reflection = project.getChildByName(reflectionType.name) + if (reflection) { + componentItem.push( + reflectionComponentFormatter( + reflection as DeclarationReflection, + level + ) + ) + } + } + } else if (reflectionType.type === "array") { + const parentKey = componentItem.push({ + name: + "name" in reflectionType ? (reflectionType.name as string) : typeName, + type, + optional: + "flags" in reflectionType + ? (reflectionType.flags as ReflectionFlags).isOptional + : false, + defaultValue: + "declaration" in reflectionType + ? getDefaultValue( + reflectionType.declaration as DeclarationReflection + ) || "" + : "", + description: comment ? getReturnComment(comment) : "", + children: [], + }) + if (level + 1 <= MAX_LEVEL) { + const elementTypeItem = returnReflectionComponentFormatter( + reflectionType.elementType, + project, + undefined, + level + 1 + ) + if (elementTypeItem.length) { + componentItem[parentKey - 1].children?.push(...elementTypeItem) + } + } + } else if (reflectionType.type === "tuple") { + let pushTo: Parameter[] = [] + if (level === 1) { + const parentKey = componentItem.push({ + name: + "name" in reflectionType ? (reflectionType.name as string) : typeName, + type, + optional: + "flags" in reflectionType + ? (reflectionType.flags as ReflectionFlags).isOptional + : false, + defaultValue: + "declaration" in reflectionType + ? getDefaultValue( + reflectionType.declaration as DeclarationReflection + ) || "" + : "", + description: comment ? getReturnComment(comment) : "", + children: [], + }) + pushTo = componentItem[parentKey - 1].children! + } else { + pushTo = componentItem + } + if (level + 1 <= MAX_LEVEL) { + reflectionType.elements.forEach((element) => { + const elementTypeItem = returnReflectionComponentFormatter( + element, + project, + undefined, + level + 1 + ) + if (elementTypeItem.length) { + pushTo.push(...elementTypeItem) + } + }) + } + } else { + // put type as the only component. + componentItem.push({ + name: "name" in reflectionType ? reflectionType.name : typeName, + type, + optional: + "flags" in reflectionType + ? (reflectionType.flags as ReflectionFlags).isOptional + : true, + defaultValue: + "declaration" in reflectionType + ? getDefaultValue(reflectionType.declaration) || "" + : "", + description: comment ? getReturnComment(comment) : "", + children: [], + }) + } + + return componentItem +} + +export function getReturnComment(comment: Comment): string { + if (!comment.blockTags?.length) { + return "" + } + + return comment.blockTags + .filter((tag) => tag.tag === "@returns") + .map((tag) => Handlebars.helpers.comment(tag.content)) + .join("\n\n") +} + +export function isOnlyVoid(reflectionTypes: SomeType[]) { + return reflectionTypes.every( + (type) => type.type === "intrinsic" && type.name === "void" + ) +} diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/utils/type-utils.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/utils/type-utils.ts new file mode 100644 index 0000000000..4460e30851 --- /dev/null +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/utils/type-utils.ts @@ -0,0 +1,300 @@ +import { + ArrayType, + ConditionalType, + DeclarationReflection, + IndexedAccessType, + InferredType, + IntersectionType, + IntrinsicType, + LiteralType, + QueryType, + ReferenceType, + ReflectionType, + SignatureReflection, + SomeType, + TupleType, + TypeOperatorType, + TypeParameterReflection, + UnionType, + UnknownType, +} from "typedoc" +import * as Handlebars from "handlebars" +import { ReflectionParameterType } from "../types" +import { escapeChars } from "../utils" + +export type Collapse = "object" | "function" | "all" | "none" + +export default function getType( + reflectionType: SomeType, + collapse: Collapse = "none", + emphasis = true +): string { + if (reflectionType instanceof ReferenceType) { + return getReferenceType(reflectionType, emphasis) + } + + if (reflectionType instanceof ArrayType && reflectionType.elementType) { + return getArrayType(reflectionType, emphasis) + } + + if (reflectionType instanceof UnionType && reflectionType.types) { + return getUnionType(reflectionType, emphasis) + } + + if (reflectionType instanceof IntersectionType && reflectionType.types) { + return getIntersectionType(reflectionType) + } + + if (reflectionType instanceof TupleType && reflectionType.elements) { + return getTupleType(reflectionType) + } + + if (reflectionType instanceof IntrinsicType && reflectionType.name) { + return getIntrinsicType(reflectionType, emphasis) + } + + if (reflectionType instanceof ReflectionType) { + return getReflectionType(reflectionType.declaration, collapse) + } + + if (reflectionType instanceof DeclarationReflection) { + return getReflectionType(reflectionType, collapse) + } + + if (reflectionType instanceof TypeOperatorType) { + return getTypeOperatorType(reflectionType) + } + + if (reflectionType instanceof QueryType) { + return getQueryType(reflectionType) + } + + if (reflectionType instanceof ConditionalType) { + return getConditionalType(reflectionType) + } + + if (reflectionType instanceof IndexedAccessType) { + return getIndexAccessType(reflectionType) + } + + if (reflectionType instanceof UnknownType) { + return getUnknownType(reflectionType) + } + + if (reflectionType instanceof InferredType) { + return getInferredType(reflectionType) + } + + if (reflectionType instanceof LiteralType) { + return getLiteralType(reflectionType) + } + + return reflectionType ? escapeChars(reflectionType.toString()) : "" +} + +export function getReflectionType( + model: ReflectionParameterType, + collapse: Collapse +): string { + if ("signatures" in model && model.signatures) { + return collapse === "function" || collapse === "all" + ? `\`fn\`` + : getFunctionType(model.signatures) + } + return collapse === "object" || collapse === "all" + ? `\`object\`` + : getDeclarationType(model as DeclarationReflection) +} + +export function getDeclarationType(model: DeclarationReflection): string { + if (model.indexSignature || model.children) { + let indexSignature = "" + const declarationIndexSignature = model.indexSignature + if (declarationIndexSignature) { + const key = declarationIndexSignature.parameters + ? declarationIndexSignature.parameters.map( + (param) => `\`[${param.name}: ${param.type}]\`` + ) + : "" + const obj = declarationIndexSignature.type + ? getType(declarationIndexSignature.type) + : "" + indexSignature = `${key}: ${obj}; ` + } + const types = + model.children && + model.children.map((obj) => { + return `\`${obj.name}${obj.flags.isOptional ? "?" : ""}\`: ${ + obj.type ? getType(obj.type) : escapeChars(obj.toString()) + } ${ + obj.defaultValue && obj.defaultValue !== "..." + ? `= ${escapeChars(obj.defaultValue)}` + : "" + }` + }) + return `{ ${indexSignature ? indexSignature : ""}${ + types ? types.join("; ") : "" + } }${ + model.defaultValue && model.defaultValue !== "..." + ? `= ${escapeChars(model.defaultValue)}` + : "" + }` + } + return "{}" +} + +export function getFunctionType( + modelSignatures: SignatureReflection[] +): string { + const functions = modelSignatures.map((fn) => { + const typeParams = fn.typeParameters + ? `<${fn.typeParameters + .map((typeParameter) => typeParameter.name) + .join(", ")}\\>` + : [] + const params = fn.parameters + ? fn.parameters.map((param) => { + return `${param.flags.isRest ? "..." : ""}\`${param.name}${ + param.flags.isOptional ? "?" : "" + }\`: ${ + param.type ? getType(param.type) : escapeChars(param.toString()) + }` + }) + : [] + const returns = fn.type ? getType(fn.type) : escapeChars(fn.toString()) + return typeParams + `(${params.join(", ")}) => ${returns}` + }) + return functions.join("") +} + +export function getLiteralType(model: LiteralType): string { + if (typeof model.value === "bigint") { + return `\`${model.value}n\`` + } + return `\`\`${JSON.stringify(model.value)}\`\`` +} + +export function getReferenceType( + model: ReferenceType, + emphasis: boolean +): string { + const shouldShowLink = emphasis && model.name !== "Record" + if (model.reflection || (model.name && model.typeArguments)) { + const reflection: string[] = [] + + if (model.reflection?.url) { + reflection.push( + shouldShowLink + ? `[${`\`${model.reflection.name}\``}](${Handlebars.helpers.relativeURL( + model.reflection.url + )})` + : model.reflection.name + ) + } else { + reflection.push( + shouldShowLink + ? model.externalUrl + ? `[${`\`${model.name}\``}]( ${model.externalUrl} )` + : `\`${model.name}\`` + : model.name + ) + } + if (model.typeArguments && model.typeArguments.length > 0) { + reflection.push( + `<${model.typeArguments + .map((typeArgument) => getType(typeArgument, "none", emphasis)) + .join(", ")}\\>` + ) + } + return reflection.join("") + } + return shouldShowLink + ? model.externalUrl + ? `[${`\`${model.name}\``}]( ${model.externalUrl} )` + : `\`${model.name}\`` + : escapeChars(model.name) +} + +export function getArrayType(model: ArrayType, emphasis: boolean): string { + const arrayType = getType(model.elementType, "none", emphasis) + return model.elementType.type === "union" + ? `(${arrayType})[]` + : `${arrayType}[]` +} + +export function getUnionType(model: UnionType, emphasis: boolean): string { + return model.types + .map((unionType) => getType(unionType, "none", emphasis)) + .join(` \\| `) +} + +export function getIntersectionType(model: IntersectionType): string { + return model.types + .map((intersectionType) => getType(intersectionType)) + .join(" & ") +} + +export function getTupleType(model: TupleType): string { + return `[${model.elements.map((element) => getType(element)).join(", ")}]` +} + +export function getIntrinsicType( + model: IntrinsicType, + emphasis: boolean +): string { + return emphasis ? `\`${model.name}\`` : escapeChars(model.name) +} + +export function getTypeOperatorType(model: TypeOperatorType): string { + return `${model.operator} ${getType(model.target)}` +} + +export function getQueryType(model: QueryType): string { + return `typeof ${getType(model.queryType)}` +} + +export function getInferredType(model: InferredType): string { + return `infer ${escapeChars(model.name)}` +} + +export function getUnknownType(model: UnknownType): string { + return escapeChars(model.name) +} + +export function getConditionalType(model: ConditionalType): string { + const md: string[] = [] + if (model.checkType) { + md.push(getType(model.checkType)) + } + md.push("extends") + if (model.extendsType) { + md.push(getType(model.extendsType)) + } + md.push("?") + if (model.trueType) { + md.push(getType(model.trueType)) + } + md.push(":") + if (model.falseType) { + md.push(getType(model.falseType)) + } + return md.join(" ") +} + +export function getIndexAccessType(model: IndexedAccessType): string { + const md: string[] = [] + if (model.objectType) { + md.push(getType(model.objectType)) + } + if (model.indexType) { + md.push(`[${getType(model.indexType)}]`) + } + return md.join("") +} + +export function hasTypes(parameters: TypeParameterReflection[]) { + const types = (parameters as TypeParameterReflection[]).map( + (param) => !!param.type || !!param.default + ) + return !types.every((value) => !value) +} diff --git a/packages/types/src/pricing/common/currency.ts b/packages/types/src/pricing/common/currency.ts index 89acdb9a20..27a28e6431 100644 --- a/packages/types/src/pricing/common/currency.ts +++ b/packages/types/src/pricing/common/currency.ts @@ -3,14 +3,13 @@ import { BaseFilterable } from "../../dal" /** * @interface * - * An object representing a currency. + * A currency's data. * - * @prop code - a string indicating the code of the currency. - * @prop symbol - a string indicating the symbol of the currency. + * @prop code - The code of the currency. + * @prop symbol - The symbol of the currency. * @prop symbol_native - - * a string indicating the symbol of the currecy in its native form. - * This is typically the symbol used when displaying a price. - * @prop name - a string indicating the name of the currency. + * The symbol of the currecy in its native form. This is typically the symbol used when displaying a price. + * @prop name - The name of the currency. */ export interface CurrencyDTO { code: string @@ -22,14 +21,13 @@ export interface CurrencyDTO { /** * @interface * - * An object that holds data to create a currency. + * A currency to create. * - * @prop code - a string indicating the code of the currency. - * @prop symbol - a string indicating the symbol of the currency. + * @prop code - The code of the currency. + * @prop symbol - The symbol of the currency. * @prop symbol_native - - * a string indicating the symbol of the currecy in its native form. - * This is typically the symbol used when displaying a price. - * @prop name - a string indicating the name of the currency. + * The symbol of the currecy in its native form. This is typically the symbol used when displaying a price. + * @prop name - The name of the currency. */ export interface CreateCurrencyDTO { code: string @@ -41,14 +39,13 @@ export interface CreateCurrencyDTO { /** * @interface * - * An object that holds data to update a currency. The currency code must be provided to identify which currency to update. + * The data to update in a currency. The `code` is used to identify which currency to update. * - * @prop code - a string indicating the code of the currency to update. - * @prop symbol - a string indicating the symbol of the currency. + * @prop code - The code of the currency to update. + * @prop symbol - The symbol of the currency. * @prop symbol_native - - * a string indicating the symbol of the currecy in its native form. - * This is typically the symbol used when displaying a price. - * @prop name - a string indicating the name of the currency. + * The symbol of the currecy in its native form. This is typically the symbol used when displaying a price. + * @prop name - The name of the currency. */ export interface UpdateCurrencyDTO { code: string @@ -60,9 +57,9 @@ export interface UpdateCurrencyDTO { /** * @interface * - * An object used to filter retrieved currencies. + * Filters to apply on a currency. * - * @prop code - an array of strings, each being a currency code to filter the currencies. + * @prop code - The codes to filter the currencies by. */ export interface FilterableCurrencyProps extends BaseFilterable { diff --git a/packages/types/src/pricing/common/money-amount.ts b/packages/types/src/pricing/common/money-amount.ts index c233721cf8..96bd1ba94b 100644 --- a/packages/types/src/pricing/common/money-amount.ts +++ b/packages/types/src/pricing/common/money-amount.ts @@ -4,14 +4,14 @@ import { CreateCurrencyDTO, CurrencyDTO } from "./currency" /** * @interface * - * An object that holds prices, which typically belong to a price set. + * A money amount's data. A money amount represents a price. * - * @prop id - A string that indicates the ID of the money amount. A money amount represents a price. - * @prop currency_code - A string that indicates the currency code of this price. - * @prop currency - An object of type {@link CurrencyDTO} that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. - * @prop amount - A number indicating the amount of this price. - * @prop min_quantity - A number that indicates the minimum quantity required to be purchased for this price to be applied. - * @prop max_quantity - A number that indicates the maximum quantity required to be purchased for this price to be applied. + * @prop id - The ID of the money amount. + * @prop currency_code - The currency code of this money amount. + * @prop currency - The money amount's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. + * @prop amount - The price of this money amount. + * @prop min_quantity - The minimum quantity required to be purchased for this price to be applied. + * @prop max_quantity - The maximum quantity required to be purchased for this price to be applied. */ export interface MoneyAmountDTO { id: string @@ -23,16 +23,16 @@ export interface MoneyAmountDTO { } /** - * * @interface + * @interface * - * An object that holds data to create a money amount. + * The money amount to create. * - * @prop id - A string that indicates the ID of the money amount. - * @prop currency_code - A string that indicates the currency code of this money amount. - * @prop currency - An object of type {@link CurrencyDTO} that holds the details of the money amount's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. - * @prop amount - A number indicating the amount of this money amount. - * @prop min_quantity - A number that indicates the minimum quantity required to be purchased for this money amount to be applied. - * @prop max_quantity - A number that indicates the maximum quantity required to be purchased for this money amount to be applied. + * @prop id - The ID of the money amount. + * @prop currency_code - The currency code of this money amount. + * @prop currency - The currency of this money amount. + * @prop amount - The amount of this money amount. + * @prop min_quantity - The minimum quantity required to be purchased for this money amount to be applied. + * @prop max_quantity - The maximum quantity required to be purchased for this money amount to be applied. */ export interface CreateMoneyAmountDTO { id?: string @@ -46,14 +46,14 @@ export interface CreateMoneyAmountDTO { /** * * @interface * - * An object that holds data to update a money amount. + * The data to update in a money amount. The `id` is used to identify which money amount to update. * - * @prop id - A string that indicates the ID of the money amount to update. - * @prop currency_code - A string that indicates the currency code of the money amount. - * @prop currency - An object of type {@link CurrencyDTO} that holds the details of the money amount's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. - * @prop amount - A number indicating the amount of this money amount. - * @prop min_quantity - A number that indicates the minimum quantity required to be purchased for this money amount to be applied. - * @prop max_quantity - A number that indicates the maximum quantity required to be purchased for this money amount to be applied. + * @prop id - The ID of the money amount to update. + * @prop currency_code - The code of the currency to associate with the money amount. + * @prop currency - The currency to associte with the money amount. + * @prop amount - The price of this money amount. + * @prop min_quantity - The minimum quantity required to be purchased for this money amount to be applied. + * @prop max_quantity - The maximum quantity required to be purchased for this money amount to be applied. */ export interface UpdateMoneyAmountDTO { id: string @@ -66,10 +66,10 @@ export interface UpdateMoneyAmountDTO { /** * @interface * - * An object that can be used to filter money amounts. + * Filters to apply on a money amount. * - * @prop id - An array of strings, each being an ID to filter money amounts. - * @prop currency_code - A string or an array of strings, each being a currency code to filter money amounts. + * @prop id - IDs to filter money amounts by. + * @prop currency_code - Currency codes to filter money amounts by. */ export interface FilterableMoneyAmountProps extends BaseFilterable { diff --git a/packages/types/src/pricing/common/price-rule.ts b/packages/types/src/pricing/common/price-rule.ts index 398fda2686..a0e970ef1f 100644 --- a/packages/types/src/pricing/common/price-rule.ts +++ b/packages/types/src/pricing/common/price-rule.ts @@ -5,18 +5,17 @@ import { RuleTypeDTO } from "./rule-type" /** * @interface * - * An object that represents a price rule. + * A price rule's data. * - * @prop id - A string indicating the ID of the price rule. - * @prop price_set_id - A string indicating the ID of the associated price set. - * @prop price_set - An object of type {@link PriceSetDTO} that holds the data of the associated price set. It may only be available if the relation `price_set` is expanded. - * @prop rule_type_id - A string indicating the ID of the associated rule type. - * @prop rule_type - An object of type {@link RuleTypeDTO} that holds the data of the associated rule type. It may only be available if the relation `rule_type` is expanded. - * @prop is_dynamic - A boolean indicating whether the price rule is dynamic. - * @prop value - A string indicating the value of the price rule. - * @prop priority - A number indicating the priority of the price rule in comparison to other applicable price rules. - * @prop price_set_money_amount_id - A string indicating the ID of the associated price set money amount. - * @prop price_list_id - A string indicating the ID of the associated price list. + * @prop id - The ID of the price rule. + * @prop price_set_id - The ID of the associated price set. + * @prop price_set - The associated price set. It may only be available if the relation `price_set` is expanded. + * @prop rule_type_id - The ID of the associated rule type. + * @prop rule_type - The associated rule type. It may only be available if the relation `rule_type` is expanded. + * @prop value - The value of the price rule. + * @prop priority - The priority of the price rule in comparison to other applicable price rules. + * @prop price_set_money_amount_id - The ID of the associated price set money amount. + * @prop price_list_id - The ID of the associated price list. */ export interface PriceRuleDTO { id: string @@ -24,6 +23,12 @@ export interface PriceRuleDTO { price_set: PriceSetDTO rule_type_id: string rule_type: RuleTypeDTO + /** + * @ignore + * @privateRemark + * + * Behavior behind this property is not implemented yet. + */ is_dynamic: boolean value: string priority: number @@ -35,21 +40,26 @@ export interface PriceRuleDTO { * * @interface * - * An object used to specify the necessary data to create a price rule. + * A price rule to create. * - * @prop id - A string indicating the ID of the price rule. - * @prop price_set_id - A string indicating the ID of the associated price set. - * @prop rule_type_id - A string indicating the ID of the associated rule type. - * @prop is_dynamic - A boolean indicating whether the price rule is dynamic. - * @prop value - A string indicating the value of the price rule. - * @prop priority - A number indicating the priority of the price rule in comparison to other applicable price rules. - * @prop price_set_money_amount_id - A string indicating the ID of the associated price set money amount. - * @prop price_list_id - A string indicating the ID of the associated price list. + * @prop id - The ID of the price rule. + * @prop price_set_id - The ID of the associated price set. + * @prop rule_type_id - The ID of the associated rule type. + * @prop value - The value of the price rule. + * @prop priority - The priority of the price rule in comparison to other applicable price rules. + * @prop price_set_money_amount_id - The ID of the associated price set money amount. + * @prop price_list_id - The ID of the associated price list. */ export interface CreatePriceRuleDTO { id: string price_set_id: string rule_type_id: string + /** + * @ignore + * @privateRemark + * + * Behavior behind this property is not implemented yet. + */ is_dynamic?: boolean value: string priority?: number @@ -61,15 +71,15 @@ export interface CreatePriceRuleDTO { * * @interface * - * An object used to specify the necessary data to update a price rule. + * The data to update in a price rule. The `id` is used to identify which money amount to update. * - * @prop id - A string indicating the ID of the price rule to update. - * @prop price_set_id - A string indicating the ID of the associated price set. - * @prop rule_type_id - A string indicating the ID of the associated rule type. - * @prop value - A string indicating the value of the price rule. - * @prop priority - A number indicating the priority of the price rule in comparison to other applicable price rules. - * @prop price_set_money_amount_id - A string indicating the ID of the associated price set money amount. - * @prop price_list_id - A string indicating the ID of the associated price list. + * @prop id - The ID of the price rule to update. + * @prop price_set_id - The ID of the associated price set. + * @prop rule_type_id - The ID of the associated rule type. + * @prop value - The value of the price rule. + * @prop priority - The priority of the price rule in comparison to other applicable price rules. + * @prop price_set_money_amount_id - The ID of the associated price set money amount. + * @prop price_list_id - The ID of the associated price list. */ export interface UpdatePriceRuleDTO { id: string @@ -91,12 +101,12 @@ export interface UpdatePriceRuleDTO { /** * @interface * - * An object used to filter price rules when retrieving them. + * Filters to apply to price rules. * - * @prop id - An array of strings, each indicating an ID to filter price rules. - * @prop name - An array of strings, each indicating a name to filter price rules. - * @prop price_set_id - An array of strings, each indicating a price set ID to filter price rules. - * @prop rule_type_id - An array of strings, each indicating a rule type ID to filter rule types. + * @prop id - The IDs to filter price rules by. + * @prop name - The names to filter price rules by. + * @prop price_set_id - The IDs to filter the price rule's associated price set. + * @prop rule_type_id - The IDs to filter the price rule's associated rule type. */ export interface FilterablePriceRuleProps extends BaseFilterable { diff --git a/packages/types/src/pricing/common/price-set-money-amount-rules.ts b/packages/types/src/pricing/common/price-set-money-amount-rules.ts index 451ffd9041..a5e7d7cfb6 100644 --- a/packages/types/src/pricing/common/price-set-money-amount-rules.ts +++ b/packages/types/src/pricing/common/price-set-money-amount-rules.ts @@ -5,12 +5,12 @@ import { RuleTypeDTO } from "./rule-type" /** * @interface * - * An object representing a price set money amount rule, which holds data related to the association between a price set money amount and a rule. + * A price set money amount rule's data. * - * @prop id - A string indicating the ID of the price set money amount. - * @prop price_set_money_amount - an object of type {@link PriceSetMoneyAmountDTO} holding the data of the associated price set money amount. - * @prop rule_type - an object of type {@link RuleTypeDTO} holding the data of the associated rule type. - * @prop value - a string indicating the value of the price set money amount rule. + * @prop id - The ID of the price set money amount. + * @prop price_set_money_amount - The associated price set money amount. It may only be available if the relation `price_set_money_amount` is expanded. + * @prop rule_type - The associated rule type. It may only be available if the relation `rule_type` is expanded. + * @prop value - The value of the price set money amount rule. */ export interface PriceSetMoneyAmountRulesDTO { id: string @@ -22,11 +22,11 @@ export interface PriceSetMoneyAmountRulesDTO { /** * @interface * - * An object used to create a price set money amount rule, which represents an association between a price set money amount and a rule type. + * The price set money amount rule to create. * - * @prop price_set_money_amount - A string indicating the ID of a price set money amount. - * @prop rule_type - A string indicating the ID of a rule type. - * @prop value - A string indicating the value of the price set money amount rule. + * @prop price_set_money_amount - The ID of a price set money amount. + * @prop rule_type - The ID of a rule type. + * @prop value - The value of the price set money amount rule. */ export interface CreatePriceSetMoneyAmountRulesDTO { price_set_money_amount: string @@ -37,12 +37,12 @@ export interface CreatePriceSetMoneyAmountRulesDTO { /** * @interface * - * An object used to update a price set money amount rule. The price set money amount rule is identified by the provided `id`. + * The data to update in a price set money amount rule. The `id` is used to identify which money amount to update. * - * @prop id - A string indicating the ID of the price set money amount rule to update. - * @prop price_set_money_amount - A string indicating the ID of a price set money amount. - * @prop rule_type - A string indicating the ID of a rule type. - * @prop value - A string indicating the value of the price set money amount rule. + * @prop id - The ID of the price set money amount rule to update. + * @prop price_set_money_amount - The ID of a price set money amount. + * @prop rule_type - The ID of a rule type. + * @prop value - The value of the price set money amount rule. */ export interface UpdatePriceSetMoneyAmountRulesDTO { id: string @@ -54,12 +54,12 @@ export interface UpdatePriceSetMoneyAmountRulesDTO { /** * @interface * - * An object used to filter price set money amount rules when listing them. + * Filters to apply on price set money amount rules. * - * @prop id - An array of strings, each string indicating an ID to filter the price set money amount rules. - * @prop rule_type_id - An array of strings, each string indicating the ID of a rule type to filter the price set money amount rules. - * @prop price_set_money_amount_id - an array of strings, each string indicating the ID of a price set money amount to filter the price set money amount rules. - * @prop value - an array of strings, each string indicating a value to filter the price set money amount rules. + * @prop id - The ID to filter price set money amount rules by. + * @prop rule_type_id - The IDs to filter the price set money amount rule's associated rule type. + * @prop price_set_money_amount_id - The IDs to filter the price set money amount rule's associated price set money amount. + * @prop value - The value to filter price set money amount rules by. */ export interface FilterablePriceSetMoneyAmountRulesProps extends BaseFilterable { diff --git a/packages/types/src/pricing/common/price-set-money-amount.ts b/packages/types/src/pricing/common/price-set-money-amount.ts index e7877e8284..b5a39e05d4 100644 --- a/packages/types/src/pricing/common/price-set-money-amount.ts +++ b/packages/types/src/pricing/common/price-set-money-amount.ts @@ -4,12 +4,12 @@ import { PriceSetDTO } from "./price-set" /** * @interface * - * An object representing a price set money amount, which holds the data related to the association between a price set and a money amount. + * A price set money amount's data. * - * @prop id - a string indicating the ID of a price set money amount. - * @prop title - a string indicating the title of the price set money amount. - * @prop price_set - an object of type {@link PriceSetDTO} holding the data of the associated price set. - * @prop money_amount - an object of type {@link MoneyAmountDTO} holding the data of the associated money amount. + * @prop id - The ID of a price set money amount. + * @prop title - The title of the price set money amount. + * @prop price_set - The price set associated with the price set money amount. It may only be available if the relation `price_set` is expanded. + * @prop money_amount - The money amount associated with the price set money amount. It may only be available if the relation `money_amount` is expanded. */ export interface PriceSetMoneyAmountDTO { id: string diff --git a/packages/types/src/pricing/common/price-set.ts b/packages/types/src/pricing/common/price-set.ts index 8313ce09ea..2cae002e31 100644 --- a/packages/types/src/pricing/common/price-set.ts +++ b/packages/types/src/pricing/common/price-set.ts @@ -9,15 +9,12 @@ import { RuleTypeDTO } from "./rule-type" /** * @interface * - * Used to specify the context to calculate prices. For example, you can specify the currency code to calculate prices in. + * The context to calculate prices. For example, you can specify the currency code to calculate prices in. * * @prop context - * an object whose keys are the name of the context attribute. Its value can be a string or a number. For example, you can pass the `currency_code` property with its value being the currency code to calculate the price in. * Another example is passing the `quantity` property to calculate the price for that specified quantity, which finds a price set whose `min_quantity` and `max_quantity` conditions match the specified quantity. * - * @example - * - * To calculate prices */ export interface PricingContext { context?: Record @@ -26,9 +23,9 @@ export interface PricingContext { /** * @interface * - * Used to filter prices when calculating them. + * Filters to apply on prices. * - * @prop id - An array of strings, each being an ID of a price set. + * @prop id - IDs to filter prices. */ export interface PricingFilters { id: string[] @@ -37,11 +34,11 @@ export interface PricingFilters { /** * @interface * - * An object that holds the details of a retrieved price set. + * A price set's data. * - * @prop id - A string indicating the ID of the price set. - * @prop money_amounts - An array of objects of type {@link MoneyAmountDTO}, which holds the prices that belong to this price set. - * @prop rule_types - An array of objects of type {@link RuleTypeDTO}, which holds the rule types applied on this price set. + * @prop id - The ID of the price set. + * @prop money_amounts - The prices that belong to this price set. + * @prop rule_types - The rule types applied on this price set. * */ export interface PriceSetDTO { @@ -53,13 +50,13 @@ export interface PriceSetDTO { /** * @interface * - * An object that holds the details of a calculated price set. + * A calculated price set's data. * - * @prop id - a string indicating the ID of the price set. - * @prop amount - a number indicating the calculated amount. It can possibly be `null` if there's no price set up for the provided context. - * @prop currency_code - a string indicating the currency code of the calculated price. It can possibly be `null`. - * @prop min_quantity - a number indicaitng the minimum quantity required to be purchased for this price to apply. It's set if the `quantity` property is provided in the context. Otherwise, its value will be `null`. - * @prop max_quantity - a number indicaitng the maximum quantity required to be purchased for this price to apply. It's set if the `quantity` property is provided in the context. Otherwise, its value will be `null`. + * @prop id - The ID of the price set. + * @prop amount - The calculated amount. It can possibly be `null` if there's no price set up for the provided context. + * @prop currency_code - The currency code of the calculated price. It can possibly be `null`. + * @prop min_quantity - The minimum quantity required to be purchased for this price to apply. It's set if the `quantity` property is provided in the context. Otherwise, its value will be `null`. + * @prop max_quantity - The maximum quantity required to be purchased for this price to apply. It's set if the `quantity` property is provided in the context. Otherwise, its value will be `null`. */ export interface CalculatedPriceSetDTO { id: string @@ -72,10 +69,10 @@ export interface CalculatedPriceSetDTO { /** * @interface * - * An object used to specify the rules to add to a price set. + * The rules to add to a price set. * - * @prop priceSetId - A string indicating the ID of the price set to add the rules to. - * @prop rules - An array of objects, each object holds a property `attribute`, with its value being the `rule_attribute` of the rule to add to the price set. + * @prop priceSetId - The ID of the price set to add the rules to. + * @prop rules - The rules to add to a price set. The value of `attribute` is the value of the rule's `rule_attribute` attribute. */ export interface AddRulesDTO { priceSetId: string @@ -85,9 +82,9 @@ export interface AddRulesDTO { /** * @interface * - * An object used to pass prices data when creating a price set. + * The prices to create part of a price set. * - * @prop rules - An object whose keys are rule types' `rule_attribute` attribute, and values are the value of that rule associated with this price. + * @prop rules - The rules to add to the price. The object's keys are rule types' `rule_attribute` attribute, and values are the value of that rule associated with this price. */ export interface CreatePricesDTO extends CreateMoneyAmountDTO { rules: Record @@ -96,10 +93,10 @@ export interface CreatePricesDTO extends CreateMoneyAmountDTO { /** * @interface * - * An object used to specify prices to add to a price set. + * The prices to add to a price set. * - * @prop priceSetId - A string indicating the ID of the price set to add prices to. - * @prop prices - An array of objects of type {@link CreatePricesDTO}, each being a price to add to the price set. + * @prop priceSetId - The ID of the price set to add prices to. + * @prop prices - The prices to add to the price set. */ export interface AddPricesDTO { priceSetId: string @@ -109,10 +106,10 @@ export interface AddPricesDTO { /** * @interface * - * An object of expected properties when removing a price set's rules. + * The rules to remove from a price set. * - * @prop id - A string indicating the ID of the price set. - * @prop rules - An array of strings, each string is the `rule_attribute` of a rule you want to remove. + * @prop id - The ID of the price set. + * @prop rules - The rules to remove. Each string is the `rule_attribute` of a rule to remove. */ export interface RemovePriceSetRulesDTO { id: string @@ -122,12 +119,10 @@ export interface RemovePriceSetRulesDTO { /** * @interface * - * An object of expected properties when creating a price set. + * A price set to create. * - * @prop rules - - * An array of objects, each object accepts a property `rule_attribute`, whose value is a string indicating the `rule_attribute` value of a rule type. - * This property is used to specify the rule types associated with the price set. - * @prop prices - An array of objects of type {@link CreatePricesDTO}, each being a price to associate with the price set. + * @prop rules - The rules to associate with the price set. The value of `attribute` is the value of the rule's `rule_attribute` attribute. + * @prop prices -The prices to create and add to this price set. */ export interface CreatePriceSetDTO { rules?: { rule_attribute: string }[] @@ -137,7 +132,7 @@ export interface CreatePriceSetDTO { /** * @interface * - * An object of expected properties when updating a price set. + * The data to update in a price set. The `id` is used to identify which price set to update. * * @prop id - A string indicating the ID of the price set to update. */ @@ -148,10 +143,10 @@ export interface UpdatePriceSetDTO { /** * @interface * - * An object that can be used to specify filters on price sets. + * Filters to apply on price sets. * - * @prop id - An array of strings, each being an ID to filter price sets. - * @prop money_amounts - An object of type {@link FilterableMoneyAmountProps} that is used to filter the price sets by their associated money amounts. + * @prop id - IDs to filter price sets by. + * @prop money_amounts - Filters to apply on a price set's associated money amounts. */ export interface FilterablePriceSetProps extends BaseFilterable { diff --git a/packages/types/src/pricing/common/rule-type.ts b/packages/types/src/pricing/common/rule-type.ts index 68aba6be4a..589ebb26eb 100644 --- a/packages/types/src/pricing/common/rule-type.ts +++ b/packages/types/src/pricing/common/rule-type.ts @@ -3,12 +3,12 @@ import { BaseFilterable } from "../../dal" /** * @interface * - * An object that holds the details of a rule type. + * A rule type's data. * - * @prop id - A string indicating the ID of the rule type. - * @prop name - A string indicating the display name of the rule type. - * @prop rule_attribute - A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. - * @prop default_priority - A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. + * @prop id - The ID of the rule type. + * @prop name - The display name of the rule type. + * @prop rule_attribute - The unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. + * @prop default_priority - The priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. */ export interface RuleTypeDTO { id: string @@ -20,12 +20,12 @@ export interface RuleTypeDTO { /** * @interface * - * An object used when creating a rule type to specify its data. + * The rule type to create. * - * @prop id - A string indicating the ID of the rule type. - * @prop name - A string indicating the display name of the rule type. - * @prop rule_attribute - A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. - * @prop default_priority - A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. + * @prop id - The ID of the rule type. + * @prop name - The display name of the rule type. + * @prop rule_attribute - The unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. + * @prop default_priority - The priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. */ export interface CreateRuleTypeDTO { id?: string @@ -37,12 +37,12 @@ export interface CreateRuleTypeDTO { /** * @interface * - * An object used when updating a rule type to specify the data to update. + * The data to update in a rule type. The `id` is used to identify which price set to update. * - * @prop id - A string indicating the ID of the rule type to update. - * @prop name - A string indicating the display name of the rule type. - * @prop rule_attribute - A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. - * @prop default_priority - A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. + * @prop id - The ID of the rule type to update. + * @prop name - The display name of the rule type. + * @prop rule_attribute - The unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. + * @prop default_priority - The priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. */ export interface UpdateRuleTypeDTO { id: string @@ -54,11 +54,11 @@ export interface UpdateRuleTypeDTO { /** * @interface * - * An object used to filter retrieved rule types. + * Filters to apply on rule types. * - * @prop id - an array of strings, each being an ID to filter rule types. - * @prop name - an array of strings, each being a name to filter rule types. - * @prop rule_attribute - an array of strings, each being a rule attribute to filter rule types. + * @prop id - The IDs to filter rule types by. + * @prop name - The names to filter rule types by. + * @prop rule_attribute - The rule attributes to filter rule types by. */ export interface FilterableRuleTypeProps extends BaseFilterable { diff --git a/packages/types/src/pricing/service.ts b/packages/types/src/pricing/service.ts index 7b903145b4..fbbd582d02 100644 --- a/packages/types/src/pricing/service.ts +++ b/packages/types/src/pricing/service.ts @@ -44,12 +44,17 @@ export interface IPricingModuleService { /** * This method is used to calculate prices based on the provided filters and context. * - * @param {PricingContext} filters - An object of type {@link PricingFilters} used to filter the price sets. - * @param {PricingContext} context - An object of type {@link PricingContext} to select prices. For example, the pricing context can specify the currency code to calculate prices in. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves to an object of type {@link CalculatedPriceSetDTO} which includes the calculated prices. + * @param {PricingFilters} filters - The filters to apply on prices. + * @param {PricingContext} context - + * The context used to select the prices. For example, you can specify the region ID in this context, and only prices having the same value + * will be retrieved. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The calculated price matching the context and filters provided. * * @example + * When you calculate prices, you must at least specify the currency code: + * + * ```ts * import { * initialize as initializePricingModule, * } from "@medusajs/pricing" @@ -67,6 +72,53 @@ export interface IPricingModuleService { * * // do something with the price or return it * } + * ``` + * + * To calculate prices for specific minimum and/or maximum quantity: + * + * ```ts + * import { + * initialize as initializePricingModule, + * } from "@medusajs/pricing" + * async function calculatePrice (priceSetId: string, currencyCode: string) { + * const pricingService = await initializePricingModule() + * + * const price = await pricingService.calculatePrices( + * { id: [priceSetId] }, + * { + * context: { + * currency_code: currencyCode, + * min_quantity: 4 + * } + * } + * ) + * + * // do something with the price or return it + * } + * ``` + * + * To calculate prices for custom rule types: + * + * ```ts + * import { + * initialize as initializePricingModule, + * } from "@medusajs/pricing" + * async function calculatePrice (priceSetId: string, currencyCode: string) { + * const pricingService = await initializePricingModule() + * + * const price = await pricingService.calculatePrices( + * { id: [priceSetId] }, + * { + * context: { + * currency_code: currencyCode, + * region_id: "US" + * } + * } + * ) + * + * // do something with the price or return it + * } + * ``` */ calculatePrices( filters: PricingFilters, @@ -77,12 +129,12 @@ export interface IPricingModuleService { /** * This method is used to retrieves a price set by its ID. * - * @param {string} id - A string indicating the ID of the price set to retrieve. + * @param {string} id - The ID of the price set to retrieve. * @param {FindConfig} config - - * An object of type {@link FindConfig} used to configure how the price set is retrieved. Its properties, such as `select` or `relations`, accept the + * The configurations determining how the price set is retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a price set. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves to an object of type {@link PriceSetDTO} which is the retrieved price set. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The retrieved price set. * * @example * A simple example that retrieves a price set by its ID: @@ -133,12 +185,12 @@ export interface IPricingModuleService { /** * This method is used to retrieve a paginated list of price sets based on optional filters and configuration. * - * @param {FilterablePriceSetProps} filters - An object of type {@link FilterablePriceSetProps} that is used to filter the retrieved price lists. + * @param {FilterablePriceSetProps} filters - The filters to apply on the retrieved price lists. * @param {FindConfig} config - - * An object of type {@link FindConfig} used to configure how the price sets are retrieved. Its properties, such as `select` or `relations`, accept the + * The configurations determining how the price sets are retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a price set. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves to an array of objects of type {@link PriceSetDTO}. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of price sets. * * @example * @@ -253,13 +305,12 @@ export interface IPricingModuleService { /** * This method is used to retrieve a paginated list of price sets along with the total count of available price sets satisfying the provided filters. * - * @param {FilterablePriceSetProps} filters - An object of type {@link FilterablePriceSetProps} that is used to filter the retrieved price lists. + * @param {FilterablePriceSetProps} filters - The filters to apply on the retrieved price lists. * @param {FindConfig} config - - * An object of type {@link FindConfig} used to configure how the price sets are retrieved. Its properties, such as `select` or `relations`, accept the + * The configurations determining how the price sets are retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a price set. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise<[PriceSetDTO[], number]>} A promise that resolves to an array having two items, the first item is an array of objects of type {@link PriceSetDTO}, - * and the second item is a number indicating the total count. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise<[PriceSetDTO[], number]>} The list of price sets along with their total count. * * @example * @@ -374,9 +425,9 @@ export interface IPricingModuleService { /** * This method is used to create a new price set. * - * @param {CreatePriceSetDTO} data - An object of type {@link CreatePriceSetDTO} that holds the attribute of the price set to create. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves to an object of type {@link PriceSetDTO}, which is the created price set. + * @param {CreatePriceSetDTO} data - The attributes of the price set to create. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The created price set. * * @example * To create a default price set, don't pass any rules. For example: @@ -466,9 +517,9 @@ export interface IPricingModuleService { * * This method is used to create multiple price sets. * - * @param {CreatePriceSetDTO[]} data - An array of objects of type {@link CreatePriceSetDTO}, where each object holds the attribute of a price set to create. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves to an array of objects of type {@link PriceSetDTO}, which are the created price sets. + * @param {CreatePriceSetDTO[]} data - The price sets to create. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of created price sets. * * @example * To create price sets with a default price, don't pass any rules and make sure to pass the `currency_code` of the price. For example: @@ -556,9 +607,9 @@ export interface IPricingModuleService { * * This method is used to update existing price sets. * - * @param {UpdatePriceSetDTO[]} data - An array of objects of type {@link UpdatePriceSetDTO}, each holding the data of the price sets to update. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves to an array of objects of type {@link PriceSetDTOs}, which are the updated price sets. + * @param {UpdatePriceSetDTO[]} data - The price sets to update, each having the attributes that should be updated in a price set. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of updated price sets. */ update( data: UpdatePriceSetDTO[], @@ -568,9 +619,9 @@ export interface IPricingModuleService { /** * This method remove rules from a price set. * - * @param {RemovePriceSetRulesDTO[]} data - An array of objects of type {@link RemovePriceSetRulesDTO}, each specfiying which rules to remove. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves when rules are successfully removed. + * @param {RemovePriceSetRulesDTO[]} data - The rules to remove per price set. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves when rules are successfully removed. * * @example * import { @@ -596,9 +647,9 @@ export interface IPricingModuleService { /** * This method deletes price sets by their IDs. * - * @param {string[]} ids - An array of strings, each being the ID for a price set to delete. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves when the price sets are successfully deleted. + * @param {string[]} ids - The IDs of the price sets to delete. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves when the price sets are successfully deleted. * * @example * import { @@ -616,9 +667,9 @@ export interface IPricingModuleService { /** * This method adds prices to a price set. * - * @param {AddPricesDTO} data - An object of type {@link AddPricesDTO} that holds the data necessary to add the prices. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves to an object of type {@link PriceSetDTO}, which is the price set that the prices belong to. + * @param {AddPricesDTO} data - The data defining the price set to add the prices to, along with the prices to add. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The price set that the prices were added to. * * @example * @@ -696,9 +747,9 @@ export interface IPricingModuleService { /** * This method adds prices to multiple price sets. * - * @param {AddPricesDTO[]} data - An array of objects of type {@link AddPricesDTO}, each holding the data necessary to add the prices to the price set. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves to an array of objects of type {@link PriceSetDTO}, each being a price list that prices were added to. + * @param {AddPricesDTO[]} data - The data defining the prices to add per price set. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of the price sets that prices were added to. * * @example * @@ -779,9 +830,9 @@ export interface IPricingModuleService { /** * This method adds rules to a price set. * - * @param {AddRulesDTO} data - An object of type {@link AddRulesDTO} that holds the necessary data to add rules to a price set. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves to an object of type {@link PriceSetDTO}, which is the price set that the rules belong to. + * @param {AddRulesDTO} data - The data defining the price set to add the rules to, along with the rules to add. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The price set that the rules were added to. * * @example * import { @@ -806,9 +857,9 @@ export interface IPricingModuleService { /** * This method adds rules to multiple price sets. * - * @param {AddRulesDTO[]} data - An array of objects of type {@link AddRulesDTO}, each holding the necessary data to add rules to a price set. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves to an array of objects of type {@link PriceSetDTO}, each being the price set that rules were added to. + * @param {AddRulesDTO[]} data - The data defining the rules to add per price set. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of the price sets that the rules were added to. * * @example * import { @@ -835,10 +886,10 @@ export interface IPricingModuleService { * * @param {string} id - The ID of the money amount to retrieve. * @param {FindConfig} config - - * An object of type {@link MoneyAmountDTO} used to configure how a money amount is retrieved. Its properties, such as `select` or `relations`, accept the + * The configurations determining how a money amount is retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a money amount. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves to an object of type {@link MoneyAmountDTO} which is the retrieved money amount. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The retrieved money amount. * * @example * To retrieve a money amount by its ID: @@ -889,12 +940,12 @@ export interface IPricingModuleService { /** * This method is used to retrieve a paginated list of money amounts based on optional filters and configuration. * - * @param {FilterableMoneyAmountProps} filters - An object of type {@link FilterableMoneyAmountProps} that is used to filter the retrieved money amounts. + * @param {FilterableMoneyAmountProps} filters - The filtes to apply on the retrieved money amounts. * @param {FindConfig} config - - * An object of type {@link FindConfig} used to configure how the money amounts are retrieved. Its properties, such as `select` or `relations`, accept the + * The configurations determining how the money amounts are retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a money amount. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves to an array of objects of type {@link MoneyAmountDTO}. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of money amounts. * * @example * @@ -1007,13 +1058,12 @@ export interface IPricingModuleService { /** * This method is used to retrieve a paginated list of money amounts along with the total count of available money amounts satisfying the provided filters. * - * @param {FilterableMoneyAmountProps} filters - An object of type {@link FilterableMoneyAmountProps} that is used to filter the retrieved money amounts. + * @param {FilterableMoneyAmountProps} filters - The filters to apply on the retrieved money amounts. * @param {FindConfig} config - - * An object of type {@link FindConfig} used to configure how the money amounts are retrieved. Its properties, such as `select` or `relations`, accept the + * The configurations determining how the money amounts are retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a money amount. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise<[MoneyAmountDTO[], number]>} A promise that resolves to an array having two items, the first item is an array of objects of type {@link MoneyAmountDTO}, - * and the second item is a number indicating the total count. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise<[MoneyAmountDTO[], number]>} The list of money amounts along with their total count. * * @example * @@ -1126,9 +1176,9 @@ export interface IPricingModuleService { /** * This method creates money amounts. * - * @param {CreateMoneyAmountDTO[]} data - An array of objects of type {@link CreateMoneyAmountDTO} that holds the necessary data to create the money amount. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves to an array of objects of type {@link MoneyAmountDTO}, each being a created money amount. + * @param {CreateMoneyAmountDTO[]} data - The money amounts to create. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of created money amounts. * * @example * import { @@ -1162,9 +1212,9 @@ export interface IPricingModuleService { /** * This method updates existing money amounts. * - * @param {UpdateMoneyAmountDTO[]} data - An array of objects of type {@link UpdateMoneyAmountDTO}, each holding data to update in a money amount. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves to an array of objects of type {@link MoneyAmountDTO}, each being a updated money amount. + * @param {UpdateMoneyAmountDTO[]} data - The money amounts to update, each having the attributes that should be updated in a money amount. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of updated money amounts. * * @example * import { @@ -1192,9 +1242,9 @@ export interface IPricingModuleService { /** * This method deletes money amounts by their IDs. * - * @param {string[]} ids - An array of strings, each being the ID of a money amount to delete. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves when the money amounts are successfully deleted. + * @param {string[]} ids - The IDs of the money amounts to delete. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves when the money amounts are successfully deleted. * * @example * import { @@ -1214,12 +1264,12 @@ export interface IPricingModuleService { /** * This method retrieves a currency by its code and and optionally based on the provided configurations. * - * @param {string} code - A string indicating the code of the currency to retrieve. + * @param {string} code - The code of the currency to retrieve. * @param {FindConfig} config - - * An object of type {@link FindConfig} used to configure how the currency is retrieved. Its properties, such as `select` or `relations`, accept the + * The configurations determining how the currency is retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a currency. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves to an object of type {@link CurrencyDTO}. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The retrieved currency. * * @example * A simple example that retrieves a currency by its code: @@ -1270,12 +1320,12 @@ export interface IPricingModuleService { /** * This method is used to retrieve a paginated list of currencies based on optional filters and configuration. * - * @param {FilterableCurrencyProps} filters - An object of type {@link FilterableCurrencyProps} that is used to filter the retrieved currencies. + * @param {FilterableCurrencyProps} filters - The filters to apply on the retrieved currencies. * @param {FindConfig} config - - * An object of type {@link FindConfig} used to configure how the currencies are retrieved. Its properties, such as `select` or `relations`, accept the + * The configurations determining how the currencies are retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a currency. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves to an array of objects of type {@link CurrencyDTO}. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of currencies. * * @example * @@ -1356,13 +1406,12 @@ export interface IPricingModuleService { /** * This method is used to retrieve a paginated list of currencies along with the total count of available currencies satisfying the provided filters. * - * @param {FilterableCurrencyProps} filters - An object of type {@link FilterableCurrencyProps} that is used to filter the retrieved currencies. + * @param {FilterableCurrencyProps} filters - The filters to apply on the retrieved currencies. * @param {FindConfig} config - - * An object of type {@link FindConfig} used to configure how the currencies are retrieved. Its properties, such as `select` or `relations`, accept the + * The configurations determining how the currencies are retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a currency. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise<[CurrencyDTO[], number]>} A promise that resolves to an array having two items, the first item is an array of objects of type {@link CurrencyDTO}, - * and the second item is a number indicating the total count. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise<[CurrencyDTO[], number]>} The list of currencies along with the total count. * * @example * @@ -1443,9 +1492,9 @@ export interface IPricingModuleService { /** * This method is used to create new currencies. * - * @param {CreateCurrencyDTO[]} data - An array of objects of type {@link CreateCurrencyDTO}, each object holding the data of a currency to create. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves to an array of objects of type {@link CurrencyDTO}, each object being a created currency. + * @param {CreateCurrencyDTO[]} data - The currencies to create. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of created currencies. * * @example * import { @@ -1475,9 +1524,9 @@ export interface IPricingModuleService { /** * This method is used to update existing currencies with the provided data. In each currency object, the currency code must be provided to identify which currency to update. * - * @param {UpdateCurrencyDTO[]} data - An array of objects of type {@link UpdateCurrencyDTO}, each object containing data to be updated in a currency. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves to an array of objects of type {@link CurrencyDTO}, each object being an updated currency. + * @param {UpdateCurrencyDTO[]} data - The currencies to update, each having the attributes that should be updated in a currency. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of updated currencies. * * @example * import { @@ -1505,9 +1554,9 @@ export interface IPricingModuleService { /** * This method is used to delete currencies based on their currency code. * - * @param {string[]} currencyCodes - An array of strings, each being a code of a currency to delete. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves once the currencies are deleted. + * @param {string[]} currencyCodes - Currency codes of the currencies to delete. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves once the currencies are deleted. * * @example * import { @@ -1531,10 +1580,10 @@ export interface IPricingModuleService { * * @param {string} id - The ID of the rule type to retrieve. * @param {FindConfig} config - - * An object of type {@link FindConfig} used to configure how the rule type is retrieved. Its properties, such as `select` or `relations`, accept the + * The configurations determining how the rule type is retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a rule type. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves to an object of type {@link RuleTypeDTO}. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The retrieved rule type. * * @example * A simple example that retrieves a rule type by its code: @@ -1572,7 +1621,7 @@ export interface IPricingModuleService { * ``` */ retrieveRuleType( - code: string, + id: string, config?: FindConfig, sharedContext?: Context ): Promise @@ -1580,12 +1629,12 @@ export interface IPricingModuleService { /** * This method is used to retrieve a paginated list of rule types based on optional filters and configuration. * - * @param {FilterableRuleTypeProps} filters - An object of type {@link FilterableRuleTypeProps} that is used to filter the retrieved rule types. + * @param {FilterableRuleTypeProps} filters - The filters to apply on the retrieved rule types. * @param {FindConfig} config - - * An object of type {@link FindConfig} used to configure how the rule types are retrieved. Its properties, such as `select` or `relations`, accept the + * The configurations determining how the rule types are retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a rule type. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves to an array of objects of type {@link RuleTypeDTO}. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of rule types. * * @example * @@ -1693,13 +1742,12 @@ export interface IPricingModuleService { /** * This method is used to retrieve a paginated list of rule types along with the total count of available rule types satisfying the provided filters. * - * @param {FilterableRuleTypeProps} filters - An object of type {@link FilterableRuleTypeProps} that is used to filter the retrieved rule types. + * @param {FilterableRuleTypeProps} filters - The filters to apply on the retrieved rule types. * @param {FindConfig} config - - * An object of type {@link FindConfig} used to configure how the rule types are retrieved. Its properties, such as `select` or `relations`, accept the + * The configurations determining how the rule types are retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a rule type. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise<[RuleTypeDTO[], number]>} A promise that resolves to an array having two items, the first item is an array of objects of type {@link RuleTypeDTO}, - * and the second item is a number indicating the total count. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise<[RuleTypeDTO[], number]>} The list of rule types along with their total count. * * @example * @@ -1807,9 +1855,9 @@ export interface IPricingModuleService { /** * This method is used to create new rule types. * - * @param {CreateRuleTypeDTO[]} data - An array of objects of type {@link CreateRuleTypeDTO}, each being the data to use to create a rule type. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves to an array of objects of type {@link RuleTypeDTO}, each being a created rule type. + * @param {CreateRuleTypeDTO[]} data - The rule types to create. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of created rule types. * * @example * import { @@ -1837,9 +1885,9 @@ export interface IPricingModuleService { /** * This method is used to update existing rule types with the provided data. * - * @param {UpdateRuleTypeDTO[]} data - An array of objects of type {@link UpdateRuleTypeDTO}, each object containing data to be updated in a rule type. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves to an array of objects of type {@link RuleTypeDTO}, each being an updated rule type. + * @param {UpdateRuleTypeDTO[]} data - The rule types to update, each having the attributes that should be updated in a rule type. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of updated rule types. * * @example * import { @@ -1867,9 +1915,9 @@ export interface IPricingModuleService { /** * This method is used to delete rule types based on the provided IDs. * - * @param {string[]} ruleTypeIds - An array of strings, each being the ID of a rule type to delete. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves once the rule types are deleted. + * @param {string[]} ruleTypeIds - The IDs of the rule types to delete. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves once the rule types are deleted. * * @example * import { @@ -1887,12 +1935,12 @@ export interface IPricingModuleService { /** * This method is used to a price set money amount rule by its ID based on the provided configuration. * - * @param {string} id - A string indicating the ID of the price set money amount rule to retrieve. + * @param {string} id - The ID of the price set money amount rule to retrieve. * @param {FindConfig} config - - * An object of type {@link FindConfig} used to configure how the price set money amount rule is retrieved. Its properties, such as `select` or `relations`, accept the + * The configurations determining how the price set money amount rule is retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a price set money amount rule. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves to an object of type {@link PriceSetMoneyAmountRulesDTO}. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The retrieved price set money amount rule. * * @example * A simple example that retrieves a price set money amount rule by its ID: @@ -1938,13 +1986,12 @@ export interface IPricingModuleService { /** * This method is used to retrieve a paginated list of price set money amount rules based on optional filters and configuration. * - * @param {FilterablePriceSetMoneyAmountRulesProps} filters - - * An object of type {@link FilterablePriceSetMoneyAmountRulesProps} that is used to filter the retrieved price set money amount rules. + * @param {FilterablePriceSetMoneyAmountRulesProps} filters - The filters to apply on the retrieved price set money amount rules. * @param {FindConfig} config - - * An object of type {@link FindConfig} used to configure how the price set money amount rules are retrieved. Its properties, such as `select` or `relations`, accept the + * The configurations determining how the price set money amount rules are retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a price set money amount rule. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves to an array of objects of type {@link PriceSetMoneyAmountRulesDTO}. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of price set money amount rules. * * @example * @@ -2047,14 +2094,12 @@ export interface IPricingModuleService { * This method is used to retrieve a paginated list of price set money amount rules along with the total count of * available price set money amount rules satisfying the provided filters. * - * @param {FilterablePriceSetMoneyAmountRulesProps} filters - - * An object of type {@link FilterablePriceSetMoneyAmountRulesProps} that is used to filter the retrieved price set money amount rules. + * @param {FilterablePriceSetMoneyAmountRulesProps} filters - The filters to apply on the retrieved price set money amount rules. * @param {FindConfig} config - - * An object of type {@link FindConfig} used to configure how the price set money amount rules are retrieved. Its properties, such as `select` or `relations`, accept the + * The configurations determining how the price set money amount rules are retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a price set money amount rule. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise<[PriceSetMoneyAmountRulesDTO[], number]>} A promise that resolves to an array having two items, the first item is an array of objects of type {@link PriceSetMoneyAmountRulesDTO}, - * and the second item is a number indicating the total count. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise<[PriceSetMoneyAmountRulesDTO[], number]>} The list of price set money amount rules and their total count. * * @example * @@ -2157,11 +2202,9 @@ export interface IPricingModuleService { * This method is used to create new price set money amount rules. A price set money amount rule creates an association between a price set money amount and * a rule type. * - * @param {CreatePriceSetMoneyAmountRulesDTO[]} data - - * An array of objects of type {@link CreatePriceSetMoneyAmountRulesDTO}, each containing the data of a price set money amount rule to create. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves to an array of objects of type {@link PriceSetMoneyAmountRulesDTO}, each being - * a created price set money amount rule. + * @param {CreatePriceSetMoneyAmountRulesDTO[]} data - The price set money amount rules to create. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of created price set money amount rules. * * @example * import { @@ -2191,10 +2234,9 @@ export interface IPricingModuleService { * This method is used to update price set money amount rules, each with their provided data. * * @param {UpdatePriceSetMoneyAmountRulesDTO[]} data - - * An array of objects of type {@link UpdatePriceSetMoneyAmountRulesDTO}, each containing the data to update in a price set money amount rule. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves to an array of objects of type {@link PriceSetMoneyAmountRulesDTO}, each being the - * updated price set money amount rule. + * The price set money amounts to update, each having the attributes to update in a price set money amount. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of updated price set money amount rules. * * @example * import { @@ -2222,9 +2264,9 @@ export interface IPricingModuleService { /** * This method is used to delete price set money amount rules based on the specified IDs. * - * @param {string[]} ids - An array of strings, each representing the ID of a price set money amount rule to delete. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves once the price set money amount rules are deleted. + * @param {string[]} ids - The IDs of the price set money amount rules to delete. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves once the price set money amount rules are deleted. * * @example * import { @@ -2247,10 +2289,10 @@ export interface IPricingModuleService { * * @param {string} id - The ID of the price rule to retrieve. * @param {FindConfig} config - - * An object of type {@link FindConfig} used to configure how the price rule is retrieved. Its properties, such as `select` or `relations`, accept the + * The configurations determining how the price rule is retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a price rule. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves to an object of type {@link PriceRuleDTO}. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The retrieved price rule. * * @example * A simple example that retrieves a price rule by its ID: @@ -2296,13 +2338,12 @@ export interface IPricingModuleService { /** * This method is used to retrieve a paginated list of price rules based on optional filters and configuration. * - * @param {FilterablePriceRuleProps} filters - - * An object of type {@link FilterablePriceRuleProps} that is used to filter the retrieved price rules. + * @param {FilterablePriceRuleProps} filters - The filters to apply on the retrieved price rules. * @param {FindConfig} config - - * An object of type {@link FindConfig} used to configure how the price rule is retrieved. Its properties, such as `select` or `relations`, accept the + * The configurations determining how the price rule is retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a price rule. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves to an array of objects of type {@link PriceRuleDTO}. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of price rules. * * @example * @@ -2404,13 +2445,12 @@ export interface IPricingModuleService { /** * This method is used to retrieve a paginated list of price rules along with the total count of available price rules satisfying the provided filters. * - * @param {FilterablePriceRuleProps} filters - - * An object of type {@link FilterablePriceRuleProps} that is used to filter the retrieved price rules. + * @param {FilterablePriceRuleProps} filters - The filters to apply on the retrieved price rules. * @param {FindConfig} config - - * An object of type {@link FindConfig} used to configure how the price rule is retrieved. Its properties, such as `select` or `relations`, accept the + * The configurations determining how the price rule is retrieved. Its properties, such as `select` or `relations`, accept the * attributes or relations associated with a price rule. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves to an array of objects of type {@link PriceRuleDTO}. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of price rules along with their total count. * * @example * @@ -2512,9 +2552,9 @@ export interface IPricingModuleService { /** * This method is used to create new price rules based on the provided data. * - * @param {CreatePriceRuleDTO[]} data - An array of objects of type {@link CreatePriceRuleDTO}, each containing the data necessary to create a price rule. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves to an array of objects of type {@link PriceRuleDTO}, each being a created price rule. + * @param {CreatePriceRuleDTO[]} data - The price rules to create. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of created price rules. * * @example * import { @@ -2553,9 +2593,9 @@ export interface IPricingModuleService { /** * This method is used to update price rules, each with their provided data. * - * @param {UpdatePriceRuleDTO[]} data - An array of objects of type {@link UpdatePriceRuleDTO}, each containing the data to update in a price rule. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves to an array of objects of type {@link PriceRuleDTO}, each being an updated price rule. + * @param {UpdatePriceRuleDTO[]} data - The price rules to update, each having attributes that should be updated in a price rule. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} The list of updated price rules. * * @example * import { @@ -2586,9 +2626,9 @@ export interface IPricingModuleService { /** * This method is used to delete price rules based on the specified IDs. * - * @param {string[]} priceRuleIds - An array of strings, each being the ID of a price rule to delete. - * @param {Context} sharedContext - An object of type {@link Context} used to share resources, such as transaction manager, between the application and the module. - * @returns {Promise} A promise that resolves once the price rules are deleted. + * @param {string[]} priceRuleIds - The IDs of the price rules to delete. + * @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module. + * @returns {Promise} Resolves once the price rules are deleted. * * @example * import { diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.addPrices.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.addPrices.md deleted file mode 100644 index 371d7a352f..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.addPrices.md +++ /dev/null @@ -1,258 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/addPrices -sidebar_label: addPrices ---- - -# addPrices - Pricing Module Reference - -This documentation provides a reference to the addPrices method. This belongs to the Pricing Module. - -## addPrices(data, sharedContext?): Promise - -This method adds prices to a price set. - -### Parameters - -- `data`: An object of type [AddPricesDTO](../../interfaces/AddPricesDTO.md) that holds the data necessary to add the prices. It accepts the following properties: - - `priceSetId`: A string indicating the ID of the price set to add prices to. - - `prices`: An array of objects of type [CreatePricesDTO](../../interfaces/CreatePricesDTO.md), each being a price to add to the price set. Its items accept the following properties: - - `amount`: (optional) A number indicating the amount of this money amount. - - `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the money amount's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. - - `currency_code`: A string that indicates the currency code of this money amount. - - `id`: (optional) A string that indicates the ID of the money amount. - - `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this money amount to be applied. - - `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this money amount to be applied. - - `rules`: An object whose keys are rule types' `rule_attribute` attribute, and values are the value of that rule associated with this price. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -### Returns - -A promise that resolves to an object of type [PriceSetDTO](../../interfaces/PriceSetDTO.md), which is the price set that the prices belong to. - -
- -PriceSetDTO - - -- `id`: A string indicating the ID of the price set. -- `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. Its items accept the following properties: - - `amount`: (optional) A number indicating the amount of this price. - - `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. It accepts the following properties: - - `code`: a string indicating the code of the currency. - - `name`: (optional) a string indicating the name of the currency. - - `symbol`: (optional) a string indicating the symbol of the currency. - - `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price. - - `currency_code`: (optional) A string that indicates the currency code of this price. - - `id`: A string that indicates the ID of the money amount. A money amount represents a price. - - `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied. - - `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied. -- `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. Its items accept the following properties: - - `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. - - `id`: A string indicating the ID of the rule type. - - `name`: A string indicating the display name of the rule type. - - `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. - -
- -### Example - -To add a default price to a price set, don't pass it any rules and make sure to pass it the `currency_code`: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function addPricesToPriceSet (priceSetId: string) { - const pricingService = await initializePricingModule() - - const priceSet = await pricingService.addPrices({ - priceSetId, - prices: [ - { - amount: 500, - currency_code: "USD", - rules: {}, - }, - ], - }) - - // do something with the price set or return it -} -``` - -To add prices with rules: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function addPricesToPriceSet (priceSetId: string) { - const pricingService = await initializePricingModule() - - const priceSet = await pricingService.addPrices({ - priceSetId, - prices: [ - { - amount: 300, - currency_code: "EUR", - rules: { - region_id: "PL", - city: "krakow" - }, - }, - { - amount: 400, - currency_code: "EUR", - min_quantity: 0, - max_quantity: 4, - rules: { - region_id: "PL" - }, - }, - { - amount: 450, - currency_code: "EUR", - rules: { - city: "krakow" - }, - } - ], - }) - - // do something with the price set or return it -} -``` - -## addPrices(data, sharedContext?): Promise - -This method adds prices to multiple price sets. - -### Parameters - -- `data`: An array of objects of type [AddPricesDTO](../../interfaces/AddPricesDTO.md), each holding the data necessary to add the prices to the price set. Its items accept the following properties: - - `priceSetId`: A string indicating the ID of the price set to add prices to. - - `prices`: An array of objects of type [CreatePricesDTO](../../interfaces/CreatePricesDTO.md), each being a price to add to the price set. Its items accept the following properties: - - `amount`: (optional) A number indicating the amount of this money amount. - - `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the money amount's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. - - `currency_code`: A string that indicates the currency code of this money amount. - - `id`: (optional) A string that indicates the ID of the money amount. - - `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this money amount to be applied. - - `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this money amount to be applied. - - `rules`: An object whose keys are rule types' `rule_attribute` attribute, and values are the value of that rule associated with this price. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -### Returns - -A promise that resolves to an array of objects of type [PriceSetDTO](../../interfaces/PriceSetDTO.md), each being a price list that prices were added to. - -
- -PriceSetDTO - - -- `id`: A string indicating the ID of the price set. -- `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. Its items accept the following properties: - - `amount`: (optional) A number indicating the amount of this price. - - `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. It accepts the following properties: - - `code`: a string indicating the code of the currency. - - `name`: (optional) a string indicating the name of the currency. - - `symbol`: (optional) a string indicating the symbol of the currency. - - `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price. - - `currency_code`: (optional) A string that indicates the currency code of this price. - - `id`: A string that indicates the ID of the money amount. A money amount represents a price. - - `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied. - - `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied. -- `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. Its items accept the following properties: - - `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. - - `id`: A string indicating the ID of the rule type. - - `name`: A string indicating the display name of the rule type. - - `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. - -
- -### Example - -To add a default price to a price set, don't pass it any rules and make sure to pass it the `currency_code`: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function addPricesToPriceSet (priceSetId: string) { - const pricingService = await initializePricingModule() - - const priceSets = await pricingService.addPrices([{ - priceSetId, - prices: [ - { - amount: 500, - currency_code: "USD", - rules: {}, - }, - ], - }]) - - // do something with the price sets or return them -} -``` - -To add prices with rules: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function addPricesToPriceSet (priceSetId: string) { - const pricingService = await initializePricingModule() - - const priceSets = await pricingService.addPrices([{ - priceSetId, - prices: [ - { - amount: 300, - currency_code: "EUR", - rules: { - region_id: "PL", - city: "krakow" - }, - }, - { - amount: 400, - currency_code: "EUR", - min_quantity: 0, - max_quantity: 4, - rules: { - region_id: "PL" - }, - }, - { - amount: 450, - currency_code: "EUR", - rules: { - city: "krakow" - }, - } - ], - }]) - - // do something with the price sets or return them -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.addPrices.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.addPrices.mdx new file mode 100644 index 0000000000..3e1425b0ae --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.addPrices.mdx @@ -0,0 +1,180 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/addPrices +sidebar_label: addPrices +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# addPrices - Pricing Module Reference + +This documentation provides a reference to the `addPrices` method. This belongs to the Pricing Module. + +## addPrices(data, sharedContext?): Promise + +This method adds prices to a price set. + +### Example + +To add a default price to a price set, don't pass it any rules and make sure to pass it the `currency_code`: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function addPricesToPriceSet (priceSetId: string) { + const pricingService = await initializePricingModule() + + const priceSet = await pricingService.addPrices({ + priceSetId, + prices: [ + { + amount: 500, + currency_code: "USD", + rules: {}, + }, + ], + }) + + // do something with the price set or return it +} +``` + +To add prices with rules: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function addPricesToPriceSet (priceSetId: string) { + const pricingService = await initializePricingModule() + + const priceSet = await pricingService.addPrices({ + priceSetId, + prices: [ + { + amount: 300, + currency_code: "EUR", + rules: { + region_id: "PL", + city: "krakow" + }, + }, + { + amount: 400, + currency_code: "EUR", + min_quantity: 0, + max_quantity: 4, + rules: { + region_id: "PL" + }, + }, + { + amount: 450, + currency_code: "EUR", + rules: { + city: "krakow" + }, + } + ], + }) + + // do something with the price set or return it +} +``` + +### Parameters + +","description":"The rules to add to the price. The object's keys are rule types' `rule_attribute` attribute, and values are the value of that rule associated with this price.","optional":false,"defaultValue":"","children":[]}]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} /> + +### Returns + +","optional":false,"defaultValue":"","description":"The price set that the prices were added to.","children":[{"name":"PriceSetDTO","type":"`object`","description":"A price set's data.","optional":false,"defaultValue":"","children":[{"name":"id","type":"`string`","description":"The ID of the price set.","optional":false,"defaultValue":"","children":[]},{"name":"money_amounts","type":"[`MoneyAmountDTO`](../../interfaces/MoneyAmountDTO.mdx)[]","description":"The prices that belong to this price set.","optional":true,"defaultValue":"","children":[]},{"name":"rule_types","type":"[`RuleTypeDTO`](../../interfaces/RuleTypeDTO.mdx)[]","description":"The rule types applied on this price set.","optional":true,"defaultValue":"","children":[]}]}]}]} /> + +## addPrices(data, sharedContext?): Promise + +This method adds prices to multiple price sets. + +### Example + +To add a default price to a price set, don't pass it any rules and make sure to pass it the `currency_code`: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function addPricesToPriceSet (priceSetId: string) { + const pricingService = await initializePricingModule() + + const priceSets = await pricingService.addPrices([{ + priceSetId, + prices: [ + { + amount: 500, + currency_code: "USD", + rules: {}, + }, + ], + }]) + + // do something with the price sets or return them +} +``` + +To add prices with rules: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function addPricesToPriceSet (priceSetId: string) { + const pricingService = await initializePricingModule() + + const priceSets = await pricingService.addPrices([{ + priceSetId, + prices: [ + { + amount: 300, + currency_code: "EUR", + rules: { + region_id: "PL", + city: "krakow" + }, + }, + { + amount: 400, + currency_code: "EUR", + min_quantity: 0, + max_quantity: 4, + rules: { + region_id: "PL" + }, + }, + { + amount: 450, + currency_code: "EUR", + rules: { + city: "krakow" + }, + } + ], + }]) + + // do something with the price sets or return them +} +``` + +### Parameters + +","description":"The rules to add to the price. The object's keys are rule types' `rule_attribute` attribute, and values are the value of that rule associated with this price.","optional":false,"defaultValue":"","children":[]}]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} /> + +### Returns + +","optional":false,"defaultValue":"","description":"The list of the price sets that prices were added to.","children":[{"name":"PriceSetDTO[]","type":"[`PriceSetDTO`](../../interfaces/PriceSetDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"PriceSetDTO","type":"`object`","description":"A price set's data.","optional":false,"defaultValue":"","children":[]}]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.addRules.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.addRules.md deleted file mode 100644 index 49f30228d3..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.addRules.md +++ /dev/null @@ -1,144 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/addRules -sidebar_label: addRules ---- - -# addRules - Pricing Module Reference - -This documentation provides a reference to the addRules method. This belongs to the Pricing Module. - -## addRules(data, sharedContext?): Promise - -This method adds rules to a price set. - -### Parameters - -- `data`: An object of type [AddRulesDTO](../../interfaces/AddRulesDTO.md) that holds the necessary data to add rules to a price set. It accepts the following properties: - - `priceSetId`: A string indicating the ID of the price set to add the rules to. - - `rules`: An array of objects, each object holds a property `attribute`, with its value being the `rule_attribute` of the rule to add to the price set. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -### Returns - -A promise that resolves to an object of type [PriceSetDTO](../../interfaces/PriceSetDTO.md), which is the price set that the rules belong to. - -
- -PriceSetDTO - - -- `id`: A string indicating the ID of the price set. -- `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. Its items accept the following properties: - - `amount`: (optional) A number indicating the amount of this price. - - `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. It accepts the following properties: - - `code`: a string indicating the code of the currency. - - `name`: (optional) a string indicating the name of the currency. - - `symbol`: (optional) a string indicating the symbol of the currency. - - `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price. - - `currency_code`: (optional) A string that indicates the currency code of this price. - - `id`: A string that indicates the ID of the money amount. A money amount represents a price. - - `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied. - - `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied. -- `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. Its items accept the following properties: - - `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. - - `id`: A string indicating the ID of the rule type. - - `name`: A string indicating the display name of the rule type. - - `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. - -
- -### Example - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function addRulesToPriceSet (priceSetId: string) { - const pricingService = await initializePricingModule() - - const priceSet = await pricingService.addRules({ - priceSetId, - rules: [{ - attribute: "region_id" - }] - }) - - // do something with the price set or return it -} -``` - -## addRules(data, sharedContext?): Promise - -This method adds rules to multiple price sets. - -### Parameters - -- `data`: An array of objects of type [AddRulesDTO](../../interfaces/AddRulesDTO.md), each holding the necessary data to add rules to a price set. Its items accept the following properties: - - `priceSetId`: A string indicating the ID of the price set to add the rules to. - - `rules`: An array of objects, each object holds a property `attribute`, with its value being the `rule_attribute` of the rule to add to the price set. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -### Returns - -A promise that resolves to an array of objects of type [PriceSetDTO](../../interfaces/PriceSetDTO.md), each being the price set that rules were added to. - -
- -PriceSetDTO - - -- `id`: A string indicating the ID of the price set. -- `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. Its items accept the following properties: - - `amount`: (optional) A number indicating the amount of this price. - - `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. It accepts the following properties: - - `code`: a string indicating the code of the currency. - - `name`: (optional) a string indicating the name of the currency. - - `symbol`: (optional) a string indicating the symbol of the currency. - - `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price. - - `currency_code`: (optional) A string that indicates the currency code of this price. - - `id`: A string that indicates the ID of the money amount. A money amount represents a price. - - `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied. - - `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied. -- `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. Its items accept the following properties: - - `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. - - `id`: A string indicating the ID of the rule type. - - `name`: A string indicating the display name of the rule type. - - `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. - -
- -### Example - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function addRulesToPriceSet (priceSetId: string) { - const pricingService = await initializePricingModule() - - const priceSets = await pricingService.addRules([{ - priceSetId, - rules: [{ - attribute: "region_id" - }] - }]) - - // do something with the price sets or return them -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.addRules.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.addRules.mdx new file mode 100644 index 0000000000..d1b9c419c7 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.addRules.mdx @@ -0,0 +1,80 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/addRules +sidebar_label: addRules +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# addRules - Pricing Module Reference + +This documentation provides a reference to the `addRules` method. This belongs to the Pricing Module. + +## addRules(data, sharedContext?): Promise + +This method adds rules to a price set. + +### Example + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function addRulesToPriceSet (priceSetId: string) { + const pricingService = await initializePricingModule() + + const priceSet = await pricingService.addRules({ + priceSetId, + rules: [{ + attribute: "region_id" + }] + }) + + // do something with the price set or return it +} +``` + +### Parameters + + + +### Returns + +","optional":false,"defaultValue":"","description":"The price set that the rules were added to.","children":[{"name":"PriceSetDTO","type":"`object`","description":"A price set's data.","optional":false,"defaultValue":"","children":[{"name":"id","type":"`string`","description":"The ID of the price set.","optional":false,"defaultValue":"","children":[]},{"name":"money_amounts","type":"[`MoneyAmountDTO`](../../interfaces/MoneyAmountDTO.mdx)[]","description":"The prices that belong to this price set.","optional":true,"defaultValue":"","children":[]},{"name":"rule_types","type":"[`RuleTypeDTO`](../../interfaces/RuleTypeDTO.mdx)[]","description":"The rule types applied on this price set.","optional":true,"defaultValue":"","children":[]}]}]}]} /> + +## addRules(data, sharedContext?): Promise + +This method adds rules to multiple price sets. + +### Example + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function addRulesToPriceSet (priceSetId: string) { + const pricingService = await initializePricingModule() + + const priceSets = await pricingService.addRules([{ + priceSetId, + rules: [{ + attribute: "region_id" + }] + }]) + + // do something with the price sets or return them +} +``` + +### Parameters + + + +### Returns + +","optional":false,"defaultValue":"","description":"The list of the price sets that the rules were added to.","children":[{"name":"PriceSetDTO[]","type":"[`PriceSetDTO`](../../interfaces/PriceSetDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"PriceSetDTO","type":"`object`","description":"A price set's data.","optional":false,"defaultValue":"","children":[]}]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.calculatePrices.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.calculatePrices.md deleted file mode 100644 index 72617efc05..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.calculatePrices.md +++ /dev/null @@ -1,66 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/calculatePrices -sidebar_label: calculatePrices ---- - -# calculatePrices - Pricing Module Reference - -This documentation provides a reference to the calculatePrices method. This belongs to the Pricing Module. - -This method is used to calculate prices based on the provided filters and context. - -## Parameters - -- `filters`: An object of type [PricingFilters](../../interfaces/PricingFilters.md) used to filter the price sets. It accepts the following properties: - - `id`: An array of strings, each being an ID of a price set. -- `context`: (optional) An object of type [PricingContext](../../interfaces/PricingContext.md) to select prices. For example, the pricing context can specify the currency code to calculate prices in. It accepts the following properties: - - `context`: (optional) an object whose keys are the name of the context attribute. Its value can be a string or a number. For example, you can pass the `currency_code` property with its value being the currency code to calculate the price in. Another example is passing the `quantity` property to calculate the price for that specified quantity, which finds a price set whose `min_quantity` and `max_quantity` conditions match the specified quantity. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves to an object of type [CalculatedPriceSetDTO](../../interfaces/CalculatedPriceSetDTO.md) which includes the calculated prices. - -
- -CalculatedPriceSetDTO - - -- `amount`: a number indicating the calculated amount. It can possibly be `null` if there's no price set up for the provided context. -- `currency_code`: a string indicating the currency code of the calculated price. It can possibly be `null`. -- `id`: a string indicating the ID of the price set. -- `max_quantity`: a number indicaitng the maximum quantity required to be purchased for this price to apply. It's set if the `quantity` property is provided in the context. Otherwise, its value will be `null`. -- `min_quantity`: a number indicaitng the minimum quantity required to be purchased for this price to apply. It's set if the `quantity` property is provided in the context. Otherwise, its value will be `null`. - -
- -## Example - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" -async function calculatePrice (priceSetId: string, currencyCode: string) { - const pricingService = await initializePricingModule() - - const price = await pricingService.calculatePrices( - { id: [priceSetId] }, - { - context: { - currency_code: currencyCode - } - } - ) - - // do something with the price or return it -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.calculatePrices.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.calculatePrices.mdx new file mode 100644 index 0000000000..37b5c1d400 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.calculatePrices.mdx @@ -0,0 +1,94 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/calculatePrices +sidebar_label: calculatePrices +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# calculatePrices - Pricing Module Reference + +This documentation provides a reference to the `calculatePrices` method. This belongs to the Pricing Module. + +This method is used to calculate prices based on the provided filters and context. + +## Example + +When you calculate prices, you must at least specify the currency code: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" +async function calculatePrice (priceSetId: string, currencyCode: string) { + const pricingService = await initializePricingModule() + + const price = await pricingService.calculatePrices( + { id: [priceSetId] }, + { + context: { + currency_code: currencyCode + } + } + ) + + // do something with the price or return it +} +``` + +To calculate prices for specific minimum and/or maximum quantity: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" +async function calculatePrice (priceSetId: string, currencyCode: string) { + const pricingService = await initializePricingModule() + + const price = await pricingService.calculatePrices( + { id: [priceSetId] }, + { + context: { + currency_code: currencyCode, + min_quantity: 4 + } + } + ) + + // do something with the price or return it +} +``` + +To calculate prices for custom rule types: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" +async function calculatePrice (priceSetId: string, currencyCode: string) { + const pricingService = await initializePricingModule() + + const price = await pricingService.calculatePrices( + { id: [priceSetId] }, + { + context: { + currency_code: currencyCode, + region_id: "US" + } + } + ) + + // do something with the price or return it +} +``` + +## Parameters + +","description":"an object whose keys are the name of the context attribute. Its value can be a string or a number. For example, you can pass the `currency_code` property with its value being the currency code to calculate the price in. Another example is passing the `quantity` property to calculate the price for that specified quantity, which finds a price set whose `min_quantity` and `max_quantity` conditions match the specified quantity.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} /> + +## Returns + +","optional":false,"defaultValue":"","description":"The calculated price matching the context and filters provided.","children":[{"name":"CalculatedPriceSetDTO","type":"`object`","description":"A calculated price set's data.","optional":false,"defaultValue":"","children":[{"name":"amount","type":"``null`` \\| `number`","description":"The calculated amount. It can possibly be `null` if there's no price set up for the provided context.","optional":false,"defaultValue":"","children":[]},{"name":"currency_code","type":"``null`` \\| `string`","description":"The currency code of the calculated price. It can possibly be `null`.","optional":false,"defaultValue":"","children":[]},{"name":"id","type":"`string`","description":"The ID of the price set.","optional":false,"defaultValue":"","children":[]},{"name":"max_quantity","type":"``null`` \\| `number`","description":"The maximum quantity required to be purchased for this price to apply. It's set if the `quantity` property is provided in the context. Otherwise, its value will be `null`.","optional":false,"defaultValue":"","children":[]},{"name":"min_quantity","type":"``null`` \\| `number`","description":"The minimum quantity required to be purchased for this price to apply. It's set if the `quantity` property is provided in the context. Otherwise, its value will be `null`.","optional":false,"defaultValue":"","children":[]}]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.create.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.create.md deleted file mode 100644 index 5441914a12..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.create.md +++ /dev/null @@ -1,273 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/create -sidebar_label: create ---- - -# create - Pricing Module Reference - -This documentation provides a reference to the create method. This belongs to the Pricing Module. - -## create(data, sharedContext?): Promise - -This method is used to create a new price set. - -### Parameters - -- `data`: An object of type [CreatePriceSetDTO](../../interfaces/CreatePriceSetDTO.md) that holds the attribute of the price set to create. It accepts the following properties: - - `prices`: (optional) An array of objects of type [CreatePricesDTO](../../interfaces/CreatePricesDTO.md), each being a price to associate with the price set. Its items accept the following properties: - - `amount`: (optional) A number indicating the amount of this money amount. - - `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the money amount's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. - - `currency_code`: A string that indicates the currency code of this money amount. - - `id`: (optional) A string that indicates the ID of the money amount. - - `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this money amount to be applied. - - `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this money amount to be applied. - - `rules`: An object whose keys are rule types' `rule_attribute` attribute, and values are the value of that rule associated with this price. - - `rules`: (optional) An array of objects, each object accepts a property `rule_attribute`, whose value is a string indicating the `rule_attribute` value of a rule type. This property is used to specify the rule types associated with the price set. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -### Returns - -A promise that resolves to an object of type [PriceSetDTO](../../interfaces/PriceSetDTO.md), which is the created price set. - -
- -PriceSetDTO - - -- `id`: A string indicating the ID of the price set. -- `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. Its items accept the following properties: - - `amount`: (optional) A number indicating the amount of this price. - - `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. It accepts the following properties: - - `code`: a string indicating the code of the currency. - - `name`: (optional) a string indicating the name of the currency. - - `symbol`: (optional) a string indicating the symbol of the currency. - - `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price. - - `currency_code`: (optional) A string that indicates the currency code of this price. - - `id`: A string that indicates the ID of the money amount. A money amount represents a price. - - `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied. - - `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied. -- `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. Its items accept the following properties: - - `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. - - `id`: A string indicating the ID of the rule type. - - `name`: A string indicating the display name of the rule type. - - `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. - -
- -### Example - -To create a default price set, don't pass any rules. For example: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function createPriceSet () { - const pricingService = await initializePricingModule() - - const priceSet = await pricingService.create( - { - rules: [], - prices: [ - { - amount: 500, - currency_code: "USD", - min_quantity: 0, - max_quantity: 4, - rules: {}, - }, - { - amount: 400, - currency_code: "USD", - min_quantity: 5, - max_quantity: 10, - rules: {}, - }, - ], - }, - ) - - // do something with the price set or return it -} -``` - -To create a price set and associate it with rule types: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function createPriceSet () { - const pricingService = await initializePricingModule() - - const priceSet = await pricingService.create( - { - rules: [{ rule_attribute: "region_id" }, { rule_attribute: "city" }], - prices: [ - { - amount: 300, - currency_code: "EUR", - rules: { - region_id: "PL", - city: "krakow" - }, - }, - { - amount: 400, - currency_code: "EUR", - rules: { - region_id: "PL" - }, - }, - { - amount: 450, - currency_code: "EUR", - rules: { - city: "krakow" - }, - } - ], - }, - ) - - // do something with the price set or return it -} -``` - -## create(data, sharedContext?): Promise - -This method is used to create multiple price sets. - -### Parameters - -- `data`: An array of objects of type [CreatePriceSetDTO](../../interfaces/CreatePriceSetDTO.md), where each object holds the attribute of a price set to create. Its items accept the following properties: - - `prices`: (optional) An array of objects of type [CreatePricesDTO](../../interfaces/CreatePricesDTO.md), each being a price to associate with the price set. Its items accept the following properties: - - `amount`: (optional) A number indicating the amount of this money amount. - - `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the money amount's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. - - `currency_code`: A string that indicates the currency code of this money amount. - - `id`: (optional) A string that indicates the ID of the money amount. - - `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this money amount to be applied. - - `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this money amount to be applied. - - `rules`: An object whose keys are rule types' `rule_attribute` attribute, and values are the value of that rule associated with this price. - - `rules`: (optional) An array of objects, each object accepts a property `rule_attribute`, whose value is a string indicating the `rule_attribute` value of a rule type. This property is used to specify the rule types associated with the price set. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -### Returns - -A promise that resolves to an array of objects of type [PriceSetDTO](../../interfaces/PriceSetDTO.md), which are the created price sets. - -
- -PriceSetDTO - - -- `id`: A string indicating the ID of the price set. -- `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. Its items accept the following properties: - - `amount`: (optional) A number indicating the amount of this price. - - `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. It accepts the following properties: - - `code`: a string indicating the code of the currency. - - `name`: (optional) a string indicating the name of the currency. - - `symbol`: (optional) a string indicating the symbol of the currency. - - `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price. - - `currency_code`: (optional) A string that indicates the currency code of this price. - - `id`: A string that indicates the ID of the money amount. A money amount represents a price. - - `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied. - - `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied. -- `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. Its items accept the following properties: - - `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. - - `id`: A string indicating the ID of the rule type. - - `name`: A string indicating the display name of the rule type. - - `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. - -
- -### Example - -To create price sets with a default price, don't pass any rules and make sure to pass the `currency_code` of the price. For example: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function createPriceSets () { - const pricingService = await initializePricingModule() - - const priceSets = await pricingService.create([ - { - rules: [], - prices: [ - { - amount: 500, - currency_code: "USD", - rules: {}, - }, - ], - }, - ]) - - // do something with the price sets or return them -} -``` - -To create price sets and associate them with rule types: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function createPriceSets () { - const pricingService = await initializePricingModule() - - const priceSets = await pricingService.create([ - { - rules: [{ rule_attribute: "region_id" }, { rule_attribute: "city" }], - prices: [ - { - amount: 300, - currency_code: "EUR", - rules: { - region_id: "PL", - city: "krakow" - }, - }, - { - amount: 400, - currency_code: "EUR", - min_quantity: 0, - max_quantity: 4, - rules: { - region_id: "PL" - }, - }, - { - amount: 450, - currency_code: "EUR", - rules: { - city: "krakow" - }, - } - ], - }, - ]) - - // do something with the price sets or return them -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.create.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.create.mdx new file mode 100644 index 0000000000..f5a3ad76f6 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.create.mdx @@ -0,0 +1,195 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/create +sidebar_label: create +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# create - Pricing Module Reference + +This documentation provides a reference to the `create` method. This belongs to the Pricing Module. + +## create(data, sharedContext?): Promise + +This method is used to create a new price set. + +### Example + +To create a default price set, don't pass any rules. For example: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function createPriceSet () { + const pricingService = await initializePricingModule() + + const priceSet = await pricingService.create( + { + rules: [], + prices: [ + { + amount: 500, + currency_code: "USD", + min_quantity: 0, + max_quantity: 4, + rules: {}, + }, + { + amount: 400, + currency_code: "USD", + min_quantity: 5, + max_quantity: 10, + rules: {}, + }, + ], + }, + ) + + // do something with the price set or return it +} +``` + +To create a price set and associate it with rule types: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function createPriceSet () { + const pricingService = await initializePricingModule() + + const priceSet = await pricingService.create( + { + rules: [{ rule_attribute: "region_id" }, { rule_attribute: "city" }], + prices: [ + { + amount: 300, + currency_code: "EUR", + rules: { + region_id: "PL", + city: "krakow" + }, + }, + { + amount: 400, + currency_code: "EUR", + rules: { + region_id: "PL" + }, + }, + { + amount: 450, + currency_code: "EUR", + rules: { + city: "krakow" + }, + } + ], + }, + ) + + // do something with the price set or return it +} +``` + +### Parameters + +","description":"The rules to add to the price. The object's keys are rule types' `rule_attribute` attribute, and values are the value of that rule associated with this price.","optional":false,"defaultValue":"","children":[]}]},{"name":"rules","type":"{ `rule_attribute`: `string` }[]","description":"The rules to associate with the price set. The value of `attribute` is the value of the rule's `rule_attribute` attribute.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} /> + +### Returns + +","optional":false,"defaultValue":"","description":"The created price set.","children":[{"name":"PriceSetDTO","type":"`object`","description":"A price set's data.","optional":false,"defaultValue":"","children":[{"name":"id","type":"`string`","description":"The ID of the price set.","optional":false,"defaultValue":"","children":[]},{"name":"money_amounts","type":"[`MoneyAmountDTO`](../../interfaces/MoneyAmountDTO.mdx)[]","description":"The prices that belong to this price set.","optional":true,"defaultValue":"","children":[]},{"name":"rule_types","type":"[`RuleTypeDTO`](../../interfaces/RuleTypeDTO.mdx)[]","description":"The rule types applied on this price set.","optional":true,"defaultValue":"","children":[]}]}]}]} /> + +## create(data, sharedContext?): Promise + +This method is used to create multiple price sets. + +### Example + +To create price sets with a default price, don't pass any rules and make sure to pass the `currency_code` of the price. For example: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function createPriceSets () { + const pricingService = await initializePricingModule() + + const priceSets = await pricingService.create([ + { + rules: [], + prices: [ + { + amount: 500, + currency_code: "USD", + rules: {}, + }, + ], + }, + ]) + + // do something with the price sets or return them +} +``` + +To create price sets and associate them with rule types: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function createPriceSets () { + const pricingService = await initializePricingModule() + + const priceSets = await pricingService.create([ + { + rules: [{ rule_attribute: "region_id" }, { rule_attribute: "city" }], + prices: [ + { + amount: 300, + currency_code: "EUR", + rules: { + region_id: "PL", + city: "krakow" + }, + }, + { + amount: 400, + currency_code: "EUR", + min_quantity: 0, + max_quantity: 4, + rules: { + region_id: "PL" + }, + }, + { + amount: 450, + currency_code: "EUR", + rules: { + city: "krakow" + }, + } + ], + }, + ]) + + // do something with the price sets or return them +} +``` + +### Parameters + +","description":"The rules to add to the price. The object's keys are rule types' `rule_attribute` attribute, and values are the value of that rule associated with this price.","optional":false,"defaultValue":"","children":[]}]},{"name":"rules","type":"{ `rule_attribute`: `string` }[]","description":"The rules to associate with the price set. The value of `attribute` is the value of the rule's `rule_attribute` attribute.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} /> + +### Returns + +","optional":false,"defaultValue":"","description":"The list of created price sets.","children":[{"name":"PriceSetDTO[]","type":"[`PriceSetDTO`](../../interfaces/PriceSetDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"PriceSetDTO","type":"`object`","description":"A price set's data.","optional":false,"defaultValue":"","children":[]}]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createCurrencies.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createCurrencies.md deleted file mode 100644 index 91ba411a4c..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createCurrencies.md +++ /dev/null @@ -1,67 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/createCurrencies -sidebar_label: createCurrencies ---- - -# createCurrencies - Pricing Module Reference - -This documentation provides a reference to the createCurrencies method. This belongs to the Pricing Module. - -This method is used to create new currencies. - -## Parameters - -- `data`: An array of objects of type [CreateCurrencyDTO](../../interfaces/CreateCurrencyDTO.md), each object holding the data of a currency to create. Its items accept the following properties: - - `code`: a string indicating the code of the currency. - - `name`: a string indicating the name of the currency. - - `symbol`: a string indicating the symbol of the currency. - - `symbol_native`: a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves to an array of objects of type [CurrencyDTO](../../interfaces/CurrencyDTO.md), each object being a created currency. - -
- -CurrencyDTO - - -- `code`: a string indicating the code of the currency. -- `name`: (optional) a string indicating the name of the currency. -- `symbol`: (optional) a string indicating the symbol of the currency. -- `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price. - -
- -## Example - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function createCurrencies () { - const pricingService = await initializePricingModule() - - const currencies = await pricingService.createCurrencies([ - { - code: "USD", - symbol: "$", - symbol_native: "$", - name: "US Dollar", - } - ]) - - // do something with the currencies or return them -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createCurrencies.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createCurrencies.mdx new file mode 100644 index 0000000000..f7ab223476 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createCurrencies.mdx @@ -0,0 +1,47 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/createCurrencies +sidebar_label: createCurrencies +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# createCurrencies - Pricing Module Reference + +This documentation provides a reference to the `createCurrencies` method. This belongs to the Pricing Module. + +This method is used to create new currencies. + +## Example + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function createCurrencies () { + const pricingService = await initializePricingModule() + + const currencies = await pricingService.createCurrencies([ + { + code: "USD", + symbol: "$", + symbol_native: "$", + name: "US Dollar", + } + ]) + + // do something with the currencies or return them +} +``` + +## Parameters + + + +## Returns + +","optional":false,"defaultValue":"","description":"The list of created currencies.","children":[{"name":"CurrencyDTO[]","type":"[`CurrencyDTO`](../../interfaces/CurrencyDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"CurrencyDTO","type":"`object`","description":"A currency's data.","optional":false,"defaultValue":"","children":[]}]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createMoneyAmounts.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createMoneyAmounts.md deleted file mode 100644 index f02df231b4..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createMoneyAmounts.md +++ /dev/null @@ -1,83 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/createMoneyAmounts -sidebar_label: createMoneyAmounts ---- - -# createMoneyAmounts - Pricing Module Reference - -This documentation provides a reference to the createMoneyAmounts method. This belongs to the Pricing Module. - -This method creates money amounts. - -## Parameters - -- `data`: An array of objects of type [CreateMoneyAmountDTO](../../interfaces/CreateMoneyAmountDTO.md) that holds the necessary data to create the money amount. Its items accept the following properties: - - `amount`: (optional) A number indicating the amount of this money amount. - - `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the money amount's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. It accepts the following properties: - - `code`: a string indicating the code of the currency. - - `name`: (optional) a string indicating the name of the currency. - - `symbol`: (optional) a string indicating the symbol of the currency. - - `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price. - - `currency_code`: A string that indicates the currency code of this money amount. - - `id`: (optional) A string that indicates the ID of the money amount. - - `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this money amount to be applied. - - `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this money amount to be applied. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves to an array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), each being a created money amount. - -
- -MoneyAmountDTO - - -- `amount`: (optional) A number indicating the amount of this price. -- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. It accepts the following properties: - - `code`: a string indicating the code of the currency. - - `name`: (optional) a string indicating the name of the currency. - - `symbol`: (optional) a string indicating the symbol of the currency. - - `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price. -- `currency_code`: (optional) A string that indicates the currency code of this price. -- `id`: A string that indicates the ID of the money amount. A money amount represents a price. -- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied. -- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied. - -
- -## Example - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrieveMoneyAmounts () { - const pricingService = await initializePricingModule() - - const moneyAmounts = await pricingService.createMoneyAmounts([ - { - amount: 500, - currency_code: "USD", - }, - { - amount: 400, - currency_code: "USD", - min_quantity: 0, - max_quantity: 4 - } - ]) - - // do something with the money amounts or return them -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createMoneyAmounts.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createMoneyAmounts.mdx new file mode 100644 index 0000000000..93fda6591a --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createMoneyAmounts.mdx @@ -0,0 +1,51 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/createMoneyAmounts +sidebar_label: createMoneyAmounts +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# createMoneyAmounts - Pricing Module Reference + +This documentation provides a reference to the `createMoneyAmounts` method. This belongs to the Pricing Module. + +This method creates money amounts. + +## Example + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrieveMoneyAmounts () { + const pricingService = await initializePricingModule() + + const moneyAmounts = await pricingService.createMoneyAmounts([ + { + amount: 500, + currency_code: "USD", + }, + { + amount: 400, + currency_code: "USD", + min_quantity: 0, + max_quantity: 4 + } + ]) + + // do something with the money amounts or return them +} +``` + +## Parameters + + + +## Returns + +","optional":false,"defaultValue":"","description":"The list of created money amounts.","children":[{"name":"MoneyAmountDTO[]","type":"[`MoneyAmountDTO`](../../interfaces/MoneyAmountDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"MoneyAmountDTO","type":"`object`","description":"A money amount's data. A money amount represents a price.","optional":false,"defaultValue":"","children":[]}]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createPriceRules.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createPriceRules.md deleted file mode 100644 index 67f2c9d9d7..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createPriceRules.md +++ /dev/null @@ -1,103 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/createPriceRules -sidebar_label: createPriceRules ---- - -# createPriceRules - Pricing Module Reference - -This documentation provides a reference to the createPriceRules method. This belongs to the Pricing Module. - -This method is used to create new price rules based on the provided data. - -## Parameters - -- `data`: An array of objects of type [CreatePriceRuleDTO](../../interfaces/CreatePriceRuleDTO.md), each containing the data necessary to create a price rule. Its items accept the following properties: - - `id`: A string indicating the ID of the price rule. - - `is_dynamic`: (optional) A boolean indicating whether the price rule is dynamic. - - `price_list_id`: A string indicating the ID of the associated price list. - - `price_set_id`: A string indicating the ID of the associated price set. - - `price_set_money_amount_id`: A string indicating the ID of the associated price set money amount. - - `priority`: (optional) A number indicating the priority of the price rule in comparison to other applicable price rules. - - `rule_type_id`: A string indicating the ID of the associated rule type. - - `value`: A string indicating the value of the price rule. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves to an array of objects of type [PriceRuleDTO](../../interfaces/PriceRuleDTO.md), each being a created price rule. - -
- -PriceRuleDTO - - -- `id`: A string indicating the ID of the price rule. -- `is_dynamic`: A boolean indicating whether the price rule is dynamic. -- `price_list_id`: A string indicating the ID of the associated price list. -- `price_set`: An object of type [PriceSetDTO](../../interfaces/PriceSetDTO.md) that holds the data of the associated price set. It may only be available if the relation `price_set` is expanded. It accepts the following properties: - - `id`: A string indicating the ID of the price set. - - `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. Its items accept the following properties: - - `amount`: (optional) A number indicating the amount of this price. - - `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. - - `currency_code`: (optional) A string that indicates the currency code of this price. - - `id`: A string that indicates the ID of the money amount. A money amount represents a price. - - `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied. - - `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied. - - `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. Its items accept the following properties: - - `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. - - `id`: A string indicating the ID of the rule type. - - `name`: A string indicating the display name of the rule type. - - `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. -- `price_set_id`: A string indicating the ID of the associated price set. -- `price_set_money_amount_id`: A string indicating the ID of the associated price set money amount. -- `priority`: A number indicating the priority of the price rule in comparison to other applicable price rules. -- `rule_type`: An object of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md) that holds the data of the associated rule type. It may only be available if the relation `rule_type` is expanded. It accepts the following properties: - - `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. - - `id`: A string indicating the ID of the rule type. - - `name`: A string indicating the display name of the rule type. - - `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. -- `rule_type_id`: A string indicating the ID of the associated rule type. -- `value`: A string indicating the value of the price rule. - -
- -## Example - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function createPriceRules ( - id: string, - priceSetId: string, - ruleTypeId: string, - value: string, - priceSetMoneyAmountId: string, - priceListId: string -) { - const pricingService = await initializePricingModule() - - const priceRules = await pricingService.createPriceRules([ - { - id, - price_set_id: priceSetId, - rule_type_id: ruleTypeId, - value, - price_set_money_amount_id: priceSetMoneyAmountId, - price_list_id: priceListId - } - ]) - - // do something with the price rules or return them -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createPriceRules.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createPriceRules.mdx new file mode 100644 index 0000000000..6409d1c870 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createPriceRules.mdx @@ -0,0 +1,56 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/createPriceRules +sidebar_label: createPriceRules +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# createPriceRules - Pricing Module Reference + +This documentation provides a reference to the `createPriceRules` method. This belongs to the Pricing Module. + +This method is used to create new price rules based on the provided data. + +## Example + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function createPriceRules ( + id: string, + priceSetId: string, + ruleTypeId: string, + value: string, + priceSetMoneyAmountId: string, + priceListId: string +) { + const pricingService = await initializePricingModule() + + const priceRules = await pricingService.createPriceRules([ + { + id, + price_set_id: priceSetId, + rule_type_id: ruleTypeId, + value, + price_set_money_amount_id: priceSetMoneyAmountId, + price_list_id: priceListId + } + ]) + + // do something with the price rules or return them +} +``` + +## Parameters + + + +## Returns + +","optional":false,"defaultValue":"","description":"The list of created price rules.","children":[{"name":"PriceRuleDTO[]","type":"[`PriceRuleDTO`](../../interfaces/PriceRuleDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"PriceRuleDTO","type":"`object`","description":"A price rule's data.","optional":false,"defaultValue":"","children":[]}]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createPriceSetMoneyAmountRules.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createPriceSetMoneyAmountRules.md deleted file mode 100644 index 82ab5a3864..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createPriceSetMoneyAmountRules.md +++ /dev/null @@ -1,84 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/createPriceSetMoneyAmountRules -sidebar_label: createPriceSetMoneyAmountRules ---- - -# createPriceSetMoneyAmountRules - Pricing Module Reference - -This documentation provides a reference to the createPriceSetMoneyAmountRules method. This belongs to the Pricing Module. - -This method is used to create new price set money amount rules. A price set money amount rule creates an association between a price set money amount and -a rule type. - -## Parameters - -- `data`: An array of objects of type [CreatePriceSetMoneyAmountRulesDTO](../../interfaces/CreatePriceSetMoneyAmountRulesDTO.md), each containing the data of a price set money amount rule to create. Its items accept the following properties: - - `price_set_money_amount`: A string indicating the ID of a price set money amount. - - `rule_type`: A string indicating the ID of a rule type. - - `value`: A string indicating the value of the price set money amount rule. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves to an array of objects of type [PriceSetMoneyAmountRulesDTO](../../interfaces/PriceSetMoneyAmountRulesDTO.md), each being -a created price set money amount rule. - -
- -PriceSetMoneyAmountRulesDTO - - -- `id`: A string indicating the ID of the price set money amount. -- `price_set_money_amount`: an object of type [PriceSetMoneyAmountDTO](../../interfaces/PriceSetMoneyAmountDTO.md) holding the data of the associated price set money amount. It accepts the following properties: - - `id`: a string indicating the ID of a price set money amount. - - `money_amount`: (optional) an object of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md) holding the data of the associated money amount. It accepts the following properties: - - `amount`: (optional) A number indicating the amount of this price. - - `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. - - `currency_code`: (optional) A string that indicates the currency code of this price. - - `id`: A string that indicates the ID of the money amount. A money amount represents a price. - - `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied. - - `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied. - - `price_set`: (optional) an object of type [PriceSetDTO](../../interfaces/PriceSetDTO.md) holding the data of the associated price set. It accepts the following properties: - - `id`: A string indicating the ID of the price set. - - `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. - - `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. - - `title`: (optional) a string indicating the title of the price set money amount. -- `rule_type`: an object of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md) holding the data of the associated rule type. It accepts the following properties: - - `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. - - `id`: A string indicating the ID of the rule type. - - `name`: A string indicating the display name of the rule type. - - `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. -- `value`: a string indicating the value of the price set money amount rule. - -
- -## Example - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function createPriceSetMoneyAmountRules (priceSetMoneyAmountId: string, ruleTypeId: string, value: string) { - const pricingService = await initializePricingModule() - - const priceSetMoneyAmountRules = await pricingService.createPriceSetMoneyAmountRules([ - { - price_set_money_amount: priceSetMoneyAmountId, - rule_type: ruleTypeId, - value - } - ]) - - // do something with the price set money amount rules or return them -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createPriceSetMoneyAmountRules.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createPriceSetMoneyAmountRules.mdx new file mode 100644 index 0000000000..72e8d118d4 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createPriceSetMoneyAmountRules.mdx @@ -0,0 +1,47 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/createPriceSetMoneyAmountRules +sidebar_label: createPriceSetMoneyAmountRules +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# createPriceSetMoneyAmountRules - Pricing Module Reference + +This documentation provides a reference to the `createPriceSetMoneyAmountRules` method. This belongs to the Pricing Module. + +This method is used to create new price set money amount rules. A price set money amount rule creates an association between a price set money amount and +a rule type. + +## Example + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function createPriceSetMoneyAmountRules (priceSetMoneyAmountId: string, ruleTypeId: string, value: string) { + const pricingService = await initializePricingModule() + + const priceSetMoneyAmountRules = await pricingService.createPriceSetMoneyAmountRules([ + { + price_set_money_amount: priceSetMoneyAmountId, + rule_type: ruleTypeId, + value + } + ]) + + // do something with the price set money amount rules or return them +} +``` + +## Parameters + + + +## Returns + +","optional":false,"defaultValue":"","description":"The list of created price set money amount rules.","children":[{"name":"PriceSetMoneyAmountRulesDTO[]","type":"[`PriceSetMoneyAmountRulesDTO`](../../interfaces/PriceSetMoneyAmountRulesDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"PriceSetMoneyAmountRulesDTO","type":"`object`","description":"A price set money amount rule's data.","optional":false,"defaultValue":"","children":[]}]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createRuleTypes.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createRuleTypes.md deleted file mode 100644 index 14be183533..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createRuleTypes.md +++ /dev/null @@ -1,65 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/createRuleTypes -sidebar_label: createRuleTypes ---- - -# createRuleTypes - Pricing Module Reference - -This documentation provides a reference to the createRuleTypes method. This belongs to the Pricing Module. - -This method is used to create new rule types. - -## Parameters - -- `data`: An array of objects of type [CreateRuleTypeDTO](../../interfaces/CreateRuleTypeDTO.md), each being the data to use to create a rule type. Its items accept the following properties: - - `default_priority`: (optional) A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. - - `id`: (optional) A string indicating the ID of the rule type. - - `name`: A string indicating the display name of the rule type. - - `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves to an array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), each being a created rule type. - -
- -RuleTypeDTO - - -- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. -- `id`: A string indicating the ID of the rule type. -- `name`: A string indicating the display name of the rule type. -- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. - -
- -## Example - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function createRuleTypes () { - const pricingService = await initializePricingModule() - - const ruleTypes = await pricingService.createRuleTypes([ - { - name: "Region", - rule_attribute: "region_id" - } - ]) - - // do something with the rule types or return them -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createRuleTypes.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createRuleTypes.mdx new file mode 100644 index 0000000000..7760de6faf --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createRuleTypes.mdx @@ -0,0 +1,45 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/createRuleTypes +sidebar_label: createRuleTypes +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# createRuleTypes - Pricing Module Reference + +This documentation provides a reference to the `createRuleTypes` method. This belongs to the Pricing Module. + +This method is used to create new rule types. + +## Example + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function createRuleTypes () { + const pricingService = await initializePricingModule() + + const ruleTypes = await pricingService.createRuleTypes([ + { + name: "Region", + rule_attribute: "region_id" + } + ]) + + // do something with the rule types or return them +} +``` + +## Parameters + + + +## Returns + +","optional":false,"defaultValue":"","description":"The list of created rule types.","children":[{"name":"RuleTypeDTO[]","type":"[`RuleTypeDTO`](../../interfaces/RuleTypeDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"RuleTypeDTO","type":"`object`","description":"A rule type's data.","optional":false,"defaultValue":"","children":[]}]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.delete.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.delete.md deleted file mode 100644 index 5319d6d447..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.delete.md +++ /dev/null @@ -1,42 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/delete -sidebar_label: delete ---- - -# delete - Pricing Module Reference - -This documentation provides a reference to the delete method. This belongs to the Pricing Module. - -This method deletes price sets by their IDs. - -## Parameters - -- `ids`: An array of strings, each being the ID for a price set to delete. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves when the price sets are successfully deleted. - -## Example - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function removePriceSetRule (priceSetIds: string[]) { - const pricingService = await initializePricingModule() - - await pricingService.delete(priceSetIds) -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.delete.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.delete.mdx new file mode 100644 index 0000000000..987bb83814 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.delete.mdx @@ -0,0 +1,38 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/delete +sidebar_label: delete +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# delete - Pricing Module Reference + +This documentation provides a reference to the `delete` method. This belongs to the Pricing Module. + +This method deletes price sets by their IDs. + +## Example + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function removePriceSetRule (priceSetIds: string[]) { + const pricingService = await initializePricingModule() + + await pricingService.delete(priceSetIds) +} +``` + +## Parameters + + + +## Returns + +","optional":false,"defaultValue":"","description":"Resolves when the price sets are successfully deleted.","children":[]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deleteCurrencies.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deleteCurrencies.md deleted file mode 100644 index 2f42380f2b..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deleteCurrencies.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/deleteCurrencies -sidebar_label: deleteCurrencies ---- - -# deleteCurrencies - Pricing Module Reference - -This documentation provides a reference to the deleteCurrencies method. This belongs to the Pricing Module. - -This method is used to delete currencies based on their currency code. - -## Parameters - -- `currencyCodes`: An array of strings, each being a code of a currency to delete. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves once the currencies are deleted. - -## Example - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function deleteCurrencies () { - const pricingService = await initializePricingModule() - - await pricingService.deleteCurrencies(["USD"]) - -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deleteCurrencies.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deleteCurrencies.mdx new file mode 100644 index 0000000000..6a66f76d9a --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deleteCurrencies.mdx @@ -0,0 +1,39 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/deleteCurrencies +sidebar_label: deleteCurrencies +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# deleteCurrencies - Pricing Module Reference + +This documentation provides a reference to the `deleteCurrencies` method. This belongs to the Pricing Module. + +This method is used to delete currencies based on their currency code. + +## Example + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function deleteCurrencies () { + const pricingService = await initializePricingModule() + + await pricingService.deleteCurrencies(["USD"]) + +} +``` + +## Parameters + + + +## Returns + +","optional":false,"defaultValue":"","description":"Resolves once the currencies are deleted.","children":[]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deleteMoneyAmounts.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deleteMoneyAmounts.md deleted file mode 100644 index f3b70aa581..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deleteMoneyAmounts.md +++ /dev/null @@ -1,44 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/deleteMoneyAmounts -sidebar_label: deleteMoneyAmounts ---- - -# deleteMoneyAmounts - Pricing Module Reference - -This documentation provides a reference to the deleteMoneyAmounts method. This belongs to the Pricing Module. - -This method deletes money amounts by their IDs. - -## Parameters - -- `ids`: An array of strings, each being the ID of a money amount to delete. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves when the money amounts are successfully deleted. - -## Example - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function deleteMoneyAmounts (moneyAmountIds: string[]) { - const pricingService = await initializePricingModule() - - await pricingService.deleteMoneyAmounts( - moneyAmountIds - ) -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deleteMoneyAmounts.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deleteMoneyAmounts.mdx new file mode 100644 index 0000000000..217ff7e042 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deleteMoneyAmounts.mdx @@ -0,0 +1,40 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/deleteMoneyAmounts +sidebar_label: deleteMoneyAmounts +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# deleteMoneyAmounts - Pricing Module Reference + +This documentation provides a reference to the `deleteMoneyAmounts` method. This belongs to the Pricing Module. + +This method deletes money amounts by their IDs. + +## Example + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function deleteMoneyAmounts (moneyAmountIds: string[]) { + const pricingService = await initializePricingModule() + + await pricingService.deleteMoneyAmounts( + moneyAmountIds + ) +} +``` + +## Parameters + + + +## Returns + +","optional":false,"defaultValue":"","description":"Resolves when the money amounts are successfully deleted.","children":[]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deletePriceRules.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deletePriceRules.md deleted file mode 100644 index 4221650e3b..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deletePriceRules.md +++ /dev/null @@ -1,44 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/deletePriceRules -sidebar_label: deletePriceRules ---- - -# deletePriceRules - Pricing Module Reference - -This documentation provides a reference to the deletePriceRules method. This belongs to the Pricing Module. - -This method is used to delete price rules based on the specified IDs. - -## Parameters - -- `priceRuleIds`: An array of strings, each being the ID of a price rule to delete. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves once the price rules are deleted. - -## Example - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function deletePriceRules ( - id: string, -) { - const pricingService = await initializePricingModule() - - await pricingService.deletePriceRules([id]) -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deletePriceRules.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deletePriceRules.mdx new file mode 100644 index 0000000000..8ba61ffb59 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deletePriceRules.mdx @@ -0,0 +1,40 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/deletePriceRules +sidebar_label: deletePriceRules +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# deletePriceRules - Pricing Module Reference + +This documentation provides a reference to the `deletePriceRules` method. This belongs to the Pricing Module. + +This method is used to delete price rules based on the specified IDs. + +## Example + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function deletePriceRules ( + id: string, +) { + const pricingService = await initializePricingModule() + + await pricingService.deletePriceRules([id]) +} +``` + +## Parameters + + + +## Returns + +","optional":false,"defaultValue":"","description":"Resolves once the price rules are deleted.","children":[]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deletePriceSetMoneyAmountRules.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deletePriceSetMoneyAmountRules.md deleted file mode 100644 index 0dce0e6df9..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deletePriceSetMoneyAmountRules.md +++ /dev/null @@ -1,42 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/deletePriceSetMoneyAmountRules -sidebar_label: deletePriceSetMoneyAmountRules ---- - -# deletePriceSetMoneyAmountRules - Pricing Module Reference - -This documentation provides a reference to the deletePriceSetMoneyAmountRules method. This belongs to the Pricing Module. - -This method is used to delete price set money amount rules based on the specified IDs. - -## Parameters - -- `ids`: An array of strings, each representing the ID of a price set money amount rule to delete. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves once the price set money amount rules are deleted. - -## Example - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function deletePriceSetMoneyAmountRule (id: string) { - const pricingService = await initializePricingModule() - - await pricingService.deletePriceSetMoneyAmountRules([id]) -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deletePriceSetMoneyAmountRules.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deletePriceSetMoneyAmountRules.mdx new file mode 100644 index 0000000000..fada33a42a --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deletePriceSetMoneyAmountRules.mdx @@ -0,0 +1,38 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/deletePriceSetMoneyAmountRules +sidebar_label: deletePriceSetMoneyAmountRules +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# deletePriceSetMoneyAmountRules - Pricing Module Reference + +This documentation provides a reference to the `deletePriceSetMoneyAmountRules` method. This belongs to the Pricing Module. + +This method is used to delete price set money amount rules based on the specified IDs. + +## Example + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function deletePriceSetMoneyAmountRule (id: string) { + const pricingService = await initializePricingModule() + + await pricingService.deletePriceSetMoneyAmountRules([id]) +} +``` + +## Parameters + + + +## Returns + +","optional":false,"defaultValue":"","description":"Resolves once the price set money amount rules are deleted.","children":[]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deleteRuleTypes.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deleteRuleTypes.md deleted file mode 100644 index b2a5723731..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deleteRuleTypes.md +++ /dev/null @@ -1,42 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/deleteRuleTypes -sidebar_label: deleteRuleTypes ---- - -# deleteRuleTypes - Pricing Module Reference - -This documentation provides a reference to the deleteRuleTypes method. This belongs to the Pricing Module. - -This method is used to delete rule types based on the provided IDs. - -## Parameters - -- `ruleTypeIds`: An array of strings, each being the ID of a rule type to delete. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves once the rule types are deleted. - -## Example - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function deleteRuleTypes (ruleTypeId: string) { - const pricingService = await initializePricingModule() - - await pricingService.deleteRuleTypes([ruleTypeId]) -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deleteRuleTypes.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deleteRuleTypes.mdx new file mode 100644 index 0000000000..cb88fb618f --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deleteRuleTypes.mdx @@ -0,0 +1,38 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/deleteRuleTypes +sidebar_label: deleteRuleTypes +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# deleteRuleTypes - Pricing Module Reference + +This documentation provides a reference to the `deleteRuleTypes` method. This belongs to the Pricing Module. + +This method is used to delete rule types based on the provided IDs. + +## Example + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function deleteRuleTypes (ruleTypeId: string) { + const pricingService = await initializePricingModule() + + await pricingService.deleteRuleTypes([ruleTypeId]) +} +``` + +## Parameters + + + +## Returns + +","optional":false,"defaultValue":"","description":"Resolves once the rule types are deleted.","children":[]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.list.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.list.md deleted file mode 100644 index 2b2524c0fd..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.list.md +++ /dev/null @@ -1,172 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/list -sidebar_label: list ---- - -# list - Pricing Module Reference - -This documentation provides a reference to the list method. This belongs to the Pricing Module. - -This method is used to retrieve a paginated list of price sets based on optional filters and configuration. - -## Parameters - -- `filters`: (optional) An object of type [FilterablePriceSetProps](../../interfaces/FilterablePriceSetProps.md) that is used to filter the retrieved price lists. It accepts the following properties: - - `$and`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "and" condition. - - `$or`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "or" condition. - - `id`: (optional) An array of strings, each being an ID to filter price sets. - - `money_amounts`: (optional) An object of type [FilterableMoneyAmountProps](../../interfaces/FilterableMoneyAmountProps.md) that is used to filter the price sets by their associated money amounts. It accepts the following properties: - - `$and`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "and" condition. - - `$or`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "or" condition. - - `currency_code`: (optional) A string or an array of strings, each being a currency code to filter money amounts. - - `id`: (optional) An array of strings, each being an ID to filter money amounts. -- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the price sets are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price set. It accepts the following properties: - - `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order. - - `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result. - - `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result. - - `skip`: (optional) A number indicating the number of records to skip before retrieving the results. - - `take`: (optional) A number indicating the number of records to return in the result. - - `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves to an array of objects of type [PriceSetDTO](../../interfaces/PriceSetDTO.md). - -
- -PriceSetDTO - - -- `id`: A string indicating the ID of the price set. -- `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. Its items accept the following properties: - - `amount`: (optional) A number indicating the amount of this price. - - `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. It accepts the following properties: - - `code`: a string indicating the code of the currency. - - `name`: (optional) a string indicating the name of the currency. - - `symbol`: (optional) a string indicating the symbol of the currency. - - `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price. - - `currency_code`: (optional) A string that indicates the currency code of this price. - - `id`: A string that indicates the ID of the money amount. A money amount represents a price. - - `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied. - - `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied. -- `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. Its items accept the following properties: - - `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. - - `id`: A string indicating the ID of the rule type. - - `name`: A string indicating the display name of the rule type. - - `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. - -
- -## Example - -To retrieve a list of price sets using their IDs: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrievePriceSets (priceSetIds: string[]) { - const pricingService = await initializePricingModule() - - const priceSets = await pricingService.list( - { - id: priceSetIds - }, - ) - - // do something with the price sets or return them -} -``` - -To specify relations that should be retrieved within the price sets: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrievePriceSets (priceSetIds: string[]) { - const pricingService = await initializePricingModule() - - const priceSets = await pricingService.list( - { - id: priceSetIds - }, - { - relations: ["money_amounts"] - } - ) - - // do something with the price sets or return them -} -``` - -By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrievePriceSets (priceSetIds: string[], skip: number, take: number) { - const pricingService = await initializePricingModule() - - const priceSets = await pricingService.list( - { - id: priceSetIds - }, - { - relations: ["money_amounts"], - skip, - take - } - ) - - // do something with the price sets or return them -} -``` - -You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrievePriceSets (priceSetIds: string[], moneyAmountIds: string[], skip: number, take: number) { - const pricingService = await initializePricingModule() - - const priceSets = await pricingService.list( - { - $and: [ - { - id: priceSetIds - }, - { - money_amounts: { - id: moneyAmountIds - } - } - ] - }, - { - relations: ["money_amounts"], - skip, - take - } - ) - - // do something with the price sets or return them -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.list.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.list.mdx new file mode 100644 index 0000000000..eddda24f5a --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.list.mdx @@ -0,0 +1,128 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/list +sidebar_label: list +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# list - Pricing Module Reference + +This documentation provides a reference to the `list` method. This belongs to the Pricing Module. + +This method is used to retrieve a paginated list of price sets based on optional filters and configuration. + +## Example + +To retrieve a list of price sets using their IDs: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrievePriceSets (priceSetIds: string[]) { + const pricingService = await initializePricingModule() + + const priceSets = await pricingService.list( + { + id: priceSetIds + }, + ) + + // do something with the price sets or return them +} +``` + +To specify relations that should be retrieved within the price sets: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrievePriceSets (priceSetIds: string[]) { + const pricingService = await initializePricingModule() + + const priceSets = await pricingService.list( + { + id: priceSetIds + }, + { + relations: ["money_amounts"] + } + ) + + // do something with the price sets or return them +} +``` + +By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrievePriceSets (priceSetIds: string[], skip: number, take: number) { + const pricingService = await initializePricingModule() + + const priceSets = await pricingService.list( + { + id: priceSetIds + }, + { + relations: ["money_amounts"], + skip, + take + } + ) + + // do something with the price sets or return them +} +``` + +You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrievePriceSets (priceSetIds: string[], moneyAmountIds: string[], skip: number, take: number) { + const pricingService = await initializePricingModule() + + const priceSets = await pricingService.list( + { + $and: [ + { + id: priceSetIds + }, + { + money_amounts: { + id: moneyAmountIds + } + } + ] + }, + { + relations: ["money_amounts"], + skip, + take + } + ) + + // do something with the price sets or return them +} +``` + +## Parameters + +)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterablePriceSetProps`](../../interfaces/FilterablePriceSetProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterablePriceSetProps`](../../interfaces/FilterablePriceSetProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`[]","description":"IDs to filter price sets by.","optional":true,"defaultValue":"","children":[]},{"name":"money_amounts","type":"[`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx)","description":"Filters to apply on a price set's associated money amounts.","optional":true,"defaultValue":"","children":[{"name":"$and","type":"([`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"currency_code","type":"`string` \\| `string`[]","description":"Currency codes to filter money amounts by.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`[]","description":"IDs to filter money amounts by.","optional":true,"defaultValue":"","children":[]}]}]},{"name":"config","type":"[`FindConfig`](../../interfaces/FindConfig.mdx)<[`PriceSetDTO`](../../interfaces/PriceSetDTO.mdx)\\>","description":"The configurations determining how the price sets are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price set.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} /> + +## Returns + +","optional":false,"defaultValue":"","description":"The list of price sets.","children":[{"name":"PriceSetDTO[]","type":"[`PriceSetDTO`](../../interfaces/PriceSetDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"PriceSetDTO","type":"`object`","description":"A price set's data.","optional":false,"defaultValue":"","children":[]}]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCount.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCount.md deleted file mode 100644 index d8ad4f7f06..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCount.md +++ /dev/null @@ -1,173 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/listAndCount -sidebar_label: listAndCount ---- - -# listAndCount - Pricing Module Reference - -This documentation provides a reference to the listAndCount method. This belongs to the Pricing Module. - -This method is used to retrieve a paginated list of price sets along with the total count of available price sets satisfying the provided filters. - -## Parameters - -- `filters`: (optional) An object of type [FilterablePriceSetProps](../../interfaces/FilterablePriceSetProps.md) that is used to filter the retrieved price lists. It accepts the following properties: - - `$and`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "and" condition. - - `$or`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "or" condition. - - `id`: (optional) An array of strings, each being an ID to filter price sets. - - `money_amounts`: (optional) An object of type [FilterableMoneyAmountProps](../../interfaces/FilterableMoneyAmountProps.md) that is used to filter the price sets by their associated money amounts. It accepts the following properties: - - `$and`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "and" condition. - - `$or`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "or" condition. - - `currency_code`: (optional) A string or an array of strings, each being a currency code to filter money amounts. - - `id`: (optional) An array of strings, each being an ID to filter money amounts. -- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the price sets are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price set. It accepts the following properties: - - `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order. - - `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result. - - `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result. - - `skip`: (optional) A number indicating the number of records to skip before retrieving the results. - - `take`: (optional) A number indicating the number of records to return in the result. - - `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves to an array having two items, the first item is an array of objects of type [PriceSetDTO](../../interfaces/PriceSetDTO.md), -and the second item is a number indicating the total count. - -
- -PriceSetDTO - - -- `id`: A string indicating the ID of the price set. -- `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. Its items accept the following properties: - - `amount`: (optional) A number indicating the amount of this price. - - `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. It accepts the following properties: - - `code`: a string indicating the code of the currency. - - `name`: (optional) a string indicating the name of the currency. - - `symbol`: (optional) a string indicating the symbol of the currency. - - `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price. - - `currency_code`: (optional) A string that indicates the currency code of this price. - - `id`: A string that indicates the ID of the money amount. A money amount represents a price. - - `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied. - - `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied. -- `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. Its items accept the following properties: - - `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. - - `id`: A string indicating the ID of the rule type. - - `name`: A string indicating the display name of the rule type. - - `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. - -
- -## Example - -To retrieve a list of prices sets using their IDs: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrievePriceSets (priceSetIds: string[]) { - const pricingService = await initializePricingModule() - - const [priceSets, count] = await pricingService.listAndCount( - { - id: priceSetIds - }, - ) - - // do something with the price sets or return them -} -``` - -To specify relations that should be retrieved within the price sets: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrievePriceSets (priceSetIds: string[]) { - const pricingService = await initializePricingModule() - - const [priceSets, count] = await pricingService.listAndCount( - { - id: priceSetIds - }, - { - relations: ["money_amounts"] - } - ) - - // do something with the price sets or return them -} -``` - -By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrievePriceSets (priceSetIds: string[], skip: number, take: number) { - const pricingService = await initializePricingModule() - - const [priceSets, count] = await pricingService.listAndCount( - { - id: priceSetIds - }, - { - relations: ["money_amounts"], - skip, - take - } - ) - - // do something with the price sets or return them -} -``` - -You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrievePriceSets (priceSetIds: string[], moneyAmountIds: string[], skip: number, take: number) { - const pricingService = await initializePricingModule() - - const [priceSets, count] = await pricingService.listAndCount( - { - $and: [ - { - id: priceSetIds - }, - { - money_amounts: { - id: moneyAmountIds - } - } - ] - }, - { - relations: ["money_amounts"], - skip, - take - } - ) - - // do something with the price sets or return them -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCount.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCount.mdx new file mode 100644 index 0000000000..21261efbab --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCount.mdx @@ -0,0 +1,128 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/listAndCount +sidebar_label: listAndCount +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# listAndCount - Pricing Module Reference + +This documentation provides a reference to the `listAndCount` method. This belongs to the Pricing Module. + +This method is used to retrieve a paginated list of price sets along with the total count of available price sets satisfying the provided filters. + +## Example + +To retrieve a list of prices sets using their IDs: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrievePriceSets (priceSetIds: string[]) { + const pricingService = await initializePricingModule() + + const [priceSets, count] = await pricingService.listAndCount( + { + id: priceSetIds + }, + ) + + // do something with the price sets or return them +} +``` + +To specify relations that should be retrieved within the price sets: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrievePriceSets (priceSetIds: string[]) { + const pricingService = await initializePricingModule() + + const [priceSets, count] = await pricingService.listAndCount( + { + id: priceSetIds + }, + { + relations: ["money_amounts"] + } + ) + + // do something with the price sets or return them +} +``` + +By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrievePriceSets (priceSetIds: string[], skip: number, take: number) { + const pricingService = await initializePricingModule() + + const [priceSets, count] = await pricingService.listAndCount( + { + id: priceSetIds + }, + { + relations: ["money_amounts"], + skip, + take + } + ) + + // do something with the price sets or return them +} +``` + +You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrievePriceSets (priceSetIds: string[], moneyAmountIds: string[], skip: number, take: number) { + const pricingService = await initializePricingModule() + + const [priceSets, count] = await pricingService.listAndCount( + { + $and: [ + { + id: priceSetIds + }, + { + money_amounts: { + id: moneyAmountIds + } + } + ] + }, + { + relations: ["money_amounts"], + skip, + take + } + ) + + // do something with the price sets or return them +} +``` + +## Parameters + +)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterablePriceSetProps`](../../interfaces/FilterablePriceSetProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterablePriceSetProps`](../../interfaces/FilterablePriceSetProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`[]","description":"IDs to filter price sets by.","optional":true,"defaultValue":"","children":[]},{"name":"money_amounts","type":"[`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx)","description":"Filters to apply on a price set's associated money amounts.","optional":true,"defaultValue":"","children":[{"name":"$and","type":"([`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"currency_code","type":"`string` \\| `string`[]","description":"Currency codes to filter money amounts by.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`[]","description":"IDs to filter money amounts by.","optional":true,"defaultValue":"","children":[]}]}]},{"name":"config","type":"[`FindConfig`](../../interfaces/FindConfig.mdx)<[`PriceSetDTO`](../../interfaces/PriceSetDTO.mdx)\\>","description":"The configurations determining how the price sets are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price set.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} /> + +## Returns + +","optional":false,"defaultValue":"","description":"The list of price sets along with their total count.","children":[{"name":"PriceSetDTO[]","type":"[`PriceSetDTO`](../../interfaces/PriceSetDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[]},{"name":"number","type":"`number`","optional":true,"defaultValue":"","description":"","children":[]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountCurrencies.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountCurrencies.md deleted file mode 100644 index 3912faf94d..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountCurrencies.md +++ /dev/null @@ -1,121 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/listAndCountCurrencies -sidebar_label: listAndCountCurrencies ---- - -# listAndCountCurrencies - Pricing Module Reference - -This documentation provides a reference to the listAndCountCurrencies method. This belongs to the Pricing Module. - -This method is used to retrieve a paginated list of currencies along with the total count of available currencies satisfying the provided filters. - -## Parameters - -- `filters`: (optional) An object of type [FilterableCurrencyProps](../../interfaces/FilterableCurrencyProps.md) that is used to filter the retrieved currencies. It accepts the following properties: - - `$and`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "and" condition. - - `$or`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "or" condition. - - `code`: (optional) an array of strings, each being a currency code to filter the currencies. -- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the currencies are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a currency. It accepts the following properties: - - `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order. - - `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result. - - `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result. - - `skip`: (optional) A number indicating the number of records to skip before retrieving the results. - - `take`: (optional) A number indicating the number of records to return in the result. - - `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves to an array having two items, the first item is an array of objects of type [CurrencyDTO](../../interfaces/CurrencyDTO.md), -and the second item is a number indicating the total count. - -
- -CurrencyDTO - - -- `code`: a string indicating the code of the currency. -- `name`: (optional) a string indicating the name of the currency. -- `symbol`: (optional) a string indicating the symbol of the currency. -- `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price. - -
- -## Example - -To retrieve a list of currencies using their codes: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrieveCurrencies (codes: string[]) { - const pricingService = await initializePricingModule() - - const [currencies, count] = await pricingService.listAndCountCurrencies( - { - code: codes - }, - ) - - // do something with the currencies or return them -} -``` - -To specify attributes that should be retrieved within the money amounts: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrieveCurrencies (codes: string[]) { - const pricingService = await initializePricingModule() - - const [currencies, count] = await pricingService.listAndCountCurrencies( - { - code: codes - }, - { - select: ["symbol_native"] - } - ) - - // do something with the currencies or return them -} -``` - -By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrieveCurrencies (codes: string[], skip: number, take: number) { - const pricingService = await initializePricingModule() - - const [currencies, count] = await pricingService.listAndCountCurrencies( - { - code: codes - }, - { - select: ["symbol_native"], - skip, - take - } - ) - - // do something with the currencies or return them -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountCurrencies.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountCurrencies.mdx new file mode 100644 index 0000000000..ae54fea90c --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountCurrencies.mdx @@ -0,0 +1,94 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/listAndCountCurrencies +sidebar_label: listAndCountCurrencies +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# listAndCountCurrencies - Pricing Module Reference + +This documentation provides a reference to the `listAndCountCurrencies` method. This belongs to the Pricing Module. + +This method is used to retrieve a paginated list of currencies along with the total count of available currencies satisfying the provided filters. + +## Example + +To retrieve a list of currencies using their codes: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrieveCurrencies (codes: string[]) { + const pricingService = await initializePricingModule() + + const [currencies, count] = await pricingService.listAndCountCurrencies( + { + code: codes + }, + ) + + // do something with the currencies or return them +} +``` + +To specify attributes that should be retrieved within the money amounts: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrieveCurrencies (codes: string[]) { + const pricingService = await initializePricingModule() + + const [currencies, count] = await pricingService.listAndCountCurrencies( + { + code: codes + }, + { + select: ["symbol_native"] + } + ) + + // do something with the currencies or return them +} +``` + +By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrieveCurrencies (codes: string[], skip: number, take: number) { + const pricingService = await initializePricingModule() + + const [currencies, count] = await pricingService.listAndCountCurrencies( + { + code: codes + }, + { + select: ["symbol_native"], + skip, + take + } + ) + + // do something with the currencies or return them +} +``` + +## Parameters + +)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterableCurrencyProps`](../../interfaces/FilterableCurrencyProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterableCurrencyProps`](../../interfaces/FilterableCurrencyProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"code","type":"`string`[]","description":"The codes to filter the currencies by.","optional":true,"defaultValue":"","children":[]}]},{"name":"config","type":"[`FindConfig`](../../interfaces/FindConfig.mdx)<[`CurrencyDTO`](../../interfaces/CurrencyDTO.mdx)\\>","description":"The configurations determining how the currencies are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a currency.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} /> + +## Returns + +","optional":false,"defaultValue":"","description":"The list of currencies along with the total count.","children":[{"name":"CurrencyDTO[]","type":"[`CurrencyDTO`](../../interfaces/CurrencyDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[]},{"name":"number","type":"`number`","optional":true,"defaultValue":"","description":"","children":[]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountMoneyAmounts.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountMoneyAmounts.md deleted file mode 100644 index e9c68bfc7d..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountMoneyAmounts.md +++ /dev/null @@ -1,160 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/listAndCountMoneyAmounts -sidebar_label: listAndCountMoneyAmounts ---- - -# listAndCountMoneyAmounts - Pricing Module Reference - -This documentation provides a reference to the listAndCountMoneyAmounts method. This belongs to the Pricing Module. - -This method is used to retrieve a paginated list of money amounts along with the total count of available money amounts satisfying the provided filters. - -## Parameters - -- `filters`: (optional) An object of type [FilterableMoneyAmountProps](../../interfaces/FilterableMoneyAmountProps.md) that is used to filter the retrieved money amounts. It accepts the following properties: - - `$and`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "and" condition. - - `$or`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "or" condition. - - `currency_code`: (optional) A string or an array of strings, each being a currency code to filter money amounts. - - `id`: (optional) An array of strings, each being an ID to filter money amounts. -- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the money amounts are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a money amount. It accepts the following properties: - - `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order. - - `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result. - - `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result. - - `skip`: (optional) A number indicating the number of records to skip before retrieving the results. - - `take`: (optional) A number indicating the number of records to return in the result. - - `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves to an array having two items, the first item is an array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), -and the second item is a number indicating the total count. - -
- -MoneyAmountDTO - - -- `amount`: (optional) A number indicating the amount of this price. -- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. It accepts the following properties: - - `code`: a string indicating the code of the currency. - - `name`: (optional) a string indicating the name of the currency. - - `symbol`: (optional) a string indicating the symbol of the currency. - - `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price. -- `currency_code`: (optional) A string that indicates the currency code of this price. -- `id`: A string that indicates the ID of the money amount. A money amount represents a price. -- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied. -- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied. - -
- -## Example - -To retrieve a list of money amounts using their IDs: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrieveMoneyAmounts (moneyAmountIds: string[]) { - const pricingService = await initializePricingModule() - - const [moneyAmounts, count] = await pricingService.listAndCountMoneyAmounts( - { - id: moneyAmountIds - } - ) - - // do something with the money amounts or return them -} -``` - -To specify relations that should be retrieved within the money amounts: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrieveMoneyAmounts (moneyAmountIds: string[]) { - const pricingService = await initializePricingModule() - - const [moneyAmounts, count] = await pricingService.listAndCountMoneyAmounts( - { - id: moneyAmountIds - }, - { - relations: ["currency"] - } - ) - - // do something with the money amounts or return them -} -``` - -By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrieveMoneyAmounts (moneyAmountIds: string[], skip: number, take: number) { - const pricingService = await initializePricingModule() - - const [moneyAmounts, count] = await pricingService.listAndCountMoneyAmounts( - { - id: moneyAmountIds - }, - { - relations: ["currency"], - skip, - take - } - ) - - // do something with the money amounts or return them -} -``` - -You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrieveMoneyAmounts (moneyAmountIds: string[], currencyCode: string[], skip: number, take: number) { - const pricingService = await initializePricingModule() - - const [moneyAmounts, count] = await pricingService.listAndCountMoneyAmounts( - { - $and: [ - { - id: moneyAmountIds - }, - { - currency_code: currencyCode - } - ] - }, - { - relations: ["currency"], - skip, - take - } - ) - - // do something with the money amounts or return them -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountMoneyAmounts.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountMoneyAmounts.mdx new file mode 100644 index 0000000000..5e12436051 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountMoneyAmounts.mdx @@ -0,0 +1,126 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/listAndCountMoneyAmounts +sidebar_label: listAndCountMoneyAmounts +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# listAndCountMoneyAmounts - Pricing Module Reference + +This documentation provides a reference to the `listAndCountMoneyAmounts` method. This belongs to the Pricing Module. + +This method is used to retrieve a paginated list of money amounts along with the total count of available money amounts satisfying the provided filters. + +## Example + +To retrieve a list of money amounts using their IDs: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrieveMoneyAmounts (moneyAmountIds: string[]) { + const pricingService = await initializePricingModule() + + const [moneyAmounts, count] = await pricingService.listAndCountMoneyAmounts( + { + id: moneyAmountIds + } + ) + + // do something with the money amounts or return them +} +``` + +To specify relations that should be retrieved within the money amounts: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrieveMoneyAmounts (moneyAmountIds: string[]) { + const pricingService = await initializePricingModule() + + const [moneyAmounts, count] = await pricingService.listAndCountMoneyAmounts( + { + id: moneyAmountIds + }, + { + relations: ["currency"] + } + ) + + // do something with the money amounts or return them +} +``` + +By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrieveMoneyAmounts (moneyAmountIds: string[], skip: number, take: number) { + const pricingService = await initializePricingModule() + + const [moneyAmounts, count] = await pricingService.listAndCountMoneyAmounts( + { + id: moneyAmountIds + }, + { + relations: ["currency"], + skip, + take + } + ) + + // do something with the money amounts or return them +} +``` + +You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrieveMoneyAmounts (moneyAmountIds: string[], currencyCode: string[], skip: number, take: number) { + const pricingService = await initializePricingModule() + + const [moneyAmounts, count] = await pricingService.listAndCountMoneyAmounts( + { + $and: [ + { + id: moneyAmountIds + }, + { + currency_code: currencyCode + } + ] + }, + { + relations: ["currency"], + skip, + take + } + ) + + // do something with the money amounts or return them +} +``` + +## Parameters + +)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"currency_code","type":"`string` \\| `string`[]","description":"Currency codes to filter money amounts by.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`[]","description":"IDs to filter money amounts by.","optional":true,"defaultValue":"","children":[]}]},{"name":"config","type":"[`FindConfig`](../../interfaces/FindConfig.mdx)<[`MoneyAmountDTO`](../../interfaces/MoneyAmountDTO.mdx)\\>","description":"The configurations determining how the money amounts are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a money amount.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} /> + +## Returns + +","optional":false,"defaultValue":"","description":"The list of money amounts along with their total count.","children":[{"name":"MoneyAmountDTO[]","type":"[`MoneyAmountDTO`](../../interfaces/MoneyAmountDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[]},{"name":"number","type":"`number`","optional":true,"defaultValue":"","description":"","children":[]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountPriceRules.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountPriceRules.md deleted file mode 100644 index 2786d83587..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountPriceRules.md +++ /dev/null @@ -1,167 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/listAndCountPriceRules -sidebar_label: listAndCountPriceRules ---- - -# listAndCountPriceRules - Pricing Module Reference - -This documentation provides a reference to the listAndCountPriceRules method. This belongs to the Pricing Module. - -This method is used to retrieve a paginated list of price rules along with the total count of available price rules satisfying the provided filters. - -## Parameters - -- `filters`: (optional) An object of type [FilterablePriceRuleProps](../../interfaces/FilterablePriceRuleProps.md) that is used to filter the retrieved price rules. It accepts the following properties: - - `$and`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "and" condition. - - `$or`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "or" condition. - - `id`: (optional) An array of strings, each indicating an ID to filter price rules. - - `name`: (optional) An array of strings, each indicating a name to filter price rules. - - `price_set_id`: (optional) An array of strings, each indicating a price set ID to filter price rules. - - `rule_type_id`: (optional) An array of strings, each indicating a rule type ID to filter rule types. -- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the price rule is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price rule. It accepts the following properties: - - `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order. - - `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result. - - `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result. - - `skip`: (optional) A number indicating the number of records to skip before retrieving the results. - - `take`: (optional) A number indicating the number of records to return in the result. - - `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves to an array of objects of type [PriceRuleDTO](../../interfaces/PriceRuleDTO.md). - -
- -PriceRuleDTO - - -- `id`: A string indicating the ID of the price rule. -- `is_dynamic`: A boolean indicating whether the price rule is dynamic. -- `price_list_id`: A string indicating the ID of the associated price list. -- `price_set`: An object of type [PriceSetDTO](../../interfaces/PriceSetDTO.md) that holds the data of the associated price set. It may only be available if the relation `price_set` is expanded. It accepts the following properties: - - `id`: A string indicating the ID of the price set. - - `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. Its items accept the following properties: - - `amount`: (optional) A number indicating the amount of this price. - - `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. - - `currency_code`: (optional) A string that indicates the currency code of this price. - - `id`: A string that indicates the ID of the money amount. A money amount represents a price. - - `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied. - - `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied. - - `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. Its items accept the following properties: - - `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. - - `id`: A string indicating the ID of the rule type. - - `name`: A string indicating the display name of the rule type. - - `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. -- `price_set_id`: A string indicating the ID of the associated price set. -- `price_set_money_amount_id`: A string indicating the ID of the associated price set money amount. -- `priority`: A number indicating the priority of the price rule in comparison to other applicable price rules. -- `rule_type`: An object of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md) that holds the data of the associated rule type. It may only be available if the relation `rule_type` is expanded. It accepts the following properties: - - `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. - - `id`: A string indicating the ID of the rule type. - - `name`: A string indicating the display name of the rule type. - - `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. -- `rule_type_id`: A string indicating the ID of the associated rule type. -- `value`: A string indicating the value of the price rule. - -
- -## Example - -To retrieve a list of price rules using their IDs: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrievePriceRules (id: string) { - const pricingService = await initializePricingModule() - - const [priceRules, count] = await pricingService.listAndCountPriceRules({ - id: [id] - }) - - // do something with the price rules or return them -} -``` - -To specify relations that should be retrieved within the price rules: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrievePriceRules (id: string) { - const pricingService = await initializePricingModule() - - const [priceRules, count] = await pricingService.listAndCountPriceRules({ - id: [id], - }, { - relations: ["price_set"] - }) - - // do something with the price rules or return them -} -``` - -By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrievePriceRules (id: string, skip: number, take: number) { - const pricingService = await initializePricingModule() - - const [priceRules, count] = await pricingService.listAndCountPriceRules({ - id: [id], - }, { - relations: ["price_set"], - skip, - take - }) - - // do something with the price rules or return them -} -``` - -You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrievePriceRules (ids: string[], name: string[], skip: number, take: number) { - const pricingService = await initializePricingModule() - - const [priceRules, count] = await pricingService.listAndCountPriceRules({ - $and: [ - { - id: ids - }, - { - name - } - ] - }, { - relations: ["price_set"], - skip, - take - }) - - // do something with the price rules or return them -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountPriceRules.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountPriceRules.mdx new file mode 100644 index 0000000000..78e3714fa0 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountPriceRules.mdx @@ -0,0 +1,115 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/listAndCountPriceRules +sidebar_label: listAndCountPriceRules +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# listAndCountPriceRules - Pricing Module Reference + +This documentation provides a reference to the `listAndCountPriceRules` method. This belongs to the Pricing Module. + +This method is used to retrieve a paginated list of price rules along with the total count of available price rules satisfying the provided filters. + +## Example + +To retrieve a list of price rules using their IDs: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrievePriceRules (id: string) { + const pricingService = await initializePricingModule() + + const [priceRules, count] = await pricingService.listAndCountPriceRules({ + id: [id] + }) + + // do something with the price rules or return them +} +``` + +To specify relations that should be retrieved within the price rules: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrievePriceRules (id: string) { + const pricingService = await initializePricingModule() + + const [priceRules, count] = await pricingService.listAndCountPriceRules({ + id: [id], + }, { + relations: ["price_set"] + }) + + // do something with the price rules or return them +} +``` + +By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrievePriceRules (id: string, skip: number, take: number) { + const pricingService = await initializePricingModule() + + const [priceRules, count] = await pricingService.listAndCountPriceRules({ + id: [id], + }, { + relations: ["price_set"], + skip, + take + }) + + // do something with the price rules or return them +} +``` + +You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrievePriceRules (ids: string[], name: string[], skip: number, take: number) { + const pricingService = await initializePricingModule() + + const [priceRules, count] = await pricingService.listAndCountPriceRules({ + $and: [ + { + id: ids + }, + { + name + } + ] + }, { + relations: ["price_set"], + skip, + take + }) + + // do something with the price rules or return them +} +``` + +## Parameters + +)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterablePriceRuleProps`](../../interfaces/FilterablePriceRuleProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterablePriceRuleProps`](../../interfaces/FilterablePriceRuleProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`[]","description":"The IDs to filter price rules by.","optional":true,"defaultValue":"","children":[]},{"name":"name","type":"`string`[]","description":"The names to filter price rules by.","optional":true,"defaultValue":"","children":[]},{"name":"price_set_id","type":"`string`[]","description":"The IDs to filter the price rule's associated price set.","optional":true,"defaultValue":"","children":[]},{"name":"rule_type_id","type":"`string`[]","description":"The IDs to filter the price rule's associated rule type.","optional":true,"defaultValue":"","children":[]}]},{"name":"config","type":"[`FindConfig`](../../interfaces/FindConfig.mdx)<[`PriceRuleDTO`](../../interfaces/PriceRuleDTO.mdx)\\>","description":"The configurations determining how the price rule is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price rule.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} /> + +## Returns + +","optional":false,"defaultValue":"","description":"The list of price rules along with their total count.","children":[{"name":"PriceRuleDTO[]","type":"[`PriceRuleDTO`](../../interfaces/PriceRuleDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[]},{"name":"number","type":"`number`","optional":true,"defaultValue":"","description":"","children":[]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountPriceSetMoneyAmountRules.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountPriceSetMoneyAmountRules.md deleted file mode 100644 index 8ce8a5cb32..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountPriceSetMoneyAmountRules.md +++ /dev/null @@ -1,163 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/listAndCountPriceSetMoneyAmountRules -sidebar_label: listAndCountPriceSetMoneyAmountRules ---- - -# listAndCountPriceSetMoneyAmountRules - Pricing Module Reference - -This documentation provides a reference to the listAndCountPriceSetMoneyAmountRules method. This belongs to the Pricing Module. - -This method is used to retrieve a paginated list of price set money amount rules along with the total count of -available price set money amount rules satisfying the provided filters. - -## Parameters - -- `filters`: (optional) An object of type [FilterablePriceSetMoneyAmountRulesProps](../../interfaces/FilterablePriceSetMoneyAmountRulesProps.md) that is used to filter the retrieved price set money amount rules. It accepts the following properties: - - `$and`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "and" condition. - - `$or`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "or" condition. - - `id`: (optional) An array of strings, each string indicating an ID to filter the price set money amount rules. - - `price_set_money_amount_id`: (optional) an array of strings, each string indicating the ID of a price set money amount to filter the price set money amount rules. - - `rule_type_id`: (optional) An array of strings, each string indicating the ID of a rule type to filter the price set money amount rules. - - `value`: (optional) an array of strings, each string indicating a value to filter the price set money amount rules. -- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the price set money amount rules are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price set money amount rule. It accepts the following properties: - - `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order. - - `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result. - - `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result. - - `skip`: (optional) A number indicating the number of records to skip before retrieving the results. - - `take`: (optional) A number indicating the number of records to return in the result. - - `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves to an array having two items, the first item is an array of objects of type [PriceSetMoneyAmountRulesDTO](../../interfaces/PriceSetMoneyAmountRulesDTO.md), -and the second item is a number indicating the total count. - -
- -PriceSetMoneyAmountRulesDTO - - -- `id`: A string indicating the ID of the price set money amount. -- `price_set_money_amount`: an object of type [PriceSetMoneyAmountDTO](../../interfaces/PriceSetMoneyAmountDTO.md) holding the data of the associated price set money amount. It accepts the following properties: - - `id`: a string indicating the ID of a price set money amount. - - `money_amount`: (optional) an object of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md) holding the data of the associated money amount. It accepts the following properties: - - `amount`: (optional) A number indicating the amount of this price. - - `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. - - `currency_code`: (optional) A string that indicates the currency code of this price. - - `id`: A string that indicates the ID of the money amount. A money amount represents a price. - - `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied. - - `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied. - - `price_set`: (optional) an object of type [PriceSetDTO](../../interfaces/PriceSetDTO.md) holding the data of the associated price set. It accepts the following properties: - - `id`: A string indicating the ID of the price set. - - `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. - - `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. - - `title`: (optional) a string indicating the title of the price set money amount. -- `rule_type`: an object of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md) holding the data of the associated rule type. It accepts the following properties: - - `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. - - `id`: A string indicating the ID of the rule type. - - `name`: A string indicating the display name of the rule type. - - `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. -- `value`: a string indicating the value of the price set money amount rule. - -
- -## Example - -To retrieve a list of price set money amounts using their IDs: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrievePriceSetMoneyAmountRules (id: string) { - const pricingService = await initializePricingModule() - - const [priceSetMoneyAmountRules, count] = await pricingService.listAndCountPriceSetMoneyAmountRules({ - id: [id] - }) - - // do something with the price set money amount rules or return them -} -``` - -To specify relations that should be retrieved within the price set money amount rules: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrievePriceSetMoneyAmountRules (id: string) { - const pricingService = await initializePricingModule() - - const [priceSetMoneyAmountRules, count] = await pricingService.listAndCountPriceSetMoneyAmountRules({ - id: [id] - }, { - relations: ["price_set_money_amount"], - }) - - // do something with the price set money amount rules or return them -} -``` - -By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrievePriceSetMoneyAmountRules (id: string, skip: number, take: number) { - const pricingService = await initializePricingModule() - - const [priceSetMoneyAmountRules, count] = await pricingService.listAndCountPriceSetMoneyAmountRules({ - id: [id] - }, { - relations: ["price_set_money_amount"], - skip, - take - }) - - // do something with the price set money amount rules or return them -} -``` - -You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrievePriceSetMoneyAmountRules (ids: string[], ruleTypeId: string[], skip: number, take: number) { - const pricingService = await initializePricingModule() - - const [priceSetMoneyAmountRules, count] = await pricingService.listAndCountPriceSetMoneyAmountRules({ - $and: [ - { - id: ids - }, - { - rule_type_id: ruleTypeId - } - ] - }, { - relations: ["price_set_money_amount"], - skip, - take - }) - - // do something with the price set money amount rules or return them -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountPriceSetMoneyAmountRules.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountPriceSetMoneyAmountRules.mdx new file mode 100644 index 0000000000..6069c31807 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountPriceSetMoneyAmountRules.mdx @@ -0,0 +1,116 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/listAndCountPriceSetMoneyAmountRules +sidebar_label: listAndCountPriceSetMoneyAmountRules +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# listAndCountPriceSetMoneyAmountRules - Pricing Module Reference + +This documentation provides a reference to the `listAndCountPriceSetMoneyAmountRules` method. This belongs to the Pricing Module. + +This method is used to retrieve a paginated list of price set money amount rules along with the total count of +available price set money amount rules satisfying the provided filters. + +## Example + +To retrieve a list of price set money amounts using their IDs: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrievePriceSetMoneyAmountRules (id: string) { + const pricingService = await initializePricingModule() + + const [priceSetMoneyAmountRules, count] = await pricingService.listAndCountPriceSetMoneyAmountRules({ + id: [id] + }) + + // do something with the price set money amount rules or return them +} +``` + +To specify relations that should be retrieved within the price set money amount rules: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrievePriceSetMoneyAmountRules (id: string) { + const pricingService = await initializePricingModule() + + const [priceSetMoneyAmountRules, count] = await pricingService.listAndCountPriceSetMoneyAmountRules({ + id: [id] + }, { + relations: ["price_set_money_amount"], + }) + + // do something with the price set money amount rules or return them +} +``` + +By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrievePriceSetMoneyAmountRules (id: string, skip: number, take: number) { + const pricingService = await initializePricingModule() + + const [priceSetMoneyAmountRules, count] = await pricingService.listAndCountPriceSetMoneyAmountRules({ + id: [id] + }, { + relations: ["price_set_money_amount"], + skip, + take + }) + + // do something with the price set money amount rules or return them +} +``` + +You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrievePriceSetMoneyAmountRules (ids: string[], ruleTypeId: string[], skip: number, take: number) { + const pricingService = await initializePricingModule() + + const [priceSetMoneyAmountRules, count] = await pricingService.listAndCountPriceSetMoneyAmountRules({ + $and: [ + { + id: ids + }, + { + rule_type_id: ruleTypeId + } + ] + }, { + relations: ["price_set_money_amount"], + skip, + take + }) + + // do something with the price set money amount rules or return them +} +``` + +## Parameters + +)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterablePriceSetMoneyAmountRulesProps`](../../interfaces/FilterablePriceSetMoneyAmountRulesProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterablePriceSetMoneyAmountRulesProps`](../../interfaces/FilterablePriceSetMoneyAmountRulesProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`[]","description":"The ID to filter price set money amount rules by.","optional":true,"defaultValue":"","children":[]},{"name":"price_set_money_amount_id","type":"`string`[]","description":"The IDs to filter the price set money amount rule's associated price set money amount.","optional":true,"defaultValue":"","children":[]},{"name":"rule_type_id","type":"`string`[]","description":"The IDs to filter the price set money amount rule's associated rule type.","optional":true,"defaultValue":"","children":[]},{"name":"value","type":"`string`[]","description":"The value to filter price set money amount rules by.","optional":true,"defaultValue":"","children":[]}]},{"name":"config","type":"[`FindConfig`](../../interfaces/FindConfig.mdx)<[`PriceSetMoneyAmountRulesDTO`](../../interfaces/PriceSetMoneyAmountRulesDTO.mdx)\\>","description":"The configurations determining how the price set money amount rules are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price set money amount rule.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} /> + +## Returns + +","optional":false,"defaultValue":"","description":"The list of price set money amount rules and their total count.","children":[{"name":"PriceSetMoneyAmountRulesDTO[]","type":"[`PriceSetMoneyAmountRulesDTO`](../../interfaces/PriceSetMoneyAmountRulesDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[]},{"name":"number","type":"`number`","optional":true,"defaultValue":"","description":"","children":[]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountRuleTypes.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountRuleTypes.md deleted file mode 100644 index 149ccf3f51..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountRuleTypes.md +++ /dev/null @@ -1,150 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/listAndCountRuleTypes -sidebar_label: listAndCountRuleTypes ---- - -# listAndCountRuleTypes - Pricing Module Reference - -This documentation provides a reference to the listAndCountRuleTypes method. This belongs to the Pricing Module. - -This method is used to retrieve a paginated list of rule types along with the total count of available rule types satisfying the provided filters. - -## Parameters - -- `filters`: (optional) An object of type [FilterableRuleTypeProps](../../interfaces/FilterableRuleTypeProps.md) that is used to filter the retrieved rule types. It accepts the following properties: - - `$and`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "and" condition. - - `$or`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "or" condition. - - `id`: (optional) an array of strings, each being an ID to filter rule types. - - `name`: (optional) an array of strings, each being a name to filter rule types. - - `rule_attribute`: (optional) an array of strings, each being a rule attribute to filter rule types. -- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the rule types are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a rule type. It accepts the following properties: - - `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order. - - `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result. - - `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result. - - `skip`: (optional) A number indicating the number of records to skip before retrieving the results. - - `take`: (optional) A number indicating the number of records to return in the result. - - `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves to an array having two items, the first item is an array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), -and the second item is a number indicating the total count. - -
- -RuleTypeDTO - - -- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. -- `id`: A string indicating the ID of the rule type. -- `name`: A string indicating the display name of the rule type. -- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. - -
- -## Example - -To retrieve a list of rule types using their IDs: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrieveRuleTypes (ruleTypeId: string) { - const pricingService = await initializePricingModule() - - const [ruleTypes, count] = await pricingService.listAndCountRuleTypes({ - id: [ - ruleTypeId - ] - }) - - // do something with the rule types or return them -} -``` - -To specify attributes that should be retrieved within the rule types: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrieveRuleTypes (ruleTypeId: string) { - const pricingService = await initializePricingModule() - - const [ruleTypes, count] = await pricingService.listAndCountRuleTypes({ - id: [ - ruleTypeId - ] - }, { - select: ["name"] - }) - - // do something with the rule types or return them -} -``` - -By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrieveRuleTypes (ruleTypeId: string, skip: number, take: number) { - const pricingService = await initializePricingModule() - - const [ruleTypes, count] = await pricingService.listAndCountRuleTypes({ - id: [ - ruleTypeId - ] - }, { - select: ["name"], - skip, - take - }) - - // do something with the rule types or return them -} -``` - -You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrieveRuleTypes (ruleTypeId: string[], name: string[], skip: number, take: number) { - const pricingService = await initializePricingModule() - - const [ruleTypes, count] = await pricingService.listAndCountRuleTypes({ - $and: [ - { - id: ruleTypeId - }, - { - name - } - ] - }, { - select: ["name"], - skip, - take - }) - - // do something with the rule types or return them -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountRuleTypes.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountRuleTypes.mdx new file mode 100644 index 0000000000..cce0d800c3 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountRuleTypes.mdx @@ -0,0 +1,121 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/listAndCountRuleTypes +sidebar_label: listAndCountRuleTypes +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# listAndCountRuleTypes - Pricing Module Reference + +This documentation provides a reference to the `listAndCountRuleTypes` method. This belongs to the Pricing Module. + +This method is used to retrieve a paginated list of rule types along with the total count of available rule types satisfying the provided filters. + +## Example + +To retrieve a list of rule types using their IDs: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrieveRuleTypes (ruleTypeId: string) { + const pricingService = await initializePricingModule() + + const [ruleTypes, count] = await pricingService.listAndCountRuleTypes({ + id: [ + ruleTypeId + ] + }) + + // do something with the rule types or return them +} +``` + +To specify attributes that should be retrieved within the rule types: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrieveRuleTypes (ruleTypeId: string) { + const pricingService = await initializePricingModule() + + const [ruleTypes, count] = await pricingService.listAndCountRuleTypes({ + id: [ + ruleTypeId + ] + }, { + select: ["name"] + }) + + // do something with the rule types or return them +} +``` + +By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrieveRuleTypes (ruleTypeId: string, skip: number, take: number) { + const pricingService = await initializePricingModule() + + const [ruleTypes, count] = await pricingService.listAndCountRuleTypes({ + id: [ + ruleTypeId + ] + }, { + select: ["name"], + skip, + take + }) + + // do something with the rule types or return them +} +``` + +You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrieveRuleTypes (ruleTypeId: string[], name: string[], skip: number, take: number) { + const pricingService = await initializePricingModule() + + const [ruleTypes, count] = await pricingService.listAndCountRuleTypes({ + $and: [ + { + id: ruleTypeId + }, + { + name + } + ] + }, { + select: ["name"], + skip, + take + }) + + // do something with the rule types or return them +} +``` + +## Parameters + +)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterableRuleTypeProps`](../../interfaces/FilterableRuleTypeProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterableRuleTypeProps`](../../interfaces/FilterableRuleTypeProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`[]","description":"The IDs to filter rule types by.","optional":true,"defaultValue":"","children":[]},{"name":"name","type":"`string`[]","description":"The names to filter rule types by.","optional":true,"defaultValue":"","children":[]},{"name":"rule_attribute","type":"`string`[]","description":"The rule attributes to filter rule types by.","optional":true,"defaultValue":"","children":[]}]},{"name":"config","type":"[`FindConfig`](../../interfaces/FindConfig.mdx)<[`RuleTypeDTO`](../../interfaces/RuleTypeDTO.mdx)\\>","description":"The configurations determining how the rule types are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a rule type.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} /> + +## Returns + +","optional":false,"defaultValue":"","description":"The list of rule types along with their total count.","children":[{"name":"RuleTypeDTO[]","type":"[`RuleTypeDTO`](../../interfaces/RuleTypeDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[]},{"name":"number","type":"`number`","optional":true,"defaultValue":"","description":"","children":[]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listCurrencies.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listCurrencies.md deleted file mode 100644 index 3191f69669..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listCurrencies.md +++ /dev/null @@ -1,120 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/listCurrencies -sidebar_label: listCurrencies ---- - -# listCurrencies - Pricing Module Reference - -This documentation provides a reference to the listCurrencies method. This belongs to the Pricing Module. - -This method is used to retrieve a paginated list of currencies based on optional filters and configuration. - -## Parameters - -- `filters`: (optional) An object of type [FilterableCurrencyProps](../../interfaces/FilterableCurrencyProps.md) that is used to filter the retrieved currencies. It accepts the following properties: - - `$and`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "and" condition. - - `$or`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "or" condition. - - `code`: (optional) an array of strings, each being a currency code to filter the currencies. -- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the currencies are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a currency. It accepts the following properties: - - `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order. - - `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result. - - `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result. - - `skip`: (optional) A number indicating the number of records to skip before retrieving the results. - - `take`: (optional) A number indicating the number of records to return in the result. - - `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves to an array of objects of type [CurrencyDTO](../../interfaces/CurrencyDTO.md). - -
- -CurrencyDTO - - -- `code`: a string indicating the code of the currency. -- `name`: (optional) a string indicating the name of the currency. -- `symbol`: (optional) a string indicating the symbol of the currency. -- `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price. - -
- -## Example - -To retrieve a list of currencies using their codes: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrieveCurrencies (codes: string[]) { - const pricingService = await initializePricingModule() - - const currencies = await pricingService.listCurrencies( - { - code: codes - }, - ) - - // do something with the currencies or return them -} -``` - -To specify attributes that should be retrieved within the money amounts: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrieveCurrencies (codes: string[]) { - const pricingService = await initializePricingModule() - - const currencies = await pricingService.listCurrencies( - { - code: codes - }, - { - select: ["symbol_native"] - } - ) - - // do something with the currencies or return them -} -``` - -By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrieveCurrencies (codes: string[], skip: number, take: number) { - const pricingService = await initializePricingModule() - - const currencies = await pricingService.listCurrencies( - { - code: codes - }, - { - select: ["symbol_native"], - skip, - take - } - ) - - // do something with the currencies or return them -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listCurrencies.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listCurrencies.mdx new file mode 100644 index 0000000000..e878fb042c --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listCurrencies.mdx @@ -0,0 +1,94 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/listCurrencies +sidebar_label: listCurrencies +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# listCurrencies - Pricing Module Reference + +This documentation provides a reference to the `listCurrencies` method. This belongs to the Pricing Module. + +This method is used to retrieve a paginated list of currencies based on optional filters and configuration. + +## Example + +To retrieve a list of currencies using their codes: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrieveCurrencies (codes: string[]) { + const pricingService = await initializePricingModule() + + const currencies = await pricingService.listCurrencies( + { + code: codes + }, + ) + + // do something with the currencies or return them +} +``` + +To specify attributes that should be retrieved within the money amounts: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrieveCurrencies (codes: string[]) { + const pricingService = await initializePricingModule() + + const currencies = await pricingService.listCurrencies( + { + code: codes + }, + { + select: ["symbol_native"] + } + ) + + // do something with the currencies or return them +} +``` + +By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrieveCurrencies (codes: string[], skip: number, take: number) { + const pricingService = await initializePricingModule() + + const currencies = await pricingService.listCurrencies( + { + code: codes + }, + { + select: ["symbol_native"], + skip, + take + } + ) + + // do something with the currencies or return them +} +``` + +## Parameters + +)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterableCurrencyProps`](../../interfaces/FilterableCurrencyProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterableCurrencyProps`](../../interfaces/FilterableCurrencyProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"code","type":"`string`[]","description":"The codes to filter the currencies by.","optional":true,"defaultValue":"","children":[]}]},{"name":"config","type":"[`FindConfig`](../../interfaces/FindConfig.mdx)<[`CurrencyDTO`](../../interfaces/CurrencyDTO.mdx)\\>","description":"The configurations determining how the currencies are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a currency.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} /> + +## Returns + +","optional":false,"defaultValue":"","description":"The list of currencies.","children":[{"name":"CurrencyDTO[]","type":"[`CurrencyDTO`](../../interfaces/CurrencyDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"CurrencyDTO","type":"`object`","description":"A currency's data.","optional":false,"defaultValue":"","children":[]}]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listMoneyAmounts.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listMoneyAmounts.md deleted file mode 100644 index 64f02422f8..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listMoneyAmounts.md +++ /dev/null @@ -1,159 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/listMoneyAmounts -sidebar_label: listMoneyAmounts ---- - -# listMoneyAmounts - Pricing Module Reference - -This documentation provides a reference to the listMoneyAmounts method. This belongs to the Pricing Module. - -This method is used to retrieve a paginated list of money amounts based on optional filters and configuration. - -## Parameters - -- `filters`: (optional) An object of type [FilterableMoneyAmountProps](../../interfaces/FilterableMoneyAmountProps.md) that is used to filter the retrieved money amounts. It accepts the following properties: - - `$and`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "and" condition. - - `$or`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "or" condition. - - `currency_code`: (optional) A string or an array of strings, each being a currency code to filter money amounts. - - `id`: (optional) An array of strings, each being an ID to filter money amounts. -- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the money amounts are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a money amount. It accepts the following properties: - - `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order. - - `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result. - - `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result. - - `skip`: (optional) A number indicating the number of records to skip before retrieving the results. - - `take`: (optional) A number indicating the number of records to return in the result. - - `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves to an array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md). - -
- -MoneyAmountDTO - - -- `amount`: (optional) A number indicating the amount of this price. -- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. It accepts the following properties: - - `code`: a string indicating the code of the currency. - - `name`: (optional) a string indicating the name of the currency. - - `symbol`: (optional) a string indicating the symbol of the currency. - - `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price. -- `currency_code`: (optional) A string that indicates the currency code of this price. -- `id`: A string that indicates the ID of the money amount. A money amount represents a price. -- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied. -- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied. - -
- -## Example - -To retrieve a list of money amounts using their IDs: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrieveMoneyAmounts (moneyAmountIds: string[]) { - const pricingService = await initializePricingModule() - - const moneyAmounts = await pricingService.listMoneyAmounts( - { - id: moneyAmountIds - } - ) - - // do something with the money amounts or return them -} -``` - -To specify relations that should be retrieved within the money amounts: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrieveMoneyAmounts (moneyAmountIds: string[]) { - const pricingService = await initializePricingModule() - - const moneyAmounts = await pricingService.listMoneyAmounts( - { - id: moneyAmountIds - }, - { - relations: ["currency"] - } - ) - - // do something with the money amounts or return them -} -``` - -By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrieveMoneyAmounts (moneyAmountIds: string[], skip: number, take: number) { - const pricingService = await initializePricingModule() - - const moneyAmounts = await pricingService.listMoneyAmounts( - { - id: moneyAmountIds - }, - { - relations: ["currency"], - skip, - take - } - ) - - // do something with the money amounts or return them -} -``` - -You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrieveMoneyAmounts (moneyAmountIds: string[], currencyCode: string[], skip: number, take: number) { - const pricingService = await initializePricingModule() - - const moneyAmounts = await pricingService.listMoneyAmounts( - { - $and: [ - { - id: moneyAmountIds - }, - { - currency_code: currencyCode - } - ] - }, - { - relations: ["currency"], - skip, - take - } - ) - - // do something with the money amounts or return them -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listMoneyAmounts.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listMoneyAmounts.mdx new file mode 100644 index 0000000000..0a2868c66b --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listMoneyAmounts.mdx @@ -0,0 +1,126 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/listMoneyAmounts +sidebar_label: listMoneyAmounts +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# listMoneyAmounts - Pricing Module Reference + +This documentation provides a reference to the `listMoneyAmounts` method. This belongs to the Pricing Module. + +This method is used to retrieve a paginated list of money amounts based on optional filters and configuration. + +## Example + +To retrieve a list of money amounts using their IDs: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrieveMoneyAmounts (moneyAmountIds: string[]) { + const pricingService = await initializePricingModule() + + const moneyAmounts = await pricingService.listMoneyAmounts( + { + id: moneyAmountIds + } + ) + + // do something with the money amounts or return them +} +``` + +To specify relations that should be retrieved within the money amounts: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrieveMoneyAmounts (moneyAmountIds: string[]) { + const pricingService = await initializePricingModule() + + const moneyAmounts = await pricingService.listMoneyAmounts( + { + id: moneyAmountIds + }, + { + relations: ["currency"] + } + ) + + // do something with the money amounts or return them +} +``` + +By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrieveMoneyAmounts (moneyAmountIds: string[], skip: number, take: number) { + const pricingService = await initializePricingModule() + + const moneyAmounts = await pricingService.listMoneyAmounts( + { + id: moneyAmountIds + }, + { + relations: ["currency"], + skip, + take + } + ) + + // do something with the money amounts or return them +} +``` + +You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrieveMoneyAmounts (moneyAmountIds: string[], currencyCode: string[], skip: number, take: number) { + const pricingService = await initializePricingModule() + + const moneyAmounts = await pricingService.listMoneyAmounts( + { + $and: [ + { + id: moneyAmountIds + }, + { + currency_code: currencyCode + } + ] + }, + { + relations: ["currency"], + skip, + take + } + ) + + // do something with the money amounts or return them +} +``` + +## Parameters + +)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterableMoneyAmountProps`](../../interfaces/FilterableMoneyAmountProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"currency_code","type":"`string` \\| `string`[]","description":"Currency codes to filter money amounts by.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`[]","description":"IDs to filter money amounts by.","optional":true,"defaultValue":"","children":[]}]},{"name":"config","type":"[`FindConfig`](../../interfaces/FindConfig.mdx)<[`MoneyAmountDTO`](../../interfaces/MoneyAmountDTO.mdx)\\>","description":"The configurations determining how the money amounts are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a money amount.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} /> + +## Returns + +","optional":false,"defaultValue":"","description":"The list of money amounts.","children":[{"name":"MoneyAmountDTO[]","type":"[`MoneyAmountDTO`](../../interfaces/MoneyAmountDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"MoneyAmountDTO","type":"`object`","description":"A money amount's data. A money amount represents a price.","optional":false,"defaultValue":"","children":[]}]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listPriceRules.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listPriceRules.md deleted file mode 100644 index 9488118952..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listPriceRules.md +++ /dev/null @@ -1,167 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/listPriceRules -sidebar_label: listPriceRules ---- - -# listPriceRules - Pricing Module Reference - -This documentation provides a reference to the listPriceRules method. This belongs to the Pricing Module. - -This method is used to retrieve a paginated list of price rules based on optional filters and configuration. - -## Parameters - -- `filters`: (optional) An object of type [FilterablePriceRuleProps](../../interfaces/FilterablePriceRuleProps.md) that is used to filter the retrieved price rules. It accepts the following properties: - - `$and`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "and" condition. - - `$or`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "or" condition. - - `id`: (optional) An array of strings, each indicating an ID to filter price rules. - - `name`: (optional) An array of strings, each indicating a name to filter price rules. - - `price_set_id`: (optional) An array of strings, each indicating a price set ID to filter price rules. - - `rule_type_id`: (optional) An array of strings, each indicating a rule type ID to filter rule types. -- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the price rule is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price rule. It accepts the following properties: - - `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order. - - `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result. - - `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result. - - `skip`: (optional) A number indicating the number of records to skip before retrieving the results. - - `take`: (optional) A number indicating the number of records to return in the result. - - `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves to an array of objects of type [PriceRuleDTO](../../interfaces/PriceRuleDTO.md). - -
- -PriceRuleDTO - - -- `id`: A string indicating the ID of the price rule. -- `is_dynamic`: A boolean indicating whether the price rule is dynamic. -- `price_list_id`: A string indicating the ID of the associated price list. -- `price_set`: An object of type [PriceSetDTO](../../interfaces/PriceSetDTO.md) that holds the data of the associated price set. It may only be available if the relation `price_set` is expanded. It accepts the following properties: - - `id`: A string indicating the ID of the price set. - - `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. Its items accept the following properties: - - `amount`: (optional) A number indicating the amount of this price. - - `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. - - `currency_code`: (optional) A string that indicates the currency code of this price. - - `id`: A string that indicates the ID of the money amount. A money amount represents a price. - - `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied. - - `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied. - - `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. Its items accept the following properties: - - `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. - - `id`: A string indicating the ID of the rule type. - - `name`: A string indicating the display name of the rule type. - - `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. -- `price_set_id`: A string indicating the ID of the associated price set. -- `price_set_money_amount_id`: A string indicating the ID of the associated price set money amount. -- `priority`: A number indicating the priority of the price rule in comparison to other applicable price rules. -- `rule_type`: An object of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md) that holds the data of the associated rule type. It may only be available if the relation `rule_type` is expanded. It accepts the following properties: - - `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. - - `id`: A string indicating the ID of the rule type. - - `name`: A string indicating the display name of the rule type. - - `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. -- `rule_type_id`: A string indicating the ID of the associated rule type. -- `value`: A string indicating the value of the price rule. - -
- -## Example - -To retrieve a list of price rules using their IDs: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrievePriceRules (id: string) { - const pricingService = await initializePricingModule() - - const priceRules = await pricingService.listPriceRules({ - id: [id] - }) - - // do something with the price rules or return them -} -``` - -To specify relations that should be retrieved within the price rules: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrievePriceRules (id: string) { - const pricingService = await initializePricingModule() - - const priceRules = await pricingService.listPriceRules({ - id: [id], - }, { - relations: ["price_set"] - }) - - // do something with the price rules or return them -} -``` - -By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrievePriceRules (id: string, skip: number, take: number) { - const pricingService = await initializePricingModule() - - const priceRules = await pricingService.listPriceRules({ - id: [id], - }, { - relations: ["price_set"], - skip, - take - }) - - // do something with the price rules or return them -} -``` - -You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrievePriceRules (ids: string[], name: string[], skip: number, take: number) { - const pricingService = await initializePricingModule() - - const priceRules = await pricingService.listPriceRules({ - $and: [ - { - id: ids - }, - { - name - } - ] - }, { - relations: ["price_set"], - skip, - take - }) - - // do something with the price rules or return them -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listPriceRules.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listPriceRules.mdx new file mode 100644 index 0000000000..39ac311e00 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listPriceRules.mdx @@ -0,0 +1,115 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/listPriceRules +sidebar_label: listPriceRules +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# listPriceRules - Pricing Module Reference + +This documentation provides a reference to the `listPriceRules` method. This belongs to the Pricing Module. + +This method is used to retrieve a paginated list of price rules based on optional filters and configuration. + +## Example + +To retrieve a list of price rules using their IDs: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrievePriceRules (id: string) { + const pricingService = await initializePricingModule() + + const priceRules = await pricingService.listPriceRules({ + id: [id] + }) + + // do something with the price rules or return them +} +``` + +To specify relations that should be retrieved within the price rules: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrievePriceRules (id: string) { + const pricingService = await initializePricingModule() + + const priceRules = await pricingService.listPriceRules({ + id: [id], + }, { + relations: ["price_set"] + }) + + // do something with the price rules or return them +} +``` + +By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrievePriceRules (id: string, skip: number, take: number) { + const pricingService = await initializePricingModule() + + const priceRules = await pricingService.listPriceRules({ + id: [id], + }, { + relations: ["price_set"], + skip, + take + }) + + // do something with the price rules or return them +} +``` + +You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrievePriceRules (ids: string[], name: string[], skip: number, take: number) { + const pricingService = await initializePricingModule() + + const priceRules = await pricingService.listPriceRules({ + $and: [ + { + id: ids + }, + { + name + } + ] + }, { + relations: ["price_set"], + skip, + take + }) + + // do something with the price rules or return them +} +``` + +## Parameters + +)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterablePriceRuleProps`](../../interfaces/FilterablePriceRuleProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterablePriceRuleProps`](../../interfaces/FilterablePriceRuleProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`[]","description":"The IDs to filter price rules by.","optional":true,"defaultValue":"","children":[]},{"name":"name","type":"`string`[]","description":"The names to filter price rules by.","optional":true,"defaultValue":"","children":[]},{"name":"price_set_id","type":"`string`[]","description":"The IDs to filter the price rule's associated price set.","optional":true,"defaultValue":"","children":[]},{"name":"rule_type_id","type":"`string`[]","description":"The IDs to filter the price rule's associated rule type.","optional":true,"defaultValue":"","children":[]}]},{"name":"config","type":"[`FindConfig`](../../interfaces/FindConfig.mdx)<[`PriceRuleDTO`](../../interfaces/PriceRuleDTO.mdx)\\>","description":"The configurations determining how the price rule is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price rule.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} /> + +## Returns + +","optional":false,"defaultValue":"","description":"The list of price rules.","children":[{"name":"PriceRuleDTO[]","type":"[`PriceRuleDTO`](../../interfaces/PriceRuleDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"PriceRuleDTO","type":"`object`","description":"A price rule's data.","optional":false,"defaultValue":"","children":[]}]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listPriceSetMoneyAmountRules.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listPriceSetMoneyAmountRules.md deleted file mode 100644 index f1fb3d861a..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listPriceSetMoneyAmountRules.md +++ /dev/null @@ -1,161 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/listPriceSetMoneyAmountRules -sidebar_label: listPriceSetMoneyAmountRules ---- - -# listPriceSetMoneyAmountRules - Pricing Module Reference - -This documentation provides a reference to the listPriceSetMoneyAmountRules method. This belongs to the Pricing Module. - -This method is used to retrieve a paginated list of price set money amount rules based on optional filters and configuration. - -## Parameters - -- `filters`: (optional) An object of type [FilterablePriceSetMoneyAmountRulesProps](../../interfaces/FilterablePriceSetMoneyAmountRulesProps.md) that is used to filter the retrieved price set money amount rules. It accepts the following properties: - - `$and`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "and" condition. - - `$or`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "or" condition. - - `id`: (optional) An array of strings, each string indicating an ID to filter the price set money amount rules. - - `price_set_money_amount_id`: (optional) an array of strings, each string indicating the ID of a price set money amount to filter the price set money amount rules. - - `rule_type_id`: (optional) An array of strings, each string indicating the ID of a rule type to filter the price set money amount rules. - - `value`: (optional) an array of strings, each string indicating a value to filter the price set money amount rules. -- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the price set money amount rules are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price set money amount rule. It accepts the following properties: - - `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order. - - `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result. - - `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result. - - `skip`: (optional) A number indicating the number of records to skip before retrieving the results. - - `take`: (optional) A number indicating the number of records to return in the result. - - `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves to an array of objects of type [PriceSetMoneyAmountRulesDTO](../../interfaces/PriceSetMoneyAmountRulesDTO.md). - -
- -PriceSetMoneyAmountRulesDTO - - -- `id`: A string indicating the ID of the price set money amount. -- `price_set_money_amount`: an object of type [PriceSetMoneyAmountDTO](../../interfaces/PriceSetMoneyAmountDTO.md) holding the data of the associated price set money amount. It accepts the following properties: - - `id`: a string indicating the ID of a price set money amount. - - `money_amount`: (optional) an object of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md) holding the data of the associated money amount. It accepts the following properties: - - `amount`: (optional) A number indicating the amount of this price. - - `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. - - `currency_code`: (optional) A string that indicates the currency code of this price. - - `id`: A string that indicates the ID of the money amount. A money amount represents a price. - - `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied. - - `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied. - - `price_set`: (optional) an object of type [PriceSetDTO](../../interfaces/PriceSetDTO.md) holding the data of the associated price set. It accepts the following properties: - - `id`: A string indicating the ID of the price set. - - `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. - - `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. - - `title`: (optional) a string indicating the title of the price set money amount. -- `rule_type`: an object of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md) holding the data of the associated rule type. It accepts the following properties: - - `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. - - `id`: A string indicating the ID of the rule type. - - `name`: A string indicating the display name of the rule type. - - `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. -- `value`: a string indicating the value of the price set money amount rule. - -
- -## Example - -To retrieve a list of price set money amount rules using their IDs: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrievePriceSetMoneyAmountRules (id: string) { - const pricingService = await initializePricingModule() - - const priceSetMoneyAmountRules = await pricingService.listPriceSetMoneyAmountRules({ - id: [id] - }) - - // do something with the price set money amount rules or return them -} -``` - -To specify relations that should be retrieved within the price set money amount rules: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrievePriceSetMoneyAmountRules (id: string) { - const pricingService = await initializePricingModule() - - const priceSetMoneyAmountRules = await pricingService.listPriceSetMoneyAmountRules({ - id: [id] - }, { - relations: ["price_set_money_amount"] - }) - - // do something with the price set money amount rules or return them -} -``` - -By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrievePriceSetMoneyAmountRules (id: string, skip: number, take: number) { - const pricingService = await initializePricingModule() - - const priceSetMoneyAmountRules = await pricingService.listPriceSetMoneyAmountRules({ - id: [id] - }, { - relations: ["price_set_money_amount"], - skip, - take - }) - - // do something with the price set money amount rules or return them -} -``` - -You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrievePriceSetMoneyAmountRules (ids: string[], ruleTypeId: string[], skip: number, take: number) { - const pricingService = await initializePricingModule() - - const priceSetMoneyAmountRules = await pricingService.listPriceSetMoneyAmountRules({ - $and: [ - { - id: ids - }, - { - rule_type_id: ruleTypeId - } - ] - }, { - relations: ["price_set_money_amount"], - skip, - take - }) - - // do something with the price set money amount rules or return them -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listPriceSetMoneyAmountRules.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listPriceSetMoneyAmountRules.mdx new file mode 100644 index 0000000000..c7e70628b4 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listPriceSetMoneyAmountRules.mdx @@ -0,0 +1,115 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/listPriceSetMoneyAmountRules +sidebar_label: listPriceSetMoneyAmountRules +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# listPriceSetMoneyAmountRules - Pricing Module Reference + +This documentation provides a reference to the `listPriceSetMoneyAmountRules` method. This belongs to the Pricing Module. + +This method is used to retrieve a paginated list of price set money amount rules based on optional filters and configuration. + +## Example + +To retrieve a list of price set money amount rules using their IDs: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrievePriceSetMoneyAmountRules (id: string) { + const pricingService = await initializePricingModule() + + const priceSetMoneyAmountRules = await pricingService.listPriceSetMoneyAmountRules({ + id: [id] + }) + + // do something with the price set money amount rules or return them +} +``` + +To specify relations that should be retrieved within the price set money amount rules: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrievePriceSetMoneyAmountRules (id: string) { + const pricingService = await initializePricingModule() + + const priceSetMoneyAmountRules = await pricingService.listPriceSetMoneyAmountRules({ + id: [id] + }, { + relations: ["price_set_money_amount"] + }) + + // do something with the price set money amount rules or return them +} +``` + +By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrievePriceSetMoneyAmountRules (id: string, skip: number, take: number) { + const pricingService = await initializePricingModule() + + const priceSetMoneyAmountRules = await pricingService.listPriceSetMoneyAmountRules({ + id: [id] + }, { + relations: ["price_set_money_amount"], + skip, + take + }) + + // do something with the price set money amount rules or return them +} +``` + +You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrievePriceSetMoneyAmountRules (ids: string[], ruleTypeId: string[], skip: number, take: number) { + const pricingService = await initializePricingModule() + + const priceSetMoneyAmountRules = await pricingService.listPriceSetMoneyAmountRules({ + $and: [ + { + id: ids + }, + { + rule_type_id: ruleTypeId + } + ] + }, { + relations: ["price_set_money_amount"], + skip, + take + }) + + // do something with the price set money amount rules or return them +} +``` + +## Parameters + +)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterablePriceSetMoneyAmountRulesProps`](../../interfaces/FilterablePriceSetMoneyAmountRulesProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterablePriceSetMoneyAmountRulesProps`](../../interfaces/FilterablePriceSetMoneyAmountRulesProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`[]","description":"The ID to filter price set money amount rules by.","optional":true,"defaultValue":"","children":[]},{"name":"price_set_money_amount_id","type":"`string`[]","description":"The IDs to filter the price set money amount rule's associated price set money amount.","optional":true,"defaultValue":"","children":[]},{"name":"rule_type_id","type":"`string`[]","description":"The IDs to filter the price set money amount rule's associated rule type.","optional":true,"defaultValue":"","children":[]},{"name":"value","type":"`string`[]","description":"The value to filter price set money amount rules by.","optional":true,"defaultValue":"","children":[]}]},{"name":"config","type":"[`FindConfig`](../../interfaces/FindConfig.mdx)<[`PriceSetMoneyAmountRulesDTO`](../../interfaces/PriceSetMoneyAmountRulesDTO.mdx)\\>","description":"The configurations determining how the price set money amount rules are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price set money amount rule.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} /> + +## Returns + +","optional":false,"defaultValue":"","description":"The list of price set money amount rules.","children":[{"name":"PriceSetMoneyAmountRulesDTO[]","type":"[`PriceSetMoneyAmountRulesDTO`](../../interfaces/PriceSetMoneyAmountRulesDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"PriceSetMoneyAmountRulesDTO","type":"`object`","description":"A price set money amount rule's data.","optional":false,"defaultValue":"","children":[]}]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listRuleTypes.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listRuleTypes.md deleted file mode 100644 index 48d9ed323b..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listRuleTypes.md +++ /dev/null @@ -1,149 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/listRuleTypes -sidebar_label: listRuleTypes ---- - -# listRuleTypes - Pricing Module Reference - -This documentation provides a reference to the listRuleTypes method. This belongs to the Pricing Module. - -This method is used to retrieve a paginated list of rule types based on optional filters and configuration. - -## Parameters - -- `filters`: (optional) An object of type [FilterableRuleTypeProps](../../interfaces/FilterableRuleTypeProps.md) that is used to filter the retrieved rule types. It accepts the following properties: - - `$and`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "and" condition. - - `$or`: (optional) An array of filters to apply on the entity, where each item in the array is joined with an "or" condition. - - `id`: (optional) an array of strings, each being an ID to filter rule types. - - `name`: (optional) an array of strings, each being a name to filter rule types. - - `rule_attribute`: (optional) an array of strings, each being a rule attribute to filter rule types. -- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the rule types are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a rule type. It accepts the following properties: - - `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order. - - `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result. - - `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result. - - `skip`: (optional) A number indicating the number of records to skip before retrieving the results. - - `take`: (optional) A number indicating the number of records to return in the result. - - `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves to an array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md). - -
- -RuleTypeDTO - - -- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. -- `id`: A string indicating the ID of the rule type. -- `name`: A string indicating the display name of the rule type. -- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. - -
- -## Example - -To retrieve a list of rule types using their IDs: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrieveRuleTypes (ruleTypeId: string) { - const pricingService = await initializePricingModule() - - const ruleTypes = await pricingService.listRuleTypes({ - id: [ - ruleTypeId - ] - }) - - // do something with the rule types or return them -} -``` - -To specify attributes that should be retrieved within the rule types: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrieveRuleTypes (ruleTypeId: string) { - const pricingService = await initializePricingModule() - - const ruleTypes = await pricingService.listRuleTypes({ - id: [ - ruleTypeId - ] - }, { - select: ["name"] - }) - - // do something with the rule types or return them -} -``` - -By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrieveRuleTypes (ruleTypeId: string, skip: number, take: number) { - const pricingService = await initializePricingModule() - - const ruleTypes = await pricingService.listRuleTypes({ - id: [ - ruleTypeId - ] - }, { - select: ["name"], - skip, - take - }) - - // do something with the rule types or return them -} -``` - -You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrieveRuleTypes (ruleTypeId: string[], name: string[], skip: number, take: number) { - const pricingService = await initializePricingModule() - - const ruleTypes = await pricingService.listRuleTypes({ - $and: [ - { - id: ruleTypeId - }, - { - name - } - ] - }, { - select: ["name"], - skip, - take - }) - - // do something with the rule types or return them -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listRuleTypes.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listRuleTypes.mdx new file mode 100644 index 0000000000..4901ebde25 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listRuleTypes.mdx @@ -0,0 +1,121 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/listRuleTypes +sidebar_label: listRuleTypes +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# listRuleTypes - Pricing Module Reference + +This documentation provides a reference to the `listRuleTypes` method. This belongs to the Pricing Module. + +This method is used to retrieve a paginated list of rule types based on optional filters and configuration. + +## Example + +To retrieve a list of rule types using their IDs: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrieveRuleTypes (ruleTypeId: string) { + const pricingService = await initializePricingModule() + + const ruleTypes = await pricingService.listRuleTypes({ + id: [ + ruleTypeId + ] + }) + + // do something with the rule types or return them +} +``` + +To specify attributes that should be retrieved within the rule types: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrieveRuleTypes (ruleTypeId: string) { + const pricingService = await initializePricingModule() + + const ruleTypes = await pricingService.listRuleTypes({ + id: [ + ruleTypeId + ] + }, { + select: ["name"] + }) + + // do something with the rule types or return them +} +``` + +By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrieveRuleTypes (ruleTypeId: string, skip: number, take: number) { + const pricingService = await initializePricingModule() + + const ruleTypes = await pricingService.listRuleTypes({ + id: [ + ruleTypeId + ] + }, { + select: ["name"], + skip, + take + }) + + // do something with the rule types or return them +} +``` + +You can also use the `$and` or `$or` properties of the `filter` parameter to use and/or conditions in your filters. For example: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrieveRuleTypes (ruleTypeId: string[], name: string[], skip: number, take: number) { + const pricingService = await initializePricingModule() + + const ruleTypes = await pricingService.listRuleTypes({ + $and: [ + { + id: ruleTypeId + }, + { + name + } + ] + }, { + select: ["name"], + skip, + take + }) + + // do something with the rule types or return them +} +``` + +## Parameters + +)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterableRuleTypeProps`](../../interfaces/FilterableRuleTypeProps.mdx) \\| [`BaseFilterable`](../../interfaces/BaseFilterable.mdx)<[`FilterableRuleTypeProps`](../../interfaces/FilterableRuleTypeProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`[]","description":"The IDs to filter rule types by.","optional":true,"defaultValue":"","children":[]},{"name":"name","type":"`string`[]","description":"The names to filter rule types by.","optional":true,"defaultValue":"","children":[]},{"name":"rule_attribute","type":"`string`[]","description":"The rule attributes to filter rule types by.","optional":true,"defaultValue":"","children":[]}]},{"name":"config","type":"[`FindConfig`](../../interfaces/FindConfig.mdx)<[`RuleTypeDTO`](../../interfaces/RuleTypeDTO.mdx)\\>","description":"The configurations determining how the rule types are retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a rule type.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} /> + +## Returns + +","optional":false,"defaultValue":"","description":"The list of rule types.","children":[{"name":"RuleTypeDTO[]","type":"[`RuleTypeDTO`](../../interfaces/RuleTypeDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"RuleTypeDTO","type":"`object`","description":"A rule type's data.","optional":false,"defaultValue":"","children":[]}]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.removeRules.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.removeRules.md deleted file mode 100644 index 9b36dc81bc..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.removeRules.md +++ /dev/null @@ -1,49 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/removeRules -sidebar_label: removeRules ---- - -# removeRules - Pricing Module Reference - -This documentation provides a reference to the removeRules method. This belongs to the Pricing Module. - -This method remove rules from a price set. - -## Parameters - -- `data`: An array of objects of type [RemovePriceSetRulesDTO](../../interfaces/RemovePriceSetRulesDTO.md), each specfiying which rules to remove. Its items accept the following properties: - - `id`: A string indicating the ID of the price set. - - `rules`: An array of strings, each string is the `rule_attribute` of a rule you want to remove. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves when rules are successfully removed. - -## Example - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function removePriceSetRule (priceSetId: string, ruleAttributes: []) { - const pricingService = await initializePricingModule() - - await pricingService.removeRules([ - { - id: priceSetId, - rules: ruleAttributes - }, - ]) -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.removeRules.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.removeRules.mdx new file mode 100644 index 0000000000..38c49a5b00 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.removeRules.mdx @@ -0,0 +1,43 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/removeRules +sidebar_label: removeRules +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# removeRules - Pricing Module Reference + +This documentation provides a reference to the `removeRules` method. This belongs to the Pricing Module. + +This method remove rules from a price set. + +## Example + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function removePriceSetRule (priceSetId: string, ruleAttributes: []) { + const pricingService = await initializePricingModule() + + await pricingService.removeRules([ + { + id: priceSetId, + rules: ruleAttributes + }, + ]) +} +``` + +## Parameters + + + +## Returns + +","optional":false,"defaultValue":"","description":"Resolves when rules are successfully removed.","children":[]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieve.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieve.md deleted file mode 100644 index a29127550b..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieve.md +++ /dev/null @@ -1,101 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/retrieve -sidebar_label: retrieve ---- - -# retrieve - Pricing Module Reference - -This documentation provides a reference to the retrieve method. This belongs to the Pricing Module. - -This method is used to retrieves a price set by its ID. - -## Parameters - -- `id`: A string indicating the ID of the price set to retrieve. -- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the price set is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price set. It accepts the following properties: - - `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order. - - `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result. - - `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result. - - `skip`: (optional) A number indicating the number of records to skip before retrieving the results. - - `take`: (optional) A number indicating the number of records to return in the result. - - `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves to an object of type [PriceSetDTO](../../interfaces/PriceSetDTO.md) which is the retrieved price set. - -
- -PriceSetDTO - - -- `id`: A string indicating the ID of the price set. -- `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. Its items accept the following properties: - - `amount`: (optional) A number indicating the amount of this price. - - `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. It accepts the following properties: - - `code`: a string indicating the code of the currency. - - `name`: (optional) a string indicating the name of the currency. - - `symbol`: (optional) a string indicating the symbol of the currency. - - `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price. - - `currency_code`: (optional) A string that indicates the currency code of this price. - - `id`: A string that indicates the ID of the money amount. A money amount represents a price. - - `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied. - - `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied. -- `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. Its items accept the following properties: - - `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. - - `id`: A string indicating the ID of the rule type. - - `name`: A string indicating the display name of the rule type. - - `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. - -
- -## Example - -A simple example that retrieves a price set by its ID: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrievePriceSet (priceSetId: string) { - const pricingService = await initializePricingModule() - - const priceSet = await pricingService.retrieve( - priceSetId - ) - - // do something with the price set or return it -} -``` - -To specify relations that should be retrieved: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrievePriceSet (priceSetId: string) { - const pricingService = await initializePricingModule() - - const priceSet = await pricingService.retrieve( - priceSetId, - { - relations: ["money_amounts"] - } - ) - - // do something with the price set or return it -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieve.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieve.mdx new file mode 100644 index 0000000000..6618bf92af --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieve.mdx @@ -0,0 +1,65 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/retrieve +sidebar_label: retrieve +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# retrieve - Pricing Module Reference + +This documentation provides a reference to the `retrieve` method. This belongs to the Pricing Module. + +This method is used to retrieves a price set by its ID. + +## Example + +A simple example that retrieves a price set by its ID: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrievePriceSet (priceSetId: string) { + const pricingService = await initializePricingModule() + + const priceSet = await pricingService.retrieve( + priceSetId + ) + + // do something with the price set or return it +} +``` + +To specify relations that should be retrieved: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrievePriceSet (priceSetId: string) { + const pricingService = await initializePricingModule() + + const priceSet = await pricingService.retrieve( + priceSetId, + { + relations: ["money_amounts"] + } + ) + + // do something with the price set or return it +} +``` + +## Parameters + +","description":"The configurations determining how the price set is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price set.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} /> + +## Returns + +","optional":false,"defaultValue":"","description":"The retrieved price set.","children":[{"name":"PriceSetDTO","type":"`object`","description":"A price set's data.","optional":false,"defaultValue":"","children":[{"name":"id","type":"`string`","description":"The ID of the price set.","optional":false,"defaultValue":"","children":[]},{"name":"money_amounts","type":"[`MoneyAmountDTO`](../../interfaces/MoneyAmountDTO.mdx)[]","description":"The prices that belong to this price set.","optional":true,"defaultValue":"","children":[]},{"name":"rule_types","type":"[`RuleTypeDTO`](../../interfaces/RuleTypeDTO.mdx)[]","description":"The rule types applied on this price set.","optional":true,"defaultValue":"","children":[]}]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieveCurrency.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieveCurrency.md deleted file mode 100644 index 9266a505ff..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieveCurrency.md +++ /dev/null @@ -1,88 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/retrieveCurrency -sidebar_label: retrieveCurrency ---- - -# retrieveCurrency - Pricing Module Reference - -This documentation provides a reference to the retrieveCurrency method. This belongs to the Pricing Module. - -This method retrieves a currency by its code and and optionally based on the provided configurations. - -## Parameters - -- `code`: A string indicating the code of the currency to retrieve. -- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the currency is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a currency. It accepts the following properties: - - `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order. - - `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result. - - `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result. - - `skip`: (optional) A number indicating the number of records to skip before retrieving the results. - - `take`: (optional) A number indicating the number of records to return in the result. - - `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves to an object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md). - -
- -CurrencyDTO - - -- `code`: a string indicating the code of the currency. -- `name`: (optional) a string indicating the name of the currency. -- `symbol`: (optional) a string indicating the symbol of the currency. -- `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price. - -
- -## Example - -A simple example that retrieves a currency by its code: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrieveCurrency (code: string) { - const pricingService = await initializePricingModule() - - const currency = await pricingService.retrieveCurrency( - code - ) - - // do something with the currency or return it -} -``` - -To specify attributes that should be retrieved: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrieveCurrency (code: string) { - const pricingService = await initializePricingModule() - - const currency = await pricingService.retrieveCurrency( - code, - { - select: ["symbol_native"] - } - ) - - // do something with the currency or return it -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieveCurrency.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieveCurrency.mdx new file mode 100644 index 0000000000..c40b6e52e6 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieveCurrency.mdx @@ -0,0 +1,65 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/retrieveCurrency +sidebar_label: retrieveCurrency +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# retrieveCurrency - Pricing Module Reference + +This documentation provides a reference to the `retrieveCurrency` method. This belongs to the Pricing Module. + +This method retrieves a currency by its code and and optionally based on the provided configurations. + +## Example + +A simple example that retrieves a currency by its code: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrieveCurrency (code: string) { + const pricingService = await initializePricingModule() + + const currency = await pricingService.retrieveCurrency( + code + ) + + // do something with the currency or return it +} +``` + +To specify attributes that should be retrieved: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrieveCurrency (code: string) { + const pricingService = await initializePricingModule() + + const currency = await pricingService.retrieveCurrency( + code, + { + select: ["symbol_native"] + } + ) + + // do something with the currency or return it +} +``` + +## Parameters + +","description":"The configurations determining how the currency is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a currency.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} /> + +## Returns + +","optional":false,"defaultValue":"","description":"The retrieved currency.","children":[{"name":"CurrencyDTO","type":"`object`","description":"A currency's data.","optional":false,"defaultValue":"","children":[{"name":"code","type":"`string`","description":"The code of the currency.","optional":false,"defaultValue":"","children":[]},{"name":"name","type":"`string`","description":"The name of the currency.","optional":true,"defaultValue":"","children":[]},{"name":"symbol","type":"`string`","description":"The symbol of the currency.","optional":true,"defaultValue":"","children":[]},{"name":"symbol_native","type":"`string`","description":"The symbol of the currecy in its native form. This is typically the symbol used when displaying a price.","optional":true,"defaultValue":"","children":[]}]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieveMoneyAmount.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieveMoneyAmount.md deleted file mode 100644 index 11cb106aab..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieveMoneyAmount.md +++ /dev/null @@ -1,98 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/retrieveMoneyAmount -sidebar_label: retrieveMoneyAmount ---- - -# retrieveMoneyAmount - Pricing Module Reference - -This documentation provides a reference to the retrieveMoneyAmount method. This belongs to the Pricing Module. - -This method retrieves a money amount by its ID. - -## Parameters - -- `id`: The ID of the money amount to retrieve. -- `config`: (optional) An object of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md) used to configure how a money amount is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a money amount. It accepts the following properties: - - `amount`: (optional) A number indicating the amount of this price. - - `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. It accepts the following properties: - - `code`: a string indicating the code of the currency. - - `name`: (optional) a string indicating the name of the currency. - - `symbol`: (optional) a string indicating the symbol of the currency. - - `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price. - - `currency_code`: (optional) A string that indicates the currency code of this price. - - `id`: A string that indicates the ID of the money amount. A money amount represents a price. - - `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied. - - `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves to an object of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md) which is the retrieved money amount. - -
- -MoneyAmountDTO - - -- `amount`: (optional) A number indicating the amount of this price. -- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. It accepts the following properties: - - `code`: a string indicating the code of the currency. - - `name`: (optional) a string indicating the name of the currency. - - `symbol`: (optional) a string indicating the symbol of the currency. - - `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price. -- `currency_code`: (optional) A string that indicates the currency code of this price. -- `id`: A string that indicates the ID of the money amount. A money amount represents a price. -- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied. -- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied. - -
- -## Example - -To retrieve a money amount by its ID: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrieveMoneyAmount (moneyAmountId: string) { - const pricingService = await initializePricingModule() - - const moneyAmount = await pricingService.retrieveMoneyAmount( - moneyAmountId, - ) - - // do something with the money amount or return it -} -``` - -To retrieve relations along with the money amount: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrieveMoneyAmount (moneyAmountId: string) { - const pricingService = await initializePricingModule() - - const moneyAmount = await pricingService.retrieveMoneyAmount( - moneyAmountId, - { - relations: ["currency"] - } - ) - - // do something with the money amount or return it -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieveMoneyAmount.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieveMoneyAmount.mdx new file mode 100644 index 0000000000..c7b9ae38fe --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieveMoneyAmount.mdx @@ -0,0 +1,65 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/retrieveMoneyAmount +sidebar_label: retrieveMoneyAmount +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# retrieveMoneyAmount - Pricing Module Reference + +This documentation provides a reference to the `retrieveMoneyAmount` method. This belongs to the Pricing Module. + +This method retrieves a money amount by its ID. + +## Example + +To retrieve a money amount by its ID: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrieveMoneyAmount (moneyAmountId: string) { + const pricingService = await initializePricingModule() + + const moneyAmount = await pricingService.retrieveMoneyAmount( + moneyAmountId, + ) + + // do something with the money amount or return it +} +``` + +To retrieve relations along with the money amount: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrieveMoneyAmount (moneyAmountId: string) { + const pricingService = await initializePricingModule() + + const moneyAmount = await pricingService.retrieveMoneyAmount( + moneyAmountId, + { + relations: ["currency"] + } + ) + + // do something with the money amount or return it +} +``` + +## Parameters + +","description":"The configurations determining how a money amount is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a money amount.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} /> + +## Returns + +","optional":false,"defaultValue":"","description":"The retrieved money amount.","children":[{"name":"MoneyAmountDTO","type":"`object`","description":"A money amount's data. A money amount represents a price.","optional":false,"defaultValue":"","children":[{"name":"amount","type":"`number`","description":"The price of this money amount.","optional":true,"defaultValue":"","children":[]},{"name":"currency","type":"[`CurrencyDTO`](../../interfaces/CurrencyDTO.mdx)","description":"The money amount's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options.","optional":true,"defaultValue":"","children":[]},{"name":"currency_code","type":"`string`","description":"The currency code of this money amount.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`","description":"The ID of the money amount.","optional":false,"defaultValue":"","children":[]},{"name":"max_quantity","type":"`number`","description":"The maximum quantity required to be purchased for this price to be applied.","optional":true,"defaultValue":"","children":[]},{"name":"min_quantity","type":"`number`","description":"The minimum quantity required to be purchased for this price to be applied.","optional":true,"defaultValue":"","children":[]}]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrievePriceRule.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrievePriceRule.md deleted file mode 100644 index d57c2a4bd1..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrievePriceRule.md +++ /dev/null @@ -1,106 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/retrievePriceRule -sidebar_label: retrievePriceRule ---- - -# retrievePriceRule - Pricing Module Reference - -This documentation provides a reference to the retrievePriceRule method. This belongs to the Pricing Module. - -This method is used to retrieve a price rule by its ID. - -## Parameters - -- `id`: The ID of the price rule to retrieve. -- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the price rule is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price rule. It accepts the following properties: - - `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order. - - `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result. - - `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result. - - `skip`: (optional) A number indicating the number of records to skip before retrieving the results. - - `take`: (optional) A number indicating the number of records to return in the result. - - `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves to an object of type [PriceRuleDTO](../../interfaces/PriceRuleDTO.md). - -
- -PriceRuleDTO - - -- `id`: A string indicating the ID of the price rule. -- `is_dynamic`: A boolean indicating whether the price rule is dynamic. -- `price_list_id`: A string indicating the ID of the associated price list. -- `price_set`: An object of type [PriceSetDTO](../../interfaces/PriceSetDTO.md) that holds the data of the associated price set. It may only be available if the relation `price_set` is expanded. It accepts the following properties: - - `id`: A string indicating the ID of the price set. - - `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. Its items accept the following properties: - - `amount`: (optional) A number indicating the amount of this price. - - `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. - - `currency_code`: (optional) A string that indicates the currency code of this price. - - `id`: A string that indicates the ID of the money amount. A money amount represents a price. - - `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied. - - `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied. - - `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. Its items accept the following properties: - - `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. - - `id`: A string indicating the ID of the rule type. - - `name`: A string indicating the display name of the rule type. - - `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. -- `price_set_id`: A string indicating the ID of the associated price set. -- `price_set_money_amount_id`: A string indicating the ID of the associated price set money amount. -- `priority`: A number indicating the priority of the price rule in comparison to other applicable price rules. -- `rule_type`: An object of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md) that holds the data of the associated rule type. It may only be available if the relation `rule_type` is expanded. It accepts the following properties: - - `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. - - `id`: A string indicating the ID of the rule type. - - `name`: A string indicating the display name of the rule type. - - `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. -- `rule_type_id`: A string indicating the ID of the associated rule type. -- `value`: A string indicating the value of the price rule. - -
- -## Example - -A simple example that retrieves a price rule by its ID: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrievePriceRule (id: string) { - const pricingService = await initializePricingModule() - - const priceRule = await pricingService.retrievePriceRule(id) - - // do something with the price rule or return it -} -``` - -To specify relations that should be retrieved: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrievePriceRule (id: string) { - const pricingService = await initializePricingModule() - - const priceRule = await pricingService.retrievePriceRule(id, { - relations: ["price_set"] - }) - - // do something with the price rule or return it -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrievePriceRule.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrievePriceRule.mdx new file mode 100644 index 0000000000..35b803b053 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrievePriceRule.mdx @@ -0,0 +1,60 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/retrievePriceRule +sidebar_label: retrievePriceRule +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# retrievePriceRule - Pricing Module Reference + +This documentation provides a reference to the `retrievePriceRule` method. This belongs to the Pricing Module. + +This method is used to retrieve a price rule by its ID. + +## Example + +A simple example that retrieves a price rule by its ID: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrievePriceRule (id: string) { + const pricingService = await initializePricingModule() + + const priceRule = await pricingService.retrievePriceRule(id) + + // do something with the price rule or return it +} +``` + +To specify relations that should be retrieved: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrievePriceRule (id: string) { + const pricingService = await initializePricingModule() + + const priceRule = await pricingService.retrievePriceRule(id, { + relations: ["price_set"] + }) + + // do something with the price rule or return it +} +``` + +## Parameters + +","description":"The configurations determining how the price rule is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price rule.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} /> + +## Returns + +","optional":false,"defaultValue":"","description":"The retrieved price rule.","children":[{"name":"PriceRuleDTO","type":"`object`","description":"A price rule's data.","optional":false,"defaultValue":"","children":[{"name":"id","type":"`string`","description":"The ID of the price rule.","optional":false,"defaultValue":"","children":[]},{"name":"price_list_id","type":"`string`","description":"The ID of the associated price list.","optional":false,"defaultValue":"","children":[]},{"name":"price_set","type":"[`PriceSetDTO`](../../interfaces/PriceSetDTO.mdx)","description":"The associated price set. It may only be available if the relation `price_set` is expanded.","optional":false,"defaultValue":"","children":[]},{"name":"price_set_id","type":"`string`","description":"The ID of the associated price set.","optional":false,"defaultValue":"","children":[]},{"name":"price_set_money_amount_id","type":"`string`","description":"The ID of the associated price set money amount.","optional":false,"defaultValue":"","children":[]},{"name":"priority","type":"`number`","description":"The priority of the price rule in comparison to other applicable price rules.","optional":false,"defaultValue":"","children":[]},{"name":"rule_type","type":"[`RuleTypeDTO`](../../interfaces/RuleTypeDTO.mdx)","description":"The associated rule type. It may only be available if the relation `rule_type` is expanded.","optional":false,"defaultValue":"","children":[]},{"name":"rule_type_id","type":"`string`","description":"The ID of the associated rule type.","optional":false,"defaultValue":"","children":[]},{"name":"value","type":"`string`","description":"The value of the price rule.","optional":false,"defaultValue":"","children":[]}]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrievePriceSetMoneyAmountRules.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrievePriceSetMoneyAmountRules.md deleted file mode 100644 index ff4cdbdf81..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrievePriceSetMoneyAmountRules.md +++ /dev/null @@ -1,100 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/retrievePriceSetMoneyAmountRules -sidebar_label: retrievePriceSetMoneyAmountRules ---- - -# retrievePriceSetMoneyAmountRules - Pricing Module Reference - -This documentation provides a reference to the retrievePriceSetMoneyAmountRules method. This belongs to the Pricing Module. - -This method is used to a price set money amount rule by its ID based on the provided configuration. - -## Parameters - -- `id`: A string indicating the ID of the price set money amount rule to retrieve. -- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the price set money amount rule is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price set money amount rule. It accepts the following properties: - - `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order. - - `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result. - - `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result. - - `skip`: (optional) A number indicating the number of records to skip before retrieving the results. - - `take`: (optional) A number indicating the number of records to return in the result. - - `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves to an object of type [PriceSetMoneyAmountRulesDTO](../../interfaces/PriceSetMoneyAmountRulesDTO.md). - -
- -PriceSetMoneyAmountRulesDTO - - -- `id`: A string indicating the ID of the price set money amount. -- `price_set_money_amount`: an object of type [PriceSetMoneyAmountDTO](../../interfaces/PriceSetMoneyAmountDTO.md) holding the data of the associated price set money amount. It accepts the following properties: - - `id`: a string indicating the ID of a price set money amount. - - `money_amount`: (optional) an object of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md) holding the data of the associated money amount. It accepts the following properties: - - `amount`: (optional) A number indicating the amount of this price. - - `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. - - `currency_code`: (optional) A string that indicates the currency code of this price. - - `id`: A string that indicates the ID of the money amount. A money amount represents a price. - - `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied. - - `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied. - - `price_set`: (optional) an object of type [PriceSetDTO](../../interfaces/PriceSetDTO.md) holding the data of the associated price set. It accepts the following properties: - - `id`: A string indicating the ID of the price set. - - `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. - - `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. - - `title`: (optional) a string indicating the title of the price set money amount. -- `rule_type`: an object of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md) holding the data of the associated rule type. It accepts the following properties: - - `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. - - `id`: A string indicating the ID of the rule type. - - `name`: A string indicating the display name of the rule type. - - `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. -- `value`: a string indicating the value of the price set money amount rule. - -
- -## Example - -A simple example that retrieves a price set money amount rule by its ID: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrievePriceSetMoneyAmountRule (id: string) { - const pricingService = await initializePricingModule() - - const priceSetMoneyAmountRule = await pricingService.retrievePriceSetMoneyAmountRules(id) - - // do something with the price set money amount rule or return it -} -``` - -To specify relations that should be retrieved: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrievePriceSetMoneyAmountRule (id: string) { - const pricingService = await initializePricingModule() - - const priceSetMoneyAmountRule = await pricingService.retrievePriceSetMoneyAmountRules(id, { - relations: ["price_set_money_amount"] - }) - - // do something with the price set money amount rule or return it -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrievePriceSetMoneyAmountRules.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrievePriceSetMoneyAmountRules.mdx new file mode 100644 index 0000000000..1c0ed8ea11 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrievePriceSetMoneyAmountRules.mdx @@ -0,0 +1,60 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/retrievePriceSetMoneyAmountRules +sidebar_label: retrievePriceSetMoneyAmountRules +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# retrievePriceSetMoneyAmountRules - Pricing Module Reference + +This documentation provides a reference to the `retrievePriceSetMoneyAmountRules` method. This belongs to the Pricing Module. + +This method is used to a price set money amount rule by its ID based on the provided configuration. + +## Example + +A simple example that retrieves a price set money amount rule by its ID: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrievePriceSetMoneyAmountRule (id: string) { + const pricingService = await initializePricingModule() + + const priceSetMoneyAmountRule = await pricingService.retrievePriceSetMoneyAmountRules(id) + + // do something with the price set money amount rule or return it +} +``` + +To specify relations that should be retrieved: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrievePriceSetMoneyAmountRule (id: string) { + const pricingService = await initializePricingModule() + + const priceSetMoneyAmountRule = await pricingService.retrievePriceSetMoneyAmountRules(id, { + relations: ["price_set_money_amount"] + }) + + // do something with the price set money amount rule or return it +} +``` + +## Parameters + +","description":"The configurations determining how the price set money amount rule is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a price set money amount rule.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} /> + +## Returns + +","optional":false,"defaultValue":"","description":"The retrieved price set money amount rule.","children":[{"name":"PriceSetMoneyAmountRulesDTO","type":"`object`","description":"A price set money amount rule's data.","optional":false,"defaultValue":"","children":[{"name":"id","type":"`string`","description":"The ID of the price set money amount.","optional":false,"defaultValue":"","children":[]},{"name":"price_set_money_amount","type":"[`PriceSetMoneyAmountDTO`](../../interfaces/PriceSetMoneyAmountDTO.mdx)","description":"The associated price set money amount. It may only be available if the relation `price_set_money_amount` is expanded.","optional":false,"defaultValue":"","children":[]},{"name":"rule_type","type":"[`RuleTypeDTO`](../../interfaces/RuleTypeDTO.mdx)","description":"The associated rule type. It may only be available if the relation `rule_type` is expanded.","optional":false,"defaultValue":"","children":[]},{"name":"value","type":"`string`","description":"The value of the price set money amount rule.","optional":false,"defaultValue":"","children":[]}]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieveRuleType.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieveRuleType.md deleted file mode 100644 index 438817b5ec..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieveRuleType.md +++ /dev/null @@ -1,83 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/retrieveRuleType -sidebar_label: retrieveRuleType ---- - -# retrieveRuleType - Pricing Module Reference - -This documentation provides a reference to the retrieveRuleType method. This belongs to the Pricing Module. - -This method is used to retrieve a rule type by its ID and and optionally based on the provided configurations. - -## Parameters - -- `code`: -- `config`: (optional) An object of type [FindConfig](../../interfaces/FindConfig.md) used to configure how the rule type is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a rule type. It accepts the following properties: - - `order`: (optional) An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order. - - `relations`: (optional) An array of strings, each being relation names of the entity to retrieve in the result. - - `select`: (optional) An array of strings, each being attribute names of the entity to retrieve in the result. - - `skip`: (optional) A number indicating the number of records to skip before retrieving the results. - - `take`: (optional) A number indicating the number of records to return in the result. - - `withDeleted`: (optional) A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves to an object of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md). - -
- -RuleTypeDTO - - -- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. -- `id`: A string indicating the ID of the rule type. -- `name`: A string indicating the display name of the rule type. -- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. - -
- -## Example - -A simple example that retrieves a rule type by its code: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrieveRuleType (ruleTypeId: string) { - const pricingService = await initializePricingModule() - - const ruleType = await pricingService.retrieveRuleType(ruleTypeId) - - // do something with the rule type or return it -} -``` - -To specify attributes that should be retrieved: - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function retrieveRuleType (ruleTypeId: string) { - const pricingService = await initializePricingModule() - - const ruleType = await pricingService.retrieveRuleType(ruleTypeId, { - select: ["name"] - }) - - // do something with the rule type or return it -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieveRuleType.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieveRuleType.mdx new file mode 100644 index 0000000000..ce4d923a3c --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieveRuleType.mdx @@ -0,0 +1,60 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/retrieveRuleType +sidebar_label: retrieveRuleType +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# retrieveRuleType - Pricing Module Reference + +This documentation provides a reference to the `retrieveRuleType` method. This belongs to the Pricing Module. + +This method is used to retrieve a rule type by its ID and and optionally based on the provided configurations. + +## Example + +A simple example that retrieves a rule type by its code: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrieveRuleType (ruleTypeId: string) { + const pricingService = await initializePricingModule() + + const ruleType = await pricingService.retrieveRuleType(ruleTypeId) + + // do something with the rule type or return it +} +``` + +To specify attributes that should be retrieved: + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function retrieveRuleType (ruleTypeId: string) { + const pricingService = await initializePricingModule() + + const ruleType = await pricingService.retrieveRuleType(ruleTypeId, { + select: ["name"] + }) + + // do something with the rule type or return it +} +``` + +## Parameters + +","description":"The configurations determining how the rule type is retrieved. Its properties, such as `select` or `relations`, accept the attributes or relations associated with a rule type.","optional":true,"defaultValue":"","children":[{"name":"order","type":"`object`","description":"An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order.","optional":true,"defaultValue":"","children":[]},{"name":"relations","type":"`string`[]","description":"An array of strings, each being relation names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"select","type":"(`string` \\| keyof `Entity`)[]","description":"An array of strings, each being attribute names of the entity to retrieve in the result.","optional":true,"defaultValue":"","children":[]},{"name":"skip","type":"`number`","description":"A number indicating the number of records to skip before retrieving the results.","optional":true,"defaultValue":"","children":[]},{"name":"take","type":"`number`","description":"A number indicating the number of records to return in the result.","optional":true,"defaultValue":"","children":[]},{"name":"withDeleted","type":"`boolean`","description":"A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the `SoftDeletableEntity` class.","optional":true,"defaultValue":"","children":[]}]},{"name":"sharedContext","type":"[`Context`](../../interfaces/Context.mdx)","description":"A context used to share resources, such as transaction manager, between the application and the module.","optional":true,"defaultValue":"","children":[{"name":"enableNestedTransactions","type":"`boolean`","description":"a boolean value indicating whether nested transactions are enabled.","optional":true,"defaultValue":"","children":[]},{"name":"isolationLevel","type":"`string`","description":"A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.","optional":true,"defaultValue":"","children":[]},{"name":"manager","type":"`TManager`","description":"An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.","optional":true,"defaultValue":"","children":[]},{"name":"transactionId","type":"`string`","description":"a string indicating the ID of the current transaction.","optional":true,"defaultValue":"","children":[]},{"name":"transactionManager","type":"`TManager`","description":"An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.","optional":true,"defaultValue":"","children":[]}]}]} /> + +## Returns + +","optional":false,"defaultValue":"","description":"The retrieved rule type.","children":[{"name":"RuleTypeDTO","type":"`object`","description":"A rule type's data.","optional":false,"defaultValue":"","children":[{"name":"default_priority","type":"`number`","description":"The priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type.","optional":false,"defaultValue":"","children":[]},{"name":"id","type":"`string`","description":"The ID of the rule type.","optional":false,"defaultValue":"","children":[]},{"name":"name","type":"`string`","description":"The display name of the rule type.","optional":false,"defaultValue":"","children":[]},{"name":"rule_attribute","type":"`string`","description":"The unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price.","optional":false,"defaultValue":"","children":[]}]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updateCurrencies.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updateCurrencies.md deleted file mode 100644 index 0192522f04..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updateCurrencies.md +++ /dev/null @@ -1,65 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/updateCurrencies -sidebar_label: updateCurrencies ---- - -# updateCurrencies - Pricing Module Reference - -This documentation provides a reference to the updateCurrencies method. This belongs to the Pricing Module. - -This method is used to update existing currencies with the provided data. In each currency object, the currency code must be provided to identify which currency to update. - -## Parameters - -- `data`: An array of objects of type [UpdateCurrencyDTO](../../interfaces/UpdateCurrencyDTO.md), each object containing data to be updated in a currency. Its items accept the following properties: - - `code`: a string indicating the code of the currency to update. - - `name`: (optional) a string indicating the name of the currency. - - `symbol`: (optional) a string indicating the symbol of the currency. - - `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves to an array of objects of type [CurrencyDTO](../../interfaces/CurrencyDTO.md), each object being an updated currency. - -
- -CurrencyDTO - - -- `code`: a string indicating the code of the currency. -- `name`: (optional) a string indicating the name of the currency. -- `symbol`: (optional) a string indicating the symbol of the currency. -- `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price. - -
- -## Example - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function updateCurrencies () { - const pricingService = await initializePricingModule() - - const currencies = await pricingService.updateCurrencies([ - { - code: "USD", - symbol: "$", - } - ]) - - // do something with the currencies or return them -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updateCurrencies.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updateCurrencies.mdx new file mode 100644 index 0000000000..f755a9d95b --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updateCurrencies.mdx @@ -0,0 +1,45 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/updateCurrencies +sidebar_label: updateCurrencies +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# updateCurrencies - Pricing Module Reference + +This documentation provides a reference to the `updateCurrencies` method. This belongs to the Pricing Module. + +This method is used to update existing currencies with the provided data. In each currency object, the currency code must be provided to identify which currency to update. + +## Example + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function updateCurrencies () { + const pricingService = await initializePricingModule() + + const currencies = await pricingService.updateCurrencies([ + { + code: "USD", + symbol: "$", + } + ]) + + // do something with the currencies or return them +} +``` + +## Parameters + + + +## Returns + +","optional":false,"defaultValue":"","description":"The list of updated currencies.","children":[{"name":"CurrencyDTO[]","type":"[`CurrencyDTO`](../../interfaces/CurrencyDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"CurrencyDTO","type":"`object`","description":"A currency's data.","optional":false,"defaultValue":"","children":[]}]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updateMoneyAmounts.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updateMoneyAmounts.md deleted file mode 100644 index 3058cefdad..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updateMoneyAmounts.md +++ /dev/null @@ -1,72 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/updateMoneyAmounts -sidebar_label: updateMoneyAmounts ---- - -# updateMoneyAmounts - Pricing Module Reference - -This documentation provides a reference to the updateMoneyAmounts method. This belongs to the Pricing Module. - -This method updates existing money amounts. - -## Parameters - -- `data`: An array of objects of type [UpdateMoneyAmountDTO](../../interfaces/UpdateMoneyAmountDTO.md), each holding data to update in a money amount. Its items accept the following properties: - - `amount`: (optional) A number indicating the amount of this money amount. - - `currency_code`: (optional) A string that indicates the currency code of the money amount. - - `id`: A string that indicates the ID of the money amount to update. - - `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this money amount to be applied. - - `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this money amount to be applied. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves to an array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), each being a updated money amount. - -
- -MoneyAmountDTO - - -- `amount`: (optional) A number indicating the amount of this price. -- `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. It accepts the following properties: - - `code`: a string indicating the code of the currency. - - `name`: (optional) a string indicating the name of the currency. - - `symbol`: (optional) a string indicating the symbol of the currency. - - `symbol_native`: (optional) a string indicating the symbol of the currecy in its native form. This is typically the symbol used when displaying a price. -- `currency_code`: (optional) A string that indicates the currency code of this price. -- `id`: A string that indicates the ID of the money amount. A money amount represents a price. -- `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied. -- `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied. - -
- -## Example - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function updateMoneyAmounts (moneyAmountId: string, amount: number) { - const pricingService = await initializePricingModule() - - const moneyAmounts = await pricingService.updateMoneyAmounts([ - { - id: moneyAmountId, - amount - } - ]) - - // do something with the money amounts or return them -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updateMoneyAmounts.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updateMoneyAmounts.mdx new file mode 100644 index 0000000000..ebbe6d1655 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updateMoneyAmounts.mdx @@ -0,0 +1,45 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/updateMoneyAmounts +sidebar_label: updateMoneyAmounts +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# updateMoneyAmounts - Pricing Module Reference + +This documentation provides a reference to the `updateMoneyAmounts` method. This belongs to the Pricing Module. + +This method updates existing money amounts. + +## Example + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function updateMoneyAmounts (moneyAmountId: string, amount: number) { + const pricingService = await initializePricingModule() + + const moneyAmounts = await pricingService.updateMoneyAmounts([ + { + id: moneyAmountId, + amount + } + ]) + + // do something with the money amounts or return them +} +``` + +## Parameters + + + +## Returns + +","optional":false,"defaultValue":"","description":"The list of updated money amounts.","children":[{"name":"MoneyAmountDTO[]","type":"[`MoneyAmountDTO`](../../interfaces/MoneyAmountDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"MoneyAmountDTO","type":"`object`","description":"A money amount's data. A money amount represents a price.","optional":false,"defaultValue":"","children":[]}]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updatePriceRules.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updatePriceRules.md deleted file mode 100644 index 46c9ba0650..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updatePriceRules.md +++ /dev/null @@ -1,94 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/updatePriceRules -sidebar_label: updatePriceRules ---- - -# updatePriceRules - Pricing Module Reference - -This documentation provides a reference to the updatePriceRules method. This belongs to the Pricing Module. - -This method is used to update price rules, each with their provided data. - -## Parameters - -- `data`: An array of objects of type [UpdatePriceRuleDTO](../../interfaces/UpdatePriceRuleDTO.md), each containing the data to update in a price rule. Its items accept the following properties: - - `id`: A string indicating the ID of the price rule to update. - - `price_list_id`: (optional) A string indicating the ID of the associated price list. - - `price_set_id`: (optional) A string indicating the ID of the associated price set. - - `price_set_money_amount_id`: (optional) A string indicating the ID of the associated price set money amount. - - `priority`: (optional) A number indicating the priority of the price rule in comparison to other applicable price rules. - - `rule_type_id`: (optional) A string indicating the ID of the associated rule type. - - `value`: (optional) A string indicating the value of the price rule. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves to an array of objects of type [PriceRuleDTO](../../interfaces/PriceRuleDTO.md), each being an updated price rule. - -
- -PriceRuleDTO - - -- `id`: A string indicating the ID of the price rule. -- `is_dynamic`: A boolean indicating whether the price rule is dynamic. -- `price_list_id`: A string indicating the ID of the associated price list. -- `price_set`: An object of type [PriceSetDTO](../../interfaces/PriceSetDTO.md) that holds the data of the associated price set. It may only be available if the relation `price_set` is expanded. It accepts the following properties: - - `id`: A string indicating the ID of the price set. - - `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. Its items accept the following properties: - - `amount`: (optional) A number indicating the amount of this price. - - `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. - - `currency_code`: (optional) A string that indicates the currency code of this price. - - `id`: A string that indicates the ID of the money amount. A money amount represents a price. - - `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied. - - `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied. - - `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. Its items accept the following properties: - - `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. - - `id`: A string indicating the ID of the rule type. - - `name`: A string indicating the display name of the rule type. - - `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. -- `price_set_id`: A string indicating the ID of the associated price set. -- `price_set_money_amount_id`: A string indicating the ID of the associated price set money amount. -- `priority`: A number indicating the priority of the price rule in comparison to other applicable price rules. -- `rule_type`: An object of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md) that holds the data of the associated rule type. It may only be available if the relation `rule_type` is expanded. It accepts the following properties: - - `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. - - `id`: A string indicating the ID of the rule type. - - `name`: A string indicating the display name of the rule type. - - `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. -- `rule_type_id`: A string indicating the ID of the associated rule type. -- `value`: A string indicating the value of the price rule. - -
- -## Example - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function updatePriceRules ( - id: string, - priceSetId: string, -) { - const pricingService = await initializePricingModule() - - const priceRules = await pricingService.updatePriceRules([ - { - id, - price_set_id: priceSetId, - } - ]) - - // do something with the price rules or return them -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updatePriceRules.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updatePriceRules.mdx new file mode 100644 index 0000000000..b0b25da300 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updatePriceRules.mdx @@ -0,0 +1,48 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/updatePriceRules +sidebar_label: updatePriceRules +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# updatePriceRules - Pricing Module Reference + +This documentation provides a reference to the `updatePriceRules` method. This belongs to the Pricing Module. + +This method is used to update price rules, each with their provided data. + +## Example + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function updatePriceRules ( + id: string, + priceSetId: string, +) { + const pricingService = await initializePricingModule() + + const priceRules = await pricingService.updatePriceRules([ + { + id, + price_set_id: priceSetId, + } + ]) + + // do something with the price rules or return them +} +``` + +## Parameters + + + +## Returns + +","optional":false,"defaultValue":"","description":"The list of updated price rules.","children":[{"name":"PriceRuleDTO[]","type":"[`PriceRuleDTO`](../../interfaces/PriceRuleDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"PriceRuleDTO","type":"`object`","description":"A price rule's data.","optional":false,"defaultValue":"","children":[]}]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updatePriceSetMoneyAmountRules.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updatePriceSetMoneyAmountRules.md deleted file mode 100644 index 0ba27a38b2..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updatePriceSetMoneyAmountRules.md +++ /dev/null @@ -1,83 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/updatePriceSetMoneyAmountRules -sidebar_label: updatePriceSetMoneyAmountRules ---- - -# updatePriceSetMoneyAmountRules - Pricing Module Reference - -This documentation provides a reference to the updatePriceSetMoneyAmountRules method. This belongs to the Pricing Module. - -This method is used to update price set money amount rules, each with their provided data. - -## Parameters - -- `data`: An array of objects of type [UpdatePriceSetMoneyAmountRulesDTO](../../interfaces/UpdatePriceSetMoneyAmountRulesDTO.md), each containing the data to update in a price set money amount rule. Its items accept the following properties: - - `id`: A string indicating the ID of the price set money amount rule to update. - - `price_set_money_amount`: (optional) A string indicating the ID of a price set money amount. - - `rule_type`: (optional) A string indicating the ID of a rule type. - - `value`: (optional) A string indicating the value of the price set money amount rule. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves to an array of objects of type [PriceSetMoneyAmountRulesDTO](../../interfaces/PriceSetMoneyAmountRulesDTO.md), each being the -updated price set money amount rule. - -
- -PriceSetMoneyAmountRulesDTO - - -- `id`: A string indicating the ID of the price set money amount. -- `price_set_money_amount`: an object of type [PriceSetMoneyAmountDTO](../../interfaces/PriceSetMoneyAmountDTO.md) holding the data of the associated price set money amount. It accepts the following properties: - - `id`: a string indicating the ID of a price set money amount. - - `money_amount`: (optional) an object of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md) holding the data of the associated money amount. It accepts the following properties: - - `amount`: (optional) A number indicating the amount of this price. - - `currency`: (optional) An object of type [CurrencyDTO](../../interfaces/CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. - - `currency_code`: (optional) A string that indicates the currency code of this price. - - `id`: A string that indicates the ID of the money amount. A money amount represents a price. - - `max_quantity`: (optional) A number that indicates the maximum quantity required to be purchased for this price to be applied. - - `min_quantity`: (optional) A number that indicates the minimum quantity required to be purchased for this price to be applied. - - `price_set`: (optional) an object of type [PriceSetDTO](../../interfaces/PriceSetDTO.md) holding the data of the associated price set. It accepts the following properties: - - `id`: A string indicating the ID of the price set. - - `money_amounts`: (optional) An array of objects of type [MoneyAmountDTO](../../interfaces/MoneyAmountDTO.md), which holds the prices that belong to this price set. - - `rule_types`: (optional) An array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), which holds the rule types applied on this price set. - - `title`: (optional) a string indicating the title of the price set money amount. -- `rule_type`: an object of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md) holding the data of the associated rule type. It accepts the following properties: - - `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. - - `id`: A string indicating the ID of the rule type. - - `name`: A string indicating the display name of the rule type. - - `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. -- `value`: a string indicating the value of the price set money amount rule. - -
- -## Example - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function updatePriceSetMoneyAmountRules (id: string, value: string) { - const pricingService = await initializePricingModule() - - const priceSetMoneyAmountRules = await pricingService.updatePriceSetMoneyAmountRules([ - { - id, - value - } - ]) - - // do something with the price set money amount rules or return them -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updatePriceSetMoneyAmountRules.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updatePriceSetMoneyAmountRules.mdx new file mode 100644 index 0000000000..68f778959e --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updatePriceSetMoneyAmountRules.mdx @@ -0,0 +1,45 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/updatePriceSetMoneyAmountRules +sidebar_label: updatePriceSetMoneyAmountRules +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# updatePriceSetMoneyAmountRules - Pricing Module Reference + +This documentation provides a reference to the `updatePriceSetMoneyAmountRules` method. This belongs to the Pricing Module. + +This method is used to update price set money amount rules, each with their provided data. + +## Example + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function updatePriceSetMoneyAmountRules (id: string, value: string) { + const pricingService = await initializePricingModule() + + const priceSetMoneyAmountRules = await pricingService.updatePriceSetMoneyAmountRules([ + { + id, + value + } + ]) + + // do something with the price set money amount rules or return them +} +``` + +## Parameters + + + +## Returns + +","optional":false,"defaultValue":"","description":"The list of updated price set money amount rules.","children":[{"name":"PriceSetMoneyAmountRulesDTO[]","type":"[`PriceSetMoneyAmountRulesDTO`](../../interfaces/PriceSetMoneyAmountRulesDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"PriceSetMoneyAmountRulesDTO","type":"`object`","description":"A price set money amount rule's data.","optional":false,"defaultValue":"","children":[]}]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updateRuleTypes.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updateRuleTypes.md deleted file mode 100644 index 7571c1003a..0000000000 --- a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updateRuleTypes.md +++ /dev/null @@ -1,65 +0,0 @@ ---- -displayed_sidebar: pricingReference -badge: - variant: orange - text: Beta -slug: /references/pricing/updateRuleTypes -sidebar_label: updateRuleTypes ---- - -# updateRuleTypes - Pricing Module Reference - -This documentation provides a reference to the updateRuleTypes method. This belongs to the Pricing Module. - -This method is used to update existing rule types with the provided data. - -## Parameters - -- `data`: An array of objects of type [UpdateRuleTypeDTO](../../interfaces/UpdateRuleTypeDTO.md), each object containing data to be updated in a rule type. Its items accept the following properties: - - `default_priority`: (optional) A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. - - `id`: A string indicating the ID of the rule type to update. - - `name`: (optional) A string indicating the display name of the rule type. - - `rule_attribute`: (optional) A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. -- `sharedContext`: (optional) An object of type [Context](../../interfaces/Context.md) used to share resources, such as transaction manager, between the application and the module. It accepts the following properties: - - `enableNestedTransactions`: (optional) a boolean value indicating whether nested transactions are enabled. - - `isolationLevel`: (optional) A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - - `manager`: (optional) An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - - `transactionId`: (optional) a string indicating the ID of the current transaction. - - `transactionManager`: (optional) An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -## Returns - -A promise that resolves to an array of objects of type [RuleTypeDTO](../../interfaces/RuleTypeDTO.md), each being an updated rule type. - -
- -RuleTypeDTO - - -- `default_priority`: A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. -- `id`: A string indicating the ID of the rule type. -- `name`: A string indicating the display name of the rule type. -- `rule_attribute`: A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. - -
- -## Example - -```ts -import { - initialize as initializePricingModule, -} from "@medusajs/pricing" - -async function updateRuleTypes (ruleTypeId: string) { - const pricingService = await initializePricingModule() - - const ruleTypes = await pricingService.updateRuleTypes([ - { - id: ruleTypeId, - name: "Region", - } - ]) - - // do something with the rule types or return them -} -``` diff --git a/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updateRuleTypes.mdx b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updateRuleTypes.mdx new file mode 100644 index 0000000000..f785fca1a4 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updateRuleTypes.mdx @@ -0,0 +1,45 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing/updateRuleTypes +sidebar_label: updateRuleTypes +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# updateRuleTypes - Pricing Module Reference + +This documentation provides a reference to the `updateRuleTypes` method. This belongs to the Pricing Module. + +This method is used to update existing rule types with the provided data. + +## Example + +```ts +import { + initialize as initializePricingModule, +} from "@medusajs/pricing" + +async function updateRuleTypes (ruleTypeId: string) { + const pricingService = await initializePricingModule() + + const ruleTypes = await pricingService.updateRuleTypes([ + { + id: ruleTypeId, + name: "Region", + } + ]) + + // do something with the rule types or return them +} +``` + +## Parameters + + + +## Returns + +","optional":false,"defaultValue":"","description":"The list of updated rule types.","children":[{"name":"RuleTypeDTO[]","type":"[`RuleTypeDTO`](../../interfaces/RuleTypeDTO.mdx)[]","optional":false,"defaultValue":"","description":"","children":[{"name":"RuleTypeDTO","type":"`object`","description":"A rule type's data.","optional":false,"defaultValue":"","children":[]}]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/index.md b/www/apps/docs/content/references/pricing/index.md index ddc9aa68b6..05dc1ea26f 100644 --- a/www/apps/docs/content/references/pricing/index.md +++ b/www/apps/docs/content/references/pricing/index.md @@ -2,55 +2,57 @@ displayed_sidebar: pricingReference --- +import ParameterTypes from "@site/src/components/ParameterTypes" + # Pricing Module Reference Reference ## Interfaces -- [AddPricesDTO](interfaces/AddPricesDTO.md) -- [AddRulesDTO](interfaces/AddRulesDTO.md) -- [BaseFilterable](interfaces/BaseFilterable.md) -- [CalculatedPriceSetDTO](interfaces/CalculatedPriceSetDTO.md) -- [Context](interfaces/Context.md) -- [CreateCurrencyDTO](interfaces/CreateCurrencyDTO.md) -- [CreateMoneyAmountDTO](interfaces/CreateMoneyAmountDTO.md) -- [CreatePriceRuleDTO](interfaces/CreatePriceRuleDTO.md) -- [CreatePriceSetDTO](interfaces/CreatePriceSetDTO.md) -- [CreatePriceSetMoneyAmountRulesDTO](interfaces/CreatePriceSetMoneyAmountRulesDTO.md) -- [CreatePricesDTO](interfaces/CreatePricesDTO.md) -- [CreateRuleTypeDTO](interfaces/CreateRuleTypeDTO.md) -- [CurrencyDTO](interfaces/CurrencyDTO.md) -- [FilterableCurrencyProps](interfaces/FilterableCurrencyProps.md) -- [FilterableMoneyAmountProps](interfaces/FilterableMoneyAmountProps.md) -- [FilterablePriceRuleProps](interfaces/FilterablePriceRuleProps.md) -- [FilterablePriceSetMoneyAmountRulesProps](interfaces/FilterablePriceSetMoneyAmountRulesProps.md) -- [FilterablePriceSetProps](interfaces/FilterablePriceSetProps.md) -- [FilterableRuleTypeProps](interfaces/FilterableRuleTypeProps.md) -- [FindConfig](interfaces/FindConfig.md) -- [IPricingModuleService](interfaces/IPricingModuleService.md) -- [JoinerServiceConfig](interfaces/JoinerServiceConfig.md) -- [JoinerServiceConfigAlias](interfaces/JoinerServiceConfigAlias.md) -- [MoneyAmountDTO](interfaces/MoneyAmountDTO.md) -- [PriceRuleDTO](interfaces/PriceRuleDTO.md) -- [PriceSetDTO](interfaces/PriceSetDTO.md) -- [PriceSetMoneyAmountDTO](interfaces/PriceSetMoneyAmountDTO.md) -- [PriceSetMoneyAmountRulesDTO](interfaces/PriceSetMoneyAmountRulesDTO.md) -- [PricingContext](interfaces/PricingContext.md) -- [PricingFilters](interfaces/PricingFilters.md) -- [RemovePriceSetRulesDTO](interfaces/RemovePriceSetRulesDTO.md) -- [RuleTypeDTO](interfaces/RuleTypeDTO.md) -- [UpdateCurrencyDTO](interfaces/UpdateCurrencyDTO.md) -- [UpdateMoneyAmountDTO](interfaces/UpdateMoneyAmountDTO.md) -- [UpdatePriceRuleDTO](interfaces/UpdatePriceRuleDTO.md) -- [UpdatePriceSetDTO](interfaces/UpdatePriceSetDTO.md) -- [UpdatePriceSetMoneyAmountRulesDTO](interfaces/UpdatePriceSetMoneyAmountRulesDTO.md) -- [UpdateRuleTypeDTO](interfaces/UpdateRuleTypeDTO.md) +- [AddPricesDTO](interfaces/AddPricesDTO.mdx) +- [AddRulesDTO](interfaces/AddRulesDTO.mdx) +- [BaseFilterable](interfaces/BaseFilterable.mdx) +- [CalculatedPriceSetDTO](interfaces/CalculatedPriceSetDTO.mdx) +- [Context](interfaces/Context.mdx) +- [CreateCurrencyDTO](interfaces/CreateCurrencyDTO.mdx) +- [CreateMoneyAmountDTO](interfaces/CreateMoneyAmountDTO.mdx) +- [CreatePriceRuleDTO](interfaces/CreatePriceRuleDTO.mdx) +- [CreatePriceSetDTO](interfaces/CreatePriceSetDTO.mdx) +- [CreatePriceSetMoneyAmountRulesDTO](interfaces/CreatePriceSetMoneyAmountRulesDTO.mdx) +- [CreatePricesDTO](interfaces/CreatePricesDTO.mdx) +- [CreateRuleTypeDTO](interfaces/CreateRuleTypeDTO.mdx) +- [CurrencyDTO](interfaces/CurrencyDTO.mdx) +- [FilterableCurrencyProps](interfaces/FilterableCurrencyProps.mdx) +- [FilterableMoneyAmountProps](interfaces/FilterableMoneyAmountProps.mdx) +- [FilterablePriceRuleProps](interfaces/FilterablePriceRuleProps.mdx) +- [FilterablePriceSetMoneyAmountRulesProps](interfaces/FilterablePriceSetMoneyAmountRulesProps.mdx) +- [FilterablePriceSetProps](interfaces/FilterablePriceSetProps.mdx) +- [FilterableRuleTypeProps](interfaces/FilterableRuleTypeProps.mdx) +- [FindConfig](interfaces/FindConfig.mdx) +- [IPricingModuleService](interfaces/IPricingModuleService.mdx) +- [JoinerServiceConfig](interfaces/JoinerServiceConfig.mdx) +- [JoinerServiceConfigAlias](interfaces/JoinerServiceConfigAlias.mdx) +- [MoneyAmountDTO](interfaces/MoneyAmountDTO.mdx) +- [PriceRuleDTO](interfaces/PriceRuleDTO.mdx) +- [PriceSetDTO](interfaces/PriceSetDTO.mdx) +- [PriceSetMoneyAmountDTO](interfaces/PriceSetMoneyAmountDTO.mdx) +- [PriceSetMoneyAmountRulesDTO](interfaces/PriceSetMoneyAmountRulesDTO.mdx) +- [PricingContext](interfaces/PricingContext.mdx) +- [PricingFilters](interfaces/PricingFilters.mdx) +- [RemovePriceSetRulesDTO](interfaces/RemovePriceSetRulesDTO.mdx) +- [RuleTypeDTO](interfaces/RuleTypeDTO.mdx) +- [UpdateCurrencyDTO](interfaces/UpdateCurrencyDTO.mdx) +- [UpdateMoneyAmountDTO](interfaces/UpdateMoneyAmountDTO.mdx) +- [UpdatePriceRuleDTO](interfaces/UpdatePriceRuleDTO.mdx) +- [UpdatePriceSetDTO](interfaces/UpdatePriceSetDTO.mdx) +- [UpdatePriceSetMoneyAmountRulesDTO](interfaces/UpdatePriceSetMoneyAmountRulesDTO.mdx) +- [UpdateRuleTypeDTO](interfaces/UpdateRuleTypeDTO.mdx) ## Type Aliases -- [Exclude](types/Exclude.md) -- [JoinerRelationship](types/JoinerRelationship.md) -- [ModuleJoinerConfig](types/ModuleJoinerConfig.md) -- [ModuleJoinerRelationship](types/ModuleJoinerRelationship.md) -- [Omit](types/Omit.md) -- [Pick](types/Pick.md) -- [Record](types/Record.md) +- [Exclude](types/Exclude.mdx) +- [JoinerRelationship](types/JoinerRelationship.mdx) +- [ModuleJoinerConfig](types/ModuleJoinerConfig.mdx) +- [ModuleJoinerRelationship](types/ModuleJoinerRelationship.mdx) +- [Omit](types/Omit.mdx) +- [Pick](types/Pick.mdx) +- [Record](types/Record.mdx) diff --git a/www/apps/docs/content/references/pricing/interfaces/AddPricesDTO.md b/www/apps/docs/content/references/pricing/interfaces/AddPricesDTO.md deleted file mode 100644 index d8436a5d3b..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/AddPricesDTO.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# AddPricesDTO - -An object used to specify prices to add to a price set. - -## Properties - -### priceSetId - - **priceSetId**: `string` - -A string indicating the ID of the price set to add prices to. - -#### Defined in - -[packages/types/src/pricing/common/price-set.ts:105](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L105) - -___ - -### prices - - **prices**: [`CreatePricesDTO`](CreatePricesDTO.md)[] - -An array of objects of type [CreatePricesDTO](CreatePricesDTO.md), each being a price to add to the price set. - -#### Defined in - -[packages/types/src/pricing/common/price-set.ts:106](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L106) diff --git a/www/apps/docs/content/references/pricing/interfaces/AddPricesDTO.mdx b/www/apps/docs/content/references/pricing/interfaces/AddPricesDTO.mdx new file mode 100644 index 0000000000..c68b155d4c --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/AddPricesDTO.mdx @@ -0,0 +1,13 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# AddPricesDTO + +The prices to add to a price set. + +## Properties + +","description":"The rules to add to the price. The object's keys are rule types' `rule_attribute` attribute, and values are the value of that rule associated with this price.","optional":false,"defaultValue":"","children":[]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/interfaces/AddRulesDTO.md b/www/apps/docs/content/references/pricing/interfaces/AddRulesDTO.md deleted file mode 100644 index ed0e99fb3b..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/AddRulesDTO.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# AddRulesDTO - -An object used to specify the rules to add to a price set. - -## Properties - -### priceSetId - - **priceSetId**: `string` - -A string indicating the ID of the price set to add the rules to. - -#### Defined in - -[packages/types/src/pricing/common/price-set.ts:81](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L81) - -___ - -### rules - - **rules**: { `attribute`: `string` }[] - -An array of objects, each object holds a property `attribute`, with its value being the `rule_attribute` of the rule to add to the price set. - -#### Defined in - -[packages/types/src/pricing/common/price-set.ts:82](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L82) diff --git a/www/apps/docs/content/references/pricing/interfaces/AddRulesDTO.mdx b/www/apps/docs/content/references/pricing/interfaces/AddRulesDTO.mdx new file mode 100644 index 0000000000..2e7f23b266 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/AddRulesDTO.mdx @@ -0,0 +1,13 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# AddRulesDTO + +The rules to add to a price set. + +## Properties + + diff --git a/www/apps/docs/content/references/pricing/interfaces/BaseFilterable.md b/www/apps/docs/content/references/pricing/interfaces/BaseFilterable.md deleted file mode 100644 index 9db6c644bb..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/BaseFilterable.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# BaseFilterable - -An object used to allow specifying flexible queries with and/or conditions. - -## Type parameters - -| Name | -| :------ | -| `T` | - -## Hierarchy - -- **`BaseFilterable`** - - ↳ [`FilterablePriceSetProps`](FilterablePriceSetProps.md) - - ↳ [`FilterableMoneyAmountProps`](FilterableMoneyAmountProps.md) - - ↳ [`FilterableCurrencyProps`](FilterableCurrencyProps.md) - - ↳ [`FilterableRuleTypeProps`](FilterableRuleTypeProps.md) - - ↳ [`FilterablePriceSetMoneyAmountRulesProps`](FilterablePriceSetMoneyAmountRulesProps.md) - - ↳ [`FilterablePriceRuleProps`](FilterablePriceRuleProps.md) - -## Properties - -### $and - - `Optional` **$and**: (`T` \| [`BaseFilterable`](BaseFilterable.md)<`T`\>)[] - -An array of filters to apply on the entity, where each item in the array is joined with an "and" condition. - -#### Defined in - -[packages/types/src/dal/index.ts:14](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/dal/index.ts#L14) - -___ - -### $or - - `Optional` **$or**: (`T` \| [`BaseFilterable`](BaseFilterable.md)<`T`\>)[] - -An array of filters to apply on the entity, where each item in the array is joined with an "or" condition. - -#### Defined in - -[packages/types/src/dal/index.ts:15](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/dal/index.ts#L15) diff --git a/www/apps/docs/content/references/pricing/interfaces/BaseFilterable.mdx b/www/apps/docs/content/references/pricing/interfaces/BaseFilterable.mdx new file mode 100644 index 0000000000..3f46618653 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/BaseFilterable.mdx @@ -0,0 +1,17 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# BaseFilterable + +An object used to allow specifying flexible queries with and/or conditions. + +## Type parameters + + + +## Properties + +)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"(`T` \\| [`BaseFilterable`](BaseFilterable.mdx)<`T`\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]}]} /> diff --git a/www/apps/docs/content/references/pricing/interfaces/CalculatedPriceSetDTO.md b/www/apps/docs/content/references/pricing/interfaces/CalculatedPriceSetDTO.md deleted file mode 100644 index 617dfeced4..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/CalculatedPriceSetDTO.md +++ /dev/null @@ -1,67 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# CalculatedPriceSetDTO - -An object that holds the details of a calculated price set. - -## Properties - -### amount - - **amount**: ``null`` \| `number` - -a number indicating the calculated amount. It can possibly be `null` if there's no price set up for the provided context. - -#### Defined in - -[packages/types/src/pricing/common/price-set.ts:66](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L66) - -___ - -### currency\_code - - **currency\_code**: ``null`` \| `string` - -a string indicating the currency code of the calculated price. It can possibly be `null`. - -#### Defined in - -[packages/types/src/pricing/common/price-set.ts:67](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L67) - -___ - -### id - - **id**: `string` - -a string indicating the ID of the price set. - -#### Defined in - -[packages/types/src/pricing/common/price-set.ts:65](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L65) - -___ - -### max\_quantity - - **max\_quantity**: ``null`` \| `number` - -a number indicaitng the maximum quantity required to be purchased for this price to apply. It's set if the `quantity` property is provided in the context. Otherwise, its value will be `null`. - -#### Defined in - -[packages/types/src/pricing/common/price-set.ts:69](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L69) - -___ - -### min\_quantity - - **min\_quantity**: ``null`` \| `number` - -a number indicaitng the minimum quantity required to be purchased for this price to apply. It's set if the `quantity` property is provided in the context. Otherwise, its value will be `null`. - -#### Defined in - -[packages/types/src/pricing/common/price-set.ts:68](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L68) diff --git a/www/apps/docs/content/references/pricing/interfaces/CalculatedPriceSetDTO.mdx b/www/apps/docs/content/references/pricing/interfaces/CalculatedPriceSetDTO.mdx new file mode 100644 index 0000000000..5ee83b8010 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/CalculatedPriceSetDTO.mdx @@ -0,0 +1,13 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# CalculatedPriceSetDTO + +A calculated price set's data. + +## Properties + + diff --git a/www/apps/docs/content/references/pricing/interfaces/Context.md b/www/apps/docs/content/references/pricing/interfaces/Context.md deleted file mode 100644 index 316b5c2bcb..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/Context.md +++ /dev/null @@ -1,75 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# Context - -The interface tag is used to ensure that the type is documented similar to interfaces. - -A shared context object that is used to share resources between the application and the module. - -## Type parameters - -| Name | Type | -| :------ | :------ | -| `TManager` | `unknown` | - -## Properties - -### enableNestedTransactions - - `Optional` **enableNestedTransactions**: `boolean` - -a boolean value indicating whether nested transactions are enabled. - -#### Defined in - -[packages/types/src/shared-context.ts:24](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/shared-context.ts#L24) - -___ - -### isolationLevel - - `Optional` **isolationLevel**: `string` - -A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. - -#### Defined in - -[packages/types/src/shared-context.ts:23](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/shared-context.ts#L23) - -___ - -### manager - - `Optional` **manager**: `TManager` - -An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. - -#### Defined in - -[packages/types/src/shared-context.ts:22](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/shared-context.ts#L22) - -___ - -### transactionId - - `Optional` **transactionId**: `string` - -a string indicating the ID of the current transaction. - -#### Defined in - -[packages/types/src/shared-context.ts:25](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/shared-context.ts#L25) - -___ - -### transactionManager - - `Optional` **transactionManager**: `TManager` - -An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. - -#### Defined in - -[packages/types/src/shared-context.ts:21](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/shared-context.ts#L21) diff --git a/www/apps/docs/content/references/pricing/interfaces/Context.mdx b/www/apps/docs/content/references/pricing/interfaces/Context.mdx new file mode 100644 index 0000000000..5b4fe874de --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/Context.mdx @@ -0,0 +1,19 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# Context + +The interface tag is used to ensure that the type is documented similar to interfaces. + +A shared context object that is used to share resources between the application and the module. + +## Type parameters + + + +## Properties + + diff --git a/www/apps/docs/content/references/pricing/interfaces/CreateCurrencyDTO.md b/www/apps/docs/content/references/pricing/interfaces/CreateCurrencyDTO.md deleted file mode 100644 index 7c8d0ac4ce..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/CreateCurrencyDTO.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# CreateCurrencyDTO - -An object that holds data to create a currency. - -## Properties - -### code - - **code**: `string` - -a string indicating the code of the currency. - -#### Defined in - -[packages/types/src/pricing/common/currency.ts:35](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/currency.ts#L35) - -___ - -### name - - **name**: `string` - -a string indicating the name of the currency. - -#### Defined in - -[packages/types/src/pricing/common/currency.ts:38](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/currency.ts#L38) - -___ - -### symbol - - **symbol**: `string` - -a string indicating the symbol of the currency. - -#### Defined in - -[packages/types/src/pricing/common/currency.ts:36](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/currency.ts#L36) - -___ - -### symbol\_native - - **symbol\_native**: `string` - -a string indicating the symbol of the currecy in its native form. -This is typically the symbol used when displaying a price. - -#### Defined in - -[packages/types/src/pricing/common/currency.ts:37](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/currency.ts#L37) diff --git a/www/apps/docs/content/references/pricing/interfaces/CreateCurrencyDTO.mdx b/www/apps/docs/content/references/pricing/interfaces/CreateCurrencyDTO.mdx new file mode 100644 index 0000000000..0c150beaef --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/CreateCurrencyDTO.mdx @@ -0,0 +1,13 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# CreateCurrencyDTO + +A currency to create. + +## Properties + + diff --git a/www/apps/docs/content/references/pricing/interfaces/CreateMoneyAmountDTO.md b/www/apps/docs/content/references/pricing/interfaces/CreateMoneyAmountDTO.md deleted file mode 100644 index f41eba6e06..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/CreateMoneyAmountDTO.md +++ /dev/null @@ -1,87 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# CreateMoneyAmountDTO - -* - -An object that holds data to create a money amount. - -## Hierarchy - -- **`CreateMoneyAmountDTO`** - - ↳ [`CreatePricesDTO`](CreatePricesDTO.md) - -## Properties - -### amount - - `Optional` **amount**: `number` - -A number indicating the amount of this money amount. - -#### Defined in - -[packages/types/src/pricing/common/money-amount.ts:41](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L41) - -___ - -### currency - - `Optional` **currency**: [`CreateCurrencyDTO`](CreateCurrencyDTO.md) - -An object of type [CurrencyDTO](CurrencyDTO.md) that holds the details of the money amount's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. - -#### Defined in - -[packages/types/src/pricing/common/money-amount.ts:40](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L40) - -___ - -### currency\_code - - **currency\_code**: `string` - -A string that indicates the currency code of this money amount. - -#### Defined in - -[packages/types/src/pricing/common/money-amount.ts:39](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L39) - -___ - -### id - - `Optional` **id**: `string` - -A string that indicates the ID of the money amount. - -#### Defined in - -[packages/types/src/pricing/common/money-amount.ts:38](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L38) - -___ - -### max\_quantity - - `Optional` **max\_quantity**: `number` - -A number that indicates the maximum quantity required to be purchased for this money amount to be applied. - -#### Defined in - -[packages/types/src/pricing/common/money-amount.ts:43](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L43) - -___ - -### min\_quantity - - `Optional` **min\_quantity**: `number` - -A number that indicates the minimum quantity required to be purchased for this money amount to be applied. - -#### Defined in - -[packages/types/src/pricing/common/money-amount.ts:42](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L42) diff --git a/www/apps/docs/content/references/pricing/interfaces/CreateMoneyAmountDTO.mdx b/www/apps/docs/content/references/pricing/interfaces/CreateMoneyAmountDTO.mdx new file mode 100644 index 0000000000..951d1f8f3b --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/CreateMoneyAmountDTO.mdx @@ -0,0 +1,13 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# CreateMoneyAmountDTO + +The money amount to create. + +## Properties + + diff --git a/www/apps/docs/content/references/pricing/interfaces/CreatePriceRuleDTO.md b/www/apps/docs/content/references/pricing/interfaces/CreatePriceRuleDTO.md deleted file mode 100644 index 1ff843ecff..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/CreatePriceRuleDTO.md +++ /dev/null @@ -1,103 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# CreatePriceRuleDTO - -An object used to specify the necessary data to create a price rule. - -## Properties - -### id - - **id**: `string` - -A string indicating the ID of the price rule. - -#### Defined in - -[packages/types/src/pricing/common/price-rule.ts:50](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L50) - -___ - -### is\_dynamic - - `Optional` **is\_dynamic**: `boolean` - -A boolean indicating whether the price rule is dynamic. - -#### Defined in - -[packages/types/src/pricing/common/price-rule.ts:53](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L53) - -___ - -### price\_list\_id - - **price\_list\_id**: `string` - -A string indicating the ID of the associated price list. - -#### Defined in - -[packages/types/src/pricing/common/price-rule.ts:57](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L57) - -___ - -### price\_set\_id - - **price\_set\_id**: `string` - -A string indicating the ID of the associated price set. - -#### Defined in - -[packages/types/src/pricing/common/price-rule.ts:51](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L51) - -___ - -### price\_set\_money\_amount\_id - - **price\_set\_money\_amount\_id**: `string` - -A string indicating the ID of the associated price set money amount. - -#### Defined in - -[packages/types/src/pricing/common/price-rule.ts:56](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L56) - -___ - -### priority - - `Optional` **priority**: `number` - -A number indicating the priority of the price rule in comparison to other applicable price rules. - -#### Defined in - -[packages/types/src/pricing/common/price-rule.ts:55](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L55) - -___ - -### rule\_type\_id - - **rule\_type\_id**: `string` - -A string indicating the ID of the associated rule type. - -#### Defined in - -[packages/types/src/pricing/common/price-rule.ts:52](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L52) - -___ - -### value - - **value**: `string` - -A string indicating the value of the price rule. - -#### Defined in - -[packages/types/src/pricing/common/price-rule.ts:54](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L54) diff --git a/www/apps/docs/content/references/pricing/interfaces/CreatePriceRuleDTO.mdx b/www/apps/docs/content/references/pricing/interfaces/CreatePriceRuleDTO.mdx new file mode 100644 index 0000000000..74a3c3a958 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/CreatePriceRuleDTO.mdx @@ -0,0 +1,13 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# CreatePriceRuleDTO + +A price rule to create. + +## Properties + + diff --git a/www/apps/docs/content/references/pricing/interfaces/CreatePriceSetDTO.md b/www/apps/docs/content/references/pricing/interfaces/CreatePriceSetDTO.md deleted file mode 100644 index 8558fea8bb..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/CreatePriceSetDTO.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# CreatePriceSetDTO - -An object of expected properties when creating a price set. - -## Properties - -### prices - - `Optional` **prices**: [`CreatePricesDTO`](CreatePricesDTO.md)[] - -An array of objects of type [CreatePricesDTO](CreatePricesDTO.md), each being a price to associate with the price set. - -#### Defined in - -[packages/types/src/pricing/common/price-set.ts:134](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L134) - -___ - -### rules - - `Optional` **rules**: { `rule_attribute`: `string` }[] - -An array of objects, each object accepts a property `rule_attribute`, whose value is a string indicating the `rule_attribute` value of a rule type. -This property is used to specify the rule types associated with the price set. - -#### Defined in - -[packages/types/src/pricing/common/price-set.ts:133](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L133) diff --git a/www/apps/docs/content/references/pricing/interfaces/CreatePriceSetDTO.mdx b/www/apps/docs/content/references/pricing/interfaces/CreatePriceSetDTO.mdx new file mode 100644 index 0000000000..0ded32ad82 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/CreatePriceSetDTO.mdx @@ -0,0 +1,13 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# CreatePriceSetDTO + +A price set to create. + +## Properties + +","description":"The rules to add to the price. The object's keys are rule types' `rule_attribute` attribute, and values are the value of that rule associated with this price.","optional":false,"defaultValue":"","children":[]}]},{"name":"rules","type":"{ `rule_attribute`: `string` }[]","description":"The rules to associate with the price set. The value of `attribute` is the value of the rule's `rule_attribute` attribute.","optional":true,"defaultValue":"","children":[]}]} /> diff --git a/www/apps/docs/content/references/pricing/interfaces/CreatePriceSetMoneyAmountRulesDTO.md b/www/apps/docs/content/references/pricing/interfaces/CreatePriceSetMoneyAmountRulesDTO.md deleted file mode 100644 index 6e941b4424..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/CreatePriceSetMoneyAmountRulesDTO.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# CreatePriceSetMoneyAmountRulesDTO - -An object used to create a price set money amount rule, which represents an association between a price set money amount and a rule type. - -## Properties - -### price\_set\_money\_amount - - **price\_set\_money\_amount**: `string` - -A string indicating the ID of a price set money amount. - -#### Defined in - -[packages/types/src/pricing/common/price-set-money-amount-rules.ts:32](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set-money-amount-rules.ts#L32) - -___ - -### rule\_type - - **rule\_type**: `string` - -A string indicating the ID of a rule type. - -#### Defined in - -[packages/types/src/pricing/common/price-set-money-amount-rules.ts:33](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set-money-amount-rules.ts#L33) - -___ - -### value - - **value**: `string` - -A string indicating the value of the price set money amount rule. - -#### Defined in - -[packages/types/src/pricing/common/price-set-money-amount-rules.ts:34](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set-money-amount-rules.ts#L34) diff --git a/www/apps/docs/content/references/pricing/interfaces/CreatePriceSetMoneyAmountRulesDTO.mdx b/www/apps/docs/content/references/pricing/interfaces/CreatePriceSetMoneyAmountRulesDTO.mdx new file mode 100644 index 0000000000..a8ed93d24c --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/CreatePriceSetMoneyAmountRulesDTO.mdx @@ -0,0 +1,13 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# CreatePriceSetMoneyAmountRulesDTO + +The price set money amount rule to create. + +## Properties + + diff --git a/www/apps/docs/content/references/pricing/interfaces/CreatePricesDTO.md b/www/apps/docs/content/references/pricing/interfaces/CreatePricesDTO.md deleted file mode 100644 index b244503558..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/CreatePricesDTO.md +++ /dev/null @@ -1,121 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# CreatePricesDTO - -An object used to pass prices data when creating a price set. - -## Hierarchy - -- [`CreateMoneyAmountDTO`](CreateMoneyAmountDTO.md) - - ↳ **`CreatePricesDTO`** - -## Properties - -### amount - - `Optional` **amount**: `number` - -A number indicating the amount of this money amount. - -#### Inherited from - -[CreateMoneyAmountDTO](CreateMoneyAmountDTO.md).[amount](CreateMoneyAmountDTO.md#amount) - -#### Defined in - -[packages/types/src/pricing/common/money-amount.ts:41](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L41) - -___ - -### currency - - `Optional` **currency**: [`CreateCurrencyDTO`](CreateCurrencyDTO.md) - -An object of type [CurrencyDTO](CurrencyDTO.md) that holds the details of the money amount's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. - -#### Inherited from - -[CreateMoneyAmountDTO](CreateMoneyAmountDTO.md).[currency](CreateMoneyAmountDTO.md#currency) - -#### Defined in - -[packages/types/src/pricing/common/money-amount.ts:40](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L40) - -___ - -### currency\_code - - **currency\_code**: `string` - -A string that indicates the currency code of this money amount. - -#### Inherited from - -[CreateMoneyAmountDTO](CreateMoneyAmountDTO.md).[currency_code](CreateMoneyAmountDTO.md#currency_code) - -#### Defined in - -[packages/types/src/pricing/common/money-amount.ts:39](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L39) - -___ - -### id - - `Optional` **id**: `string` - -A string that indicates the ID of the money amount. - -#### Inherited from - -[CreateMoneyAmountDTO](CreateMoneyAmountDTO.md).[id](CreateMoneyAmountDTO.md#id) - -#### Defined in - -[packages/types/src/pricing/common/money-amount.ts:38](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L38) - -___ - -### max\_quantity - - `Optional` **max\_quantity**: `number` - -A number that indicates the maximum quantity required to be purchased for this money amount to be applied. - -#### Inherited from - -[CreateMoneyAmountDTO](CreateMoneyAmountDTO.md).[max_quantity](CreateMoneyAmountDTO.md#max_quantity) - -#### Defined in - -[packages/types/src/pricing/common/money-amount.ts:43](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L43) - -___ - -### min\_quantity - - `Optional` **min\_quantity**: `number` - -A number that indicates the minimum quantity required to be purchased for this money amount to be applied. - -#### Inherited from - -[CreateMoneyAmountDTO](CreateMoneyAmountDTO.md).[min_quantity](CreateMoneyAmountDTO.md#min_quantity) - -#### Defined in - -[packages/types/src/pricing/common/money-amount.ts:42](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L42) - -___ - -### rules - - **rules**: [`Record`](../types/Record.md)<`string`, `string`\> - -An object whose keys are rule types' `rule_attribute` attribute, and values are the value of that rule associated with this price. - -#### Defined in - -[packages/types/src/pricing/common/price-set.ts:93](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L93) diff --git a/www/apps/docs/content/references/pricing/interfaces/CreatePricesDTO.mdx b/www/apps/docs/content/references/pricing/interfaces/CreatePricesDTO.mdx new file mode 100644 index 0000000000..da06bfaef0 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/CreatePricesDTO.mdx @@ -0,0 +1,13 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# CreatePricesDTO + +The prices to create part of a price set. + +## Properties + +","description":"The rules to add to the price. The object's keys are rule types' `rule_attribute` attribute, and values are the value of that rule associated with this price.","optional":false,"defaultValue":"","children":[]}]} /> diff --git a/www/apps/docs/content/references/pricing/interfaces/CreateRuleTypeDTO.md b/www/apps/docs/content/references/pricing/interfaces/CreateRuleTypeDTO.md deleted file mode 100644 index 26ce099663..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/CreateRuleTypeDTO.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# CreateRuleTypeDTO - -An object used when creating a rule type to specify its data. - -## Properties - -### default\_priority - - `Optional` **default\_priority**: `number` - -A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. - -#### Defined in - -[packages/types/src/pricing/common/rule-type.ts:34](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/rule-type.ts#L34) - -___ - -### id - - `Optional` **id**: `string` - -A string indicating the ID of the rule type. - -#### Defined in - -[packages/types/src/pricing/common/rule-type.ts:31](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/rule-type.ts#L31) - -___ - -### name - - **name**: `string` - -A string indicating the display name of the rule type. - -#### Defined in - -[packages/types/src/pricing/common/rule-type.ts:32](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/rule-type.ts#L32) - -___ - -### rule\_attribute - - **rule\_attribute**: `string` - -A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. - -#### Defined in - -[packages/types/src/pricing/common/rule-type.ts:33](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/rule-type.ts#L33) diff --git a/www/apps/docs/content/references/pricing/interfaces/CreateRuleTypeDTO.mdx b/www/apps/docs/content/references/pricing/interfaces/CreateRuleTypeDTO.mdx new file mode 100644 index 0000000000..f8bd19e6b4 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/CreateRuleTypeDTO.mdx @@ -0,0 +1,13 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# CreateRuleTypeDTO + +The rule type to create. + +## Properties + + diff --git a/www/apps/docs/content/references/pricing/interfaces/CurrencyDTO.md b/www/apps/docs/content/references/pricing/interfaces/CurrencyDTO.md deleted file mode 100644 index 609095a6c0..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/CurrencyDTO.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# CurrencyDTO - -An object representing a currency. - -## Properties - -### code - - **code**: `string` - -a string indicating the code of the currency. - -#### Defined in - -[packages/types/src/pricing/common/currency.ts:16](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/currency.ts#L16) - -___ - -### name - - `Optional` **name**: `string` - -a string indicating the name of the currency. - -#### Defined in - -[packages/types/src/pricing/common/currency.ts:19](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/currency.ts#L19) - -___ - -### symbol - - `Optional` **symbol**: `string` - -a string indicating the symbol of the currency. - -#### Defined in - -[packages/types/src/pricing/common/currency.ts:17](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/currency.ts#L17) - -___ - -### symbol\_native - - `Optional` **symbol\_native**: `string` - -a string indicating the symbol of the currecy in its native form. -This is typically the symbol used when displaying a price. - -#### Defined in - -[packages/types/src/pricing/common/currency.ts:18](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/currency.ts#L18) diff --git a/www/apps/docs/content/references/pricing/interfaces/CurrencyDTO.mdx b/www/apps/docs/content/references/pricing/interfaces/CurrencyDTO.mdx new file mode 100644 index 0000000000..e4f449e18f --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/CurrencyDTO.mdx @@ -0,0 +1,13 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# CurrencyDTO + +A currency's data. + +## Properties + + diff --git a/www/apps/docs/content/references/pricing/interfaces/FilterableCurrencyProps.md b/www/apps/docs/content/references/pricing/interfaces/FilterableCurrencyProps.md deleted file mode 100644 index 3c74995b7f..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/FilterableCurrencyProps.md +++ /dev/null @@ -1,57 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# FilterableCurrencyProps - -An object used to filter retrieved currencies. - -## Hierarchy - -- [`BaseFilterable`](BaseFilterable.md)<[`FilterableCurrencyProps`](FilterableCurrencyProps.md)\> - - ↳ **`FilterableCurrencyProps`** - -## Properties - -### $and - - `Optional` **$and**: ([`FilterableCurrencyProps`](FilterableCurrencyProps.md) \| [`BaseFilterable`](BaseFilterable.md)<[`FilterableCurrencyProps`](FilterableCurrencyProps.md)\>)[] - -An array of filters to apply on the entity, where each item in the array is joined with an "and" condition. - -#### Inherited from - -[BaseFilterable](BaseFilterable.md).[$and](BaseFilterable.md#$and) - -#### Defined in - -[packages/types/src/dal/index.ts:14](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/dal/index.ts#L14) - -___ - -### $or - - `Optional` **$or**: ([`FilterableCurrencyProps`](FilterableCurrencyProps.md) \| [`BaseFilterable`](BaseFilterable.md)<[`FilterableCurrencyProps`](FilterableCurrencyProps.md)\>)[] - -An array of filters to apply on the entity, where each item in the array is joined with an "or" condition. - -#### Inherited from - -[BaseFilterable](BaseFilterable.md).[$or](BaseFilterable.md#$or) - -#### Defined in - -[packages/types/src/dal/index.ts:15](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/dal/index.ts#L15) - -___ - -### code - - `Optional` **code**: `string`[] - -an array of strings, each being a currency code to filter the currencies. - -#### Defined in - -[packages/types/src/pricing/common/currency.ts:69](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/currency.ts#L69) diff --git a/www/apps/docs/content/references/pricing/interfaces/FilterableCurrencyProps.mdx b/www/apps/docs/content/references/pricing/interfaces/FilterableCurrencyProps.mdx new file mode 100644 index 0000000000..a58adb67b4 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/FilterableCurrencyProps.mdx @@ -0,0 +1,13 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# FilterableCurrencyProps + +Filters to apply on a currency. + +## Properties + +)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterableCurrencyProps`](FilterableCurrencyProps.mdx) \\| [`BaseFilterable`](BaseFilterable.mdx)<[`FilterableCurrencyProps`](FilterableCurrencyProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"code","type":"`string`[]","description":"The codes to filter the currencies by.","optional":true,"defaultValue":"","children":[]}]} /> diff --git a/www/apps/docs/content/references/pricing/interfaces/FilterableMoneyAmountProps.md b/www/apps/docs/content/references/pricing/interfaces/FilterableMoneyAmountProps.md deleted file mode 100644 index c51b743e7e..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/FilterableMoneyAmountProps.md +++ /dev/null @@ -1,69 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# FilterableMoneyAmountProps - -An object that can be used to filter money amounts. - -## Hierarchy - -- [`BaseFilterable`](BaseFilterable.md)<[`FilterableMoneyAmountProps`](FilterableMoneyAmountProps.md)\> - - ↳ **`FilterableMoneyAmountProps`** - -## Properties - -### $and - - `Optional` **$and**: ([`FilterableMoneyAmountProps`](FilterableMoneyAmountProps.md) \| [`BaseFilterable`](BaseFilterable.md)<[`FilterableMoneyAmountProps`](FilterableMoneyAmountProps.md)\>)[] - -An array of filters to apply on the entity, where each item in the array is joined with an "and" condition. - -#### Inherited from - -[BaseFilterable](BaseFilterable.md).[$and](BaseFilterable.md#$and) - -#### Defined in - -[packages/types/src/dal/index.ts:14](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/dal/index.ts#L14) - -___ - -### $or - - `Optional` **$or**: ([`FilterableMoneyAmountProps`](FilterableMoneyAmountProps.md) \| [`BaseFilterable`](BaseFilterable.md)<[`FilterableMoneyAmountProps`](FilterableMoneyAmountProps.md)\>)[] - -An array of filters to apply on the entity, where each item in the array is joined with an "or" condition. - -#### Inherited from - -[BaseFilterable](BaseFilterable.md).[$or](BaseFilterable.md#$or) - -#### Defined in - -[packages/types/src/dal/index.ts:15](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/dal/index.ts#L15) - -___ - -### currency\_code - - `Optional` **currency\_code**: `string` \| `string`[] - -A string or an array of strings, each being a currency code to filter money amounts. - -#### Defined in - -[packages/types/src/pricing/common/money-amount.ts:77](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L77) - -___ - -### id - - `Optional` **id**: `string`[] - -An array of strings, each being an ID to filter money amounts. - -#### Defined in - -[packages/types/src/pricing/common/money-amount.ts:76](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L76) diff --git a/www/apps/docs/content/references/pricing/interfaces/FilterableMoneyAmountProps.mdx b/www/apps/docs/content/references/pricing/interfaces/FilterableMoneyAmountProps.mdx new file mode 100644 index 0000000000..024c5cb5a0 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/FilterableMoneyAmountProps.mdx @@ -0,0 +1,13 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# FilterableMoneyAmountProps + +Filters to apply on a money amount. + +## Properties + +)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterableMoneyAmountProps`](FilterableMoneyAmountProps.mdx) \\| [`BaseFilterable`](BaseFilterable.mdx)<[`FilterableMoneyAmountProps`](FilterableMoneyAmountProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"currency_code","type":"`string` \\| `string`[]","description":"Currency codes to filter money amounts by.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`[]","description":"IDs to filter money amounts by.","optional":true,"defaultValue":"","children":[]}]} /> diff --git a/www/apps/docs/content/references/pricing/interfaces/FilterablePriceRuleProps.md b/www/apps/docs/content/references/pricing/interfaces/FilterablePriceRuleProps.md deleted file mode 100644 index dcacb3acf6..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/FilterablePriceRuleProps.md +++ /dev/null @@ -1,93 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# FilterablePriceRuleProps - -An object used to filter price rules when retrieving them. - -## Hierarchy - -- [`BaseFilterable`](BaseFilterable.md)<[`FilterablePriceRuleProps`](FilterablePriceRuleProps.md)\> - - ↳ **`FilterablePriceRuleProps`** - -## Properties - -### $and - - `Optional` **$and**: ([`FilterablePriceRuleProps`](FilterablePriceRuleProps.md) \| [`BaseFilterable`](BaseFilterable.md)<[`FilterablePriceRuleProps`](FilterablePriceRuleProps.md)\>)[] - -An array of filters to apply on the entity, where each item in the array is joined with an "and" condition. - -#### Inherited from - -[BaseFilterable](BaseFilterable.md).[$and](BaseFilterable.md#$and) - -#### Defined in - -[packages/types/src/dal/index.ts:14](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/dal/index.ts#L14) - -___ - -### $or - - `Optional` **$or**: ([`FilterablePriceRuleProps`](FilterablePriceRuleProps.md) \| [`BaseFilterable`](BaseFilterable.md)<[`FilterablePriceRuleProps`](FilterablePriceRuleProps.md)\>)[] - -An array of filters to apply on the entity, where each item in the array is joined with an "or" condition. - -#### Inherited from - -[BaseFilterable](BaseFilterable.md).[$or](BaseFilterable.md#$or) - -#### Defined in - -[packages/types/src/dal/index.ts:15](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/dal/index.ts#L15) - -___ - -### id - - `Optional` **id**: `string`[] - -An array of strings, each indicating an ID to filter price rules. - -#### Defined in - -[packages/types/src/pricing/common/price-rule.ts:103](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L103) - -___ - -### name - - `Optional` **name**: `string`[] - -An array of strings, each indicating a name to filter price rules. - -#### Defined in - -[packages/types/src/pricing/common/price-rule.ts:104](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L104) - -___ - -### price\_set\_id - - `Optional` **price\_set\_id**: `string`[] - -An array of strings, each indicating a price set ID to filter price rules. - -#### Defined in - -[packages/types/src/pricing/common/price-rule.ts:105](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L105) - -___ - -### rule\_type\_id - - `Optional` **rule\_type\_id**: `string`[] - -An array of strings, each indicating a rule type ID to filter rule types. - -#### Defined in - -[packages/types/src/pricing/common/price-rule.ts:106](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L106) diff --git a/www/apps/docs/content/references/pricing/interfaces/FilterablePriceRuleProps.mdx b/www/apps/docs/content/references/pricing/interfaces/FilterablePriceRuleProps.mdx new file mode 100644 index 0000000000..a5620ffaff --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/FilterablePriceRuleProps.mdx @@ -0,0 +1,13 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# FilterablePriceRuleProps + +Filters to apply to price rules. + +## Properties + +)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterablePriceRuleProps`](FilterablePriceRuleProps.mdx) \\| [`BaseFilterable`](BaseFilterable.mdx)<[`FilterablePriceRuleProps`](FilterablePriceRuleProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`[]","description":"The IDs to filter price rules by.","optional":true,"defaultValue":"","children":[]},{"name":"name","type":"`string`[]","description":"The names to filter price rules by.","optional":true,"defaultValue":"","children":[]},{"name":"price_set_id","type":"`string`[]","description":"The IDs to filter the price rule's associated price set.","optional":true,"defaultValue":"","children":[]},{"name":"rule_type_id","type":"`string`[]","description":"The IDs to filter the price rule's associated rule type.","optional":true,"defaultValue":"","children":[]}]} /> diff --git a/www/apps/docs/content/references/pricing/interfaces/FilterablePriceSetMoneyAmountRulesProps.md b/www/apps/docs/content/references/pricing/interfaces/FilterablePriceSetMoneyAmountRulesProps.md deleted file mode 100644 index b75db5a99e..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/FilterablePriceSetMoneyAmountRulesProps.md +++ /dev/null @@ -1,93 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# FilterablePriceSetMoneyAmountRulesProps - -An object used to filter price set money amount rules when listing them. - -## Hierarchy - -- [`BaseFilterable`](BaseFilterable.md)<[`FilterablePriceSetMoneyAmountRulesProps`](FilterablePriceSetMoneyAmountRulesProps.md)\> - - ↳ **`FilterablePriceSetMoneyAmountRulesProps`** - -## Properties - -### $and - - `Optional` **$and**: ([`FilterablePriceSetMoneyAmountRulesProps`](FilterablePriceSetMoneyAmountRulesProps.md) \| [`BaseFilterable`](BaseFilterable.md)<[`FilterablePriceSetMoneyAmountRulesProps`](FilterablePriceSetMoneyAmountRulesProps.md)\>)[] - -An array of filters to apply on the entity, where each item in the array is joined with an "and" condition. - -#### Inherited from - -[BaseFilterable](BaseFilterable.md).[$and](BaseFilterable.md#$and) - -#### Defined in - -[packages/types/src/dal/index.ts:14](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/dal/index.ts#L14) - -___ - -### $or - - `Optional` **$or**: ([`FilterablePriceSetMoneyAmountRulesProps`](FilterablePriceSetMoneyAmountRulesProps.md) \| [`BaseFilterable`](BaseFilterable.md)<[`FilterablePriceSetMoneyAmountRulesProps`](FilterablePriceSetMoneyAmountRulesProps.md)\>)[] - -An array of filters to apply on the entity, where each item in the array is joined with an "or" condition. - -#### Inherited from - -[BaseFilterable](BaseFilterable.md).[$or](BaseFilterable.md#$or) - -#### Defined in - -[packages/types/src/dal/index.ts:15](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/dal/index.ts#L15) - -___ - -### id - - `Optional` **id**: `string`[] - -An array of strings, each string indicating an ID to filter the price set money amount rules. - -#### Defined in - -[packages/types/src/pricing/common/price-set-money-amount-rules.ts:66](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set-money-amount-rules.ts#L66) - -___ - -### price\_set\_money\_amount\_id - - `Optional` **price\_set\_money\_amount\_id**: `string`[] - -an array of strings, each string indicating the ID of a price set money amount to filter the price set money amount rules. - -#### Defined in - -[packages/types/src/pricing/common/price-set-money-amount-rules.ts:68](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set-money-amount-rules.ts#L68) - -___ - -### rule\_type\_id - - `Optional` **rule\_type\_id**: `string`[] - -An array of strings, each string indicating the ID of a rule type to filter the price set money amount rules. - -#### Defined in - -[packages/types/src/pricing/common/price-set-money-amount-rules.ts:67](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set-money-amount-rules.ts#L67) - -___ - -### value - - `Optional` **value**: `string`[] - -an array of strings, each string indicating a value to filter the price set money amount rules. - -#### Defined in - -[packages/types/src/pricing/common/price-set-money-amount-rules.ts:69](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set-money-amount-rules.ts#L69) diff --git a/www/apps/docs/content/references/pricing/interfaces/FilterablePriceSetMoneyAmountRulesProps.mdx b/www/apps/docs/content/references/pricing/interfaces/FilterablePriceSetMoneyAmountRulesProps.mdx new file mode 100644 index 0000000000..4fec70eac4 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/FilterablePriceSetMoneyAmountRulesProps.mdx @@ -0,0 +1,13 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# FilterablePriceSetMoneyAmountRulesProps + +Filters to apply on price set money amount rules. + +## Properties + +)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterablePriceSetMoneyAmountRulesProps`](FilterablePriceSetMoneyAmountRulesProps.mdx) \\| [`BaseFilterable`](BaseFilterable.mdx)<[`FilterablePriceSetMoneyAmountRulesProps`](FilterablePriceSetMoneyAmountRulesProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`[]","description":"The ID to filter price set money amount rules by.","optional":true,"defaultValue":"","children":[]},{"name":"price_set_money_amount_id","type":"`string`[]","description":"The IDs to filter the price set money amount rule's associated price set money amount.","optional":true,"defaultValue":"","children":[]},{"name":"rule_type_id","type":"`string`[]","description":"The IDs to filter the price set money amount rule's associated rule type.","optional":true,"defaultValue":"","children":[]},{"name":"value","type":"`string`[]","description":"The value to filter price set money amount rules by.","optional":true,"defaultValue":"","children":[]}]} /> diff --git a/www/apps/docs/content/references/pricing/interfaces/FilterablePriceSetProps.md b/www/apps/docs/content/references/pricing/interfaces/FilterablePriceSetProps.md deleted file mode 100644 index 2accf4e992..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/FilterablePriceSetProps.md +++ /dev/null @@ -1,69 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# FilterablePriceSetProps - -An object that can be used to specify filters on price sets. - -## Hierarchy - -- [`BaseFilterable`](BaseFilterable.md)<[`FilterablePriceSetProps`](FilterablePriceSetProps.md)\> - - ↳ **`FilterablePriceSetProps`** - -## Properties - -### $and - - `Optional` **$and**: ([`FilterablePriceSetProps`](FilterablePriceSetProps.md) \| [`BaseFilterable`](BaseFilterable.md)<[`FilterablePriceSetProps`](FilterablePriceSetProps.md)\>)[] - -An array of filters to apply on the entity, where each item in the array is joined with an "and" condition. - -#### Inherited from - -[BaseFilterable](BaseFilterable.md).[$and](BaseFilterable.md#$and) - -#### Defined in - -[packages/types/src/dal/index.ts:14](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/dal/index.ts#L14) - -___ - -### $or - - `Optional` **$or**: ([`FilterablePriceSetProps`](FilterablePriceSetProps.md) \| [`BaseFilterable`](BaseFilterable.md)<[`FilterablePriceSetProps`](FilterablePriceSetProps.md)\>)[] - -An array of filters to apply on the entity, where each item in the array is joined with an "or" condition. - -#### Inherited from - -[BaseFilterable](BaseFilterable.md).[$or](BaseFilterable.md#$or) - -#### Defined in - -[packages/types/src/dal/index.ts:15](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/dal/index.ts#L15) - -___ - -### id - - `Optional` **id**: `string`[] - -An array of strings, each being an ID to filter price sets. - -#### Defined in - -[packages/types/src/pricing/common/price-set.ts:158](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L158) - -___ - -### money\_amounts - - `Optional` **money\_amounts**: [`FilterableMoneyAmountProps`](FilterableMoneyAmountProps.md) - -An object of type [FilterableMoneyAmountProps](FilterableMoneyAmountProps.md) that is used to filter the price sets by their associated money amounts. - -#### Defined in - -[packages/types/src/pricing/common/price-set.ts:159](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L159) diff --git a/www/apps/docs/content/references/pricing/interfaces/FilterablePriceSetProps.mdx b/www/apps/docs/content/references/pricing/interfaces/FilterablePriceSetProps.mdx new file mode 100644 index 0000000000..7a1050e3da --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/FilterablePriceSetProps.mdx @@ -0,0 +1,13 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# FilterablePriceSetProps + +Filters to apply on price sets. + +## Properties + +)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterablePriceSetProps`](FilterablePriceSetProps.mdx) \\| [`BaseFilterable`](BaseFilterable.mdx)<[`FilterablePriceSetProps`](FilterablePriceSetProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`[]","description":"IDs to filter price sets by.","optional":true,"defaultValue":"","children":[]},{"name":"money_amounts","type":"[`FilterableMoneyAmountProps`](FilterableMoneyAmountProps.mdx)","description":"Filters to apply on a price set's associated money amounts.","optional":true,"defaultValue":"","children":[{"name":"$and","type":"([`FilterableMoneyAmountProps`](FilterableMoneyAmountProps.mdx) \\| [`BaseFilterable`](BaseFilterable.mdx)<[`FilterableMoneyAmountProps`](FilterableMoneyAmountProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterableMoneyAmountProps`](FilterableMoneyAmountProps.mdx) \\| [`BaseFilterable`](BaseFilterable.mdx)<[`FilterableMoneyAmountProps`](FilterableMoneyAmountProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"currency_code","type":"`string` \\| `string`[]","description":"Currency codes to filter money amounts by.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`[]","description":"IDs to filter money amounts by.","optional":true,"defaultValue":"","children":[]}]}]} /> diff --git a/www/apps/docs/content/references/pricing/interfaces/FilterableRuleTypeProps.md b/www/apps/docs/content/references/pricing/interfaces/FilterableRuleTypeProps.md deleted file mode 100644 index 37fc281b4e..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/FilterableRuleTypeProps.md +++ /dev/null @@ -1,81 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# FilterableRuleTypeProps - -An object used to filter retrieved rule types. - -## Hierarchy - -- [`BaseFilterable`](BaseFilterable.md)<[`FilterableRuleTypeProps`](FilterableRuleTypeProps.md)\> - - ↳ **`FilterableRuleTypeProps`** - -## Properties - -### $and - - `Optional` **$and**: ([`FilterableRuleTypeProps`](FilterableRuleTypeProps.md) \| [`BaseFilterable`](BaseFilterable.md)<[`FilterableRuleTypeProps`](FilterableRuleTypeProps.md)\>)[] - -An array of filters to apply on the entity, where each item in the array is joined with an "and" condition. - -#### Inherited from - -[BaseFilterable](BaseFilterable.md).[$and](BaseFilterable.md#$and) - -#### Defined in - -[packages/types/src/dal/index.ts:14](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/dal/index.ts#L14) - -___ - -### $or - - `Optional` **$or**: ([`FilterableRuleTypeProps`](FilterableRuleTypeProps.md) \| [`BaseFilterable`](BaseFilterable.md)<[`FilterableRuleTypeProps`](FilterableRuleTypeProps.md)\>)[] - -An array of filters to apply on the entity, where each item in the array is joined with an "or" condition. - -#### Inherited from - -[BaseFilterable](BaseFilterable.md).[$or](BaseFilterable.md#$or) - -#### Defined in - -[packages/types/src/dal/index.ts:15](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/dal/index.ts#L15) - -___ - -### id - - `Optional` **id**: `string`[] - -an array of strings, each being an ID to filter rule types. - -#### Defined in - -[packages/types/src/pricing/common/rule-type.ts:65](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/rule-type.ts#L65) - -___ - -### name - - `Optional` **name**: `string`[] - -an array of strings, each being a name to filter rule types. - -#### Defined in - -[packages/types/src/pricing/common/rule-type.ts:66](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/rule-type.ts#L66) - -___ - -### rule\_attribute - - `Optional` **rule\_attribute**: `string`[] - -an array of strings, each being a rule attribute to filter rule types. - -#### Defined in - -[packages/types/src/pricing/common/rule-type.ts:67](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/rule-type.ts#L67) diff --git a/www/apps/docs/content/references/pricing/interfaces/FilterableRuleTypeProps.mdx b/www/apps/docs/content/references/pricing/interfaces/FilterableRuleTypeProps.mdx new file mode 100644 index 0000000000..ec6f56e2b7 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/FilterableRuleTypeProps.mdx @@ -0,0 +1,13 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# FilterableRuleTypeProps + +Filters to apply on rule types. + +## Properties + +)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"and\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"$or","type":"([`FilterableRuleTypeProps`](FilterableRuleTypeProps.mdx) \\| [`BaseFilterable`](BaseFilterable.mdx)<[`FilterableRuleTypeProps`](FilterableRuleTypeProps.mdx)\\>)[]","description":"An array of filters to apply on the entity, where each item in the array is joined with an \"or\" condition.","optional":true,"defaultValue":"","children":[]},{"name":"id","type":"`string`[]","description":"The IDs to filter rule types by.","optional":true,"defaultValue":"","children":[]},{"name":"name","type":"`string`[]","description":"The names to filter rule types by.","optional":true,"defaultValue":"","children":[]},{"name":"rule_attribute","type":"`string`[]","description":"The rule attributes to filter rule types by.","optional":true,"defaultValue":"","children":[]}]} /> diff --git a/www/apps/docs/content/references/pricing/interfaces/FindConfig.md b/www/apps/docs/content/references/pricing/interfaces/FindConfig.md deleted file mode 100644 index 77f761b882..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/FindConfig.md +++ /dev/null @@ -1,92 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# FindConfig - -An object that is used to configure how an entity is retrieved from the database. It accepts as a typed parameter an `Entity` class, -which provides correct typing of field names in its properties. - -## Type parameters - -| Name | -| :------ | -| `Entity` | - -## Properties - -### order - - `Optional` **order**: `Object` - -An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` -to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order. - -#### Index signature - -▪ [K: `string`]: ``"ASC"`` \| ``"DESC"`` - -#### Defined in - -[packages/types/src/common/common.ts:64](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/common/common.ts#L64) - -___ - -### relations - - `Optional` **relations**: `string`[] - -An array of strings, each being relation names of the entity to retrieve in the result. - -#### Defined in - -[packages/types/src/common/common.ts:63](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/common/common.ts#L63) - -___ - -### select - - `Optional` **select**: (`string` \| keyof `Entity`)[] - -An array of strings, each being attribute names of the entity to retrieve in the result. - -#### Defined in - -[packages/types/src/common/common.ts:60](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/common/common.ts#L60) - -___ - -### skip - - `Optional` **skip**: `number` - -A number indicating the number of records to skip before retrieving the results. - -#### Defined in - -[packages/types/src/common/common.ts:61](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/common/common.ts#L61) - -___ - -### take - - `Optional` **take**: `number` - -A number indicating the number of records to return in the result. - -#### Defined in - -[packages/types/src/common/common.ts:62](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/common/common.ts#L62) - -___ - -### withDeleted - - `Optional` **withDeleted**: `boolean` - -A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the -`SoftDeletableEntity` class. - -#### Defined in - -[packages/types/src/common/common.ts:65](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/common/common.ts#L65) diff --git a/www/apps/docs/content/references/pricing/interfaces/FindConfig.mdx b/www/apps/docs/content/references/pricing/interfaces/FindConfig.mdx new file mode 100644 index 0000000000..e8fddb9d7d --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/FindConfig.mdx @@ -0,0 +1,18 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# FindConfig + +An object that is used to configure how an entity is retrieved from the database. It accepts as a typed parameter an `Entity` class, +which provides correct typing of field names in its properties. + +## Type parameters + + + +## Properties + + diff --git a/www/apps/docs/content/references/pricing/interfaces/IPricingModuleService.md b/www/apps/docs/content/references/pricing/interfaces/IPricingModuleService.mdx similarity index 67% rename from www/apps/docs/content/references/pricing/interfaces/IPricingModuleService.md rename to www/apps/docs/content/references/pricing/interfaces/IPricingModuleService.mdx index 717a1ae562..2473108f06 100644 --- a/www/apps/docs/content/references/pricing/interfaces/IPricingModuleService.md +++ b/www/apps/docs/content/references/pricing/interfaces/IPricingModuleService.mdx @@ -6,48 +6,50 @@ badge: slug: /references/pricing --- +import ParameterTypes from "@site/src/components/ParameterTypes" + # IPricingModuleService Reference This section of the documentation provides a reference to the `IPricingModuleService` interface’s methods. This is the interface developers use to use the functionalities provided by the Pricing Module. ## Methods -- [addPrices](../IPricingModuleService/methods/IPricingModuleService.addPrices.md) -- [addRules](../IPricingModuleService/methods/IPricingModuleService.addRules.md) -- [calculatePrices](../IPricingModuleService/methods/IPricingModuleService.calculatePrices.md) -- [create](../IPricingModuleService/methods/IPricingModuleService.create.md) -- [createCurrencies](../IPricingModuleService/methods/IPricingModuleService.createCurrencies.md) -- [createMoneyAmounts](../IPricingModuleService/methods/IPricingModuleService.createMoneyAmounts.md) -- [createPriceRules](../IPricingModuleService/methods/IPricingModuleService.createPriceRules.md) -- [createPriceSetMoneyAmountRules](../IPricingModuleService/methods/IPricingModuleService.createPriceSetMoneyAmountRules.md) -- [createRuleTypes](../IPricingModuleService/methods/IPricingModuleService.createRuleTypes.md) -- [delete](../IPricingModuleService/methods/IPricingModuleService.delete.md) -- [deleteCurrencies](../IPricingModuleService/methods/IPricingModuleService.deleteCurrencies.md) -- [deleteMoneyAmounts](../IPricingModuleService/methods/IPricingModuleService.deleteMoneyAmounts.md) -- [deletePriceRules](../IPricingModuleService/methods/IPricingModuleService.deletePriceRules.md) -- [deletePriceSetMoneyAmountRules](../IPricingModuleService/methods/IPricingModuleService.deletePriceSetMoneyAmountRules.md) -- [deleteRuleTypes](../IPricingModuleService/methods/IPricingModuleService.deleteRuleTypes.md) -- [list](../IPricingModuleService/methods/IPricingModuleService.list.md) -- [listAndCount](../IPricingModuleService/methods/IPricingModuleService.listAndCount.md) -- [listAndCountCurrencies](../IPricingModuleService/methods/IPricingModuleService.listAndCountCurrencies.md) -- [listAndCountMoneyAmounts](../IPricingModuleService/methods/IPricingModuleService.listAndCountMoneyAmounts.md) -- [listAndCountPriceRules](../IPricingModuleService/methods/IPricingModuleService.listAndCountPriceRules.md) -- [listAndCountPriceSetMoneyAmountRules](../IPricingModuleService/methods/IPricingModuleService.listAndCountPriceSetMoneyAmountRules.md) -- [listAndCountRuleTypes](../IPricingModuleService/methods/IPricingModuleService.listAndCountRuleTypes.md) -- [listCurrencies](../IPricingModuleService/methods/IPricingModuleService.listCurrencies.md) -- [listMoneyAmounts](../IPricingModuleService/methods/IPricingModuleService.listMoneyAmounts.md) -- [listPriceRules](../IPricingModuleService/methods/IPricingModuleService.listPriceRules.md) -- [listPriceSetMoneyAmountRules](../IPricingModuleService/methods/IPricingModuleService.listPriceSetMoneyAmountRules.md) -- [listRuleTypes](../IPricingModuleService/methods/IPricingModuleService.listRuleTypes.md) -- [removeRules](../IPricingModuleService/methods/IPricingModuleService.removeRules.md) -- [retrieve](../IPricingModuleService/methods/IPricingModuleService.retrieve.md) -- [retrieveCurrency](../IPricingModuleService/methods/IPricingModuleService.retrieveCurrency.md) -- [retrieveMoneyAmount](../IPricingModuleService/methods/IPricingModuleService.retrieveMoneyAmount.md) -- [retrievePriceRule](../IPricingModuleService/methods/IPricingModuleService.retrievePriceRule.md) -- [retrievePriceSetMoneyAmountRules](../IPricingModuleService/methods/IPricingModuleService.retrievePriceSetMoneyAmountRules.md) -- [retrieveRuleType](../IPricingModuleService/methods/IPricingModuleService.retrieveRuleType.md) -- [updateCurrencies](../IPricingModuleService/methods/IPricingModuleService.updateCurrencies.md) -- [updateMoneyAmounts](../IPricingModuleService/methods/IPricingModuleService.updateMoneyAmounts.md) -- [updatePriceRules](../IPricingModuleService/methods/IPricingModuleService.updatePriceRules.md) -- [updatePriceSetMoneyAmountRules](../IPricingModuleService/methods/IPricingModuleService.updatePriceSetMoneyAmountRules.md) -- [updateRuleTypes](../IPricingModuleService/methods/IPricingModuleService.updateRuleTypes.md) +- [addPrices](../IPricingModuleService/methods/IPricingModuleService.addPrices.mdx) +- [addRules](../IPricingModuleService/methods/IPricingModuleService.addRules.mdx) +- [calculatePrices](../IPricingModuleService/methods/IPricingModuleService.calculatePrices.mdx) +- [create](../IPricingModuleService/methods/IPricingModuleService.create.mdx) +- [createCurrencies](../IPricingModuleService/methods/IPricingModuleService.createCurrencies.mdx) +- [createMoneyAmounts](../IPricingModuleService/methods/IPricingModuleService.createMoneyAmounts.mdx) +- [createPriceRules](../IPricingModuleService/methods/IPricingModuleService.createPriceRules.mdx) +- [createPriceSetMoneyAmountRules](../IPricingModuleService/methods/IPricingModuleService.createPriceSetMoneyAmountRules.mdx) +- [createRuleTypes](../IPricingModuleService/methods/IPricingModuleService.createRuleTypes.mdx) +- [delete](../IPricingModuleService/methods/IPricingModuleService.delete.mdx) +- [deleteCurrencies](../IPricingModuleService/methods/IPricingModuleService.deleteCurrencies.mdx) +- [deleteMoneyAmounts](../IPricingModuleService/methods/IPricingModuleService.deleteMoneyAmounts.mdx) +- [deletePriceRules](../IPricingModuleService/methods/IPricingModuleService.deletePriceRules.mdx) +- [deletePriceSetMoneyAmountRules](../IPricingModuleService/methods/IPricingModuleService.deletePriceSetMoneyAmountRules.mdx) +- [deleteRuleTypes](../IPricingModuleService/methods/IPricingModuleService.deleteRuleTypes.mdx) +- [list](../IPricingModuleService/methods/IPricingModuleService.list.mdx) +- [listAndCount](../IPricingModuleService/methods/IPricingModuleService.listAndCount.mdx) +- [listAndCountCurrencies](../IPricingModuleService/methods/IPricingModuleService.listAndCountCurrencies.mdx) +- [listAndCountMoneyAmounts](../IPricingModuleService/methods/IPricingModuleService.listAndCountMoneyAmounts.mdx) +- [listAndCountPriceRules](../IPricingModuleService/methods/IPricingModuleService.listAndCountPriceRules.mdx) +- [listAndCountPriceSetMoneyAmountRules](../IPricingModuleService/methods/IPricingModuleService.listAndCountPriceSetMoneyAmountRules.mdx) +- [listAndCountRuleTypes](../IPricingModuleService/methods/IPricingModuleService.listAndCountRuleTypes.mdx) +- [listCurrencies](../IPricingModuleService/methods/IPricingModuleService.listCurrencies.mdx) +- [listMoneyAmounts](../IPricingModuleService/methods/IPricingModuleService.listMoneyAmounts.mdx) +- [listPriceRules](../IPricingModuleService/methods/IPricingModuleService.listPriceRules.mdx) +- [listPriceSetMoneyAmountRules](../IPricingModuleService/methods/IPricingModuleService.listPriceSetMoneyAmountRules.mdx) +- [listRuleTypes](../IPricingModuleService/methods/IPricingModuleService.listRuleTypes.mdx) +- [removeRules](../IPricingModuleService/methods/IPricingModuleService.removeRules.mdx) +- [retrieve](../IPricingModuleService/methods/IPricingModuleService.retrieve.mdx) +- [retrieveCurrency](../IPricingModuleService/methods/IPricingModuleService.retrieveCurrency.mdx) +- [retrieveMoneyAmount](../IPricingModuleService/methods/IPricingModuleService.retrieveMoneyAmount.mdx) +- [retrievePriceRule](../IPricingModuleService/methods/IPricingModuleService.retrievePriceRule.mdx) +- [retrievePriceSetMoneyAmountRules](../IPricingModuleService/methods/IPricingModuleService.retrievePriceSetMoneyAmountRules.mdx) +- [retrieveRuleType](../IPricingModuleService/methods/IPricingModuleService.retrieveRuleType.mdx) +- [updateCurrencies](../IPricingModuleService/methods/IPricingModuleService.updateCurrencies.mdx) +- [updateMoneyAmounts](../IPricingModuleService/methods/IPricingModuleService.updateMoneyAmounts.mdx) +- [updatePriceRules](../IPricingModuleService/methods/IPricingModuleService.updatePriceRules.mdx) +- [updatePriceSetMoneyAmountRules](../IPricingModuleService/methods/IPricingModuleService.updatePriceSetMoneyAmountRules.mdx) +- [updateRuleTypes](../IPricingModuleService/methods/IPricingModuleService.updateRuleTypes.mdx) diff --git a/www/apps/docs/content/references/pricing/interfaces/JoinerServiceConfig.md b/www/apps/docs/content/references/pricing/interfaces/JoinerServiceConfig.md deleted file mode 100644 index aacd7ac70b..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/JoinerServiceConfig.md +++ /dev/null @@ -1,81 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# JoinerServiceConfig - -## Properties - -### alias - - `Optional` **alias**: [`JoinerServiceConfigAlias`](JoinerServiceConfigAlias.md) \| [`JoinerServiceConfigAlias`](JoinerServiceConfigAlias.md)[] - -Property name to use as entrypoint to the service - -#### Defined in - -[packages/types/src/joiner/index.ts:38](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/joiner/index.ts#L38) - -___ - -### args - - `Optional` **args**: [`Record`](../types/Record.md)<`string`, `any`\> - -Extra arguments to pass to the remoteFetchData callback - -#### Defined in - -[packages/types/src/joiner/index.ts:59](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/joiner/index.ts#L59) - -___ - -### extends - - `Optional` **extends**: { `relationship`: [`JoinerRelationship`](../types/JoinerRelationship.md) ; `serviceName`: `string` }[] - -#### Defined in - -[packages/types/src/joiner/index.ts:52](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/joiner/index.ts#L52) - -___ - -### fieldAlias - - `Optional` **fieldAlias**: [`Record`](../types/Record.md)<`string`, `string` \| { `forwardArgumentsOnPath`: `string`[] ; `path`: `string` }\> - -alias for deeper nested relationships (e.g. { 'price': 'prices.calculated_price_set.amount' }) - -#### Defined in - -[packages/types/src/joiner/index.ts:42](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/joiner/index.ts#L42) - -___ - -### primaryKeys - - **primaryKeys**: `string`[] - -#### Defined in - -[packages/types/src/joiner/index.ts:50](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/joiner/index.ts#L50) - -___ - -### relationships - - `Optional` **relationships**: [`JoinerRelationship`](../types/JoinerRelationship.md)[] - -#### Defined in - -[packages/types/src/joiner/index.ts:51](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/joiner/index.ts#L51) - -___ - -### serviceName - - **serviceName**: `string` - -#### Defined in - -[packages/types/src/joiner/index.ts:34](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/joiner/index.ts#L34) diff --git a/www/apps/docs/content/references/pricing/interfaces/JoinerServiceConfig.mdx b/www/apps/docs/content/references/pricing/interfaces/JoinerServiceConfig.mdx new file mode 100644 index 0000000000..4b55c30b78 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/JoinerServiceConfig.mdx @@ -0,0 +1,11 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# JoinerServiceConfig + +## Properties + +","description":"Extra arguments to pass to the remoteFetchData callback","optional":true,"defaultValue":"","children":[]},{"name":"extends","type":"{ `relationship`: [`JoinerRelationship`](../types/JoinerRelationship.mdx) ; `serviceName`: `string` }[]","description":"","optional":true,"defaultValue":"","children":[]},{"name":"fieldAlias","type":"Record<`string`, `string` \\| { `forwardArgumentsOnPath`: `string`[] ; `path`: `string` }\\>","description":"alias for deeper nested relationships (e.g. { 'price': 'prices.calculated_price_set.amount' })","optional":true,"defaultValue":"","children":[]},{"name":"primaryKeys","type":"`string`[]","description":"","optional":false,"defaultValue":"","children":[]},{"name":"relationships","type":"[`JoinerRelationship`](../types/JoinerRelationship.mdx)[]","description":"","optional":true,"defaultValue":"","children":[]},{"name":"serviceName","type":"`string`","description":"","optional":false,"defaultValue":"","children":[]}]} /> diff --git a/www/apps/docs/content/references/pricing/interfaces/JoinerServiceConfigAlias.md b/www/apps/docs/content/references/pricing/interfaces/JoinerServiceConfigAlias.md deleted file mode 100644 index 88354c9e6a..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/JoinerServiceConfigAlias.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# JoinerServiceConfigAlias - -## Properties - -### args - - `Optional` **args**: [`Record`](../types/Record.md)<`string`, `any`\> - -Extra arguments to pass to the remoteFetchData callback - -#### Defined in - -[packages/types/src/joiner/index.ts:30](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/joiner/index.ts#L30) - -___ - -### name - - **name**: `string` - -#### Defined in - -[packages/types/src/joiner/index.ts:26](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/joiner/index.ts#L26) diff --git a/www/apps/docs/content/references/pricing/interfaces/JoinerServiceConfigAlias.mdx b/www/apps/docs/content/references/pricing/interfaces/JoinerServiceConfigAlias.mdx new file mode 100644 index 0000000000..8fe4c19c9a --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/JoinerServiceConfigAlias.mdx @@ -0,0 +1,11 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# JoinerServiceConfigAlias + +## Properties + +","description":"Extra arguments to pass to the remoteFetchData callback","optional":true,"defaultValue":"","children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","children":[]}]} /> diff --git a/www/apps/docs/content/references/pricing/interfaces/MoneyAmountDTO.md b/www/apps/docs/content/references/pricing/interfaces/MoneyAmountDTO.md deleted file mode 100644 index 0407f386f8..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/MoneyAmountDTO.md +++ /dev/null @@ -1,79 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# MoneyAmountDTO - -An object that holds prices, which typically belong to a price set. - -## Properties - -### amount - - `Optional` **amount**: `number` - -A number indicating the amount of this price. - -#### Defined in - -[packages/types/src/pricing/common/money-amount.ts:20](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L20) - -___ - -### currency - - `Optional` **currency**: [`CurrencyDTO`](CurrencyDTO.md) - -An object of type [CurrencyDTO](CurrencyDTO.md) that holds the details of the price's currency. Since this is a relation, it will only be retrieved if it's passed to the `relations` array of the find-configuration options. - -#### Defined in - -[packages/types/src/pricing/common/money-amount.ts:19](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L19) - -___ - -### currency\_code - - `Optional` **currency\_code**: `string` - -A string that indicates the currency code of this price. - -#### Defined in - -[packages/types/src/pricing/common/money-amount.ts:18](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L18) - -___ - -### id - - **id**: `string` - -A string that indicates the ID of the money amount. A money amount represents a price. - -#### Defined in - -[packages/types/src/pricing/common/money-amount.ts:17](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L17) - -___ - -### max\_quantity - - `Optional` **max\_quantity**: `number` - -A number that indicates the maximum quantity required to be purchased for this price to be applied. - -#### Defined in - -[packages/types/src/pricing/common/money-amount.ts:22](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L22) - -___ - -### min\_quantity - - `Optional` **min\_quantity**: `number` - -A number that indicates the minimum quantity required to be purchased for this price to be applied. - -#### Defined in - -[packages/types/src/pricing/common/money-amount.ts:21](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L21) diff --git a/www/apps/docs/content/references/pricing/interfaces/MoneyAmountDTO.mdx b/www/apps/docs/content/references/pricing/interfaces/MoneyAmountDTO.mdx new file mode 100644 index 0000000000..84db9efa03 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/MoneyAmountDTO.mdx @@ -0,0 +1,13 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# MoneyAmountDTO + +A money amount's data. A money amount represents a price. + +## Properties + + diff --git a/www/apps/docs/content/references/pricing/interfaces/PriceRuleDTO.md b/www/apps/docs/content/references/pricing/interfaces/PriceRuleDTO.md deleted file mode 100644 index 27b456d150..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/PriceRuleDTO.md +++ /dev/null @@ -1,127 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# PriceRuleDTO - -An object that represents a price rule. - -## Properties - -### id - - **id**: `string` - -A string indicating the ID of the price rule. - -#### Defined in - -[packages/types/src/pricing/common/price-rule.ts:22](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L22) - -___ - -### is\_dynamic - - **is\_dynamic**: `boolean` - -A boolean indicating whether the price rule is dynamic. - -#### Defined in - -[packages/types/src/pricing/common/price-rule.ts:27](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L27) - -___ - -### price\_list\_id - - **price\_list\_id**: `string` - -A string indicating the ID of the associated price list. - -#### Defined in - -[packages/types/src/pricing/common/price-rule.ts:31](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L31) - -___ - -### price\_set - - **price\_set**: [`PriceSetDTO`](PriceSetDTO.md) - -An object of type [PriceSetDTO](PriceSetDTO.md) that holds the data of the associated price set. It may only be available if the relation `price_set` is expanded. - -#### Defined in - -[packages/types/src/pricing/common/price-rule.ts:24](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L24) - -___ - -### price\_set\_id - - **price\_set\_id**: `string` - -A string indicating the ID of the associated price set. - -#### Defined in - -[packages/types/src/pricing/common/price-rule.ts:23](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L23) - -___ - -### price\_set\_money\_amount\_id - - **price\_set\_money\_amount\_id**: `string` - -A string indicating the ID of the associated price set money amount. - -#### Defined in - -[packages/types/src/pricing/common/price-rule.ts:30](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L30) - -___ - -### priority - - **priority**: `number` - -A number indicating the priority of the price rule in comparison to other applicable price rules. - -#### Defined in - -[packages/types/src/pricing/common/price-rule.ts:29](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L29) - -___ - -### rule\_type - - **rule\_type**: [`RuleTypeDTO`](RuleTypeDTO.md) - -An object of type [RuleTypeDTO](RuleTypeDTO.md) that holds the data of the associated rule type. It may only be available if the relation `rule_type` is expanded. - -#### Defined in - -[packages/types/src/pricing/common/price-rule.ts:26](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L26) - -___ - -### rule\_type\_id - - **rule\_type\_id**: `string` - -A string indicating the ID of the associated rule type. - -#### Defined in - -[packages/types/src/pricing/common/price-rule.ts:25](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L25) - -___ - -### value - - **value**: `string` - -A string indicating the value of the price rule. - -#### Defined in - -[packages/types/src/pricing/common/price-rule.ts:28](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L28) diff --git a/www/apps/docs/content/references/pricing/interfaces/PriceRuleDTO.mdx b/www/apps/docs/content/references/pricing/interfaces/PriceRuleDTO.mdx new file mode 100644 index 0000000000..906036e565 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/PriceRuleDTO.mdx @@ -0,0 +1,13 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# PriceRuleDTO + +A price rule's data. + +## Properties + + diff --git a/www/apps/docs/content/references/pricing/interfaces/PriceSetDTO.md b/www/apps/docs/content/references/pricing/interfaces/PriceSetDTO.md deleted file mode 100644 index f98e2522d3..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/PriceSetDTO.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# PriceSetDTO - -An object that holds the details of a retrieved price set. - -## Properties - -### id - - **id**: `string` - -A string indicating the ID of the price set. - -#### Defined in - -[packages/types/src/pricing/common/price-set.ts:48](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L48) - -___ - -### money\_amounts - - `Optional` **money\_amounts**: [`MoneyAmountDTO`](MoneyAmountDTO.md)[] - -An array of objects of type [MoneyAmountDTO](MoneyAmountDTO.md), which holds the prices that belong to this price set. - -#### Defined in - -[packages/types/src/pricing/common/price-set.ts:49](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L49) - -___ - -### rule\_types - - `Optional` **rule\_types**: [`RuleTypeDTO`](RuleTypeDTO.md)[] - -An array of objects of type [RuleTypeDTO](RuleTypeDTO.md), which holds the rule types applied on this price set. - -#### Defined in - -[packages/types/src/pricing/common/price-set.ts:50](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L50) diff --git a/www/apps/docs/content/references/pricing/interfaces/PriceSetDTO.mdx b/www/apps/docs/content/references/pricing/interfaces/PriceSetDTO.mdx new file mode 100644 index 0000000000..9eea88ae14 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/PriceSetDTO.mdx @@ -0,0 +1,13 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# PriceSetDTO + +A price set's data. + +## Properties + + diff --git a/www/apps/docs/content/references/pricing/interfaces/PriceSetMoneyAmountDTO.md b/www/apps/docs/content/references/pricing/interfaces/PriceSetMoneyAmountDTO.md deleted file mode 100644 index d97475586f..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/PriceSetMoneyAmountDTO.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# PriceSetMoneyAmountDTO - -An object representing a price set money amount, which holds the data related to the association between a price set and a money amount. - -## Properties - -### id - - **id**: `string` - -a string indicating the ID of a price set money amount. - -#### Defined in - -[packages/types/src/pricing/common/price-set-money-amount.ts:15](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set-money-amount.ts#L15) - -___ - -### money\_amount - - `Optional` **money\_amount**: [`MoneyAmountDTO`](MoneyAmountDTO.md) - -an object of type [MoneyAmountDTO](MoneyAmountDTO.md) holding the data of the associated money amount. - -#### Defined in - -[packages/types/src/pricing/common/price-set-money-amount.ts:18](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set-money-amount.ts#L18) - -___ - -### price\_set - - `Optional` **price\_set**: [`PriceSetDTO`](PriceSetDTO.md) - -an object of type [PriceSetDTO](PriceSetDTO.md) holding the data of the associated price set. - -#### Defined in - -[packages/types/src/pricing/common/price-set-money-amount.ts:17](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set-money-amount.ts#L17) - -___ - -### title - - `Optional` **title**: `string` - -a string indicating the title of the price set money amount. - -#### Defined in - -[packages/types/src/pricing/common/price-set-money-amount.ts:16](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set-money-amount.ts#L16) diff --git a/www/apps/docs/content/references/pricing/interfaces/PriceSetMoneyAmountDTO.mdx b/www/apps/docs/content/references/pricing/interfaces/PriceSetMoneyAmountDTO.mdx new file mode 100644 index 0000000000..68d9254f80 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/PriceSetMoneyAmountDTO.mdx @@ -0,0 +1,13 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# PriceSetMoneyAmountDTO + +A price set money amount's data. + +## Properties + + diff --git a/www/apps/docs/content/references/pricing/interfaces/PriceSetMoneyAmountRulesDTO.md b/www/apps/docs/content/references/pricing/interfaces/PriceSetMoneyAmountRulesDTO.md deleted file mode 100644 index 4369aab892..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/PriceSetMoneyAmountRulesDTO.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# PriceSetMoneyAmountRulesDTO - -An object representing a price set money amount rule, which holds data related to the association between a price set money amount and a rule. - -## Properties - -### id - - **id**: `string` - -A string indicating the ID of the price set money amount. - -#### Defined in - -[packages/types/src/pricing/common/price-set-money-amount-rules.ts:16](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set-money-amount-rules.ts#L16) - -___ - -### price\_set\_money\_amount - - **price\_set\_money\_amount**: [`PriceSetMoneyAmountDTO`](PriceSetMoneyAmountDTO.md) - -an object of type [PriceSetMoneyAmountDTO](PriceSetMoneyAmountDTO.md) holding the data of the associated price set money amount. - -#### Defined in - -[packages/types/src/pricing/common/price-set-money-amount-rules.ts:17](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set-money-amount-rules.ts#L17) - -___ - -### rule\_type - - **rule\_type**: [`RuleTypeDTO`](RuleTypeDTO.md) - -an object of type [RuleTypeDTO](RuleTypeDTO.md) holding the data of the associated rule type. - -#### Defined in - -[packages/types/src/pricing/common/price-set-money-amount-rules.ts:18](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set-money-amount-rules.ts#L18) - -___ - -### value - - **value**: `string` - -a string indicating the value of the price set money amount rule. - -#### Defined in - -[packages/types/src/pricing/common/price-set-money-amount-rules.ts:19](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set-money-amount-rules.ts#L19) diff --git a/www/apps/docs/content/references/pricing/interfaces/PriceSetMoneyAmountRulesDTO.mdx b/www/apps/docs/content/references/pricing/interfaces/PriceSetMoneyAmountRulesDTO.mdx new file mode 100644 index 0000000000..69cefc4aa6 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/PriceSetMoneyAmountRulesDTO.mdx @@ -0,0 +1,13 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# PriceSetMoneyAmountRulesDTO + +A price set money amount rule's data. + +## Properties + + diff --git a/www/apps/docs/content/references/pricing/interfaces/PricingContext.md b/www/apps/docs/content/references/pricing/interfaces/PricingContext.md deleted file mode 100644 index c34344c0a7..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/PricingContext.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# PricingContext - -Used to specify the context to calculate prices. For example, you can specify the currency code to calculate prices in. - -**Example** - -```ts -To calculate prices -``` - -## Properties - -### context - - `Optional` **context**: [`Record`](../types/Record.md)<`string`, `string` \| `number`\> - -an object whose keys are the name of the context attribute. Its value can be a string or a number. For example, you can pass the `currency_code` property with its value being the currency code to calculate the price in. -Another example is passing the `quantity` property to calculate the price for that specified quantity, which finds a price set whose `min_quantity` and `max_quantity` conditions match the specified quantity. - -#### Defined in - -[packages/types/src/pricing/common/price-set.ts:23](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L23) diff --git a/www/apps/docs/content/references/pricing/interfaces/PricingContext.mdx b/www/apps/docs/content/references/pricing/interfaces/PricingContext.mdx new file mode 100644 index 0000000000..8ffd5c43fb --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/PricingContext.mdx @@ -0,0 +1,13 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# PricingContext + +The context to calculate prices. For example, you can specify the currency code to calculate prices in. + +## Properties + +","description":"an object whose keys are the name of the context attribute. Its value can be a string or a number. For example, you can pass the `currency_code` property with its value being the currency code to calculate the price in. Another example is passing the `quantity` property to calculate the price for that specified quantity, which finds a price set whose `min_quantity` and `max_quantity` conditions match the specified quantity.","optional":true,"defaultValue":"","children":[]}]} /> diff --git a/www/apps/docs/content/references/pricing/interfaces/PricingFilters.md b/www/apps/docs/content/references/pricing/interfaces/PricingFilters.md deleted file mode 100644 index 123ba49f11..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/PricingFilters.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# PricingFilters - -Used to filter prices when calculating them. - -## Properties - -### id - - **id**: `string`[] - -An array of strings, each being an ID of a price set. - -#### Defined in - -[packages/types/src/pricing/common/price-set.ts:34](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L34) diff --git a/www/apps/docs/content/references/pricing/interfaces/PricingFilters.mdx b/www/apps/docs/content/references/pricing/interfaces/PricingFilters.mdx new file mode 100644 index 0000000000..efc83d3fa4 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/PricingFilters.mdx @@ -0,0 +1,13 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# PricingFilters + +Filters to apply on prices. + +## Properties + + diff --git a/www/apps/docs/content/references/pricing/interfaces/RemovePriceSetRulesDTO.md b/www/apps/docs/content/references/pricing/interfaces/RemovePriceSetRulesDTO.md deleted file mode 100644 index c520e91403..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/RemovePriceSetRulesDTO.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# RemovePriceSetRulesDTO - -An object of expected properties when removing a price set's rules. - -## Properties - -### id - - **id**: `string` - -A string indicating the ID of the price set. - -#### Defined in - -[packages/types/src/pricing/common/price-set.ts:118](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L118) - -___ - -### rules - - **rules**: `string`[] - -An array of strings, each string is the `rule_attribute` of a rule you want to remove. - -#### Defined in - -[packages/types/src/pricing/common/price-set.ts:119](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L119) diff --git a/www/apps/docs/content/references/pricing/interfaces/RemovePriceSetRulesDTO.mdx b/www/apps/docs/content/references/pricing/interfaces/RemovePriceSetRulesDTO.mdx new file mode 100644 index 0000000000..340b39d481 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/RemovePriceSetRulesDTO.mdx @@ -0,0 +1,13 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# RemovePriceSetRulesDTO + +The rules to remove from a price set. + +## Properties + + diff --git a/www/apps/docs/content/references/pricing/interfaces/RuleTypeDTO.md b/www/apps/docs/content/references/pricing/interfaces/RuleTypeDTO.md deleted file mode 100644 index b175f7745c..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/RuleTypeDTO.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# RuleTypeDTO - -An object that holds the details of a rule type. - -## Properties - -### default\_priority - - **default\_priority**: `number` - -A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. - -#### Defined in - -[packages/types/src/pricing/common/rule-type.ts:17](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/rule-type.ts#L17) - -___ - -### id - - **id**: `string` - -A string indicating the ID of the rule type. - -#### Defined in - -[packages/types/src/pricing/common/rule-type.ts:14](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/rule-type.ts#L14) - -___ - -### name - - **name**: `string` - -A string indicating the display name of the rule type. - -#### Defined in - -[packages/types/src/pricing/common/rule-type.ts:15](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/rule-type.ts#L15) - -___ - -### rule\_attribute - - **rule\_attribute**: `string` - -A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. - -#### Defined in - -[packages/types/src/pricing/common/rule-type.ts:16](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/rule-type.ts#L16) diff --git a/www/apps/docs/content/references/pricing/interfaces/RuleTypeDTO.mdx b/www/apps/docs/content/references/pricing/interfaces/RuleTypeDTO.mdx new file mode 100644 index 0000000000..9215c32c75 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/RuleTypeDTO.mdx @@ -0,0 +1,13 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# RuleTypeDTO + +A rule type's data. + +## Properties + + diff --git a/www/apps/docs/content/references/pricing/interfaces/UpdateCurrencyDTO.md b/www/apps/docs/content/references/pricing/interfaces/UpdateCurrencyDTO.md deleted file mode 100644 index fca1cf5184..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/UpdateCurrencyDTO.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# UpdateCurrencyDTO - -An object that holds data to update a currency. The currency code must be provided to identify which currency to update. - -## Properties - -### code - - **code**: `string` - -a string indicating the code of the currency to update. - -#### Defined in - -[packages/types/src/pricing/common/currency.ts:54](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/currency.ts#L54) - -___ - -### name - - `Optional` **name**: `string` - -a string indicating the name of the currency. - -#### Defined in - -[packages/types/src/pricing/common/currency.ts:57](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/currency.ts#L57) - -___ - -### symbol - - `Optional` **symbol**: `string` - -a string indicating the symbol of the currency. - -#### Defined in - -[packages/types/src/pricing/common/currency.ts:55](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/currency.ts#L55) - -___ - -### symbol\_native - - `Optional` **symbol\_native**: `string` - -a string indicating the symbol of the currecy in its native form. -This is typically the symbol used when displaying a price. - -#### Defined in - -[packages/types/src/pricing/common/currency.ts:56](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/currency.ts#L56) diff --git a/www/apps/docs/content/references/pricing/interfaces/UpdateCurrencyDTO.mdx b/www/apps/docs/content/references/pricing/interfaces/UpdateCurrencyDTO.mdx new file mode 100644 index 0000000000..3e9ea28a20 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/UpdateCurrencyDTO.mdx @@ -0,0 +1,13 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# UpdateCurrencyDTO + +The data to update in a currency. The `code` is used to identify which currency to update. + +## Properties + + diff --git a/www/apps/docs/content/references/pricing/interfaces/UpdateMoneyAmountDTO.md b/www/apps/docs/content/references/pricing/interfaces/UpdateMoneyAmountDTO.md deleted file mode 100644 index 769d31a7fe..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/UpdateMoneyAmountDTO.md +++ /dev/null @@ -1,69 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# UpdateMoneyAmountDTO - -* - -An object that holds data to update a money amount. - -## Properties - -### amount - - `Optional` **amount**: `number` - -A number indicating the amount of this money amount. - -#### Defined in - -[packages/types/src/pricing/common/money-amount.ts:61](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L61) - -___ - -### currency\_code - - `Optional` **currency\_code**: `string` - -A string that indicates the currency code of the money amount. - -#### Defined in - -[packages/types/src/pricing/common/money-amount.ts:60](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L60) - -___ - -### id - - **id**: `string` - -A string that indicates the ID of the money amount to update. - -#### Defined in - -[packages/types/src/pricing/common/money-amount.ts:59](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L59) - -___ - -### max\_quantity - - `Optional` **max\_quantity**: `number` - -A number that indicates the maximum quantity required to be purchased for this money amount to be applied. - -#### Defined in - -[packages/types/src/pricing/common/money-amount.ts:63](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L63) - -___ - -### min\_quantity - - `Optional` **min\_quantity**: `number` - -A number that indicates the minimum quantity required to be purchased for this money amount to be applied. - -#### Defined in - -[packages/types/src/pricing/common/money-amount.ts:62](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/money-amount.ts#L62) diff --git a/www/apps/docs/content/references/pricing/interfaces/UpdateMoneyAmountDTO.mdx b/www/apps/docs/content/references/pricing/interfaces/UpdateMoneyAmountDTO.mdx new file mode 100644 index 0000000000..cea40e5fb3 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/UpdateMoneyAmountDTO.mdx @@ -0,0 +1,15 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# UpdateMoneyAmountDTO + +* + +The data to update in a money amount. The `id` is used to identify which money amount to update. + +## Properties + + diff --git a/www/apps/docs/content/references/pricing/interfaces/UpdatePriceRuleDTO.md b/www/apps/docs/content/references/pricing/interfaces/UpdatePriceRuleDTO.md deleted file mode 100644 index c2c5114562..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/UpdatePriceRuleDTO.md +++ /dev/null @@ -1,91 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# UpdatePriceRuleDTO - -An object used to specify the necessary data to update a price rule. - -## Properties - -### id - - **id**: `string` - -A string indicating the ID of the price rule to update. - -#### Defined in - -[packages/types/src/pricing/common/price-rule.ts:75](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L75) - -___ - -### price\_list\_id - - `Optional` **price\_list\_id**: `string` - -A string indicating the ID of the associated price list. - -#### Defined in - -[packages/types/src/pricing/common/price-rule.ts:88](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L88) - -___ - -### price\_set\_id - - `Optional` **price\_set\_id**: `string` - -A string indicating the ID of the associated price set. - -#### Defined in - -[packages/types/src/pricing/common/price-rule.ts:76](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L76) - -___ - -### price\_set\_money\_amount\_id - - `Optional` **price\_set\_money\_amount\_id**: `string` - -A string indicating the ID of the associated price set money amount. - -#### Defined in - -[packages/types/src/pricing/common/price-rule.ts:87](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L87) - -___ - -### priority - - `Optional` **priority**: `number` - -A number indicating the priority of the price rule in comparison to other applicable price rules. - -#### Defined in - -[packages/types/src/pricing/common/price-rule.ts:86](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L86) - -___ - -### rule\_type\_id - - `Optional` **rule\_type\_id**: `string` - -A string indicating the ID of the associated rule type. - -#### Defined in - -[packages/types/src/pricing/common/price-rule.ts:77](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L77) - -___ - -### value - - `Optional` **value**: `string` - -A string indicating the value of the price rule. - -#### Defined in - -[packages/types/src/pricing/common/price-rule.ts:85](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-rule.ts#L85) diff --git a/www/apps/docs/content/references/pricing/interfaces/UpdatePriceRuleDTO.mdx b/www/apps/docs/content/references/pricing/interfaces/UpdatePriceRuleDTO.mdx new file mode 100644 index 0000000000..baaf876073 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/UpdatePriceRuleDTO.mdx @@ -0,0 +1,13 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# UpdatePriceRuleDTO + +The data to update in a price rule. The `id` is used to identify which money amount to update. + +## Properties + + diff --git a/www/apps/docs/content/references/pricing/interfaces/UpdatePriceSetDTO.md b/www/apps/docs/content/references/pricing/interfaces/UpdatePriceSetDTO.md deleted file mode 100644 index df86e10a0e..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/UpdatePriceSetDTO.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# UpdatePriceSetDTO - -An object of expected properties when updating a price set. - -## Properties - -### id - - **id**: `string` - -A string indicating the ID of the price set to update. - -#### Defined in - -[packages/types/src/pricing/common/price-set.ts:145](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set.ts#L145) diff --git a/www/apps/docs/content/references/pricing/interfaces/UpdatePriceSetDTO.mdx b/www/apps/docs/content/references/pricing/interfaces/UpdatePriceSetDTO.mdx new file mode 100644 index 0000000000..b7f3ff5b3b --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/UpdatePriceSetDTO.mdx @@ -0,0 +1,13 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# UpdatePriceSetDTO + +The data to update in a price set. The `id` is used to identify which price set to update. + +## Properties + + diff --git a/www/apps/docs/content/references/pricing/interfaces/UpdatePriceSetMoneyAmountRulesDTO.md b/www/apps/docs/content/references/pricing/interfaces/UpdatePriceSetMoneyAmountRulesDTO.md deleted file mode 100644 index 452fff6559..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/UpdatePriceSetMoneyAmountRulesDTO.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# UpdatePriceSetMoneyAmountRulesDTO - -An object used to update a price set money amount rule. The price set money amount rule is identified by the provided `id`. - -## Properties - -### id - - **id**: `string` - -A string indicating the ID of the price set money amount rule to update. - -#### Defined in - -[packages/types/src/pricing/common/price-set-money-amount-rules.ts:48](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set-money-amount-rules.ts#L48) - -___ - -### price\_set\_money\_amount - - `Optional` **price\_set\_money\_amount**: `string` - -A string indicating the ID of a price set money amount. - -#### Defined in - -[packages/types/src/pricing/common/price-set-money-amount-rules.ts:49](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set-money-amount-rules.ts#L49) - -___ - -### rule\_type - - `Optional` **rule\_type**: `string` - -A string indicating the ID of a rule type. - -#### Defined in - -[packages/types/src/pricing/common/price-set-money-amount-rules.ts:50](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set-money-amount-rules.ts#L50) - -___ - -### value - - `Optional` **value**: `string` - -A string indicating the value of the price set money amount rule. - -#### Defined in - -[packages/types/src/pricing/common/price-set-money-amount-rules.ts:51](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/price-set-money-amount-rules.ts#L51) diff --git a/www/apps/docs/content/references/pricing/interfaces/UpdatePriceSetMoneyAmountRulesDTO.mdx b/www/apps/docs/content/references/pricing/interfaces/UpdatePriceSetMoneyAmountRulesDTO.mdx new file mode 100644 index 0000000000..4fde6f899b --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/UpdatePriceSetMoneyAmountRulesDTO.mdx @@ -0,0 +1,13 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# UpdatePriceSetMoneyAmountRulesDTO + +The data to update in a price set money amount rule. The `id` is used to identify which money amount to update. + +## Properties + + diff --git a/www/apps/docs/content/references/pricing/interfaces/UpdateRuleTypeDTO.md b/www/apps/docs/content/references/pricing/interfaces/UpdateRuleTypeDTO.md deleted file mode 100644 index d47f80ded6..0000000000 --- a/www/apps/docs/content/references/pricing/interfaces/UpdateRuleTypeDTO.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# UpdateRuleTypeDTO - -An object used when updating a rule type to specify the data to update. - -## Properties - -### default\_priority - - `Optional` **default\_priority**: `number` - -A number indicating the priority of the rule type. This is useful when calculating the price of a price set, and multiple rules satisfy the provided context. The higher the value, the higher the priority of the rule type. - -#### Defined in - -[packages/types/src/pricing/common/rule-type.ts:51](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/rule-type.ts#L51) - -___ - -### id - - **id**: `string` - -A string indicating the ID of the rule type to update. - -#### Defined in - -[packages/types/src/pricing/common/rule-type.ts:48](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/rule-type.ts#L48) - -___ - -### name - - `Optional` **name**: `string` - -A string indicating the display name of the rule type. - -#### Defined in - -[packages/types/src/pricing/common/rule-type.ts:49](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/rule-type.ts#L49) - -___ - -### rule\_attribute - - `Optional` **rule\_attribute**: `string` - -A string indicating a unique name used to later identify the rule_attribute. For example, it can be used in the `context` parameter of the `calculatePrices` method to specify a rule for calculating the price. - -#### Defined in - -[packages/types/src/pricing/common/rule-type.ts:50](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/pricing/common/rule-type.ts#L50) diff --git a/www/apps/docs/content/references/pricing/interfaces/UpdateRuleTypeDTO.mdx b/www/apps/docs/content/references/pricing/interfaces/UpdateRuleTypeDTO.mdx new file mode 100644 index 0000000000..27d08d36d9 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/UpdateRuleTypeDTO.mdx @@ -0,0 +1,13 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# UpdateRuleTypeDTO + +The data to update in a rule type. The `id` is used to identify which price set to update. + +## Properties + + diff --git a/www/apps/docs/content/references/pricing/types/Exclude.md b/www/apps/docs/content/references/pricing/types/Exclude.md deleted file mode 100644 index 7d664f9fff..0000000000 --- a/www/apps/docs/content/references/pricing/types/Exclude.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# Exclude - - **Exclude**<`T`, `U`\>: `T` extends `U` ? `never` : `T` - -Exclude from T those types that are assignable to U - -#### Type parameters - -| Name | -| :------ | -| `T` | -| `U` | - -#### Defined in - -docs-util/node_modules/typescript/lib/lib.es5.d.ts:1606 diff --git a/www/apps/docs/content/references/pricing/types/Exclude.mdx b/www/apps/docs/content/references/pricing/types/Exclude.mdx new file mode 100644 index 0000000000..6d550cd10a --- /dev/null +++ b/www/apps/docs/content/references/pricing/types/Exclude.mdx @@ -0,0 +1,15 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# Exclude + + **Exclude**<`T`, `U`\>: `T` extends `U` ? `never` : `T` + +Exclude from T those types that are assignable to U + +#### Type parameters + + diff --git a/www/apps/docs/content/references/pricing/types/JoinerRelationship.md b/www/apps/docs/content/references/pricing/types/JoinerRelationship.md deleted file mode 100644 index 6d6424bd14..0000000000 --- a/www/apps/docs/content/references/pricing/types/JoinerRelationship.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# JoinerRelationship - - **JoinerRelationship**: `Object` - -#### Type declaration - -| Name | Type | Description | -| :------ | :------ | :------ | -| `alias` | `string` | - | -| `args?` | [`Record`](Record.md)<`string`, `any`\> | Extra arguments to pass to the remoteFetchData callback | -| `foreignKey` | `string` | - | -| `inverse?` | `boolean` | In an inverted relationship the foreign key is on the other service and the primary key is on the current service | -| `isInternalService?` | `boolean` | If true, the relationship is an internal service from the medusa core TODO: Remove when there are no more "internal" services | -| `isList?` | `boolean` | Force the relationship to return a list | -| `primaryKey` | `string` | - | -| `serviceName` | `string` | - | - -#### Defined in - -[packages/types/src/joiner/index.ts:1](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/joiner/index.ts#L1) diff --git a/www/apps/docs/content/references/pricing/types/JoinerRelationship.mdx b/www/apps/docs/content/references/pricing/types/JoinerRelationship.mdx new file mode 100644 index 0000000000..a90fd5bd2a --- /dev/null +++ b/www/apps/docs/content/references/pricing/types/JoinerRelationship.mdx @@ -0,0 +1,13 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# JoinerRelationship + + **JoinerRelationship**: `Object` + +#### Type declaration + +","description":"Extra arguments to pass to the remoteFetchData callback","optional":true,"defaultValue":"","children":[]},{"name":"foreignKey","type":"`string`","description":"","optional":false,"defaultValue":"","children":[]},{"name":"inverse","type":"`boolean`","description":"In an inverted relationship the foreign key is on the other service and the primary key is on the current service","optional":true,"defaultValue":"","children":[]},{"name":"isInternalService","type":"`boolean`","description":"If true, the relationship is an internal service from the medusa core TODO: Remove when there are no more \"internal\" services","optional":true,"defaultValue":"","children":[]},{"name":"isList","type":"`boolean`","description":"Force the relationship to return a list","optional":true,"defaultValue":"","children":[]},{"name":"primaryKey","type":"`string`","description":"","optional":false,"defaultValue":"","children":[]},{"name":"serviceName","type":"`string`","description":"","optional":false,"defaultValue":"","children":[]}]} /> diff --git a/www/apps/docs/content/references/pricing/types/ModuleJoinerConfig.md b/www/apps/docs/content/references/pricing/types/ModuleJoinerConfig.md deleted file mode 100644 index a0a3832785..0000000000 --- a/www/apps/docs/content/references/pricing/types/ModuleJoinerConfig.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# ModuleJoinerConfig - - **ModuleJoinerConfig**: [`Omit`](Omit.md)<[`JoinerServiceConfig`](../interfaces/JoinerServiceConfig.md), ``"serviceName"`` \| ``"primaryKeys"`` \| ``"relationships"`` \| ``"extends"``\> & { `databaseConfig?`: { `extraFields?`: [`Record`](Record.md)<`string`, { `defaultValue?`: `string` ; `nullable?`: `boolean` ; `options?`: [`Record`](Record.md)<`string`, `unknown`\> ; `type`: ``"date"`` \| ``"time"`` \| ``"datetime"`` \| ``"bigint"`` \| ``"blob"`` \| ``"uint8array"`` \| ``"array"`` \| ``"enumArray"`` \| ``"enum"`` \| ``"json"`` \| ``"integer"`` \| ``"smallint"`` \| ``"tinyint"`` \| ``"mediumint"`` \| ``"float"`` \| ``"double"`` \| ``"boolean"`` \| ``"decimal"`` \| ``"string"`` \| ``"uuid"`` \| ``"text"`` }\> ; `idPrefix?`: `string` ; `tableName?`: `string` } ; `extends?`: { `fieldAlias?`: [`Record`](Record.md)<`string`, `string` \| { `forwardArgumentsOnPath`: `string`[] ; `path`: `string` }\> ; `relationship`: [`ModuleJoinerRelationship`](ModuleJoinerRelationship.md) ; `serviceName`: `string` }[] ; `isLink?`: `boolean` ; `isReadOnlyLink?`: `boolean` ; `linkableKeys?`: [`Record`](Record.md)<`string`, `string`\> ; `primaryKeys?`: `string`[] ; `relationships?`: [`ModuleJoinerRelationship`](ModuleJoinerRelationship.md)[] ; `schema?`: `string` ; `serviceName?`: `string` } - -#### Defined in - -[packages/types/src/modules-sdk/index.ts:132](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/modules-sdk/index.ts#L132) diff --git a/www/apps/docs/content/references/pricing/types/ModuleJoinerConfig.mdx b/www/apps/docs/content/references/pricing/types/ModuleJoinerConfig.mdx new file mode 100644 index 0000000000..d572b8f7f8 --- /dev/null +++ b/www/apps/docs/content/references/pricing/types/ModuleJoinerConfig.mdx @@ -0,0 +1,9 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# ModuleJoinerConfig + + **ModuleJoinerConfig**: [`Omit`](Omit.mdx)<[`JoinerServiceConfig`](../interfaces/JoinerServiceConfig.mdx), ``"serviceName"`` \| ``"primaryKeys"`` \| ``"relationships"`` \| ``"extends"``\> & { `databaseConfig?`: { `extraFields?`: Record<`string`, { `defaultValue?`: `string` ; `nullable?`: `boolean` ; `options?`: Record<`string`, `unknown`\> ; `type`: ``"date"`` \| ``"time"`` \| ``"datetime"`` \| ``"bigint"`` \| ``"blob"`` \| ``"uint8array"`` \| ``"array"`` \| ``"enumArray"`` \| ``"enum"`` \| ``"json"`` \| ``"integer"`` \| ``"smallint"`` \| ``"tinyint"`` \| ``"mediumint"`` \| ``"float"`` \| ``"double"`` \| ``"boolean"`` \| ``"decimal"`` \| ``"string"`` \| ``"uuid"`` \| ``"text"`` }\> ; `idPrefix?`: `string` ; `tableName?`: `string` } ; `extends?`: { `fieldAlias?`: Record<`string`, `string` \| { `forwardArgumentsOnPath`: `string`[] ; `path`: `string` }\> ; `relationship`: [`ModuleJoinerRelationship`](ModuleJoinerRelationship.mdx) ; `serviceName`: `string` }[] ; `isLink?`: `boolean` ; `isReadOnlyLink?`: `boolean` ; `linkableKeys?`: Record<`string`, `string`\> ; `primaryKeys?`: `string`[] ; `relationships?`: [`ModuleJoinerRelationship`](ModuleJoinerRelationship.mdx)[] ; `schema?`: `string` ; `serviceName?`: `string` } diff --git a/www/apps/docs/content/references/pricing/types/ModuleJoinerRelationship.md b/www/apps/docs/content/references/pricing/types/ModuleJoinerRelationship.md deleted file mode 100644 index 862d7f9614..0000000000 --- a/www/apps/docs/content/references/pricing/types/ModuleJoinerRelationship.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# ModuleJoinerRelationship - - **ModuleJoinerRelationship**: [`JoinerRelationship`](JoinerRelationship.md) & { `deleteCascade?`: `boolean` ; `isInternalService?`: `boolean` } - -#### Defined in - -[packages/types/src/modules-sdk/index.ts:212](https://github.com/medusajs/medusa/blob/daea35fe73/packages/types/src/modules-sdk/index.ts#L212) diff --git a/www/apps/docs/content/references/pricing/types/ModuleJoinerRelationship.mdx b/www/apps/docs/content/references/pricing/types/ModuleJoinerRelationship.mdx new file mode 100644 index 0000000000..49b4b85fd7 --- /dev/null +++ b/www/apps/docs/content/references/pricing/types/ModuleJoinerRelationship.mdx @@ -0,0 +1,9 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# ModuleJoinerRelationship + + **ModuleJoinerRelationship**: [`JoinerRelationship`](JoinerRelationship.mdx) & { `deleteCascade?`: `boolean` ; `isInternalService?`: `boolean` } diff --git a/www/apps/docs/content/references/pricing/types/Omit.md b/www/apps/docs/content/references/pricing/types/Omit.md deleted file mode 100644 index fd209bdc65..0000000000 --- a/www/apps/docs/content/references/pricing/types/Omit.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# Omit - - **Omit**<`T`, `K`\>: [`Pick`](Pick.md)<`T`, [`Exclude`](Exclude.md)\> - -Construct a type with the properties of T except for those in type K. - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `T` | `T` | -| `K` | extends keyof `any` | - -#### Defined in - -docs-util/node_modules/typescript/lib/lib.es5.d.ts:1616 diff --git a/www/apps/docs/content/references/pricing/types/Omit.mdx b/www/apps/docs/content/references/pricing/types/Omit.mdx new file mode 100644 index 0000000000..d7af53cec1 --- /dev/null +++ b/www/apps/docs/content/references/pricing/types/Omit.mdx @@ -0,0 +1,15 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# Omit + + **Omit**<`T`, `K`\>: [`Pick`](Pick.mdx)<`T`, [`Exclude`](Exclude.mdx)\> + +Construct a type with the properties of T except for those in type K. + +#### Type parameters + + diff --git a/www/apps/docs/content/references/pricing/types/Pick.md b/www/apps/docs/content/references/pricing/types/Pick.md deleted file mode 100644 index e11b12b36a..0000000000 --- a/www/apps/docs/content/references/pricing/types/Pick.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# Pick - - **Pick**<`T`, `K`\>: { [P in K]: T[P] } - -From T, pick a set of properties whose keys are in the union K - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `T` | `T` | -| `K` | extends keyof `T` | - -#### Defined in - -docs-util/node_modules/typescript/lib/lib.es5.d.ts:1592 diff --git a/www/apps/docs/content/references/pricing/types/Pick.mdx b/www/apps/docs/content/references/pricing/types/Pick.mdx new file mode 100644 index 0000000000..a851fa44c7 --- /dev/null +++ b/www/apps/docs/content/references/pricing/types/Pick.mdx @@ -0,0 +1,15 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# Pick + + **Pick**<`T`, `K`\>: { [P in K]: T[P] } + +From T, pick a set of properties whose keys are in the union K + +#### Type parameters + + diff --git a/www/apps/docs/content/references/pricing/types/Record.md b/www/apps/docs/content/references/pricing/types/Record.md deleted file mode 100644 index 70e1da4f7a..0000000000 --- a/www/apps/docs/content/references/pricing/types/Record.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -displayed_sidebar: pricingReference ---- - -# Record - - **Record**<`K`, `T`\>: { [P in K]: T } - -Construct a type with a set of properties K of type T - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `K` | extends keyof `any` | -| `T` | `T` | - -#### Defined in - -docs-util/node_modules/typescript/lib/lib.es5.d.ts:1599 diff --git a/www/apps/docs/content/references/pricing/types/Record.mdx b/www/apps/docs/content/references/pricing/types/Record.mdx new file mode 100644 index 0000000000..7e960964ff --- /dev/null +++ b/www/apps/docs/content/references/pricing/types/Record.mdx @@ -0,0 +1,15 @@ +--- +displayed_sidebar: pricingReference +--- + +import ParameterTypes from "@site/src/components/ParameterTypes" + +# Record + + **Record**<`K`, `T`\>: { [P in K]: T } + +Construct a type with a set of properties K of type T + +#### Type parameters + + diff --git a/www/apps/docs/src/components/ParameterTypes/Items/index.tsx b/www/apps/docs/src/components/ParameterTypes/Items/index.tsx new file mode 100644 index 0000000000..693ae7934a --- /dev/null +++ b/www/apps/docs/src/components/ParameterTypes/Items/index.tsx @@ -0,0 +1,127 @@ +import { DetailsSummary, InlineCode, MarkdownContent } from "docs-ui" +import React from "react" +import Details from "../../../theme/Details" +import clsx from "clsx" +import { Parameter } from ".." + +type ParameterTypesItemsProps = { + parameters: Parameter[] + level?: number +} + +const ParameterTypesItems = ({ + parameters, + level = 1, +}: ParameterTypesItemsProps) => { + function getItemClassNames(details = true) { + return clsx( + level < 3 && [ + "odd:[&:not(:first-child):not(:last-child)]:!border-y last:not(:first-child):!border-t", + "first:!border-t-0 first:not(:last-child):!border-b last:!border-b-0 even:!border-y-0", + ], + details && level == 1 && `group/parameter`, + !details && + level == 1 && + `group-open/parameter:border-solid group-open/parameter:border-0 group-open/parameter:border-b`, + level >= 3 && "!border-0" + ) + } + function getSummary(parameter: Parameter, key: number, nested = true) { + return ( + + + {parameter.description} + + {parameter.defaultValue && ( +

+ Default: {parameter.defaultValue} +

+ )} + + ) : undefined + } + expandable={parameter.children.length > 0} + className={clsx( + getItemClassNames(false), + level < 3 && "!p-1", + !nested && "cursor-default", + level >= 3 && [ + "pl-1 mt-1", + "mx-1 relative before:content-[''] before:h-full before:w-0.25", + "before:absolute before:top-0 before:left-0", + "before:bg-medusa-fg-muted before:rounded-full", + ] + )} + onClick={(e) => { + const targetElm = e.target as HTMLElement + if (targetElm.tagName.toLowerCase() === "a") { + window.location.href = + targetElm.getAttribute("href") || window.location.href + return + } + }} + > +
+ {parameter.name} + + + {parameter.type} + + + {parameter.optional === false && ( + + Required + + )} +
+
+ ) + } + + return ( +
1 && "bg-docs-bg-surface rounded", + level >= 3 && "mb-1" + )} + > + {parameters.map((parameter, key) => { + return ( + <> + {parameter.children.length > 0 && ( +
+ {parameter.children && ( + + )} +
+ )} + {parameter.children.length === 0 && + getSummary(parameter, key, false)} + + ) + })} +
+ ) +} + +export default ParameterTypesItems diff --git a/www/apps/docs/src/components/ParameterTypes/index.tsx b/www/apps/docs/src/components/ParameterTypes/index.tsx new file mode 100644 index 0000000000..388917fad6 --- /dev/null +++ b/www/apps/docs/src/components/ParameterTypes/index.tsx @@ -0,0 +1,33 @@ +import clsx from "clsx" +import React from "react" +import ParameterTypesItems from "./Items" + +export type Parameter = { + name: string + type: string + optional?: boolean + defaultValue?: string + description?: string + children?: Parameter[] +} + +type ParameterTypesType = { + parameters: Parameter[] +} & React.HTMLAttributes + +const ParameterTypes = ({ + parameters, + className, + ...props +}: ParameterTypesType) => { + return ( +
+ +
+ ) +} + +export default ParameterTypes diff --git a/www/packages/docs-ui/src/components/CodeMdx/index.tsx b/www/packages/docs-ui/src/components/CodeMdx/index.tsx index 52c63ed044..e2101f8a72 100644 --- a/www/packages/docs-ui/src/components/CodeMdx/index.tsx +++ b/www/packages/docs-ui/src/components/CodeMdx/index.tsx @@ -17,18 +17,13 @@ export const CodeMdx = ({ className, children }: CodeMdxProps) => { const match = /language-(\w+)/.exec(className || "") + const codeContent = Array.isArray(children) + ? (children[0] as string) + : (children as string) + if (match) { - return ( - - ) + return } - return {children} + return {codeContent} } diff --git a/www/packages/docs-ui/src/components/Details/Summary/index.tsx b/www/packages/docs-ui/src/components/Details/Summary/index.tsx index a43f9dea2e..dc0ecfe5a9 100644 --- a/www/packages/docs-ui/src/components/Details/Summary/index.tsx +++ b/www/packages/docs-ui/src/components/Details/Summary/index.tsx @@ -3,8 +3,8 @@ import clsx from "clsx" import { PlusMini } from "@medusajs/icons" export type DetailsSummaryProps = { - title: React.ReactNode - subtitle?: string + title?: React.ReactNode + subtitle?: React.ReactNode badge?: React.ReactNode expandable?: boolean open?: boolean @@ -28,7 +28,9 @@ export const DetailsSummary = ({ className={clsx( "py-docs_0.75 flex items-center justify-between", expandable && "cursor-pointer", - !expandable && "border-medusa-border-base border-y", + !expandable && + "border-medusa-border-base border-y border-solid border-x-0", + (expandable || badge) && "gap-0.5", "no-marker", className )} @@ -44,7 +46,7 @@ export const DetailsSummary = ({ {title || children} {subtitle && ( - + {subtitle} )} diff --git a/www/packages/docs-ui/src/components/Details/index.tsx b/www/packages/docs-ui/src/components/Details/index.tsx index b0cb84fc5f..cbeec2a32b 100644 --- a/www/packages/docs-ui/src/components/Details/index.tsx +++ b/www/packages/docs-ui/src/components/Details/index.tsx @@ -10,6 +10,7 @@ export type DetailsProps = { openInitial?: boolean summaryContent?: React.ReactNode summaryElm?: React.ReactNode + heightAnimation?: boolean } & React.HTMLAttributes export const Details = ({ @@ -17,13 +18,23 @@ export const Details = ({ summaryContent, summaryElm, children, + heightAnimation = false, ...props }: DetailsProps) => { const [open, setOpen] = useState(openInitial) const [showContent, setShowContent] = useState(openInitial) const ref = useRef(null) - const handleToggle = () => { + const handleToggle = (e: React.MouseEvent) => { + const targetElm = e.target as HTMLElement + if (targetElm.tagName.toLowerCase() === "a") { + window.location.href = + targetElm.getAttribute("href") || window.location.href + return + } + if (targetElm.tagName.toLowerCase() === "code") { + return + } if (open) { setShowContent(false) } else { @@ -70,18 +81,45 @@ export const Details = ({ in={showContent} timeout={150} onEnter={(node: HTMLElement) => { - node.classList.add( - "!mb-docs_2", - "!mt-0", - "translate-y-docs_1", - "transition-transform" - ) + if (heightAnimation) { + node.classList.add("transition-[height]") + node.style.height = `0px` + } else { + node.classList.add( + "!mb-docs_2", + "!mt-0", + "translate-y-docs_1", + "transition-transform" + ) + } + }} + onEntering={(node: HTMLElement) => { + if (heightAnimation) { + node.style.height = `${node.scrollHeight}px` + } + }} + onEntered={(node: HTMLElement) => { + if (heightAnimation) { + node.style.height = `auto` + } }} onExit={(node: HTMLElement) => { - node.classList.add("transition-transform", "!-translate-y-docs_1") - setTimeout(() => { - setOpen(false) - }, 100) + if (heightAnimation) { + node.style.height = `${node.scrollHeight}px` + } else { + node.classList.add("transition-transform", "!-translate-y-docs_1") + setTimeout(() => { + setOpen(false) + }, 100) + } + }} + onExiting={(node: HTMLElement) => { + if (heightAnimation) { + node.style.height = `0px` + setTimeout(() => { + setOpen(false) + }, 100) + } }} > }> diff --git a/www/packages/docs-ui/src/components/MarkdownContent/index.tsx b/www/packages/docs-ui/src/components/MarkdownContent/index.tsx index dceba47d71..f0b172a1c4 100644 --- a/www/packages/docs-ui/src/components/MarkdownContent/index.tsx +++ b/www/packages/docs-ui/src/components/MarkdownContent/index.tsx @@ -6,7 +6,10 @@ import clsx from "clsx" export type MarkdownContentProps = ReactMarkdownOptions -export const MarkdownContent = ({ children }: MarkdownContentProps) => { +export const MarkdownContent = ({ + children, + ...props +}: MarkdownContentProps) => { return ( { ) }, }} + {...props} > {children} diff --git a/www/packages/tailwind/base.tailwind.config.js b/www/packages/tailwind/base.tailwind.config.js index e2a6531522..4a1326a33a 100644 --- a/www/packages/tailwind/base.tailwind.config.js +++ b/www/packages/tailwind/base.tailwind.config.js @@ -675,6 +675,9 @@ module.exports = { ".animate-fast": { animationDuration: "300ms", }, + ".animate-fastest": { + animationDuration: "150ms", + }, ".clip": { clipPath: "inset(0)", },