@medusajs/pricing 0.1.13-snapshot-20240607093839 → 0.1.13-snapshot-20240703074611

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) 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 +50 -48
  23. package/dist/services/pricing-module.js +293 -482
  24. package/dist/types/services/price-list.d.ts +9 -9
  25. package/dist/utils/events.d.ts +0 -6
  26. package/dist/utils/events.js +6 -12
  27. package/package.json +7 -10
  28. package/dist/models/price-list-rule-value.d.ts +0 -17
  29. package/dist/models/price-list-rule-value.js +0 -102
  30. package/dist/models/price-set-rule-type.d.ts +0 -10
  31. package/dist/models/price-set-rule-type.js +0 -108
  32. package/dist/models/rule-type.d.ts +0 -17
  33. package/dist/models/rule-type.js +0 -100
  34. package/dist/module-definition.d.ts +0 -2
  35. package/dist/module-definition.js +0 -8
  36. package/dist/scripts/bin/run-seed.d.ts +0 -3
  37. package/dist/scripts/bin/run-seed.js +0 -38
  38. package/dist/scripts/seed.d.ts +0 -4
  39. package/dist/scripts/seed.js +0 -67
  40. package/dist/services/price-list.d.ts +0 -16
  41. package/dist/services/price-list.js +0 -34
  42. package/dist/services/rule-type.d.ts +0 -15
  43. 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 ".";
3
+ import { Price, PriceList, PriceListRule, PriceRule, PriceSet } from "../models";
5
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,37 +31,32 @@ 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
+ retrievePriceSet(id: string, config?: FindConfig<PriceSetDTO> | undefined, sharedContext?: Context | undefined): Promise<PriceSetDTO>;
47
+ listPriceSets(filters?: PricingTypes.FilterablePriceSetProps, config?: FindConfig<PricingTypes.PriceSetDTO>, sharedContext?: Context): Promise<PriceSetDTO[]>;
48
+ listAndCountPriceSets(filters?: PricingTypes.FilterablePriceSetProps, config?: FindConfig<PricingTypes.PriceSetDTO>, sharedContext?: Context): Promise<[PriceSetDTO[], number]>;
56
49
  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[]>;
50
+ createPriceSets(data: PricingTypes.CreatePriceSetDTO, sharedContext?: Context): Promise<PriceSetDTO>;
51
+ createPriceSets(data: PricingTypes.CreatePriceSetDTO[], sharedContext?: Context): Promise<PriceSetDTO[]>;
52
+ upsertPriceSets(data: UpsertPriceSetDTO[], sharedContext?: Context): Promise<PriceSetDTO[]>;
53
+ upsertPriceSets(data: UpsertPriceSetDTO, sharedContext?: Context): Promise<PriceSetDTO>;
54
+ updatePriceSets(id: string, data: PricingTypes.UpdatePriceSetDTO, sharedContext?: Context): Promise<PriceSetDTO>;
55
+ updatePriceSets(selector: PricingTypes.FilterablePriceSetProps, data: PricingTypes.UpdatePriceSetDTO, sharedContext?: Context): Promise<PriceSetDTO[]>;
63
56
  private normalizeUpdateData;
