@medusajs/pricing 0.1.13-snapshot-20240718073308 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +6 -6
- package/dist/index.js +9 -5
- package/dist/initialize/index.d.ts +4 -0
- package/dist/initialize/index.js +17 -0
- package/dist/joiner-config.d.ts +10 -2
- package/dist/joiner-config.js +52 -4
- package/dist/loaders/connection.d.ts +4 -0
- package/dist/loaders/connection.js +40 -0
- package/dist/loaders/container.d.ts +2 -0
- package/dist/loaders/container.js +34 -0
- package/dist/loaders/index.d.ts +2 -0
- package/dist/loaders/index.js +18 -0
- package/dist/migrations/Migration20230929122253.d.ts +0 -1
- package/dist/migrations/Migration20240322094407.d.ts +0 -1
- package/dist/migrations/Migration20240322113359.d.ts +0 -1
- package/dist/migrations/Migration20240322120125.d.ts +0 -1
- package/dist/models/index.d.ts +3 -2
- package/dist/models/index.js +7 -3
- package/dist/models/price-list-rule-value.d.ts +17 -0
- package/dist/models/price-list-rule-value.js +102 -0
- package/dist/models/price-list-rule.d.ts +8 -6
- package/dist/models/price-list-rule.js +29 -8
- package/dist/models/price-list.d.ts +3 -2
- package/dist/models/price-list.js +9 -0
- package/dist/models/price-rule.d.ts +9 -5
- package/dist/models/price-rule.js +45 -6
- package/dist/models/price-set-rule-type.d.ts +10 -0
- package/dist/models/price-set-rule-type.js +108 -0
- package/dist/models/price-set.d.ts +4 -1
- package/dist/models/price-set.js +19 -0
- package/dist/models/price.d.ts +4 -5
- package/dist/models/price.js +5 -5
- package/dist/models/rule-type.d.ts +17 -0
- package/dist/models/{price-preference.js → rule-type.js} +40 -35
- package/dist/module-definition.d.ts +4 -0
- package/dist/module-definition.js +50 -0
- package/dist/repositories/index.d.ts +0 -1
- package/dist/repositories/pricing.d.ts +0 -1
- package/dist/repositories/pricing.js +36 -29
- package/dist/schema/index.d.ts +0 -1
- package/dist/scripts/bin/run-seed.d.ts +3 -0
- package/dist/scripts/bin/run-seed.js +38 -0
- package/dist/scripts/seed.d.ts +4 -0
- package/dist/scripts/seed.js +67 -0
- package/dist/services/index.d.ts +2 -1
- package/dist/services/index.js +5 -1
- package/dist/services/price-list.d.ts +16 -0
- package/dist/services/price-list.js +34 -0
- package/dist/services/pricing-module.d.ts +53 -66
- package/dist/services/pricing-module.js +605 -594
- package/dist/services/rule-type.d.ts +15 -0
- package/dist/services/rule-type.js +53 -0
- package/dist/types/index.d.ts +0 -1
- package/dist/types/services/index.d.ts +2 -30
- package/dist/types/services/index.js +16 -0
- package/dist/types/services/price-list.d.ts +18 -0
- package/dist/types/services/price-list.js +2 -0
- package/dist/types/services/price-set.d.ts +4 -0
- package/dist/types/services/price-set.js +2 -0
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.js +0 -1
- package/dist/utils/validate-price-list-dates.d.ts +0 -1
- package/package.json +13 -8
- package/dist/index.d.ts.map +0 -1
- package/dist/joiner-config.d.ts.map +0 -1
- package/dist/migrations/Migration20230929122253.d.ts.map +0 -1
- package/dist/migrations/Migration20240322094407.d.ts.map +0 -1
- package/dist/migrations/Migration20240322113359.d.ts.map +0 -1
- package/dist/migrations/Migration20240322120125.d.ts.map +0 -1
- package/dist/migrations/Migration20240626133555.d.ts +0 -5
- package/dist/migrations/Migration20240626133555.d.ts.map +0 -1
- package/dist/migrations/Migration20240626133555.js +0 -33
- package/dist/migrations/Migration20240704094505.d.ts +0 -6
- package/dist/migrations/Migration20240704094505.d.ts.map +0 -1
- package/dist/migrations/Migration20240704094505.js +0 -15
- package/dist/models/index.d.ts.map +0 -1
- package/dist/models/price-list-rule.d.ts.map +0 -1
- package/dist/models/price-list.d.ts.map +0 -1
- package/dist/models/price-preference.d.ts +0 -13
- package/dist/models/price-preference.d.ts.map +0 -1
- package/dist/models/price-rule.d.ts.map +0 -1
- package/dist/models/price-set.d.ts.map +0 -1
- package/dist/models/price.d.ts.map +0 -1
- package/dist/repositories/index.d.ts.map +0 -1
- package/dist/repositories/pricing.d.ts.map +0 -1
- package/dist/schema/index.d.ts.map +0 -1
- package/dist/services/index.d.ts.map +0 -1
- package/dist/services/pricing-module.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/services/index.d.ts.map +0 -1
- package/dist/utils/events.d.ts +0 -63
- package/dist/utils/events.d.ts.map +0 -1
- package/dist/utils/events.js +0 -66
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/validate-price-list-dates.d.ts.map +0 -1
package/dist/index.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
export
|
1
|
+
import { moduleDefinition, revertMigration, runMigrations } from "./module-definition";
|
2
|
+
export default moduleDefinition;
|
3
|
+
export { revertMigration, runMigrations };
|
4
|
+
export * from "./initialize";
|
5
|
+
export * from "./models";
|
6
|
+
export * from "./services";
|
6
7
|
export * from "./types";
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
@@ -14,9 +14,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
15
|
};
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
-
|
18
|
-
const
|
19
|
-
exports
|
20
|
-
|
21
|
-
|
17
|
+
exports.runMigrations = exports.revertMigration = void 0;
|
18
|
+
const module_definition_1 = require("./module-definition");
|
19
|
+
Object.defineProperty(exports, "revertMigration", { enumerable: true, get: function () { return module_definition_1.revertMigration; } });
|
20
|
+
Object.defineProperty(exports, "runMigrations", { enumerable: true, get: function () { return module_definition_1.runMigrations; } });
|
21
|
+
exports.default = module_definition_1.moduleDefinition;
|
22
|
+
__exportStar(require("./initialize"), exports);
|
23
|
+
// TODO: remove export from models and services
|
24
|
+
__exportStar(require("./models"), exports);
|
25
|
+
__exportStar(require("./services"), exports);
|
22
26
|
__exportStar(require("./types"), exports);
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { ExternalModuleDeclaration, InternalModuleDeclaration } from "@medusajs/modules-sdk";
|
2
|
+
import { IPricingModuleService, ModulesSdkTypes } from "@medusajs/types";
|
3
|
+
import { InitializeModuleInjectableDependencies } from "../types";
|
4
|
+
export declare const initialize: (options?: ModulesSdkTypes.ModuleServiceInitializeOptions | ModulesSdkTypes.ModuleServiceInitializeCustomDataLayerOptions | ExternalModuleDeclaration | InternalModuleDeclaration, injectedDependencies?: InitializeModuleInjectableDependencies) => Promise<IPricingModuleService>;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.initialize = void 0;
|
4
|
+
const modules_sdk_1 = require("@medusajs/modules-sdk");
|
5
|
+
const module_definition_1 = require("../module-definition");
|
6
|
+
const initialize = async (options, injectedDependencies) => {
|
7
|
+
const serviceKey = modules_sdk_1.Modules.PRICING;
|
8
|
+
const loaded = await modules_sdk_1.MedusaModule.bootstrap({
|
9
|
+
moduleKey: serviceKey,
|
10
|
+
defaultPath: modules_sdk_1.MODULE_PACKAGE_NAMES[modules_sdk_1.Modules.PRICING],
|
11
|
+
declaration: options,
|
12
|
+
injectedDependencies,
|
13
|
+
moduleExports: module_definition_1.moduleDefinition,
|
14
|
+
});
|
15
|
+
return loaded[serviceKey];
|
16
|
+
};
|
17
|
+
exports.initialize = initialize;
|
package/dist/joiner-config.d.ts
CHANGED
@@ -1,2 +1,10 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
import { ModuleJoinerConfig } from "@medusajs/types";
|
2
|
+
import { MapToConfig } from "@medusajs/utils";
|
3
|
+
export declare const LinkableKeys: {
|
4
|
+
price_set_id: string;
|
5
|
+
price_list_id: string;
|
6
|
+
price_id: string;
|
7
|
+
rule_type_id: string;
|
8
|
+
};
|
9
|
+
export declare const entityNameToLinkableKeysMap: MapToConfig;
|
10
|
+
export declare const joinerConfig: ModuleJoinerConfig;
|
package/dist/joiner-config.js
CHANGED
@@ -1,8 +1,56 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.joinerConfig = void 0;
|
4
|
-
const
|
6
|
+
exports.joinerConfig = exports.entityNameToLinkableKeysMap = exports.LinkableKeys = void 0;
|
7
|
+
const modules_sdk_1 = require("@medusajs/modules-sdk");
|
5
8
|
const _models_1 = require("./models");
|
6
|
-
|
7
|
-
|
9
|
+
const schema_1 = __importDefault(require("./schema"));
|
10
|
+
exports.LinkableKeys = {
|
11
|
+
price_set_id: _models_1.PriceSet.name,
|
12
|
+
price_list_id: _models_1.PriceList.name,
|
13
|
+
price_id: _models_1.Price.name,
|
14
|
+
rule_type_id: _models_1.RuleType.name,
|
15
|
+
};
|
16
|
+
const entityLinkableKeysMap = {};
|
17
|
+
Object.entries(exports.LinkableKeys).forEach(([key, value]) => {
|
18
|
+
entityLinkableKeysMap[value] ?? (entityLinkableKeysMap[value] = []);
|
19
|
+
entityLinkableKeysMap[value].push({
|
20
|
+
mapTo: key,
|
21
|
+
valueFrom: key.split("_").pop(),
|
22
|
+
});
|
8
23
|
});
|
24
|
+
exports.entityNameToLinkableKeysMap = entityLinkableKeysMap;
|
25
|
+
exports.joinerConfig = {
|
26
|
+
serviceName: modules_sdk_1.Modules.PRICING,
|
27
|
+
primaryKeys: ["id"],
|
28
|
+
linkableKeys: exports.LinkableKeys,
|
29
|
+
schema: schema_1.default,
|
30
|
+
alias: [
|
31
|
+
{
|
32
|
+
name: ["price_set", "price_sets"],
|
33
|
+
args: {
|
34
|
+
entity: "PriceSet",
|
35
|
+
},
|
36
|
+
},
|
37
|
+
{
|
38
|
+
name: ["price_list", "price_lists"],
|
39
|
+
args: {
|
40
|
+
methodSuffix: "PriceLists",
|
41
|
+
},
|
42
|
+
},
|
43
|
+
{
|
44
|
+
name: ["price", "prices"],
|
45
|
+
args: {
|
46
|
+
methodSuffix: "Prices",
|
47
|
+
},
|
48
|
+
},
|
49
|
+
{
|
50
|
+
name: ["rule_type", "rule_types"],
|
51
|
+
args: {
|
52
|
+
methodSuffix: "RuleTypes",
|
53
|
+
},
|
54
|
+
},
|
55
|
+
],
|
56
|
+
};
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { InternalModuleDeclaration, LoaderOptions } from "@medusajs/modules-sdk";
|
2
|
+
import { ModulesSdkTypes } from "@medusajs/types";
|
3
|
+
declare const _default: ({ options, container, logger, }: LoaderOptions<ModulesSdkTypes.ModuleServiceInitializeOptions | ModulesSdkTypes.ModuleServiceInitializeCustomDataLayerOptions>, moduleDeclaration?: InternalModuleDeclaration) => Promise<void>;
|
4
|
+
export default _default;
|
@@ -0,0 +1,40 @@
|
|
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
|
+
const utils_1 = require("@medusajs/utils");
|
27
|
+
const PricingModels = __importStar(require("../models"));
|
28
|
+
exports.default = async ({ options, container, logger, }, moduleDeclaration) => {
|
29
|
+
const entities = Object.values(PricingModels);
|
30
|
+
const pathToMigrations = __dirname + "/../migrations";
|
31
|
+
await utils_1.ModulesSdkUtils.mikroOrmConnectionLoader({
|
32
|
+
moduleName: "pricing",
|
33
|
+
entities,
|
34
|
+
container,
|
35
|
+
options,
|
36
|
+
moduleDeclaration,
|
37
|
+
logger,
|
38
|
+
pathToMigrations,
|
39
|
+
});
|
40
|
+
};
|
@@ -0,0 +1,34 @@
|
|
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
|
+
const utils_1 = require("@medusajs/utils");
|
27
|
+
const ModuleModels = __importStar(require("../models"));
|
28
|
+
const ModuleRepositories = __importStar(require("../repositories"));
|
29
|
+
const ModuleServices = __importStar(require("../services"));
|
30
|
+
exports.default = utils_1.ModulesSdkUtils.moduleContainerLoaderFactory({
|
31
|
+
moduleModels: ModuleModels,
|
32
|
+
moduleRepositories: ModuleRepositories,
|
33
|
+
moduleServices: ModuleServices,
|
34
|
+
});
|
@@ -0,0 +1,18 @@
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./connection"), exports);
|
18
|
+
__exportStar(require("./container"), exports);
|
package/dist/models/index.d.ts
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
export { default as Price } from "./price";
|
2
2
|
export { default as PriceList } from "./price-list";
|
3
3
|
export { default as PriceListRule } from "./price-list-rule";
|
4
|
+
export { default as PriceListRuleValue } from "./price-list-rule-value";
|
4
5
|
export { default as PriceRule } from "./price-rule";
|
5
6
|
export { default as PriceSet } from "./price-set";
|
6
|
-
export { default as
|
7
|
-
|
7
|
+
export { default as PriceSetRuleType } from "./price-set-rule-type";
|
8
|
+
export { default as RuleType } from "./rule-type";
|
package/dist/models/index.js
CHANGED
@@ -3,16 +3,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.
|
6
|
+
exports.RuleType = exports.PriceSetRuleType = exports.PriceSet = exports.PriceRule = exports.PriceListRuleValue = exports.PriceListRule = exports.PriceList = exports.Price = void 0;
|
7
7
|
var price_1 = require("./price");
|
8
8
|
Object.defineProperty(exports, "Price", { enumerable: true, get: function () { return __importDefault(price_1).default; } });
|
9
9
|
var price_list_1 = require("./price-list");
|
10
10
|
Object.defineProperty(exports, "PriceList", { enumerable: true, get: function () { return __importDefault(price_list_1).default; } });
|
11
11
|
var price_list_rule_1 = require("./price-list-rule");
|
12
12
|
Object.defineProperty(exports, "PriceListRule", { enumerable: true, get: function () { return __importDefault(price_list_rule_1).default; } });
|
13
|
+
var price_list_rule_value_1 = require("./price-list-rule-value");
|
14
|
+
Object.defineProperty(exports, "PriceListRuleValue", { enumerable: true, get: function () { return __importDefault(price_list_rule_value_1).default; } });
|
13
15
|
var price_rule_1 = require("./price-rule");
|
14
16
|
Object.defineProperty(exports, "PriceRule", { enumerable: true, get: function () { return __importDefault(price_rule_1).default; } });
|
15
17
|
var price_set_1 = require("./price-set");
|
16
18
|
Object.defineProperty(exports, "PriceSet", { enumerable: true, get: function () { return __importDefault(price_set_1).default; } });
|
17
|
-
var
|
18
|
-
Object.defineProperty(exports, "
|
19
|
+
var price_set_rule_type_1 = require("./price-set-rule-type");
|
20
|
+
Object.defineProperty(exports, "PriceSetRuleType", { enumerable: true, get: function () { return __importDefault(price_set_rule_type_1).default; } });
|
21
|
+
var rule_type_1 = require("./rule-type");
|
22
|
+
Object.defineProperty(exports, "RuleType", { enumerable: true, get: function () { return __importDefault(rule_type_1).default; } });
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { DAL } from "@medusajs/types";
|
2
|
+
import { OptionalProps } from "@mikro-orm/core";
|
3
|
+
import PriceListRule from "./price-list-rule";
|
4
|
+
type OptionalFields = DAL.SoftDeletableEntityDateColumns;
|
5
|
+
export default class PriceListRuleValue {
|
6
|
+
[OptionalProps]?: OptionalFields;
|
7
|
+
id: string;
|
8
|
+
price_list_rule_id: string;
|
9
|
+
price_list_rule: PriceListRule;
|
10
|
+
value: string;
|
11
|
+
created_at: Date;
|
12
|
+
updated_at: Date;
|
13
|
+
deleted_at: Date | null;
|
14
|
+
onCreate(): void;
|
15
|
+
onInit(): void;
|
16
|
+
}
|
17
|
+
export {};
|
@@ -0,0 +1,102 @@
|
|
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,14 +1,17 @@
|
|
1
1
|
import { DAL } from "@medusajs/types";
|
2
|
-
import {
|
2
|
+
import { Collection, OptionalProps } from "@mikro-orm/core";
|
3
3
|
import PriceList from "./price-list";
|
4
|
-
|
4
|
+
import PriceListRuleValue from "./price-list-rule-value";
|
5
|
+
import RuleType from "./rule-type";
|
6
|
+
type OptionalFields = DAL.SoftDeletableEntityDateColumns;
|
5
7
|
export default class PriceListRule {
|
6
8
|
[OptionalProps]: OptionalFields;
|
7
9
|
id: string;
|
8
|
-
|
9
|
-
|
10
|
+
rule_type_id: string;
|
11
|
+
rule_type: RuleType;
|
12
|
+
price_list_rule_values: Collection<PriceListRuleValue, object>;
|
10
13
|
price_list_id: string;
|
11
|
-
price_list:
|
14
|
+
price_list: PriceList;
|
12
15
|
created_at: Date;
|
13
16
|
updated_at: Date;
|
14
17
|
deleted_at: Date | null;
|
@@ -16,4 +19,3 @@ export default class PriceListRule {
|
|
16
19
|
onInit(): void;
|
17
20
|
}
|
18
21
|
export {};
|
19
|
-
//# sourceMappingURL=price-list-rule.d.ts.map
|
@@ -15,12 +15,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const utils_1 = require("@medusajs/utils");
|
16
16
|
const core_1 = require("@mikro-orm/core");
|
17
17
|
const price_list_1 = __importDefault(require("./price-list"));
|
18
|
+
const price_list_rule_value_1 = __importDefault(require("./price-list-rule-value"));
|
19
|
+
const rule_type_1 = __importDefault(require("./rule-type"));
|
18
20
|
const tableName = "price_list_rule";
|
19
21
|
const PriceListRuleDeletedAtIndex = (0, utils_1.createPsqlIndexStatementHelper)({
|
20
22
|
tableName: tableName,
|
21
23
|
columns: "deleted_at",
|
22
24
|
where: "deleted_at IS NOT NULL",
|
23
25
|
});
|
26
|
+
const PriceListRuleRuleTypeIdIndex = (0, utils_1.createPsqlIndexStatementHelper)({
|
27
|
+
tableName: tableName,
|
28
|
+
columns: "rule_type_id",
|
29
|
+
where: "deleted_at IS NULL",
|
30
|
+
unique: true,
|
31
|
+
});
|
24
32
|
const PriceListRulePriceListIdIndex = (0, utils_1.createPsqlIndexStatementHelper)({
|
25
33
|
tableName: tableName,
|
26
34
|
columns: "price_list_id",
|
@@ -28,16 +36,18 @@ const PriceListRulePriceListIdIndex = (0, utils_1.createPsqlIndexStatementHelper
|
|
28
36
|
});
|
29
37
|
let PriceListRule = class PriceListRule {
|
30
38
|
constructor() {
|
31
|
-
this.
|
39
|
+
this.price_list_rule_values = new core_1.Collection(this);
|
32
40
|
this.deleted_at = null;
|
33
41
|
}
|
34
42
|
beforeCreate() {
|
35
43
|
this.id = (0, utils_1.generateEntityId)(this.id, "plrule");
|
36
|
-
this.price_list_id
|
44
|
+
this.price_list_id ?? (this.price_list_id = this.price_list?.id);
|
45
|
+
this.rule_type_id ?? (this.rule_type_id = this.rule_type?.id);
|
37
46
|
}
|
38
47
|
onInit() {
|
39
48
|
this.id = (0, utils_1.generateEntityId)(this.id, "plrule");
|
40
|
-
this.price_list_id
|
49
|
+
this.price_list_id ?? (this.price_list_id = this.price_list?.id);
|
50
|
+
this.rule_type_id ?? (this.rule_type_id = this.rule_type?.id);
|
41
51
|
}
|
42
52
|
};
|
43
53
|
__decorate([
|
@@ -45,13 +55,24 @@ __decorate([
|
|
45
55
|
__metadata("design:type", String)
|
46
56
|
], PriceListRule.prototype, "id", void 0);
|
47
57
|
__decorate([
|
48
|
-
|
58
|
+
PriceListRuleRuleTypeIdIndex.MikroORMIndex(),
|
59
|
+
(0, core_1.ManyToOne)(() => rule_type_1.default, {
|
60
|
+
columnType: "text",
|
61
|
+
mapToPk: true,
|
62
|
+
fieldName: "rule_type_id",
|
63
|
+
}),
|
49
64
|
__metadata("design:type", String)
|
50
|
-
], PriceListRule.prototype, "
|
65
|
+
], PriceListRule.prototype, "rule_type_id", void 0);
|
66
|
+
__decorate([
|
67
|
+
(0, core_1.ManyToOne)(() => rule_type_1.default, { persist: false }),
|
68
|
+
__metadata("design:type", rule_type_1.default)
|
69
|
+
], PriceListRule.prototype, "rule_type", void 0);
|
51
70
|
__decorate([
|
52
|
-
(0, core_1.
|
71
|
+
(0, core_1.OneToMany)(() => price_list_rule_value_1.default, (plrv) => plrv.price_list_rule, {
|
72
|
+
cascade: [core_1.Cascade.PERSIST, "soft-remove"],
|
73
|
+
}),
|
53
74
|
__metadata("design:type", Object)
|
54
|
-
], PriceListRule.prototype, "
|
75
|
+
], PriceListRule.prototype, "price_list_rule_values", void 0);
|
55
76
|
__decorate([
|
56
77
|
PriceListRulePriceListIdIndex.MikroORMIndex(),
|
57
78
|
(0, core_1.ManyToOne)(() => price_list_1.default, {
|
@@ -64,7 +85,7 @@ __decorate([
|
|
64
85
|
], PriceListRule.prototype, "price_list_id", void 0);
|
65
86
|
__decorate([
|
66
87
|
(0, core_1.ManyToOne)(() => price_list_1.default, { persist: false }),
|
67
|
-
__metadata("design:type",
|
88
|
+
__metadata("design:type", price_list_1.default)
|
68
89
|
], PriceListRule.prototype, "price_list", void 0);
|
69
90
|
__decorate([
|
70
91
|
(0, core_1.Property)({
|
@@ -3,7 +3,8 @@ import { PriceListStatus, PriceListType } from "@medusajs/utils";
|
|
3
3
|
import { Collection, OptionalProps } from "@mikro-orm/core";
|
4
4
|
import Price from "./price";
|
5
5
|
import PriceListRule from "./price-list-rule";
|
6
|
-
|
6
|
+
import RuleType from "./rule-type";
|
7
|
+
type OptionalFields = "starts_at" | "ends_at" | DAL.SoftDeletableEntityDateColumns;
|
7
8
|
export declare const PriceListIdPrefix = "plist";
|
8
9
|
export default class PriceList {
|
9
10
|
[OptionalProps]: OptionalFields;
|
@@ -16,6 +17,7 @@ export default class PriceList {
|
|
16
17
|
ends_at: Date | null;
|
17
18
|
prices: Collection<Price, object>;
|
18
19
|
price_list_rules: Collection<PriceListRule, object>;
|
20
|
+
rule_types: Collection<RuleType, object>;
|
19
21
|
rules_count: number;
|
20
22
|
created_at: Date;
|
21
23
|
updated_at: Date;
|
@@ -24,4 +26,3 @@ export default class PriceList {
|
|
24
26
|
onInit(): void;
|
25
27
|
}
|
26
28
|
export {};
|
27
|
-
//# sourceMappingURL=price-list.d.ts.map
|
@@ -17,6 +17,7 @@ const utils_1 = require("@medusajs/utils");
|
|
17
17
|
const core_1 = require("@mikro-orm/core");
|
18
18
|
const price_1 = __importDefault(require("./price"));
|
19
19
|
const price_list_rule_1 = __importDefault(require("./price-list-rule"));
|
20
|
+
const rule_type_1 = __importDefault(require("./rule-type"));
|
20
21
|
const tableName = "price_list";
|
21
22
|
const PriceListDeletedAtIndex = (0, utils_1.createPsqlIndexStatementHelper)({
|
22
23
|
tableName: tableName,
|
@@ -30,6 +31,7 @@ let PriceList = class PriceList {
|
|
30
31
|
this.ends_at = null;
|
31
32
|
this.prices = new core_1.Collection(this);
|
32
33
|
this.price_list_rules = new core_1.Collection(this);
|
34
|
+
this.rule_types = new core_1.Collection(this);
|
33
35
|
this.rules_count = 0;
|
34
36
|
this.deleted_at = null;
|
35
37
|
}
|
@@ -88,6 +90,13 @@ __decorate([
|
|
88
90
|
}),
|
89
91
|
__metadata("design:type", Object)
|
90
92
|
], PriceList.prototype, "price_list_rules", void 0);
|
93
|
+
__decorate([
|
94
|
+
(0, core_1.ManyToMany)({
|
95
|
+
entity: () => rule_type_1.default,
|
96
|
+
pivotEntity: () => price_list_rule_1.default,
|
97
|
+
}),
|
98
|
+
__metadata("design:type", Object)
|
99
|
+
], PriceList.prototype, "rule_types", void 0);
|
91
100
|
__decorate([
|
92
101
|
(0, core_1.Property)({ columnType: "integer", default: 0 }),
|
93
102
|
__metadata("design:type", Number)
|
@@ -1,15 +1,20 @@
|
|
1
1
|
import { DAL } from "@medusajs/types";
|
2
|
-
import { OptionalProps
|
2
|
+
import { OptionalProps } from "@mikro-orm/core";
|
3
3
|
import Price from "./price";
|
4
|
-
|
4
|
+
import PriceSet from "./price-set";
|
5
|
+
import RuleType from "./rule-type";
|
6
|
+
type OptionalFields = DAL.SoftDeletableEntityDateColumns;
|
5
7
|
export default class PriceRule {
|
6
8
|
[OptionalProps]?: OptionalFields;
|
7
9
|
id: string;
|
8
|
-
|
10
|
+
price_set_id: string;
|
11
|
+
price_set: PriceSet;
|
12
|
+
rule_type_id: string;
|
13
|
+
rule_type: RuleType;
|
9
14
|
value: string;
|
10
15
|
priority: number;
|
11
16
|
price_id: string;
|
12
|
-
price:
|
17
|
+
price: Price;
|
13
18
|
created_at: Date;
|
14
19
|
updated_at: Date;
|
15
20
|
deleted_at: Date | null;
|
@@ -17,4 +22,3 @@ export default class PriceRule {
|
|
17
22
|
onInit(): void;
|
18
23
|
}
|
19
24
|
export {};
|
20
|
-
//# sourceMappingURL=price-rule.d.ts.map
|