@medusajs/pricing 0.1.13-snapshot-20240531102054 → 0.1.13-snapshot-20240701122250

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. package/dist/index.d.ts +2 -3
  2. package/dist/index.js +7 -4
  3. package/dist/joiner-config.d.ts +1 -8
  4. package/dist/joiner-config.js +10 -52
  5. package/dist/migrations/Migration20240626133555.d.ts +4 -0
  6. package/dist/migrations/Migration20240626133555.js +33 -0
  7. package/dist/models/index.d.ts +0 -3
  8. package/dist/models/index.js +1 -7
  9. package/dist/models/price-list-rule.d.ts +4 -7
  10. package/dist/models/price-list-rule.js +6 -27
  11. package/dist/models/price-list.d.ts +0 -2
  12. package/dist/models/price-list.js +0 -9
  13. package/dist/models/price-rule.d.ts +3 -8
  14. package/dist/models/price-rule.js +4 -43
  15. package/dist/models/price-set.d.ts +0 -4
  16. package/dist/models/price-set.js +0 -19
  17. package/dist/models/price.d.ts +3 -3
  18. package/dist/models/price.js +1 -1
  19. package/dist/repositories/pricing.js +25 -30
  20. package/dist/services/index.d.ts +0 -2
  21. package/dist/services/index.js +1 -5
  22. package/dist/services/pricing-module.d.ts +38 -52
  23. package/dist/services/pricing-module.js +405 -509
  24. package/dist/types/services/price-list.d.ts +9 -9
  25. package/dist/utils/events.d.ts +38 -0
  26. package/dist/utils/events.js +42 -0
  27. package/dist/utils/index.d.ts +1 -0
  28. package/dist/utils/index.js +1 -0
  29. package/package.json +7 -10
  30. package/dist/models/price-list-rule-value.d.ts +0 -17
  31. package/dist/models/price-list-rule-value.js +0 -102
  32. package/dist/models/price-set-rule-type.d.ts +0 -10
  33. package/dist/models/price-set-rule-type.js +0 -108
  34. package/dist/models/rule-type.d.ts +0 -17
  35. package/dist/models/rule-type.js +0 -100
  36. package/dist/module-definition.d.ts +0 -2
  37. package/dist/module-definition.js +0 -8
  38. package/dist/scripts/bin/run-seed.d.ts +0 -3
  39. package/dist/scripts/bin/run-seed.js +0 -38
  40. package/dist/scripts/seed.d.ts +0 -4
  41. package/dist/scripts/seed.js +0 -67
  42. package/dist/services/price-list.d.ts +0 -16
  43. package/dist/services/price-list.js +0 -34
  44. package/dist/services/rule-type.d.ts +0 -15
  45. package/dist/services/rule-type.js +0 -53
@@ -3,10 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.RuleTypeService = exports.PricingModuleService = exports.PriceListService = void 0;
7
- var price_list_1 = require("./price-list");
8
- Object.defineProperty(exports, "PriceListService", { enumerable: true, get: function () { return __importDefault(price_list_1).default; } });
6
+ exports.PricingModuleService = void 0;
9
7
  var pricing_module_1 = require("./pricing-module");
10
8
  Object.defineProperty(exports, "PricingModuleService", { enumerable: true, get: function () { return __importDefault(pricing_module_1).default; } });
11
- var rule_type_1 = require("./rule-type");
12
- Object.defineProperty(exports, "RuleTypeService", { enumerable: true, get: function () { return __importDefault(rule_type_1).default; } });
@@ -1,21 +1,21 @@
1
- import { AddPricesDTO, Context, CreatePriceRuleDTO, DAL, FindConfig, InternalModuleDeclaration, ModuleJoinerConfig, ModulesSdkTypes, PriceSetDTO, PricingContext, PricingFilters, PricingRepositoryService, PricingTypes, RuleTypeDTO, UpsertPriceSetDTO } from "@medusajs/types";
1
+ import { AddPricesDTO, Context, CreatePriceRuleDTO, DAL, FindConfig, InternalModuleDeclaration, ModuleJoinerConfig, ModulesSdkTypes, PriceDTO, PriceSetDTO, PricingContext, PricingFilters, PricingRepositoryService, PricingTypes, UpsertPriceSetDTO } from "@medusajs/types";
2
2
  import { ModulesSdkUtils } from "@medusajs/utils";