64
- protected update_(data: ServiceTypes.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[]>;
57
+ protected updatePriceSets_(data: ServiceTypes.UpdatePriceSetInput[], sharedContext?: Context): Promise<PriceSet[]>;
67
58
  addPrices(data: AddPricesDTO, sharedContext?: Context): Promise<PricingTypes.PriceSetDTO>;
68
59
  addPrices(data: AddPricesDTO[], sharedContext?: Context): Promise<PricingTypes.PriceSetDTO[]>;
69
- removeRules(data: PricingTypes.RemovePriceSetRulesDTO[], sharedContext?: Context): Promise<void>;
70
60
  createPriceLists(data: PricingTypes.CreatePriceListDTO[], sharedContext?: Context): Promise<PricingTypes.PriceListDTO[]>;
71
61
  updatePriceLists(data: PricingTypes.UpdatePriceListDTO[], sharedContext?: Context): Promise<PricingTypes.PriceListDTO[]>;
72
62
  updatePriceListPrices(data: PricingTypes.UpdatePriceListPricesDTO[], sharedContext?: Context): Promise<PricingTypes.PriceDTO[]>;
@@ -74,15 +64,27 @@ export default class PricingModuleService<TPriceSet extends PriceSet = PriceSet,
74
64
  addPriceListPrices(data: PricingTypes.AddPriceListPricesDTO[], sharedContext?: Context): Promise<PricingTypes.PriceDTO[]>;
75
65
  setPriceListRules(data: PricingTypes.SetPriceListRulesDTO, sharedContext?: Context): Promise<PricingTypes.PriceListDTO>;
76
66
  removePriceListRules(data: PricingTypes.RemovePriceListRulesDTO, sharedContext?: Context): Promise<PricingTypes.PriceListDTO>;
77
- protected create_(data: PricingTypes.CreatePriceSetDTO[], sharedContext?: Context): Promise<TPriceSet[]>;
78
- protected addRules_(inputs: PricingTypes.AddRulesDTO[], sharedContext?: Context): Promise<TPriceSet[]>;
79
- protected addPrices_(input: AddPricesDTO[], sharedContext?: Context): Promise<TPrice[]>;
80
- protected createPriceLists_(data: PricingTypes.CreatePriceListDTO[], sharedContext?: Context): Promise<TPriceList[]>;
81
- protected updatePriceLists_(data: PricingTypes.UpdatePriceListDTO[], sharedContext?: Context): Promise<PricingTypes.PriceListDTO[]>;
82
- protected updatePriceListPrices_(data: PricingTypes.UpdatePriceListPricesDTO[], sharedContext?: Context): Promise<TPrice[]>;
67
+ protected createPriceSets_(data: PricingTypes.CreatePriceSetDTO[], sharedContext?: Context): Promise<PriceSet[]>;
68
+ protected addPrices_(input: AddPricesDTO[], sharedContext?: Context): Promise<Price[]>;
69
+ protected createPriceLists_(data: PricingTypes.CreatePriceListDTO[], sharedContext?: Context): Promise<PriceList[]>;
70
+ protected updatePriceLists_(data: PricingTypes.UpdatePriceListDTO[], sharedContext?: Context): Promise<PriceList[]>;
71
+ protected updatePriceListPrices_(data: PricingTypes.UpdatePriceListPricesDTO[], sharedContext?: Context): Promise<Price[]>;
83
72
  protected removePrices_(ids: string[], sharedContext?: Context): Promise<void>;
84
- protected addPriceListPrices_(data: PricingTypes.AddPriceListPricesDTO[], sharedContext?: Context): Promise<TPrice[]>;
85
- protected setPriceListRules_(data: PricingTypes.SetPriceListRulesDTO[], sharedContext?: Context): Promise<TPriceList[]>;
86
- protected removePriceListRules_(data: PricingTypes.RemovePriceListRulesDTO[], sharedContext?: Context): Promise<TPriceList[]>;
73
+ protected addPriceListPrices_(data: PricingTypes.AddPriceListPricesDTO[], sharedContext?: Context): Promise<Price[]>;
74
+ protected setPriceListRules_(data: PricingTypes.SetPriceListRulesDTO[], sharedContext?: Context): Promise<PriceList[]>;
75
+ protected removePriceListRules_(data: PricingTypes.RemovePriceListRulesDTO[], sharedContext?: Context): Promise<PriceList[]>;
76
+ protected normalizePriceListDate(data: (ServiceTypes.UpdatePriceListDTO | ServiceTypes.CreatePriceListDTO | CreatePriceListDTO)[]): any[];
77
+ protected normalizePriceSetConfig(config: FindConfig<PricingTypes.PriceSetDTO> | undefined): {
78
+ select?: string[] | undefined;
79
+ skip?: number | null | undefined;
80
+ take?: number | null | undefined;
81
+ relations?: string[] | undefined;
82
+ order?: {
83
+ [K: string]: "ASC" | "DESC";
84
+ } | undefined;
85
+ withDeleted?: boolean | undefined;
86
+ filters?: Record<string, any> | undefined;
87
+ options: Record<string, any>;
88
+ };
87
89
  }
88
90
  export {};