feat(core-flows,medusa,pricing,types,utils): added price list workflows + endpoints (#6648)
Apologies for the giant PR in advance, but most of these are removing of files and migrations from old workflows and routes to new. What: - Adds CRUD endpoints for price lists - Migrate workflows from old sdk to new - Added missing updatePriceListPrices method to pricing module
This commit is contained in:
@@ -86,7 +86,7 @@ export interface UpdateMoneyAmountDTO {
|
||||
/**
|
||||
* The code of the currency to associate with the money amount.
|
||||
*/
|
||||
currency_code?: string
|
||||
currency_code?: string | null
|
||||
/**
|
||||
* The price of this money amount.
|
||||
*/
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { CreateMoneyAmountDTO, MoneyAmountDTO } from "./money-amount";
|
||||
|
||||
import { BaseFilterable } from "../../dal";
|
||||
import { PriceSetMoneyAmountDTO } from "./price-set-money-amount";
|
||||
import { RuleTypeDTO } from "./rule-type";
|
||||
import { BaseFilterable } from "../../dal"
|
||||
import {
|
||||
CreateMoneyAmountDTO,
|
||||
MoneyAmountDTO,
|
||||
UpdateMoneyAmountDTO,
|
||||
} from "./money-amount"
|
||||
import { PriceSetMoneyAmountDTO } from "./price-set-money-amount"
|
||||
import { RuleTypeDTO } from "./rule-type"
|
||||
|
||||
/**
|
||||
* @enum
|
||||
@@ -106,7 +109,18 @@ export interface PriceListDTO {
|
||||
*
|
||||
* The prices associated with a price list.
|
||||
*/
|
||||
export interface PriceListPriceDTO extends CreateMoneyAmountDTO {
|
||||
export interface CreatePriceListPriceDTO extends CreateMoneyAmountDTO {
|
||||
/**
|
||||
* The ID of the associated price set.
|
||||
*/
|
||||
price_set_id: string
|
||||
/**
|
||||
* The rules to add to the price. The object's keys are rule types' `rule_attribute` attribute, and values are the value of that rule associated with this price.
|
||||
*/
|
||||
rules?: CreatePriceSetPriceRules
|
||||
}
|
||||
|
||||
export interface UpdatePriceListPriceDTO extends UpdateMoneyAmountDTO {
|
||||
/**
|
||||
* The ID of the associated price set.
|
||||
*/
|
||||
@@ -152,11 +166,11 @@ export interface CreatePriceListDTO {
|
||||
/**
|
||||
* The price list is enabled starting from this date.
|
||||
*/
|
||||
starts_at?: Date | string | null
|
||||
starts_at?: string | null
|
||||
/**
|
||||
* The price list expires after this date.
|
||||
*/
|
||||
ends_at?: Date | string | null
|
||||
ends_at?: string | null
|
||||
/**
|
||||
* The price list's status.
|
||||
*/
|
||||
@@ -176,7 +190,7 @@ export interface CreatePriceListDTO {
|
||||
/**
|
||||
* The prices associated with the price list.
|
||||
*/
|
||||
prices?: PriceListPriceDTO[]
|
||||
prices?: CreatePriceListPriceDTO[]
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -200,11 +214,11 @@ export interface UpdatePriceListDTO {
|
||||
/**
|
||||
* The price list is enabled starting from this date.
|
||||
*/
|
||||
starts_at?: Date | string | null
|
||||
starts_at?: string | null
|
||||
/**
|
||||
* The price list expires after this date.
|
||||
*/
|
||||
ends_at?: Date | string | null
|
||||
ends_at?: string | null
|
||||
/**
|
||||
* The price list's status.
|
||||
*/
|
||||
@@ -412,11 +426,27 @@ export interface AddPriceListPricesDTO {
|
||||
/**
|
||||
* The ID of the price list to add prices to.
|
||||
*/
|
||||
priceListId: string
|
||||
price_list_id: string
|
||||
/**
|
||||
* The prices to add.
|
||||
*/
|
||||
prices: PriceListPriceDTO[]
|
||||
prices: CreatePriceListPriceDTO[]
|
||||
}
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*
|
||||
* The prices to be added to a price list.
|
||||
*/
|
||||
export interface UpdatePriceListPricesDTO {
|
||||
/**
|
||||
* The ID of the price list to add prices to.
|
||||
*/
|
||||
price_list_id: string
|
||||
/**
|
||||
* The prices to add.
|
||||
*/
|
||||
prices: UpdatePriceListPriceDTO[]
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -428,7 +458,7 @@ export interface SetPriceListRulesDTO {
|
||||
/**
|
||||
* The ID of the price list to add rules to.
|
||||
*/
|
||||
priceListId: string
|
||||
price_list_id: string
|
||||
/**
|
||||
* The rules to add to the price list. Each key of the object is a rule type's `rule_attribute`, and its value
|
||||
* is the value(s) of the rule.
|
||||
@@ -445,7 +475,7 @@ export interface RemovePriceListRulesDTO {
|
||||
/**
|
||||
* The ID of the price list to remove rules from.
|
||||
*/
|
||||
priceListId: string
|
||||
price_list_id: string
|
||||
/**
|
||||
* The rules to remove from the price list. Each item being a rule type's `rule_attribute`.
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { BaseFilterable } from "../../dal"
|
||||
import { PriceSetDTO } from "./price-set"
|
||||
import { PriceSetMoneyAmountDTO } from "./price-set-money-amount"
|
||||
import { RuleTypeDTO } from "./rule-type"
|
||||
|
||||
/**
|
||||
@@ -73,18 +72,10 @@ export interface CreatePriceRuleDTO {
|
||||
* The ID of the associated price set.
|
||||
*/
|
||||
price_set_id?: string
|
||||
/**
|
||||
* The ID or object of the associated price set.
|
||||
*/
|
||||
price_set?: string | PriceSetDTO
|
||||
/**
|
||||
* The ID of the associated rule type.
|
||||
*/
|
||||
rule_type_id?: string
|
||||
/**
|
||||
* The ID of the associated rule type.
|
||||
*/
|
||||
rule_type?: string | RuleTypeDTO
|
||||
/**
|
||||
* The value of the price rule.
|
||||
*/
|
||||
@@ -97,10 +88,6 @@ export interface CreatePriceRuleDTO {
|
||||
* The ID of the associated price set money amount.
|
||||
*/
|
||||
price_set_money_amount_id?: string
|
||||
/**
|
||||
* The ID or object of the associated price set money amount.
|
||||
*/
|
||||
price_set_money_amount?: string | PriceSetMoneyAmountDTO
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { BaseFilterable } from "../../dal";
|
||||
import { MoneyAmountDTO } from "./money-amount";
|
||||
import { PriceListDTO } from "./price-list";
|
||||
import { PriceRuleDTO } from "./price-rule";
|
||||
import { PriceSetDTO } from "./price-set";
|
||||
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
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from "./common"
|
||||
export * from "./service"
|
||||
export * from "./workflows"
|
||||
|
||||
@@ -33,6 +33,7 @@ import {
|
||||
SetPriceListRulesDTO,
|
||||
UpdateMoneyAmountDTO,
|
||||
UpdatePriceListDTO,
|
||||
UpdatePriceListPricesDTO,
|
||||
UpdatePriceListRuleDTO,
|
||||
UpdatePriceRuleDTO,
|
||||
UpdatePriceSetDTO,
|
||||
@@ -3397,6 +3398,11 @@ export interface IPricingModuleService extends IModuleService {
|
||||
sharedContext?: Context
|
||||
): Promise<PriceListDTO[]>
|
||||
|
||||
updatePriceListPrices(
|
||||
data: UpdatePriceListPricesDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<PriceListDTO[]>
|
||||
|
||||
/**
|
||||
* This method is used to set the rules of a price list.
|
||||
*
|
||||
@@ -3454,4 +3460,6 @@ export interface IPricingModuleService extends IModuleService {
|
||||
data: RemovePriceListRulesDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<PriceListDTO>
|
||||
|
||||
removePrices(ids: string[], sharedContext?: Context): Promise<void>
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import { PriceListStatus } from "./common"
|
||||
|
||||
export interface CreatePriceListPriceWorkflowDTO {
|
||||
amount: number
|
||||
currency_code: string
|
||||
variant_id: string
|
||||
max_quantity?: number
|
||||
min_quantity?: number
|
||||
rules?: Record<string, string>
|
||||
}
|
||||
|
||||
export interface UpdatePriceListPriceWorkflowDTO {
|
||||
id: string
|
||||
amount?: number
|
||||
currency_code?: string
|
||||
variant_id?: string
|
||||
max_quantity?: number
|
||||
min_quantity?: number
|
||||
rules?: Record<string, string>
|
||||
}
|
||||
|
||||
export interface CreatePriceListWorkflowInputDTO {
|
||||
title: string
|
||||
description: string
|
||||
starts_at?: string | null
|
||||
ends_at?: string | null
|
||||
status?: PriceListStatus
|
||||
rules?: Record<string, string[]>
|
||||
prices?: CreatePriceListPriceWorkflowDTO[]
|
||||
}
|
||||
|
||||
export interface UpdatePriceListWorkflowInputDTO {
|
||||
id: string
|
||||
title?: string
|
||||
description?: string
|
||||
starts_at?: string | null
|
||||
ends_at?: string | null
|
||||
status?: PriceListStatus
|
||||
rules?: Record<string, string[]>
|
||||
prices?: (UpdatePriceListPriceWorkflowDTO | CreatePriceListPriceWorkflowDTO)[]
|
||||
}
|
||||
Reference in New Issue
Block a user