@medusajs/pricing 0.1.13-preview-20240701060617 → 0.1.13-preview-20240701074916

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,12 +1,11 @@
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;
@@ -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;
@@ -9,12 +9,6 @@ exports.eventBuilders = {
9
9
  object: "price_set",
10
10
  eventsEnum: utils_1.PricingEvents,
11
11
  }),
12
- createdPriceSetRuleType: (0, utils_1.eventBuilderFactory)({
13
- source: 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
13
  source: utils_1.Modules.PRICING,
20
14
  action: utils_1.CommonEvents.CREATED,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/pricing",
3
- "version": "0.1.13-preview-20240701060617",
3
+ "version": "0.1.13-preview-20240701074916",
4
4
  "description": "Medusa Pricing module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -37,7 +37,7 @@
37
37
  "@mikro-orm/cli": "5.9.7",
38
38
  "cross-env": "^5.2.1",
39
39
  "jest": "^29.7.0",
40
- "medusa-test-utils": "1.1.45-preview-20240701060617",
40
+ "medusa-test-utils": "1.1.45-preview-20240701074916",
41
41
  "rimraf": "^3.0.2",
42
42
  "ts-jest": "^29.1.1",
43
43
  "ts-node": "^10.9.1",
@@ -45,9 +45,9 @@
45
45
  "typescript": "^5.1.6"
46
46
  },
47
47
  "dependencies": {
48
- "@medusajs/modules-sdk": "1.13.0-preview-20240701060617",
49
- "@medusajs/types": "1.12.0-preview-20240701060617",
50
- "@medusajs/utils": "1.12.0-preview-20240701060617",
48
+ "@medusajs/modules-sdk": "1.13.0-preview-20240701074916",
49
+ "@medusajs/types": "1.12.0-preview-20240701074916",
50
+ "@medusajs/utils": "1.12.0-preview-20240701074916",
51
51
  "@mikro-orm/core": "5.9.7",
52
52
  "@mikro-orm/migrations": "5.9.7",
53
53
  "@mikro-orm/postgresql": "5.9.7",
@@ -1,17 +0,0 @@
1
- import { DAL } from "@medusajs/types";
2
- import { OptionalProps, Rel } 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: Rel<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", Object)
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,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 extends object = any>(container: InjectedDependencies) => import("@medusajs/types").IMedusaInternalService<TEntity, InjectedDependencies>;
8
- export default class PriceListService extends PriceListService_base<PriceList> {
9
- constructor(container: InjectedDependencies);
10
- create(data: ServiceTypes.CreatePriceListDTO[], sharedContext?: Context): Promise<PriceList[]>;
11
- create(data: ServiceTypes.CreatePriceListDTO, sharedContext?: Context): Promise<PriceList>;
12
- update(data: any[], sharedContext?: Context): Promise<PriceList[]>;
13
- update(data: any, sharedContext?: Context): Promise<PriceList>;
14
- protected normalizePriceListDate(data: (ServiceTypes.UpdatePriceListDTO | ServiceTypes.CreatePriceListDTO)[]): any[];
15
- }
16
- export {};
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const utils_1 = require("@medusajs/utils");
4
- const _models_1 = require("../models");
5
- class PriceListService extends utils_1.ModulesSdkUtils.MedusaInternalService(_models_1.PriceList) {
6
- constructor(container) {
7
- // @ts-ignore
8
- super(...arguments);
9
- }
10
- async create(data, sharedContext) {
11
- const data_ = Array.isArray(data) ? data : [data];
12
- const priceLists = this.normalizePriceListDate(data_);
13
- return await super.create(priceLists, sharedContext);
14
- }
15
- // TODO: Add support for selector? and then rm ts ignore
16
- // @ts-ignore
17
- async update(data, sharedContext) {
18
- const data_ = Array.isArray(data) ? data : [data];
19
- const priceLists = this.normalizePriceListDate(data_);
20
- return await super.update(priceLists, sharedContext);
21
- }
22
- normalizePriceListDate(data) {
23
- return data.map((priceListData) => {
24
- if (!!priceListData.starts_at) {
25
- priceListData.starts_at = (0, utils_1.GetIsoStringFromDate)(priceListData.starts_at);
26
- }
27
- if (!!priceListData.ends_at) {
28
- priceListData.ends_at = (0, utils_1.GetIsoStringFromDate)(priceListData.ends_at);
29
- }
30
- return priceListData;
31
- });
32
- }
33
- }
34
- exports.default = PriceListService;
@@ -1,15 +0,0 @@
1
- import { Context, DAL, PricingTypes } from "@medusajs/types";
2
- import { RuleType } from "../models";
3
- type InjectedDependencies = {
4
- ruleTypeRepository: DAL.RepositoryService;
5
- };
6
- declare const RuleTypeService_base: new <TEntity extends object = any>(container: InjectedDependencies) => import("@medusajs/types").IMedusaInternalService<TEntity, InjectedDependencies>;
7
- export default class RuleTypeService extends RuleTypeService_base<RuleType> {
8
- protected readonly ruleTypeRepository_: DAL.RepositoryService<RuleType>;
9
- constructor({ ruleTypeRepository }: InjectedDependencies);
10
- create(data: PricingTypes.CreateRuleTypeDTO, sharedContext: Context): Promise<RuleType>;
11
- create(data: PricingTypes.CreateRuleTypeDTO[], sharedContext: Context): Promise<RuleType[]>;
12
- update(data: PricingTypes.UpdateRuleTypeDTO[], sharedContext: Context): Promise<RuleType[]>;
13
- update(data: PricingTypes.UpdateRuleTypeDTO, sharedContext: Context): Promise<RuleType>;
14
- }
15
- export {};
@@ -1,53 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const utils_1 = require("@medusajs/utils");
16
- const _models_1 = require("../models");
17
- class RuleTypeService extends utils_1.ModulesSdkUtils.MedusaInternalService(_models_1.RuleType) {
18
- constructor({ ruleTypeRepository }) {
19
- // @ts-ignore
20
- super(...arguments);
21
- this.ruleTypeRepository_ = ruleTypeRepository;
22
- }
23
- async create(data, sharedContext = {}) {
24
- const data_ = Array.isArray(data) ? data : [data];
25
- (0, utils_1.validateRuleAttributes)(data_.map((d) => d.rule_attribute));
26
- return await super.create(data, sharedContext);
27
- }
28
- // TODO: add support for selector? and then rm ts ignore
29
- // @ts-ignore
30
- async update(data, sharedContext = {}) {
31
- const data_ = Array.isArray(data) ? data : [data];
32
- (0, utils_1.validateRuleAttributes)(data_.map((d) => d.rule_attribute));
33
- return await super.update(data, sharedContext);
34
- }
35
- }
36
- exports.default = RuleTypeService;
37
- __decorate([
38
- (0, utils_1.InjectTransactionManager)("ruleTypeRepository_"),
39
- __param(1, (0, utils_1.MedusaContext)()),
40
- __metadata("design:type", Function),
41
- __metadata("design:paramtypes", [Object, Object]),
42
- __metadata("design:returntype", Promise)
43
- ], RuleTypeService.prototype, "create", null);
44
- __decorate([
45
- (0, utils_1.InjectTransactionManager)("ruleTypeRepository_")
46
- // TODO: add support for selector? and then rm ts ignore
47
- // @ts-ignore
48
- ,
49
- __param(1, (0, utils_1.MedusaContext)()),
50
- __metadata("design:type", Function),
51
- __metadata("design:paramtypes", [Object, Object]),
52
- __metadata("design:returntype", Promise)
53
- ], RuleTypeService.prototype, "update", null);