@medusajs/promotion 0.0.5-snapshot-20240717160031 → 0.0.5-snapshot-20240718083016

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. package/dist/index.d.ts +4 -5
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +20 -5
  4. package/dist/initialize/index.d.ts +5 -0
  5. package/dist/initialize/index.d.ts.map +1 -0
  6. package/dist/initialize/index.js +16 -0
  7. package/dist/joiner-config.d.ts +8 -1
  8. package/dist/joiner-config.d.ts.map +1 -1
  9. package/dist/joiner-config.js +35 -4
  10. package/dist/loaders/connection.d.ts +5 -0
  11. package/dist/loaders/connection.d.ts.map +1 -0
  12. package/dist/loaders/connection.js +41 -0
  13. package/dist/loaders/container.d.ts +3 -0
  14. package/dist/loaders/container.d.ts.map +1 -0
  15. package/dist/loaders/container.js +34 -0
  16. package/dist/loaders/index.d.ts +3 -0
  17. package/dist/loaders/index.d.ts.map +1 -0
  18. package/dist/loaders/index.js +18 -0
  19. package/dist/migrations/Migration20240227120221.d.ts.map +1 -1
  20. package/dist/migrations/Migration20240227120221.js +2 -10
  21. package/dist/models/application-method.d.ts +6 -4
  22. package/dist/models/application-method.d.ts.map +1 -1
  23. package/dist/models/application-method.js +6 -16
  24. package/dist/models/campaign-budget.d.ts +5 -6
  25. package/dist/models/campaign-budget.d.ts.map +1 -1
  26. package/dist/models/campaign-budget.js +4 -8
  27. package/dist/models/campaign.d.ts +4 -3
  28. package/dist/models/campaign.d.ts.map +1 -1
  29. package/dist/models/campaign.js +13 -10
  30. package/dist/models/promotion-rule-value.d.ts +1 -2
  31. package/dist/models/promotion-rule-value.d.ts.map +1 -1
  32. package/dist/models/promotion-rule-value.js +1 -1
  33. package/dist/models/promotion-rule.d.ts +1 -1
  34. package/dist/models/promotion-rule.d.ts.map +1 -1
  35. package/dist/models/promotion.d.ts +4 -5
  36. package/dist/models/promotion.d.ts.map +1 -1
  37. package/dist/models/promotion.js +4 -8
  38. package/dist/module-definition.d.ts +5 -0
  39. package/dist/module-definition.d.ts.map +1 -0
  40. package/dist/module-definition.js +50 -0
  41. package/dist/repositories/campaign.d.ts +16 -0
  42. package/dist/repositories/campaign.d.ts.map +1 -0
  43. package/dist/repositories/campaign.js +90 -0
  44. package/dist/repositories/index.d.ts +3 -0
  45. package/dist/repositories/index.d.ts.map +1 -0
  46. package/dist/repositories/index.js +7 -0
  47. package/dist/services/promotion-module.d.ts +26 -40
  48. package/dist/services/promotion-module.d.ts.map +1 -1
  49. package/dist/services/promotion-module.js +62 -189
  50. package/dist/types/application-method.d.ts +10 -12
  51. package/dist/types/application-method.d.ts.map +1 -1
  52. package/dist/types/campaign-budget.d.ts +6 -8
  53. package/dist/types/campaign-budget.d.ts.map +1 -1
  54. package/dist/types/campaign.d.ts +8 -6
  55. package/dist/types/campaign.d.ts.map +1 -1
  56. package/dist/types/promotion.d.ts +2 -2
  57. package/dist/types/promotion.d.ts.map +1 -1
  58. package/dist/utils/compute-actions/buy-get.d.ts +2 -2
  59. package/dist/utils/compute-actions/buy-get.d.ts.map +1 -1
  60. package/dist/utils/compute-actions/buy-get.js +12 -12
  61. package/dist/utils/compute-actions/line-items.d.ts.map +1 -1
  62. package/dist/utils/compute-actions/line-items.js +4 -4
  63. package/dist/utils/compute-actions/shipping-methods.d.ts +2 -2
  64. package/dist/utils/compute-actions/shipping-methods.d.ts.map +1 -1
  65. package/dist/utils/compute-actions/shipping-methods.js +17 -14
  66. package/dist/utils/compute-actions/usage.d.ts +2 -2
  67. package/dist/utils/compute-actions/usage.d.ts.map +1 -1
  68. package/dist/utils/compute-actions/usage.js +3 -3
  69. package/dist/utils/validations/application-method.d.ts.map +1 -1
  70. package/dist/utils/validations/application-method.js +2 -2
  71. package/package.json +13 -8
  72. package/dist/migrations/Migration20240617102917.d.ts +0 -6
  73. package/dist/migrations/Migration20240617102917.d.ts.map +0 -1
  74. package/dist/migrations/Migration20240617102917.js +0 -15
  75. package/dist/migrations/Migration20240624153824.d.ts +0 -6
  76. package/dist/migrations/Migration20240624153824.d.ts.map +0 -1
  77. package/dist/migrations/Migration20240624153824.js +0 -15
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { PromotionModuleService } from "./services";
2
- declare const _default: import("@medusajs/types").ModuleExports<typeof PromotionModuleService> & {
3
- linkable: Record<string, any>;
4
- };
5
- export default _default;
1
+ import { moduleDefinition, revertMigration, runMigrations } from "./module-definition";
2
+ export default moduleDefinition;
3
+ export { revertMigration, runMigrations };
4
+ export * from "./initialize";
6
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAA;;;;AAElD,wBAEE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,aAAa,EACd,MAAM,qBAAqB,CAAA;AAE5B,eAAe,gBAAgB,CAAA;AAC/B,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,CAAA;AAEzC,cAAc,cAAc,CAAA"}
package/dist/index.js CHANGED
@@ -1,7 +1,22 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const utils_1 = require("@medusajs/utils");
4
- const _services_1 = require("./services");
5
- exports.default = (0, utils_1.Module)(utils_1.Modules.PROMOTION, {
6
- service: _services_1.PromotionModuleService,
7
- });
17
+ exports.runMigrations = exports.revertMigration = void 0;
18
+ const module_definition_1 = require("./module-definition");
19
+ Object.defineProperty(exports, "revertMigration", { enumerable: true, get: function () { return module_definition_1.revertMigration; } });
20
+ Object.defineProperty(exports, "runMigrations", { enumerable: true, get: function () { return module_definition_1.runMigrations; } });
21
+ exports.default = module_definition_1.moduleDefinition;
22
+ __exportStar(require("./initialize"), exports);
@@ -0,0 +1,5 @@
1
+ import { ExternalModuleDeclaration, InternalModuleDeclaration } from "@medusajs/modules-sdk";
2
+ import { IPromotionModuleService, ModulesSdkTypes } from "@medusajs/types";
3
+ import { InitializeModuleInjectableDependencies } from "../types";
4
+ export declare const initialize: (options?: ModulesSdkTypes.ModuleServiceInitializeOptions | ModulesSdkTypes.ModuleServiceInitializeCustomDataLayerOptions | ExternalModuleDeclaration | InternalModuleDeclaration, injectedDependencies?: InitializeModuleInjectableDependencies) => Promise<IPromotionModuleService>;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/initialize/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EAI1B,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAE1E,OAAO,EAAE,sCAAsC,EAAE,MAAM,UAAU,CAAA;AAEjE,eAAO,MAAM,UAAU,aAEjB,gBAAgB,8BAA8B,GAC9C,gBAAgB,6CAA6C,GAC7D,yBAAyB,GACzB,yBAAyB,yBACN,sCAAsC,KAC5D,QAAQ,uBAAuB,CAYjC,CAAA"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initialize = void 0;
4
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
5
+ const module_definition_1 = require("../module-definition");
6
+ const initialize = async (options, injectedDependencies) => {
7
+ const loaded = await modules_sdk_1.MedusaModule.bootstrap({
8
+ moduleKey: modules_sdk_1.Modules.PROMOTION,
9
+ defaultPath: modules_sdk_1.MODULE_PACKAGE_NAMES[modules_sdk_1.Modules.PROMOTION],
10
+ declaration: options,
11
+ injectedDependencies,
12
+ moduleExports: module_definition_1.moduleDefinition,
13
+ });
14
+ return loaded[modules_sdk_1.Modules.PROMOTION];
15
+ };
16
+ exports.initialize = initialize;
@@ -1,2 +1,9 @@
1
- export declare const joinerConfig: Omit<import("@medusajs/types").ModuleJoinerConfig, "serviceName" | "primaryKeys" | "alias" | "linkableKeys"> & Required<Pick<import("@medusajs/types").ModuleJoinerConfig, "serviceName" | "primaryKeys" | "alias" | "linkableKeys">>;
1
+ import { ModuleJoinerConfig } from "@medusajs/types";
2
+ export declare const LinkableKeys: {
3
+ promotion_id: string;
4
+ campaign_id: string;
5
+ promotion_rule_id: string;
6
+ };
7
+ export declare const entityNameToLinkableKeysMap: import("@medusajs/utils").MapToConfig;
8
+ export declare const joinerConfig: ModuleJoinerConfig;
2
9
  //# sourceMappingURL=joiner-config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"joiner-config.d.ts","sourceRoot":"","sources":["../src/joiner-config.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY,uOAEvB,CAAA"}
