@medusajs/pricing 0.1.13-snapshot-20240718073308 → 0.1.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. package/dist/index.d.ts +6 -6
  2. package/dist/index.js +9 -5
  3. package/dist/initialize/index.d.ts +4 -0
  4. package/dist/initialize/index.js +17 -0
  5. package/dist/joiner-config.d.ts +10 -2
  6. package/dist/joiner-config.js +52 -4
  7. package/dist/loaders/connection.d.ts +4 -0
  8. package/dist/loaders/connection.js +40 -0
  9. package/dist/loaders/container.d.ts +2 -0
  10. package/dist/loaders/container.js +34 -0
  11. package/dist/loaders/index.d.ts +2 -0
  12. package/dist/loaders/index.js +18 -0
  13. package/dist/migrations/Migration20230929122253.d.ts +0 -1
  14. package/dist/migrations/Migration20240322094407.d.ts +0 -1
  15. package/dist/migrations/Migration20240322113359.d.ts +0 -1
  16. package/dist/migrations/Migration20240322120125.d.ts +0 -1
  17. package/dist/models/index.d.ts +3 -2
  18. package/dist/models/index.js +7 -3
  19. package/dist/models/price-list-rule-value.d.ts +17 -0
  20. package/dist/models/price-list-rule-value.js +102 -0
  21. package/dist/models/price-list-rule.d.ts +8 -6
  22. package/dist/models/price-list-rule.js +29 -8
  23. package/dist/models/price-list.d.ts +3 -2
  24. package/dist/models/price-list.js +9 -0
  25. package/dist/models/price-rule.d.ts +9 -5
  26. package/dist/models/price-rule.js +45 -6
  27. package/dist/models/price-set-rule-type.d.ts +10 -0
  28. package/dist/models/price-set-rule-type.js +108 -0
  29. package/dist/models/price-set.d.ts +4 -1
  30. package/dist/models/price-set.js +19 -0
  31. package/dist/models/price.d.ts +4 -5
  32. package/dist/models/price.js +5 -5
  33. package/dist/models/rule-type.d.ts +17 -0
  34. package/dist/models/{price-preference.js → rule-type.js} +40 -35
  35. package/dist/module-definition.d.ts +4 -0
  36. package/dist/module-definition.js +50 -0
  37. package/dist/repositories/index.d.ts +0 -1
  38. package/dist/repositories/pricing.d.ts +0 -1
  39. package/dist/repositories/pricing.js +36 -29
  40. package/dist/schema/index.d.ts +0 -1
  41. package/dist/scripts/bin/run-seed.d.ts +3 -0
  42. package/dist/scripts/bin/run-seed.js +38 -0
  43. package/dist/scripts/seed.d.ts +4 -0
  44. package/dist/scripts/seed.js +67 -0
  45. package/dist/services/index.d.ts +2 -1
  46. package/dist/services/index.js +5 -1
  47. package/dist/services/price-list.d.ts +16 -0
  48. package/dist/services/price-list.js +34 -0
  49. package/dist/services/pricing-module.d.ts +53 -66
  50. package/dist/services/pricing-module.js +605 -594
  51. package/dist/services/rule-type.d.ts +15 -0
  52. package/dist/services/rule-type.js +53 -0
  53. package/dist/types/index.d.ts +0 -1
  54. package/dist/types/services/index.d.ts +2 -30
  55. package/dist/types/services/index.js +16 -0
  56. package/dist/types/services/price-list.d.ts +18 -0
  57. package/dist/types/services/price-list.js +2 -0
  58. package/dist/types/services/price-set.d.ts +4 -0
  59. package/dist/types/services/price-set.js +2 -0
  60. package/dist/utils/index.d.ts +0 -2
  61. package/dist/utils/index.js +0 -1
  62. package/dist/utils/validate-price-list-dates.d.ts +0 -1
  63. package/package.json +13 -8
  64. package/dist/index.d.ts.map +0 -1
  65. package/dist/joiner-config.d.ts.map +0 -1
  66. package/dist/migrations/Migration20230929122253.d.ts.map +0 -1
  67. package/dist/migrations/Migration20240322094407.d.ts.map +0 -1
  68. package/dist/migrations/Migration20240322113359.d.ts.map +0 -1
  69. package/dist/migrations/Migration20240322120125.d.ts.map +0 -1
  70. package/dist/migrations/Migration20240626133555.d.ts +0 -5
  71. package/dist/migrations/Migration20240626133555.d.ts.map +0 -1
  72. package/dist/migrations/Migration20240626133555.js +0 -33
  73. package/dist/migrations/Migration20240704094505.d.ts +0 -6
  74. package/dist/migrations/Migration20240704094505.d.ts.map +0 -1
  75. package/dist/migrations/Migration20240704094505.js +0 -15
  76. package/dist/models/index.d.ts.map +0 -1
  77. package/dist/models/price-list-rule.d.ts.map +0 -1
  78. package/dist/models/price-list.d.ts.map +0 -1
  79. package/dist/models/price-preference.d.ts +0 -13
  80. package/dist/models/price-preference.d.ts.map +0 -1
  81. package/dist/models/price-rule.d.ts.map +0 -1
  82. package/dist/models/price-set.d.ts.map +0 -1
  83. package/dist/models/price.d.ts.map +0 -1
  84. package/dist/repositories/index.d.ts.map +0 -1
  85. package/dist/repositories/pricing.d.ts.map +0 -1
  86. package/dist/schema/index.d.ts.map +0 -1
  87. package/dist/services/index.d.ts.map +0 -1
  88. package/dist/services/pricing-module.d.ts.map +0 -1
  89. package/dist/types/index.d.ts.map +0 -1
  90. package/dist/types/services/index.d.ts.map +0 -1
  91. package/dist/utils/events.d.ts +0 -63
  92. package/dist/utils/events.d.ts.map +0 -1
  93. package/dist/utils/events.js +0 -66
  94. package/dist/utils/index.d.ts.map +0 -1
  95. package/dist/utils/validate-price-list-dates.d.ts.map +0 -1
