@medusajs/pricing 0.0.3 → 0.0.4-next-20230929123725
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/loaders/container.d.ts +1 -1
- package/dist/loaders/container.js +4 -0
- package/dist/migrations/{Migration20230913123118.d.ts → Migration20230928154931.d.ts} +1 -1
- package/dist/migrations/Migration20230928154931.js +33 -0
- package/dist/models/index.d.ts +2 -0
- package/dist/models/index.js +5 -1
- package/dist/models/price-rule.d.ts +19 -0
- package/dist/models/price-rule.js +83 -0
- package/dist/models/price-set-money-amount-rules.d.ts +9 -0
- package/dist/models/price-set-money-amount-rules.js +53 -0
- package/dist/models/price-set-money-amount.d.ts +6 -1
- package/dist/models/price-set-money-amount.js +22 -0
- package/dist/models/price-set.d.ts +6 -1
- package/dist/models/price-set.js +15 -0
- package/dist/repositories/index.d.ts +2 -0
- package/dist/repositories/index.js +5 -1
- package/dist/repositories/price-rule.d.ts +15 -0
- package/dist/repositories/price-rule.js +76 -0
- package/dist/repositories/price-set-money-amount-rules.d.ts +15 -0
- package/dist/repositories/price-set-money-amount-rules.js +69 -0
- package/dist/scripts/bin/run-migration-down.js +0 -0
- package/dist/scripts/bin/run-migration-up.js +0 -0
- package/dist/scripts/bin/run-seed.js +0 -0
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.js +5 -1
- package/dist/services/money-amount.d.ts +0 -1
- package/dist/services/money-amount.js +3 -8
- package/dist/services/price-rule.d.ts +16 -0
- package/dist/services/price-rule.js +91 -0
- package/dist/services/price-set-money-amount-rules.d.ts +17 -0
- package/dist/services/price-set-money-amount-rules.js +96 -0
- package/dist/services/price-set.d.ts +0 -1
- package/dist/services/price-set.js +3 -8
- package/dist/services/pricing-module.d.ts +21 -5
- package/dist/services/pricing-module.js +230 -26
- package/dist/services/rule-type.d.ts +0 -1
- package/dist/services/rule-type.js +3 -8
- package/package.json +4 -4
- package/dist/migrations/Migration20230913123118.js +0 -21
|
@@ -30,17 +30,12 @@ class MoneyAmountService {
|
|
|
30
30
|
}));
|
|
31
31
|
}
|
|
32
32
|
async list(filters = {}, config = {}, sharedContext = {}) {
|
|
33
|
-
|
|
33
|
+
const queryOptions = utils_1.ModulesSdkUtils.buildQuery(filters, config);
|
|
34
|
+
return (await this.moneyAmountRepository_.find(queryOptions, sharedContext));
|
|
34
35
|
}
|
|
35
36
|
async listAndCount(filters = {}, config = {}, sharedContext = {}) {
|
|
36
|
-
return (await this.moneyAmountRepository_.findAndCount(this.buildQueryForList(filters, config), sharedContext));
|
|
37
|
-
}
|
|
38
|
-
buildQueryForList(filters = {}, config = {}) {
|
|
39
37
|
const queryOptions = utils_1.ModulesSdkUtils.buildQuery(filters, config);
|
|
40
|
-
|
|
41
|
-
queryOptions.where["id"] = { $in: filters.id };
|
|
42
|
-
}
|
|
43
|
-
return queryOptions;
|
|
38
|
+
return (await this.moneyAmountRepository_.findAndCount(queryOptions, sharedContext));
|
|
44
39
|
}
|
|
45
40
|
async create(data, sharedContext = {}) {
|
|
46
41
|
return (await this.moneyAmountRepository_.create(data, sharedContext));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Context, DAL, FindConfig, PricingTypes } from "@medusajs/types";
|
|
2
|
+
import { PriceRule } from "../models";
|
|
3
|
+
type InjectedDependencies = {
|
|
4
|
+
priceRuleRepository: DAL.RepositoryService;
|
|
5
|
+
};
|
|
6
|
+
export default class PriceRuleService<TEntity extends PriceRule = PriceRule> {
|
|
7
|
+
protected readonly priceRuleRepository_: DAL.RepositoryService;
|
|
8
|
+
constructor({ priceRuleRepository }: InjectedDependencies);
|
|
9
|
+
retrieve(priceRuleId: string, config?: FindConfig<PricingTypes.PriceRuleDTO>, sharedContext?: Context): Promise<TEntity>;
|
|
10
|
+
list(filters?: PricingTypes.FilterablePriceRuleProps, config?: FindConfig<PricingTypes.PriceRuleDTO>, sharedContext?: Context): Promise<TEntity[]>;
|
|
11
|
+
listAndCount(filters?: PricingTypes.FilterablePriceRuleProps, config?: FindConfig<PricingTypes.PriceRuleDTO>, sharedContext?: Context): Promise<[TEntity[], number]>;
|
|
12
|
+
create(data: PricingTypes.CreatePriceRuleDTO[], sharedContext?: Context): Promise<TEntity[]>;
|
|
13
|
+
update(data: PricingTypes.UpdatePriceRuleDTO[], sharedContext?: Context): Promise<TEntity[]>;
|
|
14
|
+
delete(ids: string[], sharedContext?: Context): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const types_1 = require("@medusajs/types");
|
|
16
|
+
const utils_1 = require("@medusajs/utils");
|
|
17
|
+
const _models_1 = require("../models");
|
|
18
|
+
class PriceRuleService {
|
|
19
|
+
constructor({ priceRuleRepository }) {
|
|
20
|
+
this.priceRuleRepository_ = priceRuleRepository;
|
|
21
|
+
}
|
|
22
|
+
async retrieve(priceRuleId, config = {}, sharedContext = {}) {
|
|
23
|
+
return (await (0, utils_1.retrieveEntity)({
|
|
24
|
+
id: priceRuleId,
|
|
25
|
+
entityName: _models_1.PriceRule.name,
|
|
26
|
+
repository: this.priceRuleRepository_,
|
|
27
|
+
config,
|
|
28
|
+
sharedContext,
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
async list(filters = {}, config = {}, sharedContext = {}) {
|
|
32
|
+
const queryConfig = utils_1.ModulesSdkUtils.buildQuery(filters, config);
|
|
33
|
+
return (await this.priceRuleRepository_.find(queryConfig, sharedContext));
|
|
34
|
+
}
|
|
35
|
+
async listAndCount(filters = {}, config = {}, sharedContext = {}) {
|
|
36
|
+
const queryConfig = utils_1.ModulesSdkUtils.buildQuery(filters, config);
|
|
37
|
+
return (await this.priceRuleRepository_.findAndCount(queryConfig, sharedContext));
|
|
38
|
+
}
|
|
39
|
+
async create(data, sharedContext = {}) {
|
|
40
|
+
return (await this.priceRuleRepository_.create(data, sharedContext));
|
|
41
|
+
}
|
|
42
|
+
async update(data, sharedContext = {}) {
|
|
43
|
+
return (await this.priceRuleRepository_.update(data, sharedContext));
|
|
44
|
+
}
|
|
45
|
+
async delete(ids, sharedContext = {}) {
|
|
46
|
+
await this.priceRuleRepository_.delete(ids, sharedContext);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.default = PriceRuleService;
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, utils_1.InjectManager)("priceRuleRepository_"),
|
|
52
|
+
__param(2, (0, utils_1.MedusaContext)()),
|
|
53
|
+
__metadata("design:type", Function),
|
|
54
|
+
__metadata("design:paramtypes", [String, Object, Object]),
|
|
55
|
+
__metadata("design:returntype", Promise)
|
|
56
|
+
], PriceRuleService.prototype, "retrieve", null);
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, utils_1.InjectManager)("priceRuleRepository_"),
|
|
59
|
+
__param(2, (0, utils_1.MedusaContext)()),
|
|
60
|
+
__metadata("design:type", Function),
|
|
61
|
+
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
62
|
+
__metadata("design:returntype", Promise)
|
|
63
|
+
], PriceRuleService.prototype, "list", null);
|
|
64
|
+
__decorate([
|
|
65
|
+
(0, utils_1.InjectManager)("priceRuleRepository_"),
|
|
66
|
+
__param(2, (0, utils_1.MedusaContext)()),
|
|
67
|
+
__metadata("design:type", Function),
|
|
68
|
+
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
69
|
+
__metadata("design:returntype", Promise)
|
|
70
|
+
], PriceRuleService.prototype, "listAndCount", null);
|
|
71
|
+
__decorate([
|
|
72
|
+
(0, utils_1.InjectTransactionManager)(utils_1.shouldForceTransaction, "priceRuleRepository_"),
|
|
73
|
+
__param(1, (0, utils_1.MedusaContext)()),
|
|
74
|
+
__metadata("design:type", Function),
|
|
75
|
+
__metadata("design:paramtypes", [Array, Object]),
|
|
76
|
+
__metadata("design:returntype", Promise)
|
|
77
|
+
], PriceRuleService.prototype, "create", null);
|
|
78
|
+
__decorate([
|
|
79
|
+
(0, utils_1.InjectTransactionManager)(utils_1.shouldForceTransaction, "priceRuleRepository_"),
|
|
80
|
+
__param(1, (0, utils_1.MedusaContext)()),
|
|
81
|
+
__metadata("design:type", Function),
|
|
82
|
+
__metadata("design:paramtypes", [Array, Object]),
|
|
83
|
+
__metadata("design:returntype", Promise)
|
|
84
|
+
], PriceRuleService.prototype, "update", null);
|
|
85
|
+
__decorate([
|
|
86
|
+
(0, utils_1.InjectTransactionManager)(utils_1.doNotForceTransaction, "priceRuleRepository_"),
|
|
87
|
+
__param(1, (0, utils_1.MedusaContext)()),
|
|
88
|
+
__metadata("design:type", Function),
|
|
89
|
+
__metadata("design:paramtypes", [Array, Object]),
|
|
90
|
+
__metadata("design:returntype", Promise)
|
|
91
|
+
], PriceRuleService.prototype, "delete", null);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Context, DAL, FindConfig, PricingTypes } from "@medusajs/types";
|
|
2
|
+
import { PriceSetMoneyAmountRules } from "../models";
|
|
3
|
+
type InjectedDependencies = {
|
|
4
|
+
priceSetMoneyAmountRulesRepository: DAL.RepositoryService;
|
|
5
|
+
};
|
|
6
|
+
export default class PriceSetMoneyAmountRulesService<TEntity extends PriceSetMoneyAmountRules = PriceSetMoneyAmountRules> {
|
|
7
|
+
protected readonly priceSetMoneyAmountRulesRepository_: DAL.RepositoryService;
|
|
8
|
+
constructor({ priceSetMoneyAmountRulesRepository }: InjectedDependencies);
|
|
9
|
+
retrieve(priceSetMoneyAmountRulesId: string, config?: FindConfig<PricingTypes.PriceSetMoneyAmountRulesDTO>, sharedContext?: Context): Promise<TEntity>;
|
|
10
|
+
list(filters?: PricingTypes.FilterablePriceSetMoneyAmountRulesProps, config?: FindConfig<PricingTypes.PriceSetMoneyAmountRulesDTO>, sharedContext?: Context): Promise<TEntity[]>;
|
|
11
|
+
listAndCount(filters?: PricingTypes.FilterablePriceSetMoneyAmountRulesProps, config?: FindConfig<PricingTypes.PriceSetMoneyAmountRulesDTO>, sharedContext?: Context): Promise<[TEntity[], number]>;
|
|
12
|
+
private buildQueryForList;
|
|
13
|
+
create(data: PricingTypes.CreatePriceSetMoneyAmountRulesDTO[], sharedContext?: Context): Promise<TEntity[]>;
|
|
14
|
+
update(data: PricingTypes.UpdatePriceSetMoneyAmountRulesDTO[], sharedContext?: Context): Promise<TEntity[]>;
|
|
15
|
+
delete(ids: string[], sharedContext?: Context): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const types_1 = require("@medusajs/types");
|
|
16
|
+
const utils_1 = require("@medusajs/utils");
|
|
17
|
+
const _models_1 = require("../models");
|
|
18
|
+
const utils_2 = require("@medusajs/utils");
|
|
19
|
+
class PriceSetMoneyAmountRulesService {
|
|
20
|
+
constructor({ priceSetMoneyAmountRulesRepository }) {
|
|
21
|
+
this.priceSetMoneyAmountRulesRepository_ =
|
|
22
|
+
priceSetMoneyAmountRulesRepository;
|
|
23
|
+
}
|
|
24
|
+
async retrieve(priceSetMoneyAmountRulesId, config = {}, sharedContext = {}) {
|
|
25
|
+
return (await (0, utils_1.retrieveEntity)({
|
|
26
|
+
id: priceSetMoneyAmountRulesId,
|
|
27
|
+
identifierColumn: "id",
|
|
28
|
+
entityName: _models_1.PriceSetMoneyAmountRules.name,
|
|
29
|
+
repository: this.priceSetMoneyAmountRulesRepository_,
|
|
30
|
+
config,
|
|
31
|
+
sharedContext,
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
async list(filters = {}, config = {}, sharedContext = {}) {
|
|
35
|
+
return (await this.priceSetMoneyAmountRulesRepository_.find(this.buildQueryForList(filters, config), sharedContext));
|
|
36
|
+
}
|
|
37
|
+
async listAndCount(filters = {}, config = {}, sharedContext = {}) {
|
|
38
|
+
return (await this.priceSetMoneyAmountRulesRepository_.findAndCount(this.buildQueryForList(filters, config), sharedContext));
|
|
39
|
+
}
|
|
40
|
+
buildQueryForList(filters = {}, config = {}) {
|
|
41
|
+
const queryOptions = utils_1.ModulesSdkUtils.buildQuery(filters, config);
|
|
42
|
+
return queryOptions;
|
|
43
|
+
}
|
|
44
|
+
async create(data, sharedContext = {}) {
|
|
45
|
+
return (await this.priceSetMoneyAmountRulesRepository_.create(data, sharedContext));
|
|
46
|
+
}
|
|
47
|
+
async update(data, sharedContext = {}) {
|
|
48
|
+
return (await this.priceSetMoneyAmountRulesRepository_.update(data, sharedContext));
|
|
49
|
+
}
|
|
50
|
+
async delete(ids, sharedContext = {}) {
|
|
51
|
+
await this.priceSetMoneyAmountRulesRepository_.delete(ids, sharedContext);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.default = PriceSetMoneyAmountRulesService;
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, utils_1.InjectManager)("priceSetMoneyAmountRulesRepository_"),
|
|
57
|
+
__param(2, (0, utils_1.MedusaContext)()),
|
|
58
|
+
__metadata("design:type", Function),
|
|
59
|
+
__metadata("design:paramtypes", [String, Object, Object]),
|
|
60
|
+
__metadata("design:returntype", Promise)
|
|
61
|
+
], PriceSetMoneyAmountRulesService.prototype, "retrieve", null);
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, utils_1.InjectManager)("priceSetMoneyAmountRulesRepository_"),
|
|
64
|
+
__param(2, (0, utils_1.MedusaContext)()),
|
|
65
|
+
__metadata("design:type", Function),
|
|
66
|
+
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
67
|
+
__metadata("design:returntype", Promise)
|
|
68
|
+
], PriceSetMoneyAmountRulesService.prototype, "list", null);
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, utils_1.InjectManager)("priceSetMoneyAmountRulesRepository_"),
|
|
71
|
+
__param(2, (0, utils_1.MedusaContext)()),
|
|
72
|
+
__metadata("design:type", Function),
|
|
73
|
+
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
74
|
+
__metadata("design:returntype", Promise)
|
|
75
|
+
], PriceSetMoneyAmountRulesService.prototype, "listAndCount", null);
|
|
76
|
+
__decorate([
|
|
77
|
+
(0, utils_1.InjectTransactionManager)(utils_2.shouldForceTransaction, "priceSetMoneyAmountRulesRepository_"),
|
|
78
|
+
__param(1, (0, utils_1.MedusaContext)()),
|
|
79
|
+
__metadata("design:type", Function),
|
|
80
|
+
__metadata("design:paramtypes", [Array, Object]),
|
|
81
|
+
__metadata("design:returntype", Promise)
|
|
82
|
+
], PriceSetMoneyAmountRulesService.prototype, "create", null);
|
|
83
|
+
__decorate([
|
|
84
|
+
(0, utils_1.InjectTransactionManager)(utils_2.shouldForceTransaction, "priceSetMoneyAmountRulesRepository_"),
|
|
85
|
+
__param(1, (0, utils_1.MedusaContext)()),
|
|
86
|
+
__metadata("design:type", Function),
|
|
87
|
+
__metadata("design:paramtypes", [Array, Object]),
|
|
88
|
+
__metadata("design:returntype", Promise)
|
|
89
|
+
], PriceSetMoneyAmountRulesService.prototype, "update", null);
|
|
90
|
+
__decorate([
|
|
91
|
+
(0, utils_1.InjectTransactionManager)(utils_2.doNotForceTransaction, "priceSetMoneyAmountRulesRepository_"),
|
|
92
|
+
__param(1, (0, utils_1.MedusaContext)()),
|
|
93
|
+
__metadata("design:type", Function),
|
|
94
|
+
__metadata("design:paramtypes", [Array, Object]),
|
|
95
|
+
__metadata("design:returntype", Promise)
|
|
96
|
+
], PriceSetMoneyAmountRulesService.prototype, "delete", null);
|
|
@@ -9,7 +9,6 @@ export default class PriceSetService<TEntity extends PriceSet = PriceSet> {
|
|
|
9
9
|
retrieve(priceSetId: string, config?: FindConfig<PricingTypes.PriceSetDTO>, sharedContext?: Context): Promise<TEntity>;
|
|
10
10
|
list(filters?: PricingTypes.FilterablePriceSetProps, config?: FindConfig<PricingTypes.PriceSetDTO>, sharedContext?: Context): Promise<TEntity[]>;
|
|
11
11
|
listAndCount(filters?: PricingTypes.FilterablePriceSetProps, config?: FindConfig<PricingTypes.PriceSetDTO>, sharedContext?: Context): Promise<[TEntity[], number]>;
|
|
12
|
-
private buildQueryForList;
|
|
13
12
|
create(data: PricingTypes.CreatePriceSetDTO[], sharedContext?: Context): Promise<TEntity[]>;
|
|
14
13
|
update(data: PricingTypes.UpdatePriceSetDTO[], sharedContext?: Context): Promise<TEntity[]>;
|
|
15
14
|
delete(ids: string[], sharedContext?: Context): Promise<void>;
|
|
@@ -29,17 +29,12 @@ class PriceSetService {
|
|
|
29
29
|
}));
|
|
30
30
|
}
|
|
31
31
|
async list(filters = {}, config = {}, sharedContext = {}) {
|
|
32
|
-
|
|
32
|
+
const queryOptions = utils_1.ModulesSdkUtils.buildQuery(filters, config);
|
|
33
|
+
return (await this.priceSetRepository_.find(queryOptions, sharedContext));
|
|
33
34
|
}
|
|
34
35
|
async listAndCount(filters = {}, config = {}, sharedContext = {}) {
|
|
35
|
-
return (await this.priceSetRepository_.findAndCount(this.buildQueryForList(filters, config), sharedContext));
|
|
36
|
-
}
|
|
37
|
-
buildQueryForList(filters = {}, config = {}) {
|
|
38
36
|
const queryOptions = utils_1.ModulesSdkUtils.buildQuery(filters, config);
|
|
39
|
-
|
|
40
|
-
queryOptions.where.id = { $in: filters.id };
|
|
41
|
-
}
|
|
42
|
-
return queryOptions;
|
|
37
|
+
return (await this.priceSetRepository_.findAndCount(queryOptions, sharedContext));
|
|
43
38
|
}
|
|
44
39
|
async create(data, sharedContext = {}) {
|
|
45
40
|
return (await this.priceSetRepository_.create(data, sharedContext));
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import { Context, DAL, FindConfig, InternalModuleDeclaration, ModuleJoinerConfig, PricingContext, PricingFilters, PricingTypes } from "@medusajs/types";
|
|
2
|
-
import { Currency, MoneyAmount, PriceSet, RuleType } from "../models";
|
|
3
|
-
import { CurrencyService, MoneyAmountService, PriceSetService, RuleTypeService } from ".";
|
|
2
|
+
import { Currency, MoneyAmount, PriceRule, PriceSet, PriceSetMoneyAmountRules, RuleType } from "../models";
|
|
3
|
+
import { CurrencyService, MoneyAmountService, PriceRuleService, PriceSetMoneyAmountRulesService, PriceSetService, RuleTypeService } from ".";
|
|
4
4
|
type InjectedDependencies = {
|
|
5
5
|
baseRepository: DAL.RepositoryService;
|
|
6
6
|
currencyService: CurrencyService<any>;
|
|
7
7
|
moneyAmountService: MoneyAmountService<any>;
|
|
8
|
-
ruleTypeService: RuleTypeService<any>;
|
|
9
8
|
priceSetService: PriceSetService<any>;
|
|
9
|
+
priceSetMoneyAmountRulesService: PriceSetMoneyAmountRulesService<any>;
|
|
10
|
+
ruleTypeService: RuleTypeService<any>;
|
|
11
|
+
priceRuleService: PriceRuleService<any>;
|
|
10
12
|
};
|
|
11
|
-
export default class PricingModuleService<TPriceSet extends PriceSet = PriceSet, TMoneyAmount extends MoneyAmount = MoneyAmount, TCurrency extends Currency = Currency, TRuleType extends RuleType = RuleType> implements PricingTypes.IPricingModuleService {
|
|
13
|
+
export default class PricingModuleService<TPriceSet extends PriceSet = PriceSet, TMoneyAmount extends MoneyAmount = MoneyAmount, TCurrency extends Currency = Currency, TRuleType extends RuleType = RuleType, TPriceSetMoneyAmountRules extends PriceSetMoneyAmountRules = PriceSetMoneyAmountRules, TPriceRule extends PriceRule = PriceRule> implements PricingTypes.IPricingModuleService {
|
|
12
14
|
protected readonly moduleDeclaration: InternalModuleDeclaration;
|
|
13
15
|
protected baseRepository_: DAL.RepositoryService;
|
|
14
16
|
protected readonly currencyService_: CurrencyService<TCurrency>;
|
|
15
17
|
protected readonly moneyAmountService_: MoneyAmountService<TMoneyAmount>;
|
|
16
18
|
protected readonly ruleTypeService_: RuleTypeService<TRuleType>;
|
|
17
19
|
protected readonly priceSetService_: PriceSetService<TPriceSet>;
|
|
18
|
-
|
|
20
|
+
protected readonly priceSetMoneyAmountRulesService_: PriceSetMoneyAmountRulesService<TPriceSetMoneyAmountRules>;
|
|
21
|
+
protected readonly priceRuleService_: PriceRuleService<TPriceRule>;
|
|
22
|
+
constructor({ baseRepository, moneyAmountService, currencyService, ruleTypeService, priceSetService, priceSetMoneyAmountRulesService, priceRuleService, }: InjectedDependencies, moduleDeclaration: InternalModuleDeclaration);
|
|
19
23
|
__joinerConfig(): ModuleJoinerConfig;
|
|
20
24
|
calculatePrices(pricingFilters: PricingFilters, pricingContext?: PricingContext, sharedContext?: Context): Promise<PricingTypes.CalculatedPriceSetDTO>;
|
|
21
25
|
retrieve(id: string, config?: FindConfig<PricingTypes.PriceSetDTO>, sharedContext?: Context): Promise<PricingTypes.PriceSetDTO>;
|
|
@@ -42,5 +46,17 @@ export default class PricingModuleService<TPriceSet extends PriceSet = PriceSet,
|
|
|
42
46
|
createRuleTypes(data: PricingTypes.CreateRuleTypeDTO[], sharedContext?: Context): Promise<PricingTypes.RuleTypeDTO[]>;
|
|
43
47
|
updateRuleTypes(data: PricingTypes.UpdateRuleTypeDTO[], sharedContext?: Context): Promise<PricingTypes.RuleTypeDTO[]>;
|
|
44
48
|
deleteRuleTypes(ruleTypes: string[], sharedContext?: Context): Promise<void>;
|
|
49
|
+
retrievePriceSetMoneyAmountRules(id: string, config?: FindConfig<PricingTypes.PriceSetMoneyAmountRulesDTO>, sharedContext?: Context): Promise<PricingTypes.PriceSetMoneyAmountRulesDTO>;
|
|
50
|
+
listPriceSetMoneyAmountRules(filters?: PricingTypes.FilterablePriceSetMoneyAmountRulesProps, config?: FindConfig<PricingTypes.PriceSetMoneyAmountRulesDTO>, sharedContext?: Context): Promise<PricingTypes.PriceSetMoneyAmountRulesDTO[]>;
|
|
51
|
+
listAndCountPriceSetMoneyAmountRules(filters?: PricingTypes.FilterablePriceSetMoneyAmountRulesProps, config?: FindConfig<PricingTypes.PriceSetMoneyAmountRulesDTO>, sharedContext?: Context): Promise<[PricingTypes.PriceSetMoneyAmountRulesDTO[], number]>;
|
|
52
|
+
createPriceSetMoneyAmountRules(data: PricingTypes.CreatePriceSetMoneyAmountRulesDTO[], sharedContext?: Context): Promise<PricingTypes.PriceSetMoneyAmountRulesDTO[]>;
|
|
53
|
+
updatePriceSetMoneyAmountRules(data: PricingTypes.UpdatePriceSetMoneyAmountRulesDTO[], sharedContext?: Context): Promise<PricingTypes.PriceSetMoneyAmountRulesDTO[]>;
|
|
54
|
+
deletePriceSetMoneyAmountRules(ids: string[], sharedContext?: Context): Promise<void>;
|
|
55
|
+
retrievePriceRule(id: string, config?: FindConfig<PricingTypes.PriceRuleDTO>, sharedContext?: Context): Promise<PricingTypes.PriceRuleDTO>;
|
|
56
|
+
listPriceRules(filters?: PricingTypes.FilterablePriceRuleProps, config?: FindConfig<PricingTypes.PriceRuleDTO>, sharedContext?: Context): Promise<PricingTypes.PriceRuleDTO[]>;
|
|
57
|
+
listAndCountPriceRules(filters?: PricingTypes.FilterablePriceRuleProps, config?: FindConfig<PricingTypes.PriceRuleDTO>, sharedContext?: Context): Promise<[PricingTypes.PriceRuleDTO[], number]>;
|
|
58
|
+
createPriceRules(data: PricingTypes.CreatePriceRuleDTO[], sharedContext?: Context): Promise<PricingTypes.PriceRuleDTO[]>;
|
|
59
|
+
updatePriceRules(data: PricingTypes.UpdatePriceRuleDTO[], sharedContext?: Context): Promise<PricingTypes.PriceRuleDTO[]>;
|
|
60
|
+
deletePriceRules(priceRuleIds: string[], sharedContext?: Context): Promise<void>;
|
|
45
61
|
}
|
|
46
62
|
export {};
|
|
@@ -16,47 +16,95 @@ const types_1 = require("@medusajs/types");
|
|
|
16
16
|
const utils_1 = require("@medusajs/utils");
|
|
17
17
|
const joiner_config_1 = require("../joiner-config");
|
|
18
18
|
class PricingModuleService {
|
|
19
|
-
constructor({ baseRepository, moneyAmountService, currencyService, ruleTypeService, priceSetService, }, moduleDeclaration) {
|
|
19
|
+
constructor({ baseRepository, moneyAmountService, currencyService, ruleTypeService, priceSetService, priceSetMoneyAmountRulesService, priceRuleService, }, moduleDeclaration) {
|
|
20
20
|
this.moduleDeclaration = moduleDeclaration;
|
|
21
21
|
this.baseRepository_ = baseRepository;
|
|
22
22
|
this.currencyService_ = currencyService;
|
|
23
23
|
this.moneyAmountService_ = moneyAmountService;
|
|
24
24
|
this.ruleTypeService_ = ruleTypeService;
|
|
25
25
|
this.priceSetService_ = priceSetService;
|
|
26
|
+
this.priceSetMoneyAmountRulesService_ = priceSetMoneyAmountRulesService;
|
|
27
|
+
this.ruleTypeService_ = ruleTypeService;
|
|
28
|
+
this.priceRuleService_ = priceRuleService;
|
|
26
29
|
}
|
|
27
30
|
__joinerConfig() {
|
|
28
31
|
return joiner_config_1.joinerConfig;
|
|
29
32
|
}
|
|
30
33
|
async calculatePrices(pricingFilters, pricingContext = { context: {} }, sharedContext = {}) {
|
|
34
|
+
const manager = sharedContext.manager;
|
|
35
|
+
const knex = manager.getKnex();
|
|
31
36
|
// Keeping this whole logic raw in here for now as they will undergo
|
|
32
37
|
// some changes, will abstract them out once we have a final version
|
|
33
38
|
const context = pricingContext.context || {};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
39
|
+
// Quantity is used to scope money amounts based on min_quantity and max_quantity.
|
|
40
|
+
// We should potentially think of reserved words in pricingContext that can't be used in rules
|
|
41
|
+
// or have a separate pricing options that accept things like quantity, price_list_id and other
|
|
42
|
+
// pricing module features
|
|
43
|
+
const quantity = context.quantity;
|
|
44
|
+
delete context.quantity;
|
|
45
|
+
// Gets all the price set money amounts where rules match for each of the contexts
|
|
46
|
+
// that the price set is configured for
|
|
47
|
+
const psmaSubQueryKnex = knex({
|
|
48
|
+
psma: "price_set_money_amount",
|
|
49
|
+
})
|
|
50
|
+
.select({
|
|
51
|
+
id: "psma.id",
|
|
52
|
+
price_set_id: "psma.price_set_id",
|
|
53
|
+
money_amount_id: "psma.money_amount_id",
|
|
54
|
+
number_rules: "psma.number_rules",
|
|
55
|
+
})
|
|
56
|
+
.join("price_rule as pr", "pr.price_set_money_amount_id", "psma.id")
|
|
57
|
+
.join("rule_type as rt", "rt.id", "pr.rule_type_id")
|
|
58
|
+
.orderBy("number_rules", "desc");
|
|
59
|
+
for (const [key, value] of Object.entries(context)) {
|
|
60
|
+
psmaSubQueryKnex.orWhere({
|
|
61
|
+
"rt.rule_attribute": key,
|
|
62
|
+
"pr.value": value,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
psmaSubQueryKnex
|
|
66
|
+
.groupBy("psma.id")
|
|
67
|
+
.having(knex.raw("count(DISTINCT rt.rule_attribute) = psma.number_rules"));
|
|
68
|
+
const priceSetQueryKnex = knex({
|
|
69
|
+
ps: "price_set",
|
|
70
|
+
})
|
|
71
|
+
.select({
|
|
72
|
+
id: "ps.id",
|
|
73
|
+
amount: "ma.amount",
|
|
74
|
+
min_quantity: "ma.min_quantity",
|
|
75
|
+
max_quantity: "ma.max_quantity",
|
|
76
|
+
currency_code: "ma.currency_code",
|
|
77
|
+
default_priority: "rt.default_priority",
|
|
78
|
+
number_rules: "psma.number_rules",
|
|
79
|
+
})
|
|
80
|
+
.join(psmaSubQueryKnex.as("psma"), "psma.price_set_id", "ps.id")
|
|
81
|
+
.join("money_amount as ma", "ma.id", "psma.money_amount_id")
|
|
82
|
+
.join("price_rule as pr", "pr.price_set_money_amount_id", "psma.id")
|
|
83
|
+
.join("rule_type as rt", "rt.id", "pr.rule_type_id")
|
|
84
|
+
.whereIn("ps.id", pricingFilters.id)
|
|
85
|
+
.orderBy([
|
|
86
|
+
{ column: "number_rules", order: "desc" },
|
|
87
|
+
{ column: "default_priority", order: "desc" },
|
|
88
|
+
]);
|
|
89
|
+
if (quantity) {
|
|
90
|
+
priceSetQueryKnex.where("ma.min_quantity", "<=", quantity);
|
|
91
|
+
priceSetQueryKnex.andWhere("ma.max_quantity", ">=", quantity);
|
|
92
|
+
}
|
|
93
|
+
const isContextPresent = Object.entries(context).length;
|
|
94
|
+
// Only if the context is present do we need to query the database.
|
|
95
|
+
const queryBuilderResults = isContextPresent ? await priceSetQueryKnex : [];
|
|
96
|
+
const pricesSetPricesMap = (0, utils_1.groupBy)(queryBuilderResults, "id");
|
|
97
|
+
const calculatedPrices = pricingFilters.id.map((priceSetId) => {
|
|
98
|
+
// This is where we select prices, for now we just do a first match based on the database results
|
|
99
|
+
// which is prioritized by number_rules first for exact match and then deafult_priority of the rule_type
|
|
100
|
+
// inject custom price selection here
|
|
101
|
+
const price = pricesSetPricesMap.get(priceSetId)?.[0];
|
|
54
102
|
return {
|
|
55
|
-
id:
|
|
56
|
-
amount:
|
|
57
|
-
currency_code:
|
|
58
|
-
min_quantity:
|
|
59
|
-
max_quantity:
|
|
103
|
+
id: priceSetId,
|
|
104
|
+
amount: price?.amount || null,
|
|
105
|
+
currency_code: price?.currency_code || null,
|
|
106
|
+
min_quantity: price?.min_quantity || null,
|
|
107
|
+
max_quantity: price?.max_quantity || null,
|
|
60
108
|
};
|
|
61
109
|
});
|
|
62
110
|
return JSON.parse(JSON.stringify(calculatedPrices));
|
|
@@ -205,6 +253,78 @@ class PricingModuleService {
|
|
|
205
253
|
async deleteRuleTypes(ruleTypes, sharedContext = {}) {
|
|
206
254
|
await this.ruleTypeService_.delete(ruleTypes, sharedContext);
|
|
207
255
|
}
|
|
256
|
+
async retrievePriceSetMoneyAmountRules(id, config = {}, sharedContext = {}) {
|
|
257
|
+
const record = await this.priceSetMoneyAmountRulesService_.retrieve(id, config, sharedContext);
|
|
258
|
+
return this.baseRepository_.serialize(record, {
|
|
259
|
+
populate: true,
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
async listPriceSetMoneyAmountRules(filters = {}, config = {}, sharedContext = {}) {
|
|
263
|
+
const records = await this.priceSetMoneyAmountRulesService_.list(filters, config, sharedContext);
|
|
264
|
+
return this.baseRepository_.serialize(records, {
|
|
265
|
+
populate: true,
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
async listAndCountPriceSetMoneyAmountRules(filters = {}, config = {}, sharedContext = {}) {
|
|
269
|
+
const [records, count] = await this.priceSetMoneyAmountRulesService_.listAndCount(filters, config, sharedContext);
|
|
270
|
+
return [
|
|
271
|
+
await this.baseRepository_.serialize(records, {
|
|
272
|
+
populate: true,
|
|
273
|
+
}),
|
|
274
|
+
count,
|
|
275
|
+
];
|
|
276
|
+
}
|
|
277
|
+
async createPriceSetMoneyAmountRules(data, sharedContext = {}) {
|
|
278
|
+
const records = await this.priceSetMoneyAmountRulesService_.create(data, sharedContext);
|
|
279
|
+
return this.baseRepository_.serialize(records, {
|
|
280
|
+
populate: true,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
async updatePriceSetMoneyAmountRules(data, sharedContext = {}) {
|
|
284
|
+
const records = await this.priceSetMoneyAmountRulesService_.update(data, sharedContext);
|
|
285
|
+
return this.baseRepository_.serialize(records, {
|
|
286
|
+
populate: true,
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
async deletePriceSetMoneyAmountRules(ids, sharedContext = {}) {
|
|
290
|
+
await this.priceSetMoneyAmountRulesService_.delete(ids, sharedContext);
|
|
291
|
+
}
|
|
292
|
+
async retrievePriceRule(id, config = {}, sharedContext = {}) {
|
|
293
|
+
const priceRule = await this.priceRuleService_.retrieve(id, config, sharedContext);
|
|
294
|
+
return this.baseRepository_.serialize(priceRule, {
|
|
295
|
+
populate: true,
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
async listPriceRules(filters = {}, config = {}, sharedContext = {}) {
|
|
299
|
+
const priceRules = await this.priceRuleService_.list(filters, config, sharedContext);
|
|
300
|
+
return this.baseRepository_.serialize(priceRules, {
|
|
301
|
+
populate: true,
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
async listAndCountPriceRules(filters = {}, config = {}, sharedContext = {}) {
|
|
305
|
+
const [priceRules, count] = await this.priceRuleService_.listAndCount(filters, config, sharedContext);
|
|
306
|
+
return [
|
|
307
|
+
await this.baseRepository_.serialize(priceRules, {
|
|
308
|
+
populate: true,
|
|
309
|
+
}),
|
|
310
|
+
count,
|
|
311
|
+
];
|
|
312
|
+
}
|
|
313
|
+
async createPriceRules(data, sharedContext = {}) {
|
|
314
|
+
const priceRules = await this.priceRuleService_.create(data, sharedContext);
|
|
315
|
+
return this.baseRepository_.serialize(priceRules, {
|
|
316
|
+
populate: true,
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
async updatePriceRules(data, sharedContext = {}) {
|
|
320
|
+
const priceRules = await this.priceRuleService_.update(data, sharedContext);
|
|
321
|
+
return this.baseRepository_.serialize(priceRules, {
|
|
322
|
+
populate: true,
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
async deletePriceRules(priceRuleIds, sharedContext = {}) {
|
|
326
|
+
await this.priceRuleService_.delete(priceRuleIds, sharedContext);
|
|
327
|
+
}
|
|
208
328
|
}
|
|
209
329
|
exports.default = PricingModuleService;
|
|
210
330
|
__decorate([
|
|
@@ -382,3 +502,87 @@ __decorate([
|
|
|
382
502
|
__metadata("design:paramtypes", [Array, Object]),
|
|
383
503
|
__metadata("design:returntype", Promise)
|
|
384
504
|
], PricingModuleService.prototype, "deleteRuleTypes", null);
|
|
505
|
+
__decorate([
|
|
506
|
+
(0, utils_1.InjectManager)("baseRepository_"),
|
|
507
|
+
__param(2, (0, utils_1.MedusaContext)()),
|
|
508
|
+
__metadata("design:type", Function),
|
|
509
|
+
__metadata("design:paramtypes", [String, Object, Object]),
|
|
510
|
+
__metadata("design:returntype", Promise)
|
|
511
|
+
], PricingModuleService.prototype, "retrievePriceSetMoneyAmountRules", null);
|
|
512
|
+
__decorate([
|
|
513
|
+
(0, utils_1.InjectManager)("baseRepository_"),
|
|
514
|
+
__param(2, (0, utils_1.MedusaContext)()),
|
|
515
|
+
__metadata("design:type", Function),
|
|
516
|
+
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
517
|
+
__metadata("design:returntype", Promise)
|
|
518
|
+
], PricingModuleService.prototype, "listPriceSetMoneyAmountRules", null);
|
|
519
|
+
__decorate([
|
|
520
|
+
(0, utils_1.InjectManager)("baseRepository_"),
|
|
521
|
+
__param(2, (0, utils_1.MedusaContext)()),
|
|
522
|
+
__metadata("design:type", Function),
|
|
523
|
+
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
524
|
+
__metadata("design:returntype", Promise)
|
|
525
|
+
], PricingModuleService.prototype, "listAndCountPriceSetMoneyAmountRules", null);
|
|
526
|
+
__decorate([
|
|
527
|
+
(0, utils_1.InjectTransactionManager)(utils_1.shouldForceTransaction, "baseRepository_"),
|
|
528
|
+
__param(1, (0, utils_1.MedusaContext)()),
|
|
529
|
+
__metadata("design:type", Function),
|
|
530
|
+
__metadata("design:paramtypes", [Array, Object]),
|
|
531
|
+
__metadata("design:returntype", Promise)
|
|
532
|
+
], PricingModuleService.prototype, "createPriceSetMoneyAmountRules", null);
|
|
533
|
+
__decorate([
|
|
534
|
+
(0, utils_1.InjectTransactionManager)(utils_1.shouldForceTransaction, "baseRepository_"),
|
|
535
|
+
__param(1, (0, utils_1.MedusaContext)()),
|
|
536
|
+
__metadata("design:type", Function),
|
|
537
|
+
__metadata("design:paramtypes", [Array, Object]),
|
|
538
|
+
__metadata("design:returntype", Promise)
|
|
539
|
+
], PricingModuleService.prototype, "updatePriceSetMoneyAmountRules", null);
|
|
540
|
+
__decorate([
|
|
541
|
+
(0, utils_1.InjectTransactionManager)(utils_1.shouldForceTransaction, "baseRepository_"),
|
|
542
|
+
__param(1, (0, utils_1.MedusaContext)()),
|
|
543
|
+
__metadata("design:type", Function),
|
|
544
|
+
__metadata("design:paramtypes", [Array, Object]),
|
|
545
|
+
__metadata("design:returntype", Promise)
|
|
546
|
+
], PricingModuleService.prototype, "deletePriceSetMoneyAmountRules", null);
|
|
547
|
+
__decorate([
|
|
548
|
+
(0, utils_1.InjectManager)("baseRepository_"),
|
|
549
|
+
__param(2, (0, utils_1.MedusaContext)()),
|
|
550
|
+
__metadata("design:type", Function),
|
|
551
|
+
__metadata("design:paramtypes", [String, Object, Object]),
|
|
552
|
+
__metadata("design:returntype", Promise)
|
|
553
|
+
], PricingModuleService.prototype, "retrievePriceRule", null);
|
|
554
|
+
__decorate([
|
|
555
|
+
(0, utils_1.InjectManager)("baseRepository_"),
|
|
556
|
+
__param(2, (0, utils_1.MedusaContext)()),
|
|
557
|
+
__metadata("design:type", Function),
|
|
558
|
+
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
559
|
+
__metadata("design:returntype", Promise)
|
|
560
|
+
], PricingModuleService.prototype, "listPriceRules", null);
|
|
561
|
+
__decorate([
|
|
562
|
+
(0, utils_1.InjectManager)("baseRepository_"),
|
|
563
|
+
__param(2, (0, utils_1.MedusaContext)()),
|
|
564
|
+
__metadata("design:type", Function),
|
|
565
|
+
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
566
|
+
__metadata("design:returntype", Promise)
|
|
567
|
+
], PricingModuleService.prototype, "listAndCountPriceRules", null);
|
|
568
|
+
__decorate([
|
|
569
|
+
(0, utils_1.InjectTransactionManager)(utils_1.shouldForceTransaction, "baseRepository_"),
|
|
570
|
+
__param(1, (0, utils_1.MedusaContext)()),
|
|
571
|
+
__metadata("design:type", Function),
|
|
572
|
+
__metadata("design:paramtypes", [Array, Object]),
|
|
573
|
+
__metadata("design:returntype", Promise)
|
|
574
|
+
], PricingModuleService.prototype, "createPriceRules", null);
|
|
575
|
+
__decorate([
|
|
576
|
+
(0, utils_1.InjectTransactionManager)(utils_1.shouldForceTransaction, "baseRepository_"),
|
|
577
|
+
__param(1, (0, utils_1.MedusaContext)()),
|
|
578
|
+
__metadata("design:type", Function),
|
|
579
|
+
__metadata("design:paramtypes", [Array, Object]),
|
|
580
|
+
__metadata("design:returntype", Promise)
|
|
581
|
+
], PricingModuleService.prototype, "updatePriceRules", null);
|
|
582
|
+
__decorate([
|
|
583
|
+
(0, utils_1.InjectTransactionManager)(utils_1.shouldForceTransaction, "baseRepository_"),
|
|
584
|
+
__param(1, (0, utils_1.MedusaContext)()),
|
|
585
|
+
__metadata("design:type", Function),
|
|
586
|
+
__metadata("design:paramtypes", [Array, Object]),
|
|
587
|
+
__metadata("design:returntype", Promise)
|
|
588
|
+
], PricingModuleService.prototype, "deletePriceRules", null);
|
|
@@ -9,7 +9,6 @@ export default class RuleTypeService<TEntity extends RuleType = RuleType> {
|
|
|
9
9
|
retrieve(ruleTypeId: string, config?: FindConfig<PricingTypes.RuleTypeDTO>, sharedContext?: Context): Promise<TEntity>;
|
|
10
10
|
list(filters?: PricingTypes.FilterableRuleTypeProps, config?: FindConfig<PricingTypes.RuleTypeDTO>, sharedContext?: Context): Promise<TEntity[]>;
|
|
11
11
|
listAndCount(filters?: PricingTypes.FilterableRuleTypeProps, config?: FindConfig<PricingTypes.RuleTypeDTO>, sharedContext?: Context): Promise<[TEntity[], number]>;
|
|
12
|
-
private buildQueryForList;
|
|
13
12
|
create(data: PricingTypes.CreateRuleTypeDTO[], sharedContext?: Context): Promise<TEntity[]>;
|
|
14
13
|
update(data: PricingTypes.UpdateRuleTypeDTO[], sharedContext?: Context): Promise<TEntity[]>;
|
|
15
14
|
delete(ids: string[], sharedContext?: Context): Promise<void>;
|
|
@@ -31,17 +31,12 @@ class RuleTypeService {
|
|
|
31
31
|
}));
|
|
32
32
|
}
|
|
33
33
|
async list(filters = {}, config = {}, sharedContext = {}) {
|
|
34
|
-
|
|
34
|
+
const queryOptions = utils_1.ModulesSdkUtils.buildQuery(filters, config);
|
|
35
|
+
return (await this.ruleTypeRepository_.find(queryOptions, sharedContext));
|
|
35
36
|
}
|
|
36
37
|
async listAndCount(filters = {}, config = {}, sharedContext = {}) {
|
|
37
|
-
return (await this.ruleTypeRepository_.findAndCount(this.buildQueryForList(filters, config), sharedContext));
|
|
38
|
-
}
|
|
39
|
-
buildQueryForList(filters = {}, config = {}) {
|
|
40
38
|
const queryOptions = utils_1.ModulesSdkUtils.buildQuery(filters, config);
|
|
41
|
-
|
|
42
|
-
queryOptions.where["id"] = { $in: filters.id };
|
|
43
|
-
}
|
|
44
|
-
return queryOptions;
|
|
39
|
+
return (await this.ruleTypeRepository_.findAndCount(queryOptions, sharedContext));
|
|
45
40
|
}
|
|
46
41
|
async create(data, sharedContext = {}) {
|
|
47
42
|
return (await this.ruleTypeRepository_.create(data, sharedContext));
|