@studyportals/campaign-management-api-interface 16.4.3-5 → 17.0.2-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +3 -5
- package/index.js +3 -6
- package/index.js.map +1 -1
- package/package.json +4 -7
- package/src/auditor-campaign-management-api.client.d.ts +0 -5
- package/src/auditor-campaign-management-api.client.js +8 -28
- package/src/auditor-campaign-management-api.client.js.map +1 -1
- package/src/campaign-management-api.client.d.ts +12 -25
- package/src/campaign-management-api.client.js +65 -220
- package/src/campaign-management-api.client.js.map +1 -1
- package/src/domain/campaign/index.d.ts +1 -3
- package/src/domain/campaign/index.js +1 -3
- package/src/domain/campaign/index.js.map +1 -1
- package/src/errors/http-error.d.ts +12 -0
- package/src/errors/http-error.js +12 -0
- package/src/errors/http-error.js.map +1 -0
- package/src/links-campaign-management-api.client.js +2 -5
- package/src/links-campaign-management-api.client.js.map +1 -1
- package/src/organisations-campaign-management-api.client.d.ts +1 -0
- package/src/organisations-campaign-management-api.client.js +8 -17
- package/src/organisations-campaign-management-api.client.js.map +1 -1
- package/src/private-campaign-management-api.client.d.ts +1 -43
- package/src/private-campaign-management-api.client.js +23 -97
- package/src/private-campaign-management-api.client.js.map +1 -1
- package/src/products-campaign-management-api.client.js +2 -5
- package/src/products-campaign-management-api.client.js.map +1 -1
- package/src/study-campaign-management-api.client.js +2 -5
- package/src/study-campaign-management-api.client.js.map +1 -1
- package/src/user-campaign-management-api.client.d.ts +1 -0
- package/src/user-campaign-management-api.client.js +8 -16
- package/src/user-campaign-management-api.client.js.map +1 -1
- package/src/utils/http-request.d.ts +33 -0
- package/src/utils/http-request.js +57 -0
- package/src/utils/http-request.js.map +1 -0
- package/src/campaign-saving/index.d.ts +0 -3
- package/src/campaign-saving/index.js +0 -6
- package/src/campaign-saving/index.js.map +0 -1
- package/src/campaign-saving/websocket-data-type.d.ts +0 -19
- package/src/campaign-saving/websocket-data-type.js +0 -3
- package/src/campaign-saving/websocket-data-type.js.map +0 -1
- package/src/campaign-saving/websocket-lambda-topics.enum.d.ts +0 -3
- package/src/campaign-saving/websocket-lambda-topics.enum.js +0 -8
- package/src/campaign-saving/websocket-lambda-topics.enum.js.map +0 -1
- package/src/domain/campaign/entity-geotargeting.dto.d.ts +0 -5
- package/src/domain/campaign/entity-geotargeting.dto.js +0 -3
- package/src/domain/campaign/entity-geotargeting.dto.js.map +0 -1
- package/src/domain/campaign/targeted-countries.dto.d.ts +0 -8
- package/src/domain/campaign/targeted-countries.dto.js +0 -10
- package/src/domain/campaign/targeted-countries.dto.js.map +0 -1
package/index.d.ts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { AuditorCampaignManagementAPIClient } from "./src/auditor-campaign-management-api.client";
|
|
2
|
+
import { HttpError } from "./src/errors/http-error";
|
|
2
3
|
import { OrganisationsCampaignManagementAPIClient } from "./src/organisations-campaign-management-api.client";
|
|
3
|
-
import { CampaignManagementAPIClient } from "./src/campaign-management-api.client";
|
|
4
|
+
import { CampaignManagementAPIClient, CampaignManagementAPIClientConfig } from "./src/campaign-management-api.client";
|
|
4
5
|
import { AuditorEntityType } from "./src/domain/auditor/enums/auditor-entity-type.enum";
|
|
5
6
|
import { AuditorOperation } from "./src/domain/auditor/enums/auditor-operation.enum";
|
|
6
7
|
import { GetAuditorDto } from "./src/domain/auditor/get-auditor.dto";
|
|
7
|
-
import { CampaignsEntitiesConfigDto } from "./src/domain/campaign/campaign-entities-config.dto";
|
|
8
8
|
import { NumberMap, Pricing, ICampaignAuditorData } from "./src/domain/auditor/campaigns/geotargeting.entities";
|
|
9
9
|
import { PrivateCampaignManagementAPIClient } from "./src/private-campaign-management-api.client";
|
|
10
10
|
import { UserCampaignManagementAPIClient } from "./src/user-campaign-management-api.client";
|
|
11
11
|
import { StudyCampaignManagementAPIClient } from "./src/study-campaign-management-api.client";
|
|
12
12
|
import { MinimalOrganisationDto } from "./src/domain/organisations/minimal-organisations.dto";
|
|
13
13
|
import { LinkType } from "./src/domain/studies/enums/link-type.enum";
|
|
14
|
-
import { PersistGoogleLinkerResultDto } from "./src/domain/campaign/persist-google-linker-result.dto";
|
|
15
14
|
import { LinkEntityType } from "./src/domain/links/link-entity-type.enum";
|
|
16
15
|
import { LinksCampaignManagementAPIClient } from './src/links-campaign-management-api.client';
|
|
17
16
|
import { SwappingEnabledLinkTypes } from "./src/domain/links/swapping-enabled-link-types.enum";
|
|
@@ -34,5 +33,4 @@ export * from "./src/validation";
|
|
|
34
33
|
export * from "./src/domain/organisations";
|
|
35
34
|
export * from "./src/domain/products";
|
|
36
35
|
export * from "./src/domain/degrees";
|
|
37
|
-
export
|
|
38
|
-
export { AuditorCampaignManagementAPIClient, OrganisationsCampaignManagementAPIClient, CampaignManagementAPIClient, PrivateCampaignManagementAPIClient, PrivateUserCampaignManagementAPIClient, UserCampaignManagementAPIClient, StudyCampaignManagementAPIClient, LinksCampaignManagementAPIClient, ProductsCampaignManagementAPIClient, PublicStatusClient, GeotarginatorFrontCMAClient, UniversitySchedulerCMAClient, AuditorEntityType, AuditorOperation, LinkType, LinkEntityType, SwappingEnabledLinkTypes, GetAuditorDto, PersistGoogleLinkerResultDto, IdDto, CampaignsEntitiesConfigDto, CreateLinkDto, UpdateLinkDto, MinimalOrganisationDto, CampaignEditorFrontendStatusDto, StatusHealthy, StatusBlocked, SaveCampaignGeotargetingRequest, GeotargetingEntity, TargetedCountries, EntityConfigsGroup, FlatEntityConfig, groupEntityConfigs, flattenEntityConfigs, CampaignStartPayload, SchedulerGeoEntity, SchedulerPricingEntity, NumberMap, Pricing, ICampaignAuditorData, SuperAgentResponseCover };
|
|
36
|
+
export { AuditorCampaignManagementAPIClient, OrganisationsCampaignManagementAPIClient, CampaignManagementAPIClient, CampaignManagementAPIClientConfig, PrivateCampaignManagementAPIClient, PrivateUserCampaignManagementAPIClient, UserCampaignManagementAPIClient, StudyCampaignManagementAPIClient, LinksCampaignManagementAPIClient, ProductsCampaignManagementAPIClient, PublicStatusClient, GeotarginatorFrontCMAClient, UniversitySchedulerCMAClient, AuditorEntityType, AuditorOperation, LinkType, LinkEntityType, SwappingEnabledLinkTypes, GetAuditorDto, IdDto, CreateLinkDto, UpdateLinkDto, MinimalOrganisationDto, CampaignEditorFrontendStatusDto, StatusHealthy, StatusBlocked, SaveCampaignGeotargetingRequest, GeotargetingEntity, TargetedCountries, EntityConfigsGroup, FlatEntityConfig, groupEntityConfigs, flattenEntityConfigs, CampaignStartPayload, SchedulerGeoEntity, SchedulerPricingEntity, NumberMap, Pricing, ICampaignAuditorData, SuperAgentResponseCover, HttpError };
|
package/index.js
CHANGED
|
@@ -14,9 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
17
|
+
exports.HttpError = exports.Pricing = exports.flattenEntityConfigs = exports.groupEntityConfigs = exports.MinimalOrganisationDto = exports.IdDto = exports.GetAuditorDto = exports.SwappingEnabledLinkTypes = exports.LinkEntityType = exports.LinkType = exports.AuditorOperation = exports.AuditorEntityType = exports.UniversitySchedulerCMAClient = exports.GeotarginatorFrontCMAClient = exports.PublicStatusClient = exports.ProductsCampaignManagementAPIClient = exports.LinksCampaignManagementAPIClient = exports.StudyCampaignManagementAPIClient = exports.UserCampaignManagementAPIClient = exports.PrivateUserCampaignManagementAPIClient = exports.PrivateCampaignManagementAPIClient = exports.CampaignManagementAPIClient = exports.OrganisationsCampaignManagementAPIClient = exports.AuditorCampaignManagementAPIClient = void 0;
|
|
18
18
|
const auditor_campaign_management_api_client_1 = require("./src/auditor-campaign-management-api.client");
|
|
19
19
|
Object.defineProperty(exports, "AuditorCampaignManagementAPIClient", { enumerable: true, get: function () { return auditor_campaign_management_api_client_1.AuditorCampaignManagementAPIClient; } });
|
|
20
|
+
const http_error_1 = require("./src/errors/http-error");
|
|
21
|
+
Object.defineProperty(exports, "HttpError", { enumerable: true, get: function () { return http_error_1.HttpError; } });
|
|
20
22
|
const organisations_campaign_management_api_client_1 = require("./src/organisations-campaign-management-api.client");
|
|
21
23
|
Object.defineProperty(exports, "OrganisationsCampaignManagementAPIClient", { enumerable: true, get: function () { return organisations_campaign_management_api_client_1.OrganisationsCampaignManagementAPIClient; } });
|
|
22
24
|
const campaign_management_api_client_1 = require("./src/campaign-management-api.client");
|
|
@@ -27,8 +29,6 @@ const auditor_operation_enum_1 = require("./src/domain/auditor/enums/auditor-ope
|
|
|
27
29
|
Object.defineProperty(exports, "AuditorOperation", { enumerable: true, get: function () { return auditor_operation_enum_1.AuditorOperation; } });
|
|
28
30
|
const get_auditor_dto_1 = require("./src/domain/auditor/get-auditor.dto");
|
|
29
31
|
Object.defineProperty(exports, "GetAuditorDto", { enumerable: true, get: function () { return get_auditor_dto_1.GetAuditorDto; } });
|
|
30
|
-
const campaign_entities_config_dto_1 = require("./src/domain/campaign/campaign-entities-config.dto");
|
|
31
|
-
Object.defineProperty(exports, "CampaignsEntitiesConfigDto", { enumerable: true, get: function () { return campaign_entities_config_dto_1.CampaignsEntitiesConfigDto; } });
|
|
32
32
|
const geotargeting_entities_1 = require("./src/domain/auditor/campaigns/geotargeting.entities");
|
|
33
33
|
Object.defineProperty(exports, "Pricing", { enumerable: true, get: function () { return geotargeting_entities_1.Pricing; } });
|
|
34
34
|
const private_campaign_management_api_client_1 = require("./src/private-campaign-management-api.client");
|
|
@@ -41,8 +41,6 @@ const minimal_organisations_dto_1 = require("./src/domain/organisations/minimal-
|
|
|
41
41
|
Object.defineProperty(exports, "MinimalOrganisationDto", { enumerable: true, get: function () { return minimal_organisations_dto_1.MinimalOrganisationDto; } });
|
|
42
42
|
const link_type_enum_1 = require("./src/domain/studies/enums/link-type.enum");
|
|
43
43
|
Object.defineProperty(exports, "LinkType", { enumerable: true, get: function () { return link_type_enum_1.LinkType; } });
|
|
44
|
-
const persist_google_linker_result_dto_1 = require("./src/domain/campaign/persist-google-linker-result.dto");
|
|
45
|
-
Object.defineProperty(exports, "PersistGoogleLinkerResultDto", { enumerable: true, get: function () { return persist_google_linker_result_dto_1.PersistGoogleLinkerResultDto; } });
|
|
46
44
|
const link_entity_type_enum_1 = require("./src/domain/links/link-entity-type.enum");
|
|
47
45
|
Object.defineProperty(exports, "LinkEntityType", { enumerable: true, get: function () { return link_entity_type_enum_1.LinkEntityType; } });
|
|
48
46
|
const links_campaign_management_api_client_1 = require("./src/links-campaign-management-api.client");
|
|
@@ -70,5 +68,4 @@ __exportStar(require("./src/validation"), exports);
|
|
|
70
68
|
__exportStar(require("./src/domain/organisations"), exports);
|
|
71
69
|
__exportStar(require("./src/domain/products"), exports);
|
|
72
70
|
__exportStar(require("./src/domain/degrees"), exports);
|
|
73
|
-
__exportStar(require("./src/campaign-saving"), exports);
|
|
74
71
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,yGAAkG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,yGAAkG;AAiDjG,mHAjDQ,2EAAkC,OAiDR;AAhDnC,wDAAoD;AAyGnD,0FAzGQ,sBAAS,OAyGR;AAxGV,qHAA8G;AAgD7G,yHAhDQ,uFAAwC,OAgDR;AA/CzC,yFAAsH;AAgDrH,4GAhDQ,4DAA2B,OAgDR;AA/C5B,kGAAwF;AA4DvF,kGA5DQ,4CAAiB,OA4DR;AA3DlB,8FAAqF;AA4DpF,iGA5DQ,yCAAgB,OA4DR;AA3DjB,0EAAqE;AAiEpE,8FAjEQ,+BAAa,OAiER;AAhEd,gGAAgH;AAgG/G,wFAhGmB,+BAAO,OAgGnB;AA/FR,yGAAkG;AA6CjG,mHA7CQ,2EAAkC,OA6CR;AA5CnC,mGAA4F;AA8C3F,gHA9CQ,qEAA+B,OA8CR;AA7ChC,qGAA8F;AA8C7F,iHA9CQ,uEAAgC,OA8CR;AA7CjC,oGAA8F;AAoE7F,uGApEQ,kDAAsB,OAoER;AAnEvB,8EAAqE;AAsDpE,yFAtDQ,yBAAQ,OAsDR;AArDT,oFAA0E;AAsDzE,+FAtDQ,sCAAc,OAsDR;AArDf,qGAA8F;AA2C7F,iHA3CQ,uEAAgC,OA2CR;AA1CjC,0GAA+F;AAqD9F,yGArDQ,2DAAwB,OAqDR;AAjDzB,2GAAoG;AAuCnG,oHAvCQ,6EAAmC,OAuCR;AAtCpC,qEAAgE;AAuC/D,mGAvCQ,yCAAkB,OAuCR;AArCnB,mHAA2G;AAgC1G,uHAhCQ,oFAAsC,OAgCR;AA/BvC,gDAA4C;AAiD3C,sFAjDQ,cAAK,OAiDR;AAhDN,yFAAmF;AAoClF,4GApCQ,4DAA2B,OAoCR;AAnC5B,2FAAqF;AAoCpF,6GApCQ,8DAA4B,OAoCR;AAnC7B,+DAAsF;AAoErF,mGApEQ,mCAAkB,OAoER;AAClB,qGArE4B,qCAAoB,OAqE5B;AAvDrB,wDAAsC;AACtC,qDAAmC;AACnC,mDAAiC;AACjC,6DAA2C;AAC3C,wDAAsC;AACtC,uDAAqC"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@studyportals/campaign-management-api-interface",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "17.0.2-2",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"compile": "rm -fR bin && npx tsc",
|
|
6
6
|
"test-u": "jest -c jest.config.unit.json --maxWorkers=1",
|
|
7
7
|
"test-i": "nyc mocha src tests-i",
|
|
8
8
|
"prepare-deployment": "npm run test-u && npm run compile && cp package.json bin/package.json && rm -fR bin/tests-u",
|
|
9
9
|
"predeploy": "npm run prepare-deployment",
|
|
10
|
-
"deploy": "npm publish ./bin --access=public",
|
|
10
|
+
"deploy": "npm publish ./bin --access=public --otp=123",
|
|
11
11
|
"deploy-patch": "npm version patch && npm run deploy",
|
|
12
12
|
"deploy-minor": "npm version minor && npm run deploy",
|
|
13
13
|
"deploy-major": "npm version major && npm run deploy",
|
|
@@ -22,12 +22,10 @@
|
|
|
22
22
|
"@types/chai": "^4.3.20",
|
|
23
23
|
"@types/jest": "^29.5.14",
|
|
24
24
|
"@types/node": "^22.19.7",
|
|
25
|
-
"@types/superagent": "^8.1.9",
|
|
26
25
|
"chai": "^4.5.0",
|
|
27
26
|
"eslint": "^8.57.1",
|
|
28
27
|
"jest": "^29.7.0",
|
|
29
28
|
"jest-mock-extended": "^3.0.7",
|
|
30
|
-
"superagent-mocker": "^0.5.2",
|
|
31
29
|
"ts-jest": "^29.4.6",
|
|
32
30
|
"ts-node": "^10.9.2",
|
|
33
31
|
"typescript": "^5.9.3"
|
|
@@ -37,13 +35,12 @@
|
|
|
37
35
|
"@aws-sdk/credential-provider-node": "^3.972.2",
|
|
38
36
|
"@smithy/signature-v4": "^5.3.8",
|
|
39
37
|
"@studyportals/mb-platform-date-time": "^1.3.1",
|
|
40
|
-
"@studyportals/mb-platform-http-requests": "^2.8.0",
|
|
41
38
|
"@studyportals/university-scheduler-interface": "^0.7.0",
|
|
39
|
+
"@studyportals/ws-client": "^0.3.1",
|
|
42
40
|
"class-transformer": "^0.5.1",
|
|
43
41
|
"class-validator": "^0.14.3",
|
|
44
42
|
"inversify": "^6.2.2",
|
|
45
|
-
"reflect-metadata": "^0.2.2"
|
|
46
|
-
"superagent": "^8.1.2"
|
|
43
|
+
"reflect-metadata": "^0.2.2"
|
|
47
44
|
},
|
|
48
45
|
"engines": {
|
|
49
46
|
"node": ">=18.x <=22.x",
|
|
@@ -6,11 +6,6 @@ export declare class AuditorCampaignManagementAPIClient {
|
|
|
6
6
|
constructor(baseUrl: string);
|
|
7
7
|
getCampaignAuditorData(campaignID: number, jwt?: string): Promise<GetAuditorDto[]>;
|
|
8
8
|
getStudyAuditorData(studyID: number, jwt?: string): Promise<GetAuditorDto[]>;
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated Auditing is now handled internally by CMA as part of write operations.
|
|
11
|
-
* Use GeotarginatorFrontCMAClient.saveCampaignGeotargeting() instead—auditing is automatic.
|
|
12
|
-
*/
|
|
13
|
-
storeCampaignAuditorData(operation: AuditorOperation, campaignID: number, username: string, isUserAction: boolean, data: any, jwt?: string): Promise<GetAuditorDto>;
|
|
14
9
|
storeStudyAuditorData(operation: AuditorOperation, studyID: number, username: string, isUserAction: boolean, messageType: string, message: any, jwt?: string): Promise<GetAuditorDto>;
|
|
15
10
|
storeStudiesAuditorData(operation: AuditorOperation, studyIDs: number[], username: string, isUserAction: boolean, messageType: string, message: any, jwt?: string): Promise<GetAuditorDto[]>;
|
|
16
11
|
private getRequest;
|
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.AuditorCampaignManagementAPIClient = void 0;
|
|
13
13
|
require("reflect-metadata");
|
|
14
14
|
const inversify_1 = require("inversify");
|
|
15
|
-
const
|
|
15
|
+
const http_request_1 = require("./utils/http-request");
|
|
16
16
|
let AuditorCampaignManagementAPIClient = class AuditorCampaignManagementAPIClient {
|
|
17
17
|
constructor(baseUrl) {
|
|
18
18
|
this.baseUrl = baseUrl;
|
|
@@ -27,47 +27,27 @@ let AuditorCampaignManagementAPIClient = class AuditorCampaignManagementAPIClien
|
|
|
27
27
|
const getAuditorDtos = result.body;
|
|
28
28
|
return getAuditorDtos;
|
|
29
29
|
}
|
|
30
|
-
/**
|
|
31
|
-
* @deprecated Auditing is now handled internally by CMA as part of write operations.
|
|
32
|
-
* Use GeotarginatorFrontCMAClient.saveCampaignGeotargeting() instead—auditing is automatic.
|
|
33
|
-
*/
|
|
34
|
-
async storeCampaignAuditorData(operation, campaignID, username, isUserAction, data, jwt = "") {
|
|
35
|
-
const sendData = {
|
|
36
|
-
"operation": operation,
|
|
37
|
-
"entityID": campaignID,
|
|
38
|
-
"username": username,
|
|
39
|
-
"isUserAction": isUserAction,
|
|
40
|
-
"data": data
|
|
41
|
-
};
|
|
42
|
-
const result = await this.postRequest(`auditor/campaigns`, sendData, jwt);
|
|
43
|
-
return result.body;
|
|
44
|
-
}
|
|
45
30
|
async storeStudyAuditorData(operation, studyID, username, isUserAction, messageType, message, jwt = "") {
|
|
46
31
|
const body = await this.storeStudiesAuditorData(operation, [studyID], username, isUserAction, messageType, message, jwt);
|
|
47
32
|
return body[0];
|
|
48
33
|
}
|
|
49
34
|
async storeStudiesAuditorData(operation, studyIDs, username, isUserAction, messageType, message, jwt = "") {
|
|
50
35
|
const sendData = {
|
|
51
|
-
|
|
36
|
+
operation,
|
|
52
37
|
"entityIDs": studyIDs,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
38
|
+
username,
|
|
39
|
+
isUserAction,
|
|
40
|
+
messageType,
|
|
41
|
+
message
|
|
57
42
|
};
|
|
58
43
|
const result = await this.postRequest(`auditor/studies`, sendData, jwt);
|
|
59
44
|
return result.body;
|
|
60
45
|
}
|
|
61
46
|
async getRequest(relative = "", jwt = "") {
|
|
62
|
-
return
|
|
63
|
-
.set("Content-Type", "application/json")
|
|
64
|
-
.set("Authorization", jwt);
|
|
47
|
+
return (0, http_request_1.fetchJson)('GET', this.buildBaseUrl(relative), jwt);
|
|
65
48
|
}
|
|
66
49
|
async postRequest(relative = "", data, jwt = "") {
|
|
67
|
-
return
|
|
68
|
-
.set("Content-Type", "application/json")
|
|
69
|
-
.set("Authorization", jwt)
|
|
70
|
-
.send(data);
|
|
50
|
+
return (0, http_request_1.fetchJson)('POST', this.buildBaseUrl(relative), jwt, data);
|
|
71
51
|
}
|
|
72
52
|
buildBaseUrl(relative) {
|
|
73
53
|
return `${this.baseUrl}/${relative}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auditor-campaign-management-api.client.js","sourceRoot":"","sources":["../../src/auditor-campaign-management-api.client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4BAA0B;
|
|
1
|
+
{"version":3,"file":"auditor-campaign-management-api.client.js","sourceRoot":"","sources":["../../src/auditor-campaign-management-api.client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4BAA0B;AAI1B,yCAAuC;AACvC,uDAAiD;AAG1C,IAAM,kCAAkC,GAAxC,MAAM,kCAAkC;IAC9C,YACwB,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;IACnC,CAAC;IAEE,KAAK,CAAC,sBAAsB,CAAC,UAAkB,EAAE,GAAG,GAAG,EAAE;QAC/D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,qBAAqB,UAAU,EAAE,EAAE,GAAG,CAAC,CAAC;QAC7E,MAAM,cAAc,GAAG,MAAM,CAAC,IAAuB,CAAC;QAEtD,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,KAAK,CAAC,mBAAmB,CAAC,OAAe,EAAE,GAAG,GAAG,EAAE;QACzD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,mBAAmB,OAAO,EAAE,EAAE,GAAG,CAAC,CAAC;QACxE,MAAM,cAAc,GAAG,MAAM,CAAC,IAAuB,CAAC;QAEtD,OAAO,cAAc,CAAC;IACvB,CAAC;IAEM,KAAK,CAAC,qBAAqB,CAAC,SAA2B,EAAE,OAAe,EAAE,QAAgB,EAAE,YAAqB,EAAE,WAAmB,EAAE,OAAY,EAAE,GAAG,GAAG,EAAE;QACpK,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,uBAAuB,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QACzH,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC;IAChB,CAAC;IAEM,KAAK,CAAC,uBAAuB,CAAC,SAA2B,EAAE,QAAkB,EAAE,QAAgB,EAAE,YAAqB,EAAE,WAAmB,EAAE,OAAY,EAAE,GAAG,GAAG,EAAE;QACzK,MAAM,QAAQ,GAAG;YAChB,SAAS;YACT,WAAW,EAAE,QAAQ;YACrB,QAAQ;YACR,YAAY;YACZ,WAAW;YACX,OAAO;SACP,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,iBAAiB,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;QAExE,OAAO,MAAM,CAAC,IAAuB,CAAC;IACvC,CAAC;IAGO,KAAK,CAAC,UAAU,CAAC,WAAmB,EAAE,EAAE,GAAG,GAAG,EAAE;QACvD,OAAO,IAAA,wBAAS,EAAC,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,CAAC;IAC3D,CAAC;IAEO,KAAK,CAAC,WAAW,CAAC,WAAmB,EAAE,EAAE,IAAS,EAAE,GAAG,GAAG,EAAE;QACnE,OAAO,IAAA,wBAAS,EAAC,MAAM,EAAE,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;IAClE,CAAC;IAEO,YAAY,CAAC,QAAgB;QACpC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,QAAQ,EAAE,CAAC;IACtC,CAAC;CACD,CAAA;AAnDY,gFAAkC;6CAAlC,kCAAkC;IAD9C,IAAA,sBAAU,GAAE;;GACA,kCAAkC,CAmD9C"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
|
-
import { CampaignsEntitiesConfigDto } from "./domain/campaign/campaign-entities-config.dto";
|
|
3
2
|
import { CampaignsDuplicatesDto } from "./domain/campaign/campaign-duplicates.dto";
|
|
4
3
|
import { DuplicateCampaignDto } from "./domain/campaign/duplicate-campaign.dto";
|
|
5
4
|
import { CampaignEditorGetResultDto } from "./domain/campaign/campaign-editor-get-result.dto";
|
|
@@ -9,35 +8,23 @@ import { CustomProductDto } from "./domain/campaign/custom-product.dto";
|
|
|
9
8
|
import { ValidationStateResponse } from "./domain/campaign/validation-state.response";
|
|
10
9
|
import { SearchUserDto } from "./domain/users";
|
|
11
10
|
import { EnrichedCampaignGeotargetingDto } from "./domain/campaign/enriched-campaign-geotargeting.dto";
|
|
11
|
+
import type { EventBus } from "@studyportals/ws-client";
|
|
12
|
+
export type CampaignManagementAPIClientConfig = {
|
|
13
|
+
/** Max ms to wait for lambda 'start' acknowledgement before giving up. Default: 10 000. */
|
|
14
|
+
startAckTimeoutMs?: number;
|
|
15
|
+
/** Max ms to wait for 'success'/'failed' after 'start' was received. Default: 900 000. */
|
|
16
|
+
operationTimeoutMs?: number;
|
|
17
|
+
};
|
|
12
18
|
export declare class CampaignManagementAPIClient {
|
|
13
19
|
private readonly baseUrl;
|
|
14
|
-
private
|
|
15
|
-
private
|
|
16
|
-
private pingInterval;
|
|
17
|
-
private reconnectTimeout;
|
|
20
|
+
private readonly bus;
|
|
21
|
+
private readonly config;
|
|
18
22
|
private pendingSaveOperations;
|
|
19
|
-
|
|
20
|
-
private readonly
|
|
21
|
-
private readonly
|
|
22
|
-
constructor(baseUrl: string);
|
|
23
|
-
private static readonly CMA_SUBDOMAIN_PREFIX;
|
|
24
|
-
private initializeWebSocket;
|
|
25
|
-
startWSConnection(wsUrl: string): void;
|
|
26
|
-
private sendWhoAmI;
|
|
27
|
-
private setupPingInterval;
|
|
28
|
-
private clearPingInterval;
|
|
29
|
-
private handleSavingEndMessage;
|
|
30
|
-
/** Checks if API Gateway timed out, based on the status code */
|
|
31
|
-
private is502BadGatewayError;
|
|
32
|
-
getConnectionId(): string | undefined;
|
|
23
|
+
constructor(baseUrl: string, bus: EventBus, config?: CampaignManagementAPIClientConfig);
|
|
24
|
+
private readonly handleCampaignSavingPayload;
|
|
25
|
+
private readonly handleWsDisconnected;
|
|
33
26
|
disconnect(): void;
|
|
34
27
|
getCampaignDuplicates(campaigsnDuplicates: CampaignsDuplicatesDto, jwt?: string): Promise<DuplicateCampaignDto>;
|
|
35
|
-
addCampaignsEntitiesConfigs(campaignID: number, campaignsEntitiesConfigs: CampaignsEntitiesConfigDto[], jwt?: string): Promise<void>;
|
|
36
|
-
removeCampaignsEntitiesConfigsByID(campaignID: number, campaignsEntitiesConfigsIDs: number[], jwt?: string): Promise<void>;
|
|
37
|
-
clearCampaignsEntitiesConfigsByCampaignID(campaignID: number, jwt?: string): Promise<void>;
|
|
38
|
-
setEntitiesBasic(campaignID: number, organisationIDs: number[], studyIDs: number[], jwt?: string): Promise<void>;
|
|
39
|
-
setEntitiesPremium(campaignID: number, organisationIDs: number[], studyIDs: number[], jwt?: string): Promise<void>;
|
|
40
|
-
setEntitiesPersistGoogleLinkerProperty(organisationIds: number[], studyIds: number[], persistGoogleLinkerValue: boolean, jwt: string): Promise<void>;
|
|
41
28
|
getCampaignForCampaignEditor(campaignID: number, jwt?: string): Promise<CampaignEditorGetResultDto>;
|
|
42
29
|
getClientServicesUsers(jwt?: string): Promise<MinimalUserDto[]>;
|
|
43
30
|
getAccountManagers(jwt?: string): Promise<MinimalUserDto[]>;
|
|
@@ -8,210 +8,78 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
-
var CampaignManagementAPIClient_1;
|
|
12
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
12
|
exports.CampaignManagementAPIClient = void 0;
|
|
14
13
|
require("reflect-metadata");
|
|
15
14
|
const inversify_1 = require("inversify");
|
|
16
|
-
const superagent = require("superagent");
|
|
17
15
|
const mb_platform_date_time_1 = require("@studyportals/mb-platform-date-time");
|
|
18
16
|
const ws_retrieved_error_1 = require("./errors/ws-retrieved-error");
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
const http_request_1 = require("./utils/http-request");
|
|
18
|
+
const DEFAULT_CONFIG = {
|
|
19
|
+
startAckTimeoutMs: 10000,
|
|
20
|
+
operationTimeoutMs: 900000,
|
|
21
|
+
};
|
|
22
|
+
let CampaignManagementAPIClient = class CampaignManagementAPIClient {
|
|
23
|
+
constructor(baseUrl, bus, config = {}) {
|
|
22
24
|
this.baseUrl = baseUrl;
|
|
23
25
|
this.pendingSaveOperations = new Map();
|
|
24
|
-
this.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
startWSConnection(wsUrl) {
|
|
38
|
-
this.ws = new WebSocket(wsUrl);
|
|
39
|
-
this.ws.addEventListener("open", () => {
|
|
40
|
-
console.log("WebSocket connection opened");
|
|
41
|
-
this.sendWhoAmI();
|
|
42
|
-
this.setupPingInterval();
|
|
43
|
-
});
|
|
44
|
-
this.ws.addEventListener("message", (event) => {
|
|
45
|
-
try {
|
|
46
|
-
if (typeof event.data === 'string') {
|
|
47
|
-
const response = JSON.parse(event.data);
|
|
48
|
-
// Handle connectionId response
|
|
49
|
-
if ("connectionId" in response) {
|
|
50
|
-
this.connectionId = response.connectionId;
|
|
51
|
-
console.log("Connection ID received:", this.connectionId);
|
|
26
|
+
this.handleCampaignSavingPayload = (payload) => {
|
|
27
|
+
const operationKey = 'campaign:saving';
|
|
28
|
+
const operation = this.pendingSaveOperations.get(operationKey);
|
|
29
|
+
if (!operation)
|
|
30
|
+
return;
|
|
31
|
+
if (payload.status === 'start') {
|
|
32
|
+
// Lambda acknowledged — swap start-ack timeout for full operation timeout
|
|
33
|
+
clearTimeout(operation.timeoutHandle);
|
|
34
|
+
operation.timeoutHandle = setTimeout(() => {
|
|
35
|
+
if (this.pendingSaveOperations.has(operationKey)) {
|
|
36
|
+
this.pendingSaveOperations.delete(operationKey);
|
|
37
|
+
operation.reject(new Error('Campaign save operation timed out'));
|
|
52
38
|
}
|
|
53
|
-
|
|
54
|
-
else {
|
|
55
|
-
this.handleSavingEndMessage(response);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
catch (error) {
|
|
60
|
-
console.error("Error parsing WebSocket message:", error);
|
|
61
|
-
throw error;
|
|
39
|
+
}, this.config.operationTimeoutMs);
|
|
62
40
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
this.clearPingInterval();
|
|
67
|
-
// Reject all pending save operations
|
|
68
|
-
const pendingOperations = Array.from(this.pendingSaveOperations.values());
|
|
69
|
-
this.pendingSaveOperations.clear();
|
|
70
|
-
const disconnectError = new Error('WebSocket connection was closed');
|
|
71
|
-
pendingOperations.forEach(operation => operation.reject(disconnectError));
|
|
72
|
-
// Attempt to reconnect after 5 seconds (only in non-test environment)
|
|
73
|
-
if (process.env.NODE_ENV !== 'test') {
|
|
74
|
-
this.reconnectTimeout = setTimeout(() => {
|
|
75
|
-
this.initializeWebSocket();
|
|
76
|
-
}, 5000);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
this.ws.addEventListener("error", (error) => {
|
|
80
|
-
console.error("WebSocket error:", error);
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
sendWhoAmI() {
|
|
84
|
-
if (this.ws && this.ws.readyState === WebSocket.OPEN) {
|
|
85
|
-
const message = { action: "who-am-I" };
|
|
86
|
-
this.ws.send(JSON.stringify(message));
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
setupPingInterval() {
|
|
90
|
-
this.clearPingInterval();
|
|
91
|
-
// Ping every 8 minutes (480,000 milliseconds) in production, but not in tests
|
|
92
|
-
if (process.env.NODE_ENV !== 'test') {
|
|
93
|
-
this.pingInterval = setInterval(() => {
|
|
94
|
-
this.sendWhoAmI();
|
|
95
|
-
}, this.PING_INTERVAL_MS);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
clearPingInterval() {
|
|
99
|
-
if (this.pingInterval) {
|
|
100
|
-
clearInterval(this.pingInterval);
|
|
101
|
-
this.pingInterval = undefined;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
handleSavingEndMessage(response) {
|
|
105
|
-
const operationTopic = response.topic;
|
|
106
|
-
const operation = this.pendingSaveOperations.get(operationTopic);
|
|
107
|
-
// Only process if HTTP hasn't already resolved this operation
|
|
108
|
-
if (operation) {
|
|
109
|
-
if (response.message.status === "success") {
|
|
110
|
-
this.pendingSaveOperations.delete(operationTopic);
|
|
41
|
+
else if (payload.status === 'success') {
|
|
42
|
+
clearTimeout(operation.timeoutHandle);
|
|
43
|
+
this.pendingSaveOperations.delete(operationKey);
|
|
111
44
|
operation.resolve();
|
|
112
45
|
}
|
|
113
|
-
else if (
|
|
114
|
-
|
|
115
|
-
|
|
46
|
+
else if (payload.status === 'failed') {
|
|
47
|
+
clearTimeout(operation.timeoutHandle);
|
|
48
|
+
const error = new ws_retrieved_error_1.WSRetrievedError(payload.error);
|
|
49
|
+
this.pendingSaveOperations.delete(operationKey);
|
|
116
50
|
operation.reject(error);
|
|
117
51
|
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
return true;
|
|
133
|
-
// Check message for 502 text
|
|
134
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
|
|
135
|
-
if ('message' in error && typeof error.message === 'string' && error.message.includes('502'))
|
|
136
|
-
return true;
|
|
137
|
-
}
|
|
138
|
-
catch (_a) {
|
|
139
|
-
// If any error occurs during checking, return false
|
|
140
|
-
return false;
|
|
141
|
-
}
|
|
142
|
-
return false;
|
|
143
|
-
}
|
|
144
|
-
getConnectionId() {
|
|
145
|
-
return this.connectionId;
|
|
52
|
+
};
|
|
53
|
+
this.handleWsDisconnected = () => {
|
|
54
|
+
const pendingOperations = Array.from(this.pendingSaveOperations.values());
|
|
55
|
+
this.pendingSaveOperations.clear();
|
|
56
|
+
const disconnectError = new Error('WebSocket connection was closed');
|
|
57
|
+
pendingOperations.forEach(operation => {
|
|
58
|
+
clearTimeout(operation.timeoutHandle);
|
|
59
|
+
operation.reject(disconnectError);
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
this.config = Object.assign(Object.assign({}, DEFAULT_CONFIG), config);
|
|
63
|
+
this.bus = bus;
|
|
64
|
+
this.bus.on('campaign:saving', this.handleCampaignSavingPayload);
|
|
65
|
+
this.bus.on('ws:disconnected', this.handleWsDisconnected);
|
|
146
66
|
}
|
|
147
67
|
disconnect() {
|
|
148
|
-
this.
|
|
149
|
-
|
|
150
|
-
if (this.reconnectTimeout) {
|
|
151
|
-
clearTimeout(this.reconnectTimeout);
|
|
152
|
-
this.reconnectTimeout = undefined;
|
|
153
|
-
}
|
|
154
|
-
// Reject all pending save operations
|
|
68
|
+
this.bus.off('campaign:saving', this.handleCampaignSavingPayload);
|
|
69
|
+
this.bus.off('ws:disconnected', this.handleWsDisconnected);
|
|
155
70
|
const pendingOperations = Array.from(this.pendingSaveOperations.values());
|
|
156
71
|
this.pendingSaveOperations.clear();
|
|
157
72
|
const disconnectError = new Error('WebSocket connection was closed');
|
|
158
|
-
pendingOperations.forEach(operation =>
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
this.connectionId = undefined;
|
|
73
|
+
pendingOperations.forEach(operation => {
|
|
74
|
+
clearTimeout(operation.timeoutHandle);
|
|
75
|
+
operation.reject(disconnectError);
|
|
76
|
+
});
|
|
164
77
|
}
|
|
165
78
|
async getCampaignDuplicates(campaigsnDuplicates, jwt = '') {
|
|
166
79
|
const path = `campaigns/get-duplicates`;
|
|
167
80
|
const result = await this.postRequest(path, campaigsnDuplicates, jwt);
|
|
168
81
|
return result.body;
|
|
169
82
|
}
|
|
170
|
-
async addCampaignsEntitiesConfigs(campaignID, campaignsEntitiesConfigs, jwt = '') {
|
|
171
|
-
const path = `campaigns/add-campaigns-entities-configs`;
|
|
172
|
-
const data = {
|
|
173
|
-
campaignsEntitiesConfigs,
|
|
174
|
-
campaignID
|
|
175
|
-
};
|
|
176
|
-
await this.postRequest(path, data, jwt);
|
|
177
|
-
}
|
|
178
|
-
async removeCampaignsEntitiesConfigsByID(campaignID, campaignsEntitiesConfigsIDs, jwt = '') {
|
|
179
|
-
const path = `campaigns/remove-campaigns-entities-configs`;
|
|
180
|
-
const data = { campaignsEntitiesConfigsIDs, campaignID };
|
|
181
|
-
await this.postRequest(path, data, jwt);
|
|
182
|
-
}
|
|
183
|
-
async clearCampaignsEntitiesConfigsByCampaignID(campaignID, jwt = '') {
|
|
184
|
-
const path = `campaigns/clear-campaigns-entities-configs`;
|
|
185
|
-
const data = { campaignID };
|
|
186
|
-
await this.postRequest(path, data, jwt);
|
|
187
|
-
}
|
|
188
|
-
async setEntitiesBasic(campaignID, organisationIDs, studyIDs, jwt = '') {
|
|
189
|
-
const path = `campaigns/set-entities-basic`;
|
|
190
|
-
const data = {
|
|
191
|
-
organisationIDs,
|
|
192
|
-
studyIDs,
|
|
193
|
-
campaignID
|
|
194
|
-
};
|
|
195
|
-
await this.postRequest(path, data, jwt);
|
|
196
|
-
}
|
|
197
|
-
async setEntitiesPremium(campaignID, organisationIDs, studyIDs, jwt = '') {
|
|
198
|
-
const path = `campaigns/set-entities-premium`;
|
|
199
|
-
const data = {
|
|
200
|
-
organisationIDs,
|
|
201
|
-
studyIDs,
|
|
202
|
-
campaignID
|
|
203
|
-
};
|
|
204
|
-
await this.postRequest(path, data, jwt);
|
|
205
|
-
}
|
|
206
|
-
async setEntitiesPersistGoogleLinkerProperty(organisationIds, studyIds, persistGoogleLinkerValue, jwt) {
|
|
207
|
-
const path = `campaigns/set-entities-persist-google-linker`;
|
|
208
|
-
const data = {
|
|
209
|
-
organisationIds,
|
|
210
|
-
studyIds,
|
|
211
|
-
persistGoogleLinkerValue
|
|
212
|
-
};
|
|
213
|
-
await this.postRequest(path, data, jwt);
|
|
214
|
-
}
|
|
215
83
|
async getCampaignForCampaignEditor(campaignID, jwt = '') {
|
|
216
84
|
const path = `campaigns/campaign-editor/${campaignID}`;
|
|
217
85
|
const result = await this.getRequest(path, jwt);
|
|
@@ -235,38 +103,22 @@ let CampaignManagementAPIClient = CampaignManagementAPIClient_1 = class Campaign
|
|
|
235
103
|
return parseInt(result.text);
|
|
236
104
|
}
|
|
237
105
|
async saveCampaign(campaignId, changes, jwt) {
|
|
238
|
-
const path = `campaigns/${campaignId}/process-changes
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
const is502BadGateway = this.is502BadGatewayError(error);
|
|
249
|
-
if (is502BadGateway) {
|
|
250
|
-
// 502 Bad Gateway means the request timed out server-side
|
|
251
|
-
// Continue waiting for WebSocket response, don't treat as error
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
// For other HTTP errors, fail immediately (takes priority over WebSocket)
|
|
255
|
-
if (this.pendingSaveOperations.has(operationTopic)) {
|
|
256
|
-
this.pendingSaveOperations.delete(operationTopic);
|
|
257
|
-
reject(error instanceof Error ? error : new Error(String(error)));
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
// Set a timeout for the entire operation (900 seconds (15 minutes) for HTTP + WebSocket)
|
|
261
|
-
const timeout = process.env.NODE_ENV === 'test' ? this.TEST_TIMEOUT_MS : this.LAMBDA_MAX_TIMEOUT_MS;
|
|
262
|
-
setTimeout(() => {
|
|
263
|
-
if (this.pendingSaveOperations.has(operationTopic)) {
|
|
264
|
-
this.pendingSaveOperations.delete(operationTopic);
|
|
265
|
-
reject(new Error('Campaign save operation timed out'));
|
|
106
|
+
const path = `campaigns/${campaignId}/process-changes`;
|
|
107
|
+
const operationKey = 'campaign:saving';
|
|
108
|
+
if (this.pendingSaveOperations.has(operationKey)) {
|
|
109
|
+
throw new Error('A campaign save operation is already in progress');
|
|
110
|
+
}
|
|
111
|
+
await new Promise((resolve, reject) => {
|
|
112
|
+
const timeoutHandle = setTimeout(() => {
|
|
113
|
+
if (this.pendingSaveOperations.has(operationKey)) {
|
|
114
|
+
this.pendingSaveOperations.delete(operationKey);
|
|
115
|
+
reject(new Error('Campaign save operation timed out: lambda did not acknowledge'));
|
|
266
116
|
}
|
|
267
|
-
},
|
|
117
|
+
}, this.config.startAckTimeoutMs);
|
|
118
|
+
this.pendingSaveOperations.set(operationKey, { resolve, reject, timeoutHandle });
|
|
119
|
+
// Fire-and-forget — resolution driven entirely by WebSocket message
|
|
120
|
+
void this.postRequest(path, changes, jwt).catch(() => { });
|
|
268
121
|
});
|
|
269
|
-
await savePromise;
|
|
270
122
|
}
|
|
271
123
|
async getCustomProducts(campaignID, jwt = '') {
|
|
272
124
|
const path = `campaigns/campaign-editor/custom-products/${campaignID}`;
|
|
@@ -298,25 +150,18 @@ let CampaignManagementAPIClient = CampaignManagementAPIClient_1 = class Campaign
|
|
|
298
150
|
return result.body;
|
|
299
151
|
}
|
|
300
152
|
async postRequest(relative = "", data, jwt = "") {
|
|
301
|
-
|
|
302
|
-
.set("Content-Type", "application/json")
|
|
303
|
-
.set("Authorization", jwt);
|
|
304
|
-
return await request.send(data);
|
|
153
|
+
return (0, http_request_1.fetchJson)('POST', this.buildBaseUrl(relative), jwt, data);
|
|
305
154
|
}
|
|
306
155
|
async getRequest(relative = "", jwt = "") {
|
|
307
|
-
|
|
308
|
-
.set("Content-Type", "application/json")
|
|
309
|
-
.set("Authorization", jwt);
|
|
310
|
-
return await request;
|
|
156
|
+
return (0, http_request_1.fetchJson)('GET', this.buildBaseUrl(relative), jwt);
|
|
311
157
|
}
|
|
312
158
|
buildBaseUrl(relative) {
|
|
313
159
|
return `${this.baseUrl}/${relative}`;
|
|
314
160
|
}
|
|
315
161
|
};
|
|
316
162
|
exports.CampaignManagementAPIClient = CampaignManagementAPIClient;
|
|
317
|
-
CampaignManagementAPIClient
|
|
318
|
-
exports.CampaignManagementAPIClient = CampaignManagementAPIClient = CampaignManagementAPIClient_1 = __decorate([
|
|
163
|
+
exports.CampaignManagementAPIClient = CampaignManagementAPIClient = __decorate([
|
|
319
164
|
(0, inversify_1.injectable)(),
|
|
320
|
-
__metadata("design:paramtypes", [String])
|
|
165
|
+
__metadata("design:paramtypes", [String, Object, Object])
|
|
321
166
|
], CampaignManagementAPIClient);
|
|
322
167
|
//# sourceMappingURL=campaign-management-api.client.js.map
|