@@ -37,39 +37,44 @@ class PricingRepository extends utils_1.MikroOrmBase {
37
37
  price: "price",
38
38
  })
39
39
  .select({
40
- id: "price.id",
41
- amount: "price.amount",
42
- raw_amount: "price.raw_amount",
43
- min_quantity: "price.min_quantity",
44
- max_quantity: "price.max_quantity",
45
- currency_code: "price.currency_code",
46
- price_set_id: "price.price_set_id",
47
- rules_count: "price.rules_count",
48
- price_list_id: "price.price_list_id",
40
+ id: "price1.id",
41
+ amount: "price1.amount",
42
+ min_quantity: "price1.min_quantity",
43
+ max_quantity: "price1.max_quantity",
44
+ currency_code: "price1.currency_code",
45
+ price_set_id: "price1.price_set_id",
46
+ rules_count: "price1.rules_count",
47
+ price_list_id: "price1.price_list_id",
49
48
  pl_rules_count: "pl.rules_count",
50
49
  pl_type: "pl.type",
51
- has_price_list: knex.raw("case when price.price_list_id IS NULL then False else True end"),
52
- })
53
- .leftJoin("price_rule as pr", "pr.price_id", "price.id")
54
- .leftJoin("price_list as pl", function () {
55
- this.on("pl.id", "price.price_list_id").andOn("pl.status", knex.raw("?", [utils_1.PriceListStatus.ACTIVE]));
50
+ has_price_list: knex.raw("case when price1.price_list_id IS NULL then False else True end"),
56
51
  })
52
+ .leftJoin("price as price1", "price1.id", "price1.id")
53
+ .leftJoin("price_rule as pr", "pr.price_id", "price1.id")
54
+ .leftJoin("price_list as pl", "pl.id", "price1.price_list_id")
57
55
  .leftJoin("price_list_rule as plr", "plr.price_list_id", "pl.id")