3
- import { Price, PriceList, PriceListRule, PriceListRuleValue, PriceRule, PriceSet, PriceSetRuleType, RuleType } from "../models";
4
- import { PriceListService, RuleTypeService } from ".";
5
- import { UpdatePriceSetInput } from "src/types/services";
3
+ import { Price, PriceList, PriceListRule, PriceRule, PriceSet } from "../models";
4
+ import { ServiceTypes } from "../types";
5
+ import { CreatePriceListDTO } from "src/types/services";
6
6
  type InjectedDependencies = {
7
7
  baseRepository: DAL.RepositoryService;
8
8
  pricingRepository: PricingRepositoryService;
9
- priceSetService: ModulesSdkTypes.InternalModuleService<any>;
10
- ruleTypeService: RuleTypeService<any>;
11
- priceRuleService: ModulesSdkTypes.InternalModuleService<any>;
12
- priceSetRuleTypeService: ModulesSdkTypes.InternalModuleService<any>;
13
- priceService: ModulesSdkTypes.InternalModuleService<any>;
14
- priceListService: PriceListService<any>;
15
- priceListRuleService: ModulesSdkTypes.InternalModuleService<any>;
16
- priceListRuleValueService: ModulesSdkTypes.InternalModuleService<any>;
9
+ priceSetService: ModulesSdkTypes.IMedusaInternalService<any>;
10
+ priceRuleService: ModulesSdkTypes.IMedusaInternalService<any>;
11
+ priceService: ModulesSdkTypes.IMedusaInternalService<any>;
12
+ priceListService: ModulesSdkTypes.IMedusaInternalService<any>;
13
+ priceListRuleService: ModulesSdkTypes.IMedusaInternalService<any>;
17
14
  };
18
- declare const PricingModuleService_base: new (container: InjectedDependencies) => ModulesSdkUtils.AbstractModuleService<InjectedDependencies, PriceSetDTO, {
15
+ declare const PricingModuleService_base: new (...args: any[]) => ModulesSdkUtils.AbstractModuleService<{
16
+ PriceSet: {
17
+ dto: PricingTypes.PriceSetDTO;
18
+ };
19
19
  Price: {
20
20
  dto: PricingTypes.PriceDTO;
21
21
  };
@@ -24,11 +24,6 @@ declare const PricingModuleService_base: new (container: InjectedDependencies) =
24
24
  create: PricingTypes.CreatePriceRuleDTO;
25
25
  update: PricingTypes.UpdatePriceRuleDTO;
26
26
  };
27
- RuleType: {
28
- dto: PricingTypes.RuleTypeDTO;
29
- create: PricingTypes.CreateRuleTypeDTO;
30
- update: PricingTypes.UpdateRuleTypeDTO;
31
- };
32
27
  PriceList: {
33
28
  dto: PricingTypes.PriceListDTO;
34
29
  };
@@ -36,56 +31,47 @@ declare const PricingModuleService_base: new (container: InjectedDependencies) =
36
31
  dto: PricingTypes.PriceListRuleDTO;
37
32
  };
38
33
  }>;
