@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.
- package/dist/index.d.ts +6 -6
- package/dist/index.js +9 -5
- package/dist/initialize/index.d.ts +4 -0
- package/dist/initialize/index.js +17 -0
- package/dist/joiner-config.d.ts +10 -2
- package/dist/joiner-config.js +52 -4
- package/dist/loaders/connection.d.ts +4 -0
- package/dist/loaders/connection.js +40 -0
- package/dist/loaders/container.d.ts +2 -0
- package/dist/loaders/container.js +34 -0
- package/dist/loaders/index.d.ts +2 -0
- package/dist/loaders/index.js +18 -0
- package/dist/migrations/Migration20230929122253.d.ts +0 -1
- package/dist/migrations/Migration20240322094407.d.ts +0 -1
- package/dist/migrations/Migration20240322113359.d.ts +0 -1
- package/dist/migrations/Migration20240322120125.d.ts +0 -1
- package/dist/models/index.d.ts +3 -2
- package/dist/models/index.js +7 -3
- package/dist/models/price-list-rule-value.d.ts +17 -0
- package/dist/models/price-list-rule-value.js +102 -0
- package/dist/models/price-list-rule.d.ts +8 -6
- package/dist/models/price-list-rule.js +29 -8
- package/dist/models/price-list.d.ts +3 -2
- package/dist/models/price-list.js +9 -0
- package/dist/models/price-rule.d.ts +9 -5
- package/dist/models/price-rule.js +45 -6
- package/dist/models/price-set-rule-type.d.ts +10 -0
- package/dist/models/price-set-rule-type.js +108 -0
- package/dist/models/price-set.d.ts +4 -1
- package/dist/models/price-set.js +19 -0
- package/dist/models/price.d.ts +4 -5
- package/dist/models/price.js +5 -5
- package/dist/models/rule-type.d.ts +17 -0
- package/dist/models/{price-preference.js → rule-type.js} +40 -35
- package/dist/module-definition.d.ts +4 -0
- package/dist/module-definition.js +50 -0
- package/dist/repositories/index.d.ts +0 -1
- package/dist/repositories/pricing.d.ts +0 -1
- package/dist/repositories/pricing.js +36 -29
- package/dist/schema/index.d.ts +0 -1
- package/dist/scripts/bin/run-seed.d.ts +3 -0
- package/dist/scripts/bin/run-seed.js +38 -0
- package/dist/scripts/seed.d.ts +4 -0
- package/dist/scripts/seed.js +67 -0
- package/dist/services/index.d.ts +2 -1
- package/dist/services/index.js +5 -1
- package/dist/services/price-list.d.ts +16 -0
- package/dist/services/price-list.js +34 -0
- package/dist/services/pricing-module.d.ts +53 -66
- package/dist/services/pricing-module.js +605 -594
- package/dist/services/rule-type.d.ts +15 -0
- package/dist/services/rule-type.js +53 -0
- package/dist/types/index.d.ts +0 -1
- package/dist/types/services/index.d.ts +2 -30
- package/dist/types/services/index.js +16 -0
- package/dist/types/services/price-list.d.ts +18 -0
- package/dist/types/services/price-list.js +2 -0
- package/dist/types/services/price-set.d.ts +4 -0
- package/dist/types/services/price-set.js +2 -0
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.js +0 -1
- package/dist/utils/validate-price-list-dates.d.ts +0 -1
- package/package.json +13 -8
- package/dist/index.d.ts.map +0 -1
- package/dist/joiner-config.d.ts.map +0 -1
- package/dist/migrations/Migration20230929122253.d.ts.map +0 -1
- package/dist/migrations/Migration20240322094407.d.ts.map +0 -1
- package/dist/migrations/Migration20240322113359.d.ts.map +0 -1
- package/dist/migrations/Migration20240322120125.d.ts.map +0 -1
- package/dist/migrations/Migration20240626133555.d.ts +0 -5
- package/dist/migrations/Migration20240626133555.d.ts.map +0 -1
- package/dist/migrations/Migration20240626133555.js +0 -33
- package/dist/migrations/Migration20240704094505.d.ts +0 -6
- package/dist/migrations/Migration20240704094505.d.ts.map +0 -1
- package/dist/migrations/Migration20240704094505.js +0 -15
- package/dist/models/index.d.ts.map +0 -1
- package/dist/models/price-list-rule.d.ts.map +0 -1
- package/dist/models/price-list.d.ts.map +0 -1
- package/dist/models/price-preference.d.ts +0 -13
- package/dist/models/price-preference.d.ts.map +0 -1
- package/dist/models/price-rule.d.ts.map +0 -1
- package/dist/models/price-set.d.ts.map +0 -1
- package/dist/models/price.d.ts.map +0 -1
- package/dist/repositories/index.d.ts.map +0 -1
- package/dist/repositories/pricing.d.ts.map +0 -1
- package/dist/schema/index.d.ts.map +0 -1
- package/dist/services/index.d.ts.map +0 -1
- package/dist/services/pricing-module.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/services/index.d.ts.map +0 -1
- package/dist/utils/events.d.ts +0 -63
- package/dist/utils/events.d.ts.map +0 -1
- package/dist/utils/events.js +0 -66
- package/dist/utils/index.d.ts.map +0 -1
- 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: "
|
41
|
-
amount: "
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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
|
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
|
-
.
|
59
|
-
.
|
60
|
-
.
|
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
|
-
"
|
69
|
+
"rt.rule_attribute": key,
|
65
70
|
"pr.value": value,
|
66
71
|
});
|
67
72
|
}
|
68
|
-
q.orWhere("
|
69
|
-
q.whereNull("
|
73
|
+
q.orWhere("price1.rules_count", "=", 0);
|
74
|
+
q.whereNull("price1.price_list_id");
|
70
75
|
});
|
71
76
|
priceSubQueryKnex.orWhere((q) => {
|
72
|
-
q.whereNotNull("
|
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
|
-
"
|
88
|
+
"plrt.rule_attribute": key,
|
84
89
|
});
|
85
|
-
this.
|
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
|
-
"
|
98
|
+
"rt.rule_attribute": key,
|
94
99
|
"pr.value": value,
|
95
100
|
});
|
96
101
|
}
|
97
|
-
this.andWhere("
|
102
|
+
this.andWhere("price1.rules_count", ">", 0);
|
98
103
|
});
|
99
|
-
this.orWhere("
|
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);
|
package/dist/schema/index.d.ts
CHANGED
@@ -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,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,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
|
+
}
|
package/dist/services/index.d.ts
CHANGED
package/dist/services/index.js
CHANGED
@@ -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,
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import {
|
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.
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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:
|
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
|
42
|
-
protected readonly
|
43
|
-
protected readonly
|
44
|
-
protected readonly
|
45
|
-
protected readonly
|
46
|
-
protected readonly
|
47
|
-
|
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
|
-
|
51
|
-
|
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
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
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
|
-
|
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
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
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<
|
87
|
-
protected setPriceListRules_(data: PricingTypes.SetPriceListRulesDTO[], sharedContext?: Context): Promise<
|
88
|
-
protected removePriceListRules_(data: PricingTypes.RemovePriceListRulesDTO[], sharedContext?: Context): Promise<
|
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
|