58
- .groupBy("price.id", "pl.id")
59
- .having(knex.raw("count(DISTINCT pr.attribute) = price.rules_count AND price.price_list_id IS NULL"))
60
- .orHaving(knex.raw("count(DISTINCT plr.attribute) = pl.rules_count AND price.price_list_id IS NOT NULL"));
56
+ .leftJoin("price_list_rule_value as plrv", "plrv.price_list_rule_id", "plr.id")
57
+ .leftJoin("rule_type as plrt", "plrt.id", "plr.rule_type_id")
58
+ .leftJoin("rule_type as rt", "rt.id", "pr.rule_type_id")
59
+ .orderBy([
60
+ { column: "rules_count", order: "desc" },
61
+ { column: "pl.rules_count", order: "desc" },
62
+ ])
63
+ .groupBy("price1.id", "pl.id")
64
+ .having(knex.raw("count(DISTINCT rt.rule_attribute) = price1.rules_count AND price1.price_list_id IS NULL"))
65
+ .orHaving(knex.raw("count(DISTINCT plrt.rule_attribute) = pl.rules_count AND price1.price_list_id IS NOT NULL"));
61
66
  priceSubQueryKnex.orWhere((q) => {
62
67
  for (const [key, value] of Object.entries(context)) {
63
68
  q.orWhere({
64
- "pr.attribute": key,
69
+ "rt.rule_attribute": key,
65
70
  "pr.value": value,
66
71
  });
67
72
  }
68
- q.orWhere("price.rules_count", "=", 0);
69
- q.whereNull("price.price_list_id");
73
+ q.orWhere("price1.rules_count", "=", 0);
74
+ q.whereNull("price1.price_list_id");
70
75
  });
71
76
  priceSubQueryKnex.orWhere((q) => {
72
- q.whereNotNull("price.price_list_id")
77
+ q.whereNotNull("price1.price_list_id")
73
78
  .andWhere(function () {
74
79
  this.whereNull("pl.starts_at").orWhere("pl.starts_at", "<=", date);
75
80
  })
@@ -80,9 +85,9 @@ class PricingRepository extends utils_1.MikroOrmBase {
80
85
  this.andWhere(function () {
81
86
  for (const [key, value] of Object.entries(context)) {
82
87
  this.orWhere({
83
- "plr.attribute": key,
88
+ "plrt.rule_attribute": key,
84
89
  });
85
- this.where("plr.value", "@>", JSON.stringify(Array.isArray(value) ? value : [value]));
90
+ this.whereIn("plrv.value", [value]);
86
91
  }
87
92
  this.orWhere("pl.rules_count", "=", 0);
88
93
  });
@@ -90,13 +95,13 @@ class PricingRepository extends utils_1.MikroOrmBase {
90
95
  this.andWhere(function () {
91
96
  for (const [key, value] of Object.entries(context)) {
92
97
  this.orWhere({
93
- "pr.attribute": key,
98
+ "rt.rule_attribute": key,
94
99
  "pr.value": value,
95
100
  });
96
101
  }
97
- this.andWhere("price.rules_count", ">", 0);
102
+ this.andWhere("price1.rules_count", ">", 0);
98
103
  });
99
- this.orWhere("price.rules_count", "=", 0);
104
+ this.orWhere("price1.rules_count", "=", 0);
100
105
  });
101
106
  });
102
107
  });
@@ -107,23 +112,25 @@ class PricingRepository extends utils_1.MikroOrmBase {
107
112
  id: "price.id",
108
113
  price_set_id: "ps.id",
109
114
  amount: "price.amount",
110
- raw_amount: "price.raw_amount",
111
115
  min_quantity: "price.min_quantity",
112
116
  max_quantity: "price.max_quantity",
113
117
  currency_code: "price.currency_code",
118
+ default_priority: "rt.default_priority",
114
119
  rules_count: "price.rules_count",
115
120
  pl_rules_count: "price.pl_rules_count",
116
121
  price_list_type: "price.pl_type",
117
122
  price_list_id: "price.price_list_id",
118
- all_rules_count: knex.raw("COALESCE(price.rules_count, 0) + COALESCE(price.pl_rules_count, 0)"),
119
123
  })
120
124
  .join(priceSubQueryKnex.as("price"), "price.price_set_id", "ps.id")
125
+ .leftJoin("price_rule as pr", "pr.price_id", "price.id")
126
+ .leftJoin("rule_type as rt", "rt.id", "pr.rule_type_id")
121
127
  .whereIn("ps.id", pricingFilters.id)
122
128
  .andWhere("price.currency_code", "=", currencyCode)
123
129
  .orderBy([
124
130
  { column: "price.has_price_list", order: "asc" },
125
- { column: "all_rules_count", order: "desc" },
126
131
  { column: "amount", order: "asc" },
132
+ { column: "rules_count", order: "desc" },
133
+ { column: "default_priority", order: "desc" },
127
134
  ]);
