@medusajs/promotion 0.0.5-snapshot-20240718073308 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +4 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -5
- package/dist/initialize/index.d.ts +5 -0
- package/dist/initialize/index.d.ts.map +1 -0
- package/dist/initialize/index.js +16 -0
- package/dist/joiner-config.d.ts +8 -1
- package/dist/joiner-config.d.ts.map +1 -1
- package/dist/joiner-config.js +35 -4
- package/dist/loaders/connection.d.ts +5 -0
- package/dist/loaders/connection.d.ts.map +1 -0
- package/dist/loaders/connection.js +41 -0
- package/dist/loaders/container.d.ts +3 -0
- package/dist/loaders/container.d.ts.map +1 -0
- package/dist/loaders/container.js +34 -0
- package/dist/loaders/index.d.ts +3 -0
- package/dist/loaders/index.d.ts.map +1 -0
- package/dist/loaders/index.js +18 -0
- package/dist/migrations/Migration20240227120221.d.ts.map +1 -1
- package/dist/migrations/Migration20240227120221.js +2 -10
- package/dist/models/application-method.d.ts +6 -4
- package/dist/models/application-method.d.ts.map +1 -1
- package/dist/models/application-method.js +6 -16
- package/dist/models/campaign-budget.d.ts +5 -6
- package/dist/models/campaign-budget.d.ts.map +1 -1
- package/dist/models/campaign-budget.js +4 -8
- package/dist/models/campaign.d.ts +4 -3
- package/dist/models/campaign.d.ts.map +1 -1
- package/dist/models/campaign.js +13 -10
- package/dist/models/promotion-rule-value.d.ts +1 -2
- package/dist/models/promotion-rule-value.d.ts.map +1 -1
- package/dist/models/promotion-rule-value.js +1 -1
- package/dist/models/promotion-rule.d.ts +1 -1
- package/dist/models/promotion-rule.d.ts.map +1 -1
- package/dist/models/promotion.d.ts +4 -5
- package/dist/models/promotion.d.ts.map +1 -1
- package/dist/models/promotion.js +4 -8
- package/dist/module-definition.d.ts +5 -0
- package/dist/module-definition.d.ts.map +1 -0
- package/dist/module-definition.js +50 -0
- package/dist/repositories/campaign.d.ts +16 -0
- package/dist/repositories/campaign.d.ts.map +1 -0
- package/dist/repositories/campaign.js +90 -0
- package/dist/repositories/index.d.ts +3 -0
- package/dist/repositories/index.d.ts.map +1 -0
- package/dist/repositories/index.js +7 -0
- package/dist/services/promotion-module.d.ts +26 -40
- package/dist/services/promotion-module.d.ts.map +1 -1
- package/dist/services/promotion-module.js +62 -189
- package/dist/types/application-method.d.ts +10 -12
- package/dist/types/application-method.d.ts.map +1 -1
- package/dist/types/campaign-budget.d.ts +6 -8
- package/dist/types/campaign-budget.d.ts.map +1 -1
- package/dist/types/campaign.d.ts +8 -6
- package/dist/types/campaign.d.ts.map +1 -1
- package/dist/types/promotion.d.ts +2 -2
- package/dist/types/promotion.d.ts.map +1 -1
- package/dist/utils/compute-actions/buy-get.d.ts +2 -2
- package/dist/utils/compute-actions/buy-get.d.ts.map +1 -1
- package/dist/utils/compute-actions/buy-get.js +12 -12
- package/dist/utils/compute-actions/line-items.d.ts.map +1 -1
- package/dist/utils/compute-actions/line-items.js +4 -4
- package/dist/utils/compute-actions/shipping-methods.d.ts +2 -2
- package/dist/utils/compute-actions/shipping-methods.d.ts.map +1 -1
- package/dist/utils/compute-actions/shipping-methods.js +17 -14
- package/dist/utils/compute-actions/usage.d.ts +2 -2
- package/dist/utils/compute-actions/usage.d.ts.map +1 -1
- package/dist/utils/compute-actions/usage.js +3 -3
- package/dist/utils/validations/application-method.d.ts.map +1 -1
- package/dist/utils/validations/application-method.js +2 -2
- package/package.json +13 -8
- package/dist/migrations/Migration20240617102917.d.ts +0 -6
- package/dist/migrations/Migration20240617102917.d.ts.map +0 -1
- package/dist/migrations/Migration20240617102917.js +0 -15
- package/dist/migrations/Migration20240624153824.d.ts +0 -6
- package/dist/migrations/Migration20240624153824.d.ts.map +0 -1
- package/dist/migrations/Migration20240624153824.js +0 -15
@@ -1,19 +1,18 @@
|
|
1
1
|
import { DAL, PromotionTypeValues } from "@medusajs/types";
|
2
|
-
import { Collection, OptionalProps
|
2
|
+
import { Collection, OptionalProps } from "@mikro-orm/core";
|
3
3
|
import ApplicationMethod from "./application-method";
|
4
4
|
import Campaign from "./campaign";
|
5
5
|
import PromotionRule from "./promotion-rule";
|
6
|
-
type OptionalFields = "is_automatic" | DAL.
|
6
|
+
type OptionalFields = "is_automatic" | DAL.SoftDeletableEntityDateColumns;
|
7
7
|
type OptionalRelations = "application_method" | "campaign";
|
8
8
|
export default class Promotion {
|
9
9
|
[OptionalProps]?: OptionalFields | OptionalRelations;
|
10
10
|
id: string;
|
11
11
|
code: string;
|
12
|
-
|
13
|
-
campaign: Rel<Campaign> | null;
|
12
|
+
campaign: Campaign | null;
|
14
13
|
is_automatic: boolean;
|
15
14
|
type: PromotionTypeValues;
|
16
|
-
application_method:
|
15
|
+
application_method: ApplicationMethod;
|
17
16
|
rules: Collection<PromotionRule, object>;
|
18
17
|
created_at: Date;
|
19
18
|
updated_at: Date;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"promotion.d.ts","sourceRoot":"","sources":["../../src/models/promotion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAO1D,OAAO,EAEL,UAAU,EASV,aAAa,
|
1
|
+
{"version":3,"file":"promotion.d.ts","sourceRoot":"","sources":["../../src/models/promotion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAO1D,OAAO,EAEL,UAAU,EASV,aAAa,EAId,MAAM,iBAAiB,CAAA;AACxB,OAAO,iBAAiB,MAAM,sBAAsB,CAAA;AACpD,OAAO,QAAQ,MAAM,YAAY,CAAA;AACjC,OAAO,aAAa,MAAM,kBAAkB,CAAA;AAE5C,KAAK,cAAc,GAAG,cAAc,GAAG,GAAG,CAAC,8BAA8B,CAAA;AACzE,KAAK,iBAAiB,GAAG,oBAAoB,GAAG,UAAU,CAAA;AAI1D,MAAM,CAAC,OAAO,OAAO,SAAS;IAC5B,CAAC,aAAa,CAAC,CAAC,EAAE,cAAc,GAAG,iBAAiB,CAAA;IAGpD,EAAE,EAAG,MAAM,CAAA;IASX,IAAI,EAAE,MAAM,CAAA;IAQZ,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAO;IAGhC,YAAY,EAAE,OAAO,CAAQ;IAI7B,IAAI,EAAE,mBAAmB,CAAA;IAOzB,kBAAkB,EAAE,iBAAiB,CAAA;IAOrC,KAAK,oCAAsC;IAO3C,UAAU,EAAE,IAAI,CAAA;IAQhB,UAAU,EAAE,IAAI,CAAA;IAGhB,UAAU,EAAE,IAAI,GAAG,IAAI,CAAO;IAG9B,QAAQ;IAKR,MAAM;CAGP"}
|
package/dist/models/promotion.js
CHANGED
@@ -19,7 +19,7 @@ const campaign_1 = __importDefault(require("./campaign"));
|
|
19
19
|
const promotion_rule_1 = __importDefault(require("./promotion-rule"));
|
20
20
|
let Promotion = class Promotion {
|
21
21
|
constructor() {
|
22
|
-
this.
|
22
|
+
this.campaign = null;
|
23
23
|
this.is_automatic = false;
|
24
24
|
this.rules = new core_1.Collection(this);
|
25
25
|
this.deleted_at = null;
|
@@ -46,17 +46,13 @@ __decorate([
|
|
46
46
|
__metadata("design:type", String)
|
47
47
|
], Promotion.prototype, "code", void 0);
|
48
48
|
__decorate([
|
49
|
+
(0, utils_1.Searchable)(),
|
49
50
|
(0, core_1.ManyToOne)(() => campaign_1.default, {
|
50
|
-
columnType: "text",
|
51
51
|
fieldName: "campaign_id",
|
52
52
|
nullable: true,
|
53
|
-
|
53
|
+
cascade: ["soft-remove"],
|
54
54
|
}),
|
55
55
|
__metadata("design:type", Object)
|
56
|
-
], Promotion.prototype, "campaign_id", void 0);
|
57
|
-
__decorate([
|
58
|
-
(0, core_1.ManyToOne)(() => campaign_1.default, { persist: false }),
|
59
|
-
__metadata("design:type", Object)
|
60
56
|
], Promotion.prototype, "campaign", void 0);
|
61
57
|
__decorate([
|
62
58
|
(0, core_1.Property)({ columnType: "boolean", default: false }),
|
@@ -73,7 +69,7 @@ __decorate([
|
|
73
69
|
mappedBy: (am) => am.promotion,
|
74
70
|
cascade: ["soft-remove"],
|
75
71
|
}),
|
76
|
-
__metadata("design:type",
|
72
|
+
__metadata("design:type", application_method_1.default)
|
77
73
|
], Promotion.prototype, "application_method", void 0);
|
78
74
|
__decorate([
|
79
75
|
(0, core_1.ManyToMany)(() => promotion_rule_1.default, "promotions", {
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import { ModuleExports } from "@medusajs/types";
|
2
|
+
export declare const runMigrations: ({ options, logger, }?: Pick<import("@medusajs/modules-sdk").LoaderOptions<import("@medusajs/modules-sdk").ModuleServiceInitializeOptions>, "options" | "logger"> | undefined) => Promise<void>;
|
3
|
+
export declare const revertMigration: ({ options, logger, }?: Pick<import("@medusajs/modules-sdk").LoaderOptions<import("@medusajs/modules-sdk").ModuleServiceInitializeOptions>, "options" | "logger"> | undefined) => Promise<void>;
|
4
|
+
export declare const moduleDefinition: ModuleExports;
|
5
|
+
//# sourceMappingURL=module-definition.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"module-definition.d.ts","sourceRoot":"","sources":["../src/module-definition.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAa/C,eAAO,MAAM,aAAa,iMAEzB,CAAA;AACD,eAAO,MAAM,eAAe,iMAE3B,CAAA;AAKD,eAAO,MAAM,gBAAgB,EAAE,aAK9B,CAAA"}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
27
|
+
};
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
+
exports.moduleDefinition = exports.revertMigration = exports.runMigrations = void 0;
|
30
|
+
const modules_sdk_1 = require("@medusajs/modules-sdk");
|
31
|
+
const utils_1 = require("@medusajs/utils");
|
32
|
+
const Models = __importStar(require("./models"));
|
33
|
+
const _services_1 = require("./services");
|
34
|
+
const connection_1 = __importDefault(require("./loaders/connection"));
|
35
|
+
const container_1 = __importDefault(require("./loaders/container"));
|
36
|
+
const migrationScriptOptions = {
|
37
|
+
moduleName: modules_sdk_1.Modules.PROMOTION,
|
38
|
+
models: Models,
|
39
|
+
pathToMigrations: __dirname + "/migrations",
|
40
|
+
};
|
41
|
+
exports.runMigrations = utils_1.ModulesSdkUtils.buildMigrationScript(migrationScriptOptions);
|
42
|
+
exports.revertMigration = utils_1.ModulesSdkUtils.buildRevertMigrationScript(migrationScriptOptions);
|
43
|
+
const service = _services_1.PromotionModuleService;
|
44
|
+
const loaders = [container_1.default, connection_1.default];
|
45
|
+
exports.moduleDefinition = {
|
46
|
+
service,
|
47
|
+
loaders,
|
48
|
+
runMigrations: exports.runMigrations,
|
49
|
+
revertMigration: exports.revertMigration,
|
50
|
+
};
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { Context } from "@medusajs/types";
|
2
|
+
import { DALUtils } from "@medusajs/utils";
|
3
|
+
import { Campaign } from "../models";
|
4
|
+
import { CreateCampaignDTO, UpdateCampaignDTO } from "../types";
|
5
|
+
declare const CampaignRepository_base: new ({ manager }: {
|
6
|
+
manager: any;
|
7
|
+
}) => DALUtils.MikroOrmBaseRepository<Campaign>;
|
8
|
+
export declare class CampaignRepository extends CampaignRepository_base {
|
9
|
+
create(data: CreateCampaignDTO[], context?: Context): Promise<Campaign[]>;
|
10
|
+
update(data: {
|
11
|
+
entity: Campaign;
|
12
|
+
update: UpdateCampaignDTO;
|
13
|
+
}[], context?: Context): Promise<Campaign[]>;
|
14
|
+
}
|
15
|
+
export {};
|
16
|
+
//# sourceMappingURL=campaign.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"campaign.d.ts","sourceRoot":"","sources":["../../src/repositories/campaign.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAE1C,OAAO,EAAE,QAAQ,EAAa,MAAM,SAAS,CAAA;AAC7C,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAA;;;;AAE7D,qBAAa,kBAAmB,SAAQ,uBAEvC;IACO,MAAM,CACV,IAAI,EAAE,iBAAiB,EAAE,EACzB,OAAO,GAAE,OAAY,GACpB,OAAO,CAAC,QAAQ,EAAE,CAAC;IAiDhB,MAAM,CACV,IAAI,EAAE;QAAE,MAAM,EAAE,QAAQ,CAAC;QAAC,MAAM,EAAE,iBAAiB,CAAA;KAAE,EAAE,EACvD,OAAO,GAAE,OAAY,GACpB,OAAO,CAAC,QAAQ,EAAE,CAAC;CAoFvB"}
|
@@ -0,0 +1,90 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.CampaignRepository = void 0;
|
4
|
+
const utils_1 = require("@medusajs/utils");
|
5
|
+
const _models_1 = require("../models");
|
6
|
+
class CampaignRepository extends utils_1.DALUtils.mikroOrmBaseRepositoryFactory(_models_1.Campaign) {
|
7
|
+
async create(data, context = {}) {
|
8
|
+
const manager = this.getActiveManager(context);
|
9
|
+
const promotionIdsToUpsert = [];
|
10
|
+
const campaignIdentifierPromotionsMap = new Map();
|
11
|
+
data.forEach((campaignData) => {
|
12
|
+
const campaignPromotionIds = campaignData.promotions?.map((p) => p.id) || [];
|
13
|
+
promotionIdsToUpsert.push(...campaignPromotionIds);
|
14
|
+
campaignIdentifierPromotionsMap.set(campaignData.campaign_identifier, campaignPromotionIds);
|
15
|
+
delete campaignData.promotions;
|
16
|
+
});
|
17
|
+
const existingPromotions = await manager.find(_models_1.Promotion, {
|
18
|
+
id: promotionIdsToUpsert,
|
19
|
+
});
|
20
|
+
const existingPromotionsMap = new Map(existingPromotions.map((promotion) => [promotion.id, promotion]));
|
21
|
+
const createdCampaigns = await super.create(data, context);
|
22
|
+
for (const createdCampaign of createdCampaigns) {
|
23
|
+
const campaignPromotionIds = campaignIdentifierPromotionsMap.get(createdCampaign.campaign_identifier) || [];
|
24
|
+
for (const campaignPromotionId of campaignPromotionIds) {
|
25
|
+
const promotion = existingPromotionsMap.get(campaignPromotionId);
|
26
|
+
if (!promotion) {
|
27
|
+
continue;
|
28
|
+
}
|
29
|
+
createdCampaign.promotions.add(promotion);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
return createdCampaigns;
|
33
|
+
}
|
34
|
+
async update(data, context = {}) {
|
35
|
+
const manager = this.getActiveManager(context);
|
36
|
+
const promotionIdsToUpsert = [];
|
37
|
+
const campaignIds = [];
|
38
|
+
const campaignPromotionIdsMap = new Map();
|
39
|
+
data.forEach(({ update: campaignData }) => {
|
40
|
+
const campaignPromotionIds = campaignData.promotions?.map((p) => p.id);
|
41
|
+
campaignIds.push(campaignData.id);
|
42
|
+
if (campaignPromotionIds) {
|
43
|
+
promotionIdsToUpsert.push(...campaignPromotionIds);
|
44
|
+
campaignPromotionIdsMap.set(campaignData.id, campaignPromotionIds);
|
45
|
+
}
|
46
|
+
delete campaignData.promotions;
|
47
|
+
});
|
48
|
+
const existingCampaigns = await manager.find(_models_1.Campaign, { id: campaignIds }, { populate: ["promotions"] });
|
49
|
+
const promotionIds = existingCampaigns
|
50
|
+
.map((campaign) => campaign.promotions?.map((p) => p.id))
|
51
|
+
.flat(1)
|
52
|
+
.concat(promotionIdsToUpsert);
|
53
|
+
const existingPromotions = await manager.find(_models_1.Promotion, {
|
54
|
+
id: promotionIds,
|
55
|
+
});
|
56
|
+
const existingCampaignsMap = new Map(existingCampaigns.map((campaign) => [campaign.id, campaign]));
|
57
|
+
const existingPromotionsMap = new Map(existingPromotions.map((promotion) => [promotion.id, promotion]));
|
58
|
+
const updatedCampaigns = await super.update(data, context);
|
59
|
+
for (const updatedCampaign of updatedCampaigns) {
|
60
|
+
const upsertPromotionIds = campaignPromotionIdsMap.get(updatedCampaign.id);
|
61
|
+
if (!upsertPromotionIds) {
|
62
|
+
continue;
|
63
|
+
}
|
64
|
+
const existingPromotionIds = (existingCampaignsMap.get(updatedCampaign.id)?.promotions || []).map((p) => p.id);
|
65
|
+
for (const existingPromotionId of existingPromotionIds) {
|
66
|
+
const promotion = existingPromotionsMap.get(existingPromotionId);
|
67
|
+
if (!promotion) {
|
68
|
+
continue;
|
69
|
+
}
|
70
|
+
if (!upsertPromotionIds.includes(existingPromotionId)) {
|
71
|
+
updatedCampaign.promotions.remove(promotion);
|
72
|
+
}
|
73
|
+
}
|
74
|
+
for (const promotionIdToAdd of upsertPromotionIds) {
|
75
|
+
const promotion = existingPromotionsMap.get(promotionIdToAdd);
|
76
|
+
if (!promotion) {
|
77
|
+
continue;
|
78
|
+
}
|
79
|
+
if (existingPromotionIds.includes(promotionIdToAdd)) {
|
80
|
+
continue;
|
81
|
+
}
|
82
|
+
else {
|
83
|
+
updatedCampaign.promotions.add(promotion);
|
84
|
+
}
|
85
|
+
}
|
86
|
+
}
|
87
|
+
return updatedCampaigns;
|
88
|
+
}
|
89
|
+
}
|
90
|
+
exports.CampaignRepository = CampaignRepository;
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/repositories/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,IAAI,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA"}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.CampaignRepository = exports.BaseRepository = void 0;
|
4
|
+
var utils_1 = require("@medusajs/utils");
|
5
|
+
Object.defineProperty(exports, "BaseRepository", { enumerable: true, get: function () { return utils_1.MikroOrmBaseRepository; } });
|
6
|
+
var campaign_1 = require("./campaign");
|
7
|
+
Object.defineProperty(exports, "CampaignRepository", { enumerable: true, get: function () { return campaign_1.CampaignRepository; } });
|
@@ -1,19 +1,17 @@
|
|
1
|
-
import {
|
1
|
+
import { Context, DAL, InternalModuleDeclaration, ModuleJoinerConfig, ModulesSdkTypes, PromotionTypes } from "@medusajs/types";
|
2
|
+
import { ModulesSdkUtils } from "@medusajs/utils";
|
2
3
|
import { ApplicationMethod, Campaign, CampaignBudget, Promotion, PromotionRule, PromotionRuleValue } from "../models";
|
3
4
|
import { ApplicationMethodRuleTypes } from "../types";
|
4
5
|
type InjectedDependencies = {
|
5
6
|
baseRepository: DAL.RepositoryService;
|
6
|
-
promotionService: ModulesSdkTypes.
|
7
|
-
applicationMethodService: ModulesSdkTypes.
|
8
|
-
promotionRuleService: ModulesSdkTypes.
|
9
|
-
promotionRuleValueService: ModulesSdkTypes.
|
10
|
-
campaignService: ModulesSdkTypes.
|
11
|
-
campaignBudgetService: ModulesSdkTypes.
|
7
|
+
promotionService: ModulesSdkTypes.InternalModuleService<any>;
|
8
|
+
applicationMethodService: ModulesSdkTypes.InternalModuleService<any>;
|
9
|
+
promotionRuleService: ModulesSdkTypes.InternalModuleService<any>;
|
10
|
+
promotionRuleValueService: ModulesSdkTypes.InternalModuleService<any>;
|
11
|
+
campaignService: ModulesSdkTypes.InternalModuleService<any>;
|
12
|
+
campaignBudgetService: ModulesSdkTypes.InternalModuleService<any>;
|
12
13
|
};
|
13
|
-
declare const PromotionModuleService_base:
|
14
|
-
Promotion: {
|
15
|
-
dto: PromotionTypes.PromotionDTO;
|
16
|
-
};
|
14
|
+
declare const PromotionModuleService_base: new (container: InjectedDependencies) => ModulesSdkUtils.AbstractModuleService<InjectedDependencies, PromotionTypes.PromotionDTO, {
|
17
15
|
ApplicationMethod: {
|
18
16
|
dto: PromotionTypes.ApplicationMethodDTO;
|
19
17
|
};
|
@@ -30,31 +28,31 @@ declare const PromotionModuleService_base: import("@medusajs/utils/dist/modules-
|
|
30
28
|
dto: PromotionTypes.PromotionRuleValueDTO;
|
31
29
|
};
|
32
30
|
}>;
|
33
|
-
export default class PromotionModuleService extends PromotionModuleService_base implements PromotionTypes.IPromotionModuleService {
|
31
|
+
export default class PromotionModuleService<TApplicationMethod extends ApplicationMethod = ApplicationMethod, TPromotion extends Promotion = Promotion, TPromotionRule extends PromotionRule = PromotionRule, TPromotionRuleValue extends PromotionRuleValue = PromotionRuleValue, TCampaign extends Campaign = Campaign, TCampaignBudget extends CampaignBudget = CampaignBudget> extends PromotionModuleService_base implements PromotionTypes.IPromotionModuleService {
|
34
32
|
protected readonly moduleDeclaration: InternalModuleDeclaration;
|
35
33
|
protected baseRepository_: DAL.RepositoryService;
|
36
|
-
protected promotionService_: ModulesSdkTypes.
|
37
|
-
protected applicationMethodService_: ModulesSdkTypes.
|
38
|
-
protected promotionRuleService_: ModulesSdkTypes.
|
39
|
-
protected promotionRuleValueService_: ModulesSdkTypes.
|
40
|
-
protected campaignService_: ModulesSdkTypes.
|
41
|
-
protected campaignBudgetService_: ModulesSdkTypes.
|
34
|
+
protected promotionService_: ModulesSdkTypes.InternalModuleService<TPromotion>;
|
35
|
+
protected applicationMethodService_: ModulesSdkTypes.InternalModuleService<TApplicationMethod>;
|
36
|
+
protected promotionRuleService_: ModulesSdkTypes.InternalModuleService<TPromotionRule>;
|
37
|
+
protected promotionRuleValueService_: ModulesSdkTypes.InternalModuleService<TPromotionRuleValue>;
|
38
|
+
protected campaignService_: ModulesSdkTypes.InternalModuleService<TCampaign>;
|
39
|
+
protected campaignBudgetService_: ModulesSdkTypes.InternalModuleService<TCampaignBudget>;
|
42
40
|
constructor({ baseRepository, promotionService, applicationMethodService, promotionRuleService, promotionRuleValueService, campaignService, campaignBudgetService, }: InjectedDependencies, moduleDeclaration: InternalModuleDeclaration);
|
43
41
|
__joinerConfig(): ModuleJoinerConfig;
|
44
42
|
registerUsage(computedActions: PromotionTypes.UsageComputedActions[], sharedContext?: Context): Promise<void>;
|
45
43
|
computeActions(promotionCodes: string[], applicationContext: PromotionTypes.ComputeActionContext, options?: PromotionTypes.ComputeActionOptions, sharedContext?: Context): Promise<PromotionTypes.ComputeActions[]>;
|
46
|
-
|
47
|
-
|
48
|
-
protected
|
49
|
-
|
50
|
-
|
51
|
-
protected
|
44
|
+
create(data: PromotionTypes.CreatePromotionDTO, sharedContext?: Context): Promise<PromotionTypes.PromotionDTO>;
|
45
|
+
create(data: PromotionTypes.CreatePromotionDTO[], sharedContext?: Context): Promise<PromotionTypes.PromotionDTO[]>;
|
46
|
+
protected create_(data: PromotionTypes.CreatePromotionDTO[], sharedContext?: Context): Promise<TPromotion[]>;
|
47
|
+
update(data: PromotionTypes.UpdatePromotionDTO, sharedContext?: Context): Promise<PromotionTypes.PromotionDTO>;
|
48
|
+
update(data: PromotionTypes.UpdatePromotionDTO[], sharedContext?: Context): Promise<PromotionTypes.PromotionDTO[]>;
|
49
|
+
protected update_(data: PromotionTypes.UpdatePromotionDTO[], sharedContext?: Context): Promise<TPromotion[]>;
|
52
50
|
updatePromotionRules(data: PromotionTypes.UpdatePromotionRuleDTO[], sharedContext?: Context): Promise<PromotionTypes.PromotionRuleDTO[]>;
|
53
|
-
protected updatePromotionRules_(data: PromotionTypes.UpdatePromotionRuleDTO[], sharedContext?: Context): Promise<
|
51
|
+
protected updatePromotionRules_(data: PromotionTypes.UpdatePromotionRuleDTO[], sharedContext?: Context): Promise<TPromotionRule[]>;
|
54
52
|
addPromotionRules(promotionId: string, rulesData: PromotionTypes.CreatePromotionRuleDTO[], sharedContext?: Context): Promise<PromotionTypes.PromotionRuleDTO[]>;
|
55
53
|
addPromotionTargetRules(promotionId: string, rulesData: PromotionTypes.CreatePromotionRuleDTO[], sharedContext?: Context): Promise<PromotionTypes.PromotionRuleDTO[]>;
|
56
54
|
addPromotionBuyRules(promotionId: string, rulesData: PromotionTypes.CreatePromotionRuleDTO[], sharedContext?: Context): Promise<PromotionTypes.PromotionRuleDTO[]>;
|
57
|
-
protected createPromotionRulesAndValues_(rulesData: PromotionTypes.CreatePromotionRuleDTO[], relationName: "promotions" | "method_target_rules" | "method_buy_rules", relation: Promotion | ApplicationMethod, sharedContext?: Context): Promise<
|
55
|
+
protected createPromotionRulesAndValues_(rulesData: PromotionTypes.CreatePromotionRuleDTO[], relationName: "promotions" | "method_target_rules" | "method_buy_rules", relation: Promotion | ApplicationMethod, sharedContext?: Context): Promise<TPromotionRule[]>;
|
58
56
|
removePromotionRules(promotionId: string, ruleIds: string[], sharedContext?: Context): Promise<void>;
|
59
57
|
protected removePromotionRules_(promotionId: string, ruleIds: string[], sharedContext?: Context): Promise<void>;
|
60
58
|
removePromotionTargetRules(promotionId: string, ruleIds: string[], sharedContext?: Context): Promise<void>;
|
@@ -62,22 +60,10 @@ export default class PromotionModuleService extends PromotionModuleService_base
|
|
62
60
|
protected removeApplicationMethodRules_(promotionId: string, ruleIds: string[], relation: ApplicationMethodRuleTypes.TARGET_RULES | ApplicationMethodRuleTypes.BUY_RULES, sharedContext?: Context): Promise<void>;
|
63
61
|
createCampaigns(data: PromotionTypes.CreateCampaignDTO, sharedContext?: Context): Promise<PromotionTypes.CampaignDTO>;
|
64
62
|
createCampaigns(data: PromotionTypes.CreateCampaignDTO[], sharedContext?: Context): Promise<PromotionTypes.CampaignDTO[]>;
|
65
|
-
protected createCampaigns_(data: PromotionTypes.CreateCampaignDTO[], sharedContext?: Context): Promise<
|
66
|
-
protected validateCampaignBudgetData(data: {
|
67
|
-
type?: CampaignBudgetTypeValues;
|
68
|
-
currency_code?: string | null;
|
69
|
-
}): void;
|
63
|
+
protected createCampaigns_(data: PromotionTypes.CreateCampaignDTO[], sharedContext?: Context): Promise<TCampaign[]>;
|
70
64
|
updateCampaigns(data: PromotionTypes.UpdateCampaignDTO, sharedContext?: Context): Promise<PromotionTypes.CampaignDTO>;
|
71
65
|
updateCampaigns(data: PromotionTypes.UpdateCampaignDTO[], sharedContext?: Context): Promise<PromotionTypes.CampaignDTO[]>;
|
72
|
-
protected updateCampaigns_(data: PromotionTypes.UpdateCampaignDTO[], sharedContext?: Context): Promise<
|
73
|
-
addPromotionsToCampaign(data: PromotionTypes.AddPromotionsToCampaignDTO, sharedContext?: Context): Promise<{
|
74
|
-
ids: string[];
|
75
|
-
}>;
|
76
|
-
protected addPromotionsToCampaign_(data: PromotionTypes.AddPromotionsToCampaignDTO, sharedContext?: Context): Promise<string[]>;
|
77
|
-
removePromotionsFromCampaign(data: PromotionTypes.AddPromotionsToCampaignDTO, sharedContext?: Context): Promise<{
|
78
|
-
ids: string[];
|
79
|
-
}>;
|
80
|
-
protected removePromotionsFromCampaign_(data: PromotionTypes.AddPromotionsToCampaignDTO, sharedContext?: Context): Promise<string[]>;
|
66
|
+
protected updateCampaigns_(data: PromotionTypes.UpdateCampaignDTO[], sharedContext?: Context): Promise<TCampaign[]>;
|
81
67
|
}
|
82
68
|
export {};
|
83
69
|
//# sourceMappingURL=promotion-module.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"promotion-module.d.ts","sourceRoot":"","sources":["../../src/services/promotion-module.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
1
|
+
{"version":3,"file":"promotion-module.d.ts","sourceRoot":"","sources":["../../src/services/promotion-module.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,GAAG,EACH,yBAAyB,EACzB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACf,MAAM,iBAAiB,CAAA;AACxB,OAAO,EASL,eAAe,EAMhB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,iBAAiB,EACjB,QAAQ,EACR,cAAc,EACd,SAAS,EACT,aAAa,EACb,kBAAkB,EACnB,MAAM,SAAS,CAAA;AAChB,OAAO,EACL,0BAA0B,EAU3B,MAAM,QAAQ,CAAA;AAWf,KAAK,oBAAoB,GAAG;IAC1B,cAAc,EAAE,GAAG,CAAC,iBAAiB,CAAA;IACrC,gBAAgB,EAAE,eAAe,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAA;IAC5D,wBAAwB,EAAE,eAAe,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAA;IACpE,oBAAoB,EAAE,eAAe,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAA;IAChE,yBAAyB,EAAE,eAAe,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAA;IACrE,eAAe,EAAE,eAAe,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAA;IAC3D,qBAAqB,EAAE,eAAe,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAA;CAClE,CAAA;;uBAsBwB;QAAE,GAAG,EAAE,eAAe,oBAAoB,CAAA;KAAE;cACrD;QAAE,GAAG,EAAE,eAAe,WAAW,CAAA;KAAE;oBAC7B;QAAE,GAAG,EAAE,eAAe,iBAAiB,CAAA;KAAE;mBAC1C;QAAE,GAAG,EAAE,eAAe,gBAAgB,CAAA;KAAE;wBACnC;QAAE,GAAG,EAAE,eAAe,qBAAqB,CAA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