39
- export default class PricingModuleService<TPriceSet extends PriceSet = PriceSet, TRuleType extends RuleType = RuleType, TPriceRule extends PriceRule = PriceRule, TPriceSetRuleType extends PriceSetRuleType = PriceSetRuleType, TPrice extends Price = Price, TPriceList extends PriceList = PriceList, TPriceListRule extends PriceListRule = PriceListRule, TPriceListRuleValue extends PriceListRuleValue = PriceListRuleValue> extends PricingModuleService_base implements PricingTypes.IPricingModuleService {
34
+ export default class PricingModuleService extends PricingModuleService_base implements PricingTypes.IPricingModuleService {
40
35
  protected readonly moduleDeclaration: InternalModuleDeclaration;
41
36
  protected baseRepository_: DAL.RepositoryService;
42
37
  protected readonly pricingRepository_: PricingRepositoryService;
43
- protected readonly ruleTypeService_: RuleTypeService<TRuleType>;
44
- protected readonly priceSetService_: ModulesSdkTypes.InternalModuleService<TPriceSet>;
45
- protected readonly priceRuleService_: ModulesSdkTypes.InternalModuleService<TPriceRule>;
46
- protected readonly priceSetRuleTypeService_: ModulesSdkTypes.InternalModuleService<TPriceSetRuleType>;
47
- protected readonly priceService_: ModulesSdkTypes.InternalModuleService<TPrice>;
48
- protected readonly priceListService_: PriceListService<TPriceList>;
49
- protected readonly priceListRuleService_: ModulesSdkTypes.InternalModuleService<TPriceListRule>;
50
- protected readonly priceListRuleValueService_: ModulesSdkTypes.InternalModuleService<TPriceListRuleValue>;
51
- constructor({ baseRepository, pricingRepository, ruleTypeService, priceSetService, priceRuleService, priceSetRuleTypeService, priceService, priceListService, priceListRuleService, priceListRuleValueService, }: InjectedDependencies, moduleDeclaration: InternalModuleDeclaration);
38
+ protected readonly priceSetService_: ModulesSdkTypes.IMedusaInternalService<PriceSet>;
39
+ protected readonly priceRuleService_: ModulesSdkTypes.IMedusaInternalService<PriceRule>;
40
+ protected readonly priceService_: ModulesSdkTypes.IMedusaInternalService<Price>;
41
+ protected readonly priceListService_: ModulesSdkTypes.IMedusaInternalService<PriceList>;
42
+ protected readonly priceListRuleService_: ModulesSdkTypes.IMedusaInternalService<PriceListRule>;
43
+ constructor({ baseRepository, pricingRepository, priceSetService, priceRuleService, priceService, priceListService, priceListRuleService, }: InjectedDependencies, moduleDeclaration: InternalModuleDeclaration);
52
44
  __joinerConfig(): ModuleJoinerConfig;
53
45
  private setupCalculatedPriceConfig_;
54
- list(filters?: PricingTypes.FilterablePriceSetProps, config?: FindConfig<PricingTypes.PriceSetDTO>, sharedContext?: Context): Promise<PriceSetDTO[]>;
55
- listAndCount(filters?: PricingTypes.FilterablePriceSetProps, config?: FindConfig<PricingTypes.PriceSetDTO>, sharedContext?: Context): Promise<[PriceSetDTO[], number]>;
46
+ listPriceSets(filters?: PricingTypes.FilterablePriceSetProps, config?: FindConfig<PricingTypes.PriceSetDTO>, sharedContext?: Context): Promise<PriceSetDTO[]>;
47
+ listAndCountPriceSets(filters?: PricingTypes.FilterablePriceSetProps, config?: FindConfig<PricingTypes.PriceSetDTO>, sharedContext?: Context): Promise<[PriceSetDTO[], number]>;
56
48
  calculatePrices(pricingFilters: PricingFilters, pricingContext?: PricingContext, sharedContext?: Context): Promise<PricingTypes.CalculatedPriceSet[]>;
57
- create(data: PricingTypes.CreatePriceSetDTO, sharedContext?: Context): Promise<PriceSetDTO>;
58
- create(data: PricingTypes.CreatePriceSetDTO[], sharedContext?: Context): Promise<PriceSetDTO[]>;
59
- upsert(data: UpsertPriceSetDTO[], sharedContext?: Context): Promise<PriceSetDTO[]>;
60
- upsert(data: UpsertPriceSetDTO, sharedContext?: Context): Promise<PriceSetDTO>;
61
- update(id: string, data: PricingTypes.UpdatePriceSetDTO, sharedContext?: Context): Promise<PriceSetDTO>;
62
- update(selector: PricingTypes.FilterablePriceSetProps, data: PricingTypes.UpdatePriceSetDTO, sharedContext?: Context): Promise<PriceSetDTO[]>;
49
+ createPriceSets(data: PricingTypes.CreatePriceSetDTO, sharedContext?: Context): Promise<PriceSetDTO>;
50
+ createPriceSets(data: PricingTypes.CreatePriceSetDTO[], sharedContext?: Context): Promise<PriceSetDTO[]>;
51
+ upsertPriceSets(data: UpsertPriceSetDTO[], sharedContext?: Context): Promise<PriceSetDTO[]>;
52
+ upsertPriceSets(data: UpsertPriceSetDTO, sharedContext?: Context): Promise<PriceSetDTO>;
53
+ updatePriceSets(id: string, data: PricingTypes.UpdatePriceSetDTO, sharedContext?: Context): Promise<PriceSetDTO>;
54
+ updatePriceSets(selector: PricingTypes.FilterablePriceSetProps, data: PricingTypes.UpdatePriceSetDTO, sharedContext?: Context): Promise<PriceSetDTO[]>;
63
55
  private normalizeUpdateData;
64
- protected update_(data: UpdatePriceSetInput[], sharedContext?: Context): Promise<PriceSet[]>;
65
- addRules(data: PricingTypes.AddRulesDTO, sharedContext?: Context): Promise<PricingTypes.PriceSetDTO>;
66
- addRules(data: PricingTypes.AddRulesDTO[], sharedContext?: Context): Promise<PricingTypes.PriceSetDTO[]>;
56
+ protected updatePriceSets_(data: ServiceTypes.UpdatePriceSetInput[], sharedContext?: Context): Promise<PriceSet[]>;
67
57
  addPrices(data: AddPricesDTO, sharedContext?: Context): Promise<PricingTypes.PriceSetDTO>;
68
58
  addPrices(data: AddPricesDTO[], sharedContext?: Context): Promise<PricingTypes.PriceSetDTO[]>;
69
- removeRules(data: PricingTypes.RemovePriceSetRulesDTO[], sharedContext?: Context): Promise<void>;
70
59
  createPriceLists(data: PricingTypes.CreatePriceListDTO[], sharedContext?: Context): Promise<PricingTypes.PriceListDTO[]>;
71
60
  updatePriceLists(data: PricingTypes.UpdatePriceListDTO[], sharedContext?: Context): Promise<PricingTypes.PriceListDTO[]>;
72
- createPriceListRules(data: PricingTypes.CreatePriceListRuleDTO[], sharedContext?: Context): Promise<PricingTypes.PriceListRuleDTO[]>;
73
- createPriceListRules_(data: PricingTypes.CreatePriceListRuleDTO[], sharedContext?: Context): Promise<TPriceListRule[]>;
74
- updatePriceListRules(data: PricingTypes.UpdatePriceListRuleDTO[], sharedContext?: Context): Promise<PricingTypes.PriceListRuleDTO[]>;
75
61
  updatePriceListPrices(data: PricingTypes.UpdatePriceListPricesDTO[], sharedContext?: Context): Promise<PricingTypes.PriceDTO[]>;
76
62
  removePrices(ids: string[], sharedContext?: Context): Promise<void>;
77
63
  addPriceListPrices(data: PricingTypes.AddPriceListPricesDTO[], sharedContext?: Context): Promise<PricingTypes.PriceDTO[]>;
78
64
  setPriceListRules(data: PricingTypes.SetPriceListRulesDTO, sharedContext?: Context): Promise<PricingTypes.PriceListDTO>;
79
65
  removePriceListRules(data: PricingTypes.RemovePriceListRulesDTO, sharedContext?: Context): Promise<PricingTypes.PriceListDTO>;
80
- protected create_(data: PricingTypes.CreatePriceSetDTO[], sharedContext?: Context): Promise<TPriceSet[]>;
81
- protected addRules_(inputs: PricingTypes.AddRulesDTO[], sharedContext?: Context): Promise<TPriceSet[]>;
82
- protected addPrices_(input: AddPricesDTO[], sharedContext?: Context): Promise<void>;
83
- protected createPriceLists_(data: PricingTypes.CreatePriceListDTO[], sharedContext?: Context): Promise<TPriceList[]>;
84
- protected updatePriceLists_(data: PricingTypes.UpdatePriceListDTO[], sharedContext?: Context): Promise<PricingTypes.PriceListDTO[]>;
85
- protected updatePriceListPrices_(data: PricingTypes.UpdatePriceListPricesDTO[], sharedContext?: Context): Promise<TPrice[]>;
66
+ protected createPriceSets_(data: PricingTypes.CreatePriceSetDTO[], sharedContext?: Context): Promise<PriceSet[]>;
67
+ protected addPrices_(input: AddPricesDTO[], sharedContext?: Context): Promise<Price[]>;
68
+ protected createPriceLists_(data: PricingTypes.CreatePriceListDTO[], sharedContext?: Context): Promise<PriceList[]>;
69
+ protected updatePriceLists_(data: PricingTypes.UpdatePriceListDTO[], sharedContext?: Context): Promise<PriceList[]>;
70
+ protected updatePriceListPrices_(data: PricingTypes.UpdatePriceListPricesDTO[], sharedContext?: Context): Promise<Price[]>;
86
71
  protected removePrices_(ids: string[], sharedContext?: Context): Promise<void>;
87
- protected addPriceListPrices_(data: PricingTypes.AddPriceListPricesDTO[], sharedContext?: Context): Promise<TPrice[]>;
88
- protected setPriceListRules_(data: PricingTypes.SetPriceListRulesDTO[], sharedContext?: Context): Promise<TPriceList[]>;
89
- protected removePriceListRules_(data: PricingTypes.RemovePriceListRulesDTO[], sharedContext?: Context): Promise<TPriceList[]>;
72
+ protected addPriceListPrices_(data: PricingTypes.AddPriceListPricesDTO[], sharedContext?: Context): Promise<Price[]>;
73
+ protected setPriceListRules_(data: PricingTypes.SetPriceListRulesDTO[], sharedContext?: Context): Promise<PriceList[]>;
74
+ protected removePriceListRules_(data: PricingTypes.RemovePriceListRulesDTO[], sharedContext?: Context): Promise<PriceList[]>;
75
+ protected normalizePriceListDate(data: (ServiceTypes.UpdatePriceListDTO | ServiceTypes.CreatePriceListDTO | CreatePriceListDTO)[]): any[];
90
76
  }
91
77
  export {};