From f0af8ecc89519b00a1093b977422982ade306510 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Wed, 11 Oct 2023 14:08:19 +0300 Subject: [PATCH] docs: generate pricing module reference (#5349) * docs: generate pricing module reference * added notes about new configurations --- docs-util/packages/typedoc-config/modules.js | 67 +++-- docs-util/packages/typedoc-config/pricing.js | 64 +++- .../typedoc-plugin-frontmatter/README.md | 2 + .../typedoc-plugin-frontmatter/package.json | 5 +- .../typedoc-plugin-frontmatter/src/index.ts | 14 +- .../typedoc-plugin-markdown-medusa/README.md | 3 + .../package.json | 3 +- .../src/render-utils.ts | 4 + .../src/resources/helpers/comments.ts | 26 +- .../src/resources/helpers/frontmatter.ts | 47 +++ .../helpers/reflection-description.ts | 16 + .../src/resources/helpers/title-level.ts | 17 +- .../src/resources/partials/title.hbs | 6 +- .../src/resources/templates/index.hbs | 6 + .../src/resources/templates/reflection.hbs | 6 + .../resources/templates/reflection.member.hbs | 6 + .../src/theme.ts | 99 ++----- .../src/types.ts | 2 + .../src/utils/reflection-template-strings.ts | 25 ++ docs-util/yarn.lock | 9 + .../docs/content/references/pricing/.nojekyll | 1 + .../IPricingModuleService.addPrices.md | 258 +++++++++++++++++ .../methods/IPricingModuleService.addRules.md | 144 +++++++++ .../IPricingModuleService.calculatePrices.md | 66 +++++ .../methods/IPricingModuleService.create.md | 273 ++++++++++++++++++ .../IPricingModuleService.createCurrencies.md | 67 +++++ ...PricingModuleService.createMoneyAmounts.md | 83 ++++++ .../IPricingModuleService.createPriceRules.md | 103 +++++++ ...eService.createPriceSetMoneyAmountRules.md | 84 ++++++ .../IPricingModuleService.createRuleTypes.md | 65 +++++ .../methods/IPricingModuleService.delete.md | 42 +++ .../IPricingModuleService.deleteCurrencies.md | 43 +++ ...PricingModuleService.deleteMoneyAmounts.md | 44 +++ .../IPricingModuleService.deletePriceRules.md | 44 +++ ...eService.deletePriceSetMoneyAmountRules.md | 42 +++ .../IPricingModuleService.deleteRuleTypes.md | 42 +++ .../methods/IPricingModuleService.list.md | 172 +++++++++++ .../IPricingModuleService.listAndCount.md | 173 +++++++++++ ...ingModuleService.listAndCountCurrencies.md | 121 ++++++++ ...gModuleService.listAndCountMoneyAmounts.md | 160 ++++++++++ ...ingModuleService.listAndCountPriceRules.md | 167 +++++++++++ ...ce.listAndCountPriceSetMoneyAmountRules.md | 163 +++++++++++ ...cingModuleService.listAndCountRuleTypes.md | 150 ++++++++++ .../IPricingModuleService.listCurrencies.md | 120 ++++++++ .../IPricingModuleService.listMoneyAmounts.md | 159 ++++++++++ .../IPricingModuleService.listPriceRules.md | 167 +++++++++++ ...uleService.listPriceSetMoneyAmountRules.md | 161 +++++++++++ .../IPricingModuleService.listRuleTypes.md | 149 ++++++++++ .../IPricingModuleService.removeRules.md | 49 ++++ .../methods/IPricingModuleService.retrieve.md | 101 +++++++ .../IPricingModuleService.retrieveCurrency.md | 88 ++++++ ...ricingModuleService.retrieveMoneyAmount.md | 98 +++++++ ...IPricingModuleService.retrievePriceRule.md | 106 +++++++ ...ervice.retrievePriceSetMoneyAmountRules.md | 100 +++++++ .../IPricingModuleService.retrieveRuleType.md | 83 ++++++ .../IPricingModuleService.updateCurrencies.md | 65 +++++ ...PricingModuleService.updateMoneyAmounts.md | 72 +++++ .../IPricingModuleService.updatePriceRules.md | 94 ++++++ ...eService.updatePriceSetMoneyAmountRules.md | 83 ++++++ .../IPricingModuleService.updateRuleTypes.md | 65 +++++ .../docs/content/references/pricing/index.md | 56 ++++ .../pricing/interfaces/AddPricesDTO.md | 31 ++ .../pricing/interfaces/AddRulesDTO.md | 31 ++ .../pricing/interfaces/BaseFilterable.md | 53 ++++ .../interfaces/CalculatedPriceSetDTO.md | 67 +++++ .../references/pricing/interfaces/Context.md | 75 +++++ .../pricing/interfaces/CreateCurrencyDTO.md | 56 ++++ .../interfaces/CreateMoneyAmountDTO.md | 87 ++++++ .../pricing/interfaces/CreatePriceRuleDTO.md | 103 +++++++ .../pricing/interfaces/CreatePriceSetDTO.md | 32 ++ .../CreatePriceSetMoneyAmountRulesDTO.md | 43 +++ .../pricing/interfaces/CreatePricesDTO.md | 121 ++++++++ .../pricing/interfaces/CreateRuleTypeDTO.md | 55 ++++ .../pricing/interfaces/CurrencyDTO.md | 56 ++++ .../interfaces/FilterableCurrencyProps.md | 57 ++++ .../interfaces/FilterableMoneyAmountProps.md | 69 +++++ .../interfaces/FilterablePriceRuleProps.md | 93 ++++++ ...FilterablePriceSetMoneyAmountRulesProps.md | 93 ++++++ .../interfaces/FilterablePriceSetProps.md | 69 +++++ .../interfaces/FilterableRuleTypeProps.md | 81 ++++++ .../pricing/interfaces/FindConfig.md | 92 ++++++ .../interfaces/IPricingModuleService.md | 53 ++++ .../pricing/interfaces/JoinerServiceConfig.md | 81 ++++++ .../interfaces/JoinerServiceConfigAlias.md | 27 ++ .../pricing/interfaces/MoneyAmountDTO.md | 79 +++++ .../pricing/interfaces/PriceRuleDTO.md | 127 ++++++++ .../pricing/interfaces/PriceSetDTO.md | 43 +++ .../interfaces/PriceSetMoneyAmountDTO.md | 55 ++++ .../interfaces/PriceSetMoneyAmountRulesDTO.md | 55 ++++ .../pricing/interfaces/PricingContext.md | 26 ++ .../pricing/interfaces/PricingFilters.md | 19 ++ .../interfaces/RemovePriceSetRulesDTO.md | 31 ++ .../pricing/interfaces/RuleTypeDTO.md | 55 ++++ .../pricing/interfaces/UpdateCurrencyDTO.md | 56 ++++ .../interfaces/UpdateMoneyAmountDTO.md | 69 +++++ .../pricing/interfaces/UpdatePriceRuleDTO.md | 91 ++++++ .../pricing/interfaces/UpdatePriceSetDTO.md | 19 ++ .../UpdatePriceSetMoneyAmountRulesDTO.md | 55 ++++ .../pricing/interfaces/UpdateRuleTypeDTO.md | 55 ++++ .../references/pricing/types/Exclude.md | 20 ++ .../pricing/types/JoinerRelationship.md | 24 ++ .../pricing/types/ModuleJoinerConfig.md | 11 + .../pricing/types/ModuleJoinerRelationship.md | 11 + .../content/references/pricing/types/Omit.md | 20 ++ .../content/references/pricing/types/Pick.md | 20 ++ .../references/pricing/types/Record.md | 20 ++ www/apps/docs/sidebars.js | 46 +++ .../theme/DocPage/Layout/Sidebar/index.tsx | 4 +- www/apps/docs/src/theme/MDXComponents/H1.tsx | 28 ++ .../docs/src/theme/MDXComponents/index.tsx | 2 + 110 files changed, 7170 insertions(+), 146 deletions(-) create mode 100644 docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/frontmatter.ts create mode 100644 docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/reflection-description.ts create mode 100644 docs-util/packages/typedoc-plugin-markdown-medusa/src/utils/reflection-template-strings.ts create mode 100644 www/apps/docs/content/references/pricing/.nojekyll create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.addPrices.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.addRules.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.calculatePrices.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.create.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createCurrencies.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createMoneyAmounts.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createPriceRules.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createPriceSetMoneyAmountRules.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createRuleTypes.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.delete.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deleteCurrencies.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deleteMoneyAmounts.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deletePriceRules.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deletePriceSetMoneyAmountRules.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deleteRuleTypes.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.list.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCount.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountCurrencies.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountMoneyAmounts.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountPriceRules.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountPriceSetMoneyAmountRules.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountRuleTypes.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listCurrencies.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listMoneyAmounts.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listPriceRules.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listPriceSetMoneyAmountRules.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listRuleTypes.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.removeRules.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieve.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieveCurrency.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieveMoneyAmount.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrievePriceRule.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrievePriceSetMoneyAmountRules.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieveRuleType.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updateCurrencies.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updateMoneyAmounts.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updatePriceRules.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updatePriceSetMoneyAmountRules.md create mode 100644 www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updateRuleTypes.md create mode 100644 www/apps/docs/content/references/pricing/index.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/AddPricesDTO.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/AddRulesDTO.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/BaseFilterable.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/CalculatedPriceSetDTO.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/Context.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/CreateCurrencyDTO.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/CreateMoneyAmountDTO.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/CreatePriceRuleDTO.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/CreatePriceSetDTO.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/CreatePriceSetMoneyAmountRulesDTO.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/CreatePricesDTO.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/CreateRuleTypeDTO.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/CurrencyDTO.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/FilterableCurrencyProps.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/FilterableMoneyAmountProps.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/FilterablePriceRuleProps.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/FilterablePriceSetMoneyAmountRulesProps.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/FilterablePriceSetProps.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/FilterableRuleTypeProps.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/FindConfig.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/IPricingModuleService.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/JoinerServiceConfig.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/JoinerServiceConfigAlias.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/MoneyAmountDTO.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/PriceRuleDTO.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/PriceSetDTO.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/PriceSetMoneyAmountDTO.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/PriceSetMoneyAmountRulesDTO.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/PricingContext.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/PricingFilters.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/RemovePriceSetRulesDTO.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/RuleTypeDTO.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/UpdateCurrencyDTO.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/UpdateMoneyAmountDTO.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/UpdatePriceRuleDTO.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/UpdatePriceSetDTO.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/UpdatePriceSetMoneyAmountRulesDTO.md create mode 100644 www/apps/docs/content/references/pricing/interfaces/UpdateRuleTypeDTO.md create mode 100644 www/apps/docs/content/references/pricing/types/Exclude.md create mode 100644 www/apps/docs/content/references/pricing/types/JoinerRelationship.md create mode 100644 www/apps/docs/content/references/pricing/types/ModuleJoinerConfig.md create mode 100644 www/apps/docs/content/references/pricing/types/ModuleJoinerRelationship.md create mode 100644 www/apps/docs/content/references/pricing/types/Omit.md create mode 100644 www/apps/docs/content/references/pricing/types/Pick.md create mode 100644 www/apps/docs/content/references/pricing/types/Record.md create mode 100644 www/apps/docs/src/theme/MDXComponents/H1.tsx diff --git a/docs-util/packages/typedoc-config/modules.js b/docs-util/packages/typedoc-config/modules.js index dbc2b92a45..3f2822ec66 100644 --- a/docs-util/packages/typedoc-config/modules.js +++ b/docs-util/packages/typedoc-config/modules.js @@ -10,40 +10,46 @@ module.exports = ({ tsconfigPath = "", moduleName = "", documentsToFormat = [], - additionalFormatting = {}, extraOptions = {}, }) => { const formatting = {} - documentsToFormat.forEach((document) => { - formatting[document] = { - reflectionTitle: { - kind: false, - typeParameters: false, - suffix: "Reference", - }, - expandMembers: true, - showCommentsAsHeader: true, - parameterStyle: "list", - useTsLinkResolution: false, - showReturnSignature: false, - sections: { - reflection_typeParameters: false, - member_declaration_typeParameters: false, - reflection_implements: false, - reflection_implementedBy: false, - reflection_callable: false, - reflection_indexable: false, - member_signature_typeParameters: false, - member_signature_sources: false, - member_signature_title: false, - }, - reflectionGroups: { - Constructors: false, - Properties: false, - }, - ...additionalFormatting, + documentsToFormat.forEach( + ({ pattern, additionalFormatting, useDefaults = false }) => { + formatting[pattern] = { + ...(!useDefaults + ? { + reflectionTitle: { + kind: false, + typeParameters: false, + suffix: "Reference", + }, + expandMembers: true, + showCommentsAsHeader: true, + parameterStyle: "list", + useTsLinkResolution: false, + showReturnSignature: false, + sections: { + reflection_typeParameters: false, + member_declaration_typeParameters: false, + reflection_implements: false, + reflection_implementedBy: false, + reflection_callable: false, + reflection_indexable: false, + member_signature_typeParameters: false, + member_signature_sources: false, + member_signature_title: false, + title_reflectionPath: false, + }, + reflectionGroups: { + Constructors: false, + Properties: false, + }, + } + : {}), + ...additionalFormatting, + } } - }) + ) return { ...globalTypedocOptions, entryPoints: [path.join(pathPrefix, entryPointPath)], @@ -66,6 +72,7 @@ module.exports = ({ ], hideMembersSymbol: true, formatting, + allReflectionsHaveOwnDocument: true, ...extraOptions, } } diff --git a/docs-util/packages/typedoc-config/pricing.js b/docs-util/packages/typedoc-config/pricing.js index 757524fed7..d67e42cb4d 100644 --- a/docs-util/packages/typedoc-config/pricing.js +++ b/docs-util/packages/typedoc-config/pricing.js @@ -5,14 +5,62 @@ module.exports = modulesConfig({ entryPointPath: "packages/types/src/pricing/service.ts", outPath: "www/apps/docs/content/references/pricing", moduleName: "Pricing Module Reference", - documentsToFormat: ["IPricingModuleService"], - additionalFormatting: { - reflectionDescription: - "This document provides a reference to the `IPricingModuleService` interface’s methods. This is the interface developers use to use the functionalities provided by the Pricing Module.", - }, - extraOptions: { - frontmatterData: { - displayed_sidebar: "modules", + documentsToFormat: [ + { + pattern: "IPricingModuleService.md", + additionalFormatting: { + reflectionDescription: + "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.", + frontmatterData: { + displayed_sidebar: "pricingReference", + badge: { + variant: "orange", + text: "Beta", + }, + slug: "/references/pricing", + // hide_table_of_contents: true, + }, + }, }, + { + pattern: "IPricingModuleService/methods", + additionalFormatting: { + reflectionDescription: + "This documentation provides a reference to the {{alias}} {{kind}}. This belongs to the Pricing Module.", + frontmatterData: { + displayed_sidebar: "pricingReference", + badge: { + variant: "orange", + text: "Beta", + }, + slug: "/references/pricing/{{alias}}", + sidebar_label: "{{alias}}", + }, + reflectionTitle: { + kind: false, + typeParameters: false, + suffix: "- Pricing Module Reference", + }, + }, + }, + { + pattern: "*", + useDefaults: true, + additionalFormatting: { + frontmatterData: { + displayed_sidebar: "pricingReference", + }, + }, + }, + ], + extraOptions: { + // frontmatterData: { + // displayed_sidebar: "modules", + // badge: { + // variant: "orange", + // text: "Beta", + // }, + // // hide_table_of_contents: true, + // }, }, }) diff --git a/docs-util/packages/typedoc-plugin-frontmatter/README.md b/docs-util/packages/typedoc-plugin-frontmatter/README.md index 77c5f470e2..1edd40f93c 100644 --- a/docs-util/packages/typedoc-plugin-frontmatter/README.md +++ b/docs-util/packages/typedoc-plugin-frontmatter/README.md @@ -2,6 +2,8 @@ A Typedoc plugin that allows inserting frontmatter key-value pairs at the top of the exported Markdown files. +> For more flexibility in what pages to apply the frontmatter data to, for example, to specify different frontmatter for different pages, ues the [`typedoc-plugin-markdown-medusa` plugin's `frontmatterData` option](../typedoc-plugin-markdown-medusa/README.md#configurations) + ## Configurations The following options are optional and can be used to customize the configurations of the plugin. diff --git a/docs-util/packages/typedoc-plugin-frontmatter/package.json b/docs-util/packages/typedoc-plugin-frontmatter/package.json index 51b7ab0ed6..b2523badf0 100644 --- a/docs-util/packages/typedoc-plugin-frontmatter/package.json +++ b/docs-util/packages/typedoc-plugin-frontmatter/package.json @@ -30,5 +30,8 @@ "packages", "monorepo", "typedoc" - ] + ], + "dependencies": { + "yaml": "^2.3.2" + } } diff --git a/docs-util/packages/typedoc-plugin-frontmatter/src/index.ts b/docs-util/packages/typedoc-plugin-frontmatter/src/index.ts index aec61dacb2..5e8afe573c 100644 --- a/docs-util/packages/typedoc-plugin-frontmatter/src/index.ts +++ b/docs-util/packages/typedoc-plugin-frontmatter/src/index.ts @@ -1,5 +1,6 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import { Application, PageEvent, ParameterType } from "typedoc" +import { stringify } from "yaml" export function load(app: Application) { app.options.addDeclaration({ @@ -35,20 +36,15 @@ export function load(app: Application) { if (typeof frontmatterData === "string") { frontmatterData = JSON.parse(frontmatterData) } - const frontmatterDataEntries = Object.entries(frontmatterData) - if (!frontmatterDataEntries.length || !pattern.test(page.filename)) { + if (!pattern.test(page.filename) || !Object.keys(frontmatterData).length) { return } - let frontmatterStr = `---\n` + const frontmatterStr = stringify(frontmatterData) - for (const [key, value] of frontmatterDataEntries) { - frontmatterStr += `${key}: ${value}\n` + if (frontmatterStr.length) { + page.contents = `---\n` + frontmatterStr + `---\n\n` + page.contents } - - frontmatterStr += `---\n\n` - - page.contents = frontmatterStr + page.contents }) } diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/README.md b/docs-util/packages/typedoc-plugin-markdown-medusa/README.md index 32bec5b0bc..05b48ff2bf 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/README.md +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/README.md @@ -16,8 +16,11 @@ Aside from the options detailed in [typedoc-plugin-markdown](https://github.com/ - `reflectionDescription`: (optional) a string used to add description in a documentation page after the page's title. - `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`. - `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. + - ## Build Plugin diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/package.json b/docs-util/packages/typedoc-plugin-markdown-medusa/package.json index 9644f95d91..0bd6a32b85 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/package.json +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/package.json @@ -32,6 +32,7 @@ "typedoc" ], "dependencies": { - "handlebars": "^4.7.8" + "handlebars": "^4.7.8", + "yaml": "^2.3.2" } } 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 ec39b35c06..c972332728 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 @@ -35,6 +35,8 @@ import typeParameterHelper from "./resources/helpers/type-parameter" import parameterListHelper from "./resources/helpers/parameter-list" 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 { MarkdownTheme } from "./theme" const TEMPLATE_PATH = path.join(__dirname, "resources", "templates") @@ -98,4 +100,6 @@ export function registerHelpers(theme: MarkdownTheme) { parameterListHelper() parameterHelper(theme) debugHelper() + frontmatterHelper(theme) + reflectionDescriptionHelper(theme) } 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 b1af6c89d6..565b03e33f 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 @@ -13,7 +13,8 @@ export default function (theme: MarkdownTheme) { commentLevel = 4, parent = null ) { - const { showCommentsAsHeader } = theme.getFormattingOptionsForLocation() + const { showCommentsAsHeader, showCommentsAsDetails } = + theme.getFormattingOptionsForLocation() const md: string[] = [] if (showSummary && comment.summary) { @@ -26,16 +27,19 @@ export default function (theme: MarkdownTheme) { if (showTags && comment.blockTags?.length) { const tags = filteredTags.map((tag) => { - return `${ - showCommentsAsHeader - ? `${Handlebars.helpers.titleLevel.call( - parent || comment, - commentLevel - )} ` - : "**`" - }${camelToTitleCase(tag.tag.substring(1))}${ - showCommentsAsHeader ? "" : "`**" - }\n\n${Handlebars.helpers.comment(tag.content)}` + 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}` + } }) md.push(tags.join("\n\n")) } diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/frontmatter.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/frontmatter.ts new file mode 100644 index 0000000000..7af7af946a --- /dev/null +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/frontmatter.ts @@ -0,0 +1,47 @@ +import * as Handlebars from "handlebars" +import { MarkdownTheme } from "../../theme" +import { stringify } from "yaml" +import { replaceTemplateVariables } from "../../utils/reflection-template-strings" +import { Reflection } from "typedoc" + +export default function (theme: MarkdownTheme) { + Handlebars.registerHelper("frontmatter", function (this: Reflection) { + const { frontmatterData } = theme.getFormattingOptionsForLocation() + + if (!frontmatterData) { + return "" + } + + // format frontmatter data in case it has any template variables + + return `---\n${stringify( + resolveFrontmatterVariables(frontmatterData, this) + ).trim()}\n---\n\n` + }) +} + +function resolveFrontmatterVariables( + frontmatterData: Record, + reflection: Reflection +): Record { + const tempFrontmatterData = Object.assign({}, frontmatterData) + Object.keys(tempFrontmatterData).forEach((key) => { + const value = tempFrontmatterData[key] + if (!value) { + return + } + + switch (typeof value) { + case "object": + tempFrontmatterData[key] = resolveFrontmatterVariables( + value as Record, + reflection + ) + break + case "string": + tempFrontmatterData[key] = replaceTemplateVariables(reflection, value) + } + }) + + return tempFrontmatterData +} diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/reflection-description.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/reflection-description.ts new file mode 100644 index 0000000000..b8ca22a534 --- /dev/null +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/reflection-description.ts @@ -0,0 +1,16 @@ +import * as Handlebars from "handlebars" +import { MarkdownTheme } from "../../theme" +import { Reflection } from "typedoc" +import { replaceTemplateVariables } from "../../utils/reflection-template-strings" + +export default function (theme: MarkdownTheme) { + Handlebars.registerHelper( + "reflectionDescription", + function (this: Reflection) { + const { reflectionDescription } = theme.getFormattingOptionsForLocation() + + // parse variables in description + return replaceTemplateVariables(this, reflectionDescription) + } + ) +} diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/title-level.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/title-level.ts index c33998b307..5e2360c271 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/title-level.ts +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/title-level.ts @@ -9,6 +9,12 @@ export default function (theme: MarkdownTheme) { const { expandMembers, sections } = theme.getFormattingOptionsForLocation() + if (!expandMembers) { + return Array(originalLevel).fill("#").join("") + } + + const { allReflectionsHaveOwnDocument } = theme + let isSignatureChild = false if ( sections && @@ -22,8 +28,15 @@ export default function (theme: MarkdownTheme) { (this.parent.signatures as SignatureReflection[]).length > 1 } - const level = - expandMembers && !isSignatureChild ? originalLevel - 1 : originalLevel + const numberToSubtract = allReflectionsHaveOwnDocument + ? isSignatureChild + ? 1 + : 2 + : isSignatureChild + ? 0 + : 1 + + const level = originalLevel - numberToSubtract return Array(level).fill("#").join("") } diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/partials/title.hbs b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/partials/title.hbs index 2cb892ed06..b321539d69 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/partials/title.hbs +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/partials/title.hbs @@ -4,7 +4,11 @@ {{/ifShowPageTitle}} -{{{getFormattingOption "reflectionDescription"}}} +{{#with model}} + +{{{reflectionDescription}}} + +{{/with}} {{#if (sectionEnabled "title_reflectionPath")}} 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 19a40da27f..659c738797 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,3 +1,9 @@ +{{#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 4261c213ed..65df6ad136 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,3 +1,9 @@ +{{#with model}} + +{{{frontmatter}}} + +{{/with}} + {{> header}} {{> title}} 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 78129be63b..ffe2958f96 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,3 +1,9 @@ +{{#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 ae69472585..ce4d4cc49a 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/theme.ts +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/theme.ts @@ -13,7 +13,6 @@ import { Theme, UrlMapping, } from "typedoc" -import { getKindPlural } from "./groups" import { indexTemplate, reflectionMemberTemplate, @@ -26,7 +25,6 @@ import { FormattingOptionType, FormattingOptionsType, Mapping, - NavigationItem, ObjectLiteralDeclarationStyle, } from "./types" @@ -139,9 +137,9 @@ export class MarkdownTheme extends Theme { reflection: DeclarationReflection, urls: UrlMapping[] ): UrlMapping[] { - const mapping = this.mappings.find((mapping) => - reflection.kindOf(mapping.kind) - ) + const mapping = this.getMappings( + reflection.parent?.isProject() ? "" : reflection.parent?.getAlias() + ).find((mapping) => reflection.kindOf(mapping.kind)) if (mapping) { if (!reflection.url || !MarkdownTheme.URL_PREFIX.test(reflection.url)) { const url = this.toUrl(mapping, reflection) @@ -266,103 +264,36 @@ export class MarkdownTheme extends Theme { } } - getNavigation(project: ProjectReflection) { - const urls = this.getUrls(project) - - const getUrlMapping = (name: string) => { - if (!name) { - return "" - } - return urls.find((url) => url.model.name === name) - } - - const createNavigationItem = ( - title: string, - url: string | undefined, - isLabel: boolean, - children: NavigationItem[] = [] - ) => { - const navigationItem = new NavigationItem(title, url) - navigationItem.isLabel = isLabel - navigationItem.children = children - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const { reflection, parent, ...filteredNavigationItem } = navigationItem - return filteredNavigationItem as NavigationItem - } - const navigation = createNavigationItem(project.name, undefined, false) - const hasReadme = !this.readme.endsWith("none") - if (hasReadme) { - navigation.children?.push( - createNavigationItem("Readme", this.entryDocument, false) - ) - } - if (this.entryPoints.length === 1) { - navigation.children?.push( - createNavigationItem( - "Exports", - hasReadme ? this.globalsFile : this.entryDocument, - false - ) - ) - } - this.mappings.forEach((mapping) => { - const kind = mapping.kind[0] - const items = project.getReflectionsByKind(kind) - if (items.length > 0) { - const children = items - .map((item) => { - const urlMapping = getUrlMapping(item.name) || "" - return createNavigationItem( - item.getFullName(), - typeof urlMapping === "string" ? urlMapping : urlMapping.url, - true - ) - }) - .sort((a, b) => { - return a.title > b.title ? 1 : -1 - }) - const group = createNavigationItem( - getKindPlural(kind), - undefined, - true, - children - ) - navigation.children?.push(group) - } - }) - return navigation - } - - get mappings(): Mapping[] { + getMappings(directoryPrefix?: string): Mapping[] { return [ { kind: [ReflectionKind.Module], isLeaf: false, - directory: "modules", + directory: path.join(directoryPrefix || "", "modules"), template: this.getReflectionTemplate(), }, { kind: [ReflectionKind.Namespace], isLeaf: false, - directory: "modules", + directory: path.join(directoryPrefix || "", "modules"), template: this.getReflectionTemplate(), }, { kind: [ReflectionKind.Enum], isLeaf: false, - directory: "enums", + directory: path.join(directoryPrefix || "", "enums"), template: this.getReflectionTemplate(), }, { kind: [ReflectionKind.Class], isLeaf: false, - directory: "classes", + directory: path.join(directoryPrefix || "", "classes"), template: this.getReflectionTemplate(), }, { kind: [ReflectionKind.Interface], isLeaf: false, - directory: "interfaces", + directory: path.join(directoryPrefix || "", "interfaces"), template: this.getReflectionTemplate(), }, ...(this.allReflectionsHaveOwnDocument @@ -370,19 +301,25 @@ export class MarkdownTheme extends Theme { { kind: [ReflectionKind.TypeAlias], isLeaf: true, - directory: "types", + directory: path.join(directoryPrefix || "", "types"), template: this.getReflectionMemberTemplate(), }, { kind: [ReflectionKind.Variable], isLeaf: true, - directory: "variables", + directory: path.join(directoryPrefix || "", "variables"), template: this.getReflectionMemberTemplate(), }, { kind: [ReflectionKind.Function], isLeaf: true, - directory: "functions", + directory: path.join(directoryPrefix || "", "functions"), + template: this.getReflectionMemberTemplate(), + }, + { + kind: [ReflectionKind.Method], + isLeaf: true, + directory: path.join(directoryPrefix || "", "methods"), template: this.getReflectionMemberTemplate(), }, ] 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 21b7c3c26e..fd911017a8 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/types.ts +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/types.ts @@ -68,8 +68,10 @@ export type FormattingOptionType = { reflectionDescription?: string expandMembers?: boolean showCommentsAsHeader?: boolean + showCommentsAsDetails?: boolean parameterStyle?: ParameterStyle showReturnSignature?: boolean + frontmatterData?: Record } export type FormattingOptionsType = { diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/utils/reflection-template-strings.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/utils/reflection-template-strings.ts new file mode 100644 index 0000000000..7ed3f33454 --- /dev/null +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/utils/reflection-template-strings.ts @@ -0,0 +1,25 @@ +import { Reflection, ReflectionKind } from "typedoc" + +export function replaceTemplateVariables( + reflection: Reflection, + text?: string +): string { + if (!text) { + return "" + } + + return text + .replaceAll("{{alias}}", reflection.getAlias()) + .replaceAll("{{kind}}", getKindAsText(reflection.kind)) +} + +export function getKindAsText(kind: ReflectionKind) { + switch (kind) { + case ReflectionKind.Method: + return "method" + case ReflectionKind.Enum: + return "enum" + default: + return "" + } +} diff --git a/docs-util/yarn.lock b/docs-util/yarn.lock index 3e8d596afc..6a2bc84e25 100644 --- a/docs-util/yarn.lock +++ b/docs-util/yarn.lock @@ -2832,6 +2832,7 @@ __metadata: dependencies: "@types/node": ^16.11.10 typescript: ^4.6 + yaml: ^2.3.2 peerDependencies: typedoc: 0.25.x languageName: unknown @@ -2845,6 +2846,7 @@ __metadata: copyfiles: ^2.4.1 handlebars: ^4.7.8 typescript: ^4.6 + yaml: ^2.3.2 peerDependencies: typedoc: 0.25.x languageName: unknown @@ -3139,6 +3141,13 @@ __metadata: languageName: node linkType: hard +"yaml@npm:^2.3.2": + version: 2.3.2 + resolution: "yaml@npm:2.3.2" + checksum: c2aac464015f037911c5b819475e81e52119e5495e3d43fe7cb82b5a84d59d66a86049dc85d8e90658636c1c04dde177ae196818deaf76c1bda4d34209d5c087 + languageName: node + linkType: hard + "yargs-parser@npm:^20.2.2": version: 20.2.9 resolution: "yargs-parser@npm:20.2.9" diff --git a/www/apps/docs/content/references/pricing/.nojekyll b/www/apps/docs/content/references/pricing/.nojekyll new file mode 100644 index 0000000000..e2ac6616ad --- /dev/null +++ b/www/apps/docs/content/references/pricing/.nojekyll @@ -0,0 +1 @@ +TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false. \ No newline at end of file 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 new file mode 100644 index 0000000000..371d7a352f --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.addPrices.md @@ -0,0 +1,258 @@ +--- +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.addRules.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.addRules.md new file mode 100644 index 0000000000..49f30228d3 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.addRules.md @@ -0,0 +1,144 @@ +--- +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.calculatePrices.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.calculatePrices.md new file mode 100644 index 0000000000..72617efc05 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.calculatePrices.md @@ -0,0 +1,66 @@ +--- +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.create.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.create.md new file mode 100644 index 0000000000..5441914a12 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.create.md @@ -0,0 +1,273 @@ +--- +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.createCurrencies.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createCurrencies.md new file mode 100644 index 0000000000..91ba411a4c --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createCurrencies.md @@ -0,0 +1,67 @@ +--- +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.createMoneyAmounts.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createMoneyAmounts.md new file mode 100644 index 0000000000..f02df231b4 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createMoneyAmounts.md @@ -0,0 +1,83 @@ +--- +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.createPriceRules.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createPriceRules.md new file mode 100644 index 0000000000..67f2c9d9d7 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createPriceRules.md @@ -0,0 +1,103 @@ +--- +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.createPriceSetMoneyAmountRules.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createPriceSetMoneyAmountRules.md new file mode 100644 index 0000000000..82ab5a3864 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createPriceSetMoneyAmountRules.md @@ -0,0 +1,84 @@ +--- +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.createRuleTypes.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createRuleTypes.md new file mode 100644 index 0000000000..14be183533 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.createRuleTypes.md @@ -0,0 +1,65 @@ +--- +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.delete.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.delete.md new file mode 100644 index 0000000000..5319d6d447 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.delete.md @@ -0,0 +1,42 @@ +--- +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.deleteCurrencies.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deleteCurrencies.md new file mode 100644 index 0000000000..2f42380f2b --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deleteCurrencies.md @@ -0,0 +1,43 @@ +--- +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.deleteMoneyAmounts.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deleteMoneyAmounts.md new file mode 100644 index 0000000000..f3b70aa581 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deleteMoneyAmounts.md @@ -0,0 +1,44 @@ +--- +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.deletePriceRules.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deletePriceRules.md new file mode 100644 index 0000000000..4221650e3b --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deletePriceRules.md @@ -0,0 +1,44 @@ +--- +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.deletePriceSetMoneyAmountRules.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deletePriceSetMoneyAmountRules.md new file mode 100644 index 0000000000..0dce0e6df9 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deletePriceSetMoneyAmountRules.md @@ -0,0 +1,42 @@ +--- +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.deleteRuleTypes.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deleteRuleTypes.md new file mode 100644 index 0000000000..b2a5723731 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.deleteRuleTypes.md @@ -0,0 +1,42 @@ +--- +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.list.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.list.md new file mode 100644 index 0000000000..2b2524c0fd --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.list.md @@ -0,0 +1,172 @@ +--- +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.listAndCount.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCount.md new file mode 100644 index 0000000000..d8ad4f7f06 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCount.md @@ -0,0 +1,173 @@ +--- +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.listAndCountCurrencies.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountCurrencies.md new file mode 100644 index 0000000000..3912faf94d --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountCurrencies.md @@ -0,0 +1,121 @@ +--- +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.listAndCountMoneyAmounts.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountMoneyAmounts.md new file mode 100644 index 0000000000..e9c68bfc7d --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountMoneyAmounts.md @@ -0,0 +1,160 @@ +--- +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.listAndCountPriceRules.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountPriceRules.md new file mode 100644 index 0000000000..2786d83587 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountPriceRules.md @@ -0,0 +1,167 @@ +--- +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.listAndCountPriceSetMoneyAmountRules.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountPriceSetMoneyAmountRules.md new file mode 100644 index 0000000000..8ce8a5cb32 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountPriceSetMoneyAmountRules.md @@ -0,0 +1,163 @@ +--- +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.listAndCountRuleTypes.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountRuleTypes.md new file mode 100644 index 0000000000..149ccf3f51 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listAndCountRuleTypes.md @@ -0,0 +1,150 @@ +--- +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.listCurrencies.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listCurrencies.md new file mode 100644 index 0000000000..3191f69669 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listCurrencies.md @@ -0,0 +1,120 @@ +--- +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.listMoneyAmounts.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listMoneyAmounts.md new file mode 100644 index 0000000000..64f02422f8 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listMoneyAmounts.md @@ -0,0 +1,159 @@ +--- +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.listPriceRules.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listPriceRules.md new file mode 100644 index 0000000000..9488118952 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listPriceRules.md @@ -0,0 +1,167 @@ +--- +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.listPriceSetMoneyAmountRules.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listPriceSetMoneyAmountRules.md new file mode 100644 index 0000000000..f1fb3d861a --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listPriceSetMoneyAmountRules.md @@ -0,0 +1,161 @@ +--- +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.listRuleTypes.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listRuleTypes.md new file mode 100644 index 0000000000..48d9ed323b --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.listRuleTypes.md @@ -0,0 +1,149 @@ +--- +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.removeRules.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.removeRules.md new file mode 100644 index 0000000000..9b36dc81bc --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.removeRules.md @@ -0,0 +1,49 @@ +--- +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.retrieve.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieve.md new file mode 100644 index 0000000000..a29127550b --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieve.md @@ -0,0 +1,101 @@ +--- +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.retrieveCurrency.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieveCurrency.md new file mode 100644 index 0000000000..9266a505ff --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieveCurrency.md @@ -0,0 +1,88 @@ +--- +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.retrieveMoneyAmount.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieveMoneyAmount.md new file mode 100644 index 0000000000..11cb106aab --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieveMoneyAmount.md @@ -0,0 +1,98 @@ +--- +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.retrievePriceRule.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrievePriceRule.md new file mode 100644 index 0000000000..d57c2a4bd1 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrievePriceRule.md @@ -0,0 +1,106 @@ +--- +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.retrievePriceSetMoneyAmountRules.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrievePriceSetMoneyAmountRules.md new file mode 100644 index 0000000000..ff4cdbdf81 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrievePriceSetMoneyAmountRules.md @@ -0,0 +1,100 @@ +--- +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.retrieveRuleType.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieveRuleType.md new file mode 100644 index 0000000000..438817b5ec --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.retrieveRuleType.md @@ -0,0 +1,83 @@ +--- +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.updateCurrencies.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updateCurrencies.md new file mode 100644 index 0000000000..0192522f04 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updateCurrencies.md @@ -0,0 +1,65 @@ +--- +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.updateMoneyAmounts.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updateMoneyAmounts.md new file mode 100644 index 0000000000..3058cefdad --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updateMoneyAmounts.md @@ -0,0 +1,72 @@ +--- +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.updatePriceRules.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updatePriceRules.md new file mode 100644 index 0000000000..46c9ba0650 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updatePriceRules.md @@ -0,0 +1,94 @@ +--- +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.updatePriceSetMoneyAmountRules.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updatePriceSetMoneyAmountRules.md new file mode 100644 index 0000000000..0ba27a38b2 --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updatePriceSetMoneyAmountRules.md @@ -0,0 +1,83 @@ +--- +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.updateRuleTypes.md b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updateRuleTypes.md new file mode 100644 index 0000000000..7571c1003a --- /dev/null +++ b/www/apps/docs/content/references/pricing/IPricingModuleService/methods/IPricingModuleService.updateRuleTypes.md @@ -0,0 +1,65 @@ +--- +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/index.md b/www/apps/docs/content/references/pricing/index.md new file mode 100644 index 0000000000..ddc9aa68b6 --- /dev/null +++ b/www/apps/docs/content/references/pricing/index.md @@ -0,0 +1,56 @@ +--- +displayed_sidebar: pricingReference +--- + +# 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) + +## 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) diff --git a/www/apps/docs/content/references/pricing/interfaces/AddPricesDTO.md b/www/apps/docs/content/references/pricing/interfaces/AddPricesDTO.md new file mode 100644 index 0000000000..d8436a5d3b --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/AddPricesDTO.md @@ -0,0 +1,31 @@ +--- +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/AddRulesDTO.md b/www/apps/docs/content/references/pricing/interfaces/AddRulesDTO.md new file mode 100644 index 0000000000..ed0e99fb3b --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/AddRulesDTO.md @@ -0,0 +1,31 @@ +--- +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/BaseFilterable.md b/www/apps/docs/content/references/pricing/interfaces/BaseFilterable.md new file mode 100644 index 0000000000..9db6c644bb --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/BaseFilterable.md @@ -0,0 +1,53 @@ +--- +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/CalculatedPriceSetDTO.md b/www/apps/docs/content/references/pricing/interfaces/CalculatedPriceSetDTO.md new file mode 100644 index 0000000000..617dfeced4 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/CalculatedPriceSetDTO.md @@ -0,0 +1,67 @@ +--- +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/Context.md b/www/apps/docs/content/references/pricing/interfaces/Context.md new file mode 100644 index 0000000000..316b5c2bcb --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/Context.md @@ -0,0 +1,75 @@ +--- +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/CreateCurrencyDTO.md b/www/apps/docs/content/references/pricing/interfaces/CreateCurrencyDTO.md new file mode 100644 index 0000000000..7c8d0ac4ce --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/CreateCurrencyDTO.md @@ -0,0 +1,56 @@ +--- +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/CreateMoneyAmountDTO.md b/www/apps/docs/content/references/pricing/interfaces/CreateMoneyAmountDTO.md new file mode 100644 index 0000000000..f41eba6e06 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/CreateMoneyAmountDTO.md @@ -0,0 +1,87 @@ +--- +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/CreatePriceRuleDTO.md b/www/apps/docs/content/references/pricing/interfaces/CreatePriceRuleDTO.md new file mode 100644 index 0000000000..1ff843ecff --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/CreatePriceRuleDTO.md @@ -0,0 +1,103 @@ +--- +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/CreatePriceSetDTO.md b/www/apps/docs/content/references/pricing/interfaces/CreatePriceSetDTO.md new file mode 100644 index 0000000000..8558fea8bb --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/CreatePriceSetDTO.md @@ -0,0 +1,32 @@ +--- +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/CreatePriceSetMoneyAmountRulesDTO.md b/www/apps/docs/content/references/pricing/interfaces/CreatePriceSetMoneyAmountRulesDTO.md new file mode 100644 index 0000000000..6e941b4424 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/CreatePriceSetMoneyAmountRulesDTO.md @@ -0,0 +1,43 @@ +--- +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/CreatePricesDTO.md b/www/apps/docs/content/references/pricing/interfaces/CreatePricesDTO.md new file mode 100644 index 0000000000..b244503558 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/CreatePricesDTO.md @@ -0,0 +1,121 @@ +--- +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/CreateRuleTypeDTO.md b/www/apps/docs/content/references/pricing/interfaces/CreateRuleTypeDTO.md new file mode 100644 index 0000000000..26ce099663 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/CreateRuleTypeDTO.md @@ -0,0 +1,55 @@ +--- +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/CurrencyDTO.md b/www/apps/docs/content/references/pricing/interfaces/CurrencyDTO.md new file mode 100644 index 0000000000..609095a6c0 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/CurrencyDTO.md @@ -0,0 +1,56 @@ +--- +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/FilterableCurrencyProps.md b/www/apps/docs/content/references/pricing/interfaces/FilterableCurrencyProps.md new file mode 100644 index 0000000000..3c74995b7f --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/FilterableCurrencyProps.md @@ -0,0 +1,57 @@ +--- +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/FilterableMoneyAmountProps.md b/www/apps/docs/content/references/pricing/interfaces/FilterableMoneyAmountProps.md new file mode 100644 index 0000000000..c51b743e7e --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/FilterableMoneyAmountProps.md @@ -0,0 +1,69 @@ +--- +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/FilterablePriceRuleProps.md b/www/apps/docs/content/references/pricing/interfaces/FilterablePriceRuleProps.md new file mode 100644 index 0000000000..dcacb3acf6 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/FilterablePriceRuleProps.md @@ -0,0 +1,93 @@ +--- +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/FilterablePriceSetMoneyAmountRulesProps.md b/www/apps/docs/content/references/pricing/interfaces/FilterablePriceSetMoneyAmountRulesProps.md new file mode 100644 index 0000000000..b75db5a99e --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/FilterablePriceSetMoneyAmountRulesProps.md @@ -0,0 +1,93 @@ +--- +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/FilterablePriceSetProps.md b/www/apps/docs/content/references/pricing/interfaces/FilterablePriceSetProps.md new file mode 100644 index 0000000000..2accf4e992 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/FilterablePriceSetProps.md @@ -0,0 +1,69 @@ +--- +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/FilterableRuleTypeProps.md b/www/apps/docs/content/references/pricing/interfaces/FilterableRuleTypeProps.md new file mode 100644 index 0000000000..37fc281b4e --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/FilterableRuleTypeProps.md @@ -0,0 +1,81 @@ +--- +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/FindConfig.md b/www/apps/docs/content/references/pricing/interfaces/FindConfig.md new file mode 100644 index 0000000000..77f761b882 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/FindConfig.md @@ -0,0 +1,92 @@ +--- +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/IPricingModuleService.md b/www/apps/docs/content/references/pricing/interfaces/IPricingModuleService.md new file mode 100644 index 0000000000..717a1ae562 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/IPricingModuleService.md @@ -0,0 +1,53 @@ +--- +displayed_sidebar: pricingReference +badge: + variant: orange + text: Beta +slug: /references/pricing +--- + +# 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) diff --git a/www/apps/docs/content/references/pricing/interfaces/JoinerServiceConfig.md b/www/apps/docs/content/references/pricing/interfaces/JoinerServiceConfig.md new file mode 100644 index 0000000000..aacd7ac70b --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/JoinerServiceConfig.md @@ -0,0 +1,81 @@ +--- +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/JoinerServiceConfigAlias.md b/www/apps/docs/content/references/pricing/interfaces/JoinerServiceConfigAlias.md new file mode 100644 index 0000000000..88354c9e6a --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/JoinerServiceConfigAlias.md @@ -0,0 +1,27 @@ +--- +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/MoneyAmountDTO.md b/www/apps/docs/content/references/pricing/interfaces/MoneyAmountDTO.md new file mode 100644 index 0000000000..0407f386f8 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/MoneyAmountDTO.md @@ -0,0 +1,79 @@ +--- +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/PriceRuleDTO.md b/www/apps/docs/content/references/pricing/interfaces/PriceRuleDTO.md new file mode 100644 index 0000000000..27b456d150 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/PriceRuleDTO.md @@ -0,0 +1,127 @@ +--- +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/PriceSetDTO.md b/www/apps/docs/content/references/pricing/interfaces/PriceSetDTO.md new file mode 100644 index 0000000000..f98e2522d3 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/PriceSetDTO.md @@ -0,0 +1,43 @@ +--- +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/PriceSetMoneyAmountDTO.md b/www/apps/docs/content/references/pricing/interfaces/PriceSetMoneyAmountDTO.md new file mode 100644 index 0000000000..d97475586f --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/PriceSetMoneyAmountDTO.md @@ -0,0 +1,55 @@ +--- +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/PriceSetMoneyAmountRulesDTO.md b/www/apps/docs/content/references/pricing/interfaces/PriceSetMoneyAmountRulesDTO.md new file mode 100644 index 0000000000..4369aab892 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/PriceSetMoneyAmountRulesDTO.md @@ -0,0 +1,55 @@ +--- +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/PricingContext.md b/www/apps/docs/content/references/pricing/interfaces/PricingContext.md new file mode 100644 index 0000000000..c34344c0a7 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/PricingContext.md @@ -0,0 +1,26 @@ +--- +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/PricingFilters.md b/www/apps/docs/content/references/pricing/interfaces/PricingFilters.md new file mode 100644 index 0000000000..123ba49f11 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/PricingFilters.md @@ -0,0 +1,19 @@ +--- +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/RemovePriceSetRulesDTO.md b/www/apps/docs/content/references/pricing/interfaces/RemovePriceSetRulesDTO.md new file mode 100644 index 0000000000..c520e91403 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/RemovePriceSetRulesDTO.md @@ -0,0 +1,31 @@ +--- +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/RuleTypeDTO.md b/www/apps/docs/content/references/pricing/interfaces/RuleTypeDTO.md new file mode 100644 index 0000000000..b175f7745c --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/RuleTypeDTO.md @@ -0,0 +1,55 @@ +--- +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/UpdateCurrencyDTO.md b/www/apps/docs/content/references/pricing/interfaces/UpdateCurrencyDTO.md new file mode 100644 index 0000000000..fca1cf5184 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/UpdateCurrencyDTO.md @@ -0,0 +1,56 @@ +--- +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/UpdateMoneyAmountDTO.md b/www/apps/docs/content/references/pricing/interfaces/UpdateMoneyAmountDTO.md new file mode 100644 index 0000000000..769d31a7fe --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/UpdateMoneyAmountDTO.md @@ -0,0 +1,69 @@ +--- +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/UpdatePriceRuleDTO.md b/www/apps/docs/content/references/pricing/interfaces/UpdatePriceRuleDTO.md new file mode 100644 index 0000000000..c2c5114562 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/UpdatePriceRuleDTO.md @@ -0,0 +1,91 @@ +--- +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/UpdatePriceSetDTO.md b/www/apps/docs/content/references/pricing/interfaces/UpdatePriceSetDTO.md new file mode 100644 index 0000000000..df86e10a0e --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/UpdatePriceSetDTO.md @@ -0,0 +1,19 @@ +--- +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/UpdatePriceSetMoneyAmountRulesDTO.md b/www/apps/docs/content/references/pricing/interfaces/UpdatePriceSetMoneyAmountRulesDTO.md new file mode 100644 index 0000000000..452fff6559 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/UpdatePriceSetMoneyAmountRulesDTO.md @@ -0,0 +1,55 @@ +--- +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/UpdateRuleTypeDTO.md b/www/apps/docs/content/references/pricing/interfaces/UpdateRuleTypeDTO.md new file mode 100644 index 0000000000..d47f80ded6 --- /dev/null +++ b/www/apps/docs/content/references/pricing/interfaces/UpdateRuleTypeDTO.md @@ -0,0 +1,55 @@ +--- +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/types/Exclude.md b/www/apps/docs/content/references/pricing/types/Exclude.md new file mode 100644 index 0000000000..7d664f9fff --- /dev/null +++ b/www/apps/docs/content/references/pricing/types/Exclude.md @@ -0,0 +1,20 @@ +--- +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/JoinerRelationship.md b/www/apps/docs/content/references/pricing/types/JoinerRelationship.md new file mode 100644 index 0000000000..6d6424bd14 --- /dev/null +++ b/www/apps/docs/content/references/pricing/types/JoinerRelationship.md @@ -0,0 +1,24 @@ +--- +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/ModuleJoinerConfig.md b/www/apps/docs/content/references/pricing/types/ModuleJoinerConfig.md new file mode 100644 index 0000000000..a0a3832785 --- /dev/null +++ b/www/apps/docs/content/references/pricing/types/ModuleJoinerConfig.md @@ -0,0 +1,11 @@ +--- +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/ModuleJoinerRelationship.md b/www/apps/docs/content/references/pricing/types/ModuleJoinerRelationship.md new file mode 100644 index 0000000000..862d7f9614 --- /dev/null +++ b/www/apps/docs/content/references/pricing/types/ModuleJoinerRelationship.md @@ -0,0 +1,11 @@ +--- +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/Omit.md b/www/apps/docs/content/references/pricing/types/Omit.md new file mode 100644 index 0000000000..fd209bdc65 --- /dev/null +++ b/www/apps/docs/content/references/pricing/types/Omit.md @@ -0,0 +1,20 @@ +--- +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/Pick.md b/www/apps/docs/content/references/pricing/types/Pick.md new file mode 100644 index 0000000000..e11b12b36a --- /dev/null +++ b/www/apps/docs/content/references/pricing/types/Pick.md @@ -0,0 +1,20 @@ +--- +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/Record.md b/www/apps/docs/content/references/pricing/types/Record.md new file mode 100644 index 0000000000..70e1da4f7a --- /dev/null +++ b/www/apps/docs/content/references/pricing/types/Record.md @@ -0,0 +1,20 @@ +--- +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/sidebars.js b/www/apps/docs/sidebars.js index b391905306..e2c438d0f2 100644 --- a/www/apps/docs/sidebars.js +++ b/www/apps/docs/sidebars.js @@ -1131,6 +1131,18 @@ module.exports = { id: "modules/price-lists/price-selection-strategy", label: "Price Selection Strategy", }, + { + type: "html", + value: "References", + customProps: { + sidebar_is_group_divider: true, + }, + }, + { + type: "ref", + id: "references/pricing/interfaces/IPricingModuleService", + label: "Pricing Module Service Reference", + }, { type: "html", value: "How-to", @@ -2885,4 +2897,38 @@ module.exports = { dirName: "references/entities/classes", }, ], + pricingReference: [ + { + type: "ref", + id: "modules/overview", + label: "Back to Commerce Modules", + customProps: { + sidebar_is_back_link: true, + sidebar_icon: "back-arrow", + }, + }, + { + type: "doc", + id: "references/pricing/interfaces/IPricingModuleService", + label: "Pricing Module Service Reference", + customProps: { + sidebar_is_title: true, + sidebar_icon: "folder-open", + }, + }, + { + type: "category", + label: "Methods", + collapsible: false, + customProps: { + sidebar_is_group_headline: true, + }, + items: [ + { + type: "autogenerated", + dirName: "references/pricing/IPricingModuleService/methods", + }, + ], + }, + ], } diff --git a/www/apps/docs/src/theme/DocPage/Layout/Sidebar/index.tsx b/www/apps/docs/src/theme/DocPage/Layout/Sidebar/index.tsx index 59ca8fdd79..634ae3aa5f 100644 --- a/www/apps/docs/src/theme/DocPage/Layout/Sidebar/index.tsx +++ b/www/apps/docs/src/theme/DocPage/Layout/Sidebar/index.tsx @@ -76,8 +76,8 @@ export default function DocPageLayoutSidebar({ key={name} nodeRef={sidebarRef} classNames={{ - enter: "animate__animated animate__fadeInLeft animate__fastest", - exit: "animate__animated animate__fadeOutLeft animate__fastest", + enter: "animate-fadeInLeft animate-fast", + exit: "animate-fadeOutLeft animate-fast", }} timeout={200} > diff --git a/www/apps/docs/src/theme/MDXComponents/H1.tsx b/www/apps/docs/src/theme/MDXComponents/H1.tsx new file mode 100644 index 0000000000..5b6d5f98df --- /dev/null +++ b/www/apps/docs/src/theme/MDXComponents/H1.tsx @@ -0,0 +1,28 @@ +import React from "react" +import type { Props } from "@theme/MDXComponents/Heading" +import MDXHeading from "@theme/MDXComponents/Heading" +import { useDoc } from "@docusaurus/theme-common/internal" +import { DocContextValue } from "@medusajs/docs" +import { Badge, BadgeVariant } from "docs-ui" +import clsx from "clsx" + +const H1 = ({ className, ...props }: Props) => { + const { + frontMatter: { badge }, + } = useDoc() as DocContextValue + + return ( +
+ + {badge && ( + {badge.text} + )} +
+ ) +} + +export default H1 diff --git a/www/apps/docs/src/theme/MDXComponents/index.tsx b/www/apps/docs/src/theme/MDXComponents/index.tsx index 69cb7578d4..5342b0c88b 100644 --- a/www/apps/docs/src/theme/MDXComponents/index.tsx +++ b/www/apps/docs/src/theme/MDXComponents/index.tsx @@ -4,6 +4,7 @@ import CloudinaryImage from "@site/src/components/CloudinaryImage" import MDXDetails from "./Details" import MDXA from "./A" import { Kbd, DetailsSummary, InlineCode } from "docs-ui" +import H1 from "./H1" export default { // Re-use the default mapping @@ -14,4 +15,5 @@ export default { summary: DetailsSummary, a: MDXA, kbd: Kbd, + h1: H1, }