@medusajs/pricing 0.1.10 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/dist/joiner-config.d.ts +1 -2
  2. package/dist/joiner-config.js +1 -9
  3. package/dist/migrations/Migration20230929122253.js +60 -29
  4. package/dist/migrations/Migration20240322094407.d.ts +5 -0
  5. package/dist/migrations/Migration20240322094407.js +15 -0
  6. package/dist/migrations/{Migration20231101232834.d.ts → Migration20240322113359.d.ts} +1 -1
  7. package/dist/migrations/Migration20240322113359.js +19 -0
  8. package/dist/migrations/{Migration20240103140327.d.ts → Migration20240322120125.d.ts} +1 -1
  9. package/dist/migrations/Migration20240322120125.js +15 -0
  10. package/dist/models/index.d.ts +1 -3
  11. package/dist/models/index.js +3 -7
  12. package/dist/models/price-list-rule-value.d.ts +9 -0
  13. package/dist/models/price-list-rule-value.js +49 -4
  14. package/dist/models/price-list-rule.d.ts +8 -3
  15. package/dist/models/price-list-rule.js +65 -15
  16. package/dist/models/price-list.d.ts +7 -6
  17. package/dist/models/price-list.js +23 -11
  18. package/dist/models/price-rule.d.ts +8 -5
  19. package/dist/models/price-rule.js +63 -19
  20. package/dist/models/price-set-rule-type.d.ts +5 -4
  21. package/dist/models/price-set-rule-type.js +57 -8
  22. package/dist/models/price-set.d.ts +7 -6
  23. package/dist/models/price-set.js +42 -19
  24. package/dist/models/price.d.ts +27 -0
  25. package/dist/models/price.js +167 -0
  26. package/dist/models/rule-type.d.ts +1 -0
  27. package/dist/models/rule-type.js +21 -2
  28. package/dist/repositories/pricing.js +40 -38
  29. package/dist/scripts/seed.js +9 -17
  30. package/dist/services/index.d.ts +0 -3
  31. package/dist/services/index.js +1 -7
  32. package/dist/services/pricing-module.d.ts +19 -33
  33. package/dist/services/pricing-module.js +163 -348
  34. package/dist/services/rule-type.d.ts +5 -6
  35. package/dist/types/index.d.ts +0 -1
  36. package/dist/types/index.js +1 -2
  37. package/dist/types/services/index.d.ts +0 -10
  38. package/dist/types/services/index.js +0 -10
  39. package/dist/types/services/price-list.d.ts +0 -21
  40. package/package.json +5 -5
  41. package/dist/migrations/Migration20231101232834.js +0 -50
  42. package/dist/migrations/Migration20240103140327.js +0 -29
  43. package/dist/models/money-amount.d.ts +0 -19
  44. package/dist/models/money-amount.js +0 -111
  45. package/dist/models/price-set-money-amount-rules.d.ts +0 -10
  46. package/dist/models/price-set-money-amount-rules.js +0 -63
  47. package/dist/models/price-set-money-amount.d.ts +0 -24
  48. package/dist/models/price-set-money-amount.js +0 -128
  49. package/dist/services/price-list-rule-value.d.ts +0 -13
  50. package/dist/services/price-list-rule-value.js +0 -22
  51. package/dist/services/price-list-rule.d.ts +0 -15
  52. package/dist/services/price-list-rule.js +0 -41
  53. package/dist/services/price-rule.d.ts +0 -13
  54. package/dist/services/price-rule.js +0 -22
  55. package/dist/types/repositories/index.d.ts +0 -10
  56. package/dist/types/repositories/index.js +0 -26
  57. package/dist/types/repositories/money-amount.d.ts +0 -14
  58. package/dist/types/repositories/money-amount.js +0 -2
  59. package/dist/types/repositories/price-list-rule-value.d.ts +0 -10
  60. package/dist/types/repositories/price-list-rule-value.js +0 -2
  61. package/dist/types/repositories/price-list-rule.d.ts +0 -14
  62. package/dist/types/repositories/price-list-rule.js +0 -2
  63. package/dist/types/repositories/price-list.d.ts +0 -18
  64. package/dist/types/repositories/price-list.js +0 -2
  65. package/dist/types/repositories/price-rule.d.ts +0 -21
  66. package/dist/types/repositories/price-rule.js +0 -2
  67. package/dist/types/repositories/price-set-money-amount-rules.d.ts +0 -11
  68. package/dist/types/repositories/price-set-money-amount-rules.js +0 -2
  69. package/dist/types/repositories/price-set-money-amount.d.ts +0 -13
  70. package/dist/types/repositories/price-set-money-amount.js +0 -2
  71. package/dist/types/repositories/price-set-rule-type.d.ts +0 -10
  72. package/dist/types/repositories/price-set-rule-type.js +0 -2
  73. package/dist/types/repositories/price-set.d.ts +0 -5
  74. package/dist/types/repositories/price-set.js +0 -2
  75. package/dist/types/repositories/rule-type.d.ts +0 -12
  76. package/dist/types/repositories/rule-type.js +0 -2
  77. package/dist/types/services/money-amount.d.ts +0 -30
  78. package/dist/types/services/money-amount.js +0 -2
  79. package/dist/types/services/price-list-rule-value.d.ts +0 -21
  80. package/dist/types/services/price-list-rule-value.js +0 -2
  81. package/dist/types/services/price-list-rule.d.ts +0 -27
  82. package/dist/types/services/price-list-rule.js +0 -2
  83. package/dist/types/services/price-rule.d.ts +0 -42
  84. package/dist/types/services/price-rule.js +0 -2
  85. package/dist/types/services/price-set-money-amount-rules.d.ts +0 -24
  86. package/dist/types/services/price-set-money-amount-rules.js +0 -2
  87. package/dist/types/services/price-set-money-amount.d.ts +0 -32
  88. package/dist/types/services/price-set-money-amount.js +0 -2
  89. package/dist/types/services/price-set-rule-type.d.ts +0 -21
  90. package/dist/types/services/price-set-rule-type.js +0 -2
  91. package/dist/types/services/price-set.d.ts +0 -15
  92. package/dist/types/services/price-set.js +0 -2
  93. package/dist/types/services/pricing.d.ts +0 -20
  94. package/dist/types/services/pricing.js +0 -2
  95. package/dist/types/services/rule-type.d.ts +0 -32
  96. package/dist/types/services/rule-type.js +0 -2
