Fix(medusa, inventory, stock-location, types, utils): Modules sdk build query (#5713)
* remove defaults * take 2 * works now * add changeset * pricing module and pricing service list take null updates * update handlers * update product module service with take:null where relevant * no spread * note to self:default offset should be 0, not 15
This commit is contained in:
@@ -288,6 +288,7 @@ export default class PricingModuleService<
|
||||
{ id: priceSets.filter((p) => !!p).map((p) => p!.id) },
|
||||
{
|
||||
relations: ["rule_types", "money_amounts", "price_rules"],
|
||||
take: null,
|
||||
},
|
||||
sharedContext
|
||||
)
|
||||
@@ -310,7 +311,7 @@ export default class PricingModuleService<
|
||||
{
|
||||
rule_attribute: ruleAttributes,
|
||||
},
|
||||
{},
|
||||
{ take: null },
|
||||
sharedContext
|
||||
)
|
||||
|
||||
@@ -460,7 +461,7 @@ export default class PricingModuleService<
|
||||
): Promise<PricingTypes.PriceSetDTO[]> {
|
||||
const priceSets = await this.priceSetService_.list(
|
||||
{ id: inputs.map((d) => d.priceSetId) },
|
||||
{ relations: ["rule_types"] },
|
||||
{ relations: ["rule_types"], take: null },
|
||||
sharedContext
|
||||
)
|
||||
|
||||
@@ -492,7 +493,7 @@ export default class PricingModuleService<
|
||||
.map((d) => d.rules.map((r) => r.attribute))
|
||||
.flat(),
|
||||
},
|
||||
{},
|
||||
{ take: null },
|
||||
sharedContext
|
||||
)
|
||||
|
||||
@@ -565,7 +566,7 @@ export default class PricingModuleService<
|
||||
|
||||
return (await this.list(
|
||||
{ id: input.map((d) => d.priceSetId) },
|
||||
{ relations: ["money_amounts"] },
|
||||
{ relations: ["money_amounts"], take: null },
|
||||
sharedContext
|
||||
)) as unknown as PricingTypes.PriceSetDTO[] | PricingTypes.PriceSetDTO
|
||||
}
|
||||
@@ -577,7 +578,7 @@ export default class PricingModuleService<
|
||||
) {
|
||||
const priceSets = await this.list(
|
||||
{ id: input.map((d) => d.priceSetId) },
|
||||
{ relations: ["rule_types"] },
|
||||
{ relations: ["rule_types"], take: null },
|
||||
sharedContext
|
||||
)
|
||||
|
||||
@@ -683,7 +684,7 @@ export default class PricingModuleService<
|
||||
{
|
||||
id: data.map((d) => d.id),
|
||||
},
|
||||
undefined,
|
||||
{ take: null },
|
||||
sharedContext
|
||||
)
|
||||
const priceSetIds = priceSets.map((ps) => ps.id)
|
||||
@@ -692,7 +693,7 @@ export default class PricingModuleService<
|
||||
{
|
||||
rule_attribute: data.map((d) => d.rules || []).flat(),
|
||||
},
|
||||
undefined,
|
||||
{ take: null },
|
||||
sharedContext
|
||||
)
|
||||
const ruleTypeIds = ruleTypes.map((rt) => rt.id)
|
||||
@@ -702,7 +703,7 @@ export default class PricingModuleService<
|
||||
price_set_id: priceSetIds,
|
||||
rule_type_id: ruleTypeIds,
|
||||
},
|
||||
undefined,
|
||||
{ take: null },
|
||||
sharedContext
|
||||
)
|
||||
|
||||
@@ -713,6 +714,7 @@ export default class PricingModuleService<
|
||||
},
|
||||
{
|
||||
select: ["price_set_money_amount"],
|
||||
take: null,
|
||||
},
|
||||
sharedContext
|
||||
)
|
||||
@@ -1389,9 +1391,12 @@ export default class PricingModuleService<
|
||||
.map((priceListData) => Object.keys(priceListData.rules || {}))
|
||||
.flat()
|
||||
|
||||
const ruleTypes = await this.listRuleTypes({
|
||||
rule_attribute: ruleAttributes,
|
||||
})
|
||||
const ruleTypes = await this.listRuleTypes(
|
||||
{
|
||||
rule_attribute: ruleAttributes,
|
||||
},
|
||||
{ take: null }
|
||||
)
|
||||
|
||||
const ruleTypeMap: Map<string, RuleTypeDTO> = new Map(
|
||||
ruleTypes.map((rt) => [rt.rule_attribute, rt])
|
||||
@@ -1514,7 +1519,7 @@ export default class PricingModuleService<
|
||||
|
||||
const existingPriceLists = await this.listPriceLists(
|
||||
{ id: priceListIds },
|
||||
{ relations: ["price_list_rules"] },
|
||||
{ relations: ["price_list_rules"], take: null },
|
||||
sharedContext
|
||||
)
|
||||
|
||||
@@ -1526,7 +1531,7 @@ export default class PricingModuleService<
|
||||
{
|
||||
id: priceListRuleIds,
|
||||
},
|
||||
{},
|
||||
{ take: null },
|
||||
sharedContext
|
||||
)
|
||||
|
||||
@@ -1541,7 +1546,7 @@ export default class PricingModuleService<
|
||||
{
|
||||
rule_attribute: ruleAttributes,
|
||||
},
|
||||
{},
|
||||
{ take: null },
|
||||
sharedContext
|
||||
)
|
||||
|
||||
@@ -1747,7 +1752,9 @@ export default class PricingModuleService<
|
||||
): Promise<PricingTypes.PriceListDTO[]> {
|
||||
const priceLists = await this.listPriceLists(
|
||||
{ id: data.map((d) => d.priceListId) },
|
||||
{},
|
||||
{
|
||||
take: null,
|
||||
},
|
||||
sharedContext
|
||||
)
|
||||
|
||||
@@ -1807,15 +1814,23 @@ export default class PricingModuleService<
|
||||
): Promise<PricingTypes.PriceListDTO[]> {
|
||||
const priceLists = await this.priceListService_.list(
|
||||
{ id: data.map((d) => d.priceListId) },
|
||||
{ relations: ["price_list_rules", "price_list_rules.rule_type"] },
|
||||
{
|
||||
relations: ["price_list_rules", "price_list_rules.rule_type"],
|
||||
take: null,
|
||||
},
|
||||
sharedContext
|
||||
)
|
||||
|
||||
const priceListMap = new Map(priceLists.map((p) => [p.id, p]))
|
||||
|
||||
const ruleTypes = await this.listRuleTypes({
|
||||
rule_attribute: data.map((d) => Object.keys(d.rules)).flat(),
|
||||
})
|
||||
const ruleTypes = await this.listRuleTypes(
|
||||
{
|
||||
rule_attribute: data.map((d) => Object.keys(d.rules)).flat(),
|
||||
},
|
||||
{
|
||||
take: null,
|
||||
}
|
||||
)
|
||||
|
||||
const ruleTypeMap = new Map(ruleTypes.map((rt) => [rt.rule_attribute, rt]))
|
||||
|
||||
@@ -1874,9 +1889,12 @@ export default class PricingModuleService<
|
||||
|
||||
const [createdRules, priceListValuesToDelete] = await Promise.all([
|
||||
this.priceListRuleService_.create(rulesToCreate),
|
||||
this.priceListRuleValueService_.list({
|
||||
price_list_rule_id: ruleIdsToUpdate,
|
||||
}),
|
||||
this.priceListRuleValueService_.list(
|
||||
{
|
||||
price_list_rule_id: ruleIdsToUpdate,
|
||||
},
|
||||
{ take: null }
|
||||
),
|
||||
])
|
||||
|
||||
const priceListRuleValuesToCreate: CreatePriceListRuleValueDTO[] = []
|
||||
@@ -1936,7 +1954,10 @@ export default class PricingModuleService<
|
||||
): Promise<PricingTypes.PriceListDTO[]> {
|
||||
const priceLists = await this.priceListService_.list(
|
||||
{ id: data.map((d) => d.priceListId) },
|
||||
{ relations: ["price_list_rules", "price_list_rules.rule_type"] },
|
||||
{
|
||||
relations: ["price_list_rules", "price_list_rules.rule_type"],
|
||||
take: null,
|
||||
},
|
||||
sharedContext
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user