128
135
  if (quantity) {
129
136
  priceSetQueryKnex.where("price.min_quantity", "<=", quantity);
@@ -1,3 +1,2 @@
1
1
  export declare const schema = "\ntype PriceSet {\n id: String!\n money_amounts: [MoneyAmount]\n}\n\ntype MoneyAmount {\n id: String!\n currency_code: String\n amount: Float\n min_quantity: Float\n max_quantity: Float\n}\n";
2
2
  export default schema;
3
- //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ declare const _default: Promise<void>;
3
+ export default _default;
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || function (mod) {
20
+ if (mod && mod.__esModule) return mod;
21
+ var result = {};
22
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
+ __setModuleDefault(result, mod);
24
+ return result;
25
+ };
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ const os_1 = require("os");
28
+ const seed_1 = require("../seed");
29
+ const args = process.argv;
30
+ const path = args.pop();
31
+ exports.default = (async () => {
32
+ const { config } = await Promise.resolve().then(() => __importStar(require("dotenv")));
33
+ config();
34
+ if (!path) {
35
+ throw new Error(`filePath is required.${os_1.EOL}Example: medusa-pricing-seed <filePath>`);
36
+ }
37
+ await (0, seed_1.run)({ path });
38
+ })();
@@ -0,0 +1,4 @@
1
+ import { LoaderOptions, ModulesSdkTypes } from "@medusajs/types";
2
+ export declare function run({ options, logger, path, }: Partial<Pick<LoaderOptions<ModulesSdkTypes.ModuleServiceInitializeOptions>, "options" | "logger">> & {
3
+ path: string;
4
+ }): Promise<void>;
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.run = void 0;
27
+ const utils_1 = require("@medusajs/utils");
28
+ const PricingModels = __importStar(require("../models"));
29
+ const os_1 = require("os");
30
+ const path_1 = require("path");
31
+ async function run({ options, logger, path, }) {
32
+ logger ?? (logger = console);
33
+ logger.info(`Loading seed data from ${path}...`);
34
+ const { priceSetsData, pricesData } = await Promise.resolve(`${(0, path_1.resolve)(process.cwd(), path)}`).then(s => __importStar(require(s))).catch((e) => {
35
+ logger?.error(`Failed to load seed data from ${path}. Please, provide a relative path and check that you export the following: priceSetsData and pricesData.${os_1.EOL}${e}`);
36
+ throw e;
37
+ });
38
+ const dbData = utils_1.ModulesSdkUtils.loadDatabaseConfig("pricing", options);
39
+ const entities = Object.values(PricingModels);
40
+ const pathToMigrations = __dirname + "/../migrations";
41
+ const orm = await utils_1.DALUtils.mikroOrmCreateConnection(dbData, entities, pathToMigrations);
42
+ const manager = orm.em.fork();
43
+ try {
44
+ logger.info("Inserting price_sets & prices");
45
+ await createPriceSets(manager, priceSetsData);
46
+ await createPrices(manager, pricesData);
47
+ }
48
+ catch (e) {
49
+ logger.error(`Failed to insert the seed data in the PostgreSQL database ${dbData.clientUrl}.${os_1.EOL}${e}`);
50
+ }
51
+ await orm.close(true);
52
+ }
53
+ exports.run = run;
54
+ async function createPriceSets(manager, data) {
55
+ const priceSets = data.map((priceSetData) => {
56
+ return manager.create(PricingModels.PriceSet, priceSetData);
57
+ });
58
+ await manager.persistAndFlush(priceSets);
59
+ return priceSets;
60
+ }
61
+ async function createPrices(manager, data) {
62
+ const prices = data.map((priceData) => {
63
+ return manager.create(PricingModels.Price, priceData);
64
+ });
65
+ await manager.persistAndFlush(prices);
66
+ return prices;
67
+ }
@@ -1,2 +1,3 @@
1
+ export { default as PriceListService } from "./price-list";
1
2
  export { default as PricingModuleService } from "./pricing-module";
2
- //# sourceMappingURL=index.d.ts.map
3
+ export { default as RuleTypeService } from "./rule-type";
@@ -3,6 +3,10 @@ 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.PricingModuleService = void 0;
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; } });
7
9
  var pricing_module_1 = require("./pricing-module");
8
10
  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; } });
