@medusajs/pricing 0.1.13-snapshot-20240607093839 → 0.1.13-snapshot-20240703074611

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. package/dist/index.d.ts +2 -3
  2. package/dist/index.js +7 -4
  3. package/dist/joiner-config.d.ts +1 -8
  4. package/dist/joiner-config.js +10 -52
  5. package/dist/migrations/Migration20240626133555.d.ts +4 -0
  6. package/dist/migrations/Migration20240626133555.js +33 -0
  7. package/dist/models/index.d.ts +0 -3
  8. package/dist/models/index.js +1 -7
  9. package/dist/models/price-list-rule.d.ts +4 -7
  10. package/dist/models/price-list-rule.js +6 -27
  11. package/dist/models/price-list.d.ts +0 -2
  12. package/dist/models/price-list.js +0 -9
  13. package/dist/models/price-rule.d.ts +3 -8
  14. package/dist/models/price-rule.js +4 -43
  15. package/dist/models/price-set.d.ts +0 -4
  16. package/dist/models/price-set.js +0 -19
  17. package/dist/models/price.d.ts +3 -3
  18. package/dist/models/price.js +1 -1
  19. package/dist/repositories/pricing.js +25 -30
  20. package/dist/services/index.d.ts +0 -2
  21. package/dist/services/index.js +1 -5
  22. package/dist/services/pricing-module.d.ts +50 -48
  23. package/dist/services/pricing-module.js +293 -482
  24. package/dist/types/services/price-list.d.ts +9 -9
  25. package/dist/utils/events.d.ts +0 -6
  26. package/dist/utils/events.js +6 -12
  27. package/package.json +7 -10
  28. package/dist/models/price-list-rule-value.d.ts +0 -17
  29. package/dist/models/price-list-rule-value.js +0 -102
  30. package/dist/models/price-set-rule-type.d.ts +0 -10
  31. package/dist/models/price-set-rule-type.js +0 -108
  32. package/dist/models/rule-type.d.ts +0 -17
  33. package/dist/models/rule-type.js +0 -100
  34. package/dist/module-definition.d.ts +0 -2
  35. package/dist/module-definition.js +0 -8
  36. package/dist/scripts/bin/run-seed.d.ts +0 -3
  37. package/dist/scripts/bin/run-seed.js +0 -38
  38. package/dist/scripts/seed.d.ts +0 -4
  39. package/dist/scripts/seed.js +0 -67
  40. package/dist/services/price-list.d.ts +0 -16
  41. package/dist/services/price-list.js +0 -34
  42. package/dist/services/rule-type.d.ts +0 -15
  43. package/dist/services/rule-type.js +0 -53
@@ -1,16 +1,16 @@
1
- import { PriceListStatus, PriceListType } from "@medusajs/types";
2
- export interface CreatePriceListDTO {
3
- title: string;
4
- description: string;
5
- starts_at?: string | null;
6
- ends_at?: string | null;
7
- status?: PriceListStatus;
8
- type?: PriceListType;
9
- number_rules?: number;
1
+ import { PriceListStatus, PricingTypes } from "@medusajs/types";
2
+ export interface CreatePriceListDTO extends PricingTypes.CreatePriceListDTO {
3
+ rules_count?: number;
4
+ price_list_rules?: {
5
+ attribute: string;
6
+ value: string;
7
+ }[];
8
+ prices?: PricingTypes.CreatePriceListPriceDTO[];
10
9
  }
11
10
  export interface UpdatePriceListDTO {
12
11
  id: string;
13
12
  title?: string;
13
+ description?: string | null;
14
14
  starts_at?: string | null;
15
15
  ends_at?: string | null;
16
16
  status?: PriceListStatus;
@@ -5,12 +5,6 @@ export declare const eventBuilders: {
5
5
  }[];
6
6
  sharedContext: import("@medusajs/types").Context;
7
7
  }) => void;
