@medusajs/pricing 0.1.12-snapshot-20240328213126 → 0.2.0-next-20240425093236

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,6 +4,7 @@ export declare const LinkableKeys: {
4
4
  price_set_id: string;
5
5
  price_list_id: string;
6
6
  price_id: string;
7
+ rule_type_id: string;
7
8
  };
8
9
  export declare const entityNameToLinkableKeysMap: MapToConfig;
9
10
  export declare const joinerConfig: ModuleJoinerConfig;
@@ -11,6 +11,7 @@ exports.LinkableKeys = {
11
11
  price_set_id: _models_1.PriceSet.name,
12
12
  price_list_id: _models_1.PriceList.name,
13
13
  price_id: _models_1.Price.name,
14
+ rule_type_id: _models_1.RuleType.name,
14
15
  };
15
16
  const entityLinkableKeysMap = {};
16
17
  Object.entries(exports.LinkableKeys).forEach(([key, value]) => {
@@ -39,5 +40,17 @@ exports.joinerConfig = {
39
40
  methodSuffix: "PriceLists",
40
41
  },
41
42
  },
43
+ {
44
+ name: ["price", "prices"],
45
+ args: {
46
+ methodSuffix: "Prices",
47
+ },
48
+ },
49
+ {
50
+ name: ["rule_type", "rule_types"],
51
+ args: {
52
+ methodSuffix: "RuleTypes",
53
+ },
54
+ },
42
55
  ],
43
56
  };
