@dv4resi/dvss-backend-module-offering-im 0.0.8 → 0.0.10
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 +253 -73
- package/dist/index.js +917 -162
- 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,200 @@ 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
|
|
848
893
|
};
|
|
849
894
|
return await this.integrationConfigurationDao.updateCapabilityIntegration({
|
|
850
|
-
id,
|
|
851
|
-
updateData:
|
|
852
|
-
},
|
|
895
|
+
id: request.id,
|
|
896
|
+
updateData: updateDataForDao
|
|
897
|
+
}, loggedInUserId);
|
|
898
|
+
}
|
|
899
|
+
/**
|
|
900
|
+
* Validates icon and nickname. Can be overridden in subclasses for provider-specific validation.
|
|
901
|
+
*/
|
|
902
|
+
validateIconAndNickName(updateData, loggedInUserId) {
|
|
903
|
+
if (updateData.nickname !== void 0 && (updateData.nickname === "" || updateData.nickname.trim() === "")) {
|
|
904
|
+
this.logger.error(loggedInUserId, this.validateIconAndNickName.name, this.fileName, "Validation failed: nickname cannot be empty or null");
|
|
905
|
+
throw new Error("Nickname cannot be empty");
|
|
906
|
+
}
|
|
907
|
+
if (updateData.icon && updateData.icon.meta && typeof updateData.icon.meta === "object") {
|
|
908
|
+
const meta = updateData.icon.meta;
|
|
909
|
+
if (meta.iconName !== void 0 && (meta.iconName === null || meta.iconName === "" || typeof meta.iconName === "string" && meta.iconName.trim() === "")) {
|
|
910
|
+
this.logger.error(loggedInUserId, this.validateIconAndNickName.name, this.fileName, "Validation failed: iconName cannot be empty");
|
|
911
|
+
throw new Error("Icon name cannot be empty");
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
/**
|
|
916
|
+
* Get capability integrations with pagination, filtering, sorting, and search.
|
|
917
|
+
* Delegates to DAO for database operations.
|
|
918
|
+
*
|
|
919
|
+
* @param request - Request with projectId, category, and options
|
|
920
|
+
* @param loggedInUserId - User ID for logging
|
|
921
|
+
* @returns Promise resolving to list of capability integrations with total count
|
|
922
|
+
*/
|
|
923
|
+
async getCapabilityIntegrations(request, loggedInUserId) {
|
|
924
|
+
return await this.integrationConfigurationDao.getCapabilityIntegrations(request, loggedInUserId);
|
|
925
|
+
}
|
|
926
|
+
/**
|
|
927
|
+
* Get capability integration by id or by fetchBy (configuredFor).
|
|
928
|
+
* Same business logic as project-ms CapabilityIntegrationService.getCapabilityIntegration.
|
|
929
|
+
*/
|
|
930
|
+
async getCapabilityIntegration(input, context) {
|
|
931
|
+
if (!input.projectId) {
|
|
932
|
+
throw new Error("Project ID is required");
|
|
933
|
+
}
|
|
934
|
+
await this.commonValidationDatabaseService.getProject({
|
|
935
|
+
projectId: input.projectId
|
|
936
|
+
});
|
|
937
|
+
let integration;
|
|
938
|
+
if (input.id) {
|
|
939
|
+
integration = await this.integrationConfigurationDao.getCapabilityIntegrationById({
|
|
940
|
+
id: input.id,
|
|
941
|
+
projectId: input.projectId,
|
|
942
|
+
category: input.category
|
|
943
|
+
}, context.loggedInUserId);
|
|
944
|
+
} else if (input.fetchBy) {
|
|
945
|
+
integration = await this.integrationConfigurationDao.getCapabilityIntegrationByProvider({
|
|
946
|
+
projectId: input.projectId,
|
|
947
|
+
category: input.fetchBy.category ?? input.category,
|
|
948
|
+
configuredForType: input.fetchBy.configuredForType,
|
|
949
|
+
configuredForId: BigInt(input.fetchBy.configuredForId)
|
|
950
|
+
}, context.loggedInUserId);
|
|
951
|
+
}
|
|
952
|
+
if (!integration) {
|
|
953
|
+
throw new Error("Capability integration not found");
|
|
954
|
+
}
|
|
955
|
+
return integration;
|
|
956
|
+
}
|
|
957
|
+
};
|
|
958
|
+
exports.BaseIntegrationConfiguration = _ts_decorate11([
|
|
959
|
+
common.Injectable(),
|
|
960
|
+
_ts_metadata8("design:type", Function),
|
|
961
|
+
_ts_metadata8("design:paramtypes", [
|
|
962
|
+
typeof IntegrationConfigurationDao === "undefined" ? Object : IntegrationConfigurationDao,
|
|
963
|
+
typeof CommonValidationDatabaseService === "undefined" ? Object : CommonValidationDatabaseService,
|
|
964
|
+
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
|
|
965
|
+
])
|
|
966
|
+
], exports.BaseIntegrationConfiguration);
|
|
967
|
+
var BaseIntegrationResourceManagement = class {
|
|
968
|
+
static {
|
|
969
|
+
__name(this, "BaseIntegrationResourceManagement");
|
|
970
|
+
}
|
|
971
|
+
integrationResourceManagementDao;
|
|
972
|
+
logger;
|
|
973
|
+
fileName = "integration-resource-management.base";
|
|
974
|
+
constructor(integrationResourceManagementDao, logger) {
|
|
975
|
+
this.integrationResourceManagementDao = integrationResourceManagementDao;
|
|
976
|
+
this.logger = logger;
|
|
977
|
+
}
|
|
978
|
+
/**
|
|
979
|
+
* Adds a resource (capability integration) to an offering integration via UIF.
|
|
980
|
+
* Inter-service implementation only: performs DAO insert. Wrapper must validate
|
|
981
|
+
* config and mapping-exists before calling; caller (MS) does getOffering, getIntegration,
|
|
982
|
+
* updateOffering and runAfterAddIfNeeded.
|
|
983
|
+
*
|
|
984
|
+
* @param input - projectId, offeringId, capabilityIntegrationId, optional config
|
|
985
|
+
* @param context - GraphQL context
|
|
986
|
+
* @returns Promise resolving to { status, ids }
|
|
987
|
+
*/
|
|
988
|
+
async addResourceToIntegration(input, context) {
|
|
989
|
+
this.logger.info(context.loggedInUserId, this.addResourceToIntegration.name, this.fileName, "addResourceToIntegration called", {
|
|
990
|
+
offeringId: input.offeringId.toString(),
|
|
991
|
+
capabilityIntegrationId: input.capabilityIntegrationId.toString()
|
|
992
|
+
});
|
|
993
|
+
const addResult = await this.integrationResourceManagementDao.addCapabilityIntegrationMapping({
|
|
994
|
+
projectId: input.projectId,
|
|
995
|
+
capabilityIntegrationId: input.capabilityIntegrationId,
|
|
996
|
+
configuredForId: input.offeringId,
|
|
997
|
+
configuredForType: models.CONFIGURED_FOR_TYPE_ENUM.OFFERING,
|
|
998
|
+
config: input.config
|
|
999
|
+
}, context);
|
|
1000
|
+
const result = {
|
|
1001
|
+
status: addResult.status,
|
|
1002
|
+
ids: addResult.ids
|
|
1003
|
+
};
|
|
1004
|
+
this.logger.info(context.loggedInUserId, this.addResourceToIntegration.name, this.fileName, "addResourceToIntegration completed", {
|
|
1005
|
+
status: result.status,
|
|
1006
|
+
idsCount: result.ids.length
|
|
1007
|
+
});
|
|
1008
|
+
return result;
|
|
1009
|
+
}
|
|
1010
|
+
/**
|
|
1011
|
+
* Removes a resource from an offering integration.
|
|
1012
|
+
* Generic validation and DAO call; Trybe service adds mapping-exists check before calling.
|
|
1013
|
+
*/
|
|
1014
|
+
async removeResourceFromIntegration(request, context) {
|
|
1015
|
+
const result = await this.integrationResourceManagementDao.removeCapabilityIntegrationMapping({
|
|
1016
|
+
capabilityIntegrationId: request.capabilityIntegrationId,
|
|
1017
|
+
configuredForId: request.offeringId,
|
|
1018
|
+
configuredForType: models.CONFIGURED_FOR_TYPE_ENUM.OFFERING
|
|
1019
|
+
}, context);
|
|
1020
|
+
return {
|
|
1021
|
+
status: result.status
|
|
1022
|
+
};
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Updates offering integration resource configuration (cap_integ_resource_mapping.config by id).
|
|
1026
|
+
* Inter-service implementation only: performs DAO update. Wrapper must validate config before calling
|
|
1027
|
+
* (e.g. Trybe validates via validateResourceMappingConfig). Caller (MS) does getOffering,
|
|
1028
|
+
* getIntegration, and runAfterUpdateIfNeeded (e.g. handleTrybeIntegration).
|
|
1029
|
+
*
|
|
1030
|
+
* @param input - id (resource mapping row id), config
|
|
1031
|
+
* @param context - GraphQL context
|
|
1032
|
+
* @returns Promise resolving to { status }
|
|
1033
|
+
*/
|
|
1034
|
+
async updateOfferingIntegrationResourceConfiguration(input, context) {
|
|
1035
|
+
this.logger.info(context.loggedInUserId, this.updateOfferingIntegrationResourceConfiguration.name, this.fileName, "updateOfferingIntegrationResourceConfiguration called", {
|
|
1036
|
+
id: input.id.toString()
|
|
1037
|
+
});
|
|
1038
|
+
const result = await this.integrationResourceManagementDao.updateCapabilityIntegrationConfiguration({
|
|
1039
|
+
id: input.id,
|
|
1040
|
+
config: input.config
|
|
1041
|
+
}, context);
|
|
1042
|
+
this.logger.info(context.loggedInUserId, this.updateOfferingIntegrationResourceConfiguration.name, this.fileName, "updateOfferingIntegrationResourceConfiguration completed", {
|
|
1043
|
+
status: result.status
|
|
1044
|
+
});
|
|
1045
|
+
return {
|
|
1046
|
+
status: result.status
|
|
1047
|
+
};
|
|
853
1048
|
}
|
|
854
1049
|
};
|
|
855
1050
|
|
|
@@ -1083,9 +1278,9 @@ var Table = class Table2 {
|
|
|
1083
1278
|
[IsDrizzleTable] = true;
|
|
1084
1279
|
/** @internal */
|
|
1085
1280
|
[ExtraConfigBuilder] = void 0;
|
|
1086
|
-
constructor(name,
|
|
1281
|
+
constructor(name, schema3, baseName) {
|
|
1087
1282
|
this[TableName] = this[OriginalName] = name;
|
|
1088
|
-
this[Schema] =
|
|
1283
|
+
this[Schema] = schema3;
|
|
1089
1284
|
this[BaseName] = baseName;
|
|
1090
1285
|
}
|
|
1091
1286
|
};
|
|
@@ -2061,11 +2256,11 @@ var View = class View2 {
|
|
|
2061
2256
|
static [entityKind] = "View";
|
|
2062
2257
|
/** @internal */
|
|
2063
2258
|
[ViewBaseConfig];
|
|
2064
|
-
constructor({ name: name2, schema:
|
|
2259
|
+
constructor({ name: name2, schema: schema3, selectedFields, query }) {
|
|
2065
2260
|
this[ViewBaseConfig] = {
|
|
2066
2261
|
name: name2,
|
|
2067
2262
|
originalName: name2,
|
|
2068
|
-
schema:
|
|
2263
|
+
schema: schema3,
|
|
2069
2264
|
selectedFields,
|
|
2070
2265
|
query,
|
|
2071
2266
|
isExisting: !query,
|
|
@@ -2120,30 +2315,65 @@ function and(...unfilteredConditions) {
|
|
|
2120
2315
|
]);
|
|
2121
2316
|
}
|
|
2122
2317
|
__name(and, "and");
|
|
2318
|
+
function or(...unfilteredConditions) {
|
|
2319
|
+
const conditions = unfilteredConditions.filter((c) => c !== void 0);
|
|
2320
|
+
if (conditions.length === 0) {
|
|
2321
|
+
return void 0;
|
|
2322
|
+
}
|
|
2323
|
+
if (conditions.length === 1) {
|
|
2324
|
+
return new SQL(conditions);
|
|
2325
|
+
}
|
|
2326
|
+
return new SQL([
|
|
2327
|
+
new StringChunk("("),
|
|
2328
|
+
sql.join(conditions, new StringChunk(" or ")),
|
|
2329
|
+
new StringChunk(")")
|
|
2330
|
+
]);
|
|
2331
|
+
}
|
|
2332
|
+
__name(or, "or");
|
|
2123
2333
|
function isNull(value) {
|
|
2124
2334
|
return sql`${value} is null`;
|
|
2125
2335
|
}
|
|
2126
2336
|
__name(isNull, "isNull");
|
|
2337
|
+
function isNotNull(value) {
|
|
2338
|
+
return sql`${value} is not null`;
|
|
2339
|
+
}
|
|
2340
|
+
__name(isNotNull, "isNotNull");
|
|
2341
|
+
|
|
2342
|
+
// ../../node_modules/drizzle-orm/sql/expressions/select.js
|
|
2343
|
+
function asc(column) {
|
|
2344
|
+
return sql`${column} asc`;
|
|
2345
|
+
}
|
|
2346
|
+
__name(asc, "asc");
|
|
2347
|
+
function desc(column) {
|
|
2348
|
+
return sql`${column} desc`;
|
|
2349
|
+
}
|
|
2350
|
+
__name(desc, "desc");
|
|
2351
|
+
|
|
2352
|
+
// ../../node_modules/drizzle-orm/utils.js
|
|
2353
|
+
function getTableColumns(table) {
|
|
2354
|
+
return table[Table.Symbol.Columns];
|
|
2355
|
+
}
|
|
2356
|
+
__name(getTableColumns, "getTableColumns");
|
|
2127
2357
|
|
|
2128
2358
|
// ../../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,
|
|
2359
|
+
function _ts_decorate12(decorators, target, key, desc2) {
|
|
2360
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
2361
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2132
2362
|
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
2363
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2134
2364
|
}
|
|
2135
|
-
__name(
|
|
2136
|
-
function
|
|
2365
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
2366
|
+
function _ts_metadata9(k, v) {
|
|
2137
2367
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2138
2368
|
}
|
|
2139
|
-
__name(
|
|
2369
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
2140
2370
|
function _ts_param(paramIndex, decorator) {
|
|
2141
2371
|
return function(target, key) {
|
|
2142
2372
|
decorator(target, key, paramIndex);
|
|
2143
2373
|
};
|
|
2144
2374
|
}
|
|
2145
2375
|
__name(_ts_param, "_ts_param");
|
|
2146
|
-
exports.IntegrationConfigurationDao = class
|
|
2376
|
+
exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
|
|
2147
2377
|
static {
|
|
2148
2378
|
__name(this, "IntegrationConfigurationDao");
|
|
2149
2379
|
}
|
|
@@ -2259,27 +2489,219 @@ exports.IntegrationConfigurationDao = class IntegrationConfigurationDao {
|
|
|
2259
2489
|
throw error;
|
|
2260
2490
|
}
|
|
2261
2491
|
}
|
|
2492
|
+
/**
|
|
2493
|
+
* Retrieves capability integration by ID with resource mapping details.
|
|
2494
|
+
* Copied from project-ms CapabilityIntegrationDao.getCapabilityIntegrationById.
|
|
2495
|
+
*/
|
|
2496
|
+
async getCapabilityIntegrationById(request, loggedInUserId) {
|
|
2497
|
+
try {
|
|
2498
|
+
this.logger.info(loggedInUserId, this.getCapabilityIntegrationById.name, this.fileName, "getCapabilityIntegrationById called", request);
|
|
2499
|
+
const conditions = [
|
|
2500
|
+
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.id, request.id),
|
|
2501
|
+
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.projectId, request.projectId),
|
|
2502
|
+
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.type, capability_model.CAPABILITY_TYPE_ENUM.INTEGRATION),
|
|
2503
|
+
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.status, capabilityIntegration_model.CAPABILITY_INTEGRATION_STATUS_ENUM.ACTIVE),
|
|
2504
|
+
isNull(dvssBackendModuleDatastore.schema.capabilityIntegration.deletedAt),
|
|
2505
|
+
isNull(dvssBackendModuleDatastore.schema.capability.deletedAt)
|
|
2506
|
+
];
|
|
2507
|
+
if (request.category) {
|
|
2508
|
+
conditions.push(eq(dvssBackendModuleDatastore.schema.capabilityIntegration.category, request.category));
|
|
2509
|
+
}
|
|
2510
|
+
const response = await this.conn.select({
|
|
2511
|
+
...getTableColumns(dvssBackendModuleDatastore.schema.capabilityIntegration),
|
|
2512
|
+
resourceMappingId: dvssBackendModuleDatastore.schema.capIntegResourceMapping.id,
|
|
2513
|
+
configuredForId: dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId,
|
|
2514
|
+
configuredForType: dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType,
|
|
2515
|
+
resourceMappingConfig: dvssBackendModuleDatastore.schema.capIntegResourceMapping.config,
|
|
2516
|
+
provider: dvssBackendModuleDatastore.schema.capability.providerIntegrationType
|
|
2517
|
+
}).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));
|
|
2518
|
+
return response[0];
|
|
2519
|
+
} catch (error) {
|
|
2520
|
+
this.logger.error(loggedInUserId, this.getCapabilityIntegrationById.name, this.fileName, "Error on getCapabilityIntegrationById", error, request);
|
|
2521
|
+
throw error;
|
|
2522
|
+
}
|
|
2523
|
+
}
|
|
2524
|
+
/**
|
|
2525
|
+
* Retrieves capability integration by provider type and resource mapping.
|
|
2526
|
+
* Copied from project-ms CapabilityIntegrationDao.getCapabilityIntegrationByProvider.
|
|
2527
|
+
*/
|
|
2528
|
+
async getCapabilityIntegrationByProvider(request, loggedInUserId) {
|
|
2529
|
+
try {
|
|
2530
|
+
this.logger.info(loggedInUserId, this.getCapabilityIntegrationByProvider.name, this.fileName, "getCapabilityIntegrationByProvider called", request);
|
|
2531
|
+
const conditions = [
|
|
2532
|
+
isNull(dvssBackendModuleDatastore.schema.capability.deletedAt),
|
|
2533
|
+
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.projectId, request.projectId),
|
|
2534
|
+
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.type, capability_model.CAPABILITY_TYPE_ENUM.INTEGRATION),
|
|
2535
|
+
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.status, capabilityIntegration_model.CAPABILITY_INTEGRATION_STATUS_ENUM.ACTIVE),
|
|
2536
|
+
isNull(dvssBackendModuleDatastore.schema.capabilityIntegration.deletedAt),
|
|
2537
|
+
eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.projectId, request.projectId),
|
|
2538
|
+
eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType, request.configuredForType),
|
|
2539
|
+
eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId, request.configuredForId),
|
|
2540
|
+
isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt)
|
|
2541
|
+
];
|
|
2542
|
+
if (request.category) {
|
|
2543
|
+
conditions.push(eq(dvssBackendModuleDatastore.schema.capabilityIntegration.category, request.category));
|
|
2544
|
+
}
|
|
2545
|
+
const response = await this.conn.select({
|
|
2546
|
+
...getTableColumns(dvssBackendModuleDatastore.schema.capabilityIntegration),
|
|
2547
|
+
resourceMappingId: dvssBackendModuleDatastore.schema.capIntegResourceMapping.id,
|
|
2548
|
+
configuredForId: dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId,
|
|
2549
|
+
configuredForType: dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType,
|
|
2550
|
+
resourceMappingConfig: dvssBackendModuleDatastore.schema.capIntegResourceMapping.config,
|
|
2551
|
+
provider: dvssBackendModuleDatastore.schema.capability.providerIntegrationType
|
|
2552
|
+
}).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));
|
|
2553
|
+
return response[0];
|
|
2554
|
+
} catch (error) {
|
|
2555
|
+
this.logger.error(loggedInUserId, this.getCapabilityIntegrationByProvider.name, this.fileName, "Error on getCapabilityIntegrationByProvider", error, request);
|
|
2556
|
+
throw error;
|
|
2557
|
+
}
|
|
2558
|
+
}
|
|
2559
|
+
/**
|
|
2560
|
+
* Get capability integrations with pagination, filtering, sorting, and search.
|
|
2561
|
+
* Copied from project-ms CapabilityIntegrationDao.getCapabilityIntegrations.
|
|
2562
|
+
*/
|
|
2563
|
+
async getCapabilityIntegrations(input, loggedInUserId) {
|
|
2564
|
+
try {
|
|
2565
|
+
this.logger.info(loggedInUserId, this.getCapabilityIntegrations.name, this.fileName, "getCapabilityIntegrations called", input);
|
|
2566
|
+
const count = input.options?.count ?? dvssBackendModuleDatastore.MAX_RECORDS_LENGTH;
|
|
2567
|
+
const offset = ((input.options?.page ?? 1) - 1) * count;
|
|
2568
|
+
const sorting = input.options?.sorting;
|
|
2569
|
+
let sortBy = dvssBackendModuleDatastore.schema.capabilityIntegration.id;
|
|
2570
|
+
if (sorting?.by === "CREATED_AT") {
|
|
2571
|
+
sortBy = dvssBackendModuleDatastore.schema.capabilityIntegration.createdAt;
|
|
2572
|
+
} else if (sorting?.by === "UPDATED_AT") {
|
|
2573
|
+
sortBy = dvssBackendModuleDatastore.schema.capabilityIntegration.updatedAt;
|
|
2574
|
+
}
|
|
2575
|
+
const sortOrder = sorting?.order === common_enum.SORTING_ORDER_ENUM.ASC ? asc(sortBy) : desc(sortBy);
|
|
2576
|
+
const searchTerm = input.options?.search;
|
|
2577
|
+
const shouldJoinCapability = Boolean(searchTerm) || Boolean(input.options?.filters?.some((filter) => filter.by === "PROVIDER_INTEGRATION_TYPE"));
|
|
2578
|
+
const whereConditions = [
|
|
2579
|
+
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.projectId, input.projectId),
|
|
2580
|
+
isNull(dvssBackendModuleDatastore.schema.capabilityIntegration.deletedAt)
|
|
2581
|
+
];
|
|
2582
|
+
if (input.category) {
|
|
2583
|
+
whereConditions.push(eq(dvssBackendModuleDatastore.schema.capabilityIntegration.category, input.category));
|
|
2584
|
+
}
|
|
2585
|
+
if (input.options?.filters && input.options.filters.length > 0) {
|
|
2586
|
+
this.applyFilters(whereConditions, input.options);
|
|
2587
|
+
}
|
|
2588
|
+
if (searchTerm) {
|
|
2589
|
+
const searchPattern = `%${searchTerm}%`;
|
|
2590
|
+
whereConditions.push(sql`(${dvssBackendModuleDatastore.schema.capabilityIntegration.nickname} LIKE ${searchPattern} OR ${dvssBackendModuleDatastore.schema.capability.name} LIKE ${searchPattern})`);
|
|
2591
|
+
}
|
|
2592
|
+
if (shouldJoinCapability) {
|
|
2593
|
+
whereConditions.push(isNull(dvssBackendModuleDatastore.schema.capability.deletedAt));
|
|
2594
|
+
}
|
|
2595
|
+
if (input.propertyId) {
|
|
2596
|
+
whereConditions.push(isNotNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.id));
|
|
2597
|
+
}
|
|
2598
|
+
const countWhereConditions = [
|
|
2599
|
+
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.projectId, input.projectId),
|
|
2600
|
+
isNull(dvssBackendModuleDatastore.schema.capabilityIntegration.deletedAt)
|
|
2601
|
+
];
|
|
2602
|
+
if (input.category) {
|
|
2603
|
+
countWhereConditions.push(eq(dvssBackendModuleDatastore.schema.capabilityIntegration.category, input.category));
|
|
2604
|
+
}
|
|
2605
|
+
if (input.options?.filters && input.options.filters.length > 0) {
|
|
2606
|
+
this.applyFilters(countWhereConditions, input.options);
|
|
2607
|
+
}
|
|
2608
|
+
if (searchTerm) {
|
|
2609
|
+
const searchPattern = `%${searchTerm}%`;
|
|
2610
|
+
countWhereConditions.push(sql`(${dvssBackendModuleDatastore.schema.capabilityIntegration.nickname} LIKE ${searchPattern} OR ${dvssBackendModuleDatastore.schema.capability.name} LIKE ${searchPattern})`);
|
|
2611
|
+
}
|
|
2612
|
+
const countQueryBuilder = this.conn.select({
|
|
2613
|
+
count: sql`count(distinct ${dvssBackendModuleDatastore.schema.capabilityIntegration.id})`.as("count")
|
|
2614
|
+
}).from(dvssBackendModuleDatastore.schema.capabilityIntegration);
|
|
2615
|
+
const countQueryWithJoins = shouldJoinCapability ? countQueryBuilder.leftJoin(dvssBackendModuleDatastore.schema.capability, eq(dvssBackendModuleDatastore.schema.capability.id, dvssBackendModuleDatastore.schema.capabilityIntegration.capabilityId)) : countQueryBuilder;
|
|
2616
|
+
if (shouldJoinCapability) {
|
|
2617
|
+
countWhereConditions.push(isNull(dvssBackendModuleDatastore.schema.capability.deletedAt));
|
|
2618
|
+
}
|
|
2619
|
+
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;
|
|
2620
|
+
if (input.propertyId) {
|
|
2621
|
+
countWhereConditions.push(isNotNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.id));
|
|
2622
|
+
}
|
|
2623
|
+
const countQuery = countQueryWithPropertyJoin.where(and(...countWhereConditions));
|
|
2624
|
+
const baseQuery = this.conn.select({
|
|
2625
|
+
...getTableColumns(dvssBackendModuleDatastore.schema.capabilityIntegration),
|
|
2626
|
+
provider: dvssBackendModuleDatastore.schema.capability.providerIntegrationType
|
|
2627
|
+
}).from(dvssBackendModuleDatastore.schema.capabilityIntegration).leftJoin(dvssBackendModuleDatastore.schema.capability, eq(dvssBackendModuleDatastore.schema.capability.id, dvssBackendModuleDatastore.schema.capabilityIntegration.capabilityId));
|
|
2628
|
+
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));
|
|
2629
|
+
const [{ count: totalCount }, records] = await Promise.all([
|
|
2630
|
+
countQuery.execute().then((result) => result[0]),
|
|
2631
|
+
finalQuery.limit(count).offset(offset).orderBy(sortOrder).execute()
|
|
2632
|
+
]);
|
|
2633
|
+
return {
|
|
2634
|
+
totalCount: Number(totalCount) || 0,
|
|
2635
|
+
records
|
|
2636
|
+
};
|
|
2637
|
+
} catch (error) {
|
|
2638
|
+
this.logger.error(loggedInUserId, this.getCapabilityIntegrations.name, this.fileName, "Error in getCapabilityIntegrations", error, input);
|
|
2639
|
+
throw error;
|
|
2640
|
+
}
|
|
2641
|
+
}
|
|
2642
|
+
/**
|
|
2643
|
+
* Applies filters to where conditions.
|
|
2644
|
+
*/
|
|
2645
|
+
applyFilters(whereConditions, filters) {
|
|
2646
|
+
if (!filters || !filters.filters) {
|
|
2647
|
+
return;
|
|
2648
|
+
}
|
|
2649
|
+
for (const filter of filters.filters) {
|
|
2650
|
+
const filterValues = filter.values;
|
|
2651
|
+
if (!filterValues || filterValues.length === 0) {
|
|
2652
|
+
continue;
|
|
2653
|
+
}
|
|
2654
|
+
switch (filter.by) {
|
|
2655
|
+
case "PROVIDER_INTEGRATION_TYPE": {
|
|
2656
|
+
const valuePlaceholders = filterValues.map((value) => sql`${String(value)}`);
|
|
2657
|
+
const joinedValues = sql.join(valuePlaceholders, sql`, `);
|
|
2658
|
+
whereConditions.push(sql`${dvssBackendModuleDatastore.schema.capability.providerIntegrationType} IN (${joinedValues})`);
|
|
2659
|
+
break;
|
|
2660
|
+
}
|
|
2661
|
+
case "CAPABILITY_INTEGRATION_TYPE": {
|
|
2662
|
+
const parentConditions = [];
|
|
2663
|
+
for (const value of filterValues) {
|
|
2664
|
+
const upperValue = String(value).toUpperCase();
|
|
2665
|
+
if (upperValue === "PARENT") {
|
|
2666
|
+
parentConditions.push(isNull(dvssBackendModuleDatastore.schema.capabilityIntegration.parentId));
|
|
2667
|
+
} else if (upperValue === "CHILD") {
|
|
2668
|
+
parentConditions.push(isNotNull(dvssBackendModuleDatastore.schema.capabilityIntegration.parentId));
|
|
2669
|
+
}
|
|
2670
|
+
}
|
|
2671
|
+
if (parentConditions.length === 1) {
|
|
2672
|
+
whereConditions.push(parentConditions[0]);
|
|
2673
|
+
} else if (parentConditions.length > 1) {
|
|
2674
|
+
const orCondition = or(...parentConditions);
|
|
2675
|
+
if (orCondition) {
|
|
2676
|
+
whereConditions.push(orCondition);
|
|
2677
|
+
}
|
|
2678
|
+
}
|
|
2679
|
+
break;
|
|
2680
|
+
}
|
|
2681
|
+
}
|
|
2682
|
+
}
|
|
2683
|
+
}
|
|
2262
2684
|
};
|
|
2263
|
-
exports.IntegrationConfigurationDao =
|
|
2685
|
+
exports.IntegrationConfigurationDao = _ts_decorate12([
|
|
2264
2686
|
common.Injectable(),
|
|
2265
2687
|
_ts_param(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
|
|
2266
|
-
|
|
2267
|
-
|
|
2688
|
+
_ts_metadata9("design:type", Function),
|
|
2689
|
+
_ts_metadata9("design:paramtypes", [
|
|
2268
2690
|
typeof MySql2Database === "undefined" ? Object : MySql2Database,
|
|
2269
2691
|
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
|
|
2270
2692
|
])
|
|
2271
2693
|
], 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,
|
|
2694
|
+
function _ts_decorate13(decorators, target, key, desc2) {
|
|
2695
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
2696
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2275
2697
|
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
2698
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2277
2699
|
}
|
|
2278
|
-
__name(
|
|
2279
|
-
function
|
|
2700
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
2701
|
+
function _ts_metadata10(k, v) {
|
|
2280
2702
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2281
2703
|
}
|
|
2282
|
-
__name(
|
|
2704
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
2283
2705
|
function _ts_param2(paramIndex, decorator) {
|
|
2284
2706
|
return function(target, key) {
|
|
2285
2707
|
decorator(target, key, paramIndex);
|
|
@@ -2295,25 +2717,212 @@ exports.IntegrationUserManagementDao = class IntegrationUserManagementDao {
|
|
|
2295
2717
|
this.conn = conn;
|
|
2296
2718
|
}
|
|
2297
2719
|
};
|
|
2298
|
-
exports.IntegrationUserManagementDao =
|
|
2720
|
+
exports.IntegrationUserManagementDao = _ts_decorate13([
|
|
2299
2721
|
common.Injectable(),
|
|
2300
2722
|
_ts_param2(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
|
|
2301
|
-
|
|
2302
|
-
|
|
2723
|
+
_ts_metadata10("design:type", Function),
|
|
2724
|
+
_ts_metadata10("design:paramtypes", [
|
|
2303
2725
|
typeof MySql2Database === "undefined" ? Object : MySql2Database
|
|
2304
2726
|
])
|
|
2305
2727
|
], 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,
|
|
2728
|
+
function _ts_decorate14(decorators, target, key, desc2) {
|
|
2729
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
2730
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2309
2731
|
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
2732
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2311
2733
|
}
|
|
2312
|
-
__name(
|
|
2313
|
-
function
|
|
2734
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
2735
|
+
function _ts_metadata11(k, v) {
|
|
2314
2736
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2315
2737
|
}
|
|
2316
|
-
__name(
|
|
2738
|
+
__name(_ts_metadata11, "_ts_metadata");
|
|
2739
|
+
function _ts_param3(paramIndex, decorator) {
|
|
2740
|
+
return function(target, key) {
|
|
2741
|
+
decorator(target, key, paramIndex);
|
|
2742
|
+
};
|
|
2743
|
+
}
|
|
2744
|
+
__name(_ts_param3, "_ts_param");
|
|
2745
|
+
exports.IntegrationResourceManagementDao = class IntegrationResourceManagementDao {
|
|
2746
|
+
static {
|
|
2747
|
+
__name(this, "IntegrationResourceManagementDao");
|
|
2748
|
+
}
|
|
2749
|
+
conn;
|
|
2750
|
+
logger;
|
|
2751
|
+
fileName = "integration-resource-management.dao";
|
|
2752
|
+
constructor(conn, logger) {
|
|
2753
|
+
this.conn = conn;
|
|
2754
|
+
this.logger = logger;
|
|
2755
|
+
}
|
|
2756
|
+
/**
|
|
2757
|
+
* Adds a capability integration resource mapping (insert into cap_integ_resource_mapping).
|
|
2758
|
+
* Replaces inter-service gRPC call to project-onboarding-ms for add configurations.
|
|
2759
|
+
*
|
|
2760
|
+
* @param input - projectId, capabilityIntegrationId, configuredForId, configuredForType, optional config
|
|
2761
|
+
* @param context - GraphQL context for loggedInUserId
|
|
2762
|
+
* @returns Promise resolving to { status: true, ids: [insertedId] } or { status: false, ids: [] }
|
|
2763
|
+
*/
|
|
2764
|
+
async addCapabilityIntegrationMapping(input, context) {
|
|
2765
|
+
try {
|
|
2766
|
+
this.logger.info(context.loggedInUserId, this.addCapabilityIntegrationMapping.name, this.fileName, "Adding capability integration mapping", input);
|
|
2767
|
+
const insertResult = await this.conn.insert(dvssBackendModuleDatastore.schema.capIntegResourceMapping).values({
|
|
2768
|
+
projectId: input.projectId,
|
|
2769
|
+
status: capabilityIntegration_model.CAPABILITY_INTEGRATION_STATUS_ENUM.ACTIVE,
|
|
2770
|
+
capabilityIntegrationId: input.capabilityIntegrationId,
|
|
2771
|
+
configuredForId: input.configuredForId,
|
|
2772
|
+
configuredForType: input.configuredForType,
|
|
2773
|
+
config: input.config ?? null,
|
|
2774
|
+
createdBy: context.loggedInUserId
|
|
2775
|
+
});
|
|
2776
|
+
const raw = insertResult;
|
|
2777
|
+
const insertedId = raw[0]?.insertId != null ? Number(raw[0].insertId) : 0;
|
|
2778
|
+
const isInserted = insertedId > 0;
|
|
2779
|
+
const ids = isInserted ? [
|
|
2780
|
+
BigInt(insertedId)
|
|
2781
|
+
] : [];
|
|
2782
|
+
this.logger.info(context.loggedInUserId, this.addCapabilityIntegrationMapping.name, this.fileName, `Mapping add ${isInserted ? "successful" : "failed"}`, {
|
|
2783
|
+
insertedId,
|
|
2784
|
+
status: isInserted
|
|
2785
|
+
});
|
|
2786
|
+
return {
|
|
2787
|
+
status: isInserted,
|
|
2788
|
+
ids
|
|
2789
|
+
};
|
|
2790
|
+
} catch (error) {
|
|
2791
|
+
this.logger.error(context.loggedInUserId, this.addCapabilityIntegrationMapping.name, this.fileName, "Error adding capability integration mapping", error, input);
|
|
2792
|
+
throw error;
|
|
2793
|
+
}
|
|
2794
|
+
}
|
|
2795
|
+
/**
|
|
2796
|
+
* Checks if a capability integration resource mapping exists.
|
|
2797
|
+
* Validates that the mapping exists for the given capability integration, configured for ID and type.
|
|
2798
|
+
*
|
|
2799
|
+
* @param input - Input containing capability integration ID, configured for ID and type
|
|
2800
|
+
* @param loggedInUserId - ID of the user performing the operation
|
|
2801
|
+
* @returns Promise that resolves to true if mapping exists, false otherwise
|
|
2802
|
+
*/
|
|
2803
|
+
async checkMappingExists(input, loggedInUserId) {
|
|
2804
|
+
try {
|
|
2805
|
+
this.logger.info(loggedInUserId, this.checkMappingExists.name, this.fileName, `${this.checkMappingExists.name} called`, input);
|
|
2806
|
+
const response = await this.conn.select({
|
|
2807
|
+
id: dvssBackendModuleDatastore.schema.capIntegResourceMapping.id
|
|
2808
|
+
}).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);
|
|
2809
|
+
return response.length > 0;
|
|
2810
|
+
} catch (error) {
|
|
2811
|
+
this.logger.error(loggedInUserId, this.checkMappingExists.name, this.fileName, "Error in checkMappingExists", error, input);
|
|
2812
|
+
throw error;
|
|
2813
|
+
}
|
|
2814
|
+
}
|
|
2815
|
+
/**
|
|
2816
|
+
* Removes capability integration resource mapping (soft delete).
|
|
2817
|
+
* Sets deletedAt and deletedBy on the matching cap_integ_resource_mapping row.
|
|
2818
|
+
* Use this from UIF/callers instead of inter-service call to project-onboarding-ms.
|
|
2819
|
+
*
|
|
2820
|
+
* @param input - Delete parameters including capability integration ID, configured for ID and type
|
|
2821
|
+
* @param loggedInUserId - ID of the user performing the operation
|
|
2822
|
+
* @returns Promise resolving to { status: true } if any row was updated, { status: false } otherwise
|
|
2823
|
+
*/
|
|
2824
|
+
async removeCapabilityIntegrationMapping(input, context) {
|
|
2825
|
+
try {
|
|
2826
|
+
this.logger.info(context.loggedInUserId, this.removeCapabilityIntegrationMapping.name, this.fileName, "Removing capability integration mapping", input);
|
|
2827
|
+
const whereConditions = [
|
|
2828
|
+
isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt),
|
|
2829
|
+
eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.capabilityIntegrationId, input.capabilityIntegrationId),
|
|
2830
|
+
eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId, input.configuredForId),
|
|
2831
|
+
eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType, input.configuredForType)
|
|
2832
|
+
];
|
|
2833
|
+
const deleteResult = await this.conn.update(dvssBackendModuleDatastore.schema.capIntegResourceMapping).set({
|
|
2834
|
+
deletedAt: /* @__PURE__ */ new Date(),
|
|
2835
|
+
deletedBy: context.loggedInUserId
|
|
2836
|
+
}).where(and(...whereConditions));
|
|
2837
|
+
const isSuccess = deleteResult[0].affectedRows > 0;
|
|
2838
|
+
this.logger.info(context.loggedInUserId, this.removeCapabilityIntegrationMapping.name, this.fileName, `Mapping removal ${isSuccess ? "successful" : "failed - no matching records"}`, {
|
|
2839
|
+
affectedRows: deleteResult[0].affectedRows
|
|
2840
|
+
});
|
|
2841
|
+
return {
|
|
2842
|
+
status: isSuccess
|
|
2843
|
+
};
|
|
2844
|
+
} catch (error) {
|
|
2845
|
+
this.logger.error(context.loggedInUserId, this.removeCapabilityIntegrationMapping.name, this.fileName, "Error removing capability integration mapping", error, input);
|
|
2846
|
+
throw error;
|
|
2847
|
+
}
|
|
2848
|
+
}
|
|
2849
|
+
/**
|
|
2850
|
+
* Gets a capability integration resource mapping by id (non-deleted only).
|
|
2851
|
+
* Use from UIF wrappers to validate mapping exists before update.
|
|
2852
|
+
*
|
|
2853
|
+
* @param id - cap_integ_resource_mapping.id
|
|
2854
|
+
* @param loggedInUserId - for logging
|
|
2855
|
+
* @returns The mapping row or undefined if not found
|
|
2856
|
+
*/
|
|
2857
|
+
async getCapabilityIntegrationResourceMappingById(id, loggedInUserId) {
|
|
2858
|
+
try {
|
|
2859
|
+
this.logger.info(loggedInUserId, this.getCapabilityIntegrationResourceMappingById.name, this.fileName, `${this.getCapabilityIntegrationResourceMappingById.name} called`, {
|
|
2860
|
+
id: id.toString()
|
|
2861
|
+
});
|
|
2862
|
+
const rows = await this.conn.select({
|
|
2863
|
+
id: dvssBackendModuleDatastore.schema.capIntegResourceMapping.id,
|
|
2864
|
+
capabilityIntegrationId: dvssBackendModuleDatastore.schema.capIntegResourceMapping.capabilityIntegrationId,
|
|
2865
|
+
configuredForId: dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId,
|
|
2866
|
+
configuredForType: dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType
|
|
2867
|
+
}).from(dvssBackendModuleDatastore.schema.capIntegResourceMapping).where(and(eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.id, id), isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt))).limit(1);
|
|
2868
|
+
return rows[0];
|
|
2869
|
+
} catch (error) {
|
|
2870
|
+
this.logger.error(loggedInUserId, this.getCapabilityIntegrationResourceMappingById.name, this.fileName, "Error in getCapabilityIntegrationResourceMappingById", error, {
|
|
2871
|
+
id: id.toString()
|
|
2872
|
+
});
|
|
2873
|
+
throw error;
|
|
2874
|
+
}
|
|
2875
|
+
}
|
|
2876
|
+
/**
|
|
2877
|
+
* Updates capability integration resource mapping config by id.
|
|
2878
|
+
* Replaces inter-service gRPC call to project-onboarding-ms for update capability integration configuration.
|
|
2879
|
+
*
|
|
2880
|
+
* @param input - id (mapping row id), config (new config JSON)
|
|
2881
|
+
* @param context - GraphQL context for loggedInUserId
|
|
2882
|
+
* @returns Promise resolving to { status: true } if row was updated, { status: false } otherwise
|
|
2883
|
+
*/
|
|
2884
|
+
async updateCapabilityIntegrationConfiguration(input, context) {
|
|
2885
|
+
try {
|
|
2886
|
+
this.logger.info(context.loggedInUserId, this.updateCapabilityIntegrationConfiguration.name, this.fileName, "Updating capability integration resource mapping config", {
|
|
2887
|
+
id: input.id.toString()
|
|
2888
|
+
});
|
|
2889
|
+
const updateResult = await this.conn.update(dvssBackendModuleDatastore.schema.capIntegResourceMapping).set({
|
|
2890
|
+
config: input.config,
|
|
2891
|
+
updatedBy: context.loggedInUserId
|
|
2892
|
+
}).where(and(eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.id, input.id), isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt)));
|
|
2893
|
+
const isSuccess = updateResult[0].affectedRows > 0;
|
|
2894
|
+
this.logger.info(context.loggedInUserId, this.updateCapabilityIntegrationConfiguration.name, this.fileName, `Mapping config update ${isSuccess ? "successful" : "failed - no matching records"}`, {
|
|
2895
|
+
affectedRows: updateResult[0].affectedRows
|
|
2896
|
+
});
|
|
2897
|
+
return {
|
|
2898
|
+
status: isSuccess
|
|
2899
|
+
};
|
|
2900
|
+
} catch (error) {
|
|
2901
|
+
this.logger.error(context.loggedInUserId, this.updateCapabilityIntegrationConfiguration.name, this.fileName, "Error updating capability integration resource mapping config", error, input);
|
|
2902
|
+
throw error;
|
|
2903
|
+
}
|
|
2904
|
+
}
|
|
2905
|
+
};
|
|
2906
|
+
exports.IntegrationResourceManagementDao = _ts_decorate14([
|
|
2907
|
+
common.Injectable(),
|
|
2908
|
+
_ts_param3(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
|
|
2909
|
+
_ts_metadata11("design:type", Function),
|
|
2910
|
+
_ts_metadata11("design:paramtypes", [
|
|
2911
|
+
typeof MySql2Database === "undefined" ? Object : MySql2Database,
|
|
2912
|
+
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
|
|
2913
|
+
])
|
|
2914
|
+
], exports.IntegrationResourceManagementDao);
|
|
2915
|
+
function _ts_decorate15(decorators, target, key, desc2) {
|
|
2916
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
2917
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2918
|
+
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;
|
|
2919
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2920
|
+
}
|
|
2921
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
2922
|
+
function _ts_metadata12(k, v) {
|
|
2923
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2924
|
+
}
|
|
2925
|
+
__name(_ts_metadata12, "_ts_metadata");
|
|
2317
2926
|
exports.TrybeCustomerManagement = class _TrybeCustomerManagement {
|
|
2318
2927
|
static {
|
|
2319
2928
|
__name(this, "TrybeCustomerManagement");
|
|
@@ -2403,26 +3012,61 @@ exports.TrybeCustomerManagement = class _TrybeCustomerManagement {
|
|
|
2403
3012
|
}, integration, loggedInUserId);
|
|
2404
3013
|
return response.data;
|
|
2405
3014
|
}
|
|
3015
|
+
/**
|
|
3016
|
+
* Delete a customer on Trybe.
|
|
3017
|
+
*/
|
|
3018
|
+
async deleteCustomer(customerId, integration, loggedInUserId) {
|
|
3019
|
+
try {
|
|
3020
|
+
this.logger.info(loggedInUserId, this.deleteCustomer.name, this.fileName, `${_TrybeCustomerManagement.name} -> ${this.deleteCustomer.name} Called`, {
|
|
3021
|
+
customerId
|
|
3022
|
+
});
|
|
3023
|
+
await this.trafficGatewayService.executeIntegrationRequest({
|
|
3024
|
+
apiMethod: HTTP_METHOD.DELETE,
|
|
3025
|
+
url: `/customers/customers/${customerId}`,
|
|
3026
|
+
baseUrl: integration.config.platformConfig.baseUrl,
|
|
3027
|
+
headers: integration.headers
|
|
3028
|
+
}, integration, loggedInUserId);
|
|
3029
|
+
return {
|
|
3030
|
+
status: true
|
|
3031
|
+
};
|
|
3032
|
+
} catch (error) {
|
|
3033
|
+
this.logger.error(loggedInUserId, this.deleteCustomer.name, this.fileName, "Error in deleting customer on Trybe", error);
|
|
3034
|
+
throw error;
|
|
3035
|
+
}
|
|
3036
|
+
}
|
|
2406
3037
|
};
|
|
2407
|
-
exports.TrybeCustomerManagement =
|
|
3038
|
+
exports.TrybeCustomerManagement = _ts_decorate15([
|
|
2408
3039
|
common.Injectable(),
|
|
2409
|
-
|
|
2410
|
-
|
|
3040
|
+
_ts_metadata12("design:type", Function),
|
|
3041
|
+
_ts_metadata12("design:paramtypes", [
|
|
2411
3042
|
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
|
|
2412
3043
|
typeof exports.TrafficGatewayService === "undefined" ? Object : exports.TrafficGatewayService
|
|
2413
3044
|
])
|
|
2414
3045
|
], exports.TrybeCustomerManagement);
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
3046
|
+
|
|
3047
|
+
// ../../packages/dvss-integration-trybe/src/utils/url.utils.ts
|
|
3048
|
+
function isValidHttpUrl(urlString) {
|
|
3049
|
+
try {
|
|
3050
|
+
const url = new URL(urlString);
|
|
3051
|
+
return url.protocol === "http:" || url.protocol === "https:";
|
|
3052
|
+
} catch {
|
|
3053
|
+
return false;
|
|
3054
|
+
}
|
|
3055
|
+
}
|
|
3056
|
+
__name(isValidHttpUrl, "isValidHttpUrl");
|
|
3057
|
+
|
|
3058
|
+
// ../../packages/dvss-integration-trybe/src/capabilities/auth/auth.service.ts
|
|
3059
|
+
function _ts_decorate16(decorators, target, key, desc2) {
|
|
3060
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3061
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2418
3062
|
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
3063
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2420
3064
|
}
|
|
2421
|
-
__name(
|
|
2422
|
-
function
|
|
3065
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
3066
|
+
function _ts_metadata13(k, v) {
|
|
2423
3067
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2424
3068
|
}
|
|
2425
|
-
__name(
|
|
3069
|
+
__name(_ts_metadata13, "_ts_metadata");
|
|
2426
3070
|
exports.TrybeAuthService = class _TrybeAuthService {
|
|
2427
3071
|
static {
|
|
2428
3072
|
__name(this, "TrybeAuthService");
|
|
@@ -2471,13 +3115,14 @@ exports.TrybeAuthService = class _TrybeAuthService {
|
|
|
2471
3115
|
if (!platformConfig.baseUrl) {
|
|
2472
3116
|
throw new Error("Platform configuration is invalid: Base URL not found");
|
|
2473
3117
|
}
|
|
2474
|
-
if (!
|
|
3118
|
+
if (!isValidHttpUrl(platformConfig.baseUrl)) {
|
|
2475
3119
|
throw new Error("Platform configuration is invalid: Base URL is not a valid URL");
|
|
2476
3120
|
}
|
|
2477
3121
|
} else {
|
|
2478
3122
|
throw new Error("Platform configuration is invalid: Platform config is empty");
|
|
2479
3123
|
}
|
|
2480
3124
|
const headers = {
|
|
3125
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2481
3126
|
Authorization: `Bearer ${integrationConfig.apiKey}`
|
|
2482
3127
|
};
|
|
2483
3128
|
return {
|
|
@@ -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
|
])
|
|
@@ -2540,14 +3177,14 @@ exports.TrybeAuthService = _ts_decorate14([
|
|
|
2540
3177
|
function mapStatus(t) {
|
|
2541
3178
|
if (t.redeemed_at) return CREDIT_STATUS_ENUM.REDEEMED;
|
|
2542
3179
|
if (t.revoked_at) return CREDIT_STATUS_ENUM.REVOKED;
|
|
2543
|
-
if (new Date(t.expires_at) < /* @__PURE__ */ new Date()) return CREDIT_STATUS_ENUM.EXPIRED;
|
|
3180
|
+
if (t.expires_at && new Date(t.expires_at) < /* @__PURE__ */ new Date()) return CREDIT_STATUS_ENUM.EXPIRED;
|
|
2544
3181
|
return CREDIT_STATUS_ENUM.ACTIVE;
|
|
2545
3182
|
}
|
|
2546
3183
|
__name(mapStatus, "mapStatus");
|
|
2547
3184
|
function mapTrybeCreditsToSystem(res, integration) {
|
|
2548
3185
|
const groups = /* @__PURE__ */ new Map();
|
|
2549
3186
|
for (const t of res.data) {
|
|
2550
|
-
const key = `${t.coupon_name}|${t.expires_at
|
|
3187
|
+
const key = `${t.coupon_name}|${t.expires_at?.split("T")[0]}`;
|
|
2551
3188
|
const list = groups.get(key) ?? [];
|
|
2552
3189
|
list.push(t);
|
|
2553
3190
|
groups.set(key, list);
|
|
@@ -2566,8 +3203,8 @@ function mapTrybeCreditsToSystem(res, integration) {
|
|
|
2566
3203
|
type: CREDIT_TYPE_ENUM.COUPON,
|
|
2567
3204
|
status: mapStatus(first),
|
|
2568
3205
|
externalId: first.id,
|
|
2569
|
-
expiresAt: new Date(first.expires_at),
|
|
2570
|
-
expiresDate: first.expires_at
|
|
3206
|
+
expiresAt: first.expires_at ? new Date(first.expires_at) : void 0,
|
|
3207
|
+
expiresDate: first.expires_at?.split("T")[0],
|
|
2571
3208
|
startsAt: new Date(first.issued_at),
|
|
2572
3209
|
startDate: first.issued_at.split("T")[0],
|
|
2573
3210
|
value: first.coupon_code,
|
|
@@ -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,
|
|
@@ -3086,7 +3735,7 @@ function mapTrybeSessionAvailabilityToSystemResponse(sessions) {
|
|
|
3086
3735
|
const time = sessionList.map((session) => {
|
|
3087
3736
|
const fromTime = extractTimeFromIsoString(session.start_time);
|
|
3088
3737
|
const toTime = extractTimeFromIsoString(session.end_time);
|
|
3089
|
-
const { start_time:
|
|
3738
|
+
const { start_time: startTime, end_time: endTime, ...meta } = session;
|
|
3090
3739
|
const camelCaseMeta = convertKeysToCamelCase(meta);
|
|
3091
3740
|
return {
|
|
3092
3741
|
fromTime,
|
|
@@ -3115,7 +3764,7 @@ function mapTrybeAppointmentAvailabilityToSystemResponse(slots) {
|
|
|
3115
3764
|
const time = slotList.map((slot) => {
|
|
3116
3765
|
const fromTime = extractTimeFromIsoString(slot.start_time);
|
|
3117
3766
|
const toTime = extractTimeFromIsoString(slot.end_time);
|
|
3118
|
-
const { start_time:
|
|
3767
|
+
const { start_time: startTime, end_time: endTime, ...meta } = slot;
|
|
3119
3768
|
const camelCaseMeta = convertKeysToCamelCase(meta);
|
|
3120
3769
|
return {
|
|
3121
3770
|
fromTime,
|
|
@@ -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");
|
|
@@ -3407,14 +4056,13 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
3407
4056
|
} else {
|
|
3408
4057
|
throw new Error("Course is not updatable");
|
|
3409
4058
|
}
|
|
3410
|
-
|
|
4059
|
+
return await this.trafficGatewayService.executeIntegrationRequest({
|
|
3411
4060
|
apiMethod: HTTP_METHOD.PUT,
|
|
3412
4061
|
url: `/shop/orders/${orderId}/items/${itemId}`,
|
|
3413
4062
|
baseUrl: validated.config.platformConfig.baseUrl,
|
|
3414
4063
|
headers: validated.headers,
|
|
3415
4064
|
body
|
|
3416
4065
|
}, validated, loggedInUserId);
|
|
3417
|
-
return res;
|
|
3418
4066
|
}
|
|
3419
4067
|
async addPaymentToOrder(request, integration, loggedInUserId) {
|
|
3420
4068
|
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
@@ -3640,10 +4288,10 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
3640
4288
|
return mapTrybeAppointmentAvailabilityToSystemResponse(response.data);
|
|
3641
4289
|
}
|
|
3642
4290
|
};
|
|
3643
|
-
exports.TrybeWellnessManagement =
|
|
4291
|
+
exports.TrybeWellnessManagement = _ts_decorate18([
|
|
3644
4292
|
common.Injectable(),
|
|
3645
|
-
|
|
3646
|
-
|
|
4293
|
+
_ts_metadata15("design:type", Function),
|
|
4294
|
+
_ts_metadata15("design:paramtypes", [
|
|
3647
4295
|
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
|
|
3648
4296
|
typeof exports.TrafficGatewayService === "undefined" ? Object : exports.TrafficGatewayService,
|
|
3649
4297
|
typeof exports.TrybeAuthService === "undefined" ? Object : exports.TrybeAuthService
|
|
@@ -3663,25 +4311,25 @@ function mapTrybeSiteResponseToSystem(response) {
|
|
|
3663
4311
|
__name(mapTrybeSiteResponseToSystem, "mapTrybeSiteResponseToSystem");
|
|
3664
4312
|
|
|
3665
4313
|
// ../../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,
|
|
4314
|
+
function _ts_decorate19(decorators, target, key, desc2) {
|
|
4315
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4316
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3669
4317
|
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
4318
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3671
4319
|
}
|
|
3672
|
-
__name(
|
|
3673
|
-
function
|
|
4320
|
+
__name(_ts_decorate19, "_ts_decorate");
|
|
4321
|
+
function _ts_metadata16(k, v) {
|
|
3674
4322
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
3675
4323
|
}
|
|
3676
|
-
__name(
|
|
3677
|
-
exports.TrybeIntegrationConfigurationService = class TrybeIntegrationConfigurationService extends BaseIntegrationConfiguration {
|
|
4324
|
+
__name(_ts_metadata16, "_ts_metadata");
|
|
4325
|
+
exports.TrybeIntegrationConfigurationService = class TrybeIntegrationConfigurationService extends exports.BaseIntegrationConfiguration {
|
|
3678
4326
|
static {
|
|
3679
4327
|
__name(this, "TrybeIntegrationConfigurationService");
|
|
3680
4328
|
}
|
|
3681
4329
|
trybeAuthService;
|
|
3682
4330
|
trafficGatewayService;
|
|
3683
|
-
constructor(integrationConfigurationDao, commonValidationDatabaseService, trybeAuthService, trafficGatewayService) {
|
|
3684
|
-
super(integrationConfigurationDao, commonValidationDatabaseService), this.trybeAuthService = trybeAuthService, this.trafficGatewayService = trafficGatewayService;
|
|
4331
|
+
constructor(integrationConfigurationDao, commonValidationDatabaseService, logger, trybeAuthService, trafficGatewayService) {
|
|
4332
|
+
super(integrationConfigurationDao, commonValidationDatabaseService, logger), this.trybeAuthService = trybeAuthService, this.trafficGatewayService = trafficGatewayService;
|
|
3685
4333
|
}
|
|
3686
4334
|
/**
|
|
3687
4335
|
* Add capability integration: validate Trybe config, then configuredFor (offering), then delegate to base.
|
|
@@ -3696,10 +4344,15 @@ exports.TrybeIntegrationConfigurationService = class TrybeIntegrationConfigurati
|
|
|
3696
4344
|
return super.addCapabilityIntegration(input, context);
|
|
3697
4345
|
}
|
|
3698
4346
|
/**
|
|
3699
|
-
* Update capability integration: delegate to base.
|
|
4347
|
+
* Update capability integration: convert to new signature and delegate to base.
|
|
3700
4348
|
*/
|
|
3701
|
-
async updateCapabilityIntegration(
|
|
3702
|
-
|
|
4349
|
+
async updateCapabilityIntegration(request, integration, loggedInUserId) {
|
|
4350
|
+
if (request.updateData.config) {
|
|
4351
|
+
this.trybeAuthService.validateConfig({
|
|
4352
|
+
config: request.updateData.config
|
|
4353
|
+
}, loggedInUserId);
|
|
4354
|
+
}
|
|
4355
|
+
return super.updateCapabilityIntegration(request, integration, loggedInUserId);
|
|
3703
4356
|
}
|
|
3704
4357
|
/**
|
|
3705
4358
|
* Validates configuredFor (offering exists and belongs to project). Same as project-ms validateCapabilityIntegrationConfiguredForInput.
|
|
@@ -3729,31 +4382,127 @@ exports.TrybeIntegrationConfigurationService = class TrybeIntegrationConfigurati
|
|
|
3729
4382
|
return mapTrybeSiteResponseToSystem(response);
|
|
3730
4383
|
}
|
|
3731
4384
|
};
|
|
3732
|
-
exports.TrybeIntegrationConfigurationService =
|
|
4385
|
+
exports.TrybeIntegrationConfigurationService = _ts_decorate19([
|
|
3733
4386
|
common.Injectable(),
|
|
3734
|
-
|
|
3735
|
-
|
|
4387
|
+
_ts_metadata16("design:type", Function),
|
|
4388
|
+
_ts_metadata16("design:paramtypes", [
|
|
3736
4389
|
typeof exports.IntegrationConfigurationDao === "undefined" ? Object : exports.IntegrationConfigurationDao,
|
|
3737
4390
|
typeof dvssBackendModuleDatastore.CommonValidationDatabaseService === "undefined" ? Object : dvssBackendModuleDatastore.CommonValidationDatabaseService,
|
|
4391
|
+
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
|
|
3738
4392
|
typeof exports.TrybeAuthService === "undefined" ? Object : exports.TrybeAuthService,
|
|
3739
4393
|
typeof exports.TrafficGatewayService === "undefined" ? Object : exports.TrafficGatewayService
|
|
3740
4394
|
])
|
|
3741
4395
|
], exports.TrybeIntegrationConfigurationService);
|
|
4396
|
+
function _ts_decorate20(decorators, target, key, desc2) {
|
|
4397
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4398
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
4399
|
+
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;
|
|
4400
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4401
|
+
}
|
|
4402
|
+
__name(_ts_decorate20, "_ts_decorate");
|
|
4403
|
+
function _ts_metadata17(k, v) {
|
|
4404
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4405
|
+
}
|
|
4406
|
+
__name(_ts_metadata17, "_ts_metadata");
|
|
4407
|
+
var OFFERING_INTEGRATION_MAPPING_ALREADY_EXISTS = "OFFERING_INTEGRATION_MAPPING_ALREADY_EXISTS";
|
|
4408
|
+
var VALID_JOURNEY_VALUES = /* @__PURE__ */ new Set([
|
|
4409
|
+
"SESSION",
|
|
4410
|
+
"COURSE",
|
|
4411
|
+
"APPOINTMENT"
|
|
4412
|
+
]);
|
|
4413
|
+
exports.TrybeIntegrationResourceManagementService = class TrybeIntegrationResourceManagementService extends BaseIntegrationResourceManagement {
|
|
4414
|
+
static {
|
|
4415
|
+
__name(this, "TrybeIntegrationResourceManagementService");
|
|
4416
|
+
}
|
|
4417
|
+
constructor(logger, integrationResourceManagementDao) {
|
|
4418
|
+
super(integrationResourceManagementDao, logger);
|
|
4419
|
+
}
|
|
4420
|
+
/**
|
|
4421
|
+
* Validates Trybe resource mapping config (same rules as MS trybe-offering-integration-management.service).
|
|
4422
|
+
* @throws CustomException BAD_REQUEST if config is invalid
|
|
4423
|
+
*/
|
|
4424
|
+
validateResourceMappingConfig(config3) {
|
|
4425
|
+
const resourceMappingConfig = config3;
|
|
4426
|
+
if (!resourceMappingConfig.supportedJourneys || resourceMappingConfig.supportedJourneys.length === 0) {
|
|
4427
|
+
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: supportedJourneys required and must be non-empty");
|
|
4428
|
+
}
|
|
4429
|
+
if (!resourceMappingConfig.catalogingBy || // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
4430
|
+
resourceMappingConfig.catalogingBy !== TRYBE_CATALOGING_BY_ENUM.PEOPLE_RESOURCE) {
|
|
4431
|
+
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: catalogingBy must be PEOPLE_RESOURCE");
|
|
4432
|
+
}
|
|
4433
|
+
if (resourceMappingConfig.isExternalCmsIntegrationEnabled === void 0 || typeof resourceMappingConfig.isExternalCmsIntegrationEnabled !== "boolean" || resourceMappingConfig.isExternalCmsIntegrationEnabled === false) {
|
|
4434
|
+
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: isExternalCmsIntegrationEnabled must be true");
|
|
4435
|
+
}
|
|
4436
|
+
if (!resourceMappingConfig.externalCmsUrl || !isValidHttpUrl(resourceMappingConfig.externalCmsUrl)) {
|
|
4437
|
+
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: externalCmsUrl must be a valid HTTP(S) URL");
|
|
4438
|
+
}
|
|
4439
|
+
if (!resourceMappingConfig.supportedJourneys.some((journey) => VALID_JOURNEY_VALUES.has(journey))) {
|
|
4440
|
+
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: supportedJourneys must contain at least one of SESSION, COURSE, APPOINTMENT");
|
|
4441
|
+
}
|
|
4442
|
+
if (resourceMappingConfig.supportedJourneys.some((journey) => !VALID_JOURNEY_VALUES.has(journey))) {
|
|
4443
|
+
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: supportedJourneys may only contain SESSION, COURSE, APPOINTMENT");
|
|
4444
|
+
}
|
|
4445
|
+
if (!resourceMappingConfig.paymentType || typeof resourceMappingConfig.paymentType !== "string") {
|
|
4446
|
+
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: paymentType required and must be a string");
|
|
4447
|
+
}
|
|
4448
|
+
}
|
|
4449
|
+
async addResourceToIntegration(input, context) {
|
|
4450
|
+
if (input.config != null && typeof input.config === "object") {
|
|
4451
|
+
this.validateResourceMappingConfig(input.config);
|
|
4452
|
+
}
|
|
4453
|
+
const isMappingExists = await this.integrationResourceManagementDao.checkMappingExists({
|
|
4454
|
+
capabilityIntegrationId: input.capabilityIntegrationId,
|
|
4455
|
+
configuredForId: input.offeringId,
|
|
4456
|
+
configuredForType: models.CONFIGURED_FOR_TYPE_ENUM.OFFERING
|
|
4457
|
+
}, context.loggedInUserId);
|
|
4458
|
+
if (isMappingExists) {
|
|
4459
|
+
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, OFFERING_INTEGRATION_MAPPING_ALREADY_EXISTS);
|
|
4460
|
+
}
|
|
4461
|
+
return super.addResourceToIntegration(input, context);
|
|
4462
|
+
}
|
|
4463
|
+
async removeResourceFromIntegration(request, context) {
|
|
4464
|
+
const isMappingExists = await this.integrationResourceManagementDao.checkMappingExists({
|
|
4465
|
+
capabilityIntegrationId: request.capabilityIntegrationId,
|
|
4466
|
+
configuredForId: request.offeringId,
|
|
4467
|
+
configuredForType: models.CONFIGURED_FOR_TYPE_ENUM.OFFERING
|
|
4468
|
+
}, context.loggedInUserId);
|
|
4469
|
+
if (!isMappingExists) {
|
|
4470
|
+
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Mapping not found");
|
|
4471
|
+
}
|
|
4472
|
+
return super.removeResourceFromIntegration(request, context);
|
|
4473
|
+
}
|
|
4474
|
+
async updateOfferingIntegrationResourceConfiguration(input, context) {
|
|
4475
|
+
const resourceMapping = await this.integrationResourceManagementDao.getCapabilityIntegrationResourceMappingById(input.id, context.loggedInUserId);
|
|
4476
|
+
if (!resourceMapping) {
|
|
4477
|
+
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Resource mapping not found");
|
|
4478
|
+
}
|
|
4479
|
+
this.validateResourceMappingConfig(input.config);
|
|
4480
|
+
return await super.updateOfferingIntegrationResourceConfiguration(input, context);
|
|
4481
|
+
}
|
|
4482
|
+
};
|
|
4483
|
+
exports.TrybeIntegrationResourceManagementService = _ts_decorate20([
|
|
4484
|
+
common.Injectable(),
|
|
4485
|
+
_ts_metadata17("design:type", Function),
|
|
4486
|
+
_ts_metadata17("design:paramtypes", [
|
|
4487
|
+
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
|
|
4488
|
+
typeof exports.IntegrationResourceManagementDao === "undefined" ? Object : exports.IntegrationResourceManagementDao
|
|
4489
|
+
])
|
|
4490
|
+
], exports.TrybeIntegrationResourceManagementService);
|
|
3742
4491
|
|
|
3743
4492
|
// ../../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,
|
|
4493
|
+
function _ts_decorate21(decorators, target, key, desc2) {
|
|
4494
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4495
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3747
4496
|
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
4497
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3749
4498
|
}
|
|
3750
|
-
__name(
|
|
4499
|
+
__name(_ts_decorate21, "_ts_decorate");
|
|
3751
4500
|
exports.IntegrationTrybeModule = class AppModule2 {
|
|
3752
4501
|
static {
|
|
3753
4502
|
__name(this, "AppModule");
|
|
3754
4503
|
}
|
|
3755
4504
|
};
|
|
3756
|
-
exports.IntegrationTrybeModule =
|
|
4505
|
+
exports.IntegrationTrybeModule = _ts_decorate21([
|
|
3757
4506
|
common.Module({
|
|
3758
4507
|
imports: [
|
|
3759
4508
|
// Load environment variables from root .env file
|
|
@@ -3776,12 +4525,14 @@ exports.IntegrationTrybeModule = _ts_decorate18([
|
|
|
3776
4525
|
exports.TrybeCreditBooking,
|
|
3777
4526
|
exports.TrybeWellnessManagement,
|
|
3778
4527
|
exports.IntegrationConfigurationDao,
|
|
4528
|
+
exports.IntegrationResourceManagementDao,
|
|
3779
4529
|
exports.IntegrationRequestLoggerService,
|
|
3780
4530
|
exports.RateLimiterService,
|
|
3781
4531
|
exports.TrafficGatewayService,
|
|
3782
4532
|
exports.TrybeCustomerManagement,
|
|
3783
4533
|
exports.TrybeAuthService,
|
|
3784
4534
|
exports.TrybeIntegrationConfigurationService,
|
|
4535
|
+
exports.TrybeIntegrationResourceManagementService,
|
|
3785
4536
|
dvssBackendModuleDatastore.CommonValidationDatabaseService
|
|
3786
4537
|
],
|
|
3787
4538
|
exports: [
|
|
@@ -3789,25 +4540,26 @@ exports.IntegrationTrybeModule = _ts_decorate18([
|
|
|
3789
4540
|
exports.TrybeCustomerManagement,
|
|
3790
4541
|
exports.TrybeCreditBooking,
|
|
3791
4542
|
exports.TrybeWellnessManagement,
|
|
3792
|
-
exports.TrybeIntegrationConfigurationService
|
|
4543
|
+
exports.TrybeIntegrationConfigurationService,
|
|
4544
|
+
exports.TrybeIntegrationResourceManagementService
|
|
3793
4545
|
]
|
|
3794
4546
|
})
|
|
3795
4547
|
], exports.IntegrationTrybeModule);
|
|
3796
4548
|
|
|
3797
4549
|
// 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,
|
|
4550
|
+
function _ts_decorate22(decorators, target, key, desc2) {
|
|
4551
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4552
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3801
4553
|
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
4554
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3803
4555
|
}
|
|
3804
|
-
__name(
|
|
4556
|
+
__name(_ts_decorate22, "_ts_decorate");
|
|
3805
4557
|
exports.OfferingIntegrationManager = class AppModule3 {
|
|
3806
4558
|
static {
|
|
3807
4559
|
__name(this, "AppModule");
|
|
3808
4560
|
}
|
|
3809
4561
|
};
|
|
3810
|
-
exports.OfferingIntegrationManager =
|
|
4562
|
+
exports.OfferingIntegrationManager = _ts_decorate22([
|
|
3811
4563
|
common.Module({
|
|
3812
4564
|
imports: [
|
|
3813
4565
|
exports.IntegrationTrybeModule,
|
|
@@ -3840,7 +4592,7 @@ exports.BaseAccountingTaxManagement = BaseAccountingTaxManagement;
|
|
|
3840
4592
|
exports.BaseAuth = BaseAuth;
|
|
3841
4593
|
exports.BaseCreditBooking = BaseCreditBooking;
|
|
3842
4594
|
exports.BaseCustomerManagement = BaseCustomerManagement;
|
|
3843
|
-
exports.
|
|
4595
|
+
exports.BaseIntegrationResourceManagement = BaseIntegrationResourceManagement;
|
|
3844
4596
|
exports.BaseMembershipCustomerManagement = BaseMembershipCustomerManagement;
|
|
3845
4597
|
exports.BaseMembershipManagement = BaseMembershipManagement;
|
|
3846
4598
|
exports.BasePackageManagement = BasePackageManagement;
|
|
@@ -3853,9 +4605,12 @@ exports.CREDIT_STATUS_ENUM = CREDIT_STATUS_ENUM;
|
|
|
3853
4605
|
exports.CREDIT_TYPE_ENUM = CREDIT_TYPE_ENUM;
|
|
3854
4606
|
exports.HTTP_METHOD = HTTP_METHOD;
|
|
3855
4607
|
exports.INTEGRATION_PROVIDER_ENUM = INTEGRATION_PROVIDER_ENUM;
|
|
4608
|
+
exports.OFFERING_INTEGRATION_MAPPING_ALREADY_EXISTS = OFFERING_INTEGRATION_MAPPING_ALREADY_EXISTS;
|
|
3856
4609
|
exports.TRAFFIC_ROUTER_CONFIGURATION_STORE_KEY = TRAFFIC_ROUTER_CONFIGURATION_STORE_KEY;
|
|
4610
|
+
exports.TRYBE_CATALOGING_BY_ENUM = TRYBE_CATALOGING_BY_ENUM;
|
|
3857
4611
|
exports.TRYBE_OFFERING_TYPE_API = TRYBE_OFFERING_TYPE_API;
|
|
3858
4612
|
exports.TRYBE_OFFERING_TYPE_ENUM = TRYBE_OFFERING_TYPE_ENUM;
|
|
4613
|
+
exports.TRYBE_SUPPORTED_JOURNEYS_ENUM = TRYBE_SUPPORTED_JOURNEYS_ENUM;
|
|
3859
4614
|
exports.convertKeysToCamelCase = convertKeysToCamelCase;
|
|
3860
4615
|
exports.extractTimeFromIsoString = extractTimeFromIsoString;
|
|
3861
4616
|
exports.fetchAllPages = fetchAllPages;
|