8
- createdPriceSetRuleType: ({ data, sharedContext, }: {
9
- data: {
10
- id: string;
11
- }[];
12
- sharedContext: import("@medusajs/types").Context;
13
- }) => void;
14
8
  createdPrice: ({ data, sharedContext, }: {
15
9
  data: {
16
10
  id: string;
@@ -4,43 +4,37 @@ exports.eventBuilders = void 0;
4
4
  const utils_1 = require("@medusajs/utils");
5
5
  exports.eventBuilders = {
6
6
  createdPriceSet: (0, utils_1.eventBuilderFactory)({
7
- service: utils_1.Modules.PRICING,
7
+ source: utils_1.Modules.PRICING,
8
8
  action: utils_1.CommonEvents.CREATED,
9
9
  object: "price_set",
10
10
  eventsEnum: utils_1.PricingEvents,
11
11
  }),
12
- createdPriceSetRuleType: (0, utils_1.eventBuilderFactory)({
13
- service: utils_1.Modules.PRICING,
14
- action: utils_1.CommonEvents.CREATED,
15
- object: "price_set_rule_type",
16
- eventsEnum: utils_1.PricingEvents,
17
- }),
18
12
  createdPrice: (0, utils_1.eventBuilderFactory)({
19
- service: utils_1.Modules.PRICING,
13
+ source: utils_1.Modules.PRICING,
20
14
  action: utils_1.CommonEvents.CREATED,
21
15
  object: "price",
22
16
  eventsEnum: utils_1.PricingEvents,
23
17
  }),
24
18
  createdPriceRule: (0, utils_1.eventBuilderFactory)({
25
- service: utils_1.Modules.PRICING,
19
+ source: utils_1.Modules.PRICING,
26
20
  action: utils_1.CommonEvents.CREATED,
27
21
  object: "price_rule",
28
22
  eventsEnum: utils_1.PricingEvents,
29
23
  }),
30
24
  createdPriceList: (0, utils_1.eventBuilderFactory)({
31
- service: utils_1.Modules.PRICING,
25
+ source: utils_1.Modules.PRICING,
32
26
  action: utils_1.CommonEvents.CREATED,
33
27
  object: "price_list",
34
28
  eventsEnum: utils_1.PricingEvents,
35
29
  }),
36
30
  createdPriceListRule: (0, utils_1.eventBuilderFactory)({
37
- service: utils_1.Modules.PRICING,
31
+ source: utils_1.Modules.PRICING,
38
32
  action: utils_1.CommonEvents.CREATED,
39
33
  object: "price_list_rule",
40
34
  eventsEnum: utils_1.PricingEvents,
41
35
  }),
42
36
  attachedPriceListRule: (0, utils_1.eventBuilderFactory)({
43
- service: utils_1.Modules.PRICING,
37
+ source: utils_1.Modules.PRICING,
44
38
  action: utils_1.CommonEvents.ATTACHED,
45
39
  object: "price_list_rule",
46
40
  eventsEnum: utils_1.PricingEvents,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/pricing",
3
- "version": "0.1.13-snapshot-20240607093839",
3
+ "version": "0.1.13-snapshot-20240703074611",
4
4
  "description": "Medusa Pricing module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -8,10 +8,7 @@
8
8
  "dist"
9
9
  ],
10
10
  "engines": {
11
- "node": ">=16"
12
- },
13
- "bin": {
14
- "medusa-pricing-seed": "dist/scripts/bin/run-seed.js"
11
+ "node": ">=20"
15
12
  },
16
13
  "repository": {
17
14
  "type": "git",
@@ -39,8 +36,8 @@
39
36
  "devDependencies": {
40
37
  "@mikro-orm/cli": "5.9.7",
41
38
  "cross-env": "^5.2.1",
42
- "jest": "^29.6.3",
43
- "medusa-test-utils": "1.1.45-snapshot-20240607093839",
39
+ "jest": "^29.7.0",
40
+ "medusa-test-utils": "1.1.45-snapshot-20240703074611",
44
41
  "rimraf": "^3.0.2",
45
42
  "ts-jest": "^29.1.1",
46
43
  "ts-node": "^10.9.1",
@@ -48,9 +45,9 @@
48
45
  "typescript": "^5.1.6"
49
46
  },
50
47
  "dependencies": {
51
- "@medusajs/modules-sdk": "1.13.0-snapshot-20240607093839",
52
- "@medusajs/types": "1.12.0-snapshot-20240607093839",
53
- "@medusajs/utils": "1.12.0-snapshot-20240607093839",
48
+ "@medusajs/modules-sdk": "1.13.0-snapshot-20240703074611",
49
+ "@medusajs/types": "1.12.0-snapshot-20240703074611",
50
+ "@medusajs/utils": "1.12.0-snapshot-20240703074611",
54
51
  "@mikro-orm/core": "5.9.7",
55
52
  "@mikro-orm/migrations": "5.9.7",
56
53
  "@mikro-orm/postgresql": "5.9.7",
@@ -1,17 +0,0 @@
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 {};
@@ -1,102 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const utils_1 = require("@medusajs/utils");
16
- const core_1 = require("@mikro-orm/core");
17
- const price_list_rule_1 = __importDefault(require("./price-list-rule"));
18
- const tableName = "price_list_rule_value";
19
- const PriceListRuleValueDeletedAtIndex = (0, utils_1.createPsqlIndexStatementHelper)({
20
- tableName: tableName,
21
- columns: "deleted_at",
22
- where: "deleted_at IS NOT NULL",
23
- });
24
- const PriceListPriceListRuleIdIndex = (0, utils_1.createPsqlIndexStatementHelper)({
25
- tableName: tableName,
26
- columns: "price_list_rule_id",
27
- where: "deleted_at IS NULL",
28
- });
29
- let PriceListRuleValue = class PriceListRuleValue {
30
- constructor() {
31
- this.deleted_at = null;
32
- }
33
- onCreate() {
34
- this.id = (0, utils_1.generateEntityId)(this.id, "plrv");
35
- this.price_list_rule_id ??= this.price_list_rule?.id;
36
- }
37
- onInit() {
38
- this.id = (0, utils_1.generateEntityId)(this.id, "plrv");
39
- 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,10 +0,0 @@
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
- }
@@ -1,108 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const utils_1 = require("@medusajs/utils");
16
- const core_1 = require("@mikro-orm/core");
17
- const price_set_1 = __importDefault(require("./price-set"));
18
- const rule_type_1 = __importDefault(require("./rule-type"));
19
- const tableName = "price_set_rule_type";
20
- const PriceSetRuleTypeDeletedAtIndex = (0, utils_1.createPsqlIndexStatementHelper)({
21
- tableName: tableName,
22
- columns: "deleted_at",
23
- where: "deleted_at IS NOT NULL",
24
- });
25
- const PriceSetRuleTypePriceSetIdIndex = (0, utils_1.createPsqlIndexStatementHelper)({
26
- tableName: tableName,
27
- columns: "price_set_id",
28
- where: "deleted_at IS NULL",
29
- });
30
- const PriceSetRuleTypeRuleTypeIdIndex = (0, utils_1.createPsqlIndexStatementHelper)({
31
- tableName: tableName,
32
- columns: "rule_type_id",
33
- where: "deleted_at IS NULL",
34
- });
35
- let PriceSetRuleType = class PriceSetRuleType {
36
- constructor() {
37
- this.deleted_at = null;
38
- }
39
- onCreate() {
40
- this.id = (0, utils_1.generateEntityId)(this.id, "psrt");
41
- }
42
- onInit() {
43
- this.id = (0, utils_1.generateEntityId)(this.id, "psrt");
44
- }
45
- };
46
- __decorate([
47
- (0, core_1.PrimaryKey)({ columnType: "text" }),
48
- __metadata("design:type", String)
49
- ], PriceSetRuleType.prototype, "id", void 0);
50
- __decorate([
51
- PriceSetRuleTypePriceSetIdIndex.MikroORMIndex(),
52
- (0, core_1.ManyToOne)(() => price_set_1.default, {
53
- columnType: "text",
54
- mapToPk: true,
55
- fieldName: "price_set_id",
56
- onDelete: "cascade",
57
- }),
58
- __metadata("design:type", String)
59
- ], PriceSetRuleType.prototype, "price_set_id", void 0);
60
- __decorate([
61
- PriceSetRuleTypeRuleTypeIdIndex.MikroORMIndex(),
62
- (0, core_1.ManyToOne)(() => rule_type_1.default, {
63
- columnType: "text",
64
- mapToPk: true,
65
- fieldName: "rule_type_id",
66
- onDelete: "cascade",
67
- }),
68
- __metadata("design:type", String)
69
- ], PriceSetRuleType.prototype, "rule_type_id", void 0);
70
- __decorate([
71
- (0, core_1.Property)({
72
- onCreate: () => new Date(),
73
- columnType: "timestamptz",
74
- defaultRaw: "now()",
75
- }),
76
- __metadata("design:type", Date)
77
- ], PriceSetRuleType.prototype, "created_at", void 0);
78
- __decorate([
79
- (0, core_1.Property)({
80
- onCreate: () => new Date(),
81
- onUpdate: () => new Date(),
82
- columnType: "timestamptz",
83
- defaultRaw: "now()",
84
- }),
85
- __metadata("design:type", Date)
86
- ], PriceSetRuleType.prototype, "updated_at", void 0);
87
- __decorate([
88
- PriceSetRuleTypeDeletedAtIndex.MikroORMIndex(),
89
- (0, core_1.Property)({ columnType: "timestamptz", nullable: true }),
90
- __metadata("design:type", Object)
91
- ], PriceSetRuleType.prototype, "deleted_at", void 0);
92
- __decorate([
93
- (0, core_1.BeforeCreate)(),
94
- __metadata("design:type", Function),
95
- __metadata("design:paramtypes", []),
96
- __metadata("design:returntype", void 0)
97
- ], PriceSetRuleType.prototype, "onCreate", null);
98
- __decorate([
99
- (0, core_1.OnInit)(),
100
- __metadata("design:type", Function),
101
- __metadata("design:paramtypes", []),
102
- __metadata("design:returntype", void 0)
103
- ], PriceSetRuleType.prototype, "onInit", null);
104
- PriceSetRuleType = __decorate([
105
- (0, core_1.Entity)({ tableName }),
106
- (0, core_1.Filter)(utils_1.DALUtils.mikroOrmSoftDeletableFilterOptions)
107
- ], PriceSetRuleType);
108
- exports.default = PriceSetRuleType;
@@ -1,17 +0,0 @@
1
- import { Collection, OptionalProps } from "@mikro-orm/core";
2
- import PriceSet from "./price-set";
3
- type OptionalFields = "default_priority";
4
- declare class RuleType {
5
- [OptionalProps]?: OptionalFields;
6
- id: string;
7
- name: string;
8
- rule_attribute: string;
9
- default_priority: number;
10
- price_sets: Collection<PriceSet, object>;
11
- created_at: Date;
12
- updated_at: Date;
13
- deleted_at: Date | null;
14
- onCreate(): void;
15
- onInit(): void;
16
- }
17
- export default RuleType;
@@ -1,100 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const utils_1 = require("@medusajs/utils");
16
- const core_1 = require("@mikro-orm/core");
17
- const price_set_1 = __importDefault(require("./price-set"));
18
- const tableName = "rule_type";
19
- const RuleTypeDeletedAtIndex = (0, utils_1.createPsqlIndexStatementHelper)({
20
- tableName: tableName,
21
- columns: "deleted_at",
22
- where: "deleted_at IS NOT NULL",
23
- });
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 {
30
- constructor() {
31
- this.price_sets = new core_1.Collection(this);
32
- this.deleted_at = null;
33
- }
34
- onCreate() {
35
- this.id = (0, utils_1.generateEntityId)(this.id, "rul-typ");
36
- }
37
- onInit() {
38
- this.id = (0, utils_1.generateEntityId)(this.id, "rul-typ");
39
- }
40
- };
41
- __decorate([
42
- (0, core_1.PrimaryKey)({ columnType: "text" }),
43
- __metadata("design:type", String)
44
- ], RuleType.prototype, "id", void 0);
45
- __decorate([
46
- (0, core_1.Property)({ columnType: "text" }),
47
- __metadata("design:type", String)
48
- ], RuleType.prototype, "name", void 0);
49
- __decorate([
50
- RuleTypeRuleAttributeIndex.MikroORMIndex(),
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),
60
- __metadata("design:type", Object)
61
- ], RuleType.prototype, "price_sets", void 0);
62
- __decorate([
63
- (0, core_1.Property)({
64
- onCreate: () => new Date(),
65
- columnType: "timestamptz",
66
- defaultRaw: "now()",
67
- }),
68
- __metadata("design:type", Date)
69
- ], RuleType.prototype, "created_at", void 0);
70
- __decorate([
71
- (0, core_1.Property)({
72
- onCreate: () => new Date(),
73
- onUpdate: () => new Date(),
74
- columnType: "timestamptz",
75
- defaultRaw: "now()",
76
- }),
77
- __metadata("design:type", Date)
78
- ], RuleType.prototype, "updated_at", void 0);
79
- __decorate([
80
- RuleTypeDeletedAtIndex.MikroORMIndex(),
81
- (0, core_1.Property)({ columnType: "timestamptz", nullable: true }),
82
- __metadata("design:type", Object)
83
- ], RuleType.prototype, "deleted_at", void 0);
84
- __decorate([
85
- (0, core_1.BeforeCreate)(),
86
- __metadata("design:type", Function),
87
- __metadata("design:paramtypes", []),
88
- __metadata("design:returntype", void 0)
89
- ], RuleType.prototype, "onCreate", null);
90
- __decorate([
91
- (0, core_1.OnInit)(),
92
- __metadata("design:type", Function),
93
- __metadata("design:paramtypes", []),
94
- __metadata("design:returntype", void 0)
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;
@@ -1,2 +0,0 @@
1
- import { ModuleExports } from "@medusajs/types";
2
- export declare const moduleDefinition: ModuleExports;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.moduleDefinition = void 0;
4
- const _services_1 = require("./services");
5
- const service = _services_1.PricingModuleService;
6
- exports.moduleDefinition = {
7
- service,
8
- };
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- declare const _default: Promise<void>;
3
- export default _default;
@@ -1,38 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || function (mod) {
20
- if (mod && mod.__esModule) return mod;
21
- var result = {};
22
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
- __setModuleDefault(result, mod);
24
- return result;
25
- };
26
- Object.defineProperty(exports, "__esModule", { value: true });
27
- const os_1 = require("os");
28
- const seed_1 = require("../seed");
29
- const args = process.argv;
30
- const path = args.pop();
31
- exports.default = (async () => {
32
- const { config } = await Promise.resolve().then(() => __importStar(require("dotenv")));
33
- config();
34
- if (!path) {
35
- throw new Error(`filePath is required.${os_1.EOL}Example: medusa-pricing-seed <filePath>`);
36
- }
37
- await (0, seed_1.run)({ path });
38
- })();
@@ -1,4 +0,0 @@
1
- import { LoaderOptions, ModulesSdkTypes } from "@medusajs/types";
2
- export declare function run({ options, logger, path, }: Partial<Pick<LoaderOptions<ModulesSdkTypes.ModuleServiceInitializeOptions>, "options" | "logger">> & {
3
- path: string;
4
- }): Promise<void>;
@@ -1,67 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.run = void 0;
27
- const utils_1 = require("@medusajs/utils");
28
- const PricingModels = __importStar(require("../models"));
29
- const os_1 = require("os");
30
- const path_1 = require("path");
31
- async function run({ options, logger, path, }) {
32
- logger ??= console;
33
- logger.info(`Loading seed data from ${path}...`);
34
- const { priceSetsData, pricesData } = await Promise.resolve(`${(0, path_1.resolve)(process.cwd(), path)}`).then(s => __importStar(require(s))).catch((e) => {
35
- logger?.error(`Failed to load seed data from ${path}. Please, provide a relative path and check that you export the following: priceSetsData and pricesData.${os_1.EOL}${e}`);
36
- throw e;
37
- });
38
- const dbData = utils_1.ModulesSdkUtils.loadDatabaseConfig("pricing", options);
39
- const entities = Object.values(PricingModels);
40
- const pathToMigrations = __dirname + "/../migrations";
41
- const orm = await utils_1.DALUtils.mikroOrmCreateConnection(dbData, entities, pathToMigrations);
42
- const manager = orm.em.fork();
43
- try {
44
- logger.info("Inserting price_sets & prices");
45
- await createPriceSets(manager, priceSetsData);
46
- await createPrices(manager, pricesData);
47
- }
48
- catch (e) {
49
- logger.error(`Failed to insert the seed data in the PostgreSQL database ${dbData.clientUrl}.${os_1.EOL}${e}`);
50
- }
51
- await orm.close(true);
52
- }
53
- exports.run = run;
54
- async function createPriceSets(manager, data) {
55
- const priceSets = data.map((priceSetData) => {
56
- return manager.create(PricingModels.PriceSet, priceSetData);
57
- });
58
- await manager.persistAndFlush(priceSets);
59
- return priceSets;
60
- }
61
- async function createPrices(manager, data) {
62
- const prices = data.map((priceData) => {
63
- return manager.create(PricingModels.Price, priceData);
64
- });
65
- await manager.persistAndFlush(prices);
66
- return prices;
67
- }
@@ -1,16 +0,0 @@
1
- import { Context, DAL } from "@medusajs/types";
2
- import { PriceList } from "../models";
3
- import { ServiceTypes } from "../types";
4
- type InjectedDependencies = {
5
- priceListRepository: DAL.RepositoryService;
6
- };
7
- declare const PriceListService_base: new <TEntity_1 extends object = any>(container: InjectedDependencies) => import("@medusajs/types").InternalModuleService<TEntity_1, InjectedDependencies>;
8
- export default class PriceListService<TEntity extends PriceList = PriceList> extends PriceListService_base<TEntity> {
9
- constructor(container: InjectedDependencies);
10
- create(data: ServiceTypes.CreatePriceListDTO[], sharedContext?: Context): Promise<TEntity[]>;
11
- create(data: ServiceTypes.CreatePriceListDTO, sharedContext?: Context): Promise<TEntity>;
12
- update(data: any[], sharedContext?: Context): Promise<TEntity[]>;
13
- update(data: any, sharedContext?: Context): Promise<TEntity>;
14
- protected normalizePriceListDate(data: (ServiceTypes.UpdatePriceListDTO | ServiceTypes.CreatePriceListDTO)[]): any[];
15
- }
16
- export {};