@dv4resi/dvss-backend-module-offering-im 0.0.8 → 0.0.9
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/dist/index.d.ts +251 -71
- package/dist/index.js +911 -155
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7,15 +7,17 @@ var dvssBackendModuleUtility = require('@dv4resi/dvss-backend-module-utility');
|
|
|
7
7
|
var axios = require('@nestjs/axios');
|
|
8
8
|
var config = require('@nestjs/config');
|
|
9
9
|
var rxjs = require('rxjs');
|
|
10
|
+
var models = require('@dv4resi/dvss-backend-module-datastore/dist/datastore/models');
|
|
10
11
|
var dvssBackendModuleDatastore = require('@dv4resi/dvss-backend-module-datastore');
|
|
12
|
+
var common_enum = require('@dv4resi/dvss-backend-module-datastore/dist/datastore/commons/common.enum');
|
|
11
13
|
var capabilityIntegration_model = require('@dv4resi/dvss-backend-module-datastore/dist/datastore/models/capability-integration.model');
|
|
12
|
-
var
|
|
14
|
+
var capability_model = require('@dv4resi/dvss-backend-module-datastore/dist/datastore/models/capability.model');
|
|
13
15
|
|
|
14
16
|
var __defProp = Object.defineProperty;
|
|
15
17
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
16
|
-
function _ts_decorate(decorators, target, key,
|
|
17
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
18
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
18
|
+
function _ts_decorate(decorators, target, key, desc2) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
19
21
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
20
22
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
21
23
|
}
|
|
@@ -41,9 +43,9 @@ AppService = _ts_decorate([
|
|
|
41
43
|
], AppService);
|
|
42
44
|
|
|
43
45
|
// src/app.controller.ts
|
|
44
|
-
function _ts_decorate2(decorators, target, key,
|
|
45
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
46
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
46
|
+
function _ts_decorate2(decorators, target, key, desc2) {
|
|
47
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
48
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
47
49
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
48
50
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
49
51
|
}
|
|
@@ -81,9 +83,9 @@ var rootEnvPath = path.resolve(__dirname, "../../../.env");
|
|
|
81
83
|
dotenv.config({
|
|
82
84
|
path: rootEnvPath
|
|
83
85
|
});
|
|
84
|
-
function _ts_decorate3(decorators, target, key,
|
|
85
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
86
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
86
|
+
function _ts_decorate3(decorators, target, key, desc2) {
|
|
87
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
88
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
87
89
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
88
90
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
89
91
|
}
|
|
@@ -113,9 +115,9 @@ AppService2 = _ts_decorate3([
|
|
|
113
115
|
], AppService2);
|
|
114
116
|
|
|
115
117
|
// ../../packages/dvss-integration-trybe/src/app.controller.ts
|
|
116
|
-
function _ts_decorate4(decorators, target, key,
|
|
117
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
118
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
118
|
+
function _ts_decorate4(decorators, target, key, desc2) {
|
|
119
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
120
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
119
121
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
120
122
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
121
123
|
}
|
|
@@ -149,13 +151,9 @@ AppController2 = _ts_decorate4([
|
|
|
149
151
|
typeof AppService2 === "undefined" ? Object : AppService2
|
|
150
152
|
])
|
|
151
153
|
], AppController2);
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
});
|
|
156
|
-
function _ts_decorate5(decorators, target, key, desc) {
|
|
157
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
158
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
154
|
+
function _ts_decorate5(decorators, target, key, desc2) {
|
|
155
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
156
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
159
157
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
160
158
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
161
159
|
}
|
|
@@ -173,9 +171,9 @@ AppService3 = _ts_decorate5([
|
|
|
173
171
|
], AppService3);
|
|
174
172
|
|
|
175
173
|
// ../../packages/dvss-integration-libs/src/app.controller.ts
|
|
176
|
-
function _ts_decorate6(decorators, target, key,
|
|
177
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
178
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
174
|
+
function _ts_decorate6(decorators, target, key, desc2) {
|
|
175
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
176
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
179
177
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
180
178
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
181
179
|
}
|
|
@@ -209,9 +207,19 @@ AppController3 = _ts_decorate6([
|
|
|
209
207
|
typeof AppService3 === "undefined" ? Object : AppService3
|
|
210
208
|
])
|
|
211
209
|
], AppController3);
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
210
|
+
|
|
211
|
+
// ../../packages/dvss-integration-libs/src/integration-traffic-router/constants/http.constant.ts
|
|
212
|
+
var HTTP_METHOD = /* @__PURE__ */ (function(HTTP_METHOD2) {
|
|
213
|
+
HTTP_METHOD2["GET"] = "GET";
|
|
214
|
+
HTTP_METHOD2["POST"] = "POST";
|
|
215
|
+
HTTP_METHOD2["PUT"] = "PUT";
|
|
216
|
+
HTTP_METHOD2["DELETE"] = "DELETE";
|
|
217
|
+
HTTP_METHOD2["PATCH"] = "PATCH";
|
|
218
|
+
return HTTP_METHOD2;
|
|
219
|
+
})({});
|
|
220
|
+
function _ts_decorate7(decorators, target, key, desc2) {
|
|
221
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
222
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
215
223
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
216
224
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
217
225
|
}
|
|
@@ -303,9 +311,9 @@ exports.IntegrationRequestLoggerService = _ts_decorate7([
|
|
|
303
311
|
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
|
|
304
312
|
])
|
|
305
313
|
], exports.IntegrationRequestLoggerService);
|
|
306
|
-
function _ts_decorate8(decorators, target, key,
|
|
307
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
308
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
314
|
+
function _ts_decorate8(decorators, target, key, desc2) {
|
|
315
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
316
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
309
317
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
310
318
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
311
319
|
}
|
|
@@ -326,20 +334,10 @@ exports.RateLimiterService = _ts_decorate8([
|
|
|
326
334
|
common.Injectable()
|
|
327
335
|
], exports.RateLimiterService);
|
|
328
336
|
|
|
329
|
-
// ../../packages/dvss-integration-libs/src/integration-traffic-router/constants/http.constant.ts
|
|
330
|
-
var HTTP_METHOD = /* @__PURE__ */ (function(HTTP_METHOD2) {
|
|
331
|
-
HTTP_METHOD2["GET"] = "GET";
|
|
332
|
-
HTTP_METHOD2["POST"] = "POST";
|
|
333
|
-
HTTP_METHOD2["PUT"] = "PUT";
|
|
334
|
-
HTTP_METHOD2["DELETE"] = "DELETE";
|
|
335
|
-
HTTP_METHOD2["PATCH"] = "PATCH";
|
|
336
|
-
return HTTP_METHOD2;
|
|
337
|
-
})({});
|
|
338
|
-
|
|
339
337
|
// ../../packages/dvss-integration-libs/src/integration-traffic-router/gateway/traffic-gateway.service.ts
|
|
340
|
-
function _ts_decorate9(decorators, target, key,
|
|
341
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
342
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
338
|
+
function _ts_decorate9(decorators, target, key, desc2) {
|
|
339
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
340
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
343
341
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
344
342
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
345
343
|
}
|
|
@@ -551,11 +549,15 @@ exports.TrafficGatewayService = _ts_decorate9([
|
|
|
551
549
|
typeof exports.RateLimiterService === "undefined" ? Object : exports.RateLimiterService
|
|
552
550
|
])
|
|
553
551
|
], exports.TrafficGatewayService);
|
|
552
|
+
var rootEnvPath2 = path.resolve(__dirname, "../../../.env");
|
|
553
|
+
dotenv.config({
|
|
554
|
+
path: rootEnvPath2
|
|
555
|
+
});
|
|
554
556
|
|
|
555
557
|
// ../../packages/dvss-integration-libs/src/app.module.ts
|
|
556
|
-
function _ts_decorate10(decorators, target, key,
|
|
557
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
558
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
558
|
+
function _ts_decorate10(decorators, target, key, desc2) {
|
|
559
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
560
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
559
561
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
560
562
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
561
563
|
}
|
|
@@ -752,17 +754,29 @@ var BaseMembershipManagement = class {
|
|
|
752
754
|
__name(this, "BaseMembershipManagement");
|
|
753
755
|
}
|
|
754
756
|
};
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
757
|
+
function _ts_decorate11(decorators, target, key, desc2) {
|
|
758
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
759
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
760
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
761
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
762
|
+
}
|
|
763
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
764
|
+
function _ts_metadata8(k, v) {
|
|
765
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
766
|
+
}
|
|
767
|
+
__name(_ts_metadata8, "_ts_metadata");
|
|
768
|
+
exports.BaseIntegrationConfiguration = class BaseIntegrationConfiguration {
|
|
758
769
|
static {
|
|
759
770
|
__name(this, "BaseIntegrationConfiguration");
|
|
760
771
|
}
|
|
761
772
|
integrationConfigurationDao;
|
|
762
773
|
commonValidationDatabaseService;
|
|
763
|
-
|
|
774
|
+
logger;
|
|
775
|
+
fileName = "integration-configuration.base.ts";
|
|
776
|
+
constructor(integrationConfigurationDao, commonValidationDatabaseService, logger) {
|
|
764
777
|
this.integrationConfigurationDao = integrationConfigurationDao;
|
|
765
778
|
this.commonValidationDatabaseService = commonValidationDatabaseService;
|
|
779
|
+
this.logger = logger;
|
|
766
780
|
}
|
|
767
781
|
/**
|
|
768
782
|
* Validates add-capability-integration input (project, property, parent, capability, provider, configuredFor).
|
|
@@ -837,19 +851,201 @@ var BaseIntegrationConfiguration = class {
|
|
|
837
851
|
return result;
|
|
838
852
|
}
|
|
839
853
|
/**
|
|
840
|
-
* Update
|
|
841
|
-
*
|
|
842
|
-
*
|
|
854
|
+
* Update capability integration with config merging support.
|
|
855
|
+
* Handles merging of integrationConfig and platformConfig from existing integration.
|
|
856
|
+
*
|
|
857
|
+
* @param request - Update request with id and updateData
|
|
858
|
+
* @param integration - Optional existing integration for config merging
|
|
859
|
+
* @param loggedInUserId - User ID for logging and audit
|
|
860
|
+
* @returns Promise resolving to update status
|
|
843
861
|
*/
|
|
844
|
-
async updateCapabilityIntegration(
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
862
|
+
async updateCapabilityIntegration(request, integration, loggedInUserId) {
|
|
863
|
+
if (!loggedInUserId) {
|
|
864
|
+
throw new Error("loggedInUserId is required");
|
|
865
|
+
}
|
|
866
|
+
this.validateIconAndNickName(request.updateData, loggedInUserId);
|
|
867
|
+
let configToUpdate;
|
|
868
|
+
const updateData = request.updateData;
|
|
869
|
+
if (updateData.config && integration?.config) {
|
|
870
|
+
const existingConfig = integration.config;
|
|
871
|
+
configToUpdate = {
|
|
872
|
+
...existingConfig
|
|
873
|
+
};
|
|
874
|
+
const existingIntegrationConfig = existingConfig.integrationConfig || {};
|
|
875
|
+
configToUpdate.integrationConfig = {
|
|
876
|
+
...existingIntegrationConfig,
|
|
877
|
+
...updateData.config.integrationConfig
|
|
878
|
+
};
|
|
879
|
+
const existingPlatformConfig = existingConfig.platformConfig || {};
|
|
880
|
+
configToUpdate.platformConfig = {
|
|
881
|
+
...existingPlatformConfig,
|
|
882
|
+
...updateData.config.platformConfig
|
|
883
|
+
};
|
|
884
|
+
} else if (updateData.config) {
|
|
885
|
+
configToUpdate = updateData.config;
|
|
886
|
+
}
|
|
887
|
+
const updateDataForDao = {
|
|
888
|
+
nickname: updateData.nickname,
|
|
889
|
+
icon: updateData.icon,
|
|
890
|
+
config: configToUpdate,
|
|
891
|
+
parentId: updateData.parentId,
|
|
892
|
+
updatedBy: loggedInUserId
|
|
893
|
+
};
|
|
894
|
+
const result = await this.integrationConfigurationDao.updateCapabilityIntegration({
|
|
895
|
+
id: request.id,
|
|
896
|
+
updateData: updateDataForDao
|
|
897
|
+
}, loggedInUserId);
|
|
898
|
+
return result;
|
|
899
|
+
}
|
|
900
|
+
/**
|
|
901
|
+
* Validates icon and nickname. Can be overridden in subclasses for provider-specific validation.
|
|
902
|
+
*/
|
|
903
|
+
validateIconAndNickName(updateData, loggedInUserId) {
|
|
904
|
+
if (updateData.nickname !== void 0 && (updateData.nickname === "" || updateData.nickname.trim() === "")) {
|
|
905
|
+
this.logger.error(loggedInUserId, this.validateIconAndNickName.name, this.fileName, "Validation failed: nickname cannot be empty or null");
|
|
906
|
+
throw new Error("Nickname cannot be empty");
|
|
907
|
+
}
|
|
908
|
+
if (updateData.icon && updateData.icon.meta && typeof updateData.icon.meta === "object") {
|
|
909
|
+
const meta = updateData.icon.meta;
|
|
910
|
+
if (meta.iconName !== void 0 && (meta.iconName === null || meta.iconName === "" || typeof meta.iconName === "string" && meta.iconName.trim() === "")) {
|
|
911
|
+
this.logger.error(loggedInUserId, this.validateIconAndNickName.name, this.fileName, "Validation failed: iconName cannot be empty");
|
|
912
|
+
throw new Error("Icon name cannot be empty");
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
/**
|
|
917
|
+
* Get capability integrations with pagination, filtering, sorting, and search.
|
|
918
|
+
* Delegates to DAO for database operations.
|
|
919
|
+
*
|
|
920
|
+
* @param request - Request with projectId, category, and options
|
|
921
|
+
* @param loggedInUserId - User ID for logging
|
|
922
|
+
* @returns Promise resolving to list of capability integrations with total count
|
|
923
|
+
*/
|
|
924
|
+
async getCapabilityIntegrations(request, loggedInUserId) {
|
|
925
|
+
return await this.integrationConfigurationDao.getCapabilityIntegrations(request, loggedInUserId);
|
|
926
|
+
}
|
|
927
|
+
/**
|
|
928
|
+
* Get capability integration by id or by fetchBy (configuredFor).
|
|
929
|
+
* Same business logic as project-ms CapabilityIntegrationService.getCapabilityIntegration.
|
|
930
|
+
*/
|
|
931
|
+
async getCapabilityIntegration(input, context) {
|
|
932
|
+
if (!input.projectId) {
|
|
933
|
+
throw new Error("Project ID is required");
|
|
934
|
+
}
|
|
935
|
+
await this.commonValidationDatabaseService.getProject({
|
|
936
|
+
projectId: input.projectId
|
|
937
|
+
});
|
|
938
|
+
let integration;
|
|
939
|
+
if (input.id) {
|
|
940
|
+
integration = await this.integrationConfigurationDao.getCapabilityIntegrationById({
|
|
941
|
+
id: input.id,
|
|
942
|
+
projectId: input.projectId,
|
|
943
|
+
category: input.category
|
|
944
|
+
}, context.loggedInUserId);
|
|
945
|
+
} else if (input.fetchBy) {
|
|
946
|
+
integration = await this.integrationConfigurationDao.getCapabilityIntegrationByProvider({
|
|
947
|
+
projectId: input.projectId,
|
|
948
|
+
category: input.fetchBy.category ?? input.category,
|
|
949
|
+
configuredForType: input.fetchBy.configuredForType,
|
|
950
|
+
configuredForId: BigInt(input.fetchBy.configuredForId)
|
|
951
|
+
}, context.loggedInUserId);
|
|
952
|
+
}
|
|
953
|
+
if (!integration) {
|
|
954
|
+
throw new Error("Capability integration not found");
|
|
955
|
+
}
|
|
956
|
+
return integration;
|
|
957
|
+
}
|
|
958
|
+
};
|
|
959
|
+
exports.BaseIntegrationConfiguration = _ts_decorate11([
|
|
960
|
+
common.Injectable(),
|
|
961
|
+
_ts_metadata8("design:type", Function),
|
|
962
|
+
_ts_metadata8("design:paramtypes", [
|
|
963
|
+
typeof IntegrationConfigurationDao === "undefined" ? Object : IntegrationConfigurationDao,
|
|
964
|
+
typeof CommonValidationDatabaseService === "undefined" ? Object : CommonValidationDatabaseService,
|
|
965
|
+
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
|
|
966
|
+
])
|
|
967
|
+
], exports.BaseIntegrationConfiguration);
|
|
968
|
+
var BaseIntegrationResourceManagement = class {
|
|
969
|
+
static {
|
|
970
|
+
__name(this, "BaseIntegrationResourceManagement");
|
|
971
|
+
}
|
|
972
|
+
integrationResourceManagementDao;
|
|
973
|
+
logger;
|
|
974
|
+
fileName = "integration-resource-management.base";
|
|
975
|
+
constructor(integrationResourceManagementDao, logger) {
|
|
976
|
+
this.integrationResourceManagementDao = integrationResourceManagementDao;
|
|
977
|
+
this.logger = logger;
|
|
978
|
+
}
|
|
979
|
+
/**
|
|
980
|
+
* Adds a resource (capability integration) to an offering integration via UIF.
|
|
981
|
+
* Inter-service implementation only: performs DAO insert. Wrapper must validate
|
|
982
|
+
* config and mapping-exists before calling; caller (MS) does getOffering, getIntegration,
|
|
983
|
+
* updateOffering and runAfterAddIfNeeded.
|
|
984
|
+
*
|
|
985
|
+
* @param input - projectId, offeringId, capabilityIntegrationId, optional config
|
|
986
|
+
* @param context - GraphQL context
|
|
987
|
+
* @returns Promise resolving to { status, ids }
|
|
988
|
+
*/
|
|
989
|
+
async addResourceToIntegration(input, context) {
|
|
990
|
+
this.logger.info(context.loggedInUserId, this.addResourceToIntegration.name, this.fileName, "addResourceToIntegration called", {
|
|
991
|
+
offeringId: input.offeringId.toString(),
|
|
992
|
+
capabilityIntegrationId: input.capabilityIntegrationId.toString()
|
|
993
|
+
});
|
|
994
|
+
const addResult = await this.integrationResourceManagementDao.addCapabilityIntegrationMapping({
|
|
995
|
+
projectId: input.projectId,
|
|
996
|
+
capabilityIntegrationId: input.capabilityIntegrationId,
|
|
997
|
+
configuredForId: input.offeringId,
|
|
998
|
+
configuredForType: models.CONFIGURED_FOR_TYPE_ENUM.OFFERING,
|
|
999
|
+
config: input.config
|
|
1000
|
+
}, context);
|
|
1001
|
+
const result = {
|
|
1002
|
+
status: addResult.status,
|
|
1003
|
+
ids: addResult.ids
|
|
1004
|
+
};
|
|
1005
|
+
this.logger.info(context.loggedInUserId, this.addResourceToIntegration.name, this.fileName, "addResourceToIntegration completed", {
|
|
1006
|
+
status: result.status,
|
|
1007
|
+
idsCount: result.ids.length
|
|
1008
|
+
});
|
|
1009
|
+
return result;
|
|
1010
|
+
}
|
|
1011
|
+
/**
|
|
1012
|
+
* Removes a resource from an offering integration.
|
|
1013
|
+
* Generic validation and DAO call; Trybe service adds mapping-exists check before calling.
|
|
1014
|
+
*/
|
|
1015
|
+
async removeResourceFromIntegration(request, context) {
|
|
1016
|
+
const result = await this.integrationResourceManagementDao.removeCapabilityIntegrationMapping({
|
|
1017
|
+
capabilityIntegrationId: request.capabilityIntegrationId,
|
|
1018
|
+
configuredForId: request.offeringId,
|
|
1019
|
+
configuredForType: models.CONFIGURED_FOR_TYPE_ENUM.OFFERING
|
|
1020
|
+
}, context);
|
|
1021
|
+
return {
|
|
1022
|
+
status: result.status
|
|
1023
|
+
};
|
|
1024
|
+
}
|
|
1025
|
+
/**
|
|
1026
|
+
* Updates offering integration resource configuration (cap_integ_resource_mapping.config by id).
|
|
1027
|
+
* Inter-service implementation only: performs DAO update. Wrapper must validate config before calling
|
|
1028
|
+
* (e.g. Trybe validates via validateResourceMappingConfig). Caller (MS) does getOffering,
|
|
1029
|
+
* getIntegration, and runAfterUpdateIfNeeded (e.g. handleTrybeIntegration).
|
|
1030
|
+
*
|
|
1031
|
+
* @param input - id (resource mapping row id), config
|
|
1032
|
+
* @param context - GraphQL context
|
|
1033
|
+
* @returns Promise resolving to { status }
|
|
1034
|
+
*/
|
|
1035
|
+
async updateOfferingIntegrationResourceConfiguration(input, context) {
|
|
1036
|
+
this.logger.info(context.loggedInUserId, this.updateOfferingIntegrationResourceConfiguration.name, this.fileName, "updateOfferingIntegrationResourceConfiguration called", {
|
|
1037
|
+
id: input.id.toString()
|
|
1038
|
+
});
|
|
1039
|
+
const result = await this.integrationResourceManagementDao.updateCapabilityIntegrationConfiguration({
|
|
1040
|
+
id: input.id,
|
|
1041
|
+
config: input.config
|
|
1042
|
+
}, context);
|
|
1043
|
+
this.logger.info(context.loggedInUserId, this.updateOfferingIntegrationResourceConfiguration.name, this.fileName, "updateOfferingIntegrationResourceConfiguration completed", {
|
|
1044
|
+
status: result.status
|
|
1045
|
+
});
|
|
1046
|
+
return {
|
|
1047
|
+
status: result.status
|
|
848
1048
|
};
|
|
849
|
-
return await this.integrationConfigurationDao.updateCapabilityIntegration({
|
|
850
|
-
id,
|
|
851
|
-
updateData: updateDataWithAudit
|
|
852
|
-
}, context.loggedInUserId);
|
|
853
1049
|
}
|
|
854
1050
|
};
|
|
855
1051
|
|
|
@@ -1083,9 +1279,9 @@ var Table = class Table2 {
|
|
|
1083
1279
|
[IsDrizzleTable] = true;
|
|
1084
1280
|
/** @internal */
|
|
1085
1281
|
[ExtraConfigBuilder] = void 0;
|
|
1086
|
-
constructor(name,
|
|
1282
|
+
constructor(name, schema3, baseName) {
|
|
1087
1283
|
this[TableName] = this[OriginalName] = name;
|
|
1088
|
-
this[Schema] =
|
|
1284
|
+
this[Schema] = schema3;
|
|
1089
1285
|
this[BaseName] = baseName;
|
|
1090
1286
|
}
|
|
1091
1287
|
};
|
|
@@ -2061,11 +2257,11 @@ var View = class View2 {
|
|
|
2061
2257
|
static [entityKind] = "View";
|
|
2062
2258
|
/** @internal */
|
|
2063
2259
|
[ViewBaseConfig];
|
|
2064
|
-
constructor({ name: name2, schema:
|
|
2260
|
+
constructor({ name: name2, schema: schema3, selectedFields, query }) {
|
|
2065
2261
|
this[ViewBaseConfig] = {
|
|
2066
2262
|
name: name2,
|
|
2067
2263
|
originalName: name2,
|
|
2068
|
-
schema:
|
|
2264
|
+
schema: schema3,
|
|
2069
2265
|
selectedFields,
|
|
2070
2266
|
query,
|
|
2071
2267
|
isExisting: !query,
|
|
@@ -2120,30 +2316,65 @@ function and(...unfilteredConditions) {
|
|
|
2120
2316
|
]);
|
|
2121
2317
|
}
|
|
2122
2318
|
__name(and, "and");
|
|
2319
|
+
function or(...unfilteredConditions) {
|
|
2320
|
+
const conditions = unfilteredConditions.filter((c) => c !== void 0);
|
|
2321
|
+
if (conditions.length === 0) {
|
|
2322
|
+
return void 0;
|
|
2323
|
+
}
|
|
2324
|
+
if (conditions.length === 1) {
|
|
2325
|
+
return new SQL(conditions);
|
|
2326
|
+
}
|
|
2327
|
+
return new SQL([
|
|
2328
|
+
new StringChunk("("),
|
|
2329
|
+
sql.join(conditions, new StringChunk(" or ")),
|
|
2330
|
+
new StringChunk(")")
|
|
2331
|
+
]);
|
|
2332
|
+
}
|
|
2333
|
+
__name(or, "or");
|
|
2123
2334
|
function isNull(value) {
|
|
2124
2335
|
return sql`${value} is null`;
|
|
2125
2336
|
}
|
|
2126
2337
|
__name(isNull, "isNull");
|
|
2338
|
+
function isNotNull(value) {
|
|
2339
|
+
return sql`${value} is not null`;
|
|
2340
|
+
}
|
|
2341
|
+
__name(isNotNull, "isNotNull");
|
|
2342
|
+
|
|
2343
|
+
// ../../node_modules/drizzle-orm/sql/expressions/select.js
|
|
2344
|
+
function asc(column) {
|
|
2345
|
+
return sql`${column} asc`;
|
|
2346
|
+
}
|
|
2347
|
+
__name(asc, "asc");
|
|
2348
|
+
function desc(column) {
|
|
2349
|
+
return sql`${column} desc`;
|
|
2350
|
+
}
|
|
2351
|
+
__name(desc, "desc");
|
|
2352
|
+
|
|
2353
|
+
// ../../node_modules/drizzle-orm/utils.js
|
|
2354
|
+
function getTableColumns(table) {
|
|
2355
|
+
return table[Table.Symbol.Columns];
|
|
2356
|
+
}
|
|
2357
|
+
__name(getTableColumns, "getTableColumns");
|
|
2127
2358
|
|
|
2128
2359
|
// ../../packages/dvss-integration-libs/src/integration-common-utils/dao/integration-configuration.dao.ts
|
|
2129
|
-
function
|
|
2130
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
2131
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
2360
|
+
function _ts_decorate12(decorators, target, key, desc2) {
|
|
2361
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
2362
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2132
2363
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2133
2364
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2134
2365
|
}
|
|
2135
|
-
__name(
|
|
2136
|
-
function
|
|
2366
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
2367
|
+
function _ts_metadata9(k, v) {
|
|
2137
2368
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2138
2369
|
}
|
|
2139
|
-
__name(
|
|
2370
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
2140
2371
|
function _ts_param(paramIndex, decorator) {
|
|
2141
2372
|
return function(target, key) {
|
|
2142
2373
|
decorator(target, key, paramIndex);
|
|
2143
2374
|
};
|
|
2144
2375
|
}
|
|
2145
2376
|
__name(_ts_param, "_ts_param");
|
|
2146
|
-
exports.IntegrationConfigurationDao = class
|
|
2377
|
+
exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
|
|
2147
2378
|
static {
|
|
2148
2379
|
__name(this, "IntegrationConfigurationDao");
|
|
2149
2380
|
}
|
|
@@ -2259,27 +2490,219 @@ exports.IntegrationConfigurationDao = class IntegrationConfigurationDao {
|
|
|
2259
2490
|
throw error;
|
|
2260
2491
|
}
|
|
2261
2492
|
}
|
|
2493
|
+
/**
|
|
2494
|
+
* Retrieves capability integration by ID with resource mapping details.
|
|
2495
|
+
* Copied from project-ms CapabilityIntegrationDao.getCapabilityIntegrationById.
|
|
2496
|
+
*/
|
|
2497
|
+
async getCapabilityIntegrationById(request, loggedInUserId) {
|
|
2498
|
+
try {
|
|
2499
|
+
this.logger.info(loggedInUserId, this.getCapabilityIntegrationById.name, this.fileName, "getCapabilityIntegrationById called", request);
|
|
2500
|
+
const conditions = [
|
|
2501
|
+
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.id, request.id),
|
|
2502
|
+
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.projectId, request.projectId),
|
|
2503
|
+
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.type, capability_model.CAPABILITY_TYPE_ENUM.INTEGRATION),
|
|
2504
|
+
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.status, capabilityIntegration_model.CAPABILITY_INTEGRATION_STATUS_ENUM.ACTIVE),
|
|
2505
|
+
isNull(dvssBackendModuleDatastore.schema.capabilityIntegration.deletedAt),
|
|
2506
|
+
isNull(dvssBackendModuleDatastore.schema.capability.deletedAt)
|
|
2507
|
+
];
|
|
2508
|
+
if (request.category) {
|
|
2509
|
+
conditions.push(eq(dvssBackendModuleDatastore.schema.capabilityIntegration.category, request.category));
|
|
2510
|
+
}
|
|
2511
|
+
const response = await this.conn.select({
|
|
2512
|
+
...getTableColumns(dvssBackendModuleDatastore.schema.capabilityIntegration),
|
|
2513
|
+
resourceMappingId: dvssBackendModuleDatastore.schema.capIntegResourceMapping.id,
|
|
2514
|
+
configuredForId: dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId,
|
|
2515
|
+
configuredForType: dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType,
|
|
2516
|
+
resourceMappingConfig: dvssBackendModuleDatastore.schema.capIntegResourceMapping.config,
|
|
2517
|
+
provider: dvssBackendModuleDatastore.schema.capability.providerIntegrationType
|
|
2518
|
+
}).from(dvssBackendModuleDatastore.schema.capabilityIntegration).innerJoin(dvssBackendModuleDatastore.schema.capability, eq(dvssBackendModuleDatastore.schema.capability.id, dvssBackendModuleDatastore.schema.capabilityIntegration.capabilityId)).leftJoin(dvssBackendModuleDatastore.schema.capIntegResourceMapping, and(eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.capabilityIntegrationId, dvssBackendModuleDatastore.schema.capabilityIntegration.id), eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.projectId, request.projectId), isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt))).where(and(...conditions));
|
|
2519
|
+
return response[0];
|
|
2520
|
+
} catch (error) {
|
|
2521
|
+
this.logger.error(loggedInUserId, this.getCapabilityIntegrationById.name, this.fileName, "Error on getCapabilityIntegrationById", error, request);
|
|
2522
|
+
throw error;
|
|
2523
|
+
}
|
|
2524
|
+
}
|
|
2525
|
+
/**
|
|
2526
|
+
* Retrieves capability integration by provider type and resource mapping.
|
|
2527
|
+
* Copied from project-ms CapabilityIntegrationDao.getCapabilityIntegrationByProvider.
|
|
2528
|
+
*/
|
|
2529
|
+
async getCapabilityIntegrationByProvider(request, loggedInUserId) {
|
|
2530
|
+
try {
|
|
2531
|
+
this.logger.info(loggedInUserId, this.getCapabilityIntegrationByProvider.name, this.fileName, "getCapabilityIntegrationByProvider called", request);
|
|
2532
|
+
const conditions = [
|
|
2533
|
+
isNull(dvssBackendModuleDatastore.schema.capability.deletedAt),
|
|
2534
|
+
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.projectId, request.projectId),
|
|
2535
|
+
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.type, capability_model.CAPABILITY_TYPE_ENUM.INTEGRATION),
|
|
2536
|
+
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.status, capabilityIntegration_model.CAPABILITY_INTEGRATION_STATUS_ENUM.ACTIVE),
|
|
2537
|
+
isNull(dvssBackendModuleDatastore.schema.capabilityIntegration.deletedAt),
|
|
2538
|
+
eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.projectId, request.projectId),
|
|
2539
|
+
eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType, request.configuredForType),
|
|
2540
|
+
eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId, request.configuredForId),
|
|
2541
|
+
isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt)
|
|
2542
|
+
];
|
|
2543
|
+
if (request.category) {
|
|
2544
|
+
conditions.push(eq(dvssBackendModuleDatastore.schema.capabilityIntegration.category, request.category));
|
|
2545
|
+
}
|
|
2546
|
+
const response = await this.conn.select({
|
|
2547
|
+
...getTableColumns(dvssBackendModuleDatastore.schema.capabilityIntegration),
|
|
2548
|
+
resourceMappingId: dvssBackendModuleDatastore.schema.capIntegResourceMapping.id,
|
|
2549
|
+
configuredForId: dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId,
|
|
2550
|
+
configuredForType: dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType,
|
|
2551
|
+
resourceMappingConfig: dvssBackendModuleDatastore.schema.capIntegResourceMapping.config,
|
|
2552
|
+
provider: dvssBackendModuleDatastore.schema.capability.providerIntegrationType
|
|
2553
|
+
}).from(dvssBackendModuleDatastore.schema.capabilityIntegration).innerJoin(dvssBackendModuleDatastore.schema.capability, eq(dvssBackendModuleDatastore.schema.capability.id, dvssBackendModuleDatastore.schema.capabilityIntegration.capabilityId)).innerJoin(dvssBackendModuleDatastore.schema.capIntegResourceMapping, eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.capabilityIntegrationId, dvssBackendModuleDatastore.schema.capabilityIntegration.id)).where(and(...conditions));
|
|
2554
|
+
return response[0];
|
|
2555
|
+
} catch (error) {
|
|
2556
|
+
this.logger.error(loggedInUserId, this.getCapabilityIntegrationByProvider.name, this.fileName, "Error on getCapabilityIntegrationByProvider", error, request);
|
|
2557
|
+
throw error;
|
|
2558
|
+
}
|
|
2559
|
+
}
|
|
2560
|
+
/**
|
|
2561
|
+
* Get capability integrations with pagination, filtering, sorting, and search.
|
|
2562
|
+
* Copied from project-ms CapabilityIntegrationDao.getCapabilityIntegrations.
|
|
2563
|
+
*/
|
|
2564
|
+
async getCapabilityIntegrations(input, loggedInUserId) {
|
|
2565
|
+
try {
|
|
2566
|
+
this.logger.info(loggedInUserId, this.getCapabilityIntegrations.name, this.fileName, "getCapabilityIntegrations called", input);
|
|
2567
|
+
const count = input.options?.count ?? dvssBackendModuleDatastore.MAX_RECORDS_LENGTH;
|
|
2568
|
+
const offset = ((input.options?.page ?? 1) - 1) * count;
|
|
2569
|
+
const sorting = input.options?.sorting;
|
|
2570
|
+
let sortBy = dvssBackendModuleDatastore.schema.capabilityIntegration.id;
|
|
2571
|
+
if (sorting?.by === "CREATED_AT") {
|
|
2572
|
+
sortBy = dvssBackendModuleDatastore.schema.capabilityIntegration.createdAt;
|
|
2573
|
+
} else if (sorting?.by === "UPDATED_AT") {
|
|
2574
|
+
sortBy = dvssBackendModuleDatastore.schema.capabilityIntegration.updatedAt;
|
|
2575
|
+
}
|
|
2576
|
+
const sortOrder = sorting?.order === common_enum.SORTING_ORDER_ENUM.ASC ? asc(sortBy) : desc(sortBy);
|
|
2577
|
+
const searchTerm = input.options?.search;
|
|
2578
|
+
const shouldJoinCapability = Boolean(searchTerm) || Boolean(input.options?.filters?.some((filter) => filter.by === "PROVIDER_INTEGRATION_TYPE"));
|
|
2579
|
+
const whereConditions = [
|
|
2580
|
+
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.projectId, input.projectId),
|
|
2581
|
+
isNull(dvssBackendModuleDatastore.schema.capabilityIntegration.deletedAt)
|
|
2582
|
+
];
|
|
2583
|
+
if (input.category) {
|
|
2584
|
+
whereConditions.push(eq(dvssBackendModuleDatastore.schema.capabilityIntegration.category, input.category));
|
|
2585
|
+
}
|
|
2586
|
+
if (input.options?.filters && input.options.filters.length > 0) {
|
|
2587
|
+
this.applyFilters(whereConditions, input.options);
|
|
2588
|
+
}
|
|
2589
|
+
if (searchTerm) {
|
|
2590
|
+
const searchPattern = `%${searchTerm}%`;
|
|
2591
|
+
whereConditions.push(sql`(${dvssBackendModuleDatastore.schema.capabilityIntegration.nickname} LIKE ${searchPattern} OR ${dvssBackendModuleDatastore.schema.capability.name} LIKE ${searchPattern})`);
|
|
2592
|
+
}
|
|
2593
|
+
if (shouldJoinCapability) {
|
|
2594
|
+
whereConditions.push(isNull(dvssBackendModuleDatastore.schema.capability.deletedAt));
|
|
2595
|
+
}
|
|
2596
|
+
if (input.propertyId) {
|
|
2597
|
+
whereConditions.push(isNotNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.id));
|
|
2598
|
+
}
|
|
2599
|
+
const countWhereConditions = [
|
|
2600
|
+
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.projectId, input.projectId),
|
|
2601
|
+
isNull(dvssBackendModuleDatastore.schema.capabilityIntegration.deletedAt)
|
|
2602
|
+
];
|
|
2603
|
+
if (input.category) {
|
|
2604
|
+
countWhereConditions.push(eq(dvssBackendModuleDatastore.schema.capabilityIntegration.category, input.category));
|
|
2605
|
+
}
|
|
2606
|
+
if (input.options?.filters && input.options.filters.length > 0) {
|
|
2607
|
+
this.applyFilters(countWhereConditions, input.options);
|
|
2608
|
+
}
|
|
2609
|
+
if (searchTerm) {
|
|
2610
|
+
const searchPattern = `%${searchTerm}%`;
|
|
2611
|
+
countWhereConditions.push(sql`(${dvssBackendModuleDatastore.schema.capabilityIntegration.nickname} LIKE ${searchPattern} OR ${dvssBackendModuleDatastore.schema.capability.name} LIKE ${searchPattern})`);
|
|
2612
|
+
}
|
|
2613
|
+
const countQueryBuilder = this.conn.select({
|
|
2614
|
+
count: sql`count(distinct ${dvssBackendModuleDatastore.schema.capabilityIntegration.id})`.as("count")
|
|
2615
|
+
}).from(dvssBackendModuleDatastore.schema.capabilityIntegration);
|
|
2616
|
+
const countQueryWithJoins = shouldJoinCapability ? countQueryBuilder.leftJoin(dvssBackendModuleDatastore.schema.capability, eq(dvssBackendModuleDatastore.schema.capability.id, dvssBackendModuleDatastore.schema.capabilityIntegration.capabilityId)) : countQueryBuilder;
|
|
2617
|
+
if (shouldJoinCapability) {
|
|
2618
|
+
countWhereConditions.push(isNull(dvssBackendModuleDatastore.schema.capability.deletedAt));
|
|
2619
|
+
}
|
|
2620
|
+
const countQueryWithPropertyJoin = input.propertyId ? countQueryWithJoins.leftJoin(dvssBackendModuleDatastore.schema.capIntegResourceMapping, and(eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.capabilityIntegrationId, dvssBackendModuleDatastore.schema.capabilityIntegration.id), eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType, models.CONFIGURED_FOR_TYPE_ENUM.PROPERTY), eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId, BigInt(input.propertyId)), isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt))) : countQueryWithJoins;
|
|
2621
|
+
if (input.propertyId) {
|
|
2622
|
+
countWhereConditions.push(isNotNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.id));
|
|
2623
|
+
}
|
|
2624
|
+
const countQuery = countQueryWithPropertyJoin.where(and(...countWhereConditions));
|
|
2625
|
+
const baseQuery = this.conn.select({
|
|
2626
|
+
...getTableColumns(dvssBackendModuleDatastore.schema.capabilityIntegration),
|
|
2627
|
+
provider: dvssBackendModuleDatastore.schema.capability.providerIntegrationType
|
|
2628
|
+
}).from(dvssBackendModuleDatastore.schema.capabilityIntegration).leftJoin(dvssBackendModuleDatastore.schema.capability, eq(dvssBackendModuleDatastore.schema.capability.id, dvssBackendModuleDatastore.schema.capabilityIntegration.capabilityId));
|
|
2629
|
+
const finalQuery = input.propertyId ? baseQuery.leftJoin(dvssBackendModuleDatastore.schema.capIntegResourceMapping, and(eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.capabilityIntegrationId, dvssBackendModuleDatastore.schema.capabilityIntegration.id), eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType, models.CONFIGURED_FOR_TYPE_ENUM.PROPERTY), eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId, BigInt(input.propertyId)), isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt))).where(and(...whereConditions)) : baseQuery.where(and(...whereConditions));
|
|
2630
|
+
const [{ count: totalCount }, records] = await Promise.all([
|
|
2631
|
+
countQuery.execute().then((result) => result[0]),
|
|
2632
|
+
finalQuery.limit(count).offset(offset).orderBy(sortOrder).execute()
|
|
2633
|
+
]);
|
|
2634
|
+
return {
|
|
2635
|
+
totalCount: Number(totalCount) || 0,
|
|
2636
|
+
records
|
|
2637
|
+
};
|
|
2638
|
+
} catch (error) {
|
|
2639
|
+
this.logger.error(loggedInUserId, this.getCapabilityIntegrations.name, this.fileName, "Error in getCapabilityIntegrations", error, input);
|
|
2640
|
+
throw error;
|
|
2641
|
+
}
|
|
2642
|
+
}
|
|
2643
|
+
/**
|
|
2644
|
+
* Applies filters to where conditions.
|
|
2645
|
+
*/
|
|
2646
|
+
applyFilters(whereConditions, filters) {
|
|
2647
|
+
if (!filters || !filters.filters) {
|
|
2648
|
+
return;
|
|
2649
|
+
}
|
|
2650
|
+
for (const filter of filters.filters) {
|
|
2651
|
+
const filterValues = filter.values;
|
|
2652
|
+
if (!filterValues || filterValues.length === 0) {
|
|
2653
|
+
continue;
|
|
2654
|
+
}
|
|
2655
|
+
switch (filter.by) {
|
|
2656
|
+
case "PROVIDER_INTEGRATION_TYPE": {
|
|
2657
|
+
const valuePlaceholders = filterValues.map((value) => sql`${String(value)}`);
|
|
2658
|
+
const joinedValues = sql.join(valuePlaceholders, sql`, `);
|
|
2659
|
+
whereConditions.push(sql`${dvssBackendModuleDatastore.schema.capability.providerIntegrationType} IN (${joinedValues})`);
|
|
2660
|
+
break;
|
|
2661
|
+
}
|
|
2662
|
+
case "CAPABILITY_INTEGRATION_TYPE": {
|
|
2663
|
+
const parentConditions = [];
|
|
2664
|
+
for (const value of filterValues) {
|
|
2665
|
+
const upperValue = String(value).toUpperCase();
|
|
2666
|
+
if (upperValue === "PARENT") {
|
|
2667
|
+
parentConditions.push(isNull(dvssBackendModuleDatastore.schema.capabilityIntegration.parentId));
|
|
2668
|
+
} else if (upperValue === "CHILD") {
|
|
2669
|
+
parentConditions.push(isNotNull(dvssBackendModuleDatastore.schema.capabilityIntegration.parentId));
|
|
2670
|
+
}
|
|
2671
|
+
}
|
|
2672
|
+
if (parentConditions.length === 1) {
|
|
2673
|
+
whereConditions.push(parentConditions[0]);
|
|
2674
|
+
} else if (parentConditions.length > 1) {
|
|
2675
|
+
const orCondition = or(...parentConditions);
|
|
2676
|
+
if (orCondition) {
|
|
2677
|
+
whereConditions.push(orCondition);
|
|
2678
|
+
}
|
|
2679
|
+
}
|
|
2680
|
+
break;
|
|
2681
|
+
}
|
|
2682
|
+
}
|
|
2683
|
+
}
|
|
2684
|
+
}
|
|
2262
2685
|
};
|
|
2263
|
-
exports.IntegrationConfigurationDao =
|
|
2686
|
+
exports.IntegrationConfigurationDao = _ts_decorate12([
|
|
2264
2687
|
common.Injectable(),
|
|
2265
2688
|
_ts_param(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
|
|
2266
|
-
|
|
2267
|
-
|
|
2689
|
+
_ts_metadata9("design:type", Function),
|
|
2690
|
+
_ts_metadata9("design:paramtypes", [
|
|
2268
2691
|
typeof MySql2Database === "undefined" ? Object : MySql2Database,
|
|
2269
2692
|
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
|
|
2270
2693
|
])
|
|
2271
2694
|
], exports.IntegrationConfigurationDao);
|
|
2272
|
-
function
|
|
2273
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
2274
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
2695
|
+
function _ts_decorate13(decorators, target, key, desc2) {
|
|
2696
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
2697
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2275
2698
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2276
2699
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2277
2700
|
}
|
|
2278
|
-
__name(
|
|
2279
|
-
function
|
|
2701
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
2702
|
+
function _ts_metadata10(k, v) {
|
|
2280
2703
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2281
2704
|
}
|
|
2282
|
-
__name(
|
|
2705
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
2283
2706
|
function _ts_param2(paramIndex, decorator) {
|
|
2284
2707
|
return function(target, key) {
|
|
2285
2708
|
decorator(target, key, paramIndex);
|
|
@@ -2295,25 +2718,212 @@ exports.IntegrationUserManagementDao = class IntegrationUserManagementDao {
|
|
|
2295
2718
|
this.conn = conn;
|
|
2296
2719
|
}
|
|
2297
2720
|
};
|
|
2298
|
-
exports.IntegrationUserManagementDao =
|
|
2721
|
+
exports.IntegrationUserManagementDao = _ts_decorate13([
|
|
2299
2722
|
common.Injectable(),
|
|
2300
2723
|
_ts_param2(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
|
|
2301
|
-
|
|
2302
|
-
|
|
2724
|
+
_ts_metadata10("design:type", Function),
|
|
2725
|
+
_ts_metadata10("design:paramtypes", [
|
|
2303
2726
|
typeof MySql2Database === "undefined" ? Object : MySql2Database
|
|
2304
2727
|
])
|
|
2305
2728
|
], exports.IntegrationUserManagementDao);
|
|
2306
|
-
function
|
|
2307
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
2308
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
2729
|
+
function _ts_decorate14(decorators, target, key, desc2) {
|
|
2730
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
2731
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2309
2732
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2310
2733
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2311
2734
|
}
|
|
2312
|
-
__name(
|
|
2313
|
-
function
|
|
2735
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
2736
|
+
function _ts_metadata11(k, v) {
|
|
2314
2737
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2315
2738
|
}
|
|
2316
|
-
__name(
|
|
2739
|
+
__name(_ts_metadata11, "_ts_metadata");
|
|
2740
|
+
function _ts_param3(paramIndex, decorator) {
|
|
2741
|
+
return function(target, key) {
|
|
2742
|
+
decorator(target, key, paramIndex);
|
|
2743
|
+
};
|
|
2744
|
+
}
|
|
2745
|
+
__name(_ts_param3, "_ts_param");
|
|
2746
|
+
exports.IntegrationResourceManagementDao = class IntegrationResourceManagementDao {
|
|
2747
|
+
static {
|
|
2748
|
+
__name(this, "IntegrationResourceManagementDao");
|
|
2749
|
+
}
|
|
2750
|
+
conn;
|
|
2751
|
+
logger;
|
|
2752
|
+
fileName = "integration-resource-management.dao";
|
|
2753
|
+
constructor(conn, logger) {
|
|
2754
|
+
this.conn = conn;
|
|
2755
|
+
this.logger = logger;
|
|
2756
|
+
}
|
|
2757
|
+
/**
|
|
2758
|
+
* Adds a capability integration resource mapping (insert into cap_integ_resource_mapping).
|
|
2759
|
+
* Replaces inter-service gRPC call to project-onboarding-ms for add configurations.
|
|
2760
|
+
*
|
|
2761
|
+
* @param input - projectId, capabilityIntegrationId, configuredForId, configuredForType, optional config
|
|
2762
|
+
* @param context - GraphQL context for loggedInUserId
|
|
2763
|
+
* @returns Promise resolving to { status: true, ids: [insertedId] } or { status: false, ids: [] }
|
|
2764
|
+
*/
|
|
2765
|
+
async addCapabilityIntegrationMapping(input, context) {
|
|
2766
|
+
try {
|
|
2767
|
+
this.logger.info(context.loggedInUserId, this.addCapabilityIntegrationMapping.name, this.fileName, "Adding capability integration mapping", input);
|
|
2768
|
+
const insertResult = await this.conn.insert(dvssBackendModuleDatastore.schema.capIntegResourceMapping).values({
|
|
2769
|
+
projectId: input.projectId,
|
|
2770
|
+
status: capabilityIntegration_model.CAPABILITY_INTEGRATION_STATUS_ENUM.ACTIVE,
|
|
2771
|
+
capabilityIntegrationId: input.capabilityIntegrationId,
|
|
2772
|
+
configuredForId: input.configuredForId,
|
|
2773
|
+
configuredForType: input.configuredForType,
|
|
2774
|
+
config: input.config ?? null,
|
|
2775
|
+
createdBy: context.loggedInUserId
|
|
2776
|
+
});
|
|
2777
|
+
const raw = insertResult;
|
|
2778
|
+
const insertedId = raw[0]?.insertId != null ? Number(raw[0].insertId) : 0;
|
|
2779
|
+
const status = insertedId > 0;
|
|
2780
|
+
const ids = status ? [
|
|
2781
|
+
BigInt(insertedId)
|
|
2782
|
+
] : [];
|
|
2783
|
+
this.logger.info(context.loggedInUserId, this.addCapabilityIntegrationMapping.name, this.fileName, `Mapping add ${status ? "successful" : "failed"}`, {
|
|
2784
|
+
insertedId,
|
|
2785
|
+
status
|
|
2786
|
+
});
|
|
2787
|
+
return {
|
|
2788
|
+
status,
|
|
2789
|
+
ids
|
|
2790
|
+
};
|
|
2791
|
+
} catch (error) {
|
|
2792
|
+
this.logger.error(context.loggedInUserId, this.addCapabilityIntegrationMapping.name, this.fileName, "Error adding capability integration mapping", error, input);
|
|
2793
|
+
throw error;
|
|
2794
|
+
}
|
|
2795
|
+
}
|
|
2796
|
+
/**
|
|
2797
|
+
* Checks if a capability integration resource mapping exists.
|
|
2798
|
+
* Validates that the mapping exists for the given capability integration, configured for ID and type.
|
|
2799
|
+
*
|
|
2800
|
+
* @param input - Input containing capability integration ID, configured for ID and type
|
|
2801
|
+
* @param loggedInUserId - ID of the user performing the operation
|
|
2802
|
+
* @returns Promise that resolves to true if mapping exists, false otherwise
|
|
2803
|
+
*/
|
|
2804
|
+
async checkMappingExists(input, loggedInUserId) {
|
|
2805
|
+
try {
|
|
2806
|
+
this.logger.info(loggedInUserId, this.checkMappingExists.name, this.fileName, `${this.checkMappingExists.name} called`, input);
|
|
2807
|
+
const response = await this.conn.select({
|
|
2808
|
+
id: dvssBackendModuleDatastore.schema.capIntegResourceMapping.id
|
|
2809
|
+
}).from(dvssBackendModuleDatastore.schema.capIntegResourceMapping).where(and(eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.capabilityIntegrationId, input.capabilityIntegrationId), eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId, input.configuredForId), eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType, input.configuredForType), isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt))).limit(1);
|
|
2810
|
+
return response.length > 0;
|
|
2811
|
+
} catch (error) {
|
|
2812
|
+
this.logger.error(loggedInUserId, this.checkMappingExists.name, this.fileName, "Error in checkMappingExists", error, input);
|
|
2813
|
+
throw error;
|
|
2814
|
+
}
|
|
2815
|
+
}
|
|
2816
|
+
/**
|
|
2817
|
+
* Removes capability integration resource mapping (soft delete).
|
|
2818
|
+
* Sets deletedAt and deletedBy on the matching cap_integ_resource_mapping row.
|
|
2819
|
+
* Use this from UIF/callers instead of inter-service call to project-onboarding-ms.
|
|
2820
|
+
*
|
|
2821
|
+
* @param input - Delete parameters including capability integration ID, configured for ID and type
|
|
2822
|
+
* @param loggedInUserId - ID of the user performing the operation
|
|
2823
|
+
* @returns Promise resolving to { status: true } if any row was updated, { status: false } otherwise
|
|
2824
|
+
*/
|
|
2825
|
+
async removeCapabilityIntegrationMapping(input, context) {
|
|
2826
|
+
try {
|
|
2827
|
+
this.logger.info(context.loggedInUserId, this.removeCapabilityIntegrationMapping.name, this.fileName, "Removing capability integration mapping", input);
|
|
2828
|
+
const whereConditions = [
|
|
2829
|
+
isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt),
|
|
2830
|
+
eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.capabilityIntegrationId, input.capabilityIntegrationId),
|
|
2831
|
+
eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId, input.configuredForId),
|
|
2832
|
+
eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType, input.configuredForType)
|
|
2833
|
+
];
|
|
2834
|
+
const deleteResult = await this.conn.update(dvssBackendModuleDatastore.schema.capIntegResourceMapping).set({
|
|
2835
|
+
deletedAt: /* @__PURE__ */ new Date(),
|
|
2836
|
+
deletedBy: context.loggedInUserId
|
|
2837
|
+
}).where(and(...whereConditions));
|
|
2838
|
+
const isSuccess = deleteResult[0].affectedRows > 0;
|
|
2839
|
+
this.logger.info(context.loggedInUserId, this.removeCapabilityIntegrationMapping.name, this.fileName, `Mapping removal ${isSuccess ? "successful" : "failed - no matching records"}`, {
|
|
2840
|
+
affectedRows: deleteResult[0].affectedRows
|
|
2841
|
+
});
|
|
2842
|
+
return {
|
|
2843
|
+
status: isSuccess
|
|
2844
|
+
};
|
|
2845
|
+
} catch (error) {
|
|
2846
|
+
this.logger.error(context.loggedInUserId, this.removeCapabilityIntegrationMapping.name, this.fileName, "Error removing capability integration mapping", error, input);
|
|
2847
|
+
throw error;
|
|
2848
|
+
}
|
|
2849
|
+
}
|
|
2850
|
+
/**
|
|
2851
|
+
* Gets a capability integration resource mapping by id (non-deleted only).
|
|
2852
|
+
* Use from UIF wrappers to validate mapping exists before update.
|
|
2853
|
+
*
|
|
2854
|
+
* @param id - cap_integ_resource_mapping.id
|
|
2855
|
+
* @param loggedInUserId - for logging
|
|
2856
|
+
* @returns The mapping row or undefined if not found
|
|
2857
|
+
*/
|
|
2858
|
+
async getCapabilityIntegrationResourceMappingById(id, loggedInUserId) {
|
|
2859
|
+
try {
|
|
2860
|
+
this.logger.info(loggedInUserId, this.getCapabilityIntegrationResourceMappingById.name, this.fileName, `${this.getCapabilityIntegrationResourceMappingById.name} called`, {
|
|
2861
|
+
id: id.toString()
|
|
2862
|
+
});
|
|
2863
|
+
const rows = await this.conn.select({
|
|
2864
|
+
id: dvssBackendModuleDatastore.schema.capIntegResourceMapping.id,
|
|
2865
|
+
capabilityIntegrationId: dvssBackendModuleDatastore.schema.capIntegResourceMapping.capabilityIntegrationId,
|
|
2866
|
+
configuredForId: dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId,
|
|
2867
|
+
configuredForType: dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType
|
|
2868
|
+
}).from(dvssBackendModuleDatastore.schema.capIntegResourceMapping).where(and(eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.id, id), isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt))).limit(1);
|
|
2869
|
+
return rows[0];
|
|
2870
|
+
} catch (error) {
|
|
2871
|
+
this.logger.error(loggedInUserId, this.getCapabilityIntegrationResourceMappingById.name, this.fileName, "Error in getCapabilityIntegrationResourceMappingById", error, {
|
|
2872
|
+
id: id.toString()
|
|
2873
|
+
});
|
|
2874
|
+
throw error;
|
|
2875
|
+
}
|
|
2876
|
+
}
|
|
2877
|
+
/**
|
|
2878
|
+
* Updates capability integration resource mapping config by id.
|
|
2879
|
+
* Replaces inter-service gRPC call to project-onboarding-ms for update capability integration configuration.
|
|
2880
|
+
*
|
|
2881
|
+
* @param input - id (mapping row id), config (new config JSON)
|
|
2882
|
+
* @param context - GraphQL context for loggedInUserId
|
|
2883
|
+
* @returns Promise resolving to { status: true } if row was updated, { status: false } otherwise
|
|
2884
|
+
*/
|
|
2885
|
+
async updateCapabilityIntegrationConfiguration(input, context) {
|
|
2886
|
+
try {
|
|
2887
|
+
this.logger.info(context.loggedInUserId, this.updateCapabilityIntegrationConfiguration.name, this.fileName, "Updating capability integration resource mapping config", {
|
|
2888
|
+
id: input.id.toString()
|
|
2889
|
+
});
|
|
2890
|
+
const updateResult = await this.conn.update(dvssBackendModuleDatastore.schema.capIntegResourceMapping).set({
|
|
2891
|
+
config: input.config,
|
|
2892
|
+
updatedBy: context.loggedInUserId
|
|
2893
|
+
}).where(and(eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.id, input.id), isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt)));
|
|
2894
|
+
const isSuccess = updateResult[0].affectedRows > 0;
|
|
2895
|
+
this.logger.info(context.loggedInUserId, this.updateCapabilityIntegrationConfiguration.name, this.fileName, `Mapping config update ${isSuccess ? "successful" : "failed - no matching records"}`, {
|
|
2896
|
+
affectedRows: updateResult[0].affectedRows
|
|
2897
|
+
});
|
|
2898
|
+
return {
|
|
2899
|
+
status: isSuccess
|
|
2900
|
+
};
|
|
2901
|
+
} catch (error) {
|
|
2902
|
+
this.logger.error(context.loggedInUserId, this.updateCapabilityIntegrationConfiguration.name, this.fileName, "Error updating capability integration resource mapping config", error, input);
|
|
2903
|
+
throw error;
|
|
2904
|
+
}
|
|
2905
|
+
}
|
|
2906
|
+
};
|
|
2907
|
+
exports.IntegrationResourceManagementDao = _ts_decorate14([
|
|
2908
|
+
common.Injectable(),
|
|
2909
|
+
_ts_param3(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
|
|
2910
|
+
_ts_metadata11("design:type", Function),
|
|
2911
|
+
_ts_metadata11("design:paramtypes", [
|
|
2912
|
+
typeof MySql2Database === "undefined" ? Object : MySql2Database,
|
|
2913
|
+
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
|
|
2914
|
+
])
|
|
2915
|
+
], exports.IntegrationResourceManagementDao);
|
|
2916
|
+
function _ts_decorate15(decorators, target, key, desc2) {
|
|
2917
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
2918
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2919
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2920
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2921
|
+
}
|
|
2922
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
2923
|
+
function _ts_metadata12(k, v) {
|
|
2924
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2925
|
+
}
|
|
2926
|
+
__name(_ts_metadata12, "_ts_metadata");
|
|
2317
2927
|
exports.TrybeCustomerManagement = class _TrybeCustomerManagement {
|
|
2318
2928
|
static {
|
|
2319
2929
|
__name(this, "TrybeCustomerManagement");
|
|
@@ -2403,26 +3013,61 @@ exports.TrybeCustomerManagement = class _TrybeCustomerManagement {
|
|
|
2403
3013
|
}, integration, loggedInUserId);
|
|
2404
3014
|
return response.data;
|
|
2405
3015
|
}
|
|
3016
|
+
/**
|
|
3017
|
+
* Delete a customer on Trybe.
|
|
3018
|
+
*/
|
|
3019
|
+
async deleteCustomer(customerId, integration, loggedInUserId) {
|
|
3020
|
+
try {
|
|
3021
|
+
this.logger.info(loggedInUserId, this.deleteCustomer.name, this.fileName, `${_TrybeCustomerManagement.name} -> ${this.deleteCustomer.name} Called`, {
|
|
3022
|
+
customerId
|
|
3023
|
+
});
|
|
3024
|
+
await this.trafficGatewayService.executeIntegrationRequest({
|
|
3025
|
+
apiMethod: HTTP_METHOD.DELETE,
|
|
3026
|
+
url: `/customers/customers/${customerId}`,
|
|
3027
|
+
baseUrl: integration.config.platformConfig.baseUrl,
|
|
3028
|
+
headers: integration.headers
|
|
3029
|
+
}, integration, loggedInUserId);
|
|
3030
|
+
return {
|
|
3031
|
+
status: true
|
|
3032
|
+
};
|
|
3033
|
+
} catch (error) {
|
|
3034
|
+
this.logger.error(loggedInUserId, this.deleteCustomer.name, this.fileName, "Error in deleting customer on Trybe", error);
|
|
3035
|
+
throw error;
|
|
3036
|
+
}
|
|
3037
|
+
}
|
|
2406
3038
|
};
|
|
2407
|
-
exports.TrybeCustomerManagement =
|
|
3039
|
+
exports.TrybeCustomerManagement = _ts_decorate15([
|
|
2408
3040
|
common.Injectable(),
|
|
2409
|
-
|
|
2410
|
-
|
|
3041
|
+
_ts_metadata12("design:type", Function),
|
|
3042
|
+
_ts_metadata12("design:paramtypes", [
|
|
2411
3043
|
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
|
|
2412
3044
|
typeof exports.TrafficGatewayService === "undefined" ? Object : exports.TrafficGatewayService
|
|
2413
3045
|
])
|
|
2414
3046
|
], exports.TrybeCustomerManagement);
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
3047
|
+
|
|
3048
|
+
// ../../packages/dvss-integration-trybe/src/utils/url.utils.ts
|
|
3049
|
+
function isValidHttpUrl(urlString) {
|
|
3050
|
+
try {
|
|
3051
|
+
const url = new URL(urlString);
|
|
3052
|
+
return url.protocol === "http:" || url.protocol === "https:";
|
|
3053
|
+
} catch {
|
|
3054
|
+
return false;
|
|
3055
|
+
}
|
|
3056
|
+
}
|
|
3057
|
+
__name(isValidHttpUrl, "isValidHttpUrl");
|
|
3058
|
+
|
|
3059
|
+
// ../../packages/dvss-integration-trybe/src/capabilities/auth/auth.service.ts
|
|
3060
|
+
function _ts_decorate16(decorators, target, key, desc2) {
|
|
3061
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3062
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2418
3063
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2419
3064
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2420
3065
|
}
|
|
2421
|
-
__name(
|
|
2422
|
-
function
|
|
3066
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
3067
|
+
function _ts_metadata13(k, v) {
|
|
2423
3068
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2424
3069
|
}
|
|
2425
|
-
__name(
|
|
3070
|
+
__name(_ts_metadata13, "_ts_metadata");
|
|
2426
3071
|
exports.TrybeAuthService = class _TrybeAuthService {
|
|
2427
3072
|
static {
|
|
2428
3073
|
__name(this, "TrybeAuthService");
|
|
@@ -2471,7 +3116,7 @@ exports.TrybeAuthService = class _TrybeAuthService {
|
|
|
2471
3116
|
if (!platformConfig.baseUrl) {
|
|
2472
3117
|
throw new Error("Platform configuration is invalid: Base URL not found");
|
|
2473
3118
|
}
|
|
2474
|
-
if (!
|
|
3119
|
+
if (!isValidHttpUrl(platformConfig.baseUrl)) {
|
|
2475
3120
|
throw new Error("Platform configuration is invalid: Base URL is not a valid URL");
|
|
2476
3121
|
}
|
|
2477
3122
|
} else {
|
|
@@ -2485,14 +3130,6 @@ exports.TrybeAuthService = class _TrybeAuthService {
|
|
|
2485
3130
|
headers
|
|
2486
3131
|
};
|
|
2487
3132
|
}
|
|
2488
|
-
isValidUrl(urlString) {
|
|
2489
|
-
try {
|
|
2490
|
-
const url = new URL(urlString);
|
|
2491
|
-
return url.protocol === "http:" || url.protocol === "https:";
|
|
2492
|
-
} catch {
|
|
2493
|
-
return false;
|
|
2494
|
-
}
|
|
2495
|
-
}
|
|
2496
3133
|
/**
|
|
2497
3134
|
* Tests Trybe integration by making a test API call
|
|
2498
3135
|
* Uses a test customer lookup to verify credentials are valid
|
|
@@ -2527,10 +3164,10 @@ exports.TrybeAuthService = class _TrybeAuthService {
|
|
|
2527
3164
|
throw new Error("Method not implemented.");
|
|
2528
3165
|
}
|
|
2529
3166
|
};
|
|
2530
|
-
exports.TrybeAuthService =
|
|
3167
|
+
exports.TrybeAuthService = _ts_decorate16([
|
|
2531
3168
|
common.Injectable(),
|
|
2532
|
-
|
|
2533
|
-
|
|
3169
|
+
_ts_metadata13("design:type", Function),
|
|
3170
|
+
_ts_metadata13("design:paramtypes", [
|
|
2534
3171
|
typeof exports.TrybeCustomerManagement === "undefined" ? Object : exports.TrybeCustomerManagement,
|
|
2535
3172
|
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
|
|
2536
3173
|
])
|
|
@@ -2593,17 +3230,17 @@ function mapTrybeCreditsToSystem(res, integration) {
|
|
|
2593
3230
|
__name(mapTrybeCreditsToSystem, "mapTrybeCreditsToSystem");
|
|
2594
3231
|
|
|
2595
3232
|
// ../../packages/dvss-integration-trybe/src/capabilities/credit-management/credit-booking.service.ts
|
|
2596
|
-
function
|
|
2597
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
2598
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
3233
|
+
function _ts_decorate17(decorators, target, key, desc2) {
|
|
3234
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3235
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2599
3236
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2600
3237
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2601
3238
|
}
|
|
2602
|
-
__name(
|
|
2603
|
-
function
|
|
3239
|
+
__name(_ts_decorate17, "_ts_decorate");
|
|
3240
|
+
function _ts_metadata14(k, v) {
|
|
2604
3241
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2605
3242
|
}
|
|
2606
|
-
__name(
|
|
3243
|
+
__name(_ts_metadata14, "_ts_metadata");
|
|
2607
3244
|
exports.TrybeCreditBooking = class _TrybeCreditBooking {
|
|
2608
3245
|
static {
|
|
2609
3246
|
__name(this, "TrybeCreditBooking");
|
|
@@ -2661,10 +3298,10 @@ exports.TrybeCreditBooking = class _TrybeCreditBooking {
|
|
|
2661
3298
|
return mapTrybeCreditsToSystem(raw, validatedIntegration);
|
|
2662
3299
|
}
|
|
2663
3300
|
};
|
|
2664
|
-
exports.TrybeCreditBooking =
|
|
3301
|
+
exports.TrybeCreditBooking = _ts_decorate17([
|
|
2665
3302
|
common.Injectable(),
|
|
2666
|
-
|
|
2667
|
-
|
|
3303
|
+
_ts_metadata14("design:type", Function),
|
|
3304
|
+
_ts_metadata14("design:paramtypes", [
|
|
2668
3305
|
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
|
|
2669
3306
|
typeof exports.TrafficGatewayService === "undefined" ? Object : exports.TrafficGatewayService,
|
|
2670
3307
|
typeof exports.TrybeAuthService === "undefined" ? Object : exports.TrybeAuthService
|
|
@@ -2736,6 +3373,18 @@ var TRYBE_OFFERING_TYPE_API = {
|
|
|
2736
3373
|
SESSION: "session",
|
|
2737
3374
|
COURSE: "course"
|
|
2738
3375
|
};
|
|
3376
|
+
|
|
3377
|
+
// ../../packages/dvss-integration-trybe/src/models/integration-resource-management.model.ts
|
|
3378
|
+
var TRYBE_SUPPORTED_JOURNEYS_ENUM = /* @__PURE__ */ (function(TRYBE_SUPPORTED_JOURNEYS_ENUM2) {
|
|
3379
|
+
TRYBE_SUPPORTED_JOURNEYS_ENUM2["APPOINTMENT"] = "APPOINTMENT";
|
|
3380
|
+
TRYBE_SUPPORTED_JOURNEYS_ENUM2["SESSION"] = "SESSION";
|
|
3381
|
+
TRYBE_SUPPORTED_JOURNEYS_ENUM2["COURSE"] = "COURSE";
|
|
3382
|
+
return TRYBE_SUPPORTED_JOURNEYS_ENUM2;
|
|
3383
|
+
})({});
|
|
3384
|
+
var TRYBE_CATALOGING_BY_ENUM = /* @__PURE__ */ (function(TRYBE_CATALOGING_BY_ENUM2) {
|
|
3385
|
+
TRYBE_CATALOGING_BY_ENUM2["PEOPLE_RESOURCE"] = "PEOPLE_RESOURCE";
|
|
3386
|
+
return TRYBE_CATALOGING_BY_ENUM2;
|
|
3387
|
+
})({});
|
|
2739
3388
|
var TRYBE_WEEKDAYS_MAPPING = {
|
|
2740
3389
|
monday: models.DAY_OF_WEEK.MON,
|
|
2741
3390
|
tuesday: models.DAY_OF_WEEK.TUE,
|
|
@@ -3136,17 +3785,17 @@ function mapTrybeAppointmentAvailabilityToSystemResponse(slots) {
|
|
|
3136
3785
|
__name(mapTrybeAppointmentAvailabilityToSystemResponse, "mapTrybeAppointmentAvailabilityToSystemResponse");
|
|
3137
3786
|
|
|
3138
3787
|
// ../../packages/dvss-integration-trybe/src/capabilities/wellness/wellness-management.service.ts
|
|
3139
|
-
function
|
|
3140
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
3141
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
3788
|
+
function _ts_decorate18(decorators, target, key, desc2) {
|
|
3789
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3790
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3142
3791
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3143
3792
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3144
3793
|
}
|
|
3145
|
-
__name(
|
|
3146
|
-
function
|
|
3794
|
+
__name(_ts_decorate18, "_ts_decorate");
|
|
3795
|
+
function _ts_metadata15(k, v) {
|
|
3147
3796
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
3148
3797
|
}
|
|
3149
|
-
__name(
|
|
3798
|
+
__name(_ts_metadata15, "_ts_metadata");
|
|
3150
3799
|
exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
3151
3800
|
static {
|
|
3152
3801
|
__name(this, "TrybeWellnessManagement");
|
|
@@ -3640,10 +4289,10 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
3640
4289
|
return mapTrybeAppointmentAvailabilityToSystemResponse(response.data);
|
|
3641
4290
|
}
|
|
3642
4291
|
};
|
|
3643
|
-
exports.TrybeWellnessManagement =
|
|
4292
|
+
exports.TrybeWellnessManagement = _ts_decorate18([
|
|
3644
4293
|
common.Injectable(),
|
|
3645
|
-
|
|
3646
|
-
|
|
4294
|
+
_ts_metadata15("design:type", Function),
|
|
4295
|
+
_ts_metadata15("design:paramtypes", [
|
|
3647
4296
|
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
|
|
3648
4297
|
typeof exports.TrafficGatewayService === "undefined" ? Object : exports.TrafficGatewayService,
|
|
3649
4298
|
typeof exports.TrybeAuthService === "undefined" ? Object : exports.TrybeAuthService
|
|
@@ -3663,25 +4312,25 @@ function mapTrybeSiteResponseToSystem(response) {
|
|
|
3663
4312
|
__name(mapTrybeSiteResponseToSystem, "mapTrybeSiteResponseToSystem");
|
|
3664
4313
|
|
|
3665
4314
|
// ../../packages/dvss-integration-trybe/src/capabilities/integration-configuration/integration-configuration.service.ts
|
|
3666
|
-
function
|
|
3667
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
3668
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
4315
|
+
function _ts_decorate19(decorators, target, key, desc2) {
|
|
4316
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4317
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3669
4318
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3670
4319
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3671
4320
|
}
|
|
3672
|
-
__name(
|
|
3673
|
-
function
|
|
4321
|
+
__name(_ts_decorate19, "_ts_decorate");
|
|
4322
|
+
function _ts_metadata16(k, v) {
|
|
3674
4323
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
3675
4324
|
}
|
|
3676
|
-
__name(
|
|
3677
|
-
exports.TrybeIntegrationConfigurationService = class TrybeIntegrationConfigurationService extends BaseIntegrationConfiguration {
|
|
4325
|
+
__name(_ts_metadata16, "_ts_metadata");
|
|
4326
|
+
exports.TrybeIntegrationConfigurationService = class TrybeIntegrationConfigurationService extends exports.BaseIntegrationConfiguration {
|
|
3678
4327
|
static {
|
|
3679
4328
|
__name(this, "TrybeIntegrationConfigurationService");
|
|
3680
4329
|
}
|
|
3681
4330
|
trybeAuthService;
|
|
3682
4331
|
trafficGatewayService;
|
|
3683
|
-
constructor(integrationConfigurationDao, commonValidationDatabaseService, trybeAuthService, trafficGatewayService) {
|
|
3684
|
-
super(integrationConfigurationDao, commonValidationDatabaseService), this.trybeAuthService = trybeAuthService, this.trafficGatewayService = trafficGatewayService;
|
|
4332
|
+
constructor(integrationConfigurationDao, commonValidationDatabaseService, logger, trybeAuthService, trafficGatewayService) {
|
|
4333
|
+
super(integrationConfigurationDao, commonValidationDatabaseService, logger), this.trybeAuthService = trybeAuthService, this.trafficGatewayService = trafficGatewayService;
|
|
3685
4334
|
}
|
|
3686
4335
|
/**
|
|
3687
4336
|
* Add capability integration: validate Trybe config, then configuredFor (offering), then delegate to base.
|
|
@@ -3696,10 +4345,15 @@ exports.TrybeIntegrationConfigurationService = class TrybeIntegrationConfigurati
|
|
|
3696
4345
|
return super.addCapabilityIntegration(input, context);
|
|
3697
4346
|
}
|
|
3698
4347
|
/**
|
|
3699
|
-
* Update capability integration: delegate to base.
|
|
4348
|
+
* Update capability integration: convert to new signature and delegate to base.
|
|
3700
4349
|
*/
|
|
3701
|
-
async updateCapabilityIntegration(
|
|
3702
|
-
|
|
4350
|
+
async updateCapabilityIntegration(request, integration, loggedInUserId) {
|
|
4351
|
+
if (request.updateData.config) {
|
|
4352
|
+
this.trybeAuthService.validateConfig({
|
|
4353
|
+
config: request.updateData.config
|
|
4354
|
+
}, loggedInUserId);
|
|
4355
|
+
}
|
|
4356
|
+
return super.updateCapabilityIntegration(request, integration, loggedInUserId);
|
|
3703
4357
|
}
|
|
3704
4358
|
/**
|
|
3705
4359
|
* Validates configuredFor (offering exists and belongs to project). Same as project-ms validateCapabilityIntegrationConfiguredForInput.
|
|
@@ -3729,31 +4383,127 @@ exports.TrybeIntegrationConfigurationService = class TrybeIntegrationConfigurati
|
|
|
3729
4383
|
return mapTrybeSiteResponseToSystem(response);
|
|
3730
4384
|
}
|
|
3731
4385
|
};
|
|
3732
|
-
exports.TrybeIntegrationConfigurationService =
|
|
4386
|
+
exports.TrybeIntegrationConfigurationService = _ts_decorate19([
|
|
3733
4387
|
common.Injectable(),
|
|
3734
|
-
|
|
3735
|
-
|
|
4388
|
+
_ts_metadata16("design:type", Function),
|
|
4389
|
+
_ts_metadata16("design:paramtypes", [
|
|
3736
4390
|
typeof exports.IntegrationConfigurationDao === "undefined" ? Object : exports.IntegrationConfigurationDao,
|
|
3737
4391
|
typeof dvssBackendModuleDatastore.CommonValidationDatabaseService === "undefined" ? Object : dvssBackendModuleDatastore.CommonValidationDatabaseService,
|
|
4392
|
+
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
|
|
3738
4393
|
typeof exports.TrybeAuthService === "undefined" ? Object : exports.TrybeAuthService,
|
|
3739
4394
|
typeof exports.TrafficGatewayService === "undefined" ? Object : exports.TrafficGatewayService
|
|
3740
4395
|
])
|
|
3741
4396
|
], exports.TrybeIntegrationConfigurationService);
|
|
4397
|
+
function _ts_decorate20(decorators, target, key, desc2) {
|
|
4398
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4399
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
4400
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4401
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4402
|
+
}
|
|
4403
|
+
__name(_ts_decorate20, "_ts_decorate");
|
|
4404
|
+
function _ts_metadata17(k, v) {
|
|
4405
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4406
|
+
}
|
|
4407
|
+
__name(_ts_metadata17, "_ts_metadata");
|
|
4408
|
+
var OFFERING_INTEGRATION_MAPPING_ALREADY_EXISTS = "OFFERING_INTEGRATION_MAPPING_ALREADY_EXISTS";
|
|
4409
|
+
var VALID_JOURNEY_VALUES = /* @__PURE__ */ new Set([
|
|
4410
|
+
"SESSION",
|
|
4411
|
+
"COURSE",
|
|
4412
|
+
"APPOINTMENT"
|
|
4413
|
+
]);
|
|
4414
|
+
exports.TrybeIntegrationResourceManagementService = class TrybeIntegrationResourceManagementService extends BaseIntegrationResourceManagement {
|
|
4415
|
+
static {
|
|
4416
|
+
__name(this, "TrybeIntegrationResourceManagementService");
|
|
4417
|
+
}
|
|
4418
|
+
constructor(logger, integrationResourceManagementDao) {
|
|
4419
|
+
super(integrationResourceManagementDao, logger);
|
|
4420
|
+
}
|
|
4421
|
+
/**
|
|
4422
|
+
* Validates Trybe resource mapping config (same rules as MS trybe-offering-integration-management.service).
|
|
4423
|
+
* @throws CustomException BAD_REQUEST if config is invalid
|
|
4424
|
+
*/
|
|
4425
|
+
validateResourceMappingConfig(config3) {
|
|
4426
|
+
const resourceMappingConfig = config3;
|
|
4427
|
+
if (!resourceMappingConfig.supportedJourneys || resourceMappingConfig.supportedJourneys.length === 0) {
|
|
4428
|
+
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: supportedJourneys required and must be non-empty");
|
|
4429
|
+
}
|
|
4430
|
+
if (!resourceMappingConfig.catalogingBy || // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
4431
|
+
resourceMappingConfig.catalogingBy !== TRYBE_CATALOGING_BY_ENUM.PEOPLE_RESOURCE) {
|
|
4432
|
+
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: catalogingBy must be PEOPLE_RESOURCE");
|
|
4433
|
+
}
|
|
4434
|
+
if (resourceMappingConfig.isExternalCmsIntegrationEnabled === void 0 || typeof resourceMappingConfig.isExternalCmsIntegrationEnabled !== "boolean" || resourceMappingConfig.isExternalCmsIntegrationEnabled === false) {
|
|
4435
|
+
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: isExternalCmsIntegrationEnabled must be true");
|
|
4436
|
+
}
|
|
4437
|
+
if (!resourceMappingConfig.externalCmsUrl || !isValidHttpUrl(resourceMappingConfig.externalCmsUrl)) {
|
|
4438
|
+
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: externalCmsUrl must be a valid HTTP(S) URL");
|
|
4439
|
+
}
|
|
4440
|
+
if (!resourceMappingConfig.supportedJourneys.some((journey) => VALID_JOURNEY_VALUES.has(journey))) {
|
|
4441
|
+
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: supportedJourneys must contain at least one of SESSION, COURSE, APPOINTMENT");
|
|
4442
|
+
}
|
|
4443
|
+
if (resourceMappingConfig.supportedJourneys.some((journey) => !VALID_JOURNEY_VALUES.has(journey))) {
|
|
4444
|
+
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: supportedJourneys may only contain SESSION, COURSE, APPOINTMENT");
|
|
4445
|
+
}
|
|
4446
|
+
if (!resourceMappingConfig.paymentType || typeof resourceMappingConfig.paymentType !== "string") {
|
|
4447
|
+
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: paymentType required and must be a string");
|
|
4448
|
+
}
|
|
4449
|
+
}
|
|
4450
|
+
async addResourceToIntegration(input, context) {
|
|
4451
|
+
if (input.config != null && typeof input.config === "object") {
|
|
4452
|
+
this.validateResourceMappingConfig(input.config);
|
|
4453
|
+
}
|
|
4454
|
+
const isMappingExists = await this.integrationResourceManagementDao.checkMappingExists({
|
|
4455
|
+
capabilityIntegrationId: input.capabilityIntegrationId,
|
|
4456
|
+
configuredForId: input.offeringId,
|
|
4457
|
+
configuredForType: models.CONFIGURED_FOR_TYPE_ENUM.OFFERING
|
|
4458
|
+
}, context.loggedInUserId);
|
|
4459
|
+
if (isMappingExists) {
|
|
4460
|
+
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, OFFERING_INTEGRATION_MAPPING_ALREADY_EXISTS);
|
|
4461
|
+
}
|
|
4462
|
+
return super.addResourceToIntegration(input, context);
|
|
4463
|
+
}
|
|
4464
|
+
async removeResourceFromIntegration(request, context) {
|
|
4465
|
+
const isMappingExists = await this.integrationResourceManagementDao.checkMappingExists({
|
|
4466
|
+
capabilityIntegrationId: request.capabilityIntegrationId,
|
|
4467
|
+
configuredForId: request.offeringId,
|
|
4468
|
+
configuredForType: models.CONFIGURED_FOR_TYPE_ENUM.OFFERING
|
|
4469
|
+
}, context.loggedInUserId);
|
|
4470
|
+
if (!isMappingExists) {
|
|
4471
|
+
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Mapping not found");
|
|
4472
|
+
}
|
|
4473
|
+
return super.removeResourceFromIntegration(request, context);
|
|
4474
|
+
}
|
|
4475
|
+
async updateOfferingIntegrationResourceConfiguration(input, context) {
|
|
4476
|
+
const resourceMapping = await this.integrationResourceManagementDao.getCapabilityIntegrationResourceMappingById(input.id, context.loggedInUserId);
|
|
4477
|
+
if (!resourceMapping) {
|
|
4478
|
+
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Resource mapping not found");
|
|
4479
|
+
}
|
|
4480
|
+
this.validateResourceMappingConfig(input.config);
|
|
4481
|
+
return await super.updateOfferingIntegrationResourceConfiguration(input, context);
|
|
4482
|
+
}
|
|
4483
|
+
};
|
|
4484
|
+
exports.TrybeIntegrationResourceManagementService = _ts_decorate20([
|
|
4485
|
+
common.Injectable(),
|
|
4486
|
+
_ts_metadata17("design:type", Function),
|
|
4487
|
+
_ts_metadata17("design:paramtypes", [
|
|
4488
|
+
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
|
|
4489
|
+
typeof exports.IntegrationResourceManagementDao === "undefined" ? Object : exports.IntegrationResourceManagementDao
|
|
4490
|
+
])
|
|
4491
|
+
], exports.TrybeIntegrationResourceManagementService);
|
|
3742
4492
|
|
|
3743
4493
|
// ../../packages/dvss-integration-trybe/src/app.module.ts
|
|
3744
|
-
function
|
|
3745
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
3746
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
4494
|
+
function _ts_decorate21(decorators, target, key, desc2) {
|
|
4495
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4496
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3747
4497
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3748
4498
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3749
4499
|
}
|
|
3750
|
-
__name(
|
|
4500
|
+
__name(_ts_decorate21, "_ts_decorate");
|
|
3751
4501
|
exports.IntegrationTrybeModule = class AppModule2 {
|
|
3752
4502
|
static {
|
|
3753
4503
|
__name(this, "AppModule");
|
|
3754
4504
|
}
|
|
3755
4505
|
};
|
|
3756
|
-
exports.IntegrationTrybeModule =
|
|
4506
|
+
exports.IntegrationTrybeModule = _ts_decorate21([
|
|
3757
4507
|
common.Module({
|
|
3758
4508
|
imports: [
|
|
3759
4509
|
// Load environment variables from root .env file
|
|
@@ -3776,12 +4526,14 @@ exports.IntegrationTrybeModule = _ts_decorate18([
|
|
|
3776
4526
|
exports.TrybeCreditBooking,
|
|
3777
4527
|
exports.TrybeWellnessManagement,
|
|
3778
4528
|
exports.IntegrationConfigurationDao,
|
|
4529
|
+
exports.IntegrationResourceManagementDao,
|
|
3779
4530
|
exports.IntegrationRequestLoggerService,
|
|
3780
4531
|
exports.RateLimiterService,
|
|
3781
4532
|
exports.TrafficGatewayService,
|
|
3782
4533
|
exports.TrybeCustomerManagement,
|
|
3783
4534
|
exports.TrybeAuthService,
|
|
3784
4535
|
exports.TrybeIntegrationConfigurationService,
|
|
4536
|
+
exports.TrybeIntegrationResourceManagementService,
|
|
3785
4537
|
dvssBackendModuleDatastore.CommonValidationDatabaseService
|
|
3786
4538
|
],
|
|
3787
4539
|
exports: [
|
|
@@ -3789,25 +4541,26 @@ exports.IntegrationTrybeModule = _ts_decorate18([
|
|
|
3789
4541
|
exports.TrybeCustomerManagement,
|
|
3790
4542
|
exports.TrybeCreditBooking,
|
|
3791
4543
|
exports.TrybeWellnessManagement,
|
|
3792
|
-
exports.TrybeIntegrationConfigurationService
|
|
4544
|
+
exports.TrybeIntegrationConfigurationService,
|
|
4545
|
+
exports.TrybeIntegrationResourceManagementService
|
|
3793
4546
|
]
|
|
3794
4547
|
})
|
|
3795
4548
|
], exports.IntegrationTrybeModule);
|
|
3796
4549
|
|
|
3797
4550
|
// src/app.module.ts
|
|
3798
|
-
function
|
|
3799
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
3800
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
4551
|
+
function _ts_decorate22(decorators, target, key, desc2) {
|
|
4552
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4553
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3801
4554
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3802
4555
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3803
4556
|
}
|
|
3804
|
-
__name(
|
|
4557
|
+
__name(_ts_decorate22, "_ts_decorate");
|
|
3805
4558
|
exports.OfferingIntegrationManager = class AppModule3 {
|
|
3806
4559
|
static {
|
|
3807
4560
|
__name(this, "AppModule");
|
|
3808
4561
|
}
|
|
3809
4562
|
};
|
|
3810
|
-
exports.OfferingIntegrationManager =
|
|
4563
|
+
exports.OfferingIntegrationManager = _ts_decorate22([
|
|
3811
4564
|
common.Module({
|
|
3812
4565
|
imports: [
|
|
3813
4566
|
exports.IntegrationTrybeModule,
|
|
@@ -3840,7 +4593,7 @@ exports.BaseAccountingTaxManagement = BaseAccountingTaxManagement;
|
|
|
3840
4593
|
exports.BaseAuth = BaseAuth;
|
|
3841
4594
|
exports.BaseCreditBooking = BaseCreditBooking;
|
|
3842
4595
|
exports.BaseCustomerManagement = BaseCustomerManagement;
|
|
3843
|
-
exports.
|
|
4596
|
+
exports.BaseIntegrationResourceManagement = BaseIntegrationResourceManagement;
|
|
3844
4597
|
exports.BaseMembershipCustomerManagement = BaseMembershipCustomerManagement;
|
|
3845
4598
|
exports.BaseMembershipManagement = BaseMembershipManagement;
|
|
3846
4599
|
exports.BasePackageManagement = BasePackageManagement;
|
|
@@ -3853,9 +4606,12 @@ exports.CREDIT_STATUS_ENUM = CREDIT_STATUS_ENUM;
|
|
|
3853
4606
|
exports.CREDIT_TYPE_ENUM = CREDIT_TYPE_ENUM;
|
|
3854
4607
|
exports.HTTP_METHOD = HTTP_METHOD;
|
|
3855
4608
|
exports.INTEGRATION_PROVIDER_ENUM = INTEGRATION_PROVIDER_ENUM;
|
|
4609
|
+
exports.OFFERING_INTEGRATION_MAPPING_ALREADY_EXISTS = OFFERING_INTEGRATION_MAPPING_ALREADY_EXISTS;
|
|
3856
4610
|
exports.TRAFFIC_ROUTER_CONFIGURATION_STORE_KEY = TRAFFIC_ROUTER_CONFIGURATION_STORE_KEY;
|
|
4611
|
+
exports.TRYBE_CATALOGING_BY_ENUM = TRYBE_CATALOGING_BY_ENUM;
|
|
3857
4612
|
exports.TRYBE_OFFERING_TYPE_API = TRYBE_OFFERING_TYPE_API;
|
|
3858
4613
|
exports.TRYBE_OFFERING_TYPE_ENUM = TRYBE_OFFERING_TYPE_ENUM;
|
|
4614
|
+
exports.TRYBE_SUPPORTED_JOURNEYS_ENUM = TRYBE_SUPPORTED_JOURNEYS_ENUM;
|
|
3859
4615
|
exports.convertKeysToCamelCase = convertKeysToCamelCase;
|
|
3860
4616
|
exports.extractTimeFromIsoString = extractTimeFromIsoString;
|
|
3861
4617
|
exports.fetchAllPages = fetchAllPages;
|