@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.
Files changed (95) hide show
  1. package/dist/index.d.ts +6 -6
  2. package/dist/index.js +9 -5
  3. package/dist/initialize/index.d.ts +4 -0
  4. package/dist/initialize/index.js +17 -0
  5. package/dist/joiner-config.d.ts +10 -2
  6. package/dist/joiner-config.js +52 -4
  7. package/dist/loaders/connection.d.ts +4 -0
  8. package/dist/loaders/connection.js +40 -0
  9. package/dist/loaders/container.d.ts +2 -0
  10. package/dist/loaders/container.js +34 -0
  11. package/dist/loaders/index.d.ts +2 -0
  12. package/dist/loaders/index.js +18 -0
  13. package/dist/migrations/Migration20230929122253.d.ts +0 -1
  14. package/dist/migrations/Migration20240322094407.d.ts +0 -1
  15. package/dist/migrations/Migration20240322113359.d.ts +0 -1
  16. package/dist/migrations/Migration20240322120125.d.ts +0 -1
  17. package/dist/models/index.d.ts +3 -2
  18. package/dist/models/index.js +7 -3
  19. package/dist/models/price-list-rule-value.d.ts +17 -0
  20. package/dist/models/price-list-rule-value.js +102 -0
  21. package/dist/models/price-list-rule.d.ts +8 -6
  22. package/dist/models/price-list-rule.js +29 -8
  23. package/dist/models/price-list.d.ts +3 -2
  24. package/dist/models/price-list.js +9 -0
  25. package/dist/models/price-rule.d.ts +9 -5
  26. package/dist/models/price-rule.js +45 -6
  27. package/dist/models/price-set-rule-type.d.ts +10 -0
  28. package/dist/models/price-set-rule-type.js +108 -0
  29. package/dist/models/price-set.d.ts +4 -1
  30. package/dist/models/price-set.js +19 -0
  31. package/dist/models/price.d.ts +4 -5
  32. package/dist/models/price.js +5 -5
  33. package/dist/models/rule-type.d.ts +17 -0
  34. package/dist/models/{price-preference.js → rule-type.js} +40 -35
  35. package/dist/module-definition.d.ts +4 -0
  36. package/dist/module-definition.js +50 -0
  37. package/dist/repositories/index.d.ts +0 -1
  38. package/dist/repositories/pricing.d.ts +0 -1
  39. package/dist/repositories/pricing.js +36 -29
  40. package/dist/schema/index.d.ts +0 -1
  41. package/dist/scripts/bin/run-seed.d.ts +3 -0
  42. package/dist/scripts/bin/run-seed.js +38 -0
  43. package/dist/scripts/seed.d.ts +4 -0
  44. package/dist/scripts/seed.js +67 -0
  45. package/dist/services/index.d.ts +2 -1
  46. package/dist/services/index.js +5 -1
  47. package/dist/services/price-list.d.ts +16 -0
  48. package/dist/services/price-list.js +34 -0
  49. package/dist/services/pricing-module.d.ts +53 -66
  50. package/dist/services/pricing-module.js +605 -594
  51. package/dist/services/rule-type.d.ts +15 -0
  52. package/dist/services/rule-type.js +53 -0
  53. package/dist/types/index.d.ts +0 -1
  54. package/dist/types/services/index.d.ts +2 -30
  55. package/dist/types/services/index.js +16 -0
  56. package/dist/types/services/price-list.d.ts +18 -0
  57. package/dist/types/services/price-list.js +2 -0
  58. package/dist/types/services/price-set.d.ts +4 -0
  59. package/dist/types/services/price-set.js +2 -0
  60. package/dist/utils/index.d.ts +0 -2
  61. package/dist/utils/index.js +0 -1
  62. package/dist/utils/validate-price-list-dates.d.ts +0 -1
  63. package/package.json +13 -8
  64. package/dist/index.d.ts.map +0 -1
  65. package/dist/joiner-config.d.ts.map +0 -1
  66. package/dist/migrations/Migration20230929122253.d.ts.map +0 -1
  67. package/dist/migrations/Migration20240322094407.d.ts.map +0 -1
  68. package/dist/migrations/Migration20240322113359.d.ts.map +0 -1
  69. package/dist/migrations/Migration20240322120125.d.ts.map +0 -1
  70. package/dist/migrations/Migration20240626133555.d.ts +0 -5
  71. package/dist/migrations/Migration20240626133555.d.ts.map +0 -1
  72. package/dist/migrations/Migration20240626133555.js +0 -33
  73. package/dist/migrations/Migration20240704094505.d.ts +0 -6
  74. package/dist/migrations/Migration20240704094505.d.ts.map +0 -1
  75. package/dist/migrations/Migration20240704094505.js +0 -15
  76. package/dist/models/index.d.ts.map +0 -1
  77. package/dist/models/price-list-rule.d.ts.map +0 -1
  78. package/dist/models/price-list.d.ts.map +0 -1
  79. package/dist/models/price-preference.d.ts +0 -13
  80. package/dist/models/price-preference.d.ts.map +0 -1
  81. package/dist/models/price-rule.d.ts.map +0 -1
  82. package/dist/models/price-set.d.ts.map +0 -1
  83. package/dist/models/price.d.ts.map +0 -1
  84. package/dist/repositories/index.d.ts.map +0 -1
  85. package/dist/repositories/pricing.d.ts.map +0 -1
  86. package/dist/schema/index.d.ts.map +0 -1
  87. package/dist/services/index.d.ts.map +0 -1
  88. package/dist/services/pricing-module.d.ts.map +0 -1
  89. package/dist/types/index.d.ts.map +0 -1
  90. package/dist/types/services/index.d.ts.map +0 -1
  91. package/dist/utils/events.d.ts +0 -63
  92. package/dist/utils/events.d.ts.map +0 -1
  93. package/dist/utils/events.js +0 -66
  94. package/dist/utils/index.d.ts.map +0 -1
  95. package/dist/utils/validate-price-list-dates.d.ts.map +0 -1
