@medusajs/pricing 0.1.13-preview-20240702150449 → 0.1.13-preview-20240702210436

Sign up to get free protection for your applications and to get access to all the features.
@@ -117,6 +117,7 @@ class PricingRepository extends utils_1.MikroOrmBase {
117
117
  pl_rules_count: "price.pl_rules_count",
118
118
  price_list_type: "price.pl_type",
119
119
  price_list_id: "price.price_list_id",
120
+ all_rules_count: knex.raw("COALESCE(price.rules_count, 0) + COALESCE(price.pl_rules_count, 0)"),
120
121
  })
121
122
  .join(priceSubQueryKnex.as("price"), "price.price_set_id", "ps.id")
122
123
  .leftJoin("price_rule as pr", "pr.price_id", "price.id")
@@ -124,8 +125,8 @@ class PricingRepository extends utils_1.MikroOrmBase {
124
125
  .andWhere("price.currency_code", "=", currencyCode)
125
126
  .orderBy([
126
127
  { column: "price.has_price_list", order: "asc" },
128
+ { column: "all_rules_count", order: "desc" },
127
129
  { column: "amount", order: "asc" },
128
- { column: "rules_count", order: "desc" },
129
130
  ]);
130
131
  if (quantity) {
131
132
  priceSetQueryKnex.where("price.min_quantity", "<=", quantity);
@@ -1,4 +1,4 @@
1
- import { AddPricesDTO, Context, CreatePriceRuleDTO, DAL, FindConfig, InternalModuleDeclaration, ModuleJoinerConfig, ModulesSdkTypes, PriceDTO, PriceSetDTO, PricingContext, PricingFilters, PricingRepositoryService, PricingTypes, UpsertPriceSetDTO } from "@medusajs/types";
1
+ import { AddPricesDTO, Context, CreatePriceRuleDTO, DAL, FindConfig, InternalModuleDeclaration, ModuleJoinerConfig, ModulesSdkTypes, PriceSetDTO, PricingContext, PricingFilters, PricingRepositoryService, PricingTypes, UpsertPriceSetDTO } from "@medusajs/types";
2
2
  import { ModulesSdkUtils } from "@medusajs/utils";
3
3
  import { Price, PriceList, PriceListRule, PriceRule, PriceSet } from "../models";
4
4
  import { ServiceTypes } from "../types";
@@ -53,8 +53,9 @@ export default class PricingModuleService extends PricingModuleService_base impl
53
53
  upsertPriceSets(data: UpsertPriceSetDTO, sharedContext?: Context): Promise<PriceSetDTO>;
54
54
  updatePriceSets(id: string, data: PricingTypes.UpdatePriceSetDTO, sharedContext?: Context): Promise<PriceSetDTO>;
55
55
  updatePriceSets(selector: PricingTypes.FilterablePriceSetProps, data: PricingTypes.UpdatePriceSetDTO, sharedContext?: Context): Promise<PriceSetDTO[]>;
56
- private normalizeUpdateData;
57
56
  protected updatePriceSets_(data: ServiceTypes.UpdatePriceSetInput[], sharedContext?: Context): Promise<PriceSet[]>;
57
+ private normalizeUpdateData;
58
+ private normalizePrices;
58
59
  addPrices(data: AddPricesDTO, sharedContext?: Context): Promise<PricingTypes.PriceSetDTO>;
59
60
  addPrices(data: AddPricesDTO[], sharedContext?: Context): Promise<PricingTypes.PriceSetDTO[]>;
60
61
  createPriceLists(data: PricingTypes.CreatePriceListDTO[], sharedContext?: Context): Promise<PricingTypes.PriceListDTO[]>;
@@ -188,30 +188,6 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.MedusaService(generat
188
188
  const priceSets = await this.baseRepository_.serialize(updateResult);
189
189
  return (0, utils_1.isString)(idOrSelector) ? priceSets[0] : priceSets;
190
190
  }
191
- async normalizeUpdateData(data) {
192
- return data.map((priceSet) => {
193
- const prices = priceSet.prices?.map((price) => {
194
- const rules = Object.entries(price.rules ?? {}).map(([attribute, value]) => {
195
- return {
196
- attribute,
197
- value,
198
- };
199
- });
200
- const hasRulesInput = (0, utils_1.isPresent)(price.rules);
201
- delete price.rules;
202
- return {
203
- ...price,
204
- price_set_id: priceSet.id,
205
- price_rules: hasRulesInput ? rules : undefined,
206
- rules_count: hasRulesInput ? rules.length : undefined,
207
- };
208
- });
209
- return {
210
- ...priceSet,
211
- prices,
212
- };
213
- });
214
- }
215
191
  async updatePriceSets_(data, sharedContext = {}) {
216
192
  // TODO: Since money IDs are rarely passed, this will delete all previous data and insert new entries.
217
193
  // We can make the `insert` inside upsertWithReplace do an `upsert` instead to avoid this
@@ -234,6 +210,49 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.MedusaService(generat
234
210
  const { entities: priceSets } = await this.priceSetService_.upsertWithReplace(priceSetsToUpsert, { relations: ["prices"] }, sharedContext);
235
211
  return priceSets;
236
212
  }
213
+ async normalizeUpdateData(data) {
214
+ return data.map((priceSet) => {
215
+ return {
216
+ ...priceSet,
217
+ prices: this.normalizePrices(priceSet.prices?.map((p) => ({ ...p, price_set_id: priceSet.id })), []),
218
+ };
219
+ });
220
+ }
221
+ normalizePrices(data, existingPrices, priceListId) {
222
+ const pricesToUpsert = new Map();
223
+ const existingPricesMap = new Map();
224
+ existingPrices?.forEach((price) => {
225
+ existingPricesMap.set(hashPrice(price), price);
226
+ });
227
+ data?.forEach((price) => {
228
+ const cleanRules = price.rules ? (0, utils_1.removeNullish)(price.rules) : {};
229
+ const ruleEntries = Object.entries(cleanRules);
230
+ const rules = ruleEntries.map(([attribute, value]) => {
231
+ return {
232
+ attribute,
233
+ value,
234
+ };
235
+ });
236
+ const hasRulesInput = (0, utils_1.isPresent)(price.rules);
237
+ const entry = {
238
+ ...price,
239
+ price_list_id: priceListId,
240
+ price_rules: hasRulesInput ? rules : undefined,
241
+ rules_count: hasRulesInput ? ruleEntries.length : undefined,
242
+ };
243
+ delete entry.rules;
244
+ const entryHash = hashPrice(entry);
245
+ // We want to keep the existing rules as they might already have ids, but any other data should come from the updated input
246
+ const existing = existingPricesMap.get(entryHash);
247
+ pricesToUpsert.set(entryHash, {
248
+ ...entry,
249
+ id: existing?.id ?? entry.id,
250
+ price_rules: existing?.price_rules ?? entry.price_rules,
251
+ });
252
+ return entry;
253
+ });
254
+ return Array.from(pricesToUpsert.values());
255
+ }
237
256
  async addPrices(data, sharedContext = {}) {
238
257
  const input = Array.isArray(data) ? data : [data];
239
258
  await this.addPrices_(input, sharedContext);
@@ -277,30 +296,8 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.MedusaService(generat
277
296
  const toCreate = input.map((inputData) => {
278
297
  const entry = {
279
298
  ...inputData,
299
+ prices: this.normalizePrices(inputData.prices, []),
280
300
  };
281
- if (!inputData.prices) {
282
- return entry;
283
- }
284
- const pricesData = inputData.prices.map((price) => {
285
- let { rules: priceRules = {}, ...rest } = price;
286
- const cleanRules = priceRules ? (0, utils_1.removeNullish)(priceRules) : {};
287
- const rules = Object.entries(cleanRules);
288
- const numberOfRules = rules.length;
289
- const rulesDataMap = new Map();
290
- rules.map(([attribute, value]) => {
291
- const rule = {
292
- attribute,
293
- value,
294
- };
295
- rulesDataMap.set(JSON.stringify(rule), rule);
296
- });
297
- return {
298
- ...rest,
299
- rules_count: numberOfRules,
300
- price_rules: Array.from(rulesDataMap.values()),
301
- };
302
- });
303
- entry.prices = pricesData;
304
301
  return entry;
305
302
  });
306
303
  // Bulk create price sets
@@ -340,58 +337,50 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.MedusaService(generat
340
337
  return createdPriceSets;
341
338
  }
342
339
  async addPrices_(input, sharedContext = {}) {
343
- const priceSets = await this.listPriceSets({ id: input.map((d) => d.priceSetId) }, {}, sharedContext);
340
+ const priceSets = await this.listPriceSets({ id: input.map((d) => d.priceSetId) }, { take: null, relations: ["prices", "prices.price_rules"] }, sharedContext);
341
+ const existingPrices = priceSets
342
+ .map((p) => p.prices)
343
+ .flat();
344
+ const pricesToUpsert = input
345
+ .map((addPrice) => this.normalizePrices(addPrice.prices?.map((p) => ({
346
+ ...p,
347
+ price_set_id: addPrice.priceSetId,
348
+ })), existingPrices))
349
+ .filter(Boolean)
350
+ .flat();
344
351
  const priceSetMap = new Map(priceSets.map((p) => [p.id, p]));
345
- input.forEach(({ priceSetId }) => {
346
- const priceSet = priceSetMap.get(priceSetId);
352
+ pricesToUpsert.forEach((price) => {
353
+ const priceSet = priceSetMap.get(price.price_set_id);
347
354
  if (!priceSet) {
348
- throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Price set with id: ${priceSetId} not found`);
355
+ throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Price set with id: ${price.price_set_id} not found`);
349
356
  }
350
357
  });
351
- const pricesToCreate = input.flatMap(({ priceSetId, prices }) => prices.map((price) => {
352
- const numberOfRules = Object.entries(price?.rules ?? {}).length;
353
- const priceRules = Object.entries(price.rules ?? {}).map(([attribute, value]) => ({
354
- price_set_id: priceSetId,
355
- attribute: attribute,
356
- value,
357
- }));
358
- return {
359
- ...price,
360
- price_set_id: priceSetId,
361
- rules_count: numberOfRules,
362
- price_rules: priceRules,
363
- };
364
- }));
365
- const prices = await this.priceService_.create(pricesToCreate, sharedContext);
366
- /**
367
- * Preparing data for emitting events
368
- */
369
- const eventsData = prices.reduce((eventsData, price) => {
370
- eventsData.prices.push({
371
- id: price.id,
372
- });
373
- price.price_rules.map((priceRule) => {
374
- eventsData.priceRules.push({
375
- id: priceRule.id,
376
- });
377
- });
378
- return eventsData;
379
- }, {
380
- priceRules: [],
381
- prices: [],
382
- });
383
- /**
384
- * Emitting events for all created entities
385
- */
358
+ const { entities, performedActions } = await this.priceService_.upsertWithReplace(pricesToUpsert, { relations: ["price_rules"] }, sharedContext);
386
359
  _utils_1.eventBuilders.createdPrice({
387
- data: eventsData.prices,
360
+ data: performedActions.created[_models_1.Price.name] ?? [],
361
+ sharedContext,
362
+ });
363
+ _utils_1.eventBuilders.updatedPrice({
364
+ data: performedActions.updated[_models_1.Price.name] ?? [],
365
+ sharedContext,
366
+ });
367
+ _utils_1.eventBuilders.deletedPrice({
368
+ data: performedActions.deleted[_models_1.Price.name] ?? [],
388
369
  sharedContext,
389
370
  });
390
371
  _utils_1.eventBuilders.createdPriceRule({
391
- data: eventsData.priceRules,
372
+ data: performedActions.created[_models_1.PriceRule.name] ?? [],
392
373
  sharedContext,
393
374
  });
394
- return prices;
375
+ _utils_1.eventBuilders.updatedPriceRule({
376
+ data: performedActions.updated[_models_1.PriceRule.name] ?? [],
377
+ sharedContext,
378
+ });
379
+ _utils_1.eventBuilders.deletedPriceRule({
380
+ data: performedActions.deleted[_models_1.PriceRule.name] ?? [],
381
+ sharedContext,
382
+ });
383
+ return entities;
395
384
  }
396
385
  async createPriceLists_(data, sharedContext = {}) {
397
386
  const normalized = this.normalizePriceListDate(data);
@@ -401,26 +390,7 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.MedusaService(generat
401
390
  rules: undefined,
402
391
  };
403
392
  if (priceListData.prices) {
404
- const pricesData = priceListData.prices.map((price) => {
405
- let { rules: priceRules = {}, ...rest } = price;
406
- const cleanRules = priceRules ? (0, utils_1.removeNullish)(priceRules) : {};
407
- const rules = Object.entries(cleanRules);
408
- const numberOfRules = rules.length;
409
- const rulesDataMap = new Map();
410
- rules.map(([attribute, value]) => {
411
- const rule = {
412
- attribute,
413
- value,
414
- };
415
- rulesDataMap.set(JSON.stringify(rule), rule);
416
- });
417
- return {
418
- ...rest,
419
- rules_count: numberOfRules,
420
- price_rules: Array.from(rulesDataMap.values()),
421
- };
422
- });
423
- entry.prices = pricesData;
393
+ entry.prices = this.normalizePrices(priceListData.prices, []);
424
394
  }
425
395
  if (priceListData.rules) {
426
396
  const cleanRules = priceListData.rules
@@ -529,111 +499,69 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.MedusaService(generat
529
499
  return entities;
530
500
  }
531
501
  async updatePriceListPrices_(data, sharedContext = {}) {
532
- const priceListIds = [];
533
- const priceIds = [];
534
- for (const priceListData of data) {
535
- priceListIds.push(priceListData.price_list_id);
536
- for (const price of priceListData.prices) {
537
- priceIds.push(price.id);
538
- }
539
- }
540
- const prices = await this.listPrices({ id: priceIds }, { take: null, relations: ["price_rules"] }, sharedContext);
541
- const priceMap = new Map(prices.map((price) => [price.id, price]));
542
- const priceLists = await this.listPriceLists({ id: priceListIds }, { take: null }, sharedContext);
502
+ const priceLists = await this.listPriceLists({ id: data.map((p) => p.price_list_id) }, { take: null, relations: ["prices", "prices.price_rules"] }, sharedContext);
503
+ const existingPrices = priceLists
504
+ .map((p) => p.prices ?? [])
505
+ .flat();
506
+ const pricesToUpsert = data
507
+ .map((addPrice) => this.normalizePrices(addPrice.prices, existingPrices, addPrice.price_list_id))
508
+ .filter(Boolean)
509
+ .flat();
543
510
  const priceListMap = new Map(priceLists.map((p) => [p.id, p]));
544
- const pricesToUpdate = [];
545
- const priceRuleIdsToDelete = [];
546
- const priceRulesToCreate = [];
547
511
  for (const { price_list_id: priceListId, prices } of data) {
548
512
  const priceList = priceListMap.get(priceListId);
549
513
  if (!priceList) {
550
514
  throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Price list with id: ${priceListId} not found`);
551
515
  }
552
- for (const priceData of prices) {
553
- const { rules = {}, price_set_id, ...rest } = priceData;
554
- const price = priceMap.get(rest.id);
555
- const priceRules = price.price_rules;
556
- priceRulesToCreate.push(...Object.entries(rules).map(([ruleAttribute, ruleValue]) => ({
557
- price_set_id,
558
- attribute: ruleAttribute,
559
- value: ruleValue,
560
- price_id: price.id,
561
- })));
562
- pricesToUpdate.push({
563
- ...rest,
564
- rules_count: Object.keys(rules).length,
565
- });
566
- priceRuleIdsToDelete.push(...priceRules.map((pr) => pr.id));
567
- }
568
516
  }
569
- const [_deletedPriceRule, _createdPriceRule, updatedPrices] = await (0, utils_1.promiseAll)([
570
- this.priceRuleService_.delete(priceRuleIdsToDelete),
571
- this.priceRuleService_.create(priceRulesToCreate),
572
- this.priceService_.update(pricesToUpdate),
573
- ]);
574
- return updatedPrices;
517
+ const { entities } = await this.priceService_.upsertWithReplace(pricesToUpsert, { relations: ["price_rules"] }, sharedContext);
518
+ return entities;
575
519
  }
576
520
  async removePrices_(ids, sharedContext = {}) {
577
521
  await this.priceService_.delete(ids, sharedContext);
578
522
  }
579
523
  async addPriceListPrices_(data, sharedContext = {}) {
580
- const priceListIds = [];
581
- for (const priceListData of data) {
582
- priceListIds.push(priceListData.price_list_id);
583
- }
584
- const priceLists = await this.listPriceLists({ id: priceListIds }, {}, sharedContext);
524
+ const priceLists = await this.listPriceLists({ id: data.map((p) => p.price_list_id) }, { take: null, relations: ["prices", "prices.price_rules"] }, sharedContext);
525
+ const existingPrices = priceLists
526
+ .map((p) => p.prices ?? [])
527
+ .flat();
528
+ const pricesToUpsert = data
529
+ .map((addPrice) => this.normalizePrices(addPrice.prices, existingPrices, addPrice.price_list_id))
530
+ .filter(Boolean)
531
+ .flat();
585
532
  const priceListMap = new Map(priceLists.map((p) => [p.id, p]));
586
- const pricesToCreate = [];
587
- for (const { price_list_id: priceListId, prices } of data) {
588
- const priceList = priceListMap.get(priceListId);
533
+ pricesToUpsert.forEach((price) => {
534
+ const priceList = priceListMap.get(price.price_list_id);
589
535
  if (!priceList) {
590
- throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Price list with id: ${priceListId} not found`);
536
+ throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Price list with id: ${price.price_list_id} not found`);
591
537
  }
592
- const priceListPricesToCreate = prices.map((priceData) => {
593
- const priceRules = priceData.rules || {};
594
- const noOfRules = Object.keys(priceRules).length;
595
- const priceRulesToCreate = Object.entries(priceRules).map(([ruleAttribute, ruleValue]) => {
596
- return {
597
- price_list_id: priceData.price_set_id,
598
- attribute: ruleAttribute,
599
- value: ruleValue,
600
- };
601
- });
602
- return {
603
- ...priceData,
604
- price_set_id: priceData.price_set_id,
605
- title: "test",
606
- price_list_id: priceList.id,
607
- rules_count: noOfRules,
608
- price_rules: priceRulesToCreate,
609
- };
610
- });
611
- pricesToCreate.push(...priceListPricesToCreate);
612
- }
613
- const createdPrices = await this.priceService_.create(pricesToCreate, sharedContext);
614
- const eventsData = createdPrices.reduce((eventsData, price) => {
615
- eventsData.prices.push({
616
- id: price.id,
617
- });
618
- price.price_rules.map((priceRule) => {
619
- eventsData.priceRules.push({
620
- id: priceRule.id,
621
- });
622
- });
623
- return eventsData;
624
- }, {
625
- priceRules: [],
626
- prices: [],
627
538
  });
539
+ const { entities, performedActions } = await this.priceService_.upsertWithReplace(pricesToUpsert, { relations: ["price_rules"] }, sharedContext);
628
540
  _utils_1.eventBuilders.createdPrice({
629
- data: eventsData.prices,
541
+ data: performedActions.created[_models_1.Price.name] ?? [],
542
+ sharedContext,
543
+ });
544
+ _utils_1.eventBuilders.updatedPrice({
545
+ data: performedActions.updated[_models_1.Price.name] ?? [],
546
+ sharedContext,
547
+ });
548
+ _utils_1.eventBuilders.deletedPrice({
549
+ data: performedActions.deleted[_models_1.Price.name] ?? [],
630
550
  sharedContext,
631
551
  });
632
552
  _utils_1.eventBuilders.createdPriceRule({
633
- data: eventsData.priceRules,
553
+ data: performedActions.created[_models_1.PriceRule.name] ?? [],
554
+ sharedContext,
555
+ });
556
+ _utils_1.eventBuilders.updatedPriceRule({
557
+ data: performedActions.updated[_models_1.PriceRule.name] ?? [],
634
558
  sharedContext,
635
559
  });
636
- return createdPrices;
560
+ _utils_1.eventBuilders.deletedPriceRule({
561
+ data: performedActions.deleted[_models_1.PriceRule.name] ?? [],
562
+ sharedContext,
563
+ });
564
+ return entities;
637
565
  }
638
566
  async setPriceListRules_(data, sharedContext = {}) {
639
567
  // TODO: re think this method
@@ -920,3 +848,19 @@ __decorate([
920
848
  __metadata("design:paramtypes", [Array, Object]),
921
849
  __metadata("design:returntype", Promise)
922
850
  ], PricingModuleService.prototype, "removePriceListRules_", null);
851
+ const hashPrice = (price) => {
852
+ const data = Object.entries({
853
+ currency_code: price.currency_code,
854
+ price_set_id: "price_set_id" in price ? price.price_set_id ?? null : null,
855
+ price_list_id: "price_list_id" in price ? price.price_list_id ?? null : null,
856
+ min_quantity: price.min_quantity ? price.min_quantity.toString() : null,
857
+ max_quantity: price.max_quantity ? price.max_quantity.toString() : null,
858
+ ...("price_rules" in price
859
+ ? price.price_rules?.reduce((agg, pr) => {
860
+ agg[pr.attribute] = pr.value;
861
+ return agg;
862
+ }, {})
863
+ : {}),
864
+ }).sort(([a], [b]) => a.localeCompare(b));
865
+ return (0, utils_1.simpleHash)(JSON.stringify(data));
866
+ };
@@ -1,2 +1,3 @@
1
1
  export * from "./price-list";
2
2
  export * from "./price-set";
3
+ export * from "./price";
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./price-list"), exports);
18
18
  __exportStar(require("./price-set"), exports);
19
+ __exportStar(require("./price"), exports);
@@ -0,0 +1,6 @@
1
+ import { PricingTypes } from "@medusajs/types";
2
+ export interface UpsertPriceDTO extends Omit<PricingTypes.CreatePriceDTO, "rules"> {
3
+ id?: string;
4
+ price_list_id?: string;
5
+ price_rules: PricingTypes.CreatePriceRuleDTO[];
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -35,4 +35,28 @@ export declare const eventBuilders: {
35
35
  }[];
36
36
  sharedContext: import("@medusajs/types").Context;
37
37
  }) => void;
38
+ updatedPrice: ({ data, sharedContext, }: {
39
+ data: {
40
+ id: string;
41
+ }[];
42
+ sharedContext: import("@medusajs/types").Context;
43
+ }) => void;
44
+ updatedPriceRule: ({ data, sharedContext, }: {
45
+ data: {
46
+ id: string;
47
+ }[];
48
+ sharedContext: import("@medusajs/types").Context;
49
+ }) => void;
50
+ deletedPrice: ({ data, sharedContext, }: {
51
+ data: {
52
+ id: string;
53
+ }[];
54
+ sharedContext: import("@medusajs/types").Context;
55
+ }) => void;
56
+ deletedPriceRule: ({ data, sharedContext, }: {
57
+ data: {
58
+ id: string;
59
+ }[];
60
+ sharedContext: import("@medusajs/types").Context;
61
+ }) => void;
38
62
  };
@@ -39,4 +39,28 @@ exports.eventBuilders = {
39
39
  object: "price_list_rule",
40
40
  eventsEnum: utils_1.PricingEvents,
41
41
  }),
42
+ updatedPrice: (0, utils_1.eventBuilderFactory)({
43
+ source: utils_1.Modules.PRICING,
44
+ action: utils_1.CommonEvents.UPDATED,
45
+ object: "price",
46
+ eventsEnum: utils_1.PricingEvents,
47
+ }),
48
+ updatedPriceRule: (0, utils_1.eventBuilderFactory)({
49
+ source: utils_1.Modules.PRICING,
50
+ action: utils_1.CommonEvents.UPDATED,
51
+ object: "price_rule",
52
+ eventsEnum: utils_1.PricingEvents,
53
+ }),
54
+ deletedPrice: (0, utils_1.eventBuilderFactory)({
55
+ source: utils_1.Modules.PRICING,
56
+ action: utils_1.CommonEvents.DELETED,
57
+ object: "price",
58
+ eventsEnum: utils_1.PricingEvents,
59
+ }),
60
+ deletedPriceRule: (0, utils_1.eventBuilderFactory)({
61
+ source: utils_1.Modules.PRICING,
62
+ action: utils_1.CommonEvents.DELETED,
63
+ object: "price_rule",
64
+ eventsEnum: utils_1.PricingEvents,
65
+ }),
42
66
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/pricing",
3
- "version": "0.1.13-preview-20240702150449",
3
+ "version": "0.1.13-preview-20240702210436",
4
4
  "description": "Medusa Pricing module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -37,7 +37,7 @@
37
37
  "@mikro-orm/cli": "5.9.7",
38
38
  "cross-env": "^5.2.1",
39
39
  "jest": "^29.7.0",
40
- "medusa-test-utils": "1.1.45-preview-20240702150449",
40
+ "medusa-test-utils": "1.1.45-preview-20240702210436",
41
41
  "rimraf": "^3.0.2",
42
42
  "ts-jest": "^29.1.1",
43
43
  "ts-node": "^10.9.1",
@@ -45,9 +45,9 @@
45
45
  "typescript": "^5.1.6"
46
46
  },
47
47
  "dependencies": {
48
- "@medusajs/modules-sdk": "1.13.0-preview-20240702150449",
49
- "@medusajs/types": "1.12.0-preview-20240702150449",
50
- "@medusajs/utils": "1.12.0-preview-20240702150449",
48
+ "@medusajs/modules-sdk": "1.13.0-preview-20240702210436",
49
+ "@medusajs/types": "1.12.0-preview-20240702210436",
50
+ "@medusajs/utils": "1.12.0-preview-20240702210436",
51
51
  "@mikro-orm/core": "5.9.7",
52
52
  "@mikro-orm/migrations": "5.9.7",
53
53
  "@mikro-orm/postgresql": "5.9.7",