@medusajs/pricing 0.1.13-snapshot-20240718083016 → 0.1.13-snapshot-20240719080828
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 +5 -9
- package/dist/joiner-config.d.ts +2 -10
- package/dist/joiner-config.d.ts.map +1 -0
- package/dist/joiner-config.js +4 -52
- package/dist/migrations/Migration20230929122253.d.ts +1 -0
- package/dist/migrations/Migration20230929122253.d.ts.map +1 -0
- package/dist/migrations/Migration20240322094407.d.ts +1 -0
- package/dist/migrations/Migration20240322094407.d.ts.map +1 -0
- package/dist/migrations/Migration20240322113359.d.ts +1 -0
- package/dist/migrations/Migration20240322113359.d.ts.map +1 -0
- package/dist/migrations/Migration20240322120125.d.ts +1 -0
- package/dist/migrations/Migration20240322120125.d.ts.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 +33 -0
- package/dist/migrations/Migration20240704094505.d.ts +6 -0
- package/dist/migrations/Migration20240704094505.d.ts.map +1 -0
- package/dist/migrations/Migration20240704094505.js +15 -0
- package/dist/models/index.d.ts +2 -3
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +3 -7
- package/dist/models/price-list-rule.d.ts +6 -8
- package/dist/models/price-list-rule.d.ts.map +1 -0
- package/dist/models/price-list-rule.js +8 -29
- package/dist/models/price-list.d.ts +2 -3
- package/dist/models/price-list.d.ts.map +1 -0
- package/dist/models/price-list.js +0 -9
- 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} +35 -40
- package/dist/models/price-rule.d.ts +5 -9
- package/dist/models/price-rule.d.ts.map +1 -0
- package/dist/models/price-rule.js +6 -45
- 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 +0 -19
- package/dist/models/price.d.ts +5 -4
- package/dist/models/price.d.ts.map +1 -0
- package/dist/models/price.js +5 -5
- package/dist/repositories/index.d.ts +1 -0
- package/dist/repositories/index.d.ts.map +1 -0
- package/dist/repositories/pricing.d.ts +1 -0
- package/dist/repositories/pricing.d.ts.map +1 -0
- package/dist/repositories/pricing.js +29 -36
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/index.d.ts.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 +1 -5
- 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 +594 -605
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.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 +0 -16
- package/dist/utils/events.d.ts +63 -0
- package/dist/utils/events.d.ts.map +1 -0
- package/dist/utils/events.js +66 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +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/package.json +8 -13
- 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
package/dist/index.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
export
|
6
|
-
export * from "./services";
|
1
|
+
import { PricingModuleService } from "./services";
|
2
|
+
declare const _default: import("@medusajs/types").ModuleExports<typeof PricingModuleService> & {
|
3
|
+
linkable: Record<string, any>;
|
4
|
+
};
|
5
|
+
export default _default;
|
7
6
|
export * from "./types";
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;;;;AAEhD,wBAEE;AAEF,cAAc,SAAS,CAAA"}
|
package/dist/index.js
CHANGED
@@ -14,13 +14,9 @@ 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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
__exportStar(require("./initialize"), exports);
|
23
|
-
// TODO: remove export from models and services
|
24
|
-
__exportStar(require("./models"), exports);
|
25
|
-
__exportStar(require("./services"), exports);
|
17
|
+
const utils_1 = require("@medusajs/utils");
|
18
|
+
const _services_1 = require("./services");
|
19
|
+
exports.default = (0, utils_1.Module)(utils_1.Modules.PRICING, {
|
20
|
+
service: _services_1.PricingModuleService,
|
21
|
+
});
|
26
22
|
__exportStar(require("./types"), exports);
|
package/dist/joiner-config.d.ts
CHANGED
@@ -1,10 +1,2 @@
|
|
1
|
-
|
2
|
-
|
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;
|
1
|
+
export declare const joinerConfig: Omit<import("@medusajs/types").ModuleJoinerConfig, "serviceName" | "primaryKeys" | "alias" | "linkableKeys"> & Required<Pick<import("@medusajs/types").ModuleJoinerConfig, "serviceName" | "primaryKeys" | "alias" | "linkableKeys">>;
|
2
|
+
//# sourceMappingURL=joiner-config.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"joiner-config.d.ts","sourceRoot":"","sources":["../src/joiner-config.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY,uOAEvB,CAAA"}
|
package/dist/joiner-config.js
CHANGED
@@ -1,56 +1,8 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.joinerConfig =
|
7
|
-
const
|
3
|
+
exports.joinerConfig = void 0;
|
4
|
+
const utils_1 = require("@medusajs/utils");
|
8
5
|
const _models_1 = require("./models");
|
9
|
-
|
10
|
-
|
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
|
-
});
|
6
|
+
exports.joinerConfig = (0, utils_1.defineJoinerConfig)(utils_1.Modules.PRICING, {
|
7
|
+
models: [_models_1.PriceSet, _models_1.PriceList, _models_1.Price, _models_1.PricePreference],
|
23
8
|
});
|
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 @@
|
|
1
|
+
{"version":3,"file":"Migration20230929122253.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20230929122253.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,qBAAa,uBAAwB,SAAQ,SAAS;IAC9C,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;CAkO1B"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Migration20240322094407.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20240322094407.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,qBAAa,uBAAwB,SAAQ,SAAS;IAE9C,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAInB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAM5B"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Migration20240322113359.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20240322113359.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,qBAAa,uBAAwB,SAAQ,SAAS;IAC9C,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAcnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAa5B"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Migration20240322120125.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20240322120125.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,qBAAa,uBAAwB,SAAQ,SAAS;IAC9C,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAOnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ5B"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Migration20240626133555.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20240626133555.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,qBAAa,uBAAwB,SAAQ,SAAS;IAC9C,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;CAoE1B"}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Migration20240626133555 = void 0;
|
4
|
+
const migrations_1 = require("@mikro-orm/migrations");
|
5
|
+
class Migration20240626133555 extends migrations_1.Migration {
|
6
|
+
async up() {
|
7
|
+
this.addSql('alter table if exists "price_list_rule" add column if not exists "value" jsonb;');
|
8
|
+
// TODO: Added on 28.06.2024, Drop defaults after a while.
|
9
|
+
this.addSql('alter table if exists "price_list_rule" add column if not exists "attribute" text not null DEFAULT \'\';');
|
10
|
+
this.addSql('alter table if exists "price_rule" add column if not exists "attribute" text not null DEFAULT \'\';');
|
11
|
+
/* DATA MIGRATION */
|
12
|
+
this.addSql("update price_rule set attribute = (SELECT rule_attribute FROM rule_type WHERE rule_type.id = price_rule.rule_type_id);");
|
13
|
+
this.addSql("update price_list_rule set value = (SELECT array_to_json(ARRAY(SELECT value FROM price_list_rule_value WHERE price_list_rule_value.price_list_rule_id = price_list_rule.id))::jsonb);");
|
14
|
+
this.addSql("update price_list_rule set attribute = (SELECT rule_attribute FROM rule_type WHERE rule_type.id = price_list_rule.rule_type_id);");
|
15
|
+
/* DATA MIGRATION END */
|
16
|
+
this.addSql('alter table if exists "price_set_rule_type" drop constraint if exists "price_set_rule_type_rule_type_id_foreign";');
|
17
|
+
this.addSql('alter table if exists "price_rule" drop constraint if exists "price_rule_rule_type_id_foreign";');
|
18
|
+
this.addSql('alter table if exists "price_list_rule" drop constraint if exists "price_list_rule_rule_type_id_foreign";');
|
19
|
+
this.addSql('alter table if exists "price_rule" drop constraint if exists "price_rule_price_set_id_foreign";');
|
20
|
+
this.addSql('drop index if exists "IDX_price_list_rule_rule_type_id_unique";');
|
21
|
+
this.addSql('drop index if exists "IDX_price_rule_price_set_id";');
|
22
|
+
this.addSql('drop index if exists "IDX_price_rule_rule_type_id";');
|
23
|
+
this.addSql('drop index if exists "IDX_price_rule_price_id_unique";');
|
24
|
+
this.addSql('CREATE UNIQUE INDEX IF NOT EXISTS "IDX_price_rule_price_id_attribute_unique" ON "price_rule" (price_id, attribute) WHERE deleted_at IS NULL;');
|
25
|
+
this.addSql('alter table if exists "price_rule" drop column if exists "price_set_id";');
|
26
|
+
this.addSql('alter table if exists "price_rule" drop column if exists "rule_type_id";');
|
27
|
+
this.addSql('alter table if exists "price_list_rule" drop column if exists "rule_type_id";');
|
28
|
+
this.addSql('drop table if exists "rule_type" cascade;');
|
29
|
+
this.addSql('drop table if exists "price_set_rule_type" cascade;');
|
30
|
+
this.addSql('drop table if exists "price_list_rule_value" cascade;');
|
31
|
+
}
|
32
|
+
}
|
33
|
+
exports.Migration20240626133555 = Migration20240626133555;
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Migration20240704094505.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20240704094505.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,qBAAa,uBAAwB,SAAQ,SAAS;IAE9C,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAMnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAI5B"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Migration20240704094505 = void 0;
|
4
|
+
const migrations_1 = require("@mikro-orm/migrations");
|
5
|
+
class Migration20240704094505 extends migrations_1.Migration {
|
6
|
+
async up() {
|
7
|
+
this.addSql('create table if not exists "price_preference" ("id" text not null, "attribute" text not null, "value" text null, "is_tax_inclusive" boolean not null default false, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "price_preference_pkey" primary key ("id"));');
|
8
|
+
this.addSql('CREATE INDEX IF NOT EXISTS "IDX_price_preference_deleted_at" ON "price_preference" (deleted_at) WHERE deleted_at IS NOT NULL;');
|
9
|
+
this.addSql('CREATE UNIQUE INDEX IF NOT EXISTS "IDX_price_preference_attribute_value" ON "price_preference" (attribute, value) WHERE deleted_at IS NULL;');
|
10
|
+
}
|
11
|
+
async down() {
|
12
|
+
this.addSql('drop table if exists "price_preference" cascade;');
|
13
|
+
}
|
14
|
+
}
|
15
|
+
exports.Migration20240704094505 = Migration20240704094505;
|
package/dist/models/index.d.ts
CHANGED
@@ -1,8 +1,7 @@
|
|
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";
|
5
4
|
export { default as PriceRule } from "./price-rule";
|
6
5
|
export { default as PriceSet } from "./price-set";
|
7
|
-
export { default as
|
8
|
-
|
6
|
+
export { default as PricePreference } from "./price-preference";
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,oBAAoB,CAAA"}
|
package/dist/models/index.js
CHANGED
@@ -3,20 +3,16 @@ 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.PricePreference = exports.PriceSet = exports.PriceRule = 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; } });
|
15
13
|
var price_rule_1 = require("./price-rule");
|
16
14
|
Object.defineProperty(exports, "PriceRule", { enumerable: true, get: function () { return __importDefault(price_rule_1).default; } });
|
17
15
|
var price_set_1 = require("./price-set");
|
18
16
|
Object.defineProperty(exports, "PriceSet", { enumerable: true, get: function () { return __importDefault(price_set_1).default; } });
|
19
|
-
var
|
20
|
-
Object.defineProperty(exports, "
|
21
|
-
var rule_type_1 = require("./rule-type");
|
22
|
-
Object.defineProperty(exports, "RuleType", { enumerable: true, get: function () { return __importDefault(rule_type_1).default; } });
|
17
|
+
var price_preference_1 = require("./price-preference");
|
18
|
+
Object.defineProperty(exports, "PricePreference", { enumerable: true, get: function () { return __importDefault(price_preference_1).default; } });
|
@@ -1,17 +1,14 @@
|
|
1
1
|
import { DAL } from "@medusajs/types";
|
2
|
-
import {
|
2
|
+
import { OptionalProps, Rel } from "@mikro-orm/core";
|
3
3
|
import PriceList from "./price-list";
|
4
|
-
|
5
|
-
import RuleType from "./rule-type";
|
6
|
-
type OptionalFields = DAL.SoftDeletableEntityDateColumns;
|
4
|
+
type OptionalFields = DAL.SoftDeletableModelDateColumns;
|
7
5
|
export default class PriceListRule {
|
8
6
|
[OptionalProps]: OptionalFields;
|
9
7
|
id: string;
|
10
|
-
|
11
|
-
|
12
|
-
price_list_rule_values: Collection<PriceListRuleValue, object>;
|
8
|
+
attribute: string;
|
9
|
+
value: string | string[] | null;
|
13
10
|
price_list_id: string;
|
14
|
-
price_list: PriceList
|
11
|
+
price_list: Rel<PriceList>;
|
15
12
|
created_at: Date;
|
16
13
|
updated_at: Date;
|
17
14
|
deleted_at: Date | null;
|
@@ -19,3 +16,4 @@ export default class PriceListRule {
|
|
19
16
|
onInit(): void;
|
20
17
|
}
|
21
18
|
export {};
|
19
|
+
//# sourceMappingURL=price-list-rule.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"price-list-rule.d.ts","sourceRoot":"","sources":["../../src/models/price-list-rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAMrC,OAAO,EAML,aAAa,EAGb,GAAG,EACJ,MAAM,iBAAiB,CAAA;AACxB,OAAO,SAAS,MAAM,cAAc,CAAA;AAEpC,KAAK,cAAc,GAAG,GAAG,CAAC,6BAA6B,CAAA;AAiBvD,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC,CAAC,aAAa,CAAC,EAAE,cAAc,CAAA;IAG/B,EAAE,EAAG,MAAM,CAAA;IAGX,SAAS,EAAE,MAAM,CAAA;IAGjB,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAAO;IAStC,aAAa,EAAE,MAAM,CAAA;IAGrB,UAAU,EAAE,GAAG,CAAC,SAAS,CAAC,CAAA;IAO1B,UAAU,EAAE,IAAI,CAAA;IAQhB,UAAU,EAAE,IAAI,CAAA;IAIhB,UAAU,EAAE,IAAI,GAAG,IAAI,CAAO;IAG9B,YAAY;IAMZ,MAAM;CAIP"}
|
@@ -15,20 +15,12 @@ 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"));
|
20
18
|
const tableName = "price_list_rule";
|
21
19
|
const PriceListRuleDeletedAtIndex = (0, utils_1.createPsqlIndexStatementHelper)({
|
22
20
|
tableName: tableName,
|
23
21
|
columns: "deleted_at",
|
24
22
|
where: "deleted_at IS NOT NULL",
|
25
23
|
});
|
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
|
-
});
|
32
24
|
const PriceListRulePriceListIdIndex = (0, utils_1.createPsqlIndexStatementHelper)({
|
33
25
|
tableName: tableName,
|
34
26
|
columns: "price_list_id",
|
@@ -36,18 +28,16 @@ const PriceListRulePriceListIdIndex = (0, utils_1.createPsqlIndexStatementHelper
|
|
36
28
|
});
|
37
29
|
let PriceListRule = class PriceListRule {
|
38
30
|
constructor() {
|
39
|
-
this.
|
31
|
+
this.value = null;
|
40
32
|
this.deleted_at = null;
|
41
33
|
}
|
42
34
|
beforeCreate() {
|
43
35
|
this.id = (0, utils_1.generateEntityId)(this.id, "plrule");
|
44
|
-
this.price_list_id
|
45
|
-
this.rule_type_id ?? (this.rule_type_id = this.rule_type?.id);
|
36
|
+
this.price_list_id ??= this.price_list?.id;
|
46
37
|
}
|
47
38
|
onInit() {
|
48
39
|
this.id = (0, utils_1.generateEntityId)(this.id, "plrule");
|
49
|
-
this.price_list_id
|
50
|
-
this.rule_type_id ?? (this.rule_type_id = this.rule_type?.id);
|
40
|
+
this.price_list_id ??= this.price_list?.id;
|
51
41
|
}
|
52
42
|
};
|
53
43
|
__decorate([
|
@@ -55,24 +45,13 @@ __decorate([
|
|
55
45
|
__metadata("design:type", String)
|
56
46
|
], PriceListRule.prototype, "id", void 0);
|
57
47
|
__decorate([
|
58
|
-
|
59
|
-
(0, core_1.ManyToOne)(() => rule_type_1.default, {
|
60
|
-
columnType: "text",
|
61
|
-
mapToPk: true,
|
62
|
-
fieldName: "rule_type_id",
|
63
|
-
}),
|
48
|
+
(0, core_1.Property)({ columnType: "text" }),
|
64
49
|
__metadata("design:type", String)
|
65
|
-
], PriceListRule.prototype, "
|
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);
|
50
|
+
], PriceListRule.prototype, "attribute", void 0);
|
70
51
|
__decorate([
|
71
|
-
(0, core_1.
|
72
|
-
cascade: [core_1.Cascade.PERSIST, "soft-remove"],
|
73
|
-
}),
|
52
|
+
(0, core_1.Property)({ columnType: "jsonb", nullable: true }),
|
74
53
|
__metadata("design:type", Object)
|
75
|
-
], PriceListRule.prototype, "
|
54
|
+
], PriceListRule.prototype, "value", void 0);
|
76
55
|
__decorate([
|
77
56
|
PriceListRulePriceListIdIndex.MikroORMIndex(),
|
78
57
|
(0, core_1.ManyToOne)(() => price_list_1.default, {
|
@@ -85,7 +64,7 @@ __decorate([
|
|
85
64
|
], PriceListRule.prototype, "price_list_id", void 0);
|
86
65
|
__decorate([
|
87
66
|
(0, core_1.ManyToOne)(() => price_list_1.default, { persist: false }),
|
88
|
-
__metadata("design:type",
|
67
|
+
__metadata("design:type", Object)
|
89
68
|
], PriceListRule.prototype, "price_list", void 0);
|
90
69
|
__decorate([
|
91
70
|
(0, core_1.Property)({
|
@@ -3,8 +3,7 @@ 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
|
-
|
7
|
-
type OptionalFields = "starts_at" | "ends_at" | DAL.SoftDeletableEntityDateColumns;
|
6
|
+
type OptionalFields = "starts_at" | "ends_at" | DAL.SoftDeletableModelDateColumns;
|
8
7
|
export declare const PriceListIdPrefix = "plist";
|
9
8
|
export default class PriceList {
|
10
9
|
[OptionalProps]: OptionalFields;
|
@@ -17,7 +16,6 @@ export default class PriceList {
|
|
17
16
|
ends_at: Date | null;
|
18
17
|
prices: Collection<Price, object>;
|
19
18
|
price_list_rules: Collection<PriceListRule, object>;
|
20
|
-
rule_types: Collection<RuleType, object>;
|
21
19
|
rules_count: number;
|
22
20
|
created_at: Date;
|
23
21
|
updated_at: Date;
|
@@ -26,3 +24,4 @@ export default class PriceList {
|
|
26
24
|
onInit(): void;
|
27
25
|
}
|
28
26
|
export {};
|
27
|
+
//# sourceMappingURL=price-list.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"price-list.d.ts","sourceRoot":"","sources":["../../src/models/price-list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AACrC,OAAO,EAIL,eAAe,EACf,aAAa,EAEd,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAGL,UAAU,EAMV,aAAa,EAId,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,MAAM,SAAS,CAAA;AAC3B,OAAO,aAAa,MAAM,mBAAmB,CAAA;AAE7C,KAAK,cAAc,GACf,WAAW,GACX,SAAS,GACT,GAAG,CAAC,6BAA6B,CAAA;AASrC,eAAO,MAAM,iBAAiB,UAAU,CAAA;AAIxC,MAAM,CAAC,OAAO,OAAO,SAAS;IAC5B,CAAC,aAAa,CAAC,EAAE,cAAc,CAAA;IAG/B,EAAE,EAAG,MAAM,CAAA;IAIX,KAAK,EAAE,MAAM,CAAA;IAIb,WAAW,EAAE,MAAM,CAAA;IAGnB,MAAM,EAAE,eAAe,CAAA;IAGvB,IAAI,EAAE,aAAa,CAAA;IAMnB,SAAS,EAAE,IAAI,GAAG,IAAI,CAAO;IAM7B,OAAO,EAAE,IAAI,GAAG,IAAI,CAAO;IAK3B,MAAM,4BAAmC;IAKzC,gBAAgB,oCAA2C;IAG3D,WAAW,EAAE,MAAM,CAAI;IAOvB,UAAU,EAAE,IAAI,CAAA;IAQhB,UAAU,EAAE,IAAI,CAAA;IAIhB,UAAU,EAAE,IAAI,GAAG,IAAI,CAAO;IAG9B,QAAQ;IAKR,MAAM;CAGP"}
|
@@ -17,7 +17,6 @@ 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"));
|
21
20
|
const tableName = "price_list";
|
22
21
|
const PriceListDeletedAtIndex = (0, utils_1.createPsqlIndexStatementHelper)({
|
23
22
|
tableName: tableName,
|
@@ -31,7 +30,6 @@ let PriceList = class PriceList {
|
|
31
30
|
this.ends_at = null;
|
32
31
|
this.prices = new core_1.Collection(this);
|
33
32
|
this.price_list_rules = new core_1.Collection(this);
|
34
|
-
this.rule_types = new core_1.Collection(this);
|
35
33
|
this.rules_count = 0;
|
36
34
|
this.deleted_at = null;
|
37
35
|
}
|
@@ -90,13 +88,6 @@ __decorate([
|
|
90
88
|
}),
|
91
89
|
__metadata("design:type", Object)
|
92
90
|
], 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);
|
100
91
|
__decorate([
|
101
92
|
(0, core_1.Property)({ columnType: "integer", default: 0 }),
|
102
93
|
__metadata("design:type", Number)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
export declare const uniquePreferenceRuleIndexName = "IDX_price_preference_attribute_value";
|
2
|
+
export default class PricePreference {
|
3
|
+
id: string;
|
4
|
+
attribute: string;
|
5
|
+
value: string | null;
|
6
|
+
is_tax_inclusive: boolean;
|
7
|
+
created_at: Date;
|
8
|
+
updated_at: Date;
|
9
|
+
deleted_at: Date | null;
|
10
|
+
onCreate(): void;
|
11
|
+
onInit(): void;
|
12
|
+
}
|
13
|
+
//# sourceMappingURL=price-preference.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"price-preference.d.ts","sourceRoot":"","sources":["../../src/models/price-preference.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,6BAA6B,yCACF,CAAA;AAkBxC,MAAM,CAAC,OAAO,OAAO,eAAe;IAElC,EAAE,EAAE,MAAM,CAAA;IAGV,SAAS,EAAE,MAAM,CAAA;IAGjB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAO;IAG3B,gBAAgB,EAAE,OAAO,CAAA;IAOzB,UAAU,EAAE,IAAI,CAAA;IAQhB,UAAU,EAAE,IAAI,CAAA;IAIhB,UAAU,EAAE,IAAI,GAAG,IAAI,CAAO;IAG9B,QAAQ;IAKR,MAAM;CAGP"}
|
@@ -8,57 +8,51 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
10
10
|
};
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
-
};
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.uniquePreferenceRuleIndexName = void 0;
|
15
13
|
const utils_1 = require("@medusajs/utils");
|
16
14
|
const core_1 = require("@mikro-orm/core");
|
17
|
-
|
18
|
-
const
|
19
|
-
|
20
|
-
tableName:
|
15
|
+
exports.uniquePreferenceRuleIndexName = "IDX_price_preference_attribute_value";
|
16
|
+
const UniquePreferenceRuleIndexStatement = (0, utils_1.createPsqlIndexStatementHelper)({
|
17
|
+
name: exports.uniquePreferenceRuleIndexName,
|
18
|
+
tableName: "price_preference",
|
19
|
+
columns: ["attribute", "value"],
|
20
|
+
unique: true,
|
21
|
+
where: "deleted_at IS NULL",
|
22
|
+
});
|
23
|
+
const DeletedAtIndex = (0, utils_1.createPsqlIndexStatementHelper)({
|
24
|
+
tableName: "price_preference",
|
21
25
|
columns: "deleted_at",
|
22
26
|
where: "deleted_at IS NOT NULL",
|
23
27
|
});
|
24
|
-
|
25
|
-
tableName: tableName,
|
26
|
-
columns: "rule_attribute",
|
27
|
-
where: "deleted_at IS NULL",
|
28
|
-
});
|
29
|
-
let RuleType = class RuleType {
|
28
|
+
let PricePreference = class PricePreference {
|
30
29
|
constructor() {
|
31
|
-
this.
|
30
|
+
this.value = null;
|
32
31
|
this.deleted_at = null;
|
33
32
|
}
|
34
33
|
onCreate() {
|
35
|
-
this.id = (0, utils_1.generateEntityId)(this.id, "
|
34
|
+
this.id = (0, utils_1.generateEntityId)(this.id, "prpref");
|
36
35
|
}
|
37
36
|
onInit() {
|
38
|
-
this.id = (0, utils_1.generateEntityId)(this.id, "
|
37
|
+
this.id = (0, utils_1.generateEntityId)(this.id, "prpref");
|
39
38
|
}
|
40
39
|
};
|
41
40
|
__decorate([
|
42
41
|
(0, core_1.PrimaryKey)({ columnType: "text" }),
|
43
42
|
__metadata("design:type", String)
|
44
|
-
],
|
43
|
+
], PricePreference.prototype, "id", void 0);
|
45
44
|
__decorate([
|
46
45
|
(0, core_1.Property)({ columnType: "text" }),
|
47
46
|
__metadata("design:type", String)
|
48
|
-
],
|
47
|
+
], PricePreference.prototype, "attribute", void 0);
|
49
48
|
__decorate([
|
50
|
-
|
51
|
-
(0, core_1.Property)({ columnType: "text" }),
|
52
|
-
__metadata("design:type", String)
|
53
|
-
], RuleType.prototype, "rule_attribute", void 0);
|
54
|
-
__decorate([
|
55
|
-
(0, core_1.Property)({ columnType: "integer", default: 0 }),
|
56
|
-
__metadata("design:type", Number)
|
57
|
-
], RuleType.prototype, "default_priority", void 0);
|
58
|
-
__decorate([
|
59
|
-
(0, core_1.ManyToMany)(() => price_set_1.default, (priceSet) => priceSet.rule_types),
|
49
|
+
(0, core_1.Property)({ columnType: "text", nullable: true }),
|
60
50
|
__metadata("design:type", Object)
|
61
|
-
],
|
51
|
+
], PricePreference.prototype, "value", void 0);
|
52
|
+
__decorate([
|
53
|
+
(0, core_1.Property)({ default: false }),
|
54
|
+
__metadata("design:type", Boolean)
|
55
|
+
], PricePreference.prototype, "is_tax_inclusive", void 0);
|
62
56
|
__decorate([
|
63
57
|
(0, core_1.Property)({
|
64
58
|
onCreate: () => new Date(),
|
@@ -66,7 +60,7 @@ __decorate([
|
|
66
60
|
defaultRaw: "now()",
|
67
61
|
}),
|
68
62
|
__metadata("design:type", Date)
|
69
|
-
],
|
63
|
+
], PricePreference.prototype, "created_at", void 0);
|
70
64
|
__decorate([
|
71
65
|
(0, core_1.Property)({
|
72
66
|
onCreate: () => new Date(),
|
@@ -75,26 +69,27 @@ __decorate([
|
|
75
69
|
defaultRaw: "now()",
|
76
70
|
}),
|
77
71
|
__metadata("design:type", Date)
|
78
|
-
],
|
72
|
+
], PricePreference.prototype, "updated_at", void 0);
|
79
73
|
__decorate([
|
80
|
-
|
74
|
+
DeletedAtIndex.MikroORMIndex(),
|
81
75
|
(0, core_1.Property)({ columnType: "timestamptz", nullable: true }),
|
82
76
|
__metadata("design:type", Object)
|
83
|
-
],
|
77
|
+
], PricePreference.prototype, "deleted_at", void 0);
|
84
78
|
__decorate([
|
85
79
|
(0, core_1.BeforeCreate)(),
|
86
80
|
__metadata("design:type", Function),
|
87
81
|
__metadata("design:paramtypes", []),
|
88
82
|
__metadata("design:returntype", void 0)
|
89
|
-
],
|
83
|
+
], PricePreference.prototype, "onCreate", null);
|
90
84
|
__decorate([
|
91
85
|
(0, core_1.OnInit)(),
|
92
86
|
__metadata("design:type", Function),
|
93
87
|
__metadata("design:paramtypes", []),
|
94
88
|
__metadata("design:returntype", void 0)
|
95
|
-
],
|
96
|
-
|
97
|
-
(0, core_1.Entity)(
|
98
|
-
(0, core_1.Filter)(utils_1.DALUtils.mikroOrmSoftDeletableFilterOptions)
|
99
|
-
|
100
|
-
|
89
|
+
], PricePreference.prototype, "onInit", null);
|
90
|
+
PricePreference = __decorate([
|
91
|
+
(0, core_1.Entity)(),
|
92
|
+
(0, core_1.Filter)(utils_1.DALUtils.mikroOrmSoftDeletableFilterOptions),
|
93
|
+
UniquePreferenceRuleIndexStatement.MikroORMIndex()
|
94
|
+
], PricePreference);
|
95
|
+
exports.default = PricePreference;
|
@@ -1,20 +1,15 @@
|
|
1
1
|
import { DAL } from "@medusajs/types";
|
2
|
-
import { OptionalProps } from "@mikro-orm/core";
|
2
|
+
import { OptionalProps, Rel } from "@mikro-orm/core";
|
3
3
|
import Price from "./price";
|
4
|
-
|
5
|
-
import RuleType from "./rule-type";
|
6
|
-
type OptionalFields = DAL.SoftDeletableEntityDateColumns;
|
4
|
+
type OptionalFields = DAL.SoftDeletableModelDateColumns;
|
7
5
|
export default class PriceRule {
|
8
6
|
[OptionalProps]?: OptionalFields;
|
9
7
|
id: string;
|
10
|
-
|
11
|
-
price_set: PriceSet;
|
12
|
-
rule_type_id: string;
|
13
|
-
rule_type: RuleType;
|
8
|
+
attribute: string;
|
14
9
|
value: string;
|
15
10
|
priority: number;
|
16
11
|
price_id: string;
|
17
|
-
price: Price
|
12
|
+
price: Rel<Price>;
|
18
13
|
created_at: Date;
|
19
14
|
updated_at: Date;
|
20
15
|
deleted_at: Date | null;
|
@@ -22,3 +17,4 @@ export default class PriceRule {
|
|
22
17
|
onInit(): void;
|
23
18
|
}
|
24
19
|
export {};
|
20
|
+
//# sourceMappingURL=price-rule.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"price-rule.d.ts","sourceRoot":"","sources":["../../src/models/price-rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAMrC,OAAO,EAML,aAAa,EAGb,GAAG,EACJ,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,MAAM,SAAS,CAAA;AAE3B,KAAK,cAAc,GAAG,GAAG,CAAC,6BAA6B,CAAA;AAkBvD,MAAM,CAAC,OAAO,OAAO,SAAS;IAC5B,CAAC,aAAa,CAAC,CAAC,EAAE,cAAc,CAAA;IAGhC,EAAE,EAAG,MAAM,CAAA;IAGX,SAAS,EAAE,MAAM,CAAA;IAGjB,KAAK,EAAE,MAAM,CAAA;IAGb,QAAQ,EAAE,MAAM,CAAI;IASpB,QAAQ,EAAE,MAAM,CAAA;IAGhB,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,CAAA;IAOjB,UAAU,EAAE,IAAI,CAAA;IAQhB,UAAU,EAAE,IAAI,CAAA;IAIhB,UAAU,EAAE,IAAI,GAAG,IAAI,CAAO;IAG9B,YAAY;IAMZ,MAAM;CAIP"}
|