@medusajs/pricing 0.1.10 → 0.1.11
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/joiner-config.d.ts +1 -2
- package/dist/joiner-config.js +1 -9
- package/dist/migrations/Migration20230929122253.js +60 -29
- package/dist/migrations/Migration20240322094407.d.ts +5 -0
- package/dist/migrations/Migration20240322094407.js +15 -0
- package/dist/migrations/{Migration20231101232834.d.ts → Migration20240322113359.d.ts} +1 -1
- package/dist/migrations/Migration20240322113359.js +19 -0
- package/dist/migrations/{Migration20240103140327.d.ts → Migration20240322120125.d.ts} +1 -1
- package/dist/migrations/Migration20240322120125.js +15 -0
- package/dist/models/index.d.ts +1 -3
- package/dist/models/index.js +3 -7
- package/dist/models/price-list-rule-value.d.ts +9 -0
- package/dist/models/price-list-rule-value.js +49 -4
- package/dist/models/price-list-rule.d.ts +8 -3
- package/dist/models/price-list-rule.js +65 -15
- package/dist/models/price-list.d.ts +7 -6
- package/dist/models/price-list.js +23 -11
- package/dist/models/price-rule.d.ts +8 -5
- package/dist/models/price-rule.js +63 -19
- package/dist/models/price-set-rule-type.d.ts +5 -4
- package/dist/models/price-set-rule-type.js +57 -8
- package/dist/models/price-set.d.ts +7 -6
- package/dist/models/price-set.js +42 -19
- package/dist/models/price.d.ts +27 -0
- package/dist/models/price.js +167 -0
- package/dist/models/rule-type.d.ts +1 -0
- package/dist/models/rule-type.js +21 -2
- package/dist/repositories/pricing.js +40 -38
- package/dist/scripts/seed.js +9 -17
- package/dist/services/index.d.ts +0 -3
- package/dist/services/index.js +1 -7
- package/dist/services/pricing-module.d.ts +19 -33
- package/dist/services/pricing-module.js +163 -348
- package/dist/services/rule-type.d.ts +5 -6
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.js +1 -2
- package/dist/types/services/index.d.ts +0 -10
- package/dist/types/services/index.js +0 -10
- package/dist/types/services/price-list.d.ts +0 -21
- package/package.json +5 -5
- package/dist/migrations/Migration20231101232834.js +0 -50
- package/dist/migrations/Migration20240103140327.js +0 -29
- package/dist/models/money-amount.d.ts +0 -19
- package/dist/models/money-amount.js +0 -111
- package/dist/models/price-set-money-amount-rules.d.ts +0 -10
- package/dist/models/price-set-money-amount-rules.js +0 -63
- package/dist/models/price-set-money-amount.d.ts +0 -24
- package/dist/models/price-set-money-amount.js +0 -128
- package/dist/services/price-list-rule-value.d.ts +0 -13
- package/dist/services/price-list-rule-value.js +0 -22
- package/dist/services/price-list-rule.d.ts +0 -15
- package/dist/services/price-list-rule.js +0 -41
- package/dist/services/price-rule.d.ts +0 -13
- package/dist/services/price-rule.js +0 -22
- package/dist/types/repositories/index.d.ts +0 -10
- package/dist/types/repositories/index.js +0 -26
- package/dist/types/repositories/money-amount.d.ts +0 -14
- package/dist/types/repositories/money-amount.js +0 -2
- package/dist/types/repositories/price-list-rule-value.d.ts +0 -10
- package/dist/types/repositories/price-list-rule-value.js +0 -2
- package/dist/types/repositories/price-list-rule.d.ts +0 -14
- package/dist/types/repositories/price-list-rule.js +0 -2
- package/dist/types/repositories/price-list.d.ts +0 -18
- package/dist/types/repositories/price-list.js +0 -2
- package/dist/types/repositories/price-rule.d.ts +0 -21
- package/dist/types/repositories/price-rule.js +0 -2
- package/dist/types/repositories/price-set-money-amount-rules.d.ts +0 -11
- package/dist/types/repositories/price-set-money-amount-rules.js +0 -2
- package/dist/types/repositories/price-set-money-amount.d.ts +0 -13
- package/dist/types/repositories/price-set-money-amount.js +0 -2
- package/dist/types/repositories/price-set-rule-type.d.ts +0 -10
- package/dist/types/repositories/price-set-rule-type.js +0 -2
- package/dist/types/repositories/price-set.d.ts +0 -5
- package/dist/types/repositories/price-set.js +0 -2
- package/dist/types/repositories/rule-type.d.ts +0 -12
- package/dist/types/repositories/rule-type.js +0 -2
- package/dist/types/services/money-amount.d.ts +0 -30
- package/dist/types/services/money-amount.js +0 -2
- package/dist/types/services/price-list-rule-value.d.ts +0 -21
- package/dist/types/services/price-list-rule-value.js +0 -2
- package/dist/types/services/price-list-rule.d.ts +0 -27
- package/dist/types/services/price-list-rule.js +0 -2
- package/dist/types/services/price-rule.d.ts +0 -42
- package/dist/types/services/price-rule.js +0 -2
- package/dist/types/services/price-set-money-amount-rules.d.ts +0 -24
- package/dist/types/services/price-set-money-amount-rules.js +0 -2
- package/dist/types/services/price-set-money-amount.d.ts +0 -32
- package/dist/types/services/price-set-money-amount.js +0 -2
- package/dist/types/services/price-set-rule-type.d.ts +0 -21
- package/dist/types/services/price-set-rule-type.js +0 -2
- package/dist/types/services/price-set.d.ts +0 -15
- package/dist/types/services/price-set.js +0 -2
- package/dist/types/services/pricing.d.ts +0 -20
- package/dist/types/services/pricing.js +0 -2
- package/dist/types/services/rule-type.d.ts +0 -32
- package/dist/types/services/rule-type.js +0 -2
|
@@ -12,22 +12,34 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.PriceListIdPrefix = void 0;
|
|
15
16
|
const utils_1 = require("@medusajs/utils");
|
|
16
17
|
const core_1 = require("@mikro-orm/core");
|
|
18
|
+
const price_1 = __importDefault(require("./price"));
|
|
17
19
|
const price_list_rule_1 = __importDefault(require("./price-list-rule"));
|
|
18
|
-
const price_set_money_amount_1 = __importDefault(require("./price-set-money-amount"));
|
|
19
20
|
const rule_type_1 = __importDefault(require("./rule-type"));
|
|
21
|
+
const tableName = "price_list";
|
|
22
|
+
const PriceListDeletedAtIndex = (0, utils_1.createPsqlIndexStatementHelper)({
|
|
23
|
+
tableName: tableName,
|
|
24
|
+
columns: "deleted_at",
|
|
25
|
+
where: "deleted_at IS NOT NULL",
|
|
26
|
+
});
|
|
27
|
+
exports.PriceListIdPrefix = "plist";
|
|
20
28
|
let PriceList = class PriceList {
|
|
21
29
|
constructor() {
|
|
22
|
-
this.
|
|
30
|
+
this.starts_at = null;
|
|
31
|
+
this.ends_at = null;
|
|
32
|
+
this.prices = new core_1.Collection(this);
|
|
23
33
|
this.price_list_rules = new core_1.Collection(this);
|
|
24
34
|
this.rule_types = new core_1.Collection(this);
|
|
35
|
+
this.rules_count = 0;
|
|
36
|
+
this.deleted_at = null;
|
|
25
37
|
}
|
|
26
38
|
onCreate() {
|
|
27
|
-
this.id = (0, utils_1.generateEntityId)(this.id,
|
|
39
|
+
this.id = (0, utils_1.generateEntityId)(this.id, exports.PriceListIdPrefix);
|
|
28
40
|
}
|
|
29
41
|
onInit() {
|
|
30
|
-
this.id = (0, utils_1.generateEntityId)(this.id,
|
|
42
|
+
this.id = (0, utils_1.generateEntityId)(this.id, exports.PriceListIdPrefix);
|
|
31
43
|
}
|
|
32
44
|
};
|
|
33
45
|
__decorate([
|
|
@@ -65,14 +77,14 @@ __decorate([
|
|
|
65
77
|
__metadata("design:type", Object)
|
|
66
78
|
], PriceList.prototype, "ends_at", void 0);
|
|
67
79
|
__decorate([
|
|
68
|
-
(0, core_1.OneToMany)(() =>
|
|
69
|
-
cascade: [core_1.Cascade.
|
|
80
|
+
(0, core_1.OneToMany)(() => price_1.default, (price) => price.price_list, {
|
|
81
|
+
cascade: [core_1.Cascade.PERSIST, "soft-remove"],
|
|
70
82
|
}),
|
|
71
83
|
__metadata("design:type", Object)
|
|
72
|
-
], PriceList.prototype, "
|
|
84
|
+
], PriceList.prototype, "prices", void 0);
|
|
73
85
|
__decorate([
|
|
74
86
|
(0, core_1.OneToMany)(() => price_list_rule_1.default, (pr) => pr.price_list, {
|
|
75
|
-
cascade: [core_1.Cascade.
|
|
87
|
+
cascade: [core_1.Cascade.PERSIST, "soft-remove"],
|
|
76
88
|
}),
|
|
77
89
|
__metadata("design:type", Object)
|
|
78
90
|
], PriceList.prototype, "price_list_rules", void 0);
|
|
@@ -80,7 +92,6 @@ __decorate([
|
|
|
80
92
|
(0, core_1.ManyToMany)({
|
|
81
93
|
entity: () => rule_type_1.default,
|
|
82
94
|
pivotEntity: () => price_list_rule_1.default,
|
|
83
|
-
cascade: [core_1.Cascade.REMOVE],
|
|
84
95
|
}),
|
|
85
96
|
__metadata("design:type", Object)
|
|
86
97
|
], PriceList.prototype, "rule_types", void 0);
|
|
@@ -106,7 +117,7 @@ __decorate([
|
|
|
106
117
|
__metadata("design:type", Date)
|
|
107
118
|
], PriceList.prototype, "updated_at", void 0);
|
|
108
119
|
__decorate([
|
|
109
|
-
|
|
120
|
+
PriceListDeletedAtIndex.MikroORMIndex(),
|
|
110
121
|
(0, core_1.Property)({ columnType: "timestamptz", nullable: true }),
|
|
111
122
|
__metadata("design:type", Object)
|
|
112
123
|
], PriceList.prototype, "deleted_at", void 0);
|
|
@@ -123,6 +134,7 @@ __decorate([
|
|
|
123
134
|
__metadata("design:returntype", void 0)
|
|
124
135
|
], PriceList.prototype, "onInit", null);
|
|
125
136
|
PriceList = __decorate([
|
|
126
|
-
(0, core_1.Entity)()
|
|
137
|
+
(0, core_1.Entity)({ tableName }),
|
|
138
|
+
(0, core_1.Filter)(utils_1.DALUtils.mikroOrmSoftDeletableFilterOptions)
|
|
127
139
|
], PriceList);
|
|
128
140
|
exports.default = PriceList;
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
+
import { DAL } from "@medusajs/types";
|
|
1
2
|
import { OptionalProps } from "@mikro-orm/core";
|
|
3
|
+
import Price from "./price";
|
|
2
4
|
import PriceSet from "./price-set";
|
|
3
|
-
import PriceSetMoneyAmount from "./price-set-money-amount";
|
|
4
5
|
import RuleType from "./rule-type";
|
|
5
|
-
type OptionalFields =
|
|
6
|
-
type OptionalRelations = "price_set" | "rule_type" | "price_set_money_amount";
|
|
6
|
+
type OptionalFields = DAL.SoftDeletableEntityDateColumns;
|
|
7
7
|
export default class PriceRule {
|
|
8
|
-
[OptionalProps]
|
|
8
|
+
[OptionalProps]?: OptionalFields;
|
|
9
9
|
id: string;
|
|
10
|
+
price_set_id: string;
|
|
10
11
|
price_set: PriceSet;
|
|
12
|
+
rule_type_id: string;
|
|
11
13
|
rule_type: RuleType;
|
|
12
14
|
value: string;
|
|
13
15
|
priority: number;
|
|
14
|
-
|
|
16
|
+
price_id: string;
|
|
17
|
+
price: Price;
|
|
15
18
|
created_at: Date;
|
|
16
19
|
updated_at: Date;
|
|
17
20
|
deleted_at: Date | null;
|
|
@@ -12,17 +12,49 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const core_1 = require("@mikro-orm/core");
|
|
16
15
|
const utils_1 = require("@medusajs/utils");
|
|
16
|
+
const core_1 = require("@mikro-orm/core");
|
|
17
|
+
const price_1 = __importDefault(require("./price"));
|
|
17
18
|
const price_set_1 = __importDefault(require("./price-set"));
|
|
18
|
-
const price_set_money_amount_1 = __importDefault(require("./price-set-money-amount"));
|
|
19
19
|
const rule_type_1 = __importDefault(require("./rule-type"));
|
|
20
|
+
const tableName = "price_rule";
|
|
21
|
+
const PriceRuleDeletedAtIndex = (0, utils_1.createPsqlIndexStatementHelper)({
|
|
22
|
+
tableName: tableName,
|
|
23
|
+
columns: "deleted_at",
|
|
24
|
+
where: "deleted_at IS NOT NULL",
|
|
25
|
+
});
|
|
26
|
+
const PriceRulePriceSetIdIndex = (0, utils_1.createPsqlIndexStatementHelper)({
|
|
27
|
+
tableName: tableName,
|
|
28
|
+
columns: "price_set_id",
|
|
29
|
+
where: "deleted_at IS NULL",
|
|
30
|
+
});
|
|
31
|
+
const PriceRuleRuleTypeIdIndex = (0, utils_1.createPsqlIndexStatementHelper)({
|
|
32
|
+
tableName: tableName,
|
|
33
|
+
columns: "rule_type_id",
|
|
34
|
+
where: "deleted_at IS NULL",
|
|
35
|
+
});
|
|
36
|
+
const PriceRulePriceIdIndex = (0, utils_1.createPsqlIndexStatementHelper)({
|
|
37
|
+
tableName: tableName,
|
|
38
|
+
columns: ["price_id", "rule_type_id"],
|
|
39
|
+
where: "deleted_at IS NULL",
|
|
40
|
+
unique: true,
|
|
41
|
+
});
|
|
20
42
|
let PriceRule = class PriceRule {
|
|
43
|
+
constructor() {
|
|
44
|
+
this.priority = 0;
|
|
45
|
+
this.deleted_at = null;
|
|
46
|
+
}
|
|
21
47
|
beforeCreate() {
|
|
22
48
|
this.id = (0, utils_1.generateEntityId)(this.id, "prule");
|
|
49
|
+
this.rule_type_id ?? (this.rule_type_id = this.rule_type?.id);
|
|
50
|
+
this.price_set_id ?? (this.price_set_id = this.price_set?.id);
|
|
51
|
+
this.price_id ?? (this.price_id = this.price?.id);
|
|
23
52
|
}
|
|
24
53
|
onInit() {
|
|
25
54
|
this.id = (0, utils_1.generateEntityId)(this.id, "prule");
|
|
55
|
+
this.rule_type_id ?? (this.rule_type_id = this.rule_type?.id);
|
|
56
|
+
this.price_set_id ?? (this.price_set_id = this.price_set?.id);
|
|
57
|
+
this.price_id ?? (this.price_id = this.price?.id);
|
|
26
58
|
}
|
|
27
59
|
};
|
|
28
60
|
__decorate([
|
|
@@ -30,22 +62,30 @@ __decorate([
|
|
|
30
62
|
__metadata("design:type", String)
|
|
31
63
|
], PriceRule.prototype, "id", void 0);
|
|
32
64
|
__decorate([
|
|
33
|
-
(
|
|
34
|
-
|
|
65
|
+
PriceRulePriceSetIdIndex.MikroORMIndex(),
|
|
66
|
+
(0, core_1.ManyToOne)(() => price_set_1.default, {
|
|
67
|
+
columnType: "text",
|
|
68
|
+
mapToPk: true,
|
|
35
69
|
fieldName: "price_set_id",
|
|
36
|
-
name: "price_rule_price_set_id_unique",
|
|
37
70
|
onDelete: "cascade",
|
|
38
|
-
index: "IDX_price_rule_price_set_id",
|
|
39
71
|
}),
|
|
72
|
+
__metadata("design:type", String)
|
|
73
|
+
], PriceRule.prototype, "price_set_id", void 0);
|
|
74
|
+
__decorate([
|
|
75
|
+
(0, core_1.ManyToOne)(() => price_set_1.default, { persist: false }),
|
|
40
76
|
__metadata("design:type", price_set_1.default)
|
|
41
77
|
], PriceRule.prototype, "price_set", void 0);
|
|
42
78
|
__decorate([
|
|
43
|
-
(
|
|
44
|
-
|
|
79
|
+
PriceRuleRuleTypeIdIndex.MikroORMIndex(),
|
|
80
|
+
(0, core_1.ManyToOne)(() => rule_type_1.default, {
|
|
81
|
+
columnType: "text",
|
|
82
|
+
mapToPk: true,
|
|
45
83
|
fieldName: "rule_type_id",
|
|
46
|
-
name: "price_rule_rule_type_id_unique",
|
|
47
|
-
index: "IDX_price_rule_rule_type_id",
|
|
48
84
|
}),
|
|
85
|
+
__metadata("design:type", String)
|
|
86
|
+
], PriceRule.prototype, "rule_type_id", void 0);
|
|
87
|
+
__decorate([
|
|
88
|
+
(0, core_1.ManyToOne)(() => rule_type_1.default, { persist: false }),
|
|
49
89
|
__metadata("design:type", rule_type_1.default)
|
|
50
90
|
], PriceRule.prototype, "rule_type", void 0);
|
|
51
91
|
__decorate([
|
|
@@ -57,15 +97,19 @@ __decorate([
|
|
|
57
97
|
__metadata("design:type", Number)
|
|
58
98
|
], PriceRule.prototype, "priority", void 0);
|
|
59
99
|
__decorate([
|
|
60
|
-
(
|
|
100
|
+
PriceRulePriceIdIndex.MikroORMIndex(),
|
|
101
|
+
(0, core_1.ManyToOne)(() => price_1.default, {
|
|
102
|
+
columnType: "text",
|
|
103
|
+
mapToPk: true,
|
|
104
|
+
fieldName: "price_id",
|
|
61
105
|
onDelete: "cascade",
|
|
62
|
-
entity: () => price_set_money_amount_1.default,
|
|
63
|
-
fieldName: "price_set_money_amount_id",
|
|
64
|
-
name: "price_set_money_amount_id_unique",
|
|
65
|
-
index: "IDX_price_rule_price_set_money_amount_id",
|
|
66
106
|
}),
|
|
67
|
-
__metadata("design:type",
|
|
68
|
-
], PriceRule.prototype, "
|
|
107
|
+
__metadata("design:type", String)
|
|
108
|
+
], PriceRule.prototype, "price_id", void 0);
|
|
109
|
+
__decorate([
|
|
110
|
+
(0, core_1.ManyToOne)(() => price_1.default, { persist: false }),
|
|
111
|
+
__metadata("design:type", price_1.default)
|
|
112
|
+
], PriceRule.prototype, "price", void 0);
|
|
69
113
|
__decorate([
|
|
70
114
|
(0, core_1.Property)({
|
|
71
115
|
onCreate: () => new Date(),
|
|
@@ -84,7 +128,7 @@ __decorate([
|
|
|
84
128
|
__metadata("design:type", Date)
|
|
85
129
|
], PriceRule.prototype, "updated_at", void 0);
|
|
86
130
|
__decorate([
|
|
87
|
-
|
|
131
|
+
PriceRuleDeletedAtIndex.MikroORMIndex(),
|
|
88
132
|
(0, core_1.Property)({ columnType: "timestamptz", nullable: true }),
|
|
89
133
|
__metadata("design:type", Object)
|
|
90
134
|
], PriceRule.prototype, "deleted_at", void 0);
|
|
@@ -101,7 +145,7 @@ __decorate([
|
|
|
101
145
|
__metadata("design:returntype", void 0)
|
|
102
146
|
], PriceRule.prototype, "onInit", null);
|
|
103
147
|
PriceRule = __decorate([
|
|
104
|
-
(0, core_1.Entity)(),
|
|
148
|
+
(0, core_1.Entity)({ tableName }),
|
|
105
149
|
(0, core_1.Filter)(utils_1.DALUtils.mikroOrmSoftDeletableFilterOptions)
|
|
106
150
|
], PriceRule);
|
|
107
151
|
exports.default = PriceRule;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import PriceSet from "./price-set";
|
|
2
|
-
import RuleType from "./rule-type";
|
|
3
1
|
export default class PriceSetRuleType {
|
|
4
2
|
id: string;
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
price_set_id: string;
|
|
4
|
+
rule_type_id: string;
|
|
5
|
+
created_at: Date;
|
|
6
|
+
updated_at: Date;
|
|
7
|
+
deleted_at: Date | null;
|
|
7
8
|
onCreate(): void;
|
|
8
9
|
onInit(): void;
|
|
9
10
|
}
|
|
@@ -12,11 +12,30 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const utils_1 = require("@medusajs/utils");
|
|
15
16
|
const core_1 = require("@mikro-orm/core");
|
|
16
17
|
const price_set_1 = __importDefault(require("./price-set"));
|
|
17
18
|
const rule_type_1 = __importDefault(require("./rule-type"));
|
|
18
|
-
const
|
|
19
|
+
const tableName = "price_set_rule_type";
|
|
20
|
+
const PriceSetRuleTypeDeletedAtIndex = (0, utils_1.createPsqlIndexStatementHelper)({
|
|
21
|
+
tableName: tableName,
|
|
22
|
+
columns: "deleted_at",
|
|
23
|
+
where: "deleted_at IS NOT NULL",
|
|
24
|
+
});
|
|
25
|
+
const PriceSetRuleTypePriceSetIdIndex = (0, utils_1.createPsqlIndexStatementHelper)({
|
|
26
|
+
tableName: tableName,
|
|
27
|
+
columns: "price_set_id",
|
|
28
|
+
where: "deleted_at IS NULL",
|
|
29
|
+
});
|
|
30
|
+
const PriceSetRuleTypeRuleTypeIdIndex = (0, utils_1.createPsqlIndexStatementHelper)({
|
|
31
|
+
tableName: tableName,
|
|
32
|
+
columns: "rule_type_id",
|
|
33
|
+
where: "deleted_at IS NULL",
|
|
34
|
+
});
|
|
19
35
|
let PriceSetRuleType = class PriceSetRuleType {
|
|
36
|
+
constructor() {
|
|
37
|
+
this.deleted_at = null;
|
|
38
|
+
}
|
|
20
39
|
onCreate() {
|
|
21
40
|
this.id = (0, utils_1.generateEntityId)(this.id, "psrt");
|
|
22
41
|
}
|
|
@@ -29,18 +48,47 @@ __decorate([
|
|
|
29
48
|
__metadata("design:type", String)
|
|
30
49
|
], PriceSetRuleType.prototype, "id", void 0);
|
|
31
50
|
__decorate([
|
|
51
|
+
PriceSetRuleTypePriceSetIdIndex.MikroORMIndex(),
|
|
32
52
|
(0, core_1.ManyToOne)(() => price_set_1.default, {
|
|
53
|
+
columnType: "text",
|
|
54
|
+
mapToPk: true,
|
|
55
|
+
fieldName: "price_set_id",
|
|
33
56
|
onDelete: "cascade",
|
|
34
|
-
index: "IDX_price_set_rule_type_price_set_id",
|
|
35
57
|
}),
|
|
36
|
-
__metadata("design:type",
|
|
37
|
-
], PriceSetRuleType.prototype, "
|
|
58
|
+
__metadata("design:type", String)
|
|
59
|
+
], PriceSetRuleType.prototype, "price_set_id", void 0);
|
|
38
60
|
__decorate([
|
|
61
|
+
PriceSetRuleTypeRuleTypeIdIndex.MikroORMIndex(),
|
|
39
62
|
(0, core_1.ManyToOne)(() => rule_type_1.default, {
|
|
40
|
-
|
|
63
|
+
columnType: "text",
|
|
64
|
+
mapToPk: true,
|
|
65
|
+
fieldName: "rule_type_id",
|
|
66
|
+
onDelete: "cascade",
|
|
41
67
|
}),
|
|
42
|
-
__metadata("design:type",
|
|
43
|
-
], PriceSetRuleType.prototype, "
|
|
68
|
+
__metadata("design:type", String)
|
|
69
|
+
], PriceSetRuleType.prototype, "rule_type_id", void 0);
|
|
70
|
+
__decorate([
|
|
71
|
+
(0, core_1.Property)({
|
|
72
|
+
onCreate: () => new Date(),
|
|
73
|
+
columnType: "timestamptz",
|
|
74
|
+
defaultRaw: "now()",
|
|
75
|
+
}),
|
|
76
|
+
__metadata("design:type", Date)
|
|
77
|
+
], PriceSetRuleType.prototype, "created_at", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
(0, core_1.Property)({
|
|
80
|
+
onCreate: () => new Date(),
|
|
81
|
+
onUpdate: () => new Date(),
|
|
82
|
+
columnType: "timestamptz",
|
|
83
|
+
defaultRaw: "now()",
|
|
84
|
+
}),
|
|
85
|
+
__metadata("design:type", Date)
|
|
86
|
+
], PriceSetRuleType.prototype, "updated_at", void 0);
|
|
87
|
+
__decorate([
|
|
88
|
+
PriceSetRuleTypeDeletedAtIndex.MikroORMIndex(),
|
|
89
|
+
(0, core_1.Property)({ columnType: "timestamptz", nullable: true }),
|
|
90
|
+
__metadata("design:type", Object)
|
|
91
|
+
], PriceSetRuleType.prototype, "deleted_at", void 0);
|
|
44
92
|
__decorate([
|
|
45
93
|
(0, core_1.BeforeCreate)(),
|
|
46
94
|
__metadata("design:type", Function),
|
|
@@ -54,6 +102,7 @@ __decorate([
|
|
|
54
102
|
__metadata("design:returntype", void 0)
|
|
55
103
|
], PriceSetRuleType.prototype, "onInit", null);
|
|
56
104
|
PriceSetRuleType = __decorate([
|
|
57
|
-
(0, core_1.Entity)()
|
|
105
|
+
(0, core_1.Entity)({ tableName }),
|
|
106
|
+
(0, core_1.Filter)(utils_1.DALUtils.mikroOrmSoftDeletableFilterOptions)
|
|
58
107
|
], PriceSetRuleType);
|
|
59
108
|
exports.default = PriceSetRuleType;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { Collection
|
|
2
|
-
import
|
|
1
|
+
import { Collection } from "@mikro-orm/core";
|
|
2
|
+
import Price from "./price";
|
|
3
3
|
import PriceRule from "./price-rule";
|
|
4
|
-
import PriceSetMoneyAmount from "./price-set-money-amount";
|
|
5
4
|
import RuleType from "./rule-type";
|
|
5
|
+
export declare const PriceSetIdPrefix = "pset";
|
|
6
6
|
export default class PriceSet {
|
|
7
|
-
[OptionalProps]?: "price_set_money_amounts" | "rule_types" | "money_amounts";
|
|
8
7
|
id: string;
|
|
9
|
-
|
|
8
|
+
prices: Collection<Price, object>;
|
|
10
9
|
price_rules: Collection<PriceRule, object>;
|
|
11
|
-
money_amounts: Collection<MoneyAmount, object>;
|
|
12
10
|
rule_types: Collection<RuleType, object>;
|
|
11
|
+
created_at: Date;
|
|
12
|
+
updated_at: Date;
|
|
13
|
+
deleted_at: Date | null;
|
|
13
14
|
onCreate(): void;
|
|
14
15
|
onInit(): void;
|
|
15
16
|
}
|
package/dist/models/price-set.js
CHANGED
|
@@ -12,25 +12,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.PriceSetIdPrefix = void 0;
|
|
15
16
|
const utils_1 = require("@medusajs/utils");
|
|
16
17
|
const core_1 = require("@mikro-orm/core");
|
|
17
|
-
const
|
|
18
|
+
const price_1 = __importDefault(require("./price"));
|
|
18
19
|
const price_rule_1 = __importDefault(require("./price-rule"));
|
|
19
|
-
const price_set_money_amount_1 = __importDefault(require("./price-set-money-amount"));
|
|
20
20
|
const price_set_rule_type_1 = __importDefault(require("./price-set-rule-type"));
|
|
21
21
|
const rule_type_1 = __importDefault(require("./rule-type"));
|
|
22
|
+
const tableName = "price_set";
|
|
23
|
+
const PriceSetDeletedAtIndex = (0, utils_1.createPsqlIndexStatementHelper)({
|
|
24
|
+
tableName: tableName,
|
|
25
|
+
columns: "deleted_at",
|
|
26
|
+
where: "deleted_at IS NOT NULL",
|
|
27
|
+
});
|
|
28
|
+
exports.PriceSetIdPrefix = "pset";
|
|
22
29
|
let PriceSet = class PriceSet {
|
|
23
30
|
constructor() {
|
|
24
|
-
this.
|
|
31
|
+
this.prices = new core_1.Collection(this);
|
|
25
32
|
this.price_rules = new core_1.Collection(this);
|
|
26
|
-
this.money_amounts = new core_1.Collection(this);
|
|
27
33
|
this.rule_types = new core_1.Collection(this);
|
|
34
|
+
this.deleted_at = null;
|
|
28
35
|
}
|
|
29
36
|
onCreate() {
|
|
30
|
-
this.id = (0, utils_1.generateEntityId)(this.id,
|
|
37
|
+
this.id = (0, utils_1.generateEntityId)(this.id, exports.PriceSetIdPrefix);
|
|
31
38
|
}
|
|
32
39
|
onInit() {
|
|
33
|
-
this.id = (0, utils_1.generateEntityId)(this.id,
|
|
40
|
+
this.id = (0, utils_1.generateEntityId)(this.id, exports.PriceSetIdPrefix);
|
|
34
41
|
}
|
|
35
42
|
};
|
|
36
43
|
__decorate([
|
|
@@ -38,32 +45,47 @@ __decorate([
|
|
|
38
45
|
__metadata("design:type", String)
|
|
39
46
|
], PriceSet.prototype, "id", void 0);
|
|
40
47
|
__decorate([
|
|
41
|
-
(0, core_1.OneToMany)(() =>
|
|
42
|
-
cascade: [core_1.Cascade.
|
|
48
|
+
(0, core_1.OneToMany)(() => price_1.default, (price) => price.price_set, {
|
|
49
|
+
cascade: [core_1.Cascade.PERSIST, "soft-remove"],
|
|
43
50
|
}),
|
|
44
51
|
__metadata("design:type", Object)
|
|
45
|
-
], PriceSet.prototype, "
|
|
52
|
+
], PriceSet.prototype, "prices", void 0);
|
|
46
53
|
__decorate([
|
|
47
54
|
(0, core_1.OneToMany)(() => price_rule_1.default, (pr) => pr.price_set, {
|
|
48
|
-
cascade: [core_1.Cascade.
|
|
55
|
+
cascade: [core_1.Cascade.PERSIST, "soft-remove"],
|
|
49
56
|
}),
|
|
50
57
|
__metadata("design:type", Object)
|
|
51
58
|
], PriceSet.prototype, "price_rules", void 0);
|
|
52
|
-
__decorate([
|
|
53
|
-
(0, core_1.ManyToMany)({
|
|
54
|
-
entity: () => money_amount_1.default,
|
|
55
|
-
pivotEntity: () => price_set_money_amount_1.default,
|
|
56
|
-
}),
|
|
57
|
-
__metadata("design:type", Object)
|
|
58
|
-
], PriceSet.prototype, "money_amounts", void 0);
|
|
59
59
|
__decorate([
|
|
60
60
|
(0, core_1.ManyToMany)({
|
|
61
61
|
entity: () => rule_type_1.default,
|
|
62
62
|
pivotEntity: () => price_set_rule_type_1.default,
|
|
63
|
-
cascade: [
|
|
63
|
+
cascade: ["soft-remove"],
|
|
64
64
|
}),
|
|
65
65
|
__metadata("design:type", Object)
|
|
66
66
|
], PriceSet.prototype, "rule_types", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
(0, core_1.Property)({
|
|
69
|
+
onCreate: () => new Date(),
|
|
70
|
+
columnType: "timestamptz",
|
|
71
|
+
defaultRaw: "now()",
|
|
72
|
+
}),
|
|
73
|
+
__metadata("design:type", Date)
|
|
74
|
+
], PriceSet.prototype, "created_at", void 0);
|
|
75
|
+
__decorate([
|
|
76
|
+
(0, core_1.Property)({
|
|
77
|
+
onCreate: () => new Date(),
|
|
78
|
+
onUpdate: () => new Date(),
|
|
79
|
+
columnType: "timestamptz",
|
|
80
|
+
defaultRaw: "now()",
|
|
81
|
+
}),
|
|
82
|
+
__metadata("design:type", Date)
|
|
83
|
+
], PriceSet.prototype, "updated_at", void 0);
|
|
84
|
+
__decorate([
|
|
85
|
+
PriceSetDeletedAtIndex.MikroORMIndex(),
|
|
86
|
+
(0, core_1.Property)({ columnType: "timestamptz", nullable: true }),
|
|
87
|
+
__metadata("design:type", Object)
|
|
88
|
+
], PriceSet.prototype, "deleted_at", void 0);
|
|
67
89
|
__decorate([
|
|
68
90
|
(0, core_1.BeforeCreate)(),
|
|
69
91
|
__metadata("design:type", Function),
|
|
@@ -77,6 +99,7 @@ __decorate([
|
|
|
77
99
|
__metadata("design:returntype", void 0)
|
|
78
100
|
], PriceSet.prototype, "onInit", null);
|
|
79
101
|
PriceSet = __decorate([
|
|
80
|
-
(0, core_1.Entity)()
|
|
102
|
+
(0, core_1.Entity)({ tableName }),
|
|
103
|
+
(0, core_1.Filter)(utils_1.DALUtils.mikroOrmSoftDeletableFilterOptions)
|
|
81
104
|
], PriceSet);
|
|
82
105
|
exports.default = PriceSet;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DAL } from "@medusajs/types";
|
|
2
|
+
import { Collection, OptionalProps } from "@mikro-orm/core";
|
|
3
|
+
import PriceList from "./price-list";
|
|
4
|
+
import PriceRule from "./price-rule";
|
|
5
|
+
import PriceSet from "./price-set";
|
|
6
|
+
type OptionalFields = DAL.SoftDeletableEntityDateColumns;
|
|
7
|
+
export default class Price {
|
|
8
|
+
[OptionalProps]?: OptionalFields;
|
|
9
|
+
id: string;
|
|
10
|
+
title: string | null;
|
|
11
|
+
currency_code: string;
|
|
12
|
+
amount: number;
|
|
13
|
+
min_quantity: number | null;
|
|
14
|
+
max_quantity: number | null;
|
|
15
|
+
price_set_id: string;
|
|
16
|
+
price_set?: PriceSet;
|
|
17
|
+
rules_count: number;
|
|
18
|
+
price_rules: Collection<PriceRule, object>;
|
|
19
|
+
price_list_id: string | null;
|
|
20
|
+
price_list: PriceList | null;
|
|
21
|
+
created_at: Date;
|
|
22
|
+
updated_at: Date;
|
|
23
|
+
deleted_at: Date | null;
|
|
24
|
+
onCreate(): void;
|
|
25
|
+
onInit(): void;
|
|
26
|
+
}
|
|
27
|
+
export {};
|