@@ -0,0 +1,16 @@
1
+ import { Context, DAL } from "@medusajs/types";
2
+ import { PriceList } from "../models";
3
+ import { ServiceTypes } from "../types";
4
+ type InjectedDependencies = {
5
+ priceListRepository: DAL.RepositoryService;
6
+ };
7
+ declare const PriceListService_base: new <TEntity_1 extends object = any>(container: InjectedDependencies) => import("@medusajs/types").InternalModuleService<TEntity_1, InjectedDependencies>;
8
+ export default class PriceListService<TEntity extends PriceList = PriceList> extends PriceListService_base<TEntity> {
9
+ constructor(container: InjectedDependencies);
10
+ create(data: ServiceTypes.CreatePriceListDTO[], sharedContext?: Context): Promise<TEntity[]>;
11
+ create(data: ServiceTypes.CreatePriceListDTO, sharedContext?: Context): Promise<TEntity>;
12
+ update(data: any[], sharedContext?: Context): Promise<TEntity[]>;
13
+ update(data: any, sharedContext?: Context): Promise<TEntity>;
14
+ protected normalizePriceListDate(data: (ServiceTypes.UpdatePriceListDTO | ServiceTypes.CreatePriceListDTO)[]): any[];
15
+ }
16
+ export {};
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("@medusajs/utils");
4
+ const _models_1 = require("../models");
5
+ class PriceListService extends utils_1.ModulesSdkUtils.internalModuleServiceFactory(_models_1.PriceList) {
6
+ constructor(container) {
7
+ // @ts-ignore
8
+ super(...arguments);
9
+ }
10
+ async create(data, sharedContext) {
11
+ const data_ = Array.isArray(data) ? data : [data];
12
+ const priceLists = this.normalizePriceListDate(data_);
13
+ return await super.create(priceLists, sharedContext);
14
+ }
15
+ // TODO: Add support for selector? and then rm ts ignore
16
+ // @ts-ignore
17
+ async update(data, sharedContext) {
18
+ const data_ = Array.isArray(data) ? data : [data];
19
+ const priceLists = this.normalizePriceListDate(data_);
20
+ return await super.update(priceLists, sharedContext);
21
+ }
22
+ normalizePriceListDate(data) {
23
+ return data.map((priceListData) => {
24
+ if (!!priceListData.starts_at) {
25
+ priceListData.starts_at = (0, utils_1.GetIsoStringFromDate)(priceListData.starts_at);
26
+ }
27
+ if (!!priceListData.ends_at) {
28
+ priceListData.ends_at = (0, utils_1.GetIsoStringFromDate)(priceListData.ends_at);
29
+ }
30
+ return priceListData;
31
+ });
32
+ }
33
+ }
34
+ exports.default = PriceListService;
@@ -1,21 +1,21 @@
1
- import { AddPricesDTO, Context, CreatePriceRuleDTO, DAL, FindConfig, InternalModuleDeclaration, ModuleJoinerConfig, ModulesSdkTypes, PricePreferenceDTO, PriceSetDTO, PricingContext, PricingFilters, PricingRepositoryService, PricingTypes, UpsertPricePreferenceDTO, UpsertPriceSetDTO } from "@medusajs/types";
2
- import { Price, PriceList, PriceListRule, PricePreference, PriceRule, PriceSet } from "../models";
3
- import { ServiceTypes } from "../types";
4
- import { CreatePriceListDTO } from "src/types/services";
1
+ import { AddPricesDTO, Context, CreatePriceRuleDTO, DAL, FindConfig, InternalModuleDeclaration, ModuleJoinerConfig, ModulesSdkTypes, PriceSetDTO, PricingContext, PricingFilters, PricingRepositoryService, PricingTypes, RuleTypeDTO, UpsertPriceSetDTO } from "@medusajs/types";
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";
5
6
  type InjectedDependencies = {
6
7
  baseRepository: DAL.RepositoryService;
7
8
  pricingRepository: PricingRepositoryService;
8
- priceSetService: ModulesSdkTypes.IMedusaInternalService<any>;
9
- priceRuleService: ModulesSdkTypes.IMedusaInternalService<any>;
10
- priceService: ModulesSdkTypes.IMedusaInternalService<any>;
11
- priceListService: ModulesSdkTypes.IMedusaInternalService<any>;
12
- pricePreferenceService: ModulesSdkTypes.IMedusaInternalService<any>;
13
- priceListRuleService: ModulesSdkTypes.IMedusaInternalService<any>;
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>;
14
17
  };
