@medusajs/promotion 0.0.5-snapshot-20240717160031 → 0.0.5-snapshot-20240718083016

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. package/dist/index.d.ts +4 -5
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +20 -5
  4. package/dist/initialize/index.d.ts +5 -0
  5. package/dist/initialize/index.d.ts.map +1 -0
  6. package/dist/initialize/index.js +16 -0
  7. package/dist/joiner-config.d.ts +8 -1
  8. package/dist/joiner-config.d.ts.map +1 -1
  9. package/dist/joiner-config.js +35 -4
  10. package/dist/loaders/connection.d.ts +5 -0
  11. package/dist/loaders/connection.d.ts.map +1 -0
  12. package/dist/loaders/connection.js +41 -0
  13. package/dist/loaders/container.d.ts +3 -0
  14. package/dist/loaders/container.d.ts.map +1 -0
  15. package/dist/loaders/container.js +34 -0
  16. package/dist/loaders/index.d.ts +3 -0
  17. package/dist/loaders/index.d.ts.map +1 -0
  18. package/dist/loaders/index.js +18 -0
  19. package/dist/migrations/Migration20240227120221.d.ts.map +1 -1
  20. package/dist/migrations/Migration20240227120221.js +2 -10
  21. package/dist/models/application-method.d.ts +6 -4
  22. package/dist/models/application-method.d.ts.map +1 -1
  23. package/dist/models/application-method.js +6 -16
  24. package/dist/models/campaign-budget.d.ts +5 -6
  25. package/dist/models/campaign-budget.d.ts.map +1 -1
  26. package/dist/models/campaign-budget.js +4 -8
  27. package/dist/models/campaign.d.ts +4 -3
  28. package/dist/models/campaign.d.ts.map +1 -1
  29. package/dist/models/campaign.js +13 -10
  30. package/dist/models/promotion-rule-value.d.ts +1 -2
  31. package/dist/models/promotion-rule-value.d.ts.map +1 -1
  32. package/dist/models/promotion-rule-value.js +1 -1
  33. package/dist/models/promotion-rule.d.ts +1 -1
  34. package/dist/models/promotion-rule.d.ts.map +1 -1
  35. package/dist/models/promotion.d.ts +4 -5
  36. package/dist/models/promotion.d.ts.map +1 -1
  37. package/dist/models/promotion.js +4 -8
  38. package/dist/module-definition.d.ts +5 -0
  39. package/dist/module-definition.d.ts.map +1 -0
  40. package/dist/module-definition.js +50 -0
  41. package/dist/repositories/campaign.d.ts +16 -0
  42. package/dist/repositories/campaign.d.ts.map +1 -0
  43. package/dist/repositories/campaign.js +90 -0
  44. package/dist/repositories/index.d.ts +3 -0
  45. package/dist/repositories/index.d.ts.map +1 -0
  46. package/dist/repositories/index.js +7 -0
  47. package/dist/services/promotion-module.d.ts +26 -40
  48. package/dist/services/promotion-module.d.ts.map +1 -1
  49. package/dist/services/promotion-module.js +62 -189
  50. package/dist/types/application-method.d.ts +10 -12
  51. package/dist/types/application-method.d.ts.map +1 -1
  52. package/dist/types/campaign-budget.d.ts +6 -8
  53. package/dist/types/campaign-budget.d.ts.map +1 -1
  54. package/dist/types/campaign.d.ts +8 -6
  55. package/dist/types/campaign.d.ts.map +1 -1
  56. package/dist/types/promotion.d.ts +2 -2
  57. package/dist/types/promotion.d.ts.map +1 -1
  58. package/dist/utils/compute-actions/buy-get.d.ts +2 -2
  59. package/dist/utils/compute-actions/buy-get.d.ts.map +1 -1
  60. package/dist/utils/compute-actions/buy-get.js +12 -12
  61. package/dist/utils/compute-actions/line-items.d.ts.map +1 -1
  62. package/dist/utils/compute-actions/line-items.js +4 -4
  63. package/dist/utils/compute-actions/shipping-methods.d.ts +2 -2
  64. package/dist/utils/compute-actions/shipping-methods.d.ts.map +1 -1
  65. package/dist/utils/compute-actions/shipping-methods.js +17 -14
  66. package/dist/utils/compute-actions/usage.d.ts +2 -2
  67. package/dist/utils/compute-actions/usage.d.ts.map +1 -1
  68. package/dist/utils/compute-actions/usage.js +3 -3
  69. package/dist/utils/validations/application-method.d.ts.map +1 -1
  70. package/dist/utils/validations/application-method.js +2 -2
  71. package/package.json +13 -8
  72. package/dist/migrations/Migration20240617102917.d.ts +0 -6
  73. package/dist/migrations/Migration20240617102917.d.ts.map +0 -1
  74. package/dist/migrations/Migration20240617102917.js +0 -15
  75. package/dist/migrations/Migration20240624153824.d.ts +0 -6
  76. package/dist/migrations/Migration20240624153824.d.ts.map +0 -1
  77. package/dist/migrations/Migration20240624153824.js +0 -15
@@ -18,14 +18,14 @@ const _models_1 = require("../models");
18
18
  const _types_1 = require("../types");
19
19
  const _utils_1 = require("../utils");
20
20
  const joiner_config_1 = require("../joiner-config");