@@ -6,7 +6,7 @@ class Migration20230929122253 extends migrations_1.Migration {
6
6
  async up() {
7
7
  this.addSql('create table if not exists "money_amount" ("id" text not null, "currency_code" text not null, "amount" numeric not null, "min_quantity" numeric null, "max_quantity" numeric null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "money_amount_pkey" primary key ("id"));');
8
8
  this.addSql('create table "price_set" ("id" text not null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "price_set_pkey" primary key ("id"));');
9
- this.addSql('create table "price" ("id" text not null, "title" text, "price_set_id" text not null, "money_amount_id" text not null, "rules_count" integer not null default 0, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "price_pkey" primary key ("id"));');
9
+ this.addSql('create table "price" ("id" text not null, "title" text, "price_set_id" text not null, "money_amount_id" text not null, "raw_amount" jsonb not null, "rules_count" integer not null default 0, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "price_pkey" primary key ("id"));');
10
10
  this.addSql('alter table "price" add constraint "price_money_amount_id_unique" unique ("money_amount_id");');
11
11
  this.addSql('create table "rule_type" ("id" text not null, "name" text not null, "rule_attribute" text not null, "default_priority" integer not null default 0, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "rule_type_pkey" primary key ("id"));');
12
12
  this.addSql('create table "price_set_rule_type" ("id" text not null, "price_set_id" text not null, "rule_type_id" text not null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "price_set_rule_type_pkey" primary key ("id"));');
@@ -1,4 +1,5 @@
1
1
  import { DAL } from "@medusajs/types";
2
+ import { BigNumber } from "@medusajs/utils";
2
3
  import { Collection, OptionalProps } from "@mikro-orm/core";
3
4
  import PriceList from "./price-list";
4
5
  import PriceRule from "./price-rule";
@@ -9,7 +10,8 @@ export default class Price {
9
10
  id: string;
10
11
  title: string | null;
11
12
  currency_code: string;
12
- amount: number;
13
+ amount: BigNumber | number;
14
+ raw_amount: Record<string, unknown>;
13
15
  min_quantity: number | null;
14
16
  max_quantity: number | null;
15
17
  price_set_id: string;
@@ -74,9 +74,13 @@ __decorate([
74
74
  __metadata("design:type", String)
75
75
  ], Price.prototype, "currency_code", void 0);
76
76
  __decorate([
77
- (0, core_1.Property)({ columnType: "numeric", serializer: Number }),
78
- __metadata("design:type", Number)
77
+ (0, utils_1.MikroOrmBigNumberProperty)(),
78
+ __metadata("design:type", Object)
79
79
  ], Price.prototype, "amount", void 0);
80
+ __decorate([
81
+ (0, core_1.Property)({ columnType: "jsonb" }),
82
+ __metadata("design:type", Object)
83
+ ], Price.prototype, "raw_amount", void 0);
80
84
  __decorate([
81
85
  (0, core_1.Property)({ columnType: "numeric", nullable: true }),
82
86
  __metadata("design:type", Object)
File without changes
@@ -1,7 +1,8 @@
1
- import { AddPricesDTO, Context, DAL, InternalModuleDeclaration, ModuleJoinerConfig, ModulesSdkTypes, PriceSetDTO, PricingContext, PricingFilters, PricingRepositoryService, PricingTypes, RuleTypeDTO } from "@medusajs/types";
1
+ import { AddPricesDTO, Context, CreatePriceRuleDTO, DAL, InternalModuleDeclaration, ModuleJoinerConfig, ModulesSdkTypes, PriceSetDTO, PricingContext, PricingFilters, PricingRepositoryService, PricingTypes, RuleTypeDTO, UpsertPriceSetDTO } from "@medusajs/types";
2
2
  import { ModulesSdkUtils } from "@medusajs/utils";
3
3
  import { Price, PriceList, PriceListRule, PriceListRuleValue, PriceRule, PriceSet, PriceSetRuleType, RuleType } from "../models";
4
4
  import { PriceListService, RuleTypeService } from ".";
5
+ import { UpdatePriceSetInput } from "src/types/services";
5
6
  type InjectedDependencies = {
6
7
  baseRepository: DAL.RepositoryService;
7
8
  pricingRepository: PricingRepositoryService;
@@ -52,20 +53,25 @@ export default class PricingModuleService<TPriceSet extends PriceSet = PriceSet,
52
53
  calculatePrices(pricingFilters: PricingFilters, pricingContext?: PricingContext, sharedContext?: Context): Promise<PricingTypes.CalculatedPriceSet[]>;
53
54
  create(data: PricingTypes.CreatePriceSetDTO, sharedContext?: Context): Promise<PriceSetDTO>;
54
55
  create(data: PricingTypes.CreatePriceSetDTO[], sharedContext?: Context): Promise<PriceSetDTO[]>;
56
+ upsert(data: UpsertPriceSetDTO[], sharedContext?: Context): Promise<PriceSetDTO[]>;
57
+ upsert(data: UpsertPriceSetDTO, sharedContext?: Context): Promise<PriceSetDTO>;
58
+ update(id: string, data: PricingTypes.UpdatePriceSetDTO, sharedContext?: Context): Promise<PriceSetDTO>;
59
+ update(selector: PricingTypes.FilterablePriceSetProps, data: PricingTypes.UpdatePriceSetDTO, sharedContext?: Context): Promise<PriceSetDTO[]>;
60
+ private normalizeUpdateData;
61
+ protected update_(data: UpdatePriceSetInput[], sharedContext?: Context): Promise<PriceSet[]>;
55
62
  addRules(data: PricingTypes.AddRulesDTO, sharedContext?: Context): Promise<PricingTypes.PriceSetDTO>;
56
63
  addRules(data: PricingTypes.AddRulesDTO[], sharedContext?: Context): Promise<PricingTypes.PriceSetDTO[]>;
57
64
  addPrices(data: AddPricesDTO, sharedContext?: Context): Promise<PricingTypes.PriceSetDTO>;
58
65
  addPrices(data: AddPricesDTO[], sharedContext?: Context): Promise<PricingTypes.PriceSetDTO[]>;
59
66
  removeRules(data: PricingTypes.RemovePriceSetRulesDTO[], sharedContext?: Context): Promise<void>;
60
- update(data: PricingTypes.UpdatePriceSetDTO[], sharedContext?: Context): Promise<PriceSetDTO[]>;
61
67
  createPriceLists(data: PricingTypes.CreatePriceListDTO[], sharedContext?: Context): Promise<PricingTypes.PriceListDTO[]>;
62
68
  updatePriceLists(data: PricingTypes.UpdatePriceListDTO[], sharedContext?: Context): Promise<PricingTypes.PriceListDTO[]>;
63
69
  createPriceListRules(data: PricingTypes.CreatePriceListRuleDTO[], sharedContext?: Context): Promise<PricingTypes.PriceListRuleDTO[]>;
64
70
  createPriceListRules_(data: PricingTypes.CreatePriceListRuleDTO[], sharedContext?: Context): Promise<TPriceListRule[]>;
65
71
  updatePriceListRules(data: PricingTypes.UpdatePriceListRuleDTO[], sharedContext?: Context): Promise<PricingTypes.PriceListRuleDTO[]>;
66
- updatePriceListPrices(data: PricingTypes.UpdatePriceListPricesDTO[], sharedContext?: Context): Promise<PricingTypes.PriceListDTO[]>;
72
+ updatePriceListPrices(data: PricingTypes.UpdatePriceListPricesDTO[], sharedContext?: Context): Promise<PricingTypes.PriceDTO[]>;
67
73
  removePrices(ids: string[], sharedContext?: Context): Promise<void>;
68
- addPriceListPrices(data: PricingTypes.AddPriceListPricesDTO[], sharedContext?: Context): Promise<PricingTypes.PriceListDTO[]>;
74
+ addPriceListPrices(data: PricingTypes.AddPriceListPricesDTO[], sharedContext?: Context): Promise<PricingTypes.PriceDTO[]>;
69
75
  setPriceListRules(data: PricingTypes.SetPriceListRulesDTO, sharedContext?: Context): Promise<PricingTypes.PriceListDTO>;
70
76
  removePriceListRules(data: PricingTypes.RemovePriceListRulesDTO, sharedContext?: Context): Promise<PricingTypes.PriceListDTO>;
71
77
  protected create_(data: PricingTypes.CreatePriceSetDTO[], sharedContext?: Context): Promise<TPriceSet[]>;
@@ -73,9 +79,9 @@ export default class PricingModuleService<TPriceSet extends PriceSet = PriceSet,
73
79
  protected addPrices_(input: AddPricesDTO[], sharedContext?: Context): Promise<void>;
74
80
  protected createPriceLists_(data: PricingTypes.CreatePriceListDTO[], sharedContext?: Context): Promise<TPriceList[]>;
75
81
  protected updatePriceLists_(data: PricingTypes.UpdatePriceListDTO[], sharedContext?: Context): Promise<PricingTypes.PriceListDTO[]>;
76
- protected updatePriceListPrices_(data: PricingTypes.UpdatePriceListPricesDTO[], sharedContext?: Context): Promise<PricingTypes.PriceListDTO[]>;
82
+ protected updatePriceListPrices_(data: PricingTypes.UpdatePriceListPricesDTO[], sharedContext?: Context): Promise<TPrice[]>;
77
83
  protected removePrices_(ids: string[], sharedContext?: Context): Promise<void>;
78
- protected addPriceListPrices_(data: PricingTypes.AddPriceListPricesDTO[], sharedContext?: Context): Promise<PricingTypes.PriceListDTO[]>;
84
+ protected addPriceListPrices_(data: PricingTypes.AddPriceListPricesDTO[], sharedContext?: Context): Promise<TPrice[]>;
79
85
  protected setPriceListRules_(data: PricingTypes.SetPriceListRulesDTO[], sharedContext?: Context): Promise<TPriceList[]>;
80
86
  protected removePriceListRules_(data: PricingTypes.RemovePriceListRulesDTO[], sharedContext?: Context): Promise<TPriceList[]>;
81
87
  }
@@ -17,8 +17,8 @@ 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
20
  const price_list_1 = require("../models/price-list");
21
+ const price_set_1 = require("../models/price-set");
22
22
  const generateMethodForModels = [
23
23
  _models_1.PriceList,
24
24
  _models_1.PriceListRule,
@@ -94,12 +94,103 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.abstractModuleService
94
94
  async create(data, sharedContext = {}) {
95
95
  const input = Array.isArray(data) ? data : [data];
96
96
  const priceSets = await this.create_(input, sharedContext);
97
+ // TODO: Remove the need to refetch the data here
97
98
  const dbPriceSets = await this.list({ id: priceSets.map((p) => p.id) }, { relations: ["rule_types", "prices", "price_rules"] }, sharedContext);
98
99
  // Ensure the output to be in the same order as the input
99
100
  const results = priceSets.map((priceSet) => {
100
101
  return dbPriceSets.find((p) => p.id === priceSet.id);
101
102
  });
102
- return Array.isArray(data) ? results : results[0];
103
+ return await this.baseRepository_.serialize(Array.isArray(data) ? results : results[0]);
104
+ }
105
+ async upsert(data, sharedContext = {}) {
106
+ const input = Array.isArray(data) ? data : [data];
107
+ const forUpdate = input.filter((priceSet) => !!priceSet.id);
108
+ const forCreate = input.filter((priceSet) => !priceSet.id);
109
+ const operations = [];
110
+ if (forCreate.length) {
111
+ operations.push(this.create_(forCreate, sharedContext));
112
+ }
113
+ if (forUpdate.length) {
114
+ operations.push(this.update_(forUpdate, sharedContext));
115
+ }
116
+ const result = (await (0, utils_1.promiseAll)(operations)).flat();
117
+ return await this.baseRepository_.serialize(Array.isArray(data) ? result : result[0]);
118
+ }
119
+ async update(idOrSelector, data, sharedContext = {}) {
120
+ let normalizedInput = [];
121
+ if ((0, utils_1.isString)(idOrSelector)) {
122
+ // Check if the ID exists, it will throw if not.
123
+ await this.priceSetService_.retrieve(idOrSelector, {}, sharedContext);
124
+ normalizedInput = [{ id: idOrSelector, ...data }];
125
+ }
126
+ else {
127
+ const priceSets = await this.priceSetService_.list(idOrSelector, {}, sharedContext);
128
+ normalizedInput = priceSets.map((priceSet) => ({
129
+ id: priceSet.id,
130
+ ...data,
131
+ }));
132
+ }
133
+ const updateResult = await this.update_(normalizedInput, sharedContext);
134
+ const priceSets = await this.baseRepository_.serialize(updateResult);
135
+ return (0, utils_1.isString)(idOrSelector) ? priceSets[0] : priceSets;
136
+ }
137
+ async normalizeUpdateData(data, sharedContext) {
138
+ const ruleAttributes = data
139
+ .map((d) => d.prices?.map((p) => Object.keys(p.rules ?? [])) ?? [])
140
+ .flat(Infinity)
141
+ .filter(Boolean);
142
+ const ruleTypes = await this.ruleTypeService_.list({ rule_attribute: ruleAttributes }, { take: null }, sharedContext);
143
+ const ruleTypeMap = ruleTypes.reduce((acc, curr) => {
144
+ acc.set(curr.rule_attribute, curr);
145
+ return acc;
146
+ }, new Map());
147
+ return data.map((priceSet) => {
148
+ const prices = priceSet.prices?.map((price) => {
149
+ const rules = Object.entries(price.rules ?? {}).map(([attribute, value]) => {
150
+ return {
151
+ price_set_id: priceSet.id,
152
+ rule_type_id: ruleTypeMap.get(attribute).id,
153
+ value,
154
+ };
155
+ });
156
+ const hasRulesInput = (0, utils_1.isPresent)(price.rules);
157
+ delete price.rules;
158
+ return {
159
+ ...price,
160
+ price_set_id: priceSet.id,
161
+ price_rules: hasRulesInput ? rules : undefined,
162
+ rules_count: hasRulesInput ? rules.length : undefined,
163
+ };
164
+ });
165
+ return {
166
+ ...priceSet,
167
+ prices,
168
+ };
169
+ });
170
+ }
171
+ async update_(data, sharedContext = {}) {
172
+ // TODO: We are not handling rule types, rules, etc. here, add support after data models are finalized
173
+ // TODO: Since money IDs are rarely passed, this will delete all previous data and insert new entries.
174
+ // We can make the `insert` inside upsertWithReplace do an `upsert` instead to avoid this
175
+ const normalizedData = await this.normalizeUpdateData(data, sharedContext);
176
+ const prices = normalizedData.flatMap((priceSet) => priceSet.prices || []);
177
+ const upsertedPrices = await this.priceService_.upsertWithReplace(prices, {
178
+ relations: ["price_rules"],
179
+ }, sharedContext);
180
+ const priceSetsToUpsert = normalizedData.map((priceSet) => {
181
+ const { prices, ...rest } = priceSet;
182
+ return {
183
+ ...rest,
184
+ prices: upsertedPrices
185
+ .filter((p) => p.price_set_id === priceSet.id)
186
+ .map((price) => {
187
+ // @ts-ignore
188
+ delete price.price_rules;
189
+ return price;
190
+ }),
191
+ };
192
+ });
193
+ return await this.priceSetService_.upsertWithReplace(priceSetsToUpsert, { relations: ["prices"] }, sharedContext);
103
194
  }
104
195
  async addRules(data, sharedContext = {}) {
105
196
  const inputs = Array.isArray(data) ? data : [data];
@@ -131,10 +222,6 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.abstractModuleService
131
222
  await this.priceSetRuleTypeService_.delete(priceSetRuleTypes.map((psrt) => psrt.id), sharedContext);
132
223
  await this.priceService_.delete(priceRules.map((pr) => pr.price.id), sharedContext);
133
224
  }
134
- async update(data, sharedContext = {}) {
135
- const priceSets = await this.priceSetService_.update(data, sharedContext);
136
- return await this.baseRepository_.serialize(priceSets);
137
- }
138
225
  async createPriceLists(data, sharedContext = {}) {
139
226
  const priceLists = await this.createPriceLists_(data, sharedContext);
140
227
  return await this.baseRepository_.serialize(priceLists);
@@ -159,13 +246,15 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.abstractModuleService
159
246
  });
160
247
  }
161
248
  async updatePriceListPrices(data, sharedContext = {}) {
162
- return await this.updatePriceListPrices_(data, sharedContext);
249
+ const prices = await this.updatePriceListPrices_(data, sharedContext);
250
+ return await this.baseRepository_.serialize(prices);
163
251
  }
164
252
  async removePrices(ids, sharedContext = {}) {
165
253
  await this.removePrices_(ids, sharedContext);
166
254
  }
167
255
  async addPriceListPrices(data, sharedContext = {}) {
168
- return await this.addPriceListPrices_(data, sharedContext);
256
+ const prices = await this.addPriceListPrices_(data, sharedContext);
257
+ return await this.baseRepository_.serialize(prices);
169
258
  }
170
259
  async setPriceListRules(data, sharedContext = {}) {
171
260
  const [priceList] = await this.setPriceListRules_([data], sharedContext);
@@ -475,40 +564,37 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.abstractModuleService
475
564
  }
476
565
  const priceLists = await this.listPriceLists({ id: priceListIds }, { take: null }, sharedContext);
477
566
  const priceListMap = new Map(priceLists.map((p) => [p.id, p]));
567
+ const pricesToUpdate = [];
568
+ const priceRuleIdsToDelete = [];
569
+ const priceRulesToCreate = [];
478
570
  for (const { price_list_id: priceListId, prices } of data) {
479
571
  const priceList = priceListMap.get(priceListId);
480
572
  if (!priceList) {
481
573
  throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Price list with id: ${priceListId} not found`);
482
574
  }
483
- const priceRuleIdsToDelete = [];
484
- const priceRulesToCreate = [];
485
- const pricesToUpdate = [];
486
575
  for (const priceData of prices) {
487
- const { rules, price_set_id, ...rest } = priceData;
576
+ const { rules = {}, price_set_id, ...rest } = priceData;
488
577
  const price = priceMap.get(rest.id);
489
578
  const priceRules = price.price_rules;
490
- if (!(0, utils_1.isDefined)(rules)) {
491
- continue;
492
- }
579
+ priceRulesToCreate.push(...Object.entries(rules).map(([ruleAttribute, ruleValue]) => ({
580
+ price_set_id,
581
+ rule_type_id: ruleTypeMap.get(ruleAttribute).id,
582
+ value: ruleValue,
583
+ price_id: price.id,
584
+ })));
493
585
  pricesToUpdate.push({
494
586
  ...rest,
495
587
  rules_count: Object.keys(rules).length,
496
- price_rules: Object.entries(rules).map(([ruleAttribute, ruleValue]) => ({
497
- price_set_id,
498
- rule_type_id: ruleTypeMap.get(ruleAttribute).id,
499
- value: ruleValue,
500
- price_id: price.id,
501
- })),
502
588
  });
503
589
  priceRuleIdsToDelete.push(...priceRules.map((pr) => pr.id));
504
590
  }
505
- await (0, utils_1.promiseAll)([
506
- this.priceRuleService_.delete(priceRuleIdsToDelete),
507
- this.priceRuleService_.create(priceRulesToCreate),
508
- this.priceService_.update(pricesToUpdate),
509
- ]);
510
591
  }
511
- return priceLists;
592
+ const [_deletedPriceRule, _createdPriceRule, updatedPrices] = await (0, utils_1.promiseAll)([
593
+ this.priceRuleService_.delete(priceRuleIdsToDelete),
594
+ this.priceRuleService_.create(priceRulesToCreate),
595
+ this.priceService_.update(pricesToUpdate),
596
+ ]);
597
+ return updatedPrices;
512
598
  }
513
599
  async removePrices_(ids, sharedContext = {}) {
514
600
  await this.priceService_.delete(ids, sharedContext);
@@ -577,8 +663,7 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.abstractModuleService
577
663
  });
578
664
  pricesToCreate.push(...priceListPricesToCreate);
579
665
  }
580
- await this.priceService_.create(pricesToCreate, sharedContext);
581
- return priceLists;
666
+ return await this.priceService_.create(pricesToCreate, sharedContext);
582
667
  }
583
668
  async setPriceListRules_(data, sharedContext = {}) {
584
669
  // TODO: re think this method
@@ -684,28 +769,42 @@ __decorate([
684
769
  __metadata("design:type", Function),
685
770
  __metadata("design:paramtypes", [Object, Object]),
686
771
  __metadata("design:returntype", Promise)
687
- ], PricingModuleService.prototype, "addRules", null);
772
+ ], PricingModuleService.prototype, "upsert", null);
688
773
  __decorate([
689
774
  (0, utils_1.InjectManager)("baseRepository_"),
690
- __param(1, (0, utils_1.MedusaContext)()),
775
+ __param(2, (0, utils_1.MedusaContext)()),
691
776
  __metadata("design:type", Function),
692
- __metadata("design:paramtypes", [Object, Object]),
777
+ __metadata("design:paramtypes", [Object, Object, Object]),
693
778
  __metadata("design:returntype", Promise)
694
- ], PricingModuleService.prototype, "addPrices", null);
779
+ ], PricingModuleService.prototype, "update", null);
695
780
  __decorate([
696
781
  (0, utils_1.InjectTransactionManager)("baseRepository_"),
697
782
  __param(1, (0, utils_1.MedusaContext)()),
698
783
  __metadata("design:type", Function),
699
784
  __metadata("design:paramtypes", [Array, Object]),
700
785
  __metadata("design:returntype", Promise)
701
- ], PricingModuleService.prototype, "removeRules", null);
786
+ ], PricingModuleService.prototype, "update_", null);
787
+ __decorate([
788
+ (0, utils_1.InjectManager)("baseRepository_"),
789
+ __param(1, (0, utils_1.MedusaContext)()),
790
+ __metadata("design:type", Function),
791
+ __metadata("design:paramtypes", [Object, Object]),
792
+ __metadata("design:returntype", Promise)
793
+ ], PricingModuleService.prototype, "addRules", null);
794
+ __decorate([
795
+ (0, utils_1.InjectManager)("baseRepository_"),
796
+ __param(1, (0, utils_1.MedusaContext)()),
797
+ __metadata("design:type", Function),
798
+ __metadata("design:paramtypes", [Object, Object]),
799
+ __metadata("design:returntype", Promise)
800
+ ], PricingModuleService.prototype, "addPrices", null);
702
801
  __decorate([
703
802
  (0, utils_1.InjectTransactionManager)("baseRepository_"),
704
803
  __param(1, (0, utils_1.MedusaContext)()),
705
804
  __metadata("design:type", Function),
706
805
  __metadata("design:paramtypes", [Array, Object]),
707
806
  __metadata("design:returntype", Promise)
708
- ], PricingModuleService.prototype, "update", null);
807
+ ], PricingModuleService.prototype, "removeRules", null);
709
808
  __decorate([
710
809
  (0, utils_1.InjectManager)("baseRepository_"),
711
810
  __param(1, (0, utils_1.MedusaContext)()),
@@ -1 +1,2 @@
1
1
  export * from "./price-list";
2
+ export * from "./price-set";
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./price-list"), exports);
18
+ __exportStar(require("./price-set"), exports);
@@ -0,0 +1,4 @@
1
+ import { UpdatePriceSetDTO } from "@medusajs/types";
2
+ export interface UpdatePriceSetInput extends UpdatePriceSetDTO {
3
+ id: string;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/pricing",
3
- "version": "0.1.12-snapshot-20240328213126",
3
+ "version": "0.2.0-next-20240425093236",
4
4
  "description": "Medusa Pricing module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -40,7 +40,7 @@
40
40
  "@mikro-orm/cli": "5.9.7",
41
41
  "cross-env": "^5.2.1",
42
42
  "jest": "^29.6.3",
43
- "medusa-test-utils": "1.1.44-snapshot-20240328213126",
43
+ "medusa-test-utils": "1.1.44-next-20240425093236",
44
44
  "rimraf": "^3.0.2",
45
45
  "ts-jest": "^29.1.1",
46
46
  "ts-node": "^10.9.1",
@@ -48,9 +48,9 @@
48
48
  "typescript": "^5.1.6"
49
49
  },
50
50
  "dependencies": {
51
- "@medusajs/modules-sdk": "^1.12.10",
52
- "@medusajs/types": "1.12.0-snapshot-20240328213126",
53
- "@medusajs/utils": "1.12.0-snapshot-20240328213126",
51
+ "@medusajs/modules-sdk": "1.12.11-next-20240425093236",
52
+ "@medusajs/types": "1.12.0-next-20240425093236",
53
+ "@medusajs/utils": "1.12.0-next-20240425093236",
54
54
  "@mikro-orm/core": "5.9.7",
55
55
  "@mikro-orm/migrations": "5.9.7",
56
56
  "@mikro-orm/postgresql": "5.9.7",