1
+ {"version":3,"file":"joiner-config.d.ts","sourceRoot":"","sources":["../src/joiner-config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAIpD,eAAO,MAAM,YAAY;;;;CAIxB,CAAA;AAED,eAAO,MAAM,2BAA2B,uCAAwC,CAAA;AAEhF,eAAO,MAAM,YAAY,EAAE,kBA0B1B,CAAA"}
@@ -1,8 +1,39 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.joinerConfig = void 0;
3
+ exports.joinerConfig = exports.entityNameToLinkableKeysMap = exports.LinkableKeys = void 0;
4
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
4
5
  const utils_1 = require("@medusajs/utils");
5
6
  const _models_1 = require("./models");
6
- exports.joinerConfig = (0, utils_1.defineJoinerConfig)(utils_1.Modules.PROMOTION, {
7
- models: [_models_1.Promotion, _models_1.Campaign, _models_1.PromotionRule],
8
- });
7
+ exports.LinkableKeys = {
8
+ promotion_id: _models_1.Promotion.name,
9
+ campaign_id: _models_1.Campaign.name,
10
+ promotion_rule_id: _models_1.PromotionRule.name,
11
+ };
12
+ exports.entityNameToLinkableKeysMap = (0, utils_1.generateLinkableKeysMap)(exports.LinkableKeys);
13
+ exports.joinerConfig = {
14
+ serviceName: modules_sdk_1.Modules.PROMOTION,
15
+ primaryKeys: ["id"],
16
+ linkableKeys: exports.LinkableKeys,
17
+ alias: [
18
+ {
19
+ name: ["promotion", "promotions"],
20
+ args: {
21
+ entity: _models_1.Promotion.name,
22
+ },
23
+ },
24
+ {
25
+ name: ["campaign", "campaigns"],
26
+ args: {
27
+ entity: _models_1.Campaign.name,
28
+ methodSuffix: "Campaigns",
29
+ },
30
+ },
31
+ {
32
+ name: ["promotion_rule", "promotion_rules"],
33
+ args: {
34
+ entity: _models_1.PromotionRule.name,
35
+ methodSuffix: "PromotionRules",
36
+ },
37
+ },
38
+ ],
39
+ };
@@ -0,0 +1,5 @@
1
+ import { InternalModuleDeclaration, LoaderOptions } from "@medusajs/modules-sdk";
2
+ import { ModulesSdkTypes } from "@medusajs/types";
3
+ declare const _default: ({ options, container, logger, }: LoaderOptions<ModulesSdkTypes.ModuleServiceInitializeOptions | ModulesSdkTypes.ModuleServiceInitializeCustomDataLayerOptions>, moduleDeclaration?: InternalModuleDeclaration) => Promise<void>;
4
+ export default _default;
5
+ //# sourceMappingURL=connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/loaders/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,aAAa,EAEd,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;0DAU5C,cACC,gBAAgB,8BAA8B,GAC9C,gBAAgB,6CAA6C,CAChE,sBACmB,yBAAyB,KAC5C,QAAQ,IAAI,CAAC;AAVhB,wBAuBC"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
27
+ const utils_1 = require("@medusajs/utils");
28
+ const PromotionModels = __importStar(require("../models"));
29
+ exports.default = async ({ options, container, logger, }, moduleDeclaration) => {
30
+ const entities = Object.values(PromotionModels);
31
+ const pathToMigrations = __dirname + "/../migrations";
32
+ await utils_1.ModulesSdkUtils.mikroOrmConnectionLoader({
33
+ moduleName: modules_sdk_1.Modules.PROMOTION,
34
+ entities,
35
+ container,
36
+ options,
37
+ moduleDeclaration,
38
+ logger,
39
+ pathToMigrations,
40
+ });
41
+ };
@@ -0,0 +1,3 @@
1
+ declare const _default: ({ container, options }: import("@medusajs/types").LoaderOptions) => Promise<void>;
2
+ export default _default;
3
+ //# sourceMappingURL=container.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/loaders/container.ts"],"names":[],"mappings":";AAKA,wBAIE"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const utils_1 = require("@medusajs/utils");
27
+ const ModuleModels = __importStar(require("../models"));
28
+ const ModuleRepositories = __importStar(require("../repositories"));
29
+ const ModuleServices = __importStar(require("../services"));
30
+ exports.default = utils_1.ModulesSdkUtils.moduleContainerLoaderFactory({
31
+ moduleModels: ModuleModels,
32
+ moduleRepositories: ModuleRepositories,
33
+ moduleServices: ModuleServices,
34
+ });
@@ -0,0 +1,3 @@
1
+ export * from "./connection";
2
+ export * from "./container";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/loaders/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./connection"), exports);
18
+ __exportStar(require("./container"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"Migration20240227120221.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20240227120221.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,qBAAa,uBAAwB,SAAQ,SAAS;IAC9C,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;CAiJ1B"}
1
+ {"version":3,"file":"Migration20240227120221.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20240227120221.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,qBAAa,uBAAwB,SAAQ,SAAS;IAC9C,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;CAiH1B"}
@@ -4,9 +4,9 @@ exports.Migration20240227120221 = void 0;
4
4
  const migrations_1 = require("@mikro-orm/migrations");
5
5
  class Migration20240227120221 extends migrations_1.Migration {
6
6
  async up() {
7
- this.addSql('create table if not exists "promotion_campaign" ("id" text not null, "name" text not null, "description" text null, "campaign_identifier" text not null, "starts_at" timestamptz null, "ends_at" timestamptz null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "promotion_campaign_pkey" primary key ("id"));');
7
+ this.addSql('create table if not exists "promotion_campaign" ("id" text not null, "name" text not null, "description" text null, "currency" text null, "campaign_identifier" text not null, "starts_at" timestamptz null, "ends_at" timestamptz null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "promotion_campaign_pkey" primary key ("id"));');
8
8
  this.addSql('alter table if exists "promotion_campaign" add constraint "IDX_campaign_identifier_unique" unique ("campaign_identifier");');
9
- this.addSql('create table if not exists "promotion_campaign_budget" ("id" text not null, "type" text check ("type" in (\'spend\', \'usage\')) not null, "campaign_id" text not null, "limit" numeric null, "raw_limit" jsonb null, "used" numeric not null default 0, "raw_used" jsonb not null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "promotion_campaign_budget_pkey" primary key ("id"));');
9
+ this.addSql('create table if not exists "promotion_campaign_budget" ("id" text not null, "type" text check ("type" in (\'spend\', \'usage\')) not null, "campaign_id" text not null, "limit" numeric null, "raw_limit" jsonb null, "used" numeric null, "raw_used" jsonb null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "promotion_campaign_budget_pkey" primary key ("id"));');
10
10
  this.addSql('create index if not exists "IDX_campaign_budget_type" on "promotion_campaign_budget" ("type");');
11
11
  this.addSql('alter table if exists "promotion_campaign_budget" add constraint "promotion_campaign_budget_campaign_id_unique" unique ("campaign_id");');
12
12
  this.addSql('create table if not exists "promotion" ("id" text not null, "code" text not null, "campaign_id" text null, "is_automatic" boolean not null default false, "type" text check ("type" in (\'standard\', \'buyget\')) not null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "promotion_pkey" primary key ("id"));');
@@ -36,14 +36,6 @@ class Migration20240227120221 extends migrations_1.Migration {
36
36
  this.addSql('alter table if exists "application_method_buy_rules" add constraint "application_method_buy_rules_application_method_id_foreign" foreign key ("application_method_id") references "promotion_application_method" ("id") on update cascade on delete cascade;');
37
37
  this.addSql('alter table if exists "application_method_buy_rules" add constraint "application_method_buy_rules_promotion_rule_id_foreign" foreign key ("promotion_rule_id") references "promotion_rule" ("id") on update cascade on delete cascade;');
38
38
  this.addSql('alter table if exists "promotion_rule_value" add constraint "promotion_rule_value_promotion_rule_id_foreign" foreign key ("promotion_rule_id") references "promotion_rule" ("id") on update cascade on delete cascade;');
39
- this.addSql('alter table if exists "promotion" drop constraint if exists "promotion_campaign_id_foreign";');
40
- this.addSql('alter table if exists "promotion" add constraint "promotion_campaign_id_foreign" foreign key ("campaign_id") references "promotion_campaign" ("id") on update cascade on delete set null;');
41
- this.addSql('alter table if exists "promotion_application_method" add column if not exists "currency_code" text not null;');
42
- this.addSql('CREATE INDEX IF NOT EXISTS "IDX_promotion_application_method_currency_code" ON "promotion_application_method" (currency_code) WHERE deleted_at IS NOT NULL;');
43
- this.addSql('alter table "promotion_application_method" alter column "value" type numeric using ("value"::numeric);');
44
- this.addSql('alter table "promotion_application_method" alter column "raw_value" type jsonb using ("raw_value"::jsonb);');
45
- this.addSql('alter table "promotion_application_method" alter column "raw_value" set not null;');
46
- this.addSql('alter table if exists "promotion_campaign_budget" add column if not exists "currency_code" text null;');
47
39
  }
48
40
  }
49
41
  exports.Migration20240227120221 = Migration20240227120221;
@@ -1,20 +1,21 @@
1
- import { ApplicationMethodAllocationValues, ApplicationMethodTargetTypeValues, ApplicationMethodTypeValues, BigNumberRawValue } from "@medusajs/types";
1
+ import { ApplicationMethodAllocationValues, ApplicationMethodTargetTypeValues, ApplicationMethodTypeValues, BigNumberRawValue, DAL } from "@medusajs/types";
2
2
  import { BigNumber } from "@medusajs/utils";
3
- import { Collection, Rel } from "@mikro-orm/core";
3
+ import { Collection, OptionalProps } from "@mikro-orm/core";
4
4
  import Promotion from "./promotion";
5
5
  import PromotionRule from "./promotion-rule";
6
+ type OptionalFields = "value" | "max_quantity" | "apply_to_quantity" | "buy_rules_min_quantity" | "allocation" | DAL.SoftDeletableEntityDateColumns;
6
7
  export default class ApplicationMethod {
8
+ [OptionalProps]?: OptionalFields;
7
9
  id: string;
8
10
  value: BigNumber | number | null;
9
11
  raw_value: BigNumberRawValue | null;
10
- currency_code: string | null;
11
12
  max_quantity?: number | null;
12
13
  apply_to_quantity?: number | null;
13
14
  buy_rules_min_quantity?: number | null;
14
15
  type: ApplicationMethodTypeValues;
15
16
  target_type: ApplicationMethodTargetTypeValues;
16
17
  allocation?: ApplicationMethodAllocationValues;
17
- promotion: Rel<Promotion>;
18
+ promotion: Promotion;
18
19
  target_rules: Collection<PromotionRule, object>;
19
20
  buy_rules: Collection<PromotionRule, object>;
20
21
  created_at: Date;
@@ -23,4 +24,5 @@ export default class ApplicationMethod {
23
24
  onCreate(): void;
24
25
  onInit(): void;
25
26
  }
27
+ export {};
26
28
  //# sourceMappingURL=application-method.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"application-method.d.ts","sourceRoot":"","sources":["../../src/models/application-method.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EACjC,iCAAiC,EACjC,2BAA2B,EAC3B,iBAAiB,EAClB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,SAAS,EAMV,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAEL,UAAU,EAUV,GAAG,EACJ,MAAM,iBAAiB,CAAA;AACxB,OAAO,SAAS,MAAM,aAAa,CAAA;AACnC,OAAO,aAAa,MAAM,kBAAkB,CAAA;AAW5C,MAAM,CAAC,OAAO,OAAO,iBAAiB;IAEpC,EAAE,EAAG,MAAM,CAAA;IAGX,KAAK,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,CAAA;IAGhC,SAAS,EAAE,iBAAiB,GAAG,IAAI,CAAA;IAInC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAO;IAGnC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAO;IAGnC,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAO;IAGxC,sBAAsB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAO;IAI7C,IAAI,EAAE,2BAA2B,CAAA;IAIjC,WAAW,EAAE,iCAAiC,CAAA;IAO9C,UAAU,CAAC,EAAE,iCAAiC,CAAA;IAM9C,SAAS,EAAE,GAAG,CAAC,SAAS,CAAC,CAAA;IAOzB,YAAY,oCAA2C;IAOvD,SAAS,oCAA2C;IAOpD,UAAU,EAAE,IAAI,CAAA;IAQhB,UAAU,EAAE,IAAI,CAAA;IAGhB,UAAU,EAAE,IAAI,GAAG,IAAI,CAAO;IAG9B,QAAQ;IAKR,MAAM;CAGP"}
1
+ {"version":3,"file":"application-method.d.ts","sourceRoot":"","sources":["../../src/models/application-method.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EACjC,iCAAiC,EACjC,2BAA2B,EAC3B,iBAAiB,EACjB,GAAG,EACJ,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,SAAS,EAKV,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAEL,UAAU,EAQV,aAAa,EAGd,MAAM,iBAAiB,CAAA;AACxB,OAAO,SAAS,MAAM,aAAa,CAAA;AACnC,OAAO,aAAa,MAAM,kBAAkB,CAAA;AAE5C,KAAK,cAAc,GACf,OAAO,GACP,cAAc,GACd,mBAAmB,GACnB,wBAAwB,GACxB,YAAY,GACZ,GAAG,CAAC,8BAA8B,CAAA;AAItC,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACpC,CAAC,aAAa,CAAC,CAAC,EAAE,cAAc,CAAA;IAGhC,EAAE,EAAG,MAAM,CAAA;IAGX,KAAK,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,CAAO;IAGvC,SAAS,EAAE,iBAAiB,GAAG,IAAI,CAAO;IAG1C,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAO;IAGnC,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAO;IAGxC,sBAAsB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAO;IAI7C,IAAI,EAAE,2BAA2B,CAAA;IAIjC,WAAW,EAAE,iCAAiC,CAAA;IAO9C,UAAU,CAAC,EAAE,iCAAiC,CAAA;IAM9C,SAAS,EAAE,SAAS,CAAA;IAOpB,YAAY,oCAAsC;IAOlD,SAAS,oCAAsC;IAO/C,UAAU,EAAE,IAAI,CAAA;IAQhB,UAAU,EAAE,IAAI,CAAA;IAGhB,UAAU,EAAE,IAAI,GAAG,IAAI,CAAO;IAG9B,QAAQ;IAKR,MAAM;CAGP"}
@@ -16,15 +16,10 @@ const utils_1 = require("@medusajs/utils");
16
16
  const core_1 = require("@mikro-orm/core");
17
17
  const promotion_1 = __importDefault(require("./promotion"));
18
18
  const promotion_rule_1 = __importDefault(require("./promotion-rule"));
19
- const tableName = "promotion_application_method";
20
- const CurrencyCodeIndex = (0, utils_1.createPsqlIndexStatementHelper)({
21
- tableName,
22
- columns: "currency_code",
23
- where: "deleted_at IS NOT NULL",
24
- });
25
19
  let ApplicationMethod = class ApplicationMethod {
26
20
  constructor() {
27
- this.currency_code = null;
21
+ this.value = null;
22
+ this.raw_value = null;
28
23
  this.max_quantity = null;
29
24
  this.apply_to_quantity = null;
30
25
  this.buy_rules_min_quantity = null;
@@ -44,18 +39,13 @@ __decorate([
44
39
  __metadata("design:type", String)
45
40
  ], ApplicationMethod.prototype, "id", void 0);
46
41
  __decorate([
47
- (0, utils_1.MikroOrmBigNumberProperty)(),
42
+ (0, utils_1.MikroOrmBigNumberProperty)({ nullable: true }),
48
43
  __metadata("design:type", Object)
49
44
  ], ApplicationMethod.prototype, "value", void 0);
50
45
  __decorate([
51
- (0, core_1.Property)({ columnType: "jsonb" }),
46
+ (0, core_1.Property)({ columnType: "jsonb", nullable: true }),
52
47
  __metadata("design:type", Object)
53
48
  ], ApplicationMethod.prototype, "raw_value", void 0);
54
- __decorate([
55
- (0, core_1.Property)({ columnType: "text", nullable: true }),
56
- CurrencyCodeIndex.MikroORMIndex(),
57
- __metadata("design:type", Object)
58
- ], ApplicationMethod.prototype, "currency_code", void 0);
59
49
  __decorate([
60
50
  (0, core_1.Property)({ columnType: "numeric", nullable: true, serializer: Number }),
61
51
  __metadata("design:type", Object)
@@ -91,7 +81,7 @@ __decorate([
91
81
  entity: () => promotion_1.default,
92
82
  onDelete: "cascade",
93
83
  }),
94
- __metadata("design:type", Object)
84
+ __metadata("design:type", promotion_1.default)
95
85
  ], ApplicationMethod.prototype, "promotion", void 0);
96
86
  __decorate([
97
87
  (0, core_1.ManyToMany)(() => promotion_rule_1.default, "method_target_rules", {
@@ -143,7 +133,7 @@ __decorate([
143
133
  __metadata("design:returntype", void 0)
144
134
  ], ApplicationMethod.prototype, "onInit", null);
145
135
  ApplicationMethod = __decorate([
146
- (0, core_1.Entity)({ tableName }),
136
+ (0, core_1.Entity)({ tableName: "promotion_application_method" }),
147
137
  (0, core_1.Filter)(utils_1.DALUtils.mikroOrmSoftDeletableFilterOptions)
148
138
  ], ApplicationMethod);
149
139
  exports.default = ApplicationMethod;
@@ -1,18 +1,17 @@
1
1
  import { BigNumberRawValue, CampaignBudgetTypeValues, DAL } from "@medusajs/types";
2
2
  import { BigNumber } from "@medusajs/utils";
3
- import { OptionalProps, Rel } from "@mikro-orm/core";
3
+ import { OptionalProps } from "@mikro-orm/core";
4
4
  import Campaign from "./campaign";
5
- type OptionalFields = "description" | "limit" | "used" | DAL.SoftDeletableModelDateColumns;
5
+ type OptionalFields = "description" | "limit" | "used" | DAL.SoftDeletableEntityDateColumns;
6
6
  export default class CampaignBudget {
7
7
  [OptionalProps]?: OptionalFields;
8
8
  id: string;
9
9
  type: CampaignBudgetTypeValues;
10
- campaign: Rel<Campaign> | null;
11
- currency_code: string | null;
10
+ campaign: Campaign | null;
12
11
  limit: BigNumber | number | null;
13
12
  raw_limit: BigNumberRawValue | null;
14
- used: BigNumber | number;
15
- raw_used: BigNumberRawValue;
13
+ used: BigNumber | number | null;
14
+ raw_used: BigNumberRawValue | null;
16
15
  created_at: Date;
17
16
  updated_at: Date;
18
17
  deleted_at: Date | null;
@@ -1 +1 @@
1
- {"version":3,"file":"campaign-budget.d.ts","sourceRoot":"","sources":["../../src/models/campaign-budget.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,GAAG,EACJ,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,SAAS,EAKV,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAQL,aAAa,EAGb,GAAG,EACJ,MAAM,iBAAiB,CAAA;AACxB,OAAO,QAAQ,MAAM,YAAY,CAAA;AAEjC,KAAK,cAAc,GACf,aAAa,GACb,OAAO,GACP,MAAM,GACN,GAAG,CAAC,6BAA6B,CAAA;AAIrC,MAAM,CAAC,OAAO,OAAO,cAAc;IACjC,CAAC,aAAa,CAAC,CAAC,EAAE,cAAc,CAAA;IAGhC,EAAE,EAAG,MAAM,CAAA;IAIX,IAAI,EAAE,wBAAwB,CAAA;IAK9B,QAAQ,EAAE,GAAG,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAO;IAGrC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAO;IAGnC,KAAK,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,CAAO;IAGvC,SAAS,EAAE,iBAAiB,GAAG,IAAI,CAAO;IAG1C,IAAI,EAAE,SAAS,GAAG,MAAM,CAAI;IAG5B,QAAQ,EAAE,iBAAiB,CAAA;IAO3B,UAAU,EAAE,IAAI,CAAA;IAQhB,UAAU,EAAE,IAAI,CAAA;IAGhB,UAAU,EAAE,IAAI,GAAG,IAAI,CAAO;IAG9B,QAAQ;IAKR,MAAM;CAGP"}
1
+ {"version":3,"file":"campaign-budget.d.ts","sourceRoot":"","sources":["../../src/models/campaign-budget.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,GAAG,EACJ,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,SAAS,EAKV,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAQL,aAAa,EAGd,MAAM,iBAAiB,CAAA;AACxB,OAAO,QAAQ,MAAM,YAAY,CAAA;AAEjC,KAAK,cAAc,GACf,aAAa,GACb,OAAO,GACP,MAAM,GACN,GAAG,CAAC,8BAA8B,CAAA;AAItC,MAAM,CAAC,OAAO,OAAO,cAAc;IACjC,CAAC,aAAa,CAAC,CAAC,EAAE,cAAc,CAAA;IAGhC,EAAE,EAAG,MAAM,CAAA;IAIX,IAAI,EAAE,wBAAwB,CAAA;IAK9B,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAO;IAGhC,KAAK,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,CAAO;IAGvC,SAAS,EAAE,iBAAiB,GAAG,IAAI,CAAO;IAG1C,IAAI,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,CAAO;IAGtC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAO;IAOzC,UAAU,EAAE,IAAI,CAAA;IAQhB,UAAU,EAAE,IAAI,CAAA;IAGhB,UAAU,EAAE,IAAI,GAAG,IAAI,CAAO;IAG9B,QAAQ;IAKR,MAAM;CAGP"}
@@ -18,10 +18,10 @@ const campaign_1 = __importDefault(require("./campaign"));
18
18
  let CampaignBudget = class CampaignBudget {
19
19
  constructor() {
20
20
  this.campaign = null;
21
- this.currency_code = null;
22
21
  this.limit = null;
23
22
  this.raw_limit = null;
24
- this.used = 0;
23
+ this.used = null;
24
+ this.raw_used = null;
25
25
  this.deleted_at = null;
26
26
  }
27
27
  onCreate() {
@@ -46,10 +46,6 @@ __decorate([
46
46
  }),
47
47
  __metadata("design:type", Object)
48
48
  ], CampaignBudget.prototype, "campaign", void 0);
49
- __decorate([
50
- (0, core_1.Property)({ columnType: "text", nullable: true }),
51
- __metadata("design:type", Object)
52
- ], CampaignBudget.prototype, "currency_code", void 0);
53
49
  __decorate([
54
50
  (0, utils_1.MikroOrmBigNumberProperty)({ nullable: true }),
55
51
  __metadata("design:type", Object)
@@ -59,11 +55,11 @@ __decorate([
59
55
  __metadata("design:type", Object)
60
56
  ], CampaignBudget.prototype, "raw_limit", void 0);
61
57
  __decorate([
62
- (0, utils_1.MikroOrmBigNumberProperty)({ default: 0 }),
58
+ (0, utils_1.MikroOrmBigNumberProperty)({ nullable: true }),
63
59
  __metadata("design:type", Object)
64
60
  ], CampaignBudget.prototype, "used", void 0);
65
61
  __decorate([
66
- (0, core_1.Property)({ columnType: "jsonb" }),
62
+ (0, core_1.Property)({ columnType: "jsonb", nullable: true }),
67
63
  __metadata("design:type", Object)
68
64
  ], CampaignBudget.prototype, "raw_used", void 0);
69
65
  __decorate([
@@ -1,18 +1,19 @@
1
1
  import { DAL } from "@medusajs/types";
2
- import { Collection, OptionalProps, Rel } from "@mikro-orm/core";
2
+ import { Collection, OptionalProps } from "@mikro-orm/core";
3
3
  import CampaignBudget from "./campaign-budget";
4
4
  import Promotion from "./promotion";
5
5
  type OptionalRelations = "budget";
6
- type OptionalFields = "description" | "starts_at" | "ends_at" | DAL.SoftDeletableModelDateColumns;
6
+ type OptionalFields = "description" | "currency" | "starts_at" | "ends_at" | DAL.SoftDeletableEntityDateColumns;
7
7
  export default class Campaign {
8
8
  [OptionalProps]?: OptionalFields | OptionalRelations;
9
9
  id: string;
10
10
  name: string;
11
11
  description: string | null;
12
+ currency: string | null;
12
13
  campaign_identifier: string;
13
14
  starts_at: Date | null;
14
15
  ends_at: Date | null;
15
- budget: Rel<CampaignBudget> | null;
16
+ budget: CampaignBudget | null;
16
17
  promotions: Collection<Promotion, object>;
17
18
  created_at: Date;
18
19
  updated_at: Date;
@@ -1 +1 @@
1
- {"version":3,"file":"campaign.d.ts","sourceRoot":"","sources":["../../src/models/campaign.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAOrC,OAAO,EAEL,UAAU,EAMV,aAAa,EAGb,GAAG,EACJ,MAAM,iBAAiB,CAAA;AACxB,OAAO,cAAc,MAAM,mBAAmB,CAAA;AAC9C,OAAO,SAAS,MAAM,aAAa,CAAA;AAEnC,KAAK,iBAAiB,GAAG,QAAQ,CAAA;AACjC,KAAK,cAAc,GACf,aAAa,GACb,WAAW,GACX,SAAS,GACT,GAAG,CAAC,6BAA6B,CAAA;AAYrC,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC3B,CAAC,aAAa,CAAC,CAAC,EAAE,cAAc,GAAG,iBAAiB,CAAA;IAGpD,EAAE,EAAG,MAAM,CAAA;IAIX,IAAI,EAAE,MAAM,CAAA;IAIZ,WAAW,EAAE,MAAM,GAAG,IAAI,CAAO;IAIjC,mBAAmB,EAAE,MAAM,CAAA;IAM3B,SAAS,EAAE,IAAI,GAAG,IAAI,CAAO;IAM7B,OAAO,EAAE,IAAI,GAAG,IAAI,CAAO;IAQ3B,MAAM,EAAE,GAAG,CAAC,cAAc,CAAC,GAAG,IAAI,CAAO;IAGzC,UAAU,gCAAuC;IAOjD,UAAU,EAAE,IAAI,CAAA;IAQhB,UAAU,EAAE,IAAI,CAAA;IAGhB,UAAU,EAAE,IAAI,GAAG,IAAI,CAAO;IAG9B,QAAQ;IAKR,MAAM;CAGP"}
1
+ {"version":3,"file":"campaign.d.ts","sourceRoot":"","sources":["../../src/models/campaign.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAErC,OAAO,EAEL,UAAU,EAMV,aAAa,EAId,MAAM,iBAAiB,CAAA;AACxB,OAAO,cAAc,MAAM,mBAAmB,CAAA;AAC9C,OAAO,SAAS,MAAM,aAAa,CAAA;AAEnC,KAAK,iBAAiB,GAAG,QAAQ,CAAA;AACjC,KAAK,cAAc,GACf,aAAa,GACb,UAAU,GACV,WAAW,GACX,SAAS,GACT,GAAG,CAAC,8BAA8B,CAAA;AAItC,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC3B,CAAC,aAAa,CAAC,CAAC,EAAE,cAAc,GAAG,iBAAiB,CAAA;IAGpD,EAAE,EAAG,MAAM,CAAA;IAIX,IAAI,EAAE,MAAM,CAAA;IAIZ,WAAW,EAAE,MAAM,GAAG,IAAI,CAAO;IAGjC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAO;IAO9B,mBAAmB,EAAE,MAAM,CAAA;IAM3B,SAAS,EAAE,IAAI,GAAG,IAAI,CAAO;IAM7B,OAAO,EAAE,IAAI,GAAG,IAAI,CAAO;IAQ3B,MAAM,EAAE,cAAc,GAAG,IAAI,CAAO;IAKpC,UAAU,gCAAkC;IAO5C,UAAU,EAAE,IAAI,CAAA;IAQhB,UAAU,EAAE,IAAI,CAAA;IAGhB,UAAU,EAAE,IAAI,GAAG,IAAI,CAAO;IAG9B,QAAQ;IAKR,MAAM;CAGP"}
@@ -16,16 +16,10 @@ const utils_1 = require("@medusajs/utils");
16
16
  const core_1 = require("@mikro-orm/core");
17
17
  const campaign_budget_1 = __importDefault(require("./campaign-budget"));
18
18
  const promotion_1 = __importDefault(require("./promotion"));
19
- const tableName = "promotion_campaign";
20
- const CampaignUniqueCampaignIdentifier = (0, utils_1.createPsqlIndexStatementHelper)({
21
- tableName,
22
- columns: ["campaign_identifier"],
23
- unique: true,
24
- where: "deleted_at IS NULL",
25
- });
26
19
  let Campaign = class Campaign {
27
20
  constructor() {
28
21
  this.description = null;
22
+ this.currency = null;
29
23
  this.starts_at = null;
30
24
  this.ends_at = null;
31
25
  this.budget = null;
@@ -53,9 +47,16 @@ __decorate([
53
47
  (0, core_1.Property)({ columnType: "text", nullable: true }),
54
48
  __metadata("design:type", Object)
55
49
  ], Campaign.prototype, "description", void 0);
50
+ __decorate([
51
+ (0, core_1.Property)({ columnType: "text", nullable: true }),
52
+ __metadata("design:type", Object)
53
+ ], Campaign.prototype, "currency", void 0);
56
54
  __decorate([
57
55
  (0, core_1.Property)({ columnType: "text" }),
58
- CampaignUniqueCampaignIdentifier.MikroORMIndex(),
56
+ (0, core_1.Unique)({
57
+ name: "IDX_campaign_identifier_unique",
58
+ properties: ["campaign_identifier"],
59
+ }),
59
60
  __metadata("design:type", String)
60
61
  ], Campaign.prototype, "campaign_identifier", void 0);
61
62
  __decorate([
@@ -82,7 +83,9 @@ __decorate([
82
83
  __metadata("design:type", Object)
83
84
  ], Campaign.prototype, "budget", void 0);
84
85
  __decorate([
85
- (0, core_1.OneToMany)(() => promotion_1.default, (promotion) => promotion.campaign),
86
+ (0, core_1.OneToMany)(() => promotion_1.default, (promotion) => promotion.campaign, {
87
+ orphanRemoval: true,
88
+ }),
86
89
  __metadata("design:type", Object)
87
90
  ], Campaign.prototype, "promotions", void 0);
88
91
  __decorate([
@@ -119,7 +122,7 @@ __decorate([
119
122
  __metadata("design:returntype", void 0)
120
123
  ], Campaign.prototype, "onInit", null);
121
124
  Campaign = __decorate([
122
- (0, core_1.Entity)({ tableName }),
125
+ (0, core_1.Entity)({ tableName: "promotion_campaign" }),
123
126
  (0, core_1.Filter)(utils_1.DALUtils.mikroOrmSoftDeletableFilterOptions)
124
127
  ], Campaign);
125
128
  exports.default = Campaign;
@@ -1,8 +1,7 @@
1
- import { Rel } from "@mikro-orm/core";
2
1
  import PromotionRule from "./promotion-rule";
3
2
  export default class PromotionRuleValue {
4
3
  id: string;
5
- promotion_rule: Rel<PromotionRule>;
4
+ promotion_rule: PromotionRule;
6
5
  value: string;
7
6
  created_at: Date;
8
7
  updated_at: Date;
@@ -1 +1 @@
1
- {"version":3,"file":"promotion-rule-value.d.ts","sourceRoot":"","sources":["../../src/models/promotion-rule-value.ts"],"names":[],"mappings":"AACA,OAAO,EAQL,GAAG,EACJ,MAAM,iBAAiB,CAAA;AACxB,OAAO,aAAa,MAAM,kBAAkB,CAAA;AAI5C,MAAM,CAAC,OAAO,OAAO,kBAAkB;IAErC,EAAE,EAAG,MAAM,CAAA;IAOX,cAAc,EAAE,GAAG,CAAC,aAAa,CAAC,CAAA;IAGlC,KAAK,EAAE,MAAM,CAAA;IAOb,UAAU,EAAE,IAAI,CAAA;IAQhB,UAAU,EAAE,IAAI,CAAA;IAGhB,UAAU,EAAE,IAAI,GAAG,IAAI,CAAO;IAG9B,QAAQ;IAKR,MAAM;CAGP"}
1
+ {"version":3,"file":"promotion-rule-value.d.ts","sourceRoot":"","sources":["../../src/models/promotion-rule-value.ts"],"names":[],"mappings":"AAUA,OAAO,aAAa,MAAM,kBAAkB,CAAA;AAI5C,MAAM,CAAC,OAAO,OAAO,kBAAkB;IAErC,EAAE,EAAG,MAAM,CAAA;IAOX,cAAc,EAAE,aAAa,CAAA;IAG7B,KAAK,EAAE,MAAM,CAAA;IAOb,UAAU,EAAE,IAAI,CAAA;IAQhB,UAAU,EAAE,IAAI,CAAA;IAGhB,UAAU,EAAE,IAAI,GAAG,IAAI,CAAO;IAG9B,QAAQ;IAKR,MAAM;CAGP"}
@@ -36,7 +36,7 @@ __decorate([
36
36
  fieldName: "promotion_rule_id",
37
37
  index: "IDX_promotion_rule_promotion_rule_value_id",
38
38
  }),
39
- __metadata("design:type", Object)
39
+ __metadata("design:type", promotion_rule_1.default)
40
40
  ], PromotionRuleValue.prototype, "promotion_rule", void 0);
41
41
  __decorate([
42
42
  (0, core_1.Property)({ columnType: "text" }),
@@ -3,7 +3,7 @@ import { Collection, OptionalProps } from "@mikro-orm/core";
3
3
  import ApplicationMethod from "./application-method";
4
4
  import Promotion from "./promotion";
5
5
  import PromotionRuleValue from "./promotion-rule-value";
6
- type OptionalFields = "description" | DAL.SoftDeletableModelDateColumns;
6
+ type OptionalFields = "description" | DAL.SoftDeletableEntityDateColumns;
7
7
  type OptionalRelations = "values" | "promotions";
8
8
  export default class PromotionRule {
9
9
  [OptionalProps]?: OptionalFields | OptionalRelations;
@@ -1 +1 @@
1
- {"version":3,"file":"promotion-rule.d.ts","sourceRoot":"","sources":["../../src/models/promotion-rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAA;AAElE,OAAO,EAGL,UAAU,EAQV,aAAa,EAId,MAAM,iBAAiB,CAAA;AACxB,OAAO,iBAAiB,MAAM,sBAAsB,CAAA;AACpD,OAAO,SAAS,MAAM,aAAa,CAAA;AACnC,OAAO,kBAAkB,MAAM,wBAAwB,CAAA;AAEvD,KAAK,cAAc,GAAG,aAAa,GAAG,GAAG,CAAC,6BAA6B,CAAA;AACvE,KAAK,iBAAiB,GAAG,QAAQ,GAAG,YAAY,CAAA;AAIhD,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC,CAAC,aAAa,CAAC,CAAC,EAAE,cAAc,GAAG,iBAAiB,CAAA;IAGpD,EAAE,EAAG,MAAM,CAAA;IAGX,WAAW,EAAE,MAAM,GAAG,IAAI,CAAO;IAIjC,SAAS,EAAE,MAAM,CAAA;IAIjB,QAAQ,EAAE,2BAA2B,CAAA;IAKrC,MAAM,yCAAgD;IAGtD,UAAU,gCAAuC;IAMjD,mBAAmB,wCAA+C;IAMlE,gBAAgB,wCAA+C;IAO/D,UAAU,EAAE,IAAI,CAAA;IAQhB,UAAU,EAAE,IAAI,CAAA;IAGhB,UAAU,EAAE,IAAI,GAAG,IAAI,CAAO;IAG9B,QAAQ;IAKR,MAAM;CAGP"}
1
+ {"version":3,"file":"promotion-rule.d.ts","sourceRoot":"","sources":["../../src/models/promotion-rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAA;AAElE,OAAO,EAGL,UAAU,EAQV,aAAa,EAGd,MAAM,iBAAiB,CAAA;AACxB,OAAO,iBAAiB,MAAM,sBAAsB,CAAA;AACpD,OAAO,SAAS,MAAM,aAAa,CAAA;AACnC,OAAO,kBAAkB,MAAM,wBAAwB,CAAA;AAEvD,KAAK,cAAc,GAAG,aAAa,GAAG,GAAG,CAAC,8BAA8B,CAAA;AACxE,KAAK,iBAAiB,GAAG,QAAQ,GAAG,YAAY,CAAA;AAIhD,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC,CAAC,aAAa,CAAC,CAAC,EAAE,cAAc,GAAG,iBAAiB,CAAA;IAGpD,EAAE,EAAG,MAAM,CAAA;IAGX,WAAW,EAAE,MAAM,GAAG,IAAI,CAAO;IAIjC,SAAS,EAAE,MAAM,CAAA;IAIjB,QAAQ,EAAE,2BAA2B,CAAA;IAKrC,MAAM,yCAA2C;IAGjD,UAAU,gCAAkC;IAM5C,mBAAmB,wCAA0C;IAM7D,gBAAgB,wCAA0C;IAO1D,UAAU,EAAE,IAAI,CAAA;IAQhB,UAAU,EAAE,IAAI,CAAA;IAGhB,UAAU,EAAE,IAAI,GAAG,IAAI,CAAO;IAG9B,QAAQ;IAKR,MAAM;CAGP"}