feat(core-flows,medusa,types,utils): rename psma to prices (#6796)

What:

Renames pricesetmoneyamount to prices

Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
This commit is contained in:
Riqwan Thamir
2024-03-25 13:15:25 +00:00
committed by GitHub
co-authored by Adrien de Peretti
parent fbc369705d
commit 9073d7aba3
80 changed files with 1056 additions and 2276 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
export * from "./money-amount"
export * from "./price"
export * from "./price-list"
export * from "./price-rule"
export * from "./price-set"
export * from "./price-set-money-amount"
export * from "./price-set-rule-type"
export * from "./rule-type"
@@ -1,5 +1,4 @@
import { BaseFilterable } from "../../dal"
import { PriceSetMoneyAmountDTO } from "./price-set-money-amount"
/**
* @interface
@@ -27,10 +26,6 @@ export interface MoneyAmountDTO {
* The maximum quantity required to be purchased for this price to be applied.
*/
max_quantity?: number
/**
* The details of the relation between the money amount and its associated price set.
*/
price_set_money_amount?: PriceSetMoneyAmountDTO
/**
* When the money_amount was created.
*/
@@ -4,7 +4,7 @@ import {
MoneyAmountDTO,
UpdateMoneyAmountDTO,
} from "./money-amount"
import { PriceSetMoneyAmountDTO } from "./price-set-money-amount"
import { PriceDTO } from "./price"
import { RuleTypeDTO } from "./rule-type"
/**
@@ -74,7 +74,7 @@ export interface PriceListDTO {
*
* @expandable
*/
price_set_money_amounts?: PriceSetMoneyAmountDTO[]
prices?: PriceDTO[]
/**
* The associated money amounts.
*
@@ -40,9 +40,9 @@ export interface PriceRuleDTO {
*/
priority: number
/**
* The ID of the associated price set money amount.
* The ID of the associated price.
*/
price_set_money_amount_id: string
price_id: string
/**
* The ID of the associated price list.
*/
@@ -85,16 +85,16 @@ export interface CreatePriceRuleDTO {
*/
priority?: number
/**
* The ID of the associated price set money amount.
* The ID of the associated price.
*/
price_set_money_amount_id?: string
price_id?: string
}
/**
*
* @interface
*
* The data to update in a price rule. The `id` is used to identify which money amount to update.
* The data to update in a price rule. The `id` is used to identify which price rule to update.
*/
export interface UpdatePriceRuleDTO {
id: string
@@ -109,9 +109,9 @@ export interface UpdatePriceRuleDTO {
*/
priority?: number
/**
* The ID of the associated price set money amount.
* The ID of the associated price.
*/
price_set_money_amount_id?: string
price_id?: string
/**
* The ID of the associated price list.
*/
@@ -1,97 +0,0 @@
import { BaseFilterable } from "../../dal"
import { MoneyAmountDTO } from "./money-amount"
import { PriceListDTO } from "./price-list"
import { PriceRuleDTO } from "./price-rule"
import { PriceSetDTO } from "./price-set"
/**
* @interface
*
* A price set money amount's data.
*/
export interface PriceSetMoneyAmountDTO {
/**
* The ID of a price set money amount.
*/
id: string
/**
* The title of the price set money amount.
*/
title?: string
/**
* The price set associated with the price set money amount.
*
* @expandable
*/
price_set?: PriceSetDTO
/**
* The price list associated with the price set money amount.
*
* @expandable
*/
price_list?: PriceListDTO
/**
* The ID of the associated price set.
*/
price_set_id?: string
/**
* The price rules associated with the price set money amount.
*
* @expandable
*/
price_rules?: PriceRuleDTO[]
/**
* The money amount associated with the price set money amount.
*
* @expandable
*/
money_amount?: MoneyAmountDTO
/**
* When the price_set_money_amount was created.
*/
created_at: Date
/**
* When the price_set_money_amount was updated.
*/
updated_at: Date
/**
* When the price_set_money_amount was deleted.
*/
deleted_at: null | Date
}
export interface UpdatePriceSetMoneyAmountDTO {
id: string
title?: string
price_set?: PriceSetDTO
money_amount?: MoneyAmountDTO
}
export interface CreatePriceSetMoneyAmountDTO {
title?: string
price_set?: PriceSetDTO | string
price_list?: PriceListDTO | string
money_amount?: MoneyAmountDTO | string
rules_count?: number
}
/**
* @interface
*
* Filters to apply on price set money amounts.
*/
export interface FilterablePriceSetMoneyAmountProps
extends BaseFilterable<FilterablePriceSetMoneyAmountProps> {
/**
* The IDs to filter the price set money amounts by.
*/
id?: string[]
/**
* The IDs to filter the price set money amount's associated price set.
*/
price_set_id?: string[]
/**
* The IDs to filter the price set money amount's associated price list.
*/
price_list_id?: string[]
}
@@ -10,8 +10,8 @@ export interface PriceSetRuleTypeDTO {
}
export interface CreatePriceSetRuleTypeDTO {
price_set: PriceSetDTO
rule_type: RuleTypeDTO
price_set_id: string
rule_type_id: string
}
export interface UpdatePriceSetRuleTypeDTO {
+141
View File
@@ -0,0 +1,141 @@
import { BaseFilterable } from "../../dal"
import { PriceListDTO } from "./price-list"
import { PriceRuleDTO } from "./price-rule"
import { PriceSetDTO } from "./price-set"
/**
* @interface
*
* A price's data.
*/
export interface PriceDTO {
/**
* The ID of a price.
*/
id: string
/**
* The title of the price.
*/
title?: string
/**
* The currency code of this price.
*/
currency_code?: string
/**
* The price of this price.
*/
amount?: number
/**
* The minimum quantity required to be purchased for this price to be applied.
*/
min_quantity?: number
/**
* The maximum quantity required to be purchased for this price to be applied.
*/
max_quantity?: number
/**
* The price set associated with the price.
*
* @expandable
*/
price_set?: PriceSetDTO
/**
* The price list associated with the price.
*
* @expandable
*/
price_list?: PriceListDTO
/**
* The ID of the associated price set.
*/
price_set_id?: string
/**
* The price rules associated with the price.
*
* @expandable
*/
price_rules?: PriceRuleDTO[]
/**
* When the price was created.
*/
created_at: Date
/**
* When the price was updated.
*/
updated_at: Date
/**
* When the price was deleted.
*/
deleted_at: null | Date
}
export interface UpdatePriceDTO {
id: string
title?: string
price_set?: PriceSetDTO
/**
* The code of the currency to associate with the price.
*/
currency_code?: string | null
/**
* The amount of this price.
*/
amount?: number
/**
* The minimum quantity required to be purchased for this price to be applied.
*/
min_quantity?: number
/**
* The maximum quantity required to be purchased for this price to be applied.
*/
max_quantity?: number
}
export interface CreatePriceDTO {
title?: string
price_set?: PriceSetDTO | string
price_set_id: string
price_list?: PriceListDTO | string
rules_count?: number
/**
* The currency code of this price.
*/
currency_code: string
/**
* The amount of this price.
*/
amount: number
/**
* The minimum quantity required to be purchased for this price to be applied.
*/
min_quantity?: number | null
/**
* The maximum quantity required to be purchased for this price to be applied.
*/
max_quantity?: number | null
}
/**
* @interface
*
* Filters to apply on prices.
*/
export interface FilterablePriceProps
extends BaseFilterable<FilterablePriceProps> {
/**
* The IDs to filter the prices by.
*/
id?: string[]
/**
* Currency codes to filter price by.
*/
currency_code?: string | string[]
/**
* The IDs to filter the price's associated price set.
*/
price_set_id?: string[]
/**
* The IDs to filter the price's associated price list.
*/
price_list_id?: string[]
}
+77 -79
View File
@@ -10,15 +10,15 @@ import {
CreateRuleTypeDTO,
FilterablePriceListProps,
FilterablePriceListRuleProps,
FilterablePriceProps,
FilterablePriceRuleProps,
FilterablePriceSetMoneyAmountProps,
FilterablePriceSetProps,
FilterableRuleTypeProps,
PriceDTO,
PriceListDTO,
PriceListRuleDTO,
PriceRuleDTO,
PriceSetDTO,
PriceSetMoneyAmountDTO,
PricingContext,
PricingFilters,
RemovePriceListRulesDTO,
@@ -169,7 +169,7 @@ export interface IPricingModuleService extends IModuleService {
* const priceSet = await pricingService.retrieve(
* priceSetId,
* {
* relations: ["money_amounts"]
* relations: ["prices"]
* }
* )
*
@@ -230,7 +230,7 @@ export interface IPricingModuleService extends IModuleService {
* id: priceSetIds
* },
* {
* relations: ["money_amounts"]
* relations: ["prices"]
* }
* )
*
@@ -253,7 +253,7 @@ export interface IPricingModuleService extends IModuleService {
* id: priceSetIds
* },
* {
* relations: ["money_amounts"],
* relations: ["prices"],
* skip,
* take
* }
@@ -270,7 +270,7 @@ export interface IPricingModuleService extends IModuleService {
* initialize as initializePricingModule,
* } from "@medusajs/pricing"
*
* async function retrievePriceSets (priceSetIds: string[], moneyAmountIds: string[], skip: number, take: number) {
* async function retrievePriceSets (priceSetIds: string[], priceIds: string[], skip: number, take: number) {
* const pricingService = await initializePricingModule()
*
* const priceSets = await pricingService.list(
@@ -280,14 +280,14 @@ export interface IPricingModuleService extends IModuleService {
* id: priceSetIds
* },
* {
* money_amounts: {
* id: moneyAmountIds
* prices: {
* id: priceIds
* }
* }
* ]
* },
* {
* relations: ["money_amounts"],
* relations: ["prices"],
* skip,
* take
* }
@@ -350,7 +350,7 @@ export interface IPricingModuleService extends IModuleService {
* id: priceSetIds
* },
* {
* relations: ["money_amounts"]
* relations: ["prices"]
* }
* )
*
@@ -373,7 +373,7 @@ export interface IPricingModuleService extends IModuleService {
* id: priceSetIds
* },
* {
* relations: ["money_amounts"],
* relations: ["prices"],
* skip,
* take
* }
@@ -390,7 +390,7 @@ export interface IPricingModuleService extends IModuleService {
* initialize as initializePricingModule,
* } from "@medusajs/pricing"
*
* async function retrievePriceSets (priceSetIds: string[], moneyAmountIds: string[], skip: number, take: number) {
* async function retrievePriceSets (priceSetIds: string[], priceIds: string[], skip: number, take: number) {
* const pricingService = await initializePricingModule()
*
* const [priceSets, count] = await pricingService.listAndCount(
@@ -400,14 +400,14 @@ export interface IPricingModuleService extends IModuleService {
* id: priceSetIds
* },
* {
* money_amounts: {
* id: moneyAmountIds
* prices: {
* id: priceIds
* }
* }
* ]
* },
* {
* relations: ["money_amounts"],
* relations: ["prices"],
* skip,
* take
* }
@@ -1240,52 +1240,52 @@ export interface IPricingModuleService extends IModuleService {
deleteRuleTypes(ruleTypeIds: string[], sharedContext?: Context): Promise<void>
/**
* This method is used to retrieve a paginated list of price set money amounts based on optional filters and configuration.
* This method is used to retrieve a paginated list of prices based on optional filters and configuration.
*
* @param {FilterablePriceSetMoneyAmountProps} filters - The filters to apply on the retrieved price set money amounts.
* @param {FindConfig<PriceSetMoneyAmountDTO>} config -
* The configurations determining how the price set money amounts are retrieved. Its properties, such as `select` or `relations`, accept the
* attributes or relations associated with a price set money amount.
* @param {FilterablePriceProps} filters - The filters to apply on the retrieved prices.
* @param {FindConfig<PriceDTO>} config -
* The configurations determining how the prices are retrieved. Its properties, such as `select` or `relations`, accept the
* attributes or relations associated with a price.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<PriceSetMoneyAmountDTO[]>} The list of price set money amounts.
* @returns {Promise<PriceDTO[]>} The list of prices.
*
* @example
*
* To retrieve a list of price set money amounts using their IDs:
* To retrieve a list of prices using their IDs:
*
* ```ts
* import {
* initialize as initializePricingModule,
* } from "@medusajs/pricing"
*
* async function retrievePriceSetMoneyAmounts (id: string) {
* async function retrievePrices (id: string) {
* const pricingService = await initializePricingModule()
*
* const priceSetMoneyAmounts = await pricingService.listPriceSetMoneyAmounts({
* const prices = await pricingService.listPrices({
* id: [id]
* })
*
* // do something with the price set money amounts or return them
* // do something with the prices or return them
* }
* ```
*
* To specify relations that should be retrieved within the price set money amounts:
* To specify relations that should be retrieved within the prices:
*
* ```ts
* import {
* initialize as initializePricingModule,
* } from "@medusajs/pricing"
*
* async function retrievePriceSetMoneyAmounts (id: string) {
* async function retrievePrices (id: string) {
* const pricingService = await initializePricingModule()
*
* const priceSetMoneyAmounts = await pricingService.listPriceSetMoneyAmounts({
* const prices = await pricingService.listPrices({
* id: [id]
* }, {
* relations: ["price_rules"]
* })
*
* // do something with the price set money amounts or return them
* // do something with the prices or return them
* }
* ```
*
@@ -1296,10 +1296,10 @@ export interface IPricingModuleService extends IModuleService {
* initialize as initializePricingModule,
* } from "@medusajs/pricing"
*
* async function retrievePriceSetMoneyAmounts (id: string, skip: number, take: number) {
* async function retrievePrices (id: string, skip: number, take: number) {
* const pricingService = await initializePricingModule()
*
* const priceSetMoneyAmounts = await pricingService.listPriceSetMoneyAmounts({
* const prices = await pricingService.listPrices({
* id: [id]
* }, {
* relations: ["price_rules"],
@@ -1307,7 +1307,7 @@ export interface IPricingModuleService extends IModuleService {
* take
* })
*
* // do something with the price set money amounts or return them
* // do something with the prices or return them
* }
* ```
*
@@ -1318,10 +1318,10 @@ export interface IPricingModuleService extends IModuleService {
* initialize as initializePricingModule,
* } from "@medusajs/pricing"
*
* async function retrievePriceSetMoneyAmounts (ids: string[], titles: string[], skip: number, take: number) {
* async function retrievePrices (ids: string[], titles: string[], skip: number, take: number) {
* const pricingService = await initializePricingModule()
*
* const priceSetMoneyAmounts = await pricingService.listPriceSetMoneyAmounts({
* const prices = await pricingService.listPrices({
* $and: [
* {
* id: ids
@@ -1336,78 +1336,76 @@ export interface IPricingModuleService extends IModuleService {
* take
* })
*
* // do something with the price set money amounts or return them
* // do something with the prices or return them
* }
* ```
*/
listPriceSetMoneyAmounts(
filters?: FilterablePriceSetMoneyAmountProps,
config?: FindConfig<PriceSetMoneyAmountDTO>,
listPrices(
filters?: FilterablePriceProps,
config?: FindConfig<PriceDTO>,
sharedContext?: Context
): Promise<PriceSetMoneyAmountDTO[]>
): Promise<PriceDTO[]>
softDeletePriceSetMoneyAmounts<
TReturnableLinkableKeys extends string = string
>(
psmaIds: string[],
softDeletePrices<TReturnableLinkableKeys extends string = string>(
priceIds: string[],
config?: SoftDeleteReturn<TReturnableLinkableKeys>,
sharedContext?: Context
): Promise<Record<string, string[]> | void>
restorePriceSetMoneyAmounts<TReturnableLinkableKeys extends string = string>(
psmaIds: string[],
restorePrices<TReturnableLinkableKeys extends string = string>(
priceIds: string[],
config?: RestoreReturn<TReturnableLinkableKeys>,
sharedContext?: Context
): Promise<Record<string, string[]> | void>
/**
* This method is used to retrieve a paginated list of price set money amounts along with the total count of
* available price set money amounts satisfying the provided filters.
* This method is used to retrieve a paginated list of prices along with the total count of
* available prices satisfying the provided filters.
*
* @param {FilterablePriceSetMoneyAmountProps} filters - The filters to apply on the retrieved price set money amounts.
* @param {FindConfig<PriceSetMoneyAmountDTO>} config -
* The configurations determining how the price set money amounts are retrieved. Its properties, such as `select` or `relations`, accept the
* attributes or relations associated with a price set money amount.
* @param {FilterablePriceProps} filters - The filters to apply on the retrieved prices.
* @param {FindConfig<PriceDTO>} config -
* The configurations determining how the prices are retrieved. Its properties, such as `select` or `relations`, accept the
* attributes or relations associated with a price.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<[PriceSetMoneyAmountDTO[], number]>} The list of price set money amounts and their total count.
* @returns {Promise<[PriceDTO[], number]>} The list of prices and their total count.
*
* @example
*
* To retrieve a list of price set money amounts using their IDs:
* To retrieve a list of prices using their IDs:
*
* ```ts
* import {
* initialize as initializePricingModule,
* } from "@medusajs/pricing"
*
* async function retrievePriceSetMoneyAmounts (id: string) {
* async function retrievePrices (id: string) {
* const pricingService = await initializePricingModule()
*
* const [priceSetMoneyAmounts, count] = await pricingService.listAndCountPriceSetMoneyAmounts({
* const [prices, count] = await pricingService.listAndCountPrices({
* id: [id]
* })
*
* // do something with the price set money amounts or return them
* // do something with the prices or return them
* }
* ```
*
* To specify relations that should be retrieved within the price set money amounts:
* To specify relations that should be retrieved within the prices:
*
* ```ts
* import {
* initialize as initializePricingModule,
* } from "@medusajs/pricing"
*
* async function retrievePriceSetMoneyAmounts (id: string) {
* async function retrievePrices (id: string) {
* const pricingService = await initializePricingModule()
*
* const [priceSetMoneyAmounts, count] = await pricingService.listAndCountPriceSetMoneyAmounts({
* const [prices, count] = await pricingService.listAndCountPrices({
* id: [id]
* }, {
* relations: ["price_rules"],
* })
*
* // do something with the price set money amounts or return them
* // do something with the prices or return them
* }
* ```
*
@@ -1418,10 +1416,10 @@ export interface IPricingModuleService extends IModuleService {
* initialize as initializePricingModule,
* } from "@medusajs/pricing"
*
* async function retrievePriceSetMoneyAmounts (id: string, skip: number, take: number) {
* async function retrievePrices (id: string, skip: number, take: number) {
* const pricingService = await initializePricingModule()
*
* const [priceSetMoneyAmounts, count] = await pricingService.listAndCountPriceSetMoneyAmounts({
* const [prices, count] = await pricingService.listAndCountPrices({
* id: [id]
* }, {
* relations: ["price_rules"],
@@ -1429,7 +1427,7 @@ export interface IPricingModuleService extends IModuleService {
* take
* })
*
* // do something with the price set money amounts or return them
* // do something with the prices or return them
* }
* ```
*
@@ -1440,10 +1438,10 @@ export interface IPricingModuleService extends IModuleService {
* initialize as initializePricingModule,
* } from "@medusajs/pricing"
*
* async function retrievePriceSetMoneyAmounts (ids: string[], titles: string[], skip: number, take: number) {
* async function retrievePrices (ids: string[], titles: string[], skip: number, take: number) {
* const pricingService = await initializePricingModule()
*
* const [priceSetMoneyAmounts, count] = await pricingService.listAndCountPriceSetMoneyAmounts({
* const [prices, count] = await pricingService.listAndCountPrices({
* $and: [
* {
* id: ids
@@ -1458,15 +1456,15 @@ export interface IPricingModuleService extends IModuleService {
* take
* })
*
* // do something with the price set money amounts or return them
* // do something with the prices or return them
* }
* ```
*/
listAndCountPriceSetMoneyAmounts(
filters?: FilterablePriceSetMoneyAmountProps,
config?: FindConfig<PriceSetMoneyAmountDTO>,
listAndCountPrices(
filters?: FilterablePriceProps,
config?: FindConfig<PriceDTO>,
sharedContext?: Context
): Promise<[PriceSetMoneyAmountDTO[], number]>
): Promise<[PriceDTO[], number]>
/**
* This method is used to retrieve a price rule by its ID.
@@ -1750,7 +1748,7 @@ export interface IPricingModuleService extends IModuleService {
* priceSetId: string,
* ruleTypeId: string,
* value: string,
* priceSetMoneyAmountId: string,
* priceId: string,
* priceListId: string
* ) {
* const pricingService = await initializePricingModule()
@@ -1761,7 +1759,7 @@ export interface IPricingModuleService extends IModuleService {
* price_set_id: priceSetId,
* rule_type_id: ruleTypeId,
* value,
* price_set_money_amount_id: priceSetMoneyAmountId,
* price_id: priceId,
* price_list_id: priceListId
* }
* ])
@@ -1874,7 +1872,7 @@ export interface IPricingModuleService extends IModuleService {
* const priceList = await pricingService.retrievePriceList(
* priceListId,
* {
* relations: ["price_set_money_amounts"]
* relations: ["prices"]
* }
* )
*
@@ -1935,7 +1933,7 @@ export interface IPricingModuleService extends IModuleService {
* id: priceListIds
* },
* {
* relations: ["price_set_money_amounts"]
* relations: ["prices"]
* }
* )
*
@@ -1958,7 +1956,7 @@ export interface IPricingModuleService extends IModuleService {
* id: priceListIds
* },
* {
* relations: ["price_set_money_amounts"],
* relations: ["prices"],
* skip,
* take
* }
@@ -1990,7 +1988,7 @@ export interface IPricingModuleService extends IModuleService {
* ]
* },
* {
* relations: ["price_set_money_amounts"],
* relations: ["prices"],
* skip,
* take
* }
@@ -2053,7 +2051,7 @@ export interface IPricingModuleService extends IModuleService {
* id: priceListIds
* },
* {
* relations: ["price_set_money_amounts"]
* relations: ["prices"]
* }
* )
*
@@ -2076,7 +2074,7 @@ export interface IPricingModuleService extends IModuleService {
* id: priceListIds
* },
* {
* relations: ["price_set_money_amounts"],
* relations: ["prices"],
* skip,
* take
* }
@@ -2108,7 +2106,7 @@ export interface IPricingModuleService extends IModuleService {
* ]
* },
* {
* relations: ["price_set_money_amounts"],
* relations: ["prices"],
* skip,
* take
* }