feat(pricing,types): addPrice and removePricreRules APIs (#5237)

* initial

* initial service

* update pricing module service

* add integration test for rule-type

* update pricing-module integration tests

* update pricing service interface

* feat(pricing): PriceSets as entry point to pricing module

* chore: add price set money amount

* chore: add price set money amount

* chore: change name of test

* chore: added changeset

* chore: use filterable props from money amount in price sets

* chore: update migrations

* test update integration test

* fix weird behavior

* Update packages/pricing/integration-tests/__fixtures__/rule-type/index.ts

Co-authored-by: Riqwan Thamir <rmthamir@gmail.com>

* Apply suggestions from code review

Co-authored-by: Riqwan Thamir <rmthamir@gmail.com>

* move rule-type to common

* chore: reset migration

* chore: remove incorrect conflicts

* chore: address review

* chore: remove ghost price list

* Apply suggestions from code review

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>

* update id prefix

* use persist not persistAndflush

* rename key_value to rule_attribute

* more renaming

* feat(types,pricing): add price set money amount rules to pricing module

* chore: cleanup + add test cases for relationship update

* chore: revert package json

* chore: cleanup

* initial

* update pricing module service

* update pricing-module integration tests

* update pricing service interface

* chore: update migrations

* fix weird behavior

* Apply suggestions from code review

Co-authored-by: Riqwan Thamir <rmthamir@gmail.com>

* move rule-type to common

* chore: delete duplicate migration files

* fix(link-modules): Fix link module initialization (#4990)

**What**
Add a new configuration on the relationship to specify if the relation is consumed from an internal service (from medusa core). In that case do not check if the service is part of the loaded modules

* initial price rule

* rebase develop

* save here

* final changes to create

* update price rule integration test

* add module integraiton tests for price rules

* fix merge

* redo wierd order change

* pr cleanup

* pr cleanup

* pr cleanup

* update pr

* sort out migrations

* [wip]

* wip

* chore: temporarily emulate mikroorm internals

* currency code hard filtering

* before creating subqueries

* chore: wip

* chore: wip

* chore: add exact match multiple contexts

* chore: add one more test

* chore: add query that works with exact match

* chore: qb the thingy

* chore: add some comments

* chore: removed extra filter

* chore: added some more comments + prettify

* chore: test with carlos

* chore: add fallbacks and exact match tests

* chore: cleanup

* feat(types,pricing): add price set money amount rules to pricing module (#5065)

* initial

* initial service

* update pricing module service

* add integration test for rule-type

* update pricing-module integration tests

* update pricing service interface

* feat(pricing): PriceSets as entry point to pricing module

* chore: add price set money amount

* chore: add price set money amount

* chore: change name of test

* chore: added changeset

* chore: use filterable props from money amount in price sets

* chore: update migrations

* test update integration test

* fix weird behavior

* Update packages/pricing/integration-tests/__fixtures__/rule-type/index.ts

Co-authored-by: Riqwan Thamir <rmthamir@gmail.com>

* Apply suggestions from code review

Co-authored-by: Riqwan Thamir <rmthamir@gmail.com>

* move rule-type to common

* chore: reset migration

* chore: remove incorrect conflicts

* chore: address review

* chore: remove ghost price list

* Apply suggestions from code review

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>

* update id prefix

* use persist not persistAndflush

* rename key_value to rule_attribute

* more renaming

* feat(types,pricing): add price set money amount rules to pricing module

* chore: cleanup + add test cases for relationship update

* chore: revert package json

* chore: cleanup

---------

Co-authored-by: Philip Korsholm <philip.korsholm@hotmail.com>
Co-authored-by: Philip Korsholm <88927411+pKorsholm@users.noreply.github.com>
Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>

* chore: minor cleanup

* chore: added money amount scoping

* chore: added review comments

* chore: update changset and undo test scoping

* add migration for price_set_rule_type table

* update types

* initial add

* update tests

* working create with rule-types

* initial testing for money amount creation

* add price set money amount repo and service

* fix broken build

* create price list with prices and rule types

* create price set with info not being rules and money amounts

* create price set initial working implementation

* chore: introduce group by util + no queries on empty context

* addPrices

* remove comments

* Feat/pricing module methods (#5218)

chore: add removePrices to pricing module

* fix broken integration test

* Revert "Feat/pricing module methods (#5218)" (#5236)

This reverts commit 95c8aaa66423d290a35b6e736e5b187e12d44a36.

* feat(types,pricing): remove prices from a price set (#5235)

feat(types,pricing): remove prices from a price set

* add addRules

* typing

* add validation of price set ids for addRules

* add rule_attribute check for addRules method

* chore: review changes

* chore: update schema

* chore: first part of reviews

* chore: reset migration

* remove unnecessary init

* update interface

* use persist not persistAndflush

* chore: added money amount scoping

* chore: update schema

* fix

* fix 2

* add default pricing

* addPrices

* create

* update pricing service interface

* chore: rename money amounts to prices

* chore: cleanup + changelog

* chore: update package.json

* chore: cleanup persistAndFlushes from services

* jsdoc

* chore: add js docs for price rules

* chore: added js doc for psma and rule types

* chore: added jsdoc for currencies

* more jsdocs

* jsdoc money amounts

* chore: move jsdoc to interface

* chore: remove persist and flush to persist

* change overload

---------

Co-authored-by: Philip Korsholm <philip.korsholm@hotmail.com>
Co-authored-by: Philip Korsholm <88927411+pKorsholm@users.noreply.github.com>
Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
Co-authored-by: Adrien de Peretti <adrien.deperetti@gmail.com>
This commit is contained in:
authored and GitHub committed 2023-10-02 20:56:05 +02:00
1 parent cf18211848
commit c5703a4765
39 files changed
+2310 -301

No files matched your search

+2 -1
View File
@@ -1,7 +1,8 @@
export * from "./currency"
export * from "./money-amount"
export * from "./price-rule"
export * from "./price-set"
export * from "./price-set-money-amount"
export * from "./price-set-money-amount-rules"
export * from "./price-set-rule-type"
export * from "./rule-type"
export * from './price-rule'
@@ -11,7 +11,7 @@ export interface MoneyAmountDTO {
}
export interface CreateMoneyAmountDTO {
id: string
id?: string
currency_code: string
currency?: CreateCurrencyDTO
amount?: number
@@ -22,7 +22,7 @@ export interface CreatePriceRuleDTO {
is_dynamic?: boolean
value: string
priority?: number
price_set_money_amount_id: string
price_set_money_amount_id: string
price_list_id: string
}
@@ -41,4 +41,6 @@ export interface FilterablePriceRuleProps
extends BaseFilterable<FilterablePriceRuleProps> {
id?: string[]
name?: string[]
price_set_id?: string[]
rule_type_id?: string[]
}
@@ -5,5 +5,18 @@ export interface PriceSetMoneyAmountDTO {
id: string
title?: string
price_set?: PriceSetDTO
rule_type?: MoneyAmountDTO
money_amount?: MoneyAmountDTO
}
export interface UpdatePriceSetMoneyAmountDTO {
id: string
title?: string
price_set?: PriceSetDTO
money_amount?: MoneyAmountDTO
}
export interface CreatePriceSetMoneyAmountDTO {
title?: string
price_set?: PriceSetDTO | string
money_amount?: MoneyAmountDTO | string
}
@@ -0,0 +1,29 @@
import { BaseFilterable } from "../../dal"
import { PriceSetDTO } from "./price-set"
import { PriceSetMoneyAmountDTO } from "./price-set-money-amount"
import { RuleTypeDTO } from "./rule-type"
export interface PriceSetRuleTypeDTO {
id: string
price_set: PriceSetDTO
rule_type: RuleTypeDTO
value: string
}
export interface CreatePriceSetRuleTypeDTO {
price_set: PriceSetDTO
rule_type: RuleTypeDTO
}
export interface UpdatePriceSetRuleTypeDTO {
id: string
price_set?: string
rule_type?: string
}
export interface FilterablePriceSetRuleTypeProps
extends BaseFilterable<FilterablePriceSetRuleTypeProps> {
id?: string[]
rule_type_id?: string[]
price_set_id?: string[]
}
+25 -2
View File
@@ -1,5 +1,10 @@
import { BaseFilterable } from "../../dal"
import { FilterableMoneyAmountProps, MoneyAmountDTO } from "./money-amount"
import {
CreateMoneyAmountDTO,
FilterableMoneyAmountProps,
MoneyAmountDTO,
} from "./money-amount"
import { RuleTypeDTO } from "./rule-type"
export interface PricingContext {
context?: Record<string, string | number>
@@ -12,6 +17,7 @@ export interface PricingFilters {
export interface PriceSetDTO {
id: string
money_amounts?: MoneyAmountDTO[]
rule_types?: RuleTypeDTO[]
}
export interface CalculatedPriceSetDTO {
@@ -22,8 +28,25 @@ export interface CalculatedPriceSetDTO {
max_quantity: number | null
}
export interface AddRulesDTO {
priceSetId: string
rules: { attribute: string }[]
}
export interface AddPricesDTO {
priceSetId: string
prices: (CreateMoneyAmountDTO & {
rules?: Record<string, string>
})[]
}
export interface RemovePriceSetRulesDTO {
id: string
rules: string[]
}
export interface CreatePriceSetDTO {
money_amounts?: MoneyAmountDTO[]
rules?: { rule_attribute: string }[]
prices?: (CreateMoneyAmountDTO & { rules: Record<string, string> })[]
}
export interface UpdatePriceSetDTO {
@@ -25,4 +25,5 @@ export interface FilterableRuleTypeProps
extends BaseFilterable<FilterableRuleTypeProps> {
id?: string[]
name?: string[]
rule_attribute?: string[]
}
+340
View File
@@ -1,4 +1,6 @@
import {
AddPricesDTO,
AddRulesDTO,
CalculatedPriceSetDTO,
CreateCurrencyDTO,
CreateMoneyAmountDTO,
@@ -19,6 +21,7 @@ import {
PriceSetMoneyAmountRulesDTO,
PricingContext,
PricingFilters,
RemovePriceSetRulesDTO,
RuleTypeDTO,
UpdateCurrencyDTO,
UpdateMoneyAmountDTO,
@@ -35,195 +38,532 @@ import { Context } from "../shared-context"
export interface IPricingModuleService {
__joinerConfig(): ModuleJoinerConfig
/**
* Calculates prices based on the provided filters and context.
*
* @async
* @param {PricingFilters} filters - PriceSet filters
* @param {PricingContext=} context - Optional pricing context to select prices.
* @param {Context=} sharedContext - Optional shared context.
* @returns {Promise<CalculatedPriceSetDTO>} A promise that resolves to the calculated prices.
*/
calculatePrices(
filters: PricingFilters,
context?: PricingContext,
sharedContext?: Context
): Promise<CalculatedPriceSetDTO>
/**
* Retrieves a priceSet by its ID.
*
* @async
* @param {string} id - The ID of the priceSet to retrieve.
* @param {FindConfig<PriceSetDTO>=} config - Optional configuration for the retrieval.
* @param {Context=} sharedContext - Optional shared context.
* @returns {Promise<PriceSetDTO>} A promise that resolves to a PriceSetDTO.
*/
retrieve(
id: string,
config?: FindConfig<PriceSetDTO>,
sharedContext?: Context
): Promise<PriceSetDTO>
/**
* Lists price sets based on optional filters and configuration.
*
* @async
* @param {FilterablePriceSetProps=} filters - Optional filters to narrow down the list.
* @param {FindConfig<PriceSetDTO>=} config - Optional configuration.
* @param {Context=} sharedContext - Optional shared context.
* @returns {Promise<PriceSetDTO[]>} A promise that resolves to an array of PriceSetDTOs.
*/
list(
filters?: FilterablePriceSetProps,
config?: FindConfig<PriceSetDTO>,
sharedContext?: Context
): Promise<PriceSetDTO[]>
/**
* List priceSets and provide the total count.
* @param filters - Optional filters for listing.
* @param config - Optional configuration.
* @param sharedContext - Optional shared context.
* @returns A promise resolving to an array of PriceSetDTOs and a count.
*/
listAndCount(
filters?: FilterablePriceSetProps,
config?: FindConfig<PriceSetDTO>,
sharedContext?: Context
): Promise<[PriceSetDTO[], number]>
/**
* Create a new priceSet.
* @param data - Data for creating a priceSet.
* @param sharedContext - Optional shared context.
* @returns A promise resolving to the created PriceSetDTO.
*/
create(data: CreatePriceSetDTO, sharedContext?: Context): Promise<PriceSetDTO>
/**
* Create multiple new priceSets.
* @param data - Array of data for creating priceSets.
* @param sharedContext - Optional shared context.
* @returns A promise resolving to an array of created PriceSetDTOs.
*/
create(
data: CreatePriceSetDTO[],
sharedContext?: Context
): Promise<PriceSetDTO[]>
/**
* Update existing priceSets.
* @param data - Array of data for updating priceSets.
* @param sharedContext - Optional shared context.
* @returns A promise resolving to an array of updated PriceSetDTOs.
*/
update(
data: UpdatePriceSetDTO[],
sharedContext?: Context
): Promise<PriceSetDTO[]>
/**
* Remove rules from priceSet.
* @param data - Array of data for removing priceSet rules.
* @param sharedContext - Optional shared context.
* @returns A promise that resolves when rules are successfully removed.
*/
removeRules(
data: RemovePriceSetRulesDTO[],
sharedContext?: Context
): Promise<void>
/**
* Delete priceSets by their IDs.
*
* @param ids - An array of IDs for priceSets to delete.
* @param sharedContext - Optional shared context.
* @returns A promise that resolves when the price sets are successfully deleted.
*/
delete(ids: string[], sharedContext?: Context): Promise<void>
/**
* Add prices to a price set.
*
* @param data - Data for adding prices to a price set.
* @param sharedContext - Optional shared context.
* @returns A promise resolving to the updated PriceSetDTO.
*/
addPrices(data: AddPricesDTO, sharedContext?: Context): Promise<PriceSetDTO>
/**
* Add prices to multiple price sets.
*
* @param data - An array of data for adding prices to price sets.
* @param sharedContext - Optional shared context.
* @returns A promise resolving to an array of updated PriceSetDTOs.
*/
addPrices(
data: AddPricesDTO[],
sharedContext?: Context
): Promise<PriceSetDTO[]>
/**
* Add rules to a price set.
*
* @param data - Data for adding rules to a price set.
* @param sharedContext - Optional shared context.
* @returns A promise resolving to the updated PriceSetDTO.
*/
addRules(data: AddRulesDTO, sharedContext?: Context): Promise<PriceSetDTO>
/**
* Add rules to multiple price sets.
*
* @param data - An array of data for adding rules to price sets.
* @param sharedContext - Optional shared context.
* @returns A promise resolving to an array of updated PriceSetDTOs.
*/
addRules(data: AddRulesDTO[], sharedContext?: Context): Promise<PriceSetDTO[]>
/**
* Retrieves a money amount by its ID.
*
* @param {string} id - The ID of the money amount to retrieve.
* @param {FindConfig<MoneyAmountDTO>=} config - Optional configuration for the retrieval operation.
* @param sharedContext - Optional shared context.
* @returns {Promise<MoneyAmountDTO>} A promise that resolves to a MoneyAmountDTO.
*/
retrieveMoneyAmount(
id: string,
config?: FindConfig<MoneyAmountDTO>,
sharedContext?: Context
): Promise<MoneyAmountDTO>
/**
* Lists money amounts based on optional filters and configuration.
*
* @param {FilterableMoneyAmountProps=} filters - Optional filters to narrow down the list.
* @param {FindConfig<MoneyAmountDTO>=} config - Optional configuration for the listing operation.
* @param sharedContext - Optional shared context.
* @returns {Promise<MoneyAmountDTO[]>} A promise that resolves to an array of MoneyAmountDTOs.
*/
listMoneyAmounts(
filters?: FilterableMoneyAmountProps,
config?: FindConfig<MoneyAmountDTO>,
sharedContext?: Context
): Promise<MoneyAmountDTO[]>
/**
* Lists money amounts based on optional filters and configuration and provides the total count.
*
* @param {FilterableMoneyAmountProps=} filters - Optional filters to narrow down the list.
* @param {FindConfig<MoneyAmountDTO>=} config - Optional configuration for the listing operation.
* @param sharedContext - Optional shared context.
* @returns {Promise<[MoneyAmountDTO[], number]>} A promise that resolves to an array of MoneyAmountDTOs and the total count.
*/
listAndCountMoneyAmounts(
filters?: FilterableMoneyAmountProps,
config?: FindConfig<MoneyAmountDTO>,
sharedContext?: Context
): Promise<[MoneyAmountDTO[], number]>
/**
* Creates new money amounts based on the provided data.
*
* @param {CreateMoneyAmountDTO[]} data - An array of data objects for creating money amounts.
* @param sharedContext - Optional shared context.
* @returns {Promise<MoneyAmountDTO[]>} A promise that resolves to an array of created MoneyAmountDTOs.
*/
createMoneyAmounts(
data: CreateMoneyAmountDTO[],
sharedContext?: Context
): Promise<MoneyAmountDTO[]>
/**
* Updates existing money amounts based on the provided data.
*
* @param {UpdateMoneyAmountDTO[]} data - An array of data objects for updating money amounts.
* @param sharedContext - Optional shared context.
* @returns {Promise<MoneyAmountDTO[]>} A promise that resolves to an array of updated MoneyAmountDTOs.
*/
updateMoneyAmounts(
data: UpdateMoneyAmountDTO[],
sharedContext?: Context
): Promise<MoneyAmountDTO[]>
/**
* Deletes money amounts by their IDs.
*
* @param {string[]} ids - An array of IDs for money amounts to delete.
* @param sharedContext - Optional shared context.
* @returns {Promise<void>} A promise that resolves when the money amounts are successfully deleted.
*/
deleteMoneyAmounts(ids: string[], sharedContext?: Context): Promise<void>
/**
* Retrieves a currency by its code based on the provided configuration.
*
* @param {string} code - The code of the currency to retrieve.
* @param {FindConfig<PricingTypes.CurrencyDTO>} [config={}] - Optional configuration for retrieving the currency.
* @param {Context} [sharedContext={}] - An optional shared MedusaContext object.
* @returns {Promise<PricingTypes.CurrencyDTO>} A Promise that resolves to the retrieved currency object.
*/
retrieveCurrency(
code: string,
config?: FindConfig<CurrencyDTO>,
sharedContext?: Context
): Promise<CurrencyDTO>
/**
* Lists currencies based on the provided filters and configuration.
*
* @param {PricingTypes.FilterableCurrencyProps} [filters={}] - Optional filters to apply when listing currencies.
* @param {FindConfig<PricingTypes.CurrencyDTO>} [config={}] - Optional configuration for listing currencies.
* @param {Context} [sharedContext={}] - An optional shared MedusaContext object.
* @returns {Promise<PricingTypes.CurrencyDTO[]>} A Promise that resolves to an array containing the list of currency objects.
*/
listCurrencies(
filters?: FilterableCurrencyProps,
config?: FindConfig<CurrencyDTO>,
sharedContext?: Context
): Promise<CurrencyDTO[]>
/**
* Lists and counts currencies based on the provided filters and configuration.
*
* @param {PricingTypes.FilterableCurrencyProps} [filters={}] - Optional filters to apply when listing currencies.
* @param {FindConfig<PricingTypes.CurrencyDTO>} [config={}] - Optional configuration for listing currencies.
* @param {Context} [sharedContext={}] - An optional shared MedusaContext object.
* @returns {Promise<[PricingTypes.CurrencyDTO[], number]>} A Promise that resolves to an array containing the list of currency objects and the total count.
*/
listAndCountCurrencies(
filters?: FilterableCurrencyProps,
config?: FindConfig<CurrencyDTO>,
sharedContext?: Context
): Promise<[CurrencyDTO[], number]>
/**
* Creates new currencies based on the provided data.
*
* @param {PricingTypes.CreateCurrencyDTO[]} data - An array of objects containing the data to create new currencies.
* @param {Context} [sharedContext={}] - An optional shared MedusaContext object.
* @returns {Promise<PricingTypes.CurrencyDTO[]>} A Promise that resolves to an array of newly created currency objects.
*/
createCurrencies(
data: CreateCurrencyDTO[],
sharedContext?: Context
): Promise<CurrencyDTO[]>
/**
* Updates currencies with the provided data.
*
* @param {PricingTypes.UpdateCurrencyDTO[]} data - An array of objects containing the data to update the currencies.
* @param {Context} [sharedContext={}] - An optional shared MedusaContext object.
* @returns {Promise<PricingTypes.CurrencyDTO[]>} A Promise that resolves to an array of updated currency objects.
*/
updateCurrencies(
data: UpdateCurrencyDTO[],
sharedContext?: Context
): Promise<CurrencyDTO[]>
/**
* Deletes currencies with the specified codes.
*
* @param {string[]} currencyCodes - An array of string codes representing the currencies to delete.
* @param {Context} [sharedContext={}] - An optional shared MedusaContext object.
* @returns {Promise<void>} A Promise that resolves once the currencies are deleted.
*/
deleteCurrencies(
currencyCodes: string[],
sharedContext?: Context
): Promise<void>
/**
* Retrieves a rule type by its ID based on the provided configuration.
*
* @param {string} id - The ID of the rule type to retrieve.
* @param {FindConfig<PricingTypes.RuleTypeDTO>} [config={}] - Optional configuration for retrieving the rule type.
* @param {Context} [sharedContext={}] - An optional shared MedusaContext object.
* @returns {Promise<PricingTypes.RuleTypeDTO>} A Promise that resolves to the retrieved rule type object.
*/
retrieveRuleType(
code: string,
config?: FindConfig<RuleTypeDTO>,
sharedContext?: Context
): Promise<RuleTypeDTO>
/**
* Lists rule types based on the provided filters and configuration.
*
* @param {PricingTypes.FilterableRuleTypeProps} [filters={}] - Optional filters to apply when listing rule types.
* @param {FindConfig<PricingTypes.RuleTypeDTO>} [config={}] - Optional configuration for listing rule types.
* @param {Context} [sharedContext={}] - An optional shared MedusaContext object.
* @returns {Promise<PricingTypes.RuleTypeDTO[]>} A Promise that resolves to an array containing the list of rule type objects.
*/
listRuleTypes(
filters?: FilterableRuleTypeProps,
config?: FindConfig<RuleTypeDTO>,
sharedContext?: Context
): Promise<RuleTypeDTO[]>
/**
* Lists and counts rule types based on the provided filters and configuration.
*
* @param {PricingTypes.FilterableRuleTypeProps} [filters={}] - Optional filters to apply when listing rule types.
* @param {FindConfig<PricingTypes.RuleTypeDTO>} [config={}] - Optional configuration for listing rule types.
* @param {Context} [sharedContext={}] - An optional shared MedusaContext object.
* @returns {Promise<[PricingTypes.RuleTypeDTO[], number]>} A Promise that resolves to an array containing the list of rule type objects and the total count.
*/
listAndCountRuleTypes(
filters?: FilterableRuleTypeProps,
config?: FindConfig<RuleTypeDTO>,
sharedContext?: Context
): Promise<[RuleTypeDTO[], number]>
/**
* Creates new rule types based on the provided data.
*
* @param {PricingTypes.CreateRuleTypeDTO[]} data - An array of objects containing the data to create new rule types.
* @param {Context} [sharedContext={}] - An optional shared MedusaContext object.
* @returns {Promise<PricingTypes.RuleTypeDTO[]>} A Promise that resolves to an array of newly created rule type objects.
*/
createRuleTypes(
data: CreateRuleTypeDTO[],
sharedContext?: Context
): Promise<RuleTypeDTO[]>
/**
* Updates rule types with the provided data.
*
* @param {PricingTypes.UpdateRuleTypeDTO[]} data - An array of objects containing the data to update the rule types.
* @param {Context} [sharedContext={}] - An optional shared MedusaContext object.
* @returns {Promise<PricingTypes.RuleTypeDTO[]>} A Promise that resolves to an array of updated rule type objects.
*/
updateRuleTypes(
data: UpdateRuleTypeDTO[],
sharedContext?: Context
): Promise<RuleTypeDTO[]>
/**
* Deletes rule types with the specified IDs.
*
* @param {string[]} ruleTypeIds - An array of string IDs representing the rule types to delete.
* @param {Context} [sharedContext={}] - An optional shared MedusaContext object.
* @returns {Promise<void>} A Promise that resolves once the rule types are deleted.
*/
deleteRuleTypes(ruleTypeIds: string[], sharedContext?: Context): Promise<void>
/**
* Retrieves a price set money amount rule by its ID based on the provided configuration.
*
* @param {string} id - The ID of the price set money amount rule to retrieve.
* @param {FindConfig<PricingTypes.PriceSetMoneyAmountRulesDTO>} [config={}] - Optional configuration for retrieving the price set money amount rule.
* @param {Context} [sharedContext={}] - An optional shared MedusaContext object.
* @returns {Promise<PricingTypes.PriceSetMoneyAmountRulesDTO>} A Promise that resolves to the retrieved price set money amount rule object.
*/
retrievePriceSetMoneyAmountRules(
id: string,
config?: FindConfig<PriceSetMoneyAmountRulesDTO>,
sharedContext?: Context
): Promise<PriceSetMoneyAmountRulesDTO>
/**
* Lists price set money amount rules based on the provided filters and configuration.
*
* @param {PricingTypes.FilterablePriceSetMoneyAmountRulesProps} [filters={}] - Optional filters to apply when listing price set money amount rules.
* @param {FindConfig<PricingTypes.PriceSetMoneyAmountRulesDTO>} [config={}] - Optional configuration for listing price set money amount rules.
* @param {Context} [sharedContext={}] - An optional shared MedusaContext object.
* @returns {Promise<PricingTypes.PriceSetMoneyAmountRulesDTO[]>} A Promise that resolves to an array containing the list of price set money amount rule objects.
*/
listPriceSetMoneyAmountRules(
filters?: FilterablePriceSetMoneyAmountRulesProps,
config?: FindConfig<PriceSetMoneyAmountRulesDTO>,
sharedContext?: Context
): Promise<PriceSetMoneyAmountRulesDTO[]>
/**
* Lists and counts price set money amount rules based on the provided filters and configuration.
*
* @param {PricingTypes.FilterablePriceSetMoneyAmountRulesProps} [filters={}] - Optional filters to apply when listing price set money amount rules.
* @param {FindConfig<PricingTypes.PriceSetMoneyAmountRulesDTO>} [config={}] - Optional configuration for listing price set money amount rules.
* @param {Context} [sharedContext={}] - An optional shared MedusaContext object.
* @returns {Promise<[PricingTypes.PriceSetMoneyAmountRulesDTO[], number]>} A Promise that resolves to an array containing the list of price set money amount rule objects and the total count.
*/
listAndCountPriceSetMoneyAmountRules(
filters?: FilterablePriceSetMoneyAmountRulesProps,
config?: FindConfig<PriceSetMoneyAmountRulesDTO>,
sharedContext?: Context
): Promise<[PriceSetMoneyAmountRulesDTO[], number]>
/**
* Creates new price set money amount rules based on the provided data.
*
* @param {PricingTypes.CreatePriceSetMoneyAmountRulesDTO[]} data - An array of objects containing the data to create new price set money amount rules.
* @param {Context} [sharedContext={}] - An optional shared MedusaContext object.
* @returns {Promise<PricingTypes.PriceSetMoneyAmountRulesDTO[]>} A Promise that resolves to an array of newly created price set money amount rule objects.
*/
createPriceSetMoneyAmountRules(
data: CreatePriceSetMoneyAmountRulesDTO[],
sharedContext?: Context
): Promise<PriceSetMoneyAmountRulesDTO[]>
/**
* Updates price set money amount rules with the provided data.
*
* @param {PricingTypes.UpdatePriceSetMoneyAmountRulesDTO[]} data - An array of objects containing the data to update the price set money amount rules.
* @param {Context} [sharedContext={}] - An optional shared MedusaContext object.
* @returns {Promise<PricingTypes.PriceSetMoneyAmountRulesDTO[]>} A Promise that resolves to an array of updated price set money amount rule objects.
*/
updatePriceSetMoneyAmountRules(
data: UpdatePriceSetMoneyAmountRulesDTO[],
sharedContext?: Context
): Promise<PriceSetMoneyAmountRulesDTO[]>
/**
* Deletes price set money amount rules with the specified IDs.
*
* @param {string[]} ids - An array of string IDs representing the price set money amount rules to delete.
* @param {Context} [sharedContext={}] - An optional shared MedusaContext object.
* @returns {Promise<void>} A Promise that resolves once the price set money amount rules are deleted.
*/
deletePriceSetMoneyAmountRules(
ids: string[],
sharedContext?: Context
): Promise<void>
/**
* Retrieves a price rule by its ID
*
* @param {string} id - The ID of the price rule to retrieve.
* @param {FindConfig<PricingTypes.PriceRuleDTO>} [config={}] - Optional configuration for retrieving the price rule.
* @param {Context} [sharedContext={}] - An optional shared MedusaContext object.
* @returns {Promise<PricingTypes.PriceRuleDTO>} A Promise that resolves to the retrieved price rule object.
*/
retrievePriceRule(
id: string,
config?: FindConfig<PriceRuleDTO>,
sharedContext?: Context
): Promise<PriceRuleDTO>
/**
* Lists price rules based on the provided filters and configuration.
*
* @param {PricingTypes.FilterablePriceRuleProps} [filters={}] - Optional filters to apply when listing price rules.
* @param {FindConfig<PricingTypes.PriceRuleDTO>} [config={}] - Optional configuration for listing price rules.
* @param {Context} [sharedContext={}] - An optional shared MedusaContext object.
* @returns {Promise<PricingTypes.PriceRuleDTO[]>} A Promise that resolves to an array containing the list of price rule objects.
*/
listPriceRules(
filters?: FilterablePriceRuleProps,
config?: FindConfig<PriceRuleDTO>,
sharedContext?: Context
): Promise<PriceRuleDTO[]>
/**
* Lists and counts price rules based on the provided filters and configuration.
*
* @param {PricingTypes.FilterablePriceRuleProps} [filters={}] - Optional filters to apply when listing price rules.
* @param {FindConfig<PricingTypes.PriceRuleDTO>} [config={}] - Optional configuration for listing price rules.
* @param {Context} [sharedContext={}] - An optional shared MedusaContext object.
* @returns {Promise<[PricingTypes.PriceRuleDTO[], number]>} A Promise that resolves to an array containing the list of price rule objects and the total count.
*/
listAndCountPriceRules(
filters?: FilterablePriceRuleProps,
config?: FindConfig<PriceRuleDTO>,
sharedContext?: Context
): Promise<[PriceRuleDTO[], number]>
/**
* Creates new price rules based on the provided data.
*
* @param {PricingTypes.CreatePriceRuleDTO[]} data - An array of objects containing the data to create new price rules.
* @param {Context} [sharedContext={}] - An optional shared MedusaContext object.
* @returns {Promise<PricingTypes.PriceRuleDTO[]>} A Promise that resolves to an array of newly created price rule objects.
*/
createPriceRules(
data: CreatePriceRuleDTO[],
sharedContext?: Context
): Promise<PriceRuleDTO[]>
/**
* Updates price rules with the provided data.
*
* @param {PricingTypes.UpdatePriceRuleDTO[]} data - An array of objects containing the data to update the price rules.
* @param {Context} [sharedContext={}] - An optional shared MedusaContext object.
* @returns {Promise<PricingTypes.PriceRuleDTO[]>} A Promise that resolves to an array of updated price rule objects.
*/
updatePriceRules(
data: UpdatePriceRuleDTO[],
sharedContext?: Context
): Promise<PriceRuleDTO[]>
/**
* Deletes price rules with the specified IDs.
*
* @param {string[]} priceRuleIds - An array of string IDs representing the price rules to delete.
* @param {Context} [sharedContext={}] - An optional shared MedusaContext object.
* @returns {Promise<void>} A Promise that resolves once the price rules are deleted.
*/
deletePriceRules(
priceRuleIds: string[],
sharedContext?: Context