@medusajs/pricing 0.2.0-snapshot-20240429062340 → 1.0.0-rc-20241001083650
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.d.ts.map +1 -0
- package/dist/index.js +6 -9
- package/dist/index.js.map +1 -0
- package/dist/joiner-config.d.ts +2 -10
- package/dist/joiner-config.d.ts.map +1 -0
- package/dist/joiner-config.js +6 -48
- package/dist/joiner-config.js.map +1 -0
- package/dist/migrations/Migration20230929122253.d.ts +1 -0
- package/dist/migrations/Migration20230929122253.d.ts.map +1 -0
- package/dist/migrations/Migration20230929122253.js +1 -0
- package/dist/migrations/Migration20230929122253.js.map +1 -0
- package/dist/migrations/Migration20240322094407.d.ts +1 -0
- package/dist/migrations/Migration20240322094407.d.ts.map +1 -0
- package/dist/migrations/Migration20240322094407.js +1 -0
- package/dist/migrations/Migration20240322094407.js.map +1 -0
- package/dist/migrations/Migration20240322113359.d.ts +1 -0
- package/dist/migrations/Migration20240322113359.d.ts.map +1 -0
- package/dist/migrations/Migration20240322113359.js +1 -0
- package/dist/migrations/Migration20240322113359.js.map +1 -0
- package/dist/migrations/Migration20240322120125.d.ts +1 -0
- package/dist/migrations/Migration20240322120125.d.ts.map +1 -0
- package/dist/migrations/Migration20240322120125.js +1 -0
- package/dist/migrations/Migration20240322120125.js.map +1 -0
- package/dist/migrations/Migration20240626133555.d.ts +5 -0
- package/dist/migrations/Migration20240626133555.d.ts.map +1 -0
- package/dist/migrations/Migration20240626133555.js +34 -0
- package/dist/migrations/Migration20240626133555.js.map +1 -0
- package/dist/migrations/Migration20240704094505.d.ts +6 -0
- package/dist/migrations/Migration20240704094505.d.ts.map +1 -0
- package/dist/migrations/Migration20240704094505.js +16 -0
- package/dist/migrations/Migration20240704094505.js.map +1 -0
- package/dist/models/index.d.ts +2 -3
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +4 -7
- package/dist/models/index.js.map +1 -0
- package/dist/models/price-list-rule.d.ts +7 -9
- package/dist/models/price-list-rule.d.ts.map +1 -0
- package/dist/models/price-list-rule.js +10 -30
- package/dist/models/price-list-rule.js.map +1 -0
- package/dist/models/price-list.d.ts +4 -5
- package/dist/models/price-list.d.ts.map +1 -0
- package/dist/models/price-list.js +2 -10
- package/dist/models/price-list.js.map +1 -0
- package/dist/models/price-preference.d.ts +13 -0
- package/dist/models/price-preference.d.ts.map +1 -0
- package/dist/models/{rule-type.js → price-preference.js} +37 -41
- package/dist/models/price-preference.js.map +1 -0
- package/dist/models/price-rule.d.ts +6 -10
- package/dist/models/price-rule.d.ts.map +1 -0
- package/dist/models/price-rule.js +8 -46
- package/dist/models/price-rule.js.map +1 -0
- package/dist/models/price-set.d.ts +1 -4
- package/dist/models/price-set.d.ts.map +1 -0
- package/dist/models/price-set.js +2 -20
- package/dist/models/price-set.js.map +1 -0
- package/dist/models/price.d.ts +7 -6
- package/dist/models/price.d.ts.map +1 -0
- package/dist/models/price.js +7 -6
- package/dist/models/price.js.map +1 -0
- package/dist/repositories/index.d.ts +2 -1
- package/dist/repositories/index.d.ts.map +1 -0
- package/dist/repositories/index.js +2 -1
- package/dist/repositories/index.js.map +1 -0
- package/dist/repositories/pricing.d.ts +3 -2
- package/dist/repositories/pricing.d.ts.map +1 -0
- package/dist/repositories/pricing.js +41 -45
- package/dist/repositories/pricing.js.map +1 -0
- package/dist/schema/index.d.ts +2 -1
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +48 -4
- package/dist/schema/index.js.map +1 -0
- package/dist/services/index.d.ts +1 -2
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +2 -5
- package/dist/services/index.js.map +1 -0
- package/dist/services/pricing-module.d.ts +66 -53
- package/dist/services/pricing-module.d.ts.map +1 -0
- package/dist/services/pricing-module.js +625 -631
- package/dist/services/pricing-module.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/services/index.d.ts +30 -2
- package/dist/types/services/index.d.ts.map +1 -0
- package/dist/types/services/index.js +1 -16
- package/dist/types/services/index.js.map +1 -0
- package/dist/utils/events.d.ts +83 -0
- package/dist/utils/events.d.ts.map +1 -0
- package/dist/utils/events.js +67 -0
- package/dist/utils/events.js.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/validate-price-list-dates.d.ts +1 -0
- package/dist/utils/validate-price-list-dates.d.ts.map +1 -0
- package/dist/utils/validate-price-list-dates.js +2 -1
- package/dist/utils/validate-price-list-dates.js.map +1 -0
- package/package.json +20 -21
- package/dist/initialize/index.d.ts +0 -4
- package/dist/initialize/index.js +0 -17
- package/dist/loaders/connection.d.ts +0 -4
- package/dist/loaders/connection.js +0 -40
- package/dist/loaders/container.d.ts +0 -2
- package/dist/loaders/container.js +0 -34
- package/dist/loaders/index.d.ts +0 -2
- package/dist/loaders/index.js +0 -18
- package/dist/models/price-list-rule-value.d.ts +0 -17
- package/dist/models/price-list-rule-value.js +0 -102
- package/dist/models/price-set-rule-type.d.ts +0 -10
- package/dist/models/price-set-rule-type.js +0 -108
- package/dist/models/rule-type.d.ts +0 -17
- package/dist/module-definition.d.ts +0 -4
- package/dist/module-definition.js +0 -50
- package/dist/scripts/bin/run-seed.d.ts +0 -3
- package/dist/scripts/bin/run-seed.js +0 -38
- package/dist/scripts/seed.d.ts +0 -4
- package/dist/scripts/seed.js +0 -67
- package/dist/services/price-list.d.ts +0 -16
- package/dist/services/price-list.js +0 -34
- package/dist/services/rule-type.d.ts +0 -15
- package/dist/services/rule-type.js +0 -53
- package/dist/types/services/price-list.d.ts +0 -18
- package/dist/types/services/price-list.js +0 -2
- package/dist/types/services/price-set.d.ts +0 -4
- package/dist/types/services/price-set.js +0 -2
@@ -1,102 +0,0 @@
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
-
};
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
-
const utils_1 = require("@medusajs/utils");
|
16
|
-
const core_1 = require("@mikro-orm/core");
|
17
|
-
const price_list_rule_1 = __importDefault(require("./price-list-rule"));
|
18
|
-
const tableName = "price_list_rule_value";
|
19
|
-
const PriceListRuleValueDeletedAtIndex = (0, utils_1.createPsqlIndexStatementHelper)({
|
20
|
-
tableName: tableName,
|
21
|
-
columns: "deleted_at",
|
22
|
-
where: "deleted_at IS NOT NULL",
|
23
|
-
});
|
24
|
-
const PriceListPriceListRuleIdIndex = (0, utils_1.createPsqlIndexStatementHelper)({
|
25
|
-
tableName: tableName,
|
26
|
-
columns: "price_list_rule_id",
|
27
|
-
where: "deleted_at IS NULL",
|
28
|
-
});
|
29
|
-
let PriceListRuleValue = class PriceListRuleValue {
|
30
|
-
constructor() {
|
31
|
-
this.deleted_at = null;
|
32
|
-
}
|
33
|
-
onCreate() {
|
34
|
-
this.id = (0, utils_1.generateEntityId)(this.id, "plrv");
|
35
|
-
this.price_list_rule_id ?? (this.price_list_rule_id = this.price_list_rule?.id);
|
36
|
-
}
|
37
|
-
onInit() {
|
38
|
-
this.id = (0, utils_1.generateEntityId)(this.id, "plrv");
|
39
|
-
this.price_list_rule_id ?? (this.price_list_rule_id = this.price_list_rule?.id);
|
40
|
-
}
|
41
|
-
};
|
42
|
-
__decorate([
|
43
|
-
(0, core_1.PrimaryKey)({ columnType: "text" }),
|
44
|
-
__metadata("design:type", String)
|
45
|
-
], PriceListRuleValue.prototype, "id", void 0);
|
46
|
-
__decorate([
|
47
|
-
PriceListPriceListRuleIdIndex.MikroORMIndex(),
|
48
|
-
(0, core_1.ManyToOne)(() => price_list_rule_1.default, {
|
49
|
-
columnType: "text",
|
50
|
-
mapToPk: true,
|
51
|
-
fieldName: "price_list_rule_id",
|
52
|
-
onDelete: "cascade",
|
53
|
-
}),
|
54
|
-
__metadata("design:type", String)
|
55
|
-
], PriceListRuleValue.prototype, "price_list_rule_id", void 0);
|
56
|
-
__decorate([
|
57
|
-
(0, core_1.ManyToOne)(() => price_list_rule_1.default, { persist: false }),
|
58
|
-
__metadata("design:type", price_list_rule_1.default)
|
59
|
-
], PriceListRuleValue.prototype, "price_list_rule", void 0);
|
60
|
-
__decorate([
|
61
|
-
(0, core_1.Property)({ columnType: "text" }),
|
62
|
-
__metadata("design:type", String)
|
63
|
-
], PriceListRuleValue.prototype, "value", void 0);
|
64
|
-
__decorate([
|
65
|
-
(0, core_1.Property)({
|
66
|
-
onCreate: () => new Date(),
|
67
|
-
columnType: "timestamptz",
|
68
|
-
defaultRaw: "now()",
|
69
|
-
}),
|
70
|
-
__metadata("design:type", Date)
|
71
|
-
], PriceListRuleValue.prototype, "created_at", void 0);
|
72
|
-
__decorate([
|
73
|
-
(0, core_1.Property)({
|
74
|
-
onCreate: () => new Date(),
|
75
|
-
onUpdate: () => new Date(),
|
76
|
-
columnType: "timestamptz",
|
77
|
-
defaultRaw: "now()",
|
78
|
-
}),
|
79
|
-
__metadata("design:type", Date)
|
80
|
-
], PriceListRuleValue.prototype, "updated_at", void 0);
|
81
|
-
__decorate([
|
82
|
-
PriceListRuleValueDeletedAtIndex.MikroORMIndex(),
|
83
|
-
(0, core_1.Property)({ columnType: "timestamptz", nullable: true }),
|
84
|
-
__metadata("design:type", Object)
|
85
|
-
], PriceListRuleValue.prototype, "deleted_at", void 0);
|
86
|
-
__decorate([
|
87
|
-
(0, core_1.BeforeCreate)(),
|
88
|
-
__metadata("design:type", Function),
|
89
|
-
__metadata("design:paramtypes", []),
|
90
|
-
__metadata("design:returntype", void 0)
|
91
|
-
], PriceListRuleValue.prototype, "onCreate", null);
|
92
|
-
__decorate([
|
93
|
-
(0, core_1.OnInit)(),
|
94
|
-
__metadata("design:type", Function),
|
95
|
-
__metadata("design:paramtypes", []),
|
96
|
-
__metadata("design:returntype", void 0)
|
97
|
-
], PriceListRuleValue.prototype, "onInit", null);
|
98
|
-
PriceListRuleValue = __decorate([
|
99
|
-
(0, core_1.Entity)({ tableName }),
|
100
|
-
(0, core_1.Filter)(utils_1.DALUtils.mikroOrmSoftDeletableFilterOptions)
|
101
|
-
], PriceListRuleValue);
|
102
|
-
exports.default = PriceListRuleValue;
|
@@ -1,108 +0,0 @@
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
-
};
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
-
const utils_1 = require("@medusajs/utils");
|
16
|
-
const core_1 = require("@mikro-orm/core");
|
17
|
-
const price_set_1 = __importDefault(require("./price-set"));
|
18
|
-
const rule_type_1 = __importDefault(require("./rule-type"));
|
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
|
-
});
|
35
|
-
let PriceSetRuleType = class PriceSetRuleType {
|
36
|
-
constructor() {
|
37
|
-
this.deleted_at = null;
|
38
|
-
}
|
39
|
-
onCreate() {
|
40
|
-
this.id = (0, utils_1.generateEntityId)(this.id, "psrt");
|
41
|
-
}
|
42
|
-
onInit() {
|
43
|
-
this.id = (0, utils_1.generateEntityId)(this.id, "psrt");
|
44
|
-
}
|
45
|
-
};
|
46
|
-
__decorate([
|
47
|
-
(0, core_1.PrimaryKey)({ columnType: "text" }),
|
48
|
-
__metadata("design:type", String)
|
49
|
-
], PriceSetRuleType.prototype, "id", void 0);
|
50
|
-
__decorate([
|
51
|
-
PriceSetRuleTypePriceSetIdIndex.MikroORMIndex(),
|
52
|
-
(0, core_1.ManyToOne)(() => price_set_1.default, {
|
53
|
-
columnType: "text",
|
54
|
-
mapToPk: true,
|
55
|
-
fieldName: "price_set_id",
|
56
|
-
onDelete: "cascade",
|
57
|
-
}),
|
58
|
-
__metadata("design:type", String)
|
59
|
-
], PriceSetRuleType.prototype, "price_set_id", void 0);
|
60
|
-
__decorate([
|
61
|
-
PriceSetRuleTypeRuleTypeIdIndex.MikroORMIndex(),
|
62
|
-
(0, core_1.ManyToOne)(() => rule_type_1.default, {
|
63
|
-
columnType: "text",
|
64
|
-
mapToPk: true,
|
65
|
-
fieldName: "rule_type_id",
|
66
|
-
onDelete: "cascade",
|
67
|
-
}),
|
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);
|
92
|
-
__decorate([
|
93
|
-
(0, core_1.BeforeCreate)(),
|
94
|
-
__metadata("design:type", Function),
|
95
|
-
__metadata("design:paramtypes", []),
|
96
|
-
__metadata("design:returntype", void 0)
|
97
|
-
], PriceSetRuleType.prototype, "onCreate", null);
|
98
|
-
__decorate([
|
99
|
-
(0, core_1.OnInit)(),
|
100
|
-
__metadata("design:type", Function),
|
101
|
-
__metadata("design:paramtypes", []),
|
102
|
-
__metadata("design:returntype", void 0)
|
103
|
-
], PriceSetRuleType.prototype, "onInit", null);
|
104
|
-
PriceSetRuleType = __decorate([
|
105
|
-
(0, core_1.Entity)({ tableName }),
|
106
|
-
(0, core_1.Filter)(utils_1.DALUtils.mikroOrmSoftDeletableFilterOptions)
|
107
|
-
], PriceSetRuleType);
|
108
|
-
exports.default = PriceSetRuleType;
|
@@ -1,17 +0,0 @@
|
|
1
|
-
import { Collection, OptionalProps } from "@mikro-orm/core";
|
2
|
-
import PriceSet from "./price-set";
|
3
|
-
type OptionalFields = "default_priority";
|
4
|
-
declare class RuleType {
|
5
|
-
[OptionalProps]?: OptionalFields;
|
6
|
-
id: string;
|
7
|
-
name: string;
|
8
|
-
rule_attribute: string;
|
9
|
-
default_priority: number;
|
10
|
-
price_sets: Collection<PriceSet, object>;
|
11
|
-
created_at: Date;
|
12
|
-
updated_at: Date;
|
13
|
-
deleted_at: Date | null;
|
14
|
-
onCreate(): void;
|
15
|
-
onInit(): void;
|
16
|
-
}
|
17
|
-
export default RuleType;
|
@@ -1,4 +0,0 @@
|
|
1
|
-
import { ModuleExports } from "@medusajs/types";
|
2
|
-
export declare const runMigrations: ({ options, logger, }?: Pick<import("@medusajs/modules-sdk").LoaderOptions<import("@medusajs/modules-sdk").ModuleServiceInitializeOptions>, "options" | "logger"> | undefined) => Promise<void>;
|
3
|
-
export declare const revertMigration: ({ options, logger, }?: Pick<import("@medusajs/modules-sdk").LoaderOptions<import("@medusajs/modules-sdk").ModuleServiceInitializeOptions>, "options" | "logger"> | undefined) => Promise<void>;
|
4
|
-
export declare const moduleDefinition: ModuleExports;
|
@@ -1,50 +0,0 @@
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
27
|
-
};
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
-
exports.moduleDefinition = exports.revertMigration = exports.runMigrations = void 0;
|
30
|
-
const modules_sdk_1 = require("@medusajs/modules-sdk");
|
31
|
-
const utils_1 = require("@medusajs/utils");
|
32
|
-
const Models = __importStar(require("./models"));
|
33
|
-
const _services_1 = require("./services");
|
34
|
-
const connection_1 = __importDefault(require("./loaders/connection"));
|
35
|
-
const container_1 = __importDefault(require("./loaders/container"));
|
36
|
-
const migrationScriptOptions = {
|
37
|
-
moduleName: modules_sdk_1.Modules.PRICING,
|
38
|
-
models: Models,
|
39
|
-
pathToMigrations: __dirname + "/migrations",
|
40
|
-
};
|
41
|
-
exports.runMigrations = utils_1.ModulesSdkUtils.buildMigrationScript(migrationScriptOptions);
|
42
|
-
exports.revertMigration = utils_1.ModulesSdkUtils.buildRevertMigrationScript(migrationScriptOptions);
|
43
|
-
const service = _services_1.PricingModuleService;
|
44
|
-
const loaders = [container_1.default, connection_1.default];
|
45
|
-
exports.moduleDefinition = {
|
46
|
-
service,
|
47
|
-
loaders,
|
48
|
-
runMigrations: exports.runMigrations,
|
49
|
-
revertMigration: exports.revertMigration,
|
50
|
-
};
|
@@ -1,38 +0,0 @@
|
|
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
|
-
})();
|
package/dist/scripts/seed.d.ts
DELETED
package/dist/scripts/seed.js
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
-
if (k2 === undefined) k2 = k;
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
-
}
|
8
|
-
Object.defineProperty(o, k2, desc);
|
9
|
-
}) : (function(o, m, k, k2) {
|
10
|
-
if (k2 === undefined) k2 = k;
|
11
|
-
o[k2] = m[k];
|
12
|
-
}));
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
-
}) : function(o, v) {
|
16
|
-
o["default"] = v;
|
17
|
-
});
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
-
if (mod && mod.__esModule) return mod;
|
20
|
-
var result = {};
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
-
__setModuleDefault(result, mod);
|
23
|
-
return result;
|
24
|
-
};
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
26
|
-
exports.run = void 0;
|
27
|
-
const utils_1 = require("@medusajs/utils");
|
28
|
-
const PricingModels = __importStar(require("../models"));
|
29
|
-
const os_1 = require("os");
|
30
|
-
const path_1 = require("path");
|
31
|
-
async function run({ options, logger, path, }) {
|
32
|
-
logger ?? (logger = console);
|
33
|
-
logger.info(`Loading seed data from ${path}...`);
|
34
|
-
const { priceSetsData, pricesData } = await Promise.resolve(`${(0, path_1.resolve)(process.cwd(), path)}`).then(s => __importStar(require(s))).catch((e) => {
|
35
|
-
logger?.error(`Failed to load seed data from ${path}. Please, provide a relative path and check that you export the following: priceSetsData and pricesData.${os_1.EOL}${e}`);
|
36
|
-
throw e;
|
37
|
-
});
|
38
|
-
const dbData = utils_1.ModulesSdkUtils.loadDatabaseConfig("pricing", options);
|
39
|
-
const entities = Object.values(PricingModels);
|
40
|
-
const pathToMigrations = __dirname + "/../migrations";
|
41
|
-
const orm = await utils_1.DALUtils.mikroOrmCreateConnection(dbData, entities, pathToMigrations);
|
42
|
-
const manager = orm.em.fork();
|
43
|
-
try {
|
44
|
-
logger.info("Inserting price_sets & prices");
|
45
|
-
await createPriceSets(manager, priceSetsData);
|
46
|
-
await createPrices(manager, pricesData);
|
47
|
-
}
|
48
|
-
catch (e) {
|
49
|
-
logger.error(`Failed to insert the seed data in the PostgreSQL database ${dbData.clientUrl}.${os_1.EOL}${e}`);
|
50
|
-
}
|
51
|
-
await orm.close(true);
|
52
|
-
}
|
53
|
-
exports.run = run;
|
54
|
-
async function createPriceSets(manager, data) {
|
55
|
-
const priceSets = data.map((priceSetData) => {
|
56
|
-
return manager.create(PricingModels.PriceSet, priceSetData);
|
57
|
-
});
|
58
|
-
await manager.persistAndFlush(priceSets);
|
59
|
-
return priceSets;
|
60
|
-
}
|
61
|
-
async function createPrices(manager, data) {
|
62
|
-
const prices = data.map((priceData) => {
|
63
|
-
return manager.create(PricingModels.Price, priceData);
|
64
|
-
});
|
65
|
-
await manager.persistAndFlush(prices);
|
66
|
-
return prices;
|
67
|
-
}
|
@@ -1,16 +0,0 @@
|
|
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 {};
|
@@ -1,34 +0,0 @@
|
|
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,15 +0,0 @@
|
|
1
|
-
import { Context, DAL, PricingTypes } from "@medusajs/types";
|
2
|
-
import { RuleType } from "../models";
|
3
|
-
type InjectedDependencies = {
|
4
|
-
ruleTypeRepository: DAL.RepositoryService;
|
5
|
-
};
|
6
|
-
declare const RuleTypeService_base: new <TEntity_1 extends object = any>(container: InjectedDependencies) => import("@medusajs/types").InternalModuleService<TEntity_1, InjectedDependencies>;
|
7
|
-
export default class RuleTypeService<TEntity extends RuleType = RuleType> extends RuleTypeService_base<TEntity> {
|
8
|
-
protected readonly ruleTypeRepository_: DAL.RepositoryService<TEntity>;
|
9
|
-
constructor({ ruleTypeRepository }: InjectedDependencies);
|
10
|
-
create(data: PricingTypes.CreateRuleTypeDTO, sharedContext: Context): Promise<TEntity>;
|
11
|
-
create(data: PricingTypes.CreateRuleTypeDTO[], sharedContext: Context): Promise<TEntity[]>;
|
12
|
-
update(data: PricingTypes.UpdateRuleTypeDTO[], sharedContext: Context): Promise<TEntity[]>;
|
13
|
-
update(data: PricingTypes.UpdateRuleTypeDTO, sharedContext: Context): Promise<TEntity>;
|
14
|
-
}
|
15
|
-
export {};
|
@@ -1,53 +0,0 @@
|
|
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 utils_1 = require("@medusajs/utils");
|
16
|
-
const _models_1 = require("../models");
|
17
|
-
class RuleTypeService extends utils_1.ModulesSdkUtils.internalModuleServiceFactory(_models_1.RuleType) {
|
18
|
-
constructor({ ruleTypeRepository }) {
|
19
|
-
// @ts-ignore
|
20
|
-
super(...arguments);
|
21
|
-
this.ruleTypeRepository_ = ruleTypeRepository;
|
22
|
-
}
|
23
|
-
async create(data, sharedContext = {}) {
|
24
|
-
const data_ = Array.isArray(data) ? data : [data];
|
25
|
-
(0, utils_1.validateRuleAttributes)(data_.map((d) => d.rule_attribute));
|
26
|
-
return await super.create(data, sharedContext);
|
27
|
-
}
|
28
|
-
// TODO: add support for selector? and then rm ts ignore
|
29
|
-
// @ts-ignore
|
30
|
-
async update(data, sharedContext = {}) {
|
31
|
-
const data_ = Array.isArray(data) ? data : [data];
|
32
|
-
(0, utils_1.validateRuleAttributes)(data_.map((d) => d.rule_attribute));
|
33
|
-
return await super.update(data, sharedContext);
|
34
|
-
}
|
35
|
-
}
|
36
|
-
exports.default = RuleTypeService;
|
37
|
-
__decorate([
|
38
|
-
(0, utils_1.InjectTransactionManager)("ruleTypeRepository_"),
|
39
|
-
__param(1, (0, utils_1.MedusaContext)()),
|
40
|
-
__metadata("design:type", Function),
|
41
|
-
__metadata("design:paramtypes", [Object, Object]),
|
42
|
-
__metadata("design:returntype", Promise)
|
43
|
-
], RuleTypeService.prototype, "create", null);
|
44
|
-
__decorate([
|
45
|
-
(0, utils_1.InjectTransactionManager)("ruleTypeRepository_")
|
46
|
-
// TODO: add support for selector? and then rm ts ignore
|
47
|
-
// @ts-ignore
|
48
|
-
,
|
49
|
-
__param(1, (0, utils_1.MedusaContext)()),
|
50
|
-
__metadata("design:type", Function),
|
51
|
-
__metadata("design:paramtypes", [Object, Object]),
|
52
|
-
__metadata("design:returntype", Promise)
|
53
|
-
], RuleTypeService.prototype, "update", null);
|
@@ -1,18 +0,0 @@
|
|
1
|
-
import { PriceListStatus, PriceListType } from "@medusajs/utils";
|
2
|
-
export interface CreatePriceListDTO {
|
3
|
-
title: string;
|
4
|
-
description: string;
|
5
|
-
starts_at?: string | null;
|
6
|
-
ends_at?: string | null;
|
7
|
-
status?: PriceListStatus;
|
8
|
-
type?: PriceListType;
|
9
|
-
number_rules?: number;
|
10
|
-
}
|
11
|
-
export interface UpdatePriceListDTO {
|
12
|
-
id: string;
|
13
|
-
title?: string;
|
14
|
-
starts_at?: string | null;
|
15
|
-
ends_at?: string | null;
|
16
|
-
status?: PriceListStatus;
|
17
|
-
number_rules?: number;
|
18
|
-
}
|