15
- declare const PricingModuleService_base: import("@medusajs/utils/dist/modules-sdk/types/medusa-service").MedusaServiceReturnType<{
16
- PriceSet: {
17
- dto: PricingTypes.PriceSetDTO;
18
- };
18
+ declare const PricingModuleService_base: new (container: InjectedDependencies) => ModulesSdkUtils.AbstractModuleService<InjectedDependencies, PriceSetDTO, {
19
19
  Price: {
20
20
  dto: PricingTypes.PriceDTO;
21
21
  };
@@ -24,81 +24,68 @@ declare const PricingModuleService_base: import("@medusajs/utils/dist/modules-sd
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
+ };
27
32
  PriceList: {
28
33
  dto: PricingTypes.PriceListDTO;
29
34
  };
30
35
  PriceListRule: {
31
36
  dto: PricingTypes.PriceListRuleDTO;
32
37
  };
33
- PricePreference: {
34
- dto: any;
35
- };
36
38
  }>;
37
- export default class PricingModuleService extends PricingModuleService_base implements PricingTypes.IPricingModuleService {
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 {
38
40
  protected readonly moduleDeclaration: InternalModuleDeclaration;
39
41
  protected baseRepository_: DAL.RepositoryService;
40
42
  protected readonly pricingRepository_: PricingRepositoryService;
41
- protected readonly priceSetService_: ModulesSdkTypes.IMedusaInternalService<PriceSet>;
42
- protected readonly priceRuleService_: ModulesSdkTypes.IMedusaInternalService<PriceRule>;
43
- protected readonly priceService_: ModulesSdkTypes.IMedusaInternalService<Price>;
44
- protected readonly priceListService_: ModulesSdkTypes.IMedusaInternalService<PriceList>;
45
- protected readonly priceListRuleService_: ModulesSdkTypes.IMedusaInternalService<PriceListRule>;
46
- protected readonly pricePreferenceService_: ModulesSdkTypes.IMedusaInternalService<PricePreference>;
47
- constructor({ baseRepository, pricingRepository, priceSetService, priceRuleService, priceService, pricePreferenceService, priceListService, priceListRuleService, }: InjectedDependencies, moduleDeclaration: InternalModuleDeclaration);
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);
48
52
  __joinerConfig(): ModuleJoinerConfig;
49
53
  private setupCalculatedPriceConfig_;
50
- retrievePriceSet(id: string, config?: FindConfig<PriceSetDTO> | undefined, sharedContext?: Context | undefined): Promise<PriceSetDTO>;
51
- listPriceSets(filters?: PricingTypes.FilterablePriceSetProps, config?: FindConfig<PricingTypes.PriceSetDTO>, sharedContext?: Context): Promise<PriceSetDTO[]>;
52
- listAndCountPriceSets(filters?: PricingTypes.FilterablePriceSetProps, config?: FindConfig<PricingTypes.PriceSetDTO>, sharedContext?: Context): Promise<[PriceSetDTO[], number]>;
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]>;
53
56
  calculatePrices(pricingFilters: PricingFilters, pricingContext?: PricingContext, sharedContext?: Context): Promise<PricingTypes.CalculatedPriceSet[]>;
54
- createPriceSets(data: PricingTypes.CreatePriceSetDTO, sharedContext?: Context): Promise<PriceSetDTO>;
55
- createPriceSets(data: PricingTypes.CreatePriceSetDTO[], sharedContext?: Context): Promise<PriceSetDTO[]>;
56
- upsertPriceSets(data: UpsertPriceSetDTO[], sharedContext?: Context): Promise<PriceSetDTO[]>;
57
- upsertPriceSets(data: UpsertPriceSetDTO, sharedContext?: Context): Promise<PriceSetDTO>;
58
- updatePriceSets(id: string, data: PricingTypes.UpdatePriceSetDTO, sharedContext?: Context): Promise<PriceSetDTO>;
59
- updatePriceSets(selector: PricingTypes.FilterablePriceSetProps, data: PricingTypes.UpdatePriceSetDTO, sharedContext?: Context): Promise<PriceSetDTO[]>;
60
- protected updatePriceSets_(data: ServiceTypes.UpdatePriceSetInput[], sharedContext?: Context): Promise<PriceSet[]>;
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[]>;
61
63
  private normalizeUpdateData;
62
- private normalizePrices;
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[]>;
63
67
  addPrices(data: AddPricesDTO, sharedContext?: Context): Promise<PricingTypes.PriceSetDTO>;
64
68
  addPrices(data: AddPricesDTO[], sharedContext?: Context): Promise<PricingTypes.PriceSetDTO[]>;
69
+ removeRules(data: PricingTypes.RemovePriceSetRulesDTO[], sharedContext?: Context): Promise<void>;
65
70
  createPriceLists(data: PricingTypes.CreatePriceListDTO[], sharedContext?: Context): Promise<PricingTypes.PriceListDTO[]>;
66
71
  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[]>;
67
75
  updatePriceListPrices(data: PricingTypes.UpdatePriceListPricesDTO[], sharedContext?: Context): Promise<PricingTypes.PriceDTO[]>;
68
76
  removePrices(ids: string[], sharedContext?: Context): Promise<void>;
69
77
  addPriceListPrices(data: PricingTypes.AddPriceListPricesDTO[], sharedContext?: Context): Promise<PricingTypes.PriceDTO[]>;
70
78
  setPriceListRules(data: PricingTypes.SetPriceListRulesDTO, sharedContext?: Context): Promise<PricingTypes.PriceListDTO>;
71
79
  removePriceListRules(data: PricingTypes.RemovePriceListRulesDTO, sharedContext?: Context): Promise<PricingTypes.PriceListDTO>;
72
- createPricePreferences(data: PricingTypes.CreatePricePreferenceDTO, sharedContext?: Context): Promise<PricePreferenceDTO>;
73
- createPricePreferences(data: PricingTypes.CreatePricePreferenceDTO[], sharedContext?: Context): Promise<PricePreferenceDTO[]>;
74
- upsertPricePreferences(data: UpsertPricePreferenceDTO[], sharedContext?: Context): Promise<PricePreferenceDTO[]>;
75
- upsertPricePreferences(data: UpsertPricePreferenceDTO, sharedContext?: Context): Promise<PricePreferenceDTO>;
76
- updatePricePreferences(id: string, data: PricingTypes.UpdatePricePreferenceDTO, sharedContext?: Context): Promise<PricePreferenceDTO>;
77
- updatePricePreferences(selector: PricingTypes.FilterablePricePreferenceProps, data: PricingTypes.UpdatePricePreferenceDTO, sharedContext?: Context): Promise<PricePreferenceDTO[]>;
78
- protected createPricePreferences_(data: PricingTypes.CreatePricePreferenceDTO[], sharedContext?: Context): Promise<PricePreference[]>;
79
- protected updatePricePreferences_(data: PricingTypes.UpdatePricePreferenceDTO[], sharedContext?: Context): Promise<PricePreference[]>;
80
- protected createPriceSets_(data: PricingTypes.CreatePriceSetDTO[], sharedContext?: Context): Promise<PriceSet[]>;
81
- protected addPrices_(input: AddPricesDTO[], sharedContext?: Context): Promise<Price[]>;
82
- protected createPriceLists_(data: PricingTypes.CreatePriceListDTO[], sharedContext?: Context): Promise<PriceList[]>;
83
- protected updatePriceLists_(data: PricingTypes.UpdatePriceListDTO[], sharedContext?: Context): Promise<PriceList[]>;
84
- protected updatePriceListPrices_(data: PricingTypes.UpdatePriceListPricesDTO[], sharedContext?: Context): Promise<Price[]>;
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[]>;
85
86
  protected removePrices_(ids: string[], sharedContext?: Context): Promise<void>;
86
- protected addPriceListPrices_(data: PricingTypes.AddPriceListPricesDTO[], sharedContext?: Context): Promise<Price[]>;
87
- protected setPriceListRules_(data: PricingTypes.SetPriceListRulesDTO[], sharedContext?: Context): Promise<PriceList[]>;
88
- protected removePriceListRules_(data: PricingTypes.RemovePriceListRulesDTO[], sharedContext?: Context): Promise<PriceList[]>;
89
- protected normalizePriceListDate(data: (ServiceTypes.UpdatePriceListDTO | ServiceTypes.CreatePriceListDTO | CreatePriceListDTO)[]): any[];
90
- protected normalizePriceSetConfig(config: FindConfig<PricingTypes.PriceSetDTO> | undefined): {
91
- select?: string[] | undefined;
92
- skip?: number | null | undefined;
93
- take?: number | null | undefined;
94
- relations?: string[] | undefined;
95
- order?: {
96
- [K: string]: "ASC" | "DESC";
97
- } | undefined;
98
- withDeleted?: boolean | undefined;
99
- filters?: Record<string, any> | undefined;
100
- options: Record<string, any>;
101
- };
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[]>;
102
90
  }
103
91
  export {};
104
- //# sourceMappingURL=pricing-module.d.ts.map