21
- class PromotionModuleService extends (0, utils_1.MedusaService)({
22
- Promotion: _models_1.Promotion,
23
- ApplicationMethod: _models_1.ApplicationMethod,
24
- Campaign: _models_1.Campaign,
25
- CampaignBudget: _models_1.CampaignBudget,
26
- PromotionRule: _models_1.PromotionRule,
27
- PromotionRuleValue: _models_1.PromotionRuleValue,
28
- }) {
21
+ const generateMethodForModels = [
22
+ _models_1.ApplicationMethod,
23
+ _models_1.Campaign,
24
+ _models_1.CampaignBudget,
25
+ _models_1.PromotionRule,
26
+ _models_1.PromotionRuleValue,
27
+ ];
28
+ class PromotionModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFactory(_models_1.Promotion, generateMethodForModels, joiner_config_1.entityNameToLinkableKeysMap) {
29
29
  constructor({ baseRepository, promotionService, applicationMethodService, promotionRuleService, promotionRuleValueService, campaignService, campaignBudgetService, }, moduleDeclaration) {
30
30
  // @ts-ignore
31
31
  super(...arguments);
@@ -47,7 +47,7 @@ class PromotionModuleService extends (0, utils_1.MedusaService)({
47
47
  .filter(Boolean);
48
48
  const promotionCodeCampaignBudgetMap = new Map();
49
49
  const promotionCodeUsageMap = new Map();
50
- const existingPromotions = await this.listPromotions({ code: promotionCodes }, { relations: ["application_method", "campaign", "campaign.budget"] }, sharedContext);
50
+ const existingPromotions = await this.list({ code: promotionCodes }, { relations: ["application_method", "campaign", "campaign.budget"] }, sharedContext);
51
51
  const existingPromotionsMap = new Map(existingPromotions.map((promotion) => [promotion.code, promotion]));
52
52
  for (let computedAction of computedActions) {
53
53
  if (!_utils_1.ComputeActionUtils.canRegisterUsage(computedAction)) {
@@ -63,9 +63,10 @@ class PromotionModuleService extends (0, utils_1.MedusaService)({
63
63
  }
64
64
  if (campaignBudget.type === utils_1.CampaignBudgetType.SPEND) {
65
65
  const campaignBudgetData = promotionCodeCampaignBudgetMap.get(campaignBudget.id) || { id: campaignBudget.id, used: campaignBudget.used ?? 0 };
66
- campaignBudgetData.used = utils_1.MathBN.add(campaignBudgetData.used ?? 0, computedAction.amount);
66
+ campaignBudgetData.used =
67
+ (campaignBudgetData.used ?? 0) + computedAction.amount;
67
68
  if (campaignBudget.limit &&
68
- utils_1.MathBN.gt(campaignBudgetData.used, campaignBudget.limit)) {
69
+ campaignBudgetData.used > campaignBudget.limit) {
69
70
  continue;
70
71
  }
71
72
  promotionCodeCampaignBudgetMap.set(campaignBudget.id, campaignBudgetData);
@@ -77,10 +78,10 @@ class PromotionModuleService extends (0, utils_1.MedusaService)({
77
78
  }
78
79
  const campaignBudgetData = {
79
80
  id: campaignBudget.id,
80
- used: utils_1.MathBN.add(campaignBudget.used ?? 0, 1),
81
+ used: (campaignBudget.used ?? 0) + 1,
81
82
  };
82
83
  if (campaignBudget.limit &&
83
- utils_1.MathBN.gt(campaignBudgetData.used, campaignBudget.limit)) {
84
+ campaignBudgetData.used > campaignBudget.limit) {
84
85
  continue;
85
86
  }
86
87
  promotionCodeCampaignBudgetMap.set(campaignBudget.id, campaignBudgetData);
@@ -103,7 +104,7 @@ class PromotionModuleService extends (0, utils_1.MedusaService)({
103
104
  const methodIdPromoValueMap = new Map();
104
105
  const automaticPromotions = preventAutoPromotions
105
106
  ? []
106
- : await this.listPromotions({ is_automatic: true }, { select: ["code"], take: null }, sharedContext);
107
+ : await this.list({ is_automatic: true }, { select: ["code"], take: null }, sharedContext);
107
108
  // Promotions we need to apply includes all the codes that are passed as an argument
108
109
  // to this method, along with any automatic promotions that can be applied to the context
109
110
  const automaticPromotionCodes = automaticPromotions.map((p) => p.code);
@@ -131,7 +132,7 @@ class PromotionModuleService extends (0, utils_1.MedusaService)({
131
132
  }
132
133
  });
133
134
  });
134
- const promotions = await this.listPromotions({
135
+ const promotions = await this.list({
135
136
  code: [
136
137
  ...promotionCodesToApply,
137
138
  ...appliedItemCodes,
@@ -208,13 +209,12 @@ class PromotionModuleService extends (0, utils_1.MedusaService)({
208
209
  }
209
210
  }
210
211
  }
211
- (0, utils_1.transformPropertiesToBigNumber)(computedActions, { include: ["amount"] });
212
212
  return computedActions;
213
213
  }
214
- async createPromotions(data, sharedContext = {}) {
214
+ async create(data, sharedContext = {}) {
215
215
  const input = Array.isArray(data) ? data : [data];
216
- const createdPromotions = await this.createPromotions_(input, sharedContext);
217
- const promotions = await this.listPromotions({ id: createdPromotions.map((p) => p.id) }, {
216
+ const createdPromotions = await this.create_(input, sharedContext);
217
+ const promotions = await this.list({ id: createdPromotions.map((p) => p.id) }, {
218
218
  relations: [
219
219
  "application_method",
220
220
  "application_method.target_rules",
@@ -230,45 +230,31 @@ class PromotionModuleService extends (0, utils_1.MedusaService)({
230
230
  }, sharedContext);
231
231
  return Array.isArray(data) ? promotions : promotions[0];
232
232
  }
233
- async createPromotions_(data, sharedContext = {}) {
233
+ async create_(data, sharedContext = {}) {
234
234
  const promotionsData = [];
235
235
  const applicationMethodsData = [];
236
236
  const campaignsData = [];
237
- const existingCampaigns = await this.campaignService_.list({ id: data.map((d) => d.campaign_id).filter((id) => (0, utils_1.isString)(id)) }, { relations: ["budget"] }, sharedContext);
238
237
  const promotionCodeApplicationMethodDataMap = new Map();
239
238
  const promotionCodeRulesDataMap = new Map();
240
239
  const methodTargetRulesMap = new Map();
241
240
  const methodBuyRulesMap = new Map();
242
241
  const promotionCodeCampaignMap = new Map();
243
242
  for (const { application_method: applicationMethodData, rules: rulesData, campaign: campaignData, campaign_id: campaignId, ...promotionData } of data) {
244
- promotionCodeApplicationMethodDataMap.set(promotionData.code, applicationMethodData);
243
+ if (applicationMethodData) {
244
+ promotionCodeApplicationMethodDataMap.set(promotionData.code, applicationMethodData);
245
+ }
245
246
  if (rulesData) {
246
247
  promotionCodeRulesDataMap.set(promotionData.code, rulesData);
247
248
  }
248
249
  if (campaignData && campaignId) {
249
250
  throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Provide either the 'campaign' or 'campaign_id' parameter; both cannot be used simultaneously.`);
250
251
  }
251
- if (!campaignData && !campaignId) {
252
- promotionsData.push({ ...promotionData });
253
- continue;
254
- }
255
- const existingCampaign = existingCampaigns.find((c) => c.id === campaignId);
256
- if (campaignId && !existingCampaign) {
257
- throw new utils_1.MedusaError(utils_1.MedusaError.Types.NOT_FOUND, `Could not find campaign with id - ${campaignId}`);
258
- }
259
- const campaignCurrency = campaignData?.budget?.currency_code ||
260
- existingCampaigns.find((c) => c.id === campaignId)?.budget
261
- ?.currency_code;
262
- if (campaignData?.budget?.type === utils_1.CampaignBudgetType.SPEND &&
263
- campaignCurrency !== applicationMethodData?.currency_code) {
264
- throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Currency between promotion and campaigns should match`);
265
- }
266
252
  if (campaignData) {
267
253
  promotionCodeCampaignMap.set(promotionData.code, campaignData);
268
254
  }
269
255
  promotionsData.push({
270
256
  ...promotionData,
271
- campaign_id: campaignId,
257
+ campaign: campaignId,
272
258
  });
273
259
  }
274
260
  const createdPromotions = await this.promotionService_.create(promotionsData, sharedContext);
@@ -311,14 +297,8 @@ class PromotionModuleService extends (0, utils_1.MedusaService)({
311
297
  await this.createPromotionRulesAndValues_(promotionCodeRulesDataMap.get(promotion.code) || [], "promotions", promotion, sharedContext);
312
298
  }
313
299
  const createdApplicationMethods = await this.applicationMethodService_.create(applicationMethodsData, sharedContext);
314
- const createdCampaigns = await this.createCampaigns(campaignsData, sharedContext);
315
- for (const campaignData of campaignsData) {
316
- const promotions = campaignData.promotions;
317
- const campaign = createdCampaigns.find((c) => c.campaign_identifier === campaignData.campaign_identifier);
318
- if (!campaign || !promotions || !promotions.length) {
319
- continue;
320
- }
321
- await this.addPromotionsToCampaign({ id: campaign.id, promotion_ids: promotions.map((p) => p.id) }, sharedContext);
300
+ if (campaignsData.length) {
301
+ await this.createCampaigns(campaignsData, sharedContext);
322
302
  }
323
303
  for (const applicationMethod of createdApplicationMethods) {
324
304
  await this.createPromotionRulesAndValues_(methodTargetRulesMap.get(applicationMethod.promotion.id) || [], "method_target_rules", applicationMethod, sharedContext);
@@ -326,10 +306,10 @@ class PromotionModuleService extends (0, utils_1.MedusaService)({
326
306
  }
327
307
  return createdPromotions;
328
308
  }
329
- async updatePromotions(data, sharedContext = {}) {
309
+ async update(data, sharedContext = {}) {
330
310
  const input = Array.isArray(data) ? data : [data];
331
- const updatedPromotions = await this.updatePromotions_(input, sharedContext);
332
- const promotions = await this.listPromotions({ id: updatedPromotions.map((p) => p.id) }, {
311
+ const updatedPromotions = await this.update_(input, sharedContext);
312
+ const promotions = await this.list({ id: updatedPromotions.map((p) => p.id) }, {
333
313
  relations: [
334
314
  "application_method",
335
315
  "application_method.target_rules",
@@ -343,34 +323,25 @@ class PromotionModuleService extends (0, utils_1.MedusaService)({
343
323
  }, sharedContext);
344
324
  return Array.isArray(data) ? promotions : promotions[0];
345
325
  }
346
- async updatePromotions_(data, sharedContext = {}) {
326
+ async update_(data, sharedContext = {}) {
347
327
  const promotionIds = data.map((d) => d.id);
348
328
  const existingPromotions = await this.promotionService_.list({ id: promotionIds }, { relations: ["application_method"] });
349
- const existingCampaigns = await this.campaignService_.list({ id: data.map((d) => d.campaign_id).filter((d) => (0, utils_1.isPresent)(d)) }, { relations: ["budget"] });
350
329
  const existingPromotionsMap = new Map(existingPromotions.map((promotion) => [promotion.id, promotion]));
351
330
  const promotionsData = [];
352
331
  const applicationMethodsData = [];
353
332
  for (const { application_method: applicationMethodData, campaign_id: campaignId, ...promotionData } of data) {
354
- const existingCampaign = existingCampaigns.find((c) => c.id === campaignId);
355
- const existingPromotion = existingPromotionsMap.get(promotionData.id);
356
- const existingApplicationMethod = existingPromotion?.application_method;
357
- const promotionCurrencyCode = existingApplicationMethod?.currency_code ||
358
- applicationMethodData?.currency_code;
359
- if (campaignId && !existingCampaign) {
360
- throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Could not find campaign with id ${campaignId}`);
361
- }
362
- if (campaignId &&
363
- existingCampaign?.budget?.type === utils_1.CampaignBudgetType.SPEND &&
364
- existingCampaign.budget.currency_code !== promotionCurrencyCode) {
365
- throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Currency code doesn't match for campaign (${campaignId}) and promotion (${existingPromotion.id})`);
366
- }
367
- if ((0, utils_1.isDefined)(campaignId)) {
368
- promotionsData.push({ ...promotionData, campaign_id: campaignId });
333
+ if (campaignId) {
334
+ promotionsData.push({ ...promotionData, campaign: campaignId });
369
335
  }
370
336
  else {
371
337
  promotionsData.push(promotionData);
372
338
  }
373
- if (!applicationMethodData || !existingApplicationMethod) {
339
+ if (!applicationMethodData) {
340
+ continue;
341
+ }
342
+ const existingPromotion = existingPromotionsMap.get(promotionData.id);
343
+ const existingApplicationMethod = existingPromotion?.application_method;
344
+ if (!existingApplicationMethod) {
374
345
  continue;
375
346
  }
376
347
  if (applicationMethodData.allocation &&
@@ -390,10 +361,9 @@ class PromotionModuleService extends (0, utils_1.MedusaService)({
390
361
  }
391
362
  return updatedPromotions;
392
363
  }
393
- // @ts-ignore
394
364
  async updatePromotionRules(data, sharedContext = {}) {
395
365
  const updatedPromotionRules = await this.updatePromotionRules_(data, sharedContext);
396
- return await this.listPromotionRules({ id: updatedPromotionRules.map((r) => r.id) }, { relations: ["values"] }, sharedContext);
366
+ return this.listPromotionRules({ id: updatedPromotionRules.map((r) => r.id) }, { relations: ["values"] }, sharedContext);
397
367
  }
398
368
  async updatePromotionRules_(data, sharedContext = {}) {
399
369
  const promotionRuleIds = data.map((d) => d.id);
@@ -443,7 +413,9 @@ class PromotionModuleService extends (0, utils_1.MedusaService)({
443
413
  return await this.listPromotionRules({ id: createdPromotionRules.map((pr) => pr.id) }, { relations: ["values"] }, sharedContext);
444
414
  }
445
415
  async addPromotionBuyRules(promotionId, rulesData, sharedContext = {}) {
446
- const promotion = await this.promotionService_.retrieve(promotionId, { relations: ["application_method"] }, sharedContext);
416
+ const promotion = await this.promotionService_.retrieve(promotionId, {
417
+ relations: ["application_method"],
418
+ });
447
419
  const applicationMethod = promotion.application_method;
448
420
  if (!applicationMethod) {
449
421
  throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `application_method for promotion not found`);
@@ -519,19 +491,22 @@ class PromotionModuleService extends (0, utils_1.MedusaService)({
519
491
  const campaignBudgetsData = [];
520
492
  const campaignIdentifierBudgetMap = new Map();
521
493
  for (const createCampaignData of data) {
522
- const { budget: campaignBudgetData, ...campaignData } = createCampaignData;
494
+ const { budget: campaignBudgetData, promotions, ...campaignData } = createCampaignData;
495
+ const promotionsToAdd = promotions
496
+ ? await this.list({ id: promotions.map((p) => p.id) }, { take: null }, sharedContext)
497
+ : [];
523
498
  if (campaignBudgetData) {
524
499
  campaignIdentifierBudgetMap.set(campaignData.campaign_identifier, campaignBudgetData);
525
500
  }
526
501
  campaignsData.push({
527
502
  ...campaignData,
503
+ promotions: promotionsToAdd,
528
504
  });
529
505
  }
530
506
  const createdCampaigns = await this.campaignService_.create(campaignsData, sharedContext);
531
507
  for (const createdCampaign of createdCampaigns) {
532
508
  const campaignBudgetData = campaignIdentifierBudgetMap.get(createdCampaign.campaign_identifier);
533
509
  if (campaignBudgetData) {
534
- this.validateCampaignBudgetData(campaignBudgetData);
535
510
  campaignBudgetsData.push({
536
511
  ...campaignBudgetData,
537
512
  campaign: createdCampaign.id,
@@ -543,15 +518,6 @@ class PromotionModuleService extends (0, utils_1.MedusaService)({
543
518
  }
544
519
  return createdCampaigns;
545
520
  }
546
- validateCampaignBudgetData(data) {
547
- if (!data.type) {
548
- throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Campaign Budget type is a required field`);
549
- }
550
- if (data.type === utils_1.CampaignBudgetType.SPEND &&
551
- !(0, utils_1.isPresent)(data.currency_code)) {
552
- throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Campaign Budget type is a required field`);
553
- }
554
- }
555
521
  async updateCampaigns(data, sharedContext = {}) {
556
522
  const input = Array.isArray(data) ? data : [data];
557
523
  const updatedCampaigns = await this.updateCampaigns_(input, sharedContext);
@@ -564,92 +530,27 @@ class PromotionModuleService extends (0, utils_1.MedusaService)({
564
530
  async updateCampaigns_(data, sharedContext = {}) {
565
531
  const campaignIds = data.map((d) => d.id);
566
532
  const campaignsData = [];
567
- const updateBudgetData = [];
568
- const createBudgetData = [];
533
+ const campaignBudgetsData = [];
569
534
  const existingCampaigns = await this.listCampaigns({ id: campaignIds }, { relations: ["budget"], take: null }, sharedContext);
570
535
  const existingCampaignsMap = new Map(existingCampaigns.map((campaign) => [campaign.id, campaign]));
571
536
  for (const updateCampaignData of data) {
572
- const { budget: budgetData, ...campaignData } = updateCampaignData;
537
+ const { budget: campaignBudgetData, ...campaignData } = updateCampaignData;
573
538
  const existingCampaign = existingCampaignsMap.get(campaignData.id);
539
+ const existingCampaignBudget = existingCampaign?.budget;
574
540
  campaignsData.push(campaignData);
575
- // Type & currency code of the budget is immutable, we don't allow for it to be updated.
576
- // If an existing budget is present, we remove the type and currency from being updated
577
- if ((existingCampaign?.budget && budgetData?.type) ||
578
- budgetData?.currency_code) {
579
- delete budgetData?.type;
580
- delete budgetData?.currency_code;
581
- throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Campaign budget attributes (type, currency_code) are immutable`);
582
- }
583
- if (budgetData) {
584
- if (existingCampaign?.budget) {
585
- updateBudgetData.push({
586
- id: existingCampaign.budget.id,
587
- ...budgetData,
588
- });
589
- }
590
- else {
591
- createBudgetData.push({
592
- ...budgetData,
593
- campaign: existingCampaign.id,
594
- });
595
- }
541
+ if (existingCampaignBudget && campaignBudgetData) {
542
+ campaignBudgetsData.push({
543
+ id: existingCampaignBudget.id,
544
+ ...campaignBudgetData,
545
+ });
596
546
  }
597
547
  }
598
548
  const updatedCampaigns = await this.campaignService_.update(campaignsData, sharedContext);
599
- if (updateBudgetData.length) {
600
- await this.campaignBudgetService_.update(updateBudgetData, sharedContext);
601
- }
602
- if (createBudgetData.length) {
603
- await this.campaignBudgetService_.create(createBudgetData, sharedContext);
549
+ if (campaignBudgetsData.length) {
550
+ await this.campaignBudgetService_.update(campaignBudgetsData, sharedContext);
604
551
  }
605
552
  return updatedCampaigns;
606
553
  }
607
- async addPromotionsToCampaign(data, sharedContext) {
608
- const ids = await this.addPromotionsToCampaign_(data, sharedContext);
609
- return { ids };
610
- }
611
- // TODO:
612
- // - introduce currency_code to promotion
613
- // - allow promotions to be queried by currency code
614
- // - when the above is present, validate adding promotion to campaign based on currency code
615
- async addPromotionsToCampaign_(data, sharedContext = {}) {
616
- const { id, promotion_ids: promotionIds = [] } = data;
617
- const campaign = await this.campaignService_.retrieve(id, {}, sharedContext);
618
- const promotionsToAdd = await this.promotionService_.list({ id: promotionIds, campaign_id: null }, { take: null, relations: ["application_method"] }, sharedContext);
619
- const diff = (0, utils_1.arrayDifference)(promotionsToAdd.map((p) => p.id), promotionIds);
620
- if (diff.length > 0) {
621
- throw new utils_1.MedusaError(utils_1.MedusaError.Types.NOT_FOUND, `Cannot add promotions (${diff.join(",")}) to campaign. These promotions are either already part of a campaign or not found.`);
622
- }
623
- const promotionsWithInvalidCurrency = promotionsToAdd.filter((promotion) => campaign.budget?.type === utils_1.CampaignBudgetType.SPEND &&
624
- promotion.application_method?.currency_code !==
625
- campaign?.budget?.currency_code);
626
- if (promotionsWithInvalidCurrency.length > 0) {
627
- throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Cannot add promotions to campaign where currency_code don't match.`);
628
- }
629
- await this.promotionService_.update(promotionsToAdd.map((promotion) => ({
630
- id: promotion.id,
631
- campaign_id: campaign.id,
632
- })), sharedContext);
633
- return promotionsToAdd.map((promo) => promo.id);
634
- }
635
- async removePromotionsFromCampaign(data, sharedContext) {
636
- const ids = await this.removePromotionsFromCampaign_(data, sharedContext);
637
- return { ids };
638
- }
639
- async removePromotionsFromCampaign_(data, sharedContext = {}) {
640
- const { id, promotion_ids: promotionIds = [] } = data;
641
- await this.campaignService_.retrieve(id, {}, sharedContext);
642
- const promotionsToRemove = await this.promotionService_.list({ id: promotionIds }, { take: null }, sharedContext);
643
- const diff = (0, utils_1.arrayDifference)(promotionsToRemove.map((p) => p.id), promotionIds);
644
- if (diff.length > 0) {
645
- throw new utils_1.MedusaError(utils_1.MedusaError.Types.NOT_FOUND, `Promotions with ids (${diff.join(",")}) not found.`);
646
- }
647
- await this.promotionService_.update(promotionsToRemove.map((promotion) => ({
648
- id: promotion.id,
649
- campaign_id: null,
650
- })), sharedContext);
651
- return promotionsToRemove.map((promo) => promo.id);
652
- }
653
554
  }
654
555
  exports.default = PromotionModuleService;
655
556
  __decorate([
@@ -672,32 +573,30 @@ __decorate([
672
573
  __metadata("design:type", Function),
673
574
  __metadata("design:paramtypes", [Object, Object]),
674
575
  __metadata("design:returntype", Promise)
675
- ], PromotionModuleService.prototype, "createPromotions", null);
576
+ ], PromotionModuleService.prototype, "create", null);
676
577
  __decorate([
677
578
  (0, utils_1.InjectTransactionManager)("baseRepository_"),
678
579
  __param(1, (0, utils_1.MedusaContext)()),
679
580
  __metadata("design:type", Function),
680
581
  __metadata("design:paramtypes", [Array, Object]),
681
582
  __metadata("design:returntype", Promise)
682
- ], PromotionModuleService.prototype, "createPromotions_", null);
583
+ ], PromotionModuleService.prototype, "create_", null);
683
584
  __decorate([
684
585
  (0, utils_1.InjectManager)("baseRepository_"),
685
586
  __param(1, (0, utils_1.MedusaContext)()),
686
587
  __metadata("design:type", Function),
687
588
  __metadata("design:paramtypes", [Object, Object]),
688
589
  __metadata("design:returntype", Promise)
689
- ], PromotionModuleService.prototype, "updatePromotions", null);
590
+ ], PromotionModuleService.prototype, "update", null);
690
591
  __decorate([
691
592
  (0, utils_1.InjectTransactionManager)("baseRepository_"),
692
593
  __param(1, (0, utils_1.MedusaContext)()),
693
594
  __metadata("design:type", Function),
694
595
  __metadata("design:paramtypes", [Array, Object]),
695
596
  __metadata("design:returntype", Promise)
696
- ], PromotionModuleService.prototype, "updatePromotions_", null);
597
+ ], PromotionModuleService.prototype, "update_", null);
697
598
  __decorate([
698
- (0, utils_1.InjectManager)("baseRepository_")
699
- // @ts-ignore
700
- ,
599
+ (0, utils_1.InjectManager)("baseRepository_"),
701
600
  __param(1, (0, utils_1.MedusaContext)()),
702
601
  __metadata("design:type", Function),
703
602
  __metadata("design:paramtypes", [Array, Object]),
@@ -801,29 +700,3 @@ __decorate([
801
700
  __metadata("design:paramtypes", [Array, Object]),
802
701
  __metadata("design:returntype", Promise)
803
702
  ], PromotionModuleService.prototype, "updateCampaigns_", null);
804
- __decorate([
805
- (0, utils_1.InjectManager)("baseRepository_"),
806
- __metadata("design:type", Function),
807
- __metadata("design:paramtypes", [Object, Object]),
808
- __metadata("design:returntype", Promise)
809
- ], PromotionModuleService.prototype, "addPromotionsToCampaign", null);
810
- __decorate([
811
- (0, utils_1.InjectTransactionManager)("baseRepository_"),
812
- __param(1, (0, utils_1.MedusaContext)()),
813
- __metadata("design:type", Function),
814
- __metadata("design:paramtypes", [Object, Object]),
815
- __metadata("design:returntype", Promise)
816
- ], PromotionModuleService.prototype, "addPromotionsToCampaign_", null);
817
- __decorate([
818
- (0, utils_1.InjectManager)("baseRepository_"),
819
- __metadata("design:type", Function),
820
- __metadata("design:paramtypes", [Object, Object]),
821
- __metadata("design:returntype", Promise)
822
- ], PromotionModuleService.prototype, "removePromotionsFromCampaign", null);
823
- __decorate([
824
- (0, utils_1.InjectTransactionManager)("baseRepository_"),
825
- __param(1, (0, utils_1.MedusaContext)()),
826
- __metadata("design:type", Function),
827
- __metadata("design:paramtypes", [Object, Object]),
828
- __metadata("design:returntype", Promise)
829
- ], PromotionModuleService.prototype, "removePromotionsFromCampaign_", null);
@@ -1,26 +1,24 @@
1
- import { ApplicationMethodAllocationValues, ApplicationMethodTargetTypeValues, ApplicationMethodTypeValues, BigNumberInput, PromotionDTO } from "@medusajs/types";
1
+ import { ApplicationMethodAllocationValues, ApplicationMethodTargetTypeValues, ApplicationMethodTypeValues, PromotionDTO } from "@medusajs/types";
2
2
  import { Promotion } from "../models";
3
3
  export interface CreateApplicationMethodDTO {
4
4
  type: ApplicationMethodTypeValues;
5
5
  target_type: ApplicationMethodTargetTypeValues;
6
6
  allocation?: ApplicationMethodAllocationValues;
7
- value?: BigNumberInput;
8
- currency_code?: string | null;
7
+ value?: number;
9
8
  promotion: Promotion | string | PromotionDTO;
10
- max_quantity?: BigNumberInput | null;
11
- buy_rules_min_quantity?: BigNumberInput | null;
12
- apply_to_quantity?: BigNumberInput | null;
9
+ max_quantity?: number | null;
10
+ buy_rules_min_quantity?: number | null;
11
+ apply_to_quantity?: number | null;
13
12
  }
14
13
  export interface UpdateApplicationMethodDTO {
15
- id?: string;
14
+ id: string;
16
15
  type?: ApplicationMethodTypeValues;
17
16
  target_type?: ApplicationMethodTargetTypeValues;
18
17
  allocation?: ApplicationMethodAllocationValues;
19
- value?: BigNumberInput;
20
- currency_code?: string | null;
18
+ value?: number;
21
19
  promotion?: Promotion | string | PromotionDTO;
22
- max_quantity?: BigNumberInput | null;
23
- buy_rules_min_quantity?: BigNumberInput | null;
24
- apply_to_quantity?: BigNumberInput | null;
20
+ max_quantity?: number | null;
21
+ buy_rules_min_quantity?: number | null;
22
+ apply_to_quantity?: number | null;
25
23
  }
26
24
  //# sourceMappingURL=application-method.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"application-method.d.ts","sourceRoot":"","sources":["../../src/types/application-method.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EACjC,iCAAiC,EACjC,2BAA2B,EAC3B,cAAc,EACd,YAAY,EACb,MAAM,iBAAiB,CAAA;AAExB,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEnC,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,2BAA2B,CAAA;IACjC,WAAW,EAAE,iCAAiC,CAAA;IAC9C,UAAU,CAAC,EAAE,iCAAiC,CAAA;IAC9C,KAAK,CAAC,EAAE,cAAc,CAAA;IACtB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,SAAS,EAAE,SAAS,GAAG,MAAM,GAAG,YAAY,CAAA;IAC5C,YAAY,CAAC,EAAE,cAAc,GAAG,IAAI,CAAA;IACpC,sBAAsB,CAAC,EAAE,cAAc,GAAG,IAAI,CAAA;IAC9C,iBAAiB,CAAC,EAAE,cAAc,GAAG,IAAI,CAAA;CAC1C;AAED,MAAM,WAAW,0BAA0B;IACzC,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,2BAA2B,CAAA;IAClC,WAAW,CAAC,EAAE,iCAAiC,CAAA;IAC/C,UAAU,CAAC,EAAE,iCAAiC,CAAA;IAC9C,KAAK,CAAC,EAAE,cAAc,CAAA;IACtB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,SAAS,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,YAAY,CAAA;IAC7C,YAAY,CAAC,EAAE,cAAc,GAAG,IAAI,CAAA;IACpC,sBAAsB,CAAC,EAAE,cAAc,GAAG,IAAI,CAAA;IAC9C,iBAAiB,CAAC,EAAE,cAAc,GAAG,IAAI,CAAA;CAC1C"}
1
+ {"version":3,"file":"application-method.d.ts","sourceRoot":"","sources":["../../src/types/application-method.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EACjC,iCAAiC,EACjC,2BAA2B,EAC3B,YAAY,EACb,MAAM,iBAAiB,CAAA;AAExB,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEnC,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,2BAA2B,CAAA;IACjC,WAAW,EAAE,iCAAiC,CAAA;IAC9C,UAAU,CAAC,EAAE,iCAAiC,CAAA;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,SAAS,GAAG,MAAM,GAAG,YAAY,CAAA;IAC5C,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,sBAAsB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtC,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAClC;AAED,MAAM,WAAW,0BAA0B;IACzC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,CAAC,EAAE,2BAA2B,CAAA;IAClC,WAAW,CAAC,EAAE,iCAAiC,CAAA;IAC/C,UAAU,CAAC,EAAE,iCAAiC,CAAA;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,YAAY,CAAA;IAC7C,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,sBAAsB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtC,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAClC"}
@@ -1,17 +1,15 @@
1
- import { BigNumberInput, CampaignBudgetTypeValues } from "@medusajs/types";
1
+ import { CampaignBudgetTypeValues } from "@medusajs/types";
2
2
  import { Campaign } from "../models";
3
3
  export interface CreateCampaignBudgetDTO {
4
- type?: CampaignBudgetTypeValues;
5
- limit?: BigNumberInput | null;
6
- currency_code?: string | null;
7
- used?: BigNumberInput;
4
+ type: CampaignBudgetTypeValues;
5
+ limit: number | null;
6
+ used?: number;
8
7
  campaign?: Campaign | string;
9
8
  }
10
9
  export interface UpdateCampaignBudgetDTO {
11
10
  id: string;
12
11
  type?: CampaignBudgetTypeValues;
13
- limit?: BigNumberInput | null;
14
- currency_code?: string | null;
15
- used?: BigNumberInput;
12
+ limit?: number | null;
13
+ used?: number;
16
14
  }
17
15
  //# sourceMappingURL=campaign-budget.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"campaign-budget.d.ts","sourceRoot":"","sources":["../../src/types/campaign-budget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAA;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAElC,MAAM,WAAW,uBAAuB;IACtC,IAAI,CAAC,EAAE,wBAAwB,CAAA;IAC/B,KAAK,CAAC,EAAE,cAAc,GAAG,IAAI,CAAA;IAC7B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,IAAI,CAAC,EAAE,cAAc,CAAA;IACrB,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAA;CAC7B;AAED,MAAM,WAAW,uBAAuB;IACtC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,CAAC,EAAE,wBAAwB,CAAA;IAC/B,KAAK,CAAC,EAAE,cAAc,GAAG,IAAI,CAAA;IAC7B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,IAAI,CAAC,EAAE,cAAc,CAAA;CACtB"}
1
+ {"version":3,"file":"campaign-budget.d.ts","sourceRoot":"","sources":["../../src/types/campaign-budget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAElC,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,wBAAwB,CAAA;IAC9B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAA;CAC7B;AAED,MAAM,WAAW,uBAAuB;IACtC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,CAAC,EAAE,wBAAwB,CAAA;IAC/B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,IAAI,CAAC,EAAE,MAAM,CAAA;CACd"}
@@ -2,19 +2,21 @@ import { PromotionDTO } from "@medusajs/types";
2
2
  import { Promotion } from "../models";
3
3
  export interface CreateCampaignDTO {
4
4
  name: string;
5
- description?: string | null;
5
+ description?: string;
6
+ currency?: string;
6
7
  campaign_identifier: string;
7
- starts_at?: Date | null;
8
- ends_at?: Date | null;
8
+ starts_at: Date;
9
+ ends_at: Date;
9
10
  promotions?: (PromotionDTO | Promotion)[];
10
11
  }
11
12
  export interface UpdateCampaignDTO {
12
13
  id: string;
13
14
  name?: string;
14
- description?: string | null;
15
+ description?: string;
16
+ currency?: string;
15
17
  campaign_identifier?: string;
16
- starts_at?: Date | null;
17
- ends_at?: Date | null;
18
+ starts_at?: Date;
19
+ ends_at?: Date;
18
20
  promotions?: (PromotionDTO | Promotion)[];
19
21
  }
20
22
  //# sourceMappingURL=campaign.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"campaign.d.ts","sourceRoot":"","sources":["../../src/types/campaign.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEnC,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,mBAAmB,EAAE,MAAM,CAAA;IAC3B,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;IACvB,OAAO,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;IACrB,UAAU,CAAC,EAAE,CAAC,YAAY,GAAG,SAAS,CAAC,EAAE,CAAA;CAC1C;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;IACvB,OAAO,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;IACrB,UAAU,CAAC,EAAE,CAAC,YAAY,GAAG,SAAS,CAAC,EAAE,CAAA;CAC1C"}
1
+ {"version":3,"file":"campaign.d.ts","sourceRoot":"","sources":["../../src/types/campaign.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEnC,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,mBAAmB,EAAE,MAAM,CAAA;IAC3B,SAAS,EAAE,IAAI,CAAA;IACf,OAAO,EAAE,IAAI,CAAA;IACb,UAAU,CAAC,EAAE,CAAC,YAAY,GAAG,SAAS,CAAC,EAAE,CAAA;CAC1C;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,SAAS,CAAC,EAAE,IAAI,CAAA;IAChB,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,UAAU,CAAC,EAAE,CAAC,YAAY,GAAG,SAAS,CAAC,EAAE,CAAA;CAC1C"}
@@ -3,13 +3,13 @@ export interface CreatePromotionDTO {
3
3
  code: string;
4
4
  type: PromotionTypeValues;
5
5
  is_automatic?: boolean;
6
- campaign_id?: string | null;
6
+ campaign?: string;
7
7
  }
8
8
  export interface UpdatePromotionDTO {
9
9
  id: string;
10
10
  code?: string;
11
11
  type?: PromotionTypeValues;
12
12
  is_automatic?: boolean;
13
- campaign_id?: string | null;
13
+ campaign?: string;
14
14
  }
15
15
  //# sourceMappingURL=promotion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"promotion.d.ts","sourceRoot":"","sources":["../../src/types/promotion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAErD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,mBAAmB,CAAA;IACzB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC5B;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,mBAAmB,CAAA;IAC1B,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC5B"}
1
+ {"version":3,"file":"promotion.d.ts","sourceRoot":"","sources":["../../src/types/promotion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAErD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,mBAAmB,CAAA;IACzB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,mBAAmB,CAAA;IAC1B,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB"}
@@ -1,5 +1,5 @@
1
- import { BigNumberInput, PromotionTypes } from "@medusajs/types";
1
+ import { PromotionTypes } from "@medusajs/types";
2
2
  import { ApplicationMethodTargetType } from "@medusajs/utils";
3
- export declare function getComputedActionsForBuyGet(promotion: PromotionTypes.PromotionDTO, itemsContext: PromotionTypes.ComputeActionContext[ApplicationMethodTargetType.ITEMS], methodIdPromoValueMap: Map<string, BigNumberInput>): PromotionTypes.ComputeActions[];
3
+ export declare function getComputedActionsForBuyGet(promotion: PromotionTypes.PromotionDTO, itemsContext: PromotionTypes.ComputeActionContext[ApplicationMethodTargetType.ITEMS], methodIdPromoValueMap: Map<string, number>): PromotionTypes.ComputeActions[];
4
4
  export declare function sortByBuyGetType(a: any, b: any): 0 | 1 | -1;
5
5
  //# sourceMappingURL=buy-get.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"buy-get.d.ts","sourceRoot":"","sources":["../../../src/utils/compute-actions/buy-get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChE,OAAO,EACL,2BAA2B,EAM5B,MAAM,iBAAiB,CAAA;AAKxB,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,cAAc,CAAC,YAAY,EACtC,YAAY,EAAE,cAAc,CAAC,oBAAoB,CAAC,2BAA2B,CAAC,KAAK,CAAC,EACpF,qBAAqB,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,GACjD,cAAc,CAAC,cAAc,EAAE,CAkFjC;AAED,wBAAgB,gBAAgB,CAAC,CAAC,KAAA,EAAE,CAAC,KAAA,cAWpC"}
1
+ {"version":3,"file":"buy-get.d.ts","sourceRoot":"","sources":["../../../src/utils/compute-actions/buy-get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EACL,2BAA2B,EAK5B,MAAM,iBAAiB,CAAA;AAKxB,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,cAAc,CAAC,YAAY,EACtC,YAAY,EAAE,cAAc,CAAC,oBAAoB,CAAC,2BAA2B,CAAC,KAAK,CAAC,EACpF,qBAAqB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GACzC,cAAc,CAAC,cAAc,EAAE,CA6EjC;AAED,wBAAgB,gBAAgB,CAAC,CAAC,KAAA,EAAE,CAAC,KAAA,cAWpC"}