@@ -15,15 +15,27 @@ 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_1 = __importDefault(require("./price"));
18
+ const price_set_1 = __importDefault(require("./price-set"));
19
+ const rule_type_1 = __importDefault(require("./rule-type"));
18
20
  const tableName = "price_rule";
19
21
  const PriceRuleDeletedAtIndex = (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 PriceRulePriceSetIdIndex = (0, utils_1.createPsqlIndexStatementHelper)({
27
+ tableName: tableName,
28
+ columns: "price_set_id",
29
+ where: "deleted_at IS NULL",
30
+ });
31
+ const PriceRuleRuleTypeIdIndex = (0, utils_1.createPsqlIndexStatementHelper)({
32
+ tableName: tableName,
33
+ columns: "rule_type_id",
34
+ where: "deleted_at IS NULL",
35
+ });
24
36
  const PriceRulePriceIdIndex = (0, utils_1.createPsqlIndexStatementHelper)({
25
37
  tableName: tableName,
26
- columns: ["price_id", "attribute"],
38
+ columns: ["price_id", "rule_type_id"],
27
39
  where: "deleted_at IS NULL",
28
40
  unique: true,
29
41
  });
@@ -34,11 +46,15 @@ let PriceRule = class PriceRule {
34
46
  }
35
47
  beforeCreate() {
36
48
  this.id = (0, utils_1.generateEntityId)(this.id, "prule");
37
- this.price_id ??= this.price?.id;
49
+ this.rule_type_id ?? (this.rule_type_id = this.rule_type?.id);
50
+ this.price_set_id ?? (this.price_set_id = this.price_set?.id);
51
+ this.price_id ?? (this.price_id = this.price?.id);
38
52
  }
39
53
  onInit() {
40
54
  this.id = (0, utils_1.generateEntityId)(this.id, "prule");
41
- this.price_id ??= this.price?.id;
55
+ this.rule_type_id ?? (this.rule_type_id = this.rule_type?.id);
56
+ this.price_set_id ?? (this.price_set_id = this.price_set?.id);
57
+ this.price_id ?? (this.price_id = this.price?.id);
42
58
  }
43
59
  };