@@ -17,32 +17,30 @@ const utils_1 = require("@medusajs/utils");
17
17
  const _models_1 = require("../models");
18
18
  const _utils_1 = require("../utils");
19
19
  const joiner_config_1 = require("../joiner-config");
20
+ const price_set_1 = require("../models/price-set");
21
+ const price_list_1 = require("../models/price-list");
20
22
  const generateMethodForModels = [
21
- _models_1.MoneyAmount,
22
23
  _models_1.PriceList,
23
24
  _models_1.PriceListRule,
24
25
  _models_1.PriceListRuleValue,
25
26
  _models_1.PriceRule,
26
- _models_1.PriceSetMoneyAmount,
27
- _models_1.PriceSetMoneyAmountRules,
27
+ _models_1.Price,
28
28
  _models_1.PriceSetRuleType,
29
29
  _models_1.RuleType,
30
30
  ];
31
31
  class PricingModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFactory(_models_1.PriceSet, generateMethodForModels, joiner_config_1.entityNameToLinkableKeysMap) {
32
- constructor({ baseRepository, pricingRepository, moneyAmountService, ruleTypeService, priceSetService, priceSetMoneyAmountRulesService, priceRuleService, priceSetRuleTypeService, priceSetMoneyAmountService, priceListService, priceListRuleService, priceListRuleValueService, }, moduleDeclaration) {
32
+ constructor({ baseRepository, pricingRepository, ruleTypeService, priceSetService, priceRuleService, priceSetRuleTypeService, priceService, priceListService, priceListRuleService, priceListRuleValueService, }, moduleDeclaration) {
33
33
  // @ts-ignore
34
34
  super(...arguments);
35
35
  this.moduleDeclaration = moduleDeclaration;
36
36
  this.baseRepository_ = baseRepository;
37
37
  this.pricingRepository_ = pricingRepository;
38
- this.moneyAmountService_ = moneyAmountService;
39
38
  this.ruleTypeService_ = ruleTypeService;
40
39
  this.priceSetService_ = priceSetService;
41
- this.priceSetMoneyAmountRulesService_ = priceSetMoneyAmountRulesService;
42
40
  this.ruleTypeService_ = ruleTypeService;
43
41
  this.priceRuleService_ = priceRuleService;
44
42
  this.priceSetRuleTypeService_ = priceSetRuleTypeService;
45
- this.priceSetMoneyAmountService_ = priceSetMoneyAmountService;
43
+ this.priceService_ = priceService;
46
44
  this.priceListService_ = priceListService;
47
45
  this.priceListRuleService_ = priceListRuleService;
48
46
  this.priceListRuleValueService_ = priceListRuleValueService;
@@ -76,14 +74,14 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.abstractModuleService
76
74
  original_amount: parseInt(originalPrice?.amount || "") || null,
77
75
  currency_code: calculatedPrice?.currency_code || null,
78
76
  calculated_price: {
79
- money_amount_id: calculatedPrice?.id || null,
77
+ id: calculatedPrice?.id || null,
80
78
  price_list_id: calculatedPrice?.price_list_id || null,
81
79
  price_list_type: calculatedPrice?.price_list_type || null,
82
80
  min_quantity: parseInt(calculatedPrice?.min_quantity || "") || null,
83
81
  max_quantity: parseInt(calculatedPrice?.max_quantity || "") || null,
84
82
  },
85
83
  original_price: {
86
- money_amount_id: originalPrice?.id || null,
84
+ id: originalPrice?.id || null,
87
85
  price_list_id: originalPrice?.price_list_id || null,
88
86
  price_list_type: originalPrice?.price_list_type || null,
89
87
  min_quantity: parseInt(originalPrice?.min_quantity || "") || null,
@@ -96,18 +94,19 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.abstractModuleService
96
94
  async create(data, sharedContext = {}) {
97
95
  const input = Array.isArray(data) ? data : [data];
98
96
  const priceSets = await this.create_(input, sharedContext);
99
- const dbPriceSets = await this.list({ id: priceSets.filter((p) => !!p).map((p) => p.id) }, {
100
- relations: ["rule_types", "money_amounts", "price_rules"],
101
- }, sharedContext);
102
- return (Array.isArray(data) ? dbPriceSets : dbPriceSets[0]);
97
+ const dbPriceSets = await this.list({ id: priceSets.map((p) => p.id) }, { relations: ["rule_types", "prices", "price_rules"] }, sharedContext);
98
+ // Ensure the output to be in the same order as the input
99
+ const results = priceSets.map((priceSet) => {
100
+ return dbPriceSets.find((p) => p.id === priceSet.id);
101
+ });
102
+ return Array.isArray(data) ? results : results[0];
103
103
  }
104
104
  async create_(data, sharedContext = {}) {
105
+ const input = Array.isArray(data) ? data : [data];
105
106
  const ruleAttributes = data
106
107
  .map((d) => d.rules?.map((r) => r.rule_attribute) ?? [])
107
108
  .flat();
108
- const ruleTypes = await this.ruleTypeService_.list({
109
- rule_attribute: ruleAttributes,
110
- }, { take: null }, sharedContext);
109
+ const ruleTypes = await this.ruleTypeService_.list({ rule_attribute: ruleAttributes }, { take: null }, sharedContext);
111
110
  const ruleTypeMap = ruleTypes.reduce((acc, curr) => {
112
111
  acc.set(curr.rule_attribute, curr);
113
112
  return acc;
@@ -123,68 +122,62 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.abstractModuleService
123
122
  if (invalidMoneyAmountRule.length > 0) {
124
123
  throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Rule types don't exist for money amounts with rule attribute: ${invalidMoneyAmountRule.join(", ")}`);
125
124
  }
126
- // Bulk create price sets
127
- const priceSetData = data.map(({ rules, prices, ...rest }) => rest);
128
- const createdPriceSets = await this.priceSetService_.create(priceSetData, sharedContext);
129
- // Price set rule types
130
- const ruleTypeData = data.flatMap((item, index) => item.rules?.map((rule) => ({
131
- rule_type: ruleTypeMap.get(rule.rule_attribute),
132
- price_set: createdPriceSets[index],
133
- })) || []);
134
- if (ruleTypeData.length > 0) {
135
- await this.priceSetRuleTypeService_.create(ruleTypeData, sharedContext);
136
- }
137
- // Money amounts
138
- const moneyAmountData = data.flatMap((item) => item.prices || []);
139
- const createdMoneyAmounts = await this.moneyAmountService_.create(moneyAmountData, sharedContext);
140
- let moneyAmountIndex = 0;
141
- const priceSetMoneyAmountData = [];
142
- const priceRulesData = [];
143
- for (const [index, item] of data.entries()) {
144
- for (const ma of item.prices || []) {
145
- const cleanRules = ma.rules ? (0, utils_1.removeNullish)(ma.rules) : {};
146
- const numberOfRules = Object.entries(cleanRules).length;
147
- const priceSetMoneyAmount = {
148
- price_set: createdPriceSets[index],
149
- money_amount: createdMoneyAmounts[moneyAmountIndex++],
150
- title: "test",
151
- rules_count: numberOfRules,
125
+ const ruleSetRuleTypeToCreateMap = new Map();
126
+ const toCreate = input.map((inputData) => {
127
+ const id = (0, utils_1.generateEntityId)(inputData.id, price_set_1.PriceSetIdPrefix);
128
+ const { prices, rules = [], ...rest } = inputData;
129
+ let pricesData = [];
130
+ rules.forEach((rule) => {
131
+ const priceSetRuleType = {
132
+ rule_type_id: ruleTypeMap.get(rule.rule_attribute).id,
133
+ price_set_id: id,
152
134
  };
153
- priceSetMoneyAmountData.push(priceSetMoneyAmount);
154
- for (const [k, v] of Object.entries(cleanRules)) {
155
- priceRulesData.push({
156
- price_set_money_amount: null,
157
- rule_type: ruleTypeMap.get(k),
158
- price_set: createdPriceSets[index],
159
- value: v,
160
- price_list_id: "test",
135
+ ruleSetRuleTypeToCreateMap.set(JSON.stringify(priceSetRuleType), priceSetRuleType);
136
+ });
137
+ if (inputData.prices) {
138
+ pricesData = inputData.prices.map((price) => {
139
+ let { rules: priceRules = {}, ...rest } = price;
140
+ const cleanRules = priceRules ? (0, utils_1.removeNullish)(priceRules) : {};
141
+ const numberOfRules = Object.keys(cleanRules).length;
142
+ const rulesDataMap = new Map();
143
+ Object.entries(priceRules).map(([attribute, value]) => {
144
+ const rule = {
145
+ price_set_id: id,
146
+ rule_type_id: ruleTypeMap.get(attribute).id,
147
+ value,
148
+ };
149
+ rulesDataMap.set(JSON.stringify(rule), rule);
150
+ const priceSetRuleType = {
151
+ rule_type_id: ruleTypeMap.get(attribute).id,
152
+ price_set_id: id,
153
+ };
154
+ ruleSetRuleTypeToCreateMap.set(JSON.stringify(priceSetRuleType), priceSetRuleType);
161
155
  });
162
- }
163
- }
164
- }
165
- // Bulk create price set money amounts
166
- const createdPriceSetMoneyAmounts = await this.priceSetMoneyAmountService_.create(priceSetMoneyAmountData, sharedContext);
167
- // Update price set money amount references
168
- for (let i = 0, j = 0; i < priceSetMoneyAmountData.length; i++) {
169
- const rulesCount = priceSetMoneyAmountData[i].rules_count;
170
- for (let k = 0; k < rulesCount; k++, j++) {
171
- ;
172
- priceRulesData[j].price_set_money_amount =
173
- createdPriceSetMoneyAmounts[i];
156
+ return {
157
+ ...rest,
158
+ title: "test",
159
+ rules_count: numberOfRules,
160
+ price_rules: Array.from(rulesDataMap.values()),
161
+ };
162
+ });
174
163
  }
175
- }
176
- // Price rules
177
- if (priceRulesData.length > 0) {
178
- await this.priceRuleService_.create(priceRulesData, sharedContext);
164
+ return {
165
+ ...rest,
166
+ id,
167
+ prices: pricesData,
168
+ };
169
+ });
170
+ // Bulk create price sets
171
+ const createdPriceSets = await this.priceSetService_.create(toCreate, sharedContext);
172
+ if (ruleSetRuleTypeToCreateMap.size) {
173
+ await this.priceSetRuleTypeService_.create(Array.from(ruleSetRuleTypeToCreateMap.values()), sharedContext);
179
174
  }
180
175
  return createdPriceSets;
181
176
  }
182
177
  async addRules(data, sharedContext = {}) {
183
178
  const inputs = Array.isArray(data) ? data : [data];
184
179
  const priceSets = await this.addRules_(inputs, sharedContext);
185
- return await this.list({ id: priceSets.map(({ id }) => id) }, {
186
- relations: ["rule_types"],
187
- });
180
+ return await this.list({ id: priceSets.map(({ id }) => id) }, { relations: ["rule_types"] });
188
181
  }
189
182
  async addRules_(inputs, sharedContext = {}) {
190
183
  const priceSets = await this.priceSetService_.list({ id: inputs.map((d) => d.priceSetId) }, { relations: ["rule_types"] }, sharedContext);
@@ -201,7 +194,7 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.abstractModuleService
201
194
  }
202
195
  const ruleTypes = await this.ruleTypeService_.list({
203
196
  rule_attribute: inputs
204
- .map((d) => d.rules.map((r) => r.attribute))
197
+ .map((data) => data.rules.map((r) => r.attribute))
205
198
  .flat(),
206
199
  }, { take: null }, sharedContext);
207
200
  const ruleTypeMap = new Map(ruleTypes.map((rt) => [rt.rule_attribute, rt]));
@@ -215,15 +208,14 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.abstractModuleService
215
208
  ].join(", ")}`);
216
209
  }
217
210
  const priceSetRuleTypesCreate = [];
218
- inputs.forEach((d) => {
219
- const priceSet = priceSetMap.get(d.priceSetId);
220
- for (const r of d.rules) {
221
- if (priceSetRuleTypeMap.get(d.priceSetId).has(r.attribute)) {
211
+ inputs.forEach((data) => {
212
+ for (const rule of data.rules) {
213
+ if (priceSetRuleTypeMap.get(data.priceSetId).has(rule.attribute)) {
222
214
  continue;
223
215
  }
224
216
  priceSetRuleTypesCreate.push({
225
- rule_type: ruleTypeMap.get(r.attribute),
226
- price_set: priceSet,
217
+ rule_type_id: ruleTypeMap.get(rule.attribute).id,
218
+ price_set_id: priceSetMap.get(data.priceSetId).id,
227
219
  });
228
220
  }
229
221
  });
@@ -233,7 +225,7 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.abstractModuleService
233
225
  async addPrices(data, sharedContext = {}) {
234
226
  const input = Array.isArray(data) ? data : [data];
235
227
  await this.addPrices_(input, sharedContext);
236
- return (await this.list({ id: input.map((d) => d.priceSetId) }, { relations: ["money_amounts"] }, sharedContext));
228
+ return await this.list({ id: input.map((d) => d.priceSetId) }, { relations: ["prices"] }, sharedContext);
237
229
  }
238
230
  async addPrices_(input, sharedContext = {}) {
239
231
  const priceSets = await this.list({ id: input.map((d) => d.priceSetId) }, { relations: ["rule_types"] }, sharedContext);
@@ -255,33 +247,26 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.abstractModuleService
255
247
  throw new utils_1.MedusaError(utils_1.MedusaError.Types.NOT_FOUND, `Rule types don't exist for: ${invalidRuleAttributes.join(", ")}`);
256
248
  }
257
249
  });
258
- // Money amounts
259
- const moneyAmountsBulkData = input.flatMap((entry) => entry.prices);
260
- const createdMoneyAmounts = await this.moneyAmountService_.create(moneyAmountsBulkData, sharedContext);
261
- // Price set money amounts
262
- let maCursor = 0;
263
- const priceSetMoneyAmountsBulkData = input.flatMap(({ priceSetId, prices }) => prices.map(() => {
264
- const ma = createdMoneyAmounts[maCursor];
265
- const numberOfRules = Object.entries(prices[maCursor]?.rules ?? {}).length;
266
- maCursor++;
250
+ const pricesToCreate = input.flatMap(({ priceSetId, prices }) => prices.map((price) => {
251
+ const numberOfRules = Object.entries(price?.rules ?? {}).length;
267
252
  return {
268
- price_set: priceSetId,
269
- money_amount: ma,
253
+ ...price,
254
+ price_set_id: priceSetId,
270
255
  title: "test",
271
256
  rules_count: numberOfRules,
272
257
  };
273
258
  }));
274
- const createdPriceSetMoneyAmounts = await this.priceSetMoneyAmountService_.create(priceSetMoneyAmountsBulkData, sharedContext);
259
+ const createdPrices = await this.priceService_.create(pricesToCreate, sharedContext);
275
260
  // Price rules
276
261
  let rulesCursor = 0;
277
262
  const priceRulesBulkData = input.flatMap(({ priceSetId, prices }) => prices.flatMap((ma) => {
278
263
  const rules = ma.rules ?? {};
279
- const priceSetMoneyAmount = createdPriceSetMoneyAmounts[rulesCursor];
264
+ const price = createdPrices[rulesCursor];
280
265
  rulesCursor++;
281
266
  return Object.entries(rules).map(([k, v]) => ({
282
- price_set_money_amount: priceSetMoneyAmount,
267
+ price_id: price.id,
283
268
  rule_type_id: ruleTypeMap.get(priceSetId).get(k).id,
284
- price_set: priceSetId,
269
+ price_set_id: priceSetId,
285
270
  value: v,
286
271
  }));
287
272
  }));
@@ -290,87 +275,24 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.abstractModuleService
290
275
  }
291
276
  }
292
277
  async removeRules(data, sharedContext = {}) {
293
- const priceSets = await this.priceSetService_.list({
294
- id: data.map((d) => d.id),
295
- }, {}, sharedContext);
278
+ const priceSets = await this.priceSetService_.list({ id: data.map((d) => d.id) }, {}, sharedContext);
296
279
  const priceSetIds = priceSets.map((ps) => ps.id);
297
280
  const ruleTypes = await this.ruleTypeService_.list({
298
281
  rule_attribute: data.map((d) => d.rules || []).flat(),
299
282
  }, { take: null }, sharedContext);
300
283
  const ruleTypeIds = ruleTypes.map((rt) => rt.id);
301
- const priceSetRuleTypes = await this.priceSetRuleTypeService_.list({
302
- price_set_id: priceSetIds,
303
- rule_type_id: ruleTypeIds,
304
- }, { take: null }, sharedContext);
305
- const priceRules = await this.priceRuleService_.list({
306
- price_set_id: priceSetIds,
307
- rule_type_id: ruleTypeIds,
308
- }, {
309
- select: ["price_set_money_amount"],
310
- take: null,
311
- }, sharedContext);
284
+ const priceSetRuleTypes = await this.priceSetRuleTypeService_.list({ price_set_id: priceSetIds, rule_type_id: ruleTypeIds }, { take: null }, sharedContext);
285
+ const priceRules = await this.priceRuleService_.list({ price_set_id: priceSetIds, rule_type_id: ruleTypeIds }, { select: ["price"], take: null }, sharedContext);
312
286
  await this.priceSetRuleTypeService_.delete(priceSetRuleTypes.map((psrt) => psrt.id), sharedContext);
313
- await this.priceSetMoneyAmountService_.delete(priceRules.map((pr) => pr.price_set_money_amount.id), sharedContext);
287
+ await this.priceService_.delete(priceRules.map((pr) => pr.price.id), sharedContext);
314
288
  }
315
289
  async update(data, sharedContext = {}) {
316
290
  const priceSets = await this.priceSetService_.update(data, sharedContext);
317
- return await this.baseRepository_.serialize(priceSets, {
318
- populate: true,
319
- });
320
- }
321
- async createMoneyAmounts(data, sharedContext = {}) {
322
- const moneyAmounts = await this.moneyAmountService_.create(data, sharedContext);
323
- return await this.baseRepository_.serialize(moneyAmounts, {
324
- populate: true,
325
- });
326
- }
327
- async updateMoneyAmounts(data, sharedContext = {}) {
328
- const moneyAmounts = await this.moneyAmountService_.update(data, sharedContext);
329
- return await this.baseRepository_.serialize(moneyAmounts, {
330
- populate: true,
331
- });
332
- }
333
- async createRuleTypes(data, sharedContext = {}) {
334
- const ruleTypes = await this.ruleTypeService_.create(data, sharedContext);
335
- return await this.baseRepository_.serialize(ruleTypes, {
336
- populate: true,
337
- });
338
- }
339
- async updateRuleTypes(data, sharedContext = {}) {
340
- const ruleTypes = await this.ruleTypeService_.update(data, sharedContext);
341
- return await this.baseRepository_.serialize(ruleTypes, {
342
- populate: true,
343
- });
344
- }
345
- async createPriceSetMoneyAmountRules(data, sharedContext = {}) {
346
- const records = await this.priceSetMoneyAmountRulesService_.create(data, sharedContext);
347
- return await this.baseRepository_.serialize(records, {
348
- populate: true,
349
- });
350
- }
351
- async updatePriceSetMoneyAmountRules(data, sharedContext = {}) {
352
- const records = await this.priceSetMoneyAmountRulesService_.update(data, sharedContext);
353
- return await this.baseRepository_.serialize(records, {
354
- populate: true,
355
- });
356
- }
357
- async createPriceRules(data, sharedContext = {}) {
358
- const priceRules = await this.priceRuleService_.create(data, sharedContext);
359
- return await this.baseRepository_.serialize(priceRules, {
360
- populate: true,
361
- });
362
- }
363
- async updatePriceRules(data, sharedContext = {}) {
364
- const priceRules = await this.priceRuleService_.update(data, sharedContext);
365
- return await this.baseRepository_.serialize(priceRules, {
366
- populate: true,
367
- });
291
+ return await this.baseRepository_.serialize(priceSets, { populate: true });
368
292
  }
369
293
  async createPriceLists(data, sharedContext = {}) {
370
294
  const priceLists = await this.createPriceLists_(data, sharedContext);
371
- return await this.baseRepository_.serialize(priceLists, {
372
- populate: true,
373
- });
295
+ return await this.baseRepository_.serialize(priceLists, { populate: true });
374
296
  }
375
297
  async createPriceLists_(data, sharedContext = {}) {
376
298
  const ruleTypeAttributes = [];
@@ -382,74 +304,53 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.abstractModuleService
382
304
  ruleTypeAttributes.push(...Object.keys(priceListPriceRules));
383
305
  }
384
306
  }
385
- const ruleTypes = await this.listRuleTypes({ rule_attribute: ruleTypeAttributes }, { take: null });
307
+ const ruleTypes = await this.listRuleTypes({ rule_attribute: ruleTypeAttributes }, { take: null }, sharedContext);
386
308
  const invalidRuleTypes = (0, utils_1.arrayDifference)((0, utils_1.deduplicate)(ruleTypeAttributes), ruleTypes.map((ruleType) => ruleType.rule_attribute));
387
309
  if (invalidRuleTypes.length) {
388
310
  throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Cannot find RuleTypes with rule_attribute - ${invalidRuleTypes.join(", ")}`);
389
311
  }
390
312
  const ruleTypeMap = new Map(ruleTypes.map((rt) => [rt.rule_attribute, rt]));
391
- const priceListsToCreate = [];
392
- for (const priceListData of data) {
393
- const { rules = {}, prices = [], ...priceListOnlyData } = priceListData;
313
+ const priceListsToCreate = data.map((priceListData) => {
314
+ const id = (0, utils_1.generateEntityId)(priceListData.id, price_list_1.PriceListIdPrefix);
315
+ const { prices = [], rules = {}, ...rest } = priceListData;
394
316
  (0, _utils_1.validatePriceListDates)(priceListData);
395
- priceListsToCreate.push({
396
- ...priceListOnlyData,
397
- rules_count: Object.keys(rules).length,
317
+ const priceListRules = Object.entries(rules).map(([attribute, value]) => {
318
+ const ruleType = ruleTypeMap.get(attribute);
319
+ return {
320
+ price_list_id: id,
321
+ rule_type_id: ruleType.id,
322
+ price_list_rule_values: value.map((v) => ({ value: v }))
323
+ };
398
324
  });
399
- }
400
- const priceLists = (await this.priceListService_.create(priceListsToCreate));
401
- for (let i = 0; i < data.length; i++) {
402
- const { rules = {}, prices = [] } = data[i];
403
- const priceList = priceLists[i];
404
- for (const [ruleAttribute, ruleValues = []] of Object.entries(rules)) {
405
- let ruleType = ruleTypeMap.get(ruleAttribute);
406
- // Create the rule
407
- const [priceListRule] = await this.priceListRuleService_.create([
408
- {
409
- price_list: priceList,
410
- rule_type: ruleType.id,
411
- },
412
- ], sharedContext);
413
- // Create the values for the rule
414
- for (const ruleValue of ruleValues) {
415
- await this.priceListRuleValueService_.create([
416
- {
417
- price_list_rule: priceListRule,
418
- value: ruleValue,
419
- },
420
- ], sharedContext);
421
- }
422
- }
423
- for (const price of prices) {
424
- const { price_set_id: priceSetId, rules: priceRules = {}, ...moneyAmountData } = price;
425
- const [moneyAmount] = await this.moneyAmountService_.create([moneyAmountData], sharedContext);
426
- const [priceSetMoneyAmount] = await this.priceSetMoneyAmountService_.create([
427
- {
428
- price_set: priceSetId,
429
- price_list: priceList,
430
- money_amount: moneyAmount,
431
- title: "test",
432
- rules_count: Object.keys(priceRules).length,
433
- },
434
- ], sharedContext);
435
- await this.createPriceRules(Object.entries(priceRules).map(([ruleAttribute, ruleValue]) => {
325
+ const pricesData = prices.map((price) => {
326
+ const priceRules = Object.entries(price.rules ?? {}).map(([ruleAttribute, ruleValue]) => {
436
327
  return {
437
- price_set_id: priceSetId,
438
- rule_type: ruleTypeMap.get(ruleAttribute)?.id ||
439
- ruleTypeMap.get(ruleAttribute),
328
+ price_set_id: price.price_set_id,
329
+ rule_type_id: ruleTypeMap.get(ruleAttribute)?.id,
440
330
  value: ruleValue,
441
- price_set_money_amount: priceSetMoneyAmount,
442
331
  };
443
- }), sharedContext);
444
- }
445
- }
446
- return priceLists;
332
+ });
333
+ return {
334
+ price_list_id: id,
335
+ title: "test",
336
+ rules_count: Object.keys(price.rules ?? {}).length,
337
+ price_rules: priceRules,
338
+ ...price,
339
+ };
340
+ });
341
+ return {
342
+ id,
343
+ ...rest,
344
+ rules_count: Object.keys(rules).length,
345
+ price_list_rules: priceListRules,
346
+ prices: pricesData,
347
+ };
348
+ });
349
+ return await this.priceListService_.create(priceListsToCreate, sharedContext);
447
350
  }
448
351
  async updatePriceLists(data, sharedContext = {}) {
449
352
  const priceLists = await this.updatePriceLists_(data, sharedContext);
450
- return await this.baseRepository_.serialize(priceLists, {
451
- populate: true,
452
- });
353
+ return await this.baseRepository_.serialize(priceLists, { populate: true });
453
354
  }
454
355
  async updatePriceLists_(data, sharedContext = {}) {
455
356
  const updatedPriceLists = [];
@@ -491,12 +392,12 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.abstractModuleService
491
392
  }
492
393
  const [priceListRule] = await this.priceListRuleService_.create([
493
394
  {
494
- price_list: updatedPriceList,
495
- rule_type: ruleType?.id || ruleType,
395
+ price_list_id: updatedPriceList.id,
396
+ rule_type_id: ruleType?.id,
496
397
  },
497
398
  ], sharedContext);
498
399
  for (const ruleValue of ruleValues) {
499
- await this.priceListRuleValueService_.create([{ price_list_rule: priceListRule, value: ruleValue }], sharedContext);
400
+ await this.priceListRuleValueService_.create([{ price_list_rule_id: priceListRule.id, value: ruleValue }], sharedContext);
500
401
  }
501
402
  }
502
403
  }
@@ -523,25 +424,19 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.abstractModuleService
523
424
  async updatePriceListPrices_(data, sharedContext = {}) {
524
425
  const ruleTypeAttributes = [];
525
426
  const priceListIds = [];
526
- const moneyAmountIds = [];
427
+ const priceIds = [];
527
428
  const priceSetIds = data
528
429
  .map((d) => d.prices.map((price) => price.price_set_id))
529
430
  .flat();
530
431
  for (const priceListData of data) {
531
432
  priceListIds.push(priceListData.price_list_id);
532
433
  for (const price of priceListData.prices) {
533
- moneyAmountIds.push(price.id);
434
+ priceIds.push(price.id);
534
435
  ruleTypeAttributes.push(...Object.keys(price.rules || {}));
535
436
  }
536
437
  }
537
- const moneyAmounts = await this.listMoneyAmounts({ id: moneyAmountIds }, {
538
- take: null,
539
- relations: [
540
- "price_set_money_amount",
541
- "price_set_money_amount.price_rules",
542
- ],
543
- }, sharedContext);
544
- const moneyAmountMap = new Map(moneyAmounts.map((ma) => [ma.id, ma]));
438
+ const prices = await this.listPrices({ id: priceIds }, { take: null, relations: ["price_rules"] }, sharedContext);
439
+ const priceMap = new Map(prices.map((price) => [price.id, price]));
545
440
  const ruleTypes = await this.listRuleTypes({ rule_attribute: ruleTypeAttributes }, { take: null }, sharedContext);
546
441
  const ruleTypeMap = new Map(ruleTypes.map((rt) => [rt.rule_attribute, rt]));
547
442
  const priceSets = await this.list({ id: priceSetIds }, { relations: ["rule_types"] }, sharedContext);
@@ -573,36 +468,32 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.abstractModuleService
573
468
  if (!priceList) {
574
469
  throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Price list with id: ${priceListId} not found`);
575
470
  }
576
- const moneyAmountsToUpdate = [];
577
- const priceRulesToDelete = [];
471
+ const priceRuleIdsToDelete = [];
578
472
  const priceRulesToCreate = [];
579
- const psmaToUpdate = [];
580
- for (const price of prices) {
581
- const { rules, price_set_id, ...priceData } = price;
582
- const moneyAmount = moneyAmountMap.get(price.id);
583
- const priceSetMoneyAmount = moneyAmount.price_set_money_amount;
584
- const priceRules = priceSetMoneyAmount.price_rules;
585
- moneyAmountsToUpdate.push(priceData);
473
+ const pricesToUpdate = [];
474
+ for (const priceData of prices) {
475
+ const { rules, price_set_id, ...rest } = priceData;
476
+ const price = priceMap.get(rest.id);
477
+ const priceRules = price.price_rules;
586
478
  if (typeof rules === "undefined") {
587
479
  continue;
588
480
  }
589
- psmaToUpdate.push({
590
- id: priceSetMoneyAmount.id,
481
+ pricesToUpdate.push({
482
+ ...rest,
591
483
  rules_count: Object.keys(rules).length,
592
484
  });
593
- priceRulesToDelete.push(...priceRules.map((pr) => pr.id));
485
+ priceRuleIdsToDelete.push(...priceRules.map((pr) => pr.id));
594
486
  priceRulesToCreate.push(...Object.entries(rules).map(([ruleAttribute, ruleValue]) => ({
595
- price_set_id: price.price_set_id,
487
+ price_set_id,
596
488
  rule_type_id: ruleTypeMap.get(ruleAttribute).id,
597
489
  value: ruleValue,
598
- price_set_money_amount_id: priceSetMoneyAmount.id,
490
+ price_id: price.id,
599
491
  })));
600
492
  }
601
493
  await Promise.all([
602
- this.moneyAmountService_.update(moneyAmountsToUpdate),
603
- this.priceRuleService_.delete(priceRulesToDelete),
494
+ this.priceRuleService_.delete(priceRuleIdsToDelete),
604
495
  this.priceRuleService_.create(priceRulesToCreate),
605
- this.priceSetMoneyAmountService_.update(psmaToUpdate),
496
+ this.priceService_.update(pricesToUpdate),
606
497
  ]);
607
498
  }
608
499
  return priceLists;
@@ -611,7 +502,7 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.abstractModuleService
611
502
  await this.removePrices_(ids, sharedContext);
612
503
  }
613
504
  async removePrices_(ids, sharedContext = {}) {
614
- await this.priceSetMoneyAmountService_.delete(ids, sharedContext);
505
+ await this.priceService_.delete(ids, sharedContext);
615
506
  }
616
507
  async addPriceListPrices(data, sharedContext = {}) {
617
508
  return await this.addPriceListPrices_(data, sharedContext);
@@ -658,29 +549,27 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.abstractModuleService
658
549
  if (!priceList) {
659
550
  throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Price list with id: ${priceListId} not found`);
660
551
  }
661
- await Promise.all(prices.map(async (price) => {
662
- const priceRules = price.rules || {};
552
+ await Promise.all(prices.map(async (priceData) => {
553
+ const priceRules = priceData.rules || {};
663
554
  const noOfRules = Object.keys(priceRules).length;
664
- const [moneyAmount] = await this.moneyAmountService_.create([price], sharedContext);
665
- const [psma] = await this.priceSetMoneyAmountService_.create([
555
+ const [price] = await this.priceService_.create([
666
556
  {
667
- price_set: price.price_set_id,
668
- money_amount: moneyAmount.id,
557
+ ...priceData,
558
+ price_set_id: priceData.price_set_id,
669
559
  title: "test",
670
- price_list: priceList.id,
560
+ price_list_id: priceList.id,
671
561
  rules_count: noOfRules,
672
562
  },
673
563
  ], sharedContext);
674
- await this.createPriceRules(Object.entries(priceRules).map(([ruleAttribute, ruleValue]) => {
564
+ await this.priceRuleService_.create(Object.entries(priceRules).map(([ruleAttribute, ruleValue]) => {
675
565
  return {
676
- price_set_id: price.price_set_id,
677
- rule_type: ruleTypeMap.get(ruleAttribute)?.id ||
678
- ruleTypeMap.get(ruleAttribute),
566
+ price_set_id: priceData.price_set_id,
567
+ rule_type_id: ruleTypeMap.get(ruleAttribute)?.id,
679
568
  value: ruleValue,
680
- price_set_money_amount: psma,
569
+ price_id: price.id,
681
570
  };
682
571
  }), sharedContext);
683
- return psma;
572
+ return price;
684
573
  }));
685
574
  }
686
575
  return priceLists;
@@ -690,15 +579,9 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.abstractModuleService
690
579
  return priceList;
691
580
  }
692
581
  async setPriceListRules_(data, sharedContext = {}) {
693
- const priceLists = await this.priceListService_.list({ id: data.map((d) => d.price_list_id) }, {
694
- relations: ["price_list_rules", "price_list_rules.rule_type"],
695
- }, sharedContext);
582
+ const priceLists = await this.priceListService_.list({ id: data.map((d) => d.price_list_id) }, { relations: ["price_list_rules", "price_list_rules.rule_type"] }, sharedContext);
696
583
  const priceListMap = new Map(priceLists.map((p) => [p.id, p]));
697
- const ruleTypes = await this.listRuleTypes({
698
- rule_attribute: data.map((d) => Object.keys(d.rules)).flat(),
699
- }, {
700
- take: null,
701
- });
584
+ const ruleTypes = await this.listRuleTypes({ rule_attribute: data.map((d) => Object.keys(d.rules)).flat() }, { take: null });
702
585
  const ruleTypeMap = new Map(ruleTypes.map((rt) => [rt.rule_attribute, rt]));
703
586
  const ruleIdsToUpdate = [];
704
587
  const rulesToCreate = [];
@@ -708,9 +591,7 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.abstractModuleService
708
591
  if (!priceList) {
709
592
  throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Price list with id: ${priceListId} not found`);
710
593
  }
711
- const priceListRulesMap = new Map(priceList.price_list_rules
712
- .getItems()
713
- .map((p) => [p.rule_type.rule_attribute, p]));
594
+ const priceListRulesMap = new Map(priceList.price_list_rules.map((p) => [p.rule_type.rule_attribute, p]));
714
595
  const priceListRuleValues = new Map();
715
596
  await Promise.all(Object.entries(rules).map(async ([key, value]) => {
716
597
  const ruleType = ruleTypeMap.get(key);
@@ -721,8 +602,8 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.abstractModuleService
721
602
  priceListRuleValues.set(ruleType.id, Array.isArray(value) ? value : [value]);
722
603
  if (!rule) {
723
604
  rulesToCreate.push({
724
- rule_type: ruleType.id,
725
- price_list: priceListId,
605
+ rule_type_id: ruleType.id,
606
+ price_list_id: priceListId,
726
607
  });
727
608
  }
728
609
  else {
@@ -733,23 +614,21 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.abstractModuleService
733
614
  }
734
615
  const [createdRules, priceListValuesToDelete] = await Promise.all([
735
616
  this.priceListRuleService_.create(rulesToCreate),
736
- this.priceListRuleValueService_.list({
737
- price_list_rule_id: ruleIdsToUpdate,
738
- }, { take: null }),
617
+ this.priceListRuleValueService_.list({ price_list_rule_id: ruleIdsToUpdate }, { take: null }),
739
618
  ]);
740
619
  const priceListRuleValuesToCreate = [];
741
- for (const { id, price_list, rule_type } of createdRules) {
742
- const ruleValues = priceRuleValues.get(price_list.id ?? price_list);
620
+ for (const { id, price_list_id, rule_type_id } of createdRules) {
621
+ const ruleValues = priceRuleValues.get(price_list_id);
743
622
  if (!ruleValues) {
744
623
  continue;
745
624
  }
746
- const values = ruleValues.get(rule_type.id ?? rule_type);
625
+ const values = ruleValues.get(rule_type_id);
747
626
  if (!values) {
748
627
  continue;
749
628
  }
750
629
  values.forEach((v) => {
751
630
  priceListRuleValuesToCreate.push({
752
- price_list_rule: id,
631
+ price_list_rule_id: id,
753
632
  value: v,
754
633
  });
755
634
  });
@@ -758,18 +637,14 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.abstractModuleService
758
637
  this.priceListRuleValueService_.delete(priceListValuesToDelete.map((p) => p.id), sharedContext),
759
638
  this.priceListRuleValueService_.create(priceListRuleValuesToCreate, sharedContext),
760
639
  ]);
761
- return await this.baseRepository_.serialize(priceLists, {
762
- populate: true,
763
- });
640
+ return await this.baseRepository_.serialize(priceLists, { populate: true });
764
641
  }
765
642
  async removePriceListRules(data, sharedContext = {}) {
766
643
  const [priceList] = await this.removePriceListRules_([data], sharedContext);
767
644
  return priceList;
768
645
  }
769
646
  async removePriceListRules_(data, sharedContext = {}) {
770
- const priceLists = await this.priceListService_.list({ id: data.map((d) => d.price_list_id) }, {
771
- relations: ["price_list_rules", "price_list_rules.rule_type"],
772
- }, sharedContext);
647
+ const priceLists = await this.priceListService_.list({ id: data.map((d) => d.price_list_id) }, { relations: ["price_list_rules", "price_list_rules.rule_type"] }, sharedContext);
773
648
  const priceListMap = new Map(priceLists.map((p) => [p.id, p]));
774
649
  const idsToDelete = [];
775
650
  for (const { price_list_id: priceListId, rules } of data) {
@@ -777,9 +652,7 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.abstractModuleService
777
652
  if (!priceList) {
778
653
  throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Price list with id: ${priceListId} not found`);
779
654
  }
780
- const priceListRulesMap = new Map(priceList.price_list_rules
781
- .getItems()
782
- .map((p) => [p.rule_type.rule_attribute, p]));
655
+ const priceListRulesMap = new Map(priceList.price_list_rules.map((p) => [p.rule_type.rule_attribute, p]));
783
656
  await Promise.all(rules.map(async (rule_attribute) => {
784
657
  const rule = priceListRulesMap.get(rule_attribute);
785
658
  if (rule) {
@@ -788,9 +661,7 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.abstractModuleService
788
661
  }));
789
662
  }
790
663
  await this.priceListRuleService_.delete(idsToDelete);
791
- return await this.baseRepository_.serialize(priceLists, {
792
- populate: true,
793
- });
664
+ return await this.baseRepository_.serialize(priceLists, { populate: true });
794
665
  }
795
666
  }
796
667
  exports.default = PricingModuleService;
@@ -857,62 +728,6 @@ __decorate([
857
728
  __metadata("design:paramtypes", [Array, Object]),
858
729
  __metadata("design:returntype", Promise)
859
730
  ], PricingModuleService.prototype, "update", null);
860
- __decorate([
861
- (0, utils_1.InjectTransactionManager)("baseRepository_"),
862
- __param(1, (0, utils_1.MedusaContext)()),
863
- __metadata("design:type", Function),
864
- __metadata("design:paramtypes", [Array, Object]),
865
- __metadata("design:returntype", Promise)
866
- ], PricingModuleService.prototype, "createMoneyAmounts", null);
867
- __decorate([
868
- (0, utils_1.InjectTransactionManager)("baseRepository_"),
869
- __param(1, (0, utils_1.MedusaContext)()),
870
- __metadata("design:type", Function),
871
- __metadata("design:paramtypes", [Array, Object]),
872
- __metadata("design:returntype", Promise)
873
- ], PricingModuleService.prototype, "updateMoneyAmounts", null);
874
- __decorate([
875
- (0, utils_1.InjectTransactionManager)("baseRepository_"),
876
- __param(1, (0, utils_1.MedusaContext)()),
877
- __metadata("design:type", Function),
878
- __metadata("design:paramtypes", [Array, Object]),
879
- __metadata("design:returntype", Promise)
880
- ], PricingModuleService.prototype, "createRuleTypes", null);
881
- __decorate([
882
- (0, utils_1.InjectTransactionManager)("baseRepository_"),
883
- __param(1, (0, utils_1.MedusaContext)()),
884
- __metadata("design:type", Function),
885
- __metadata("design:paramtypes", [Array, Object]),
886
- __metadata("design:returntype", Promise)
887
- ], PricingModuleService.prototype, "updateRuleTypes", null);
888
- __decorate([
889
- (0, utils_1.InjectTransactionManager)("baseRepository_"),
890
- __param(1, (0, utils_1.MedusaContext)()),
891
- __metadata("design:type", Function),
892
- __metadata("design:paramtypes", [Array, Object]),
893
- __metadata("design:returntype", Promise)
894
- ], PricingModuleService.prototype, "createPriceSetMoneyAmountRules", null);
895
- __decorate([
896
- (0, utils_1.InjectTransactionManager)("baseRepository_"),
897
- __param(1, (0, utils_1.MedusaContext)()),
898
- __metadata("design:type", Function),
899
- __metadata("design:paramtypes", [Array, Object]),
900
- __metadata("design:returntype", Promise)
901
- ], PricingModuleService.prototype, "updatePriceSetMoneyAmountRules", null);
902
- __decorate([
903
- (0, utils_1.InjectTransactionManager)("baseRepository_"),
904
- __param(1, (0, utils_1.MedusaContext)()),
905
- __metadata("design:type", Function),
906
- __metadata("design:paramtypes", [Array, Object]),
907
- __metadata("design:returntype", Promise)
908
- ], PricingModuleService.prototype, "createPriceRules", null);
909
- __decorate([
910
- (0, utils_1.InjectTransactionManager)("baseRepository_"),
911
- __param(1, (0, utils_1.MedusaContext)()),
912
- __metadata("design:type", Function),
913
- __metadata("design:paramtypes", [Array, Object]),
914
- __metadata("design:returntype", Promise)
915
- ], PricingModuleService.prototype, "updatePriceRules", null);
916
731
  __decorate([
917
732
  (0, utils_1.InjectManager)("baseRepository_"),
918
733
  __param(1, (0, utils_1.MedusaContext)()),