44
60
  __decorate([
@@ -46,9 +62,32 @@ __decorate([
46
62
  __metadata("design:type", String)
47
63
  ], PriceRule.prototype, "id", void 0);
48
64
  __decorate([
49
- (0, core_1.Property)({ columnType: "text" }),
65
+ PriceRulePriceSetIdIndex.MikroORMIndex(),
66
+ (0, core_1.ManyToOne)(() => price_set_1.default, {
67
+ columnType: "text",
68
+ mapToPk: true,
69
+ fieldName: "price_set_id",
70
+ onDelete: "cascade",
71
+ }),
50
72
  __metadata("design:type", String)
51
- ], PriceRule.prototype, "attribute", void 0);
73
+ ], PriceRule.prototype, "price_set_id", void 0);
74
+ __decorate([
75
+ (0, core_1.ManyToOne)(() => price_set_1.default, { persist: false }),
76
+ __metadata("design:type", price_set_1.default)
77
+ ], PriceRule.prototype, "price_set", void 0);
78
+ __decorate([
79
+ PriceRuleRuleTypeIdIndex.MikroORMIndex(),
80
+ (0, core_1.ManyToOne)(() => rule_type_1.default, {
81
+ columnType: "text",
82
+ mapToPk: true,
83
+ fieldName: "rule_type_id",
84
+ }),
85
+ __metadata("design:type", String)
86
+ ], PriceRule.prototype, "rule_type_id", void 0);
87
+ __decorate([
88
+ (0, core_1.ManyToOne)(() => rule_type_1.default, { persist: false }),
89
+ __metadata("design:type", rule_type_1.default)
90
+ ], PriceRule.prototype, "rule_type", void 0);
52
91
  __decorate([
53
92
  (0, core_1.Property)({ columnType: "text" }),
54
93
  __metadata("design:type", String)
@@ -69,7 +108,7 @@ __decorate([
69
108
  ], PriceRule.prototype, "price_id", void 0);
70
109
  __decorate([
71
110
  (0, core_1.ManyToOne)(() => price_1.default, { persist: false }),
72
- __metadata("design:type", Object)
111
+ __metadata("design:type", price_1.default)
73
112
  ], PriceRule.prototype, "price", void 0);
74
113
  __decorate([
75
114
  (0, core_1.Property)({
@@ -0,0 +1,10 @@
1
+ export default class PriceSetRuleType {
2
+ id: string;
3
+ price_set_id: string;
4
+ rule_type_id: string;
5
+ created_at: Date;
6
+ updated_at: Date;
7
+ deleted_at: Date | null;
8
+ onCreate(): void;
9
+ onInit(): void;
10
+ }
@@ -0,0 +1,108 @@
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,13 +1,16 @@
1
1
  import { Collection } from "@mikro-orm/core";
2
2
  import Price from "./price";
3
+ import PriceRule from "./price-rule";
4
+ import RuleType from "./rule-type";
3
5
  export declare const PriceSetIdPrefix = "pset";
4
6
  export default class PriceSet {
5
7
  id: string;
6
8
  prices: Collection<Price, object>;
9
+ price_rules: Collection<PriceRule, object>;
10
+ rule_types: Collection<RuleType, object>;
7
11
  created_at: Date;
8
12
  updated_at: Date;
9
13
  deleted_at: Date | null;
10
14
  onCreate(): void;
11
15
  onInit(): void;
12
16
  }
13
- //# sourceMappingURL=price-set.d.ts.map
@@ -16,6 +16,9 @@ exports.PriceSetIdPrefix = void 0;
16
16
  const utils_1 = require("@medusajs/utils");
17
17
  const core_1 = require("@mikro-orm/core");
18
18
  const price_1 = __importDefault(require("./price"));
19
+ const price_rule_1 = __importDefault(require("./price-rule"));
20
+ const price_set_rule_type_1 = __importDefault(require("./price-set-rule-type"));
21
+ const rule_type_1 = __importDefault(require("./rule-type"));
19
22
  const tableName = "price_set";
20
23
  const PriceSetDeletedAtIndex = (0, utils_1.createPsqlIndexStatementHelper)({
21
24
  tableName: tableName,
@@ -26,6 +29,8 @@ exports.PriceSetIdPrefix = "pset";
26
29
  let PriceSet = class PriceSet {
27
30
  constructor() {
28
31
  this.prices = new core_1.Collection(this);
32
+ this.price_rules = new core_1.Collection(this);
33
+ this.rule_types = new core_1.Collection(this);
29
34
  this.deleted_at = null;
30
35
  }
31
36
  onCreate() {
@@ -45,6 +50,20 @@ __decorate([
45
50
  }),
46
51
  __metadata("design:type", Object)
47
52
  ], PriceSet.prototype, "prices", void 0);
53
+ __decorate([
54
+ (0, core_1.OneToMany)(() => price_rule_1.default, (pr) => pr.price_set, {
55
+ cascade: [core_1.Cascade.PERSIST, "soft-remove"],
56
+ }),
57
+ __metadata("design:type", Object)
58
+ ], PriceSet.prototype, "price_rules", void 0);
59
+ __decorate([
60
+ (0, core_1.ManyToMany)({
61
+ entity: () => rule_type_1.default,
62
+ pivotEntity: () => price_set_rule_type_1.default,
63
+ cascade: ["soft-remove"],
64
+ }),
65
+ __metadata("design:type", Object)
66
+ ], PriceSet.prototype, "rule_types", void 0);
48
67
  __decorate([
49
68
  (0, core_1.Property)({
50
69
  onCreate: () => new Date(),
@@ -1,10 +1,10 @@
1
1
  import { DAL } from "@medusajs/types";
2
2
  import { BigNumber } from "@medusajs/utils";
3
- import { Collection, OptionalProps, Rel } from "@mikro-orm/core";
3
+ import { Collection, OptionalProps } from "@mikro-orm/core";
4
4
  import PriceList from "./price-list";
5
5
  import PriceRule from "./price-rule";
6
6
  import PriceSet from "./price-set";
7
- type OptionalFields = DAL.SoftDeletableModelDateColumns;
7
+ type OptionalFields = DAL.SoftDeletableEntityDateColumns;
8
8
  export default class Price {
9
9
  [OptionalProps]?: OptionalFields;
10
10
  id: string;
@@ -15,11 +15,11 @@ export default class Price {
15
15
  min_quantity: number | null;
16
16
  max_quantity: number | null;
17
17
  price_set_id: string;
18
- price_set?: Rel<PriceSet>;
18
+ price_set?: PriceSet;
19
19
  rules_count: number;
20
20
  price_rules: Collection<PriceRule, object>;
21
21
  price_list_id: string | null;
22
- price_list: Rel<PriceList> | null;
22
+ price_list: PriceList | null;
23
23
  created_at: Date;
24
24
  updated_at: Date;
25
25
  deleted_at: Date | null;
@@ -27,4 +27,3 @@ export default class Price {
27
27
  onInit(): void;
28
28
  }
29
29
  export {};
30
- //# sourceMappingURL=price.d.ts.map
@@ -51,13 +51,13 @@ let Price = class Price {
51
51
  }
52
52
  onCreate() {
53
53
  this.id = (0, utils_1.generateEntityId)(this.id, "price");
54
- this.price_set_id ??= this.price_set?.id;
55
- this.price_list_id ??= this.price_list?.id;
54
+ this.price_set_id ?? (this.price_set_id = this.price_set?.id);
55
+ this.price_list_id ?? (this.price_list_id = this.price_list?.id);
56
56
  }
57
57
  onInit() {
58
58
  this.id = (0, utils_1.generateEntityId)(this.id, "price");
59
- this.price_set_id ??= this.price_set?.id;
60
- this.price_list_id ??= this.price_list?.id;
59
+ this.price_set_id ?? (this.price_set_id = this.price_set?.id);
60
+ this.price_list_id ?? (this.price_list_id = this.price_list?.id);
61
61
  }
62
62
  };
63
63
  __decorate([
@@ -101,7 +101,7 @@ __decorate([
101
101
  ], Price.prototype, "price_set_id", void 0);
102
102
  __decorate([
103
103
  (0, core_1.ManyToOne)(() => price_set_1.default, { persist: false }),
104
- __metadata("design:type", Object)
104
+ __metadata("design:type", price_set_1.default)
105
105
  ], Price.prototype, "price_set", void 0);
106
106
  __decorate([
107
107
  (0, core_1.Property)({ columnType: "integer", default: 0 }),
@@ -0,0 +1,17 @@
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;
@@ -8,51 +8,57 @@ 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
+ };
11
14
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.uniquePreferenceRuleIndexName = void 0;
13
15
  const utils_1 = require("@medusajs/utils");
14
16
  const core_1 = require("@mikro-orm/core");
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",
17
+ const price_set_1 = __importDefault(require("./price-set"));
18
+ const tableName = "rule_type";
19
+ const RuleTypeDeletedAtIndex = (0, utils_1.createPsqlIndexStatementHelper)({
20
+ tableName: tableName,
25
21
  columns: "deleted_at",
26
22
  where: "deleted_at IS NOT NULL",
27
23
  });
28
- let PricePreference = class PricePreference {
24
+ const RuleTypeRuleAttributeIndex = (0, utils_1.createPsqlIndexStatementHelper)({
25
+ tableName: tableName,
26
+ columns: "rule_attribute",
27
+ where: "deleted_at IS NULL",
28
+ });
29
+ let RuleType = class RuleType {
29
30
  constructor() {
30
- this.value = null;
31
+ this.price_sets = new core_1.Collection(this);
31
32
  this.deleted_at = null;
32
33
  }
33
34
  onCreate() {
34
- this.id = (0, utils_1.generateEntityId)(this.id, "prpref");
35
+ this.id = (0, utils_1.generateEntityId)(this.id, "rul-typ");
35
36
  }
36
37
  onInit() {
37
- this.id = (0, utils_1.generateEntityId)(this.id, "prpref");
38
+ this.id = (0, utils_1.generateEntityId)(this.id, "rul-typ");
38
39
  }
39
40
  };
40
41
  __decorate([
41
42
  (0, core_1.PrimaryKey)({ columnType: "text" }),
42
43
  __metadata("design:type", String)
43
- ], PricePreference.prototype, "id", void 0);
44
+ ], RuleType.prototype, "id", void 0);
44
45
  __decorate([
45
46
  (0, core_1.Property)({ columnType: "text" }),
46
47
  __metadata("design:type", String)
47
- ], PricePreference.prototype, "attribute", void 0);
48
+ ], RuleType.prototype, "name", void 0);
48
49
  __decorate([
49
- (0, core_1.Property)({ columnType: "text", nullable: true }),
50
- __metadata("design:type", Object)
51
- ], PricePreference.prototype, "value", void 0);
50
+ RuleTypeRuleAttributeIndex.MikroORMIndex(),
51
+ (0, core_1.Property)({ columnType: "text" }),
52
+ __metadata("design:type", String)
53
+ ], RuleType.prototype, "rule_attribute", void 0);
52
54
  __decorate([
53
- (0, core_1.Property)({ default: false }),
54
- __metadata("design:type", Boolean)
55
- ], PricePreference.prototype, "is_tax_inclusive", void 0);
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),
60
+ __metadata("design:type", Object)
61
+ ], RuleType.prototype, "price_sets", void 0);
56
62
  __decorate([
57
63
  (0, core_1.Property)({
58
64
  onCreate: () => new Date(),
@@ -60,7 +66,7 @@ __decorate([
60
66
  defaultRaw: "now()",
61
67
  }),
62
68
  __metadata("design:type", Date)
63
- ], PricePreference.prototype, "created_at", void 0);
69
+ ], RuleType.prototype, "created_at", void 0);
64
70
  __decorate([
65
71
  (0, core_1.Property)({
66
72
  onCreate: () => new Date(),
@@ -69,27 +75,26 @@ __decorate([
69
75
  defaultRaw: "now()",
70
76
  }),
71
77
  __metadata("design:type", Date)
72
- ], PricePreference.prototype, "updated_at", void 0);
78
+ ], RuleType.prototype, "updated_at", void 0);
73
79
  __decorate([
74
- DeletedAtIndex.MikroORMIndex(),
80
+ RuleTypeDeletedAtIndex.MikroORMIndex(),
75
81
  (0, core_1.Property)({ columnType: "timestamptz", nullable: true }),
76
82
  __metadata("design:type", Object)
77
- ], PricePreference.prototype, "deleted_at", void 0);
83
+ ], RuleType.prototype, "deleted_at", void 0);
78
84
  __decorate([
79
85
  (0, core_1.BeforeCreate)(),
80
86
  __metadata("design:type", Function),
81
87
  __metadata("design:paramtypes", []),
82
88
  __metadata("design:returntype", void 0)
83
- ], PricePreference.prototype, "onCreate", null);
89
+ ], RuleType.prototype, "onCreate", null);
84
90
  __decorate([
85
91
  (0, core_1.OnInit)(),
86
92
  __metadata("design:type", Function),
87
93
  __metadata("design:paramtypes", []),
88
94
  __metadata("design:returntype", void 0)
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;
95
+ ], RuleType.prototype, "onInit", null);
96
+ RuleType = __decorate([
97
+ (0, core_1.Entity)({ tableName }),
98
+ (0, core_1.Filter)(utils_1.DALUtils.mikroOrmSoftDeletableFilterOptions)
99
+ ], RuleType);
100
+ exports.default = RuleType;
@@ -0,0 +1,4 @@
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;
@@ -0,0 +1,50 @@
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,3 +1,2 @@
1
1
  export { MikroOrmBaseRepository as BaseRepository } from "@medusajs/utils";
2
2
  export { PricingRepository } from "./pricing";
3
- //# sourceMappingURL=index.d.ts.map
@@ -4,4 +4,3 @@ export declare class PricingRepository extends MikroOrmBase implements PricingRe
4
4
  constructor();
5
5
  calculatePrices(pricingFilters: PricingFilters, pricingContext?: PricingContext, sharedContext?: Context): Promise<CalculatedPriceSetDTO[]>;
6
6
  }
7
- //# sourceMappingURL=pricing.d.ts.map