@dv4resi/dvss-backend-module-offering-im 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +589 -58
- package/dist/index.js +2953 -211
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7,12 +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');
|
|
11
|
+
var dvssBackendModuleDatastore = require('@dv4resi/dvss-backend-module-datastore');
|
|
12
|
+
var common_enum = require('@dv4resi/dvss-backend-module-datastore/dist/datastore/commons/common.enum');
|
|
13
|
+
var capabilityIntegration_model = require('@dv4resi/dvss-backend-module-datastore/dist/datastore/models/capability-integration.model');
|
|
14
|
+
var capability_model = require('@dv4resi/dvss-backend-module-datastore/dist/datastore/models/capability.model');
|
|
10
15
|
|
|
11
16
|
var __defProp = Object.defineProperty;
|
|
12
17
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
13
|
-
function _ts_decorate(decorators, target, key,
|
|
14
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
15
|
-
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);
|
|
16
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;
|
|
17
22
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
18
23
|
}
|
|
@@ -38,9 +43,9 @@ AppService = _ts_decorate([
|
|
|
38
43
|
], AppService);
|
|
39
44
|
|
|
40
45
|
// src/app.controller.ts
|
|
41
|
-
function _ts_decorate2(decorators, target, key,
|
|
42
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
43
|
-
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);
|
|
44
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;
|
|
45
50
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
46
51
|
}
|
|
@@ -78,9 +83,9 @@ var rootEnvPath = path.resolve(__dirname, "../../../.env");
|
|
|
78
83
|
dotenv.config({
|
|
79
84
|
path: rootEnvPath
|
|
80
85
|
});
|
|
81
|
-
function _ts_decorate3(decorators, target, key,
|
|
82
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
83
|
-
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);
|
|
84
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;
|
|
85
90
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
86
91
|
}
|
|
@@ -110,9 +115,9 @@ AppService2 = _ts_decorate3([
|
|
|
110
115
|
], AppService2);
|
|
111
116
|
|
|
112
117
|
// ../../packages/dvss-integration-trybe/src/app.controller.ts
|
|
113
|
-
function _ts_decorate4(decorators, target, key,
|
|
114
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
115
|
-
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);
|
|
116
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;
|
|
117
122
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
118
123
|
}
|
|
@@ -146,13 +151,9 @@ AppController2 = _ts_decorate4([
|
|
|
146
151
|
typeof AppService2 === "undefined" ? Object : AppService2
|
|
147
152
|
])
|
|
148
153
|
], AppController2);
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
});
|
|
153
|
-
function _ts_decorate5(decorators, target, key, desc) {
|
|
154
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
155
|
-
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);
|
|
156
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;
|
|
157
158
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
158
159
|
}
|
|
@@ -170,9 +171,9 @@ AppService3 = _ts_decorate5([
|
|
|
170
171
|
], AppService3);
|
|
171
172
|
|
|
172
173
|
// ../../packages/dvss-integration-libs/src/app.controller.ts
|
|
173
|
-
function _ts_decorate6(decorators, target, key,
|
|
174
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
175
|
-
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);
|
|
176
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;
|
|
177
178
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
178
179
|
}
|
|
@@ -206,9 +207,19 @@ AppController3 = _ts_decorate6([
|
|
|
206
207
|
typeof AppService3 === "undefined" ? Object : AppService3
|
|
207
208
|
])
|
|
208
209
|
], AppController3);
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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);
|
|
212
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;
|
|
213
224
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
214
225
|
}
|
|
@@ -217,7 +228,7 @@ function _ts_metadata6(k, v) {
|
|
|
217
228
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
218
229
|
}
|
|
219
230
|
__name(_ts_metadata6, "_ts_metadata");
|
|
220
|
-
|
|
231
|
+
exports.IntegrationRequestLoggerService = class _IntegrationRequestLoggerService {
|
|
221
232
|
static {
|
|
222
233
|
__name(this, "IntegrationRequestLoggerService");
|
|
223
234
|
}
|
|
@@ -237,7 +248,7 @@ var IntegrationRequestLoggerService = class _IntegrationRequestLoggerService {
|
|
|
237
248
|
integrationId: logData.integrationId,
|
|
238
249
|
method,
|
|
239
250
|
url,
|
|
240
|
-
headers
|
|
251
|
+
headers,
|
|
241
252
|
requestBody,
|
|
242
253
|
timestamp: logData.timestamp || /* @__PURE__ */ new Date()
|
|
243
254
|
});
|
|
@@ -265,7 +276,7 @@ var IntegrationRequestLoggerService = class _IntegrationRequestLoggerService {
|
|
|
265
276
|
* @param logData - The error log data to be logged
|
|
266
277
|
*/
|
|
267
278
|
logError(logData) {
|
|
268
|
-
const { loggedInUserId, method, url, statusCode, duration, error } = logData;
|
|
279
|
+
const { loggedInUserId, method, url, statusCode, duration, error, responseBody } = logData;
|
|
269
280
|
this.logger.error(loggedInUserId || dvssBackendModuleUtility.SYSTEM_USER_ID, this.logError.name, this.className, `Integration API Error: ${method} ${url} - ${statusCode || "N/A"} (${duration || 0}ms)`, {
|
|
270
281
|
integrationId: logData.integrationId,
|
|
271
282
|
method,
|
|
@@ -273,6 +284,7 @@ var IntegrationRequestLoggerService = class _IntegrationRequestLoggerService {
|
|
|
273
284
|
statusCode,
|
|
274
285
|
duration,
|
|
275
286
|
error,
|
|
287
|
+
responseBody,
|
|
276
288
|
timestamp: logData.timestamp || /* @__PURE__ */ new Date()
|
|
277
289
|
});
|
|
278
290
|
}
|
|
@@ -291,49 +303,22 @@ var IntegrationRequestLoggerService = class _IntegrationRequestLoggerService {
|
|
|
291
303
|
this.logRequest(logData);
|
|
292
304
|
}
|
|
293
305
|
}
|
|
294
|
-
/**
|
|
295
|
-
* Sanitize headers to remove sensitive information
|
|
296
|
-
*
|
|
297
|
-
* @param headers - The headers to sanitize
|
|
298
|
-
* @returns Sanitized headers
|
|
299
|
-
*/
|
|
300
|
-
sanitizeHeaders(headers) {
|
|
301
|
-
if (!headers) {
|
|
302
|
-
return void 0;
|
|
303
|
-
}
|
|
304
|
-
const sanitized = {
|
|
305
|
-
...headers
|
|
306
|
-
};
|
|
307
|
-
const sensitiveKeys = [
|
|
308
|
-
"authorization",
|
|
309
|
-
"api-key",
|
|
310
|
-
"apikey",
|
|
311
|
-
"x-api-key",
|
|
312
|
-
"cookie"
|
|
313
|
-
];
|
|
314
|
-
for (const key of Object.keys(sanitized)) {
|
|
315
|
-
if (sensitiveKeys.includes(key.toLowerCase())) {
|
|
316
|
-
sanitized[key] = "***REDACTED***";
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
return sanitized;
|
|
320
|
-
}
|
|
321
306
|
};
|
|
322
|
-
IntegrationRequestLoggerService = _ts_decorate7([
|
|
307
|
+
exports.IntegrationRequestLoggerService = _ts_decorate7([
|
|
323
308
|
common.Injectable(),
|
|
324
309
|
_ts_metadata6("design:type", Function),
|
|
325
310
|
_ts_metadata6("design:paramtypes", [
|
|
326
311
|
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
|
|
327
312
|
])
|
|
328
|
-
], IntegrationRequestLoggerService);
|
|
329
|
-
function _ts_decorate8(decorators, target, key,
|
|
330
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
331
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
313
|
+
], exports.IntegrationRequestLoggerService);
|
|
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);
|
|
332
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;
|
|
333
318
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
334
319
|
}
|
|
335
320
|
__name(_ts_decorate8, "_ts_decorate");
|
|
336
|
-
|
|
321
|
+
exports.RateLimiterService = class RateLimiterService {
|
|
337
322
|
static {
|
|
338
323
|
__name(this, "RateLimiterService");
|
|
339
324
|
}
|
|
@@ -345,24 +330,14 @@ var RateLimiterService = class {
|
|
|
345
330
|
async validateAndEnforceRateLimit() {
|
|
346
331
|
}
|
|
347
332
|
};
|
|
348
|
-
RateLimiterService = _ts_decorate8([
|
|
333
|
+
exports.RateLimiterService = _ts_decorate8([
|
|
349
334
|
common.Injectable()
|
|
350
|
-
], RateLimiterService);
|
|
351
|
-
|
|
352
|
-
// ../../packages/dvss-integration-libs/src/integration-traffic-router/constants/http.constant.ts
|
|
353
|
-
var HTTP_METHOD = /* @__PURE__ */ (function(HTTP_METHOD2) {
|
|
354
|
-
HTTP_METHOD2["GET"] = "GET";
|
|
355
|
-
HTTP_METHOD2["POST"] = "POST";
|
|
356
|
-
HTTP_METHOD2["PUT"] = "PUT";
|
|
357
|
-
HTTP_METHOD2["DELETE"] = "DELETE";
|
|
358
|
-
HTTP_METHOD2["PATCH"] = "PATCH";
|
|
359
|
-
return HTTP_METHOD2;
|
|
360
|
-
})({});
|
|
335
|
+
], exports.RateLimiterService);
|
|
361
336
|
|
|
362
337
|
// ../../packages/dvss-integration-libs/src/integration-traffic-router/gateway/traffic-gateway.service.ts
|
|
363
|
-
function _ts_decorate9(decorators, target, key,
|
|
364
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
365
|
-
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);
|
|
366
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;
|
|
367
342
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
368
343
|
}
|
|
@@ -435,10 +410,15 @@ exports.TrafficGatewayService = class TrafficGatewayService {
|
|
|
435
410
|
requestBody: request.body,
|
|
436
411
|
loggedInUserId,
|
|
437
412
|
timestamp: /* @__PURE__ */ new Date(),
|
|
438
|
-
error: errorDetails.
|
|
413
|
+
error: errorDetails.apiMessage,
|
|
439
414
|
statusCode: errorDetails.statusCode,
|
|
440
|
-
duration
|
|
415
|
+
duration,
|
|
416
|
+
responseBody: errorDetails.responseBody
|
|
441
417
|
});
|
|
418
|
+
const err = error;
|
|
419
|
+
err.apiMessage = errorDetails.message;
|
|
420
|
+
err.statusCode = errorDetails.statusCode;
|
|
421
|
+
err.message = errorDetails.apiMessage;
|
|
442
422
|
throw error;
|
|
443
423
|
}
|
|
444
424
|
}
|
|
@@ -528,17 +508,35 @@ exports.TrafficGatewayService = class TrafficGatewayService {
|
|
|
528
508
|
}
|
|
529
509
|
}
|
|
530
510
|
/**
|
|
531
|
-
* Extract error details from an error object
|
|
511
|
+
* Extract error details from an error object (e.g. Axios error).
|
|
512
|
+
* Provider-agnostic: derives apiMessage from common response shapes so any integration
|
|
513
|
+
* (Trybe, OAuth, REST, etc.) gets a readable reason. Callers can use statusCode and
|
|
514
|
+
* responseBody to map to their own exceptions (e.g. 404 -> RESOURCE_NOT_FOUND).
|
|
515
|
+
*
|
|
516
|
+
* Supported response.data fields (first string wins): message, error_description,
|
|
517
|
+
* error, detail, msg.
|
|
532
518
|
*
|
|
533
519
|
* @private
|
|
534
520
|
* @param error - The error object
|
|
535
|
-
* @returns Extracted error details
|
|
521
|
+
* @returns Extracted error details including apiMessage for logging and callers
|
|
536
522
|
*/
|
|
537
523
|
extractErrorDetails(error) {
|
|
538
524
|
const errorObject = error;
|
|
525
|
+
const responseData = errorObject.response?.data;
|
|
526
|
+
const data = typeof responseData === "object" && responseData !== null ? responseData : void 0;
|
|
527
|
+
const firstString = /* @__PURE__ */ __name((...keys) => {
|
|
528
|
+
for (const k of keys) {
|
|
529
|
+
const v = data?.[k];
|
|
530
|
+
if (typeof v === "string" && v.trim()) return v;
|
|
531
|
+
}
|
|
532
|
+
return void 0;
|
|
533
|
+
}, "firstString");
|
|
534
|
+
const apiMessage = firstString("message", "error_description", "error", "detail", "msg") || errorObject.message || "API error";
|
|
539
535
|
return {
|
|
540
536
|
message: errorObject.message,
|
|
541
|
-
statusCode: errorObject.status || errorObject.response?.status
|
|
537
|
+
statusCode: errorObject.status || errorObject.response?.status,
|
|
538
|
+
responseBody: errorObject.response?.data,
|
|
539
|
+
apiMessage
|
|
542
540
|
};
|
|
543
541
|
}
|
|
544
542
|
};
|
|
@@ -547,15 +545,19 @@ exports.TrafficGatewayService = _ts_decorate9([
|
|
|
547
545
|
_ts_metadata7("design:type", Function),
|
|
548
546
|
_ts_metadata7("design:paramtypes", [
|
|
549
547
|
typeof axios.HttpService === "undefined" ? Object : axios.HttpService,
|
|
550
|
-
typeof IntegrationRequestLoggerService === "undefined" ? Object : IntegrationRequestLoggerService,
|
|
551
|
-
typeof RateLimiterService === "undefined" ? Object : RateLimiterService
|
|
548
|
+
typeof exports.IntegrationRequestLoggerService === "undefined" ? Object : exports.IntegrationRequestLoggerService,
|
|
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
|
}
|
|
@@ -582,13 +584,13 @@ exports.IntegrationLibsModule = _ts_decorate10([
|
|
|
582
584
|
providers: [
|
|
583
585
|
AppService3,
|
|
584
586
|
exports.TrafficGatewayService,
|
|
585
|
-
IntegrationRequestLoggerService,
|
|
586
|
-
RateLimiterService
|
|
587
|
+
exports.IntegrationRequestLoggerService,
|
|
588
|
+
exports.RateLimiterService
|
|
587
589
|
],
|
|
588
590
|
exports: [
|
|
589
591
|
exports.TrafficGatewayService,
|
|
590
|
-
IntegrationRequestLoggerService,
|
|
591
|
-
RateLimiterService
|
|
592
|
+
exports.IntegrationRequestLoggerService,
|
|
593
|
+
exports.RateLimiterService
|
|
592
594
|
]
|
|
593
595
|
})
|
|
594
596
|
], exports.IntegrationLibsModule);
|
|
@@ -596,13 +598,51 @@ exports.IntegrationLibsModule = _ts_decorate10([
|
|
|
596
598
|
// ../../packages/dvss-integration-libs/src/integration-traffic-router/constants/traffic-router.constant.ts
|
|
597
599
|
var TRAFFIC_ROUTER_CONFIGURATION_STORE_KEY = "traffic-router-configuration-store";
|
|
598
600
|
|
|
599
|
-
// ../../packages/dvss-integration-libs/src/integration-operation-skeletons/auth/auth.base.ts
|
|
601
|
+
// ../../packages/dvss-integration-libs/src/integration-operation-skeletons/capabilities/auth/auth.base.ts
|
|
600
602
|
var BaseAuth = class {
|
|
601
603
|
static {
|
|
602
604
|
__name(this, "BaseAuth");
|
|
603
605
|
}
|
|
604
606
|
};
|
|
605
607
|
|
|
608
|
+
// ../../packages/dvss-integration-libs/src/integration-operation-skeletons/models/credit-management.model.ts
|
|
609
|
+
var CREDIT_TYPE_ENUM = /* @__PURE__ */ (function(CREDIT_TYPE_ENUM2) {
|
|
610
|
+
CREDIT_TYPE_ENUM2["COUPON"] = "COUPON";
|
|
611
|
+
CREDIT_TYPE_ENUM2["AMOUNT"] = "AMOUNT";
|
|
612
|
+
return CREDIT_TYPE_ENUM2;
|
|
613
|
+
})({});
|
|
614
|
+
var CREDIT_STATUS_ENUM = /* @__PURE__ */ (function(CREDIT_STATUS_ENUM2) {
|
|
615
|
+
CREDIT_STATUS_ENUM2["ACTIVE"] = "ACTIVE";
|
|
616
|
+
CREDIT_STATUS_ENUM2["REDEEMED"] = "REDEEMED";
|
|
617
|
+
CREDIT_STATUS_ENUM2["EXPIRED"] = "EXPIRED";
|
|
618
|
+
CREDIT_STATUS_ENUM2["REVOKED"] = "REVOKED";
|
|
619
|
+
return CREDIT_STATUS_ENUM2;
|
|
620
|
+
})({});
|
|
621
|
+
var CREDIT_FILTER_BY_ENUM = /* @__PURE__ */ (function(CREDIT_FILTER_BY_ENUM2) {
|
|
622
|
+
CREDIT_FILTER_BY_ENUM2["TYPE"] = "TYPE";
|
|
623
|
+
CREDIT_FILTER_BY_ENUM2["STATUS"] = "STATUS";
|
|
624
|
+
return CREDIT_FILTER_BY_ENUM2;
|
|
625
|
+
})({});
|
|
626
|
+
|
|
627
|
+
// ../../packages/dvss-integration-libs/src/integration-operation-skeletons/models/capability-integration.model.ts
|
|
628
|
+
var INTEGRATION_PROVIDER_ENUM = /* @__PURE__ */ (function(INTEGRATION_PROVIDER_ENUM2) {
|
|
629
|
+
INTEGRATION_PROVIDER_ENUM2["TRYBE"] = "TRYBE";
|
|
630
|
+
return INTEGRATION_PROVIDER_ENUM2;
|
|
631
|
+
})({});
|
|
632
|
+
|
|
633
|
+
// ../../packages/dvss-integration-libs/src/integration-operation-skeletons/models/wellness-management.model.ts
|
|
634
|
+
var BOOKABLE_ITEM_TYPE_ENUM = /* @__PURE__ */ (function(BOOKABLE_ITEM_TYPE_ENUM2) {
|
|
635
|
+
BOOKABLE_ITEM_TYPE_ENUM2["APPOINTMENT"] = "APPOINTMENT";
|
|
636
|
+
BOOKABLE_ITEM_TYPE_ENUM2["SESSION"] = "SESSION";
|
|
637
|
+
BOOKABLE_ITEM_TYPE_ENUM2["COURSE"] = "COURSE";
|
|
638
|
+
return BOOKABLE_ITEM_TYPE_ENUM2;
|
|
639
|
+
})({});
|
|
640
|
+
var BOOKABLE_ITEM_STATUS_ENUM = /* @__PURE__ */ (function(BOOKABLE_ITEM_STATUS_ENUM2) {
|
|
641
|
+
BOOKABLE_ITEM_STATUS_ENUM2["ACTIVE"] = "ACTIVE";
|
|
642
|
+
BOOKABLE_ITEM_STATUS_ENUM2["INACTIVE"] = "INACTIVE";
|
|
643
|
+
return BOOKABLE_ITEM_STATUS_ENUM2;
|
|
644
|
+
})({});
|
|
645
|
+
|
|
606
646
|
// ../../packages/dvss-integration-libs/src/integration-operation-skeletons/capabilities/wellness/wellness-management.base.ts
|
|
607
647
|
var BaseWellnessManagement = class {
|
|
608
648
|
static {
|
|
@@ -714,65 +754,2176 @@ var BaseMembershipManagement = class {
|
|
|
714
754
|
__name(this, "BaseMembershipManagement");
|
|
715
755
|
}
|
|
716
756
|
};
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
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 {
|
|
769
|
+
static {
|
|
770
|
+
__name(this, "BaseIntegrationConfiguration");
|
|
771
|
+
}
|
|
772
|
+
integrationConfigurationDao;
|
|
773
|
+
commonValidationDatabaseService;
|
|
774
|
+
logger;
|
|
775
|
+
fileName = "integration-configuration.base.ts";
|
|
776
|
+
constructor(integrationConfigurationDao, commonValidationDatabaseService, logger) {
|
|
777
|
+
this.integrationConfigurationDao = integrationConfigurationDao;
|
|
778
|
+
this.commonValidationDatabaseService = commonValidationDatabaseService;
|
|
779
|
+
this.logger = logger;
|
|
780
|
+
}
|
|
781
|
+
/**
|
|
782
|
+
* Validates add-capability-integration input (project, property, parent, capability, provider, configuredFor).
|
|
783
|
+
* Logic copied from project-ms CapabilityIntegrationService.validateAddCapabilityIntegrationInput.
|
|
784
|
+
*/
|
|
785
|
+
async validateAddCapabilityIntegrationInput(input, context) {
|
|
786
|
+
await this.commonValidationDatabaseService.getProject({
|
|
787
|
+
projectId: input.projectId
|
|
788
|
+
});
|
|
789
|
+
if (input.propertyId != null) {
|
|
790
|
+
await this.commonValidationDatabaseService.getProperty({
|
|
791
|
+
propertyId: input.propertyId,
|
|
792
|
+
projectId: input.projectId
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
if (input.parentId != null) {
|
|
796
|
+
const parentIntegration = await this.integrationConfigurationDao.getCapabilityIntegration({
|
|
797
|
+
capabilityIntegrationId: input.parentId
|
|
798
|
+
}, context.loggedInUserId);
|
|
799
|
+
if (!parentIntegration) {
|
|
800
|
+
throw new Error("Parent capability integration not found");
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
const [capability, capabilityProvider] = await Promise.all([
|
|
804
|
+
this.integrationConfigurationDao.getCapability({
|
|
805
|
+
capabilityId: input.capabilityId
|
|
806
|
+
}, context.loggedInUserId),
|
|
807
|
+
this.integrationConfigurationDao.getCapabilityProvider({
|
|
808
|
+
capabilityProviderId: input.capabilityProviderId
|
|
809
|
+
}, context.loggedInUserId)
|
|
810
|
+
]);
|
|
811
|
+
if (!capability) {
|
|
812
|
+
throw new Error("Capability not found");
|
|
813
|
+
}
|
|
814
|
+
if (!capabilityProvider) {
|
|
815
|
+
throw new Error("Capability provider not found");
|
|
816
|
+
}
|
|
817
|
+
if (capability.providerId !== capabilityProvider.id) {
|
|
818
|
+
throw new Error(`Capability provider mismatch: capabilityId=${capability.id}, capabilityProviderId=${capability.providerId}`);
|
|
819
|
+
}
|
|
820
|
+
return {
|
|
821
|
+
capability: {
|
|
822
|
+
id: capability.id,
|
|
823
|
+
type: capability.type,
|
|
824
|
+
category: capability.category,
|
|
825
|
+
providerId: capability.providerId
|
|
826
|
+
},
|
|
827
|
+
capabilityProvider: {
|
|
828
|
+
id: capabilityProvider.id
|
|
829
|
+
}
|
|
830
|
+
};
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Add a capability integration (validate then persist via DAO).
|
|
834
|
+
* Same name as project MS call: addCapabilityIntegration.
|
|
835
|
+
*/
|
|
836
|
+
async addCapabilityIntegration(input, context) {
|
|
837
|
+
const { capability, capabilityProvider } = await this.validateAddCapabilityIntegrationInput(input, context);
|
|
838
|
+
const addCapabilityIntegrationInput = {
|
|
839
|
+
...input,
|
|
840
|
+
providerId: capabilityProvider.id,
|
|
841
|
+
createdBy: context.loggedInUserId,
|
|
842
|
+
type: capability.type,
|
|
843
|
+
category: capability.category,
|
|
844
|
+
availableFor: input.availableFor,
|
|
845
|
+
configuredFor: input.configuredFor
|
|
846
|
+
};
|
|
847
|
+
const result = await this.integrationConfigurationDao.addCapabilityIntegration(addCapabilityIntegrationInput, context.loggedInUserId);
|
|
848
|
+
if (!result || !result.id) {
|
|
849
|
+
throw new Error("Failed to add capability integration");
|
|
850
|
+
}
|
|
851
|
+
return result;
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
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
|
|
861
|
+
*/
|
|
862
|
+
async updateCapabilityIntegration(request, integration, loggedInUserId) {
|
|
863
|
+
if (!loggedInUserId) {
|
|
864
|
+
throw new Error("loggedInUserId is required");
|
|
865
|
+
}
|
|
866
|
+
this.validateIconAndNickName(request.updateData, loggedInUserId);
|
|
867
|
+
let configToUpdate;
|
|
868
|
+
const updateData = request.updateData;
|
|
869
|
+
if (updateData.config && integration?.config) {
|
|
870
|
+
const existingConfig = integration.config;
|
|
871
|
+
configToUpdate = {
|
|
872
|
+
...existingConfig
|
|
873
|
+
};
|
|
874
|
+
const existingIntegrationConfig = existingConfig.integrationConfig || {};
|
|
875
|
+
configToUpdate.integrationConfig = {
|
|
876
|
+
...existingIntegrationConfig,
|
|
877
|
+
...updateData.config.integrationConfig
|
|
878
|
+
};
|
|
879
|
+
const existingPlatformConfig = existingConfig.platformConfig || {};
|
|
880
|
+
configToUpdate.platformConfig = {
|
|
881
|
+
...existingPlatformConfig,
|
|
882
|
+
...updateData.config.platformConfig
|
|
883
|
+
};
|
|
884
|
+
} else if (updateData.config) {
|
|
885
|
+
configToUpdate = updateData.config;
|
|
886
|
+
}
|
|
887
|
+
const updateDataForDao = {
|
|
888
|
+
nickname: updateData.nickname,
|
|
889
|
+
icon: updateData.icon,
|
|
890
|
+
config: configToUpdate,
|
|
891
|
+
parentId: updateData.parentId,
|
|
892
|
+
updatedBy: loggedInUserId
|
|
893
|
+
};
|
|
894
|
+
const result = await this.integrationConfigurationDao.updateCapabilityIntegration({
|
|
895
|
+
id: request.id,
|
|
896
|
+
updateData: updateDataForDao
|
|
897
|
+
}, loggedInUserId);
|
|
898
|
+
return result;
|
|
899
|
+
}
|
|
900
|
+
/**
|
|
901
|
+
* Validates icon and nickname. Can be overridden in subclasses for provider-specific validation.
|
|
902
|
+
*/
|
|
903
|
+
validateIconAndNickName(updateData, loggedInUserId) {
|
|
904
|
+
if (updateData.nickname !== void 0 && (updateData.nickname === "" || updateData.nickname.trim() === "")) {
|
|
905
|
+
this.logger.error(loggedInUserId, this.validateIconAndNickName.name, this.fileName, "Validation failed: nickname cannot be empty or null");
|
|
906
|
+
throw new Error("Nickname cannot be empty");
|
|
907
|
+
}
|
|
908
|
+
if (updateData.icon && updateData.icon.meta && typeof updateData.icon.meta === "object") {
|
|
909
|
+
const meta = updateData.icon.meta;
|
|
910
|
+
if (meta.iconName !== void 0 && (meta.iconName === null || meta.iconName === "" || typeof meta.iconName === "string" && meta.iconName.trim() === "")) {
|
|
911
|
+
this.logger.error(loggedInUserId, this.validateIconAndNickName.name, this.fileName, "Validation failed: iconName cannot be empty");
|
|
912
|
+
throw new Error("Icon name cannot be empty");
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
/**
|
|
917
|
+
* Get capability integrations with pagination, filtering, sorting, and search.
|
|
918
|
+
* Delegates to DAO for database operations.
|
|
919
|
+
*
|
|
920
|
+
* @param request - Request with projectId, category, and options
|
|
921
|
+
* @param loggedInUserId - User ID for logging
|
|
922
|
+
* @returns Promise resolving to list of capability integrations with total count
|
|
923
|
+
*/
|
|
924
|
+
async getCapabilityIntegrations(request, loggedInUserId) {
|
|
925
|
+
return await this.integrationConfigurationDao.getCapabilityIntegrations(request, loggedInUserId);
|
|
926
|
+
}
|
|
927
|
+
/**
|
|
928
|
+
* Get capability integration by id or by fetchBy (configuredFor).
|
|
929
|
+
* Same business logic as project-ms CapabilityIntegrationService.getCapabilityIntegration.
|
|
930
|
+
*/
|
|
931
|
+
async getCapabilityIntegration(input, context) {
|
|
932
|
+
if (!input.projectId) {
|
|
933
|
+
throw new Error("Project ID is required");
|
|
934
|
+
}
|
|
935
|
+
await this.commonValidationDatabaseService.getProject({
|
|
936
|
+
projectId: input.projectId
|
|
937
|
+
});
|
|
938
|
+
let integration;
|
|
939
|
+
if (input.id) {
|
|
940
|
+
integration = await this.integrationConfigurationDao.getCapabilityIntegrationById({
|
|
941
|
+
id: input.id,
|
|
942
|
+
projectId: input.projectId,
|
|
943
|
+
category: input.category
|
|
944
|
+
}, context.loggedInUserId);
|
|
945
|
+
} else if (input.fetchBy) {
|
|
946
|
+
integration = await this.integrationConfigurationDao.getCapabilityIntegrationByProvider({
|
|
947
|
+
projectId: input.projectId,
|
|
948
|
+
category: input.fetchBy.category ?? input.category,
|
|
949
|
+
configuredForType: input.fetchBy.configuredForType,
|
|
950
|
+
configuredForId: BigInt(input.fetchBy.configuredForId)
|
|
951
|
+
}, context.loggedInUserId);
|
|
952
|
+
}
|
|
953
|
+
if (!integration) {
|
|
954
|
+
throw new Error("Capability integration not found");
|
|
955
|
+
}
|
|
956
|
+
return integration;
|
|
957
|
+
}
|
|
958
|
+
};
|
|
959
|
+
exports.BaseIntegrationConfiguration = _ts_decorate11([
|
|
960
|
+
common.Injectable(),
|
|
961
|
+
_ts_metadata8("design:type", Function),
|
|
962
|
+
_ts_metadata8("design:paramtypes", [
|
|
963
|
+
typeof IntegrationConfigurationDao === "undefined" ? Object : IntegrationConfigurationDao,
|
|
964
|
+
typeof CommonValidationDatabaseService === "undefined" ? Object : CommonValidationDatabaseService,
|
|
965
|
+
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
|
|
966
|
+
])
|
|
967
|
+
], exports.BaseIntegrationConfiguration);
|
|
968
|
+
var BaseIntegrationResourceManagement = class {
|
|
969
|
+
static {
|
|
970
|
+
__name(this, "BaseIntegrationResourceManagement");
|
|
971
|
+
}
|
|
972
|
+
integrationResourceManagementDao;
|
|
973
|
+
logger;
|
|
974
|
+
fileName = "integration-resource-management.base";
|
|
975
|
+
constructor(integrationResourceManagementDao, logger) {
|
|
976
|
+
this.integrationResourceManagementDao = integrationResourceManagementDao;
|
|
977
|
+
this.logger = logger;
|
|
978
|
+
}
|
|
979
|
+
/**
|
|
980
|
+
* Adds a resource (capability integration) to an offering integration via UIF.
|
|
981
|
+
* Inter-service implementation only: performs DAO insert. Wrapper must validate
|
|
982
|
+
* config and mapping-exists before calling; caller (MS) does getOffering, getIntegration,
|
|
983
|
+
* updateOffering and runAfterAddIfNeeded.
|
|
984
|
+
*
|
|
985
|
+
* @param input - projectId, offeringId, capabilityIntegrationId, optional config
|
|
986
|
+
* @param context - GraphQL context
|
|
987
|
+
* @returns Promise resolving to { status, ids }
|
|
988
|
+
*/
|
|
989
|
+
async addResourceToIntegration(input, context) {
|
|
990
|
+
this.logger.info(context.loggedInUserId, this.addResourceToIntegration.name, this.fileName, "addResourceToIntegration called", {
|
|
991
|
+
offeringId: input.offeringId.toString(),
|
|
992
|
+
capabilityIntegrationId: input.capabilityIntegrationId.toString()
|
|
993
|
+
});
|
|
994
|
+
const addResult = await this.integrationResourceManagementDao.addCapabilityIntegrationMapping({
|
|
995
|
+
projectId: input.projectId,
|
|
996
|
+
capabilityIntegrationId: input.capabilityIntegrationId,
|
|
997
|
+
configuredForId: input.offeringId,
|
|
998
|
+
configuredForType: models.CONFIGURED_FOR_TYPE_ENUM.OFFERING,
|
|
999
|
+
config: input.config
|
|
1000
|
+
}, context);
|
|
1001
|
+
const result = {
|
|
1002
|
+
status: addResult.status,
|
|
1003
|
+
ids: addResult.ids
|
|
1004
|
+
};
|
|
1005
|
+
this.logger.info(context.loggedInUserId, this.addResourceToIntegration.name, this.fileName, "addResourceToIntegration completed", {
|
|
1006
|
+
status: result.status,
|
|
1007
|
+
idsCount: result.ids.length
|
|
1008
|
+
});
|
|
1009
|
+
return result;
|
|
1010
|
+
}
|
|
1011
|
+
/**
|
|
1012
|
+
* Removes a resource from an offering integration.
|
|
1013
|
+
* Generic validation and DAO call; Trybe service adds mapping-exists check before calling.
|
|
1014
|
+
*/
|
|
1015
|
+
async removeResourceFromIntegration(request, context) {
|
|
1016
|
+
const result = await this.integrationResourceManagementDao.removeCapabilityIntegrationMapping({
|
|
1017
|
+
capabilityIntegrationId: request.capabilityIntegrationId,
|
|
1018
|
+
configuredForId: request.offeringId,
|
|
1019
|
+
configuredForType: models.CONFIGURED_FOR_TYPE_ENUM.OFFERING
|
|
1020
|
+
}, context);
|
|
1021
|
+
return {
|
|
1022
|
+
status: result.status
|
|
1023
|
+
};
|
|
1024
|
+
}
|
|
1025
|
+
/**
|
|
1026
|
+
* Updates offering integration resource configuration (cap_integ_resource_mapping.config by id).
|
|
1027
|
+
* Inter-service implementation only: performs DAO update. Wrapper must validate config before calling
|
|
1028
|
+
* (e.g. Trybe validates via validateResourceMappingConfig). Caller (MS) does getOffering,
|
|
1029
|
+
* getIntegration, and runAfterUpdateIfNeeded (e.g. handleTrybeIntegration).
|
|
1030
|
+
*
|
|
1031
|
+
* @param input - id (resource mapping row id), config
|
|
1032
|
+
* @param context - GraphQL context
|
|
1033
|
+
* @returns Promise resolving to { status }
|
|
1034
|
+
*/
|
|
1035
|
+
async updateOfferingIntegrationResourceConfiguration(input, context) {
|
|
1036
|
+
this.logger.info(context.loggedInUserId, this.updateOfferingIntegrationResourceConfiguration.name, this.fileName, "updateOfferingIntegrationResourceConfiguration called", {
|
|
1037
|
+
id: input.id.toString()
|
|
1038
|
+
});
|
|
1039
|
+
const result = await this.integrationResourceManagementDao.updateCapabilityIntegrationConfiguration({
|
|
1040
|
+
id: input.id,
|
|
1041
|
+
config: input.config
|
|
1042
|
+
}, context);
|
|
1043
|
+
this.logger.info(context.loggedInUserId, this.updateOfferingIntegrationResourceConfiguration.name, this.fileName, "updateOfferingIntegrationResourceConfiguration completed", {
|
|
1044
|
+
status: result.status
|
|
1045
|
+
});
|
|
1046
|
+
return {
|
|
1047
|
+
status: result.status
|
|
1048
|
+
};
|
|
1049
|
+
}
|
|
1050
|
+
};
|
|
1051
|
+
|
|
1052
|
+
// ../../node_modules/drizzle-orm/entity.js
|
|
1053
|
+
var entityKind = /* @__PURE__ */ Symbol.for("drizzle:entityKind");
|
|
1054
|
+
function is(value, type) {
|
|
1055
|
+
if (!value || typeof value !== "object") {
|
|
1056
|
+
return false;
|
|
1057
|
+
}
|
|
1058
|
+
if (value instanceof type) {
|
|
1059
|
+
return true;
|
|
1060
|
+
}
|
|
1061
|
+
if (!Object.prototype.hasOwnProperty.call(type, entityKind)) {
|
|
1062
|
+
throw new Error(`Class "${type.name ?? "<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);
|
|
1063
|
+
}
|
|
1064
|
+
let cls = value.constructor;
|
|
1065
|
+
if (cls) {
|
|
1066
|
+
while (cls) {
|
|
1067
|
+
if (entityKind in cls && cls[entityKind] === type[entityKind]) {
|
|
1068
|
+
return true;
|
|
1069
|
+
}
|
|
1070
|
+
cls = Object.getPrototypeOf(cls);
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
return false;
|
|
1074
|
+
}
|
|
1075
|
+
__name(is, "is");
|
|
1076
|
+
|
|
1077
|
+
// ../../node_modules/drizzle-orm/column.js
|
|
1078
|
+
var Column = class Column2 {
|
|
1079
|
+
static {
|
|
1080
|
+
__name(this, "Column");
|
|
1081
|
+
}
|
|
1082
|
+
constructor(table, config3) {
|
|
1083
|
+
this.table = table;
|
|
1084
|
+
this.config = config3;
|
|
1085
|
+
this.name = config3.name;
|
|
1086
|
+
this.notNull = config3.notNull;
|
|
1087
|
+
this.default = config3.default;
|
|
1088
|
+
this.defaultFn = config3.defaultFn;
|
|
1089
|
+
this.onUpdateFn = config3.onUpdateFn;
|
|
1090
|
+
this.hasDefault = config3.hasDefault;
|
|
1091
|
+
this.primary = config3.primaryKey;
|
|
1092
|
+
this.isUnique = config3.isUnique;
|
|
1093
|
+
this.uniqueName = config3.uniqueName;
|
|
1094
|
+
this.uniqueType = config3.uniqueType;
|
|
1095
|
+
this.dataType = config3.dataType;
|
|
1096
|
+
this.columnType = config3.columnType;
|
|
1097
|
+
this.generated = config3.generated;
|
|
1098
|
+
this.generatedIdentity = config3.generatedIdentity;
|
|
1099
|
+
}
|
|
1100
|
+
static [entityKind] = "Column";
|
|
1101
|
+
name;
|
|
1102
|
+
primary;
|
|
1103
|
+
notNull;
|
|
1104
|
+
default;
|
|
1105
|
+
defaultFn;
|
|
1106
|
+
onUpdateFn;
|
|
1107
|
+
hasDefault;
|
|
1108
|
+
isUnique;
|
|
1109
|
+
uniqueName;
|
|
1110
|
+
uniqueType;
|
|
1111
|
+
dataType;
|
|
1112
|
+
columnType;
|
|
1113
|
+
enumValues = void 0;
|
|
1114
|
+
generated = void 0;
|
|
1115
|
+
generatedIdentity = void 0;
|
|
1116
|
+
config;
|
|
1117
|
+
mapFromDriverValue(value) {
|
|
1118
|
+
return value;
|
|
1119
|
+
}
|
|
1120
|
+
mapToDriverValue(value) {
|
|
1121
|
+
return value;
|
|
1122
|
+
}
|
|
1123
|
+
// ** @internal */
|
|
1124
|
+
shouldDisableInsert() {
|
|
1125
|
+
return this.config.generated !== void 0 && this.config.generated.type !== "byDefault";
|
|
1126
|
+
}
|
|
1127
|
+
};
|
|
1128
|
+
|
|
1129
|
+
// ../../node_modules/drizzle-orm/column-builder.js
|
|
1130
|
+
var ColumnBuilder = class ColumnBuilder2 {
|
|
1131
|
+
static {
|
|
1132
|
+
__name(this, "ColumnBuilder");
|
|
1133
|
+
}
|
|
1134
|
+
static [entityKind] = "ColumnBuilder";
|
|
1135
|
+
config;
|
|
1136
|
+
constructor(name, dataType, columnType) {
|
|
1137
|
+
this.config = {
|
|
1138
|
+
name,
|
|
1139
|
+
notNull: false,
|
|
1140
|
+
default: void 0,
|
|
1141
|
+
hasDefault: false,
|
|
1142
|
+
primaryKey: false,
|
|
1143
|
+
isUnique: false,
|
|
1144
|
+
uniqueName: void 0,
|
|
1145
|
+
uniqueType: void 0,
|
|
1146
|
+
dataType,
|
|
1147
|
+
columnType,
|
|
1148
|
+
generated: void 0
|
|
1149
|
+
};
|
|
1150
|
+
}
|
|
1151
|
+
/**
|
|
1152
|
+
* Changes the data type of the column. Commonly used with `json` columns. Also, useful for branded types.
|
|
1153
|
+
*
|
|
1154
|
+
* @example
|
|
1155
|
+
* ```ts
|
|
1156
|
+
* const users = pgTable('users', {
|
|
1157
|
+
* id: integer('id').$type<UserId>().primaryKey(),
|
|
1158
|
+
* details: json('details').$type<UserDetails>().notNull(),
|
|
1159
|
+
* });
|
|
1160
|
+
* ```
|
|
1161
|
+
*/
|
|
1162
|
+
$type() {
|
|
1163
|
+
return this;
|
|
1164
|
+
}
|
|
1165
|
+
/**
|
|
1166
|
+
* Adds a `not null` clause to the column definition.
|
|
1167
|
+
*
|
|
1168
|
+
* Affects the `select` model of the table - columns *without* `not null` will be nullable on select.
|
|
1169
|
+
*/
|
|
1170
|
+
notNull() {
|
|
1171
|
+
this.config.notNull = true;
|
|
1172
|
+
return this;
|
|
1173
|
+
}
|
|
1174
|
+
/**
|
|
1175
|
+
* Adds a `default <value>` clause to the column definition.
|
|
1176
|
+
*
|
|
1177
|
+
* Affects the `insert` model of the table - columns *with* `default` are optional on insert.
|
|
1178
|
+
*
|
|
1179
|
+
* If you need to set a dynamic default value, use {@link $defaultFn} instead.
|
|
1180
|
+
*/
|
|
1181
|
+
default(value) {
|
|
1182
|
+
this.config.default = value;
|
|
1183
|
+
this.config.hasDefault = true;
|
|
1184
|
+
return this;
|
|
1185
|
+
}
|
|
1186
|
+
/**
|
|
1187
|
+
* Adds a dynamic default value to the column.
|
|
1188
|
+
* The function will be called when the row is inserted, and the returned value will be used as the column value.
|
|
1189
|
+
*
|
|
1190
|
+
* **Note:** This value does not affect the `drizzle-kit` behavior, it is only used at runtime in `drizzle-orm`.
|
|
1191
|
+
*/
|
|
1192
|
+
$defaultFn(fn) {
|
|
1193
|
+
this.config.defaultFn = fn;
|
|
1194
|
+
this.config.hasDefault = true;
|
|
1195
|
+
return this;
|
|
1196
|
+
}
|
|
1197
|
+
/**
|
|
1198
|
+
* Alias for {@link $defaultFn}.
|
|
1199
|
+
*/
|
|
1200
|
+
$default = this.$defaultFn;
|
|
1201
|
+
/**
|
|
1202
|
+
* Adds a dynamic update value to the column.
|
|
1203
|
+
* The function will be called when the row is updated, and the returned value will be used as the column value if none is provided.
|
|
1204
|
+
* If no `default` (or `$defaultFn`) value is provided, the function will be called when the row is inserted as well, and the returned value will be used as the column value.
|
|
1205
|
+
*
|
|
1206
|
+
* **Note:** This value does not affect the `drizzle-kit` behavior, it is only used at runtime in `drizzle-orm`.
|
|
1207
|
+
*/
|
|
1208
|
+
$onUpdateFn(fn) {
|
|
1209
|
+
this.config.onUpdateFn = fn;
|
|
1210
|
+
this.config.hasDefault = true;
|
|
1211
|
+
return this;
|
|
1212
|
+
}
|
|
1213
|
+
/**
|
|
1214
|
+
* Alias for {@link $onUpdateFn}.
|
|
1215
|
+
*/
|
|
1216
|
+
$onUpdate = this.$onUpdateFn;
|
|
1217
|
+
/**
|
|
1218
|
+
* Adds a `primary key` clause to the column definition. This implicitly makes the column `not null`.
|
|
1219
|
+
*
|
|
1220
|
+
* In SQLite, `integer primary key` implicitly makes the column auto-incrementing.
|
|
1221
|
+
*/
|
|
1222
|
+
primaryKey() {
|
|
1223
|
+
this.config.primaryKey = true;
|
|
1224
|
+
this.config.notNull = true;
|
|
1225
|
+
return this;
|
|
1226
|
+
}
|
|
1227
|
+
};
|
|
1228
|
+
|
|
1229
|
+
// ../../node_modules/drizzle-orm/table.js
|
|
1230
|
+
var TableName = /* @__PURE__ */ Symbol.for("drizzle:Name");
|
|
1231
|
+
var Schema = /* @__PURE__ */ Symbol.for("drizzle:Schema");
|
|
1232
|
+
var Columns = /* @__PURE__ */ Symbol.for("drizzle:Columns");
|
|
1233
|
+
var ExtraConfigColumns = /* @__PURE__ */ Symbol.for("drizzle:ExtraConfigColumns");
|
|
1234
|
+
var OriginalName = /* @__PURE__ */ Symbol.for("drizzle:OriginalName");
|
|
1235
|
+
var BaseName = /* @__PURE__ */ Symbol.for("drizzle:BaseName");
|
|
1236
|
+
var IsAlias = /* @__PURE__ */ Symbol.for("drizzle:IsAlias");
|
|
1237
|
+
var ExtraConfigBuilder = /* @__PURE__ */ Symbol.for("drizzle:ExtraConfigBuilder");
|
|
1238
|
+
var IsDrizzleTable = /* @__PURE__ */ Symbol.for("drizzle:IsDrizzleTable");
|
|
1239
|
+
var Table = class Table2 {
|
|
1240
|
+
static {
|
|
1241
|
+
__name(this, "Table");
|
|
1242
|
+
}
|
|
1243
|
+
static [entityKind] = "Table";
|
|
1244
|
+
/** @internal */
|
|
1245
|
+
static Symbol = {
|
|
1246
|
+
Name: TableName,
|
|
1247
|
+
Schema,
|
|
1248
|
+
OriginalName,
|
|
1249
|
+
Columns,
|
|
1250
|
+
ExtraConfigColumns,
|
|
1251
|
+
BaseName,
|
|
1252
|
+
IsAlias,
|
|
1253
|
+
ExtraConfigBuilder
|
|
1254
|
+
};
|
|
1255
|
+
/**
|
|
1256
|
+
* @internal
|
|
1257
|
+
* Can be changed if the table is aliased.
|
|
1258
|
+
*/
|
|
1259
|
+
[TableName];
|
|
1260
|
+
/**
|
|
1261
|
+
* @internal
|
|
1262
|
+
* Used to store the original name of the table, before any aliasing.
|
|
1263
|
+
*/
|
|
1264
|
+
[OriginalName];
|
|
1265
|
+
/** @internal */
|
|
1266
|
+
[Schema];
|
|
1267
|
+
/** @internal */
|
|
1268
|
+
[Columns];
|
|
1269
|
+
/** @internal */
|
|
1270
|
+
[ExtraConfigColumns];
|
|
1271
|
+
/**
|
|
1272
|
+
* @internal
|
|
1273
|
+
* Used to store the table name before the transformation via the `tableCreator` functions.
|
|
1274
|
+
*/
|
|
1275
|
+
[BaseName];
|
|
1276
|
+
/** @internal */
|
|
1277
|
+
[IsAlias] = false;
|
|
1278
|
+
/** @internal */
|
|
1279
|
+
[IsDrizzleTable] = true;
|
|
1280
|
+
/** @internal */
|
|
1281
|
+
[ExtraConfigBuilder] = void 0;
|
|
1282
|
+
constructor(name, schema3, baseName) {
|
|
1283
|
+
this[TableName] = this[OriginalName] = name;
|
|
1284
|
+
this[Schema] = schema3;
|
|
1285
|
+
this[BaseName] = baseName;
|
|
1286
|
+
}
|
|
1287
|
+
};
|
|
1288
|
+
|
|
1289
|
+
// ../../node_modules/drizzle-orm/pg-core/table.js
|
|
1290
|
+
var InlineForeignKeys = /* @__PURE__ */ Symbol.for("drizzle:PgInlineForeignKeys");
|
|
1291
|
+
var PgTable = class PgTable2 extends Table {
|
|
1292
|
+
static {
|
|
1293
|
+
__name(this, "PgTable");
|
|
1294
|
+
}
|
|
1295
|
+
static [entityKind] = "PgTable";
|
|
1296
|
+
/** @internal */
|
|
1297
|
+
static Symbol = Object.assign({}, Table.Symbol, {
|
|
1298
|
+
InlineForeignKeys
|
|
1299
|
+
});
|
|
1300
|
+
/**@internal */
|
|
1301
|
+
[InlineForeignKeys] = [];
|
|
1302
|
+
/** @internal */
|
|
1303
|
+
[Table.Symbol.ExtraConfigBuilder] = void 0;
|
|
1304
|
+
};
|
|
1305
|
+
|
|
1306
|
+
// ../../node_modules/drizzle-orm/pg-core/foreign-keys.js
|
|
1307
|
+
var ForeignKeyBuilder = class ForeignKeyBuilder2 {
|
|
1308
|
+
static {
|
|
1309
|
+
__name(this, "ForeignKeyBuilder");
|
|
1310
|
+
}
|
|
1311
|
+
static [entityKind] = "PgForeignKeyBuilder";
|
|
1312
|
+
/** @internal */
|
|
1313
|
+
reference;
|
|
1314
|
+
/** @internal */
|
|
1315
|
+
_onUpdate = "no action";
|
|
1316
|
+
/** @internal */
|
|
1317
|
+
_onDelete = "no action";
|
|
1318
|
+
constructor(config3, actions) {
|
|
1319
|
+
this.reference = () => {
|
|
1320
|
+
const { name, columns, foreignColumns } = config3();
|
|
1321
|
+
return {
|
|
1322
|
+
name,
|
|
1323
|
+
columns,
|
|
1324
|
+
foreignTable: foreignColumns[0].table,
|
|
1325
|
+
foreignColumns
|
|
1326
|
+
};
|
|
1327
|
+
};
|
|
1328
|
+
if (actions) {
|
|
1329
|
+
this._onUpdate = actions.onUpdate;
|
|
1330
|
+
this._onDelete = actions.onDelete;
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
onUpdate(action) {
|
|
1334
|
+
this._onUpdate = action === void 0 ? "no action" : action;
|
|
1335
|
+
return this;
|
|
1336
|
+
}
|
|
1337
|
+
onDelete(action) {
|
|
1338
|
+
this._onDelete = action === void 0 ? "no action" : action;
|
|
1339
|
+
return this;
|
|
1340
|
+
}
|
|
1341
|
+
/** @internal */
|
|
1342
|
+
build(table) {
|
|
1343
|
+
return new ForeignKey(table, this);
|
|
1344
|
+
}
|
|
1345
|
+
};
|
|
1346
|
+
var ForeignKey = class ForeignKey2 {
|
|
1347
|
+
static {
|
|
1348
|
+
__name(this, "ForeignKey");
|
|
1349
|
+
}
|
|
1350
|
+
constructor(table, builder) {
|
|
1351
|
+
this.table = table;
|
|
1352
|
+
this.reference = builder.reference;
|
|
1353
|
+
this.onUpdate = builder._onUpdate;
|
|
1354
|
+
this.onDelete = builder._onDelete;
|
|
1355
|
+
}
|
|
1356
|
+
static [entityKind] = "PgForeignKey";
|
|
1357
|
+
reference;
|
|
1358
|
+
onUpdate;
|
|
1359
|
+
onDelete;
|
|
1360
|
+
getName() {
|
|
1361
|
+
const { name, columns, foreignColumns } = this.reference();
|
|
1362
|
+
const columnNames = columns.map((column) => column.name);
|
|
1363
|
+
const foreignColumnNames = foreignColumns.map((column) => column.name);
|
|
1364
|
+
const chunks = [
|
|
1365
|
+
this.table[PgTable.Symbol.Name],
|
|
1366
|
+
...columnNames,
|
|
1367
|
+
foreignColumns[0].table[PgTable.Symbol.Name],
|
|
1368
|
+
...foreignColumnNames
|
|
1369
|
+
];
|
|
1370
|
+
return name ?? `${chunks.join("_")}_fk`;
|
|
1371
|
+
}
|
|
1372
|
+
};
|
|
1373
|
+
|
|
1374
|
+
// ../../node_modules/drizzle-orm/tracing-utils.js
|
|
1375
|
+
function iife(fn, ...args) {
|
|
1376
|
+
return fn(...args);
|
|
1377
|
+
}
|
|
1378
|
+
__name(iife, "iife");
|
|
1379
|
+
|
|
1380
|
+
// ../../node_modules/drizzle-orm/pg-core/unique-constraint.js
|
|
1381
|
+
function uniqueKeyName(table, columns) {
|
|
1382
|
+
return `${table[PgTable.Symbol.Name]}_${columns.join("_")}_unique`;
|
|
1383
|
+
}
|
|
1384
|
+
__name(uniqueKeyName, "uniqueKeyName");
|
|
1385
|
+
var UniqueConstraintBuilder = class UniqueConstraintBuilder2 {
|
|
1386
|
+
static {
|
|
1387
|
+
__name(this, "UniqueConstraintBuilder");
|
|
1388
|
+
}
|
|
1389
|
+
constructor(columns, name) {
|
|
1390
|
+
this.name = name;
|
|
1391
|
+
this.columns = columns;
|
|
1392
|
+
}
|
|
1393
|
+
static [entityKind] = "PgUniqueConstraintBuilder";
|
|
1394
|
+
/** @internal */
|
|
1395
|
+
columns;
|
|
1396
|
+
/** @internal */
|
|
1397
|
+
nullsNotDistinctConfig = false;
|
|
1398
|
+
nullsNotDistinct() {
|
|
1399
|
+
this.nullsNotDistinctConfig = true;
|
|
1400
|
+
return this;
|
|
1401
|
+
}
|
|
1402
|
+
/** @internal */
|
|
1403
|
+
build(table) {
|
|
1404
|
+
return new UniqueConstraint(table, this.columns, this.nullsNotDistinctConfig, this.name);
|
|
1405
|
+
}
|
|
1406
|
+
};
|
|
1407
|
+
(class UniqueOnConstraintBuilder2 {
|
|
1408
|
+
static {
|
|
1409
|
+
__name(this, "UniqueOnConstraintBuilder");
|
|
1410
|
+
}
|
|
1411
|
+
static [entityKind] = "PgUniqueOnConstraintBuilder";
|
|
1412
|
+
/** @internal */
|
|
1413
|
+
name;
|
|
1414
|
+
constructor(name) {
|
|
1415
|
+
this.name = name;
|
|
1416
|
+
}
|
|
1417
|
+
on(...columns) {
|
|
1418
|
+
return new UniqueConstraintBuilder(columns, this.name);
|
|
1419
|
+
}
|
|
1420
|
+
});
|
|
1421
|
+
var UniqueConstraint = class UniqueConstraint2 {
|
|
1422
|
+
static {
|
|
1423
|
+
__name(this, "UniqueConstraint");
|
|
1424
|
+
}
|
|
1425
|
+
constructor(table, columns, nullsNotDistinct, name) {
|
|
1426
|
+
this.table = table;
|
|
1427
|
+
this.columns = columns;
|
|
1428
|
+
this.name = name ?? uniqueKeyName(this.table, this.columns.map((column) => column.name));
|
|
1429
|
+
this.nullsNotDistinct = nullsNotDistinct;
|
|
1430
|
+
}
|
|
1431
|
+
static [entityKind] = "PgUniqueConstraint";
|
|
1432
|
+
columns;
|
|
1433
|
+
name;
|
|
1434
|
+
nullsNotDistinct = false;
|
|
1435
|
+
getName() {
|
|
1436
|
+
return this.name;
|
|
1437
|
+
}
|
|
1438
|
+
};
|
|
1439
|
+
|
|
1440
|
+
// ../../node_modules/drizzle-orm/pg-core/utils/array.js
|
|
1441
|
+
function parsePgArrayValue(arrayString, startFrom, inQuotes) {
|
|
1442
|
+
for (let i = startFrom; i < arrayString.length; i++) {
|
|
1443
|
+
const char = arrayString[i];
|
|
1444
|
+
if (char === "\\") {
|
|
1445
|
+
i++;
|
|
1446
|
+
continue;
|
|
1447
|
+
}
|
|
1448
|
+
if (char === '"') {
|
|
1449
|
+
return [
|
|
1450
|
+
arrayString.slice(startFrom, i).replace(/\\/g, ""),
|
|
1451
|
+
i + 1
|
|
1452
|
+
];
|
|
1453
|
+
}
|
|
1454
|
+
if (inQuotes) {
|
|
1455
|
+
continue;
|
|
1456
|
+
}
|
|
1457
|
+
if (char === "," || char === "}") {
|
|
1458
|
+
return [
|
|
1459
|
+
arrayString.slice(startFrom, i).replace(/\\/g, ""),
|
|
1460
|
+
i
|
|
1461
|
+
];
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
return [
|
|
1465
|
+
arrayString.slice(startFrom).replace(/\\/g, ""),
|
|
1466
|
+
arrayString.length
|
|
1467
|
+
];
|
|
1468
|
+
}
|
|
1469
|
+
__name(parsePgArrayValue, "parsePgArrayValue");
|
|
1470
|
+
function parsePgNestedArray(arrayString, startFrom = 0) {
|
|
1471
|
+
const result = [];
|
|
1472
|
+
let i = startFrom;
|
|
1473
|
+
let lastCharIsComma = false;
|
|
1474
|
+
while (i < arrayString.length) {
|
|
1475
|
+
const char = arrayString[i];
|
|
1476
|
+
if (char === ",") {
|
|
1477
|
+
if (lastCharIsComma || i === startFrom) {
|
|
1478
|
+
result.push("");
|
|
1479
|
+
}
|
|
1480
|
+
lastCharIsComma = true;
|
|
1481
|
+
i++;
|
|
1482
|
+
continue;
|
|
1483
|
+
}
|
|
1484
|
+
lastCharIsComma = false;
|
|
1485
|
+
if (char === "\\") {
|
|
1486
|
+
i += 2;
|
|
1487
|
+
continue;
|
|
1488
|
+
}
|
|
1489
|
+
if (char === '"') {
|
|
1490
|
+
const [value2, startFrom2] = parsePgArrayValue(arrayString, i + 1, true);
|
|
1491
|
+
result.push(value2);
|
|
1492
|
+
i = startFrom2;
|
|
1493
|
+
continue;
|
|
1494
|
+
}
|
|
1495
|
+
if (char === "}") {
|
|
1496
|
+
return [
|
|
1497
|
+
result,
|
|
1498
|
+
i + 1
|
|
1499
|
+
];
|
|
1500
|
+
}
|
|
1501
|
+
if (char === "{") {
|
|
1502
|
+
const [value2, startFrom2] = parsePgNestedArray(arrayString, i + 1);
|
|
1503
|
+
result.push(value2);
|
|
1504
|
+
i = startFrom2;
|
|
1505
|
+
continue;
|
|
1506
|
+
}
|
|
1507
|
+
const [value, newStartFrom] = parsePgArrayValue(arrayString, i, false);
|
|
1508
|
+
result.push(value);
|
|
1509
|
+
i = newStartFrom;
|
|
1510
|
+
}
|
|
1511
|
+
return [
|
|
1512
|
+
result,
|
|
1513
|
+
i
|
|
1514
|
+
];
|
|
1515
|
+
}
|
|
1516
|
+
__name(parsePgNestedArray, "parsePgNestedArray");
|
|
1517
|
+
function parsePgArray(arrayString) {
|
|
1518
|
+
const [result] = parsePgNestedArray(arrayString, 1);
|
|
1519
|
+
return result;
|
|
1520
|
+
}
|
|
1521
|
+
__name(parsePgArray, "parsePgArray");
|
|
1522
|
+
function makePgArray(array) {
|
|
1523
|
+
return `{${array.map((item) => {
|
|
1524
|
+
if (Array.isArray(item)) {
|
|
1525
|
+
return makePgArray(item);
|
|
1526
|
+
}
|
|
1527
|
+
if (typeof item === "string") {
|
|
1528
|
+
return `"${item.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
1529
|
+
}
|
|
1530
|
+
return `${item}`;
|
|
1531
|
+
}).join(",")}}`;
|
|
1532
|
+
}
|
|
1533
|
+
__name(makePgArray, "makePgArray");
|
|
1534
|
+
|
|
1535
|
+
// ../../node_modules/drizzle-orm/pg-core/columns/common.js
|
|
1536
|
+
var PgColumnBuilder = class PgColumnBuilder2 extends ColumnBuilder {
|
|
1537
|
+
static {
|
|
1538
|
+
__name(this, "PgColumnBuilder");
|
|
1539
|
+
}
|
|
1540
|
+
foreignKeyConfigs = [];
|
|
1541
|
+
static [entityKind] = "PgColumnBuilder";
|
|
1542
|
+
array(size) {
|
|
1543
|
+
return new PgArrayBuilder(this.config.name, this, size);
|
|
1544
|
+
}
|
|
1545
|
+
references(ref, actions = {}) {
|
|
1546
|
+
this.foreignKeyConfigs.push({
|
|
1547
|
+
ref,
|
|
1548
|
+
actions
|
|
1549
|
+
});
|
|
1550
|
+
return this;
|
|
1551
|
+
}
|
|
1552
|
+
unique(name, config3) {
|
|
1553
|
+
this.config.isUnique = true;
|
|
1554
|
+
this.config.uniqueName = name;
|
|
1555
|
+
this.config.uniqueType = config3?.nulls;
|
|
1556
|
+
return this;
|
|
1557
|
+
}
|
|
1558
|
+
generatedAlwaysAs(as) {
|
|
1559
|
+
this.config.generated = {
|
|
1560
|
+
as,
|
|
1561
|
+
type: "always",
|
|
1562
|
+
mode: "stored"
|
|
1563
|
+
};
|
|
1564
|
+
return this;
|
|
1565
|
+
}
|
|
1566
|
+
/** @internal */
|
|
1567
|
+
buildForeignKeys(column, table) {
|
|
1568
|
+
return this.foreignKeyConfigs.map(({ ref, actions }) => {
|
|
1569
|
+
return iife((ref2, actions2) => {
|
|
1570
|
+
const builder = new ForeignKeyBuilder(() => {
|
|
1571
|
+
const foreignColumn = ref2();
|
|
1572
|
+
return {
|
|
1573
|
+
columns: [
|
|
1574
|
+
column
|
|
1575
|
+
],
|
|
1576
|
+
foreignColumns: [
|
|
1577
|
+
foreignColumn
|
|
1578
|
+
]
|
|
1579
|
+
};
|
|
1580
|
+
});
|
|
1581
|
+
if (actions2.onUpdate) {
|
|
1582
|
+
builder.onUpdate(actions2.onUpdate);
|
|
1583
|
+
}
|
|
1584
|
+
if (actions2.onDelete) {
|
|
1585
|
+
builder.onDelete(actions2.onDelete);
|
|
1586
|
+
}
|
|
1587
|
+
return builder.build(table);
|
|
1588
|
+
}, ref, actions);
|
|
1589
|
+
});
|
|
1590
|
+
}
|
|
1591
|
+
/** @internal */
|
|
1592
|
+
buildExtraConfigColumn(table) {
|
|
1593
|
+
return new ExtraConfigColumn(table, this.config);
|
|
1594
|
+
}
|
|
1595
|
+
};
|
|
1596
|
+
var PgColumn = class PgColumn2 extends Column {
|
|
1597
|
+
static {
|
|
1598
|
+
__name(this, "PgColumn");
|
|
1599
|
+
}
|
|
1600
|
+
constructor(table, config3) {
|
|
1601
|
+
if (!config3.uniqueName) {
|
|
1602
|
+
config3.uniqueName = uniqueKeyName(table, [
|
|
1603
|
+
config3.name
|
|
1604
|
+
]);
|
|
1605
|
+
}
|
|
1606
|
+
super(table, config3);
|
|
1607
|
+
this.table = table;
|
|
1608
|
+
}
|
|
1609
|
+
static [entityKind] = "PgColumn";
|
|
1610
|
+
};
|
|
1611
|
+
var ExtraConfigColumn = class ExtraConfigColumn2 extends PgColumn {
|
|
1612
|
+
static {
|
|
1613
|
+
__name(this, "ExtraConfigColumn");
|
|
1614
|
+
}
|
|
1615
|
+
static [entityKind] = "ExtraConfigColumn";
|
|
1616
|
+
getSQLType() {
|
|
1617
|
+
return this.getSQLType();
|
|
1618
|
+
}
|
|
1619
|
+
indexConfig = {
|
|
1620
|
+
order: this.config.order ?? "asc",
|
|
1621
|
+
nulls: this.config.nulls ?? "last",
|
|
1622
|
+
opClass: this.config.opClass
|
|
1623
|
+
};
|
|
1624
|
+
defaultConfig = {
|
|
1625
|
+
order: "asc",
|
|
1626
|
+
nulls: "last",
|
|
1627
|
+
opClass: void 0
|
|
1628
|
+
};
|
|
1629
|
+
asc() {
|
|
1630
|
+
this.indexConfig.order = "asc";
|
|
1631
|
+
return this;
|
|
1632
|
+
}
|
|
1633
|
+
desc() {
|
|
1634
|
+
this.indexConfig.order = "desc";
|
|
1635
|
+
return this;
|
|
1636
|
+
}
|
|
1637
|
+
nullsFirst() {
|
|
1638
|
+
this.indexConfig.nulls = "first";
|
|
1639
|
+
return this;
|
|
1640
|
+
}
|
|
1641
|
+
nullsLast() {
|
|
1642
|
+
this.indexConfig.nulls = "last";
|
|
1643
|
+
return this;
|
|
1644
|
+
}
|
|
1645
|
+
/**
|
|
1646
|
+
* ### PostgreSQL documentation quote
|
|
1647
|
+
*
|
|
1648
|
+
* > An operator class with optional parameters can be specified for each column of an index.
|
|
1649
|
+
* The operator class identifies the operators to be used by the index for that column.
|
|
1650
|
+
* For example, a B-tree index on four-byte integers would use the int4_ops class;
|
|
1651
|
+
* this operator class includes comparison functions for four-byte integers.
|
|
1652
|
+
* In practice the default operator class for the column's data type is usually sufficient.
|
|
1653
|
+
* The main point of having operator classes is that for some data types, there could be more than one meaningful ordering.
|
|
1654
|
+
* For example, we might want to sort a complex-number data type either by absolute value or by real part.
|
|
1655
|
+
* We could do this by defining two operator classes for the data type and then selecting the proper class when creating an index.
|
|
1656
|
+
* More information about operator classes check:
|
|
1657
|
+
*
|
|
1658
|
+
* ### Useful links
|
|
1659
|
+
* https://www.postgresql.org/docs/current/sql-createindex.html
|
|
1660
|
+
*
|
|
1661
|
+
* https://www.postgresql.org/docs/current/indexes-opclass.html
|
|
1662
|
+
*
|
|
1663
|
+
* https://www.postgresql.org/docs/current/xindex.html
|
|
1664
|
+
*
|
|
1665
|
+
* ### Additional types
|
|
1666
|
+
* If you have the `pg_vector` extension installed in your database, you can use the
|
|
1667
|
+
* `vector_l2_ops`, `vector_ip_ops`, `vector_cosine_ops`, `vector_l1_ops`, `bit_hamming_ops`, `bit_jaccard_ops`, `halfvec_l2_ops`, `sparsevec_l2_ops` options, which are predefined types.
|
|
1668
|
+
*
|
|
1669
|
+
* **You can always specify any string you want in the operator class, in case Drizzle doesn't have it natively in its types**
|
|
1670
|
+
*
|
|
1671
|
+
* @param opClass
|
|
1672
|
+
* @returns
|
|
1673
|
+
*/
|
|
1674
|
+
op(opClass) {
|
|
1675
|
+
this.indexConfig.opClass = opClass;
|
|
1676
|
+
return this;
|
|
1677
|
+
}
|
|
1678
|
+
};
|
|
1679
|
+
(class IndexedColumn2 {
|
|
1680
|
+
static {
|
|
1681
|
+
__name(this, "IndexedColumn");
|
|
1682
|
+
}
|
|
1683
|
+
static [entityKind] = "IndexedColumn";
|
|
1684
|
+
constructor(name, type, indexConfig) {
|
|
1685
|
+
this.name = name;
|
|
1686
|
+
this.type = type;
|
|
1687
|
+
this.indexConfig = indexConfig;
|
|
1688
|
+
}
|
|
1689
|
+
name;
|
|
1690
|
+
type;
|
|
1691
|
+
indexConfig;
|
|
1692
|
+
});
|
|
1693
|
+
var PgArrayBuilder = class PgArrayBuilder2 extends PgColumnBuilder {
|
|
1694
|
+
static {
|
|
1695
|
+
__name(this, "PgArrayBuilder");
|
|
1696
|
+
}
|
|
1697
|
+
static [entityKind] = "PgArrayBuilder";
|
|
1698
|
+
constructor(name, baseBuilder, size) {
|
|
1699
|
+
super(name, "array", "PgArray");
|
|
1700
|
+
this.config.baseBuilder = baseBuilder;
|
|
1701
|
+
this.config.size = size;
|
|
1702
|
+
}
|
|
1703
|
+
/** @internal */
|
|
1704
|
+
build(table) {
|
|
1705
|
+
const baseColumn = this.config.baseBuilder.build(table);
|
|
1706
|
+
return new PgArray(table, this.config, baseColumn);
|
|
1707
|
+
}
|
|
1708
|
+
};
|
|
1709
|
+
var PgArray = class PgArray2 extends PgColumn {
|
|
1710
|
+
static {
|
|
1711
|
+
__name(this, "PgArray");
|
|
1712
|
+
}
|
|
1713
|
+
constructor(table, config3, baseColumn, range) {
|
|
1714
|
+
super(table, config3);
|
|
1715
|
+
this.baseColumn = baseColumn;
|
|
1716
|
+
this.range = range;
|
|
1717
|
+
this.size = config3.size;
|
|
1718
|
+
}
|
|
1719
|
+
size;
|
|
1720
|
+
static [entityKind] = "PgArray";
|
|
1721
|
+
getSQLType() {
|
|
1722
|
+
return `${this.baseColumn.getSQLType()}[${typeof this.size === "number" ? this.size : ""}]`;
|
|
1723
|
+
}
|
|
1724
|
+
mapFromDriverValue(value) {
|
|
1725
|
+
if (typeof value === "string") {
|
|
1726
|
+
value = parsePgArray(value);
|
|
1727
|
+
}
|
|
1728
|
+
return value.map((v) => this.baseColumn.mapFromDriverValue(v));
|
|
1729
|
+
}
|
|
1730
|
+
mapToDriverValue(value, isNestedArray = false) {
|
|
1731
|
+
const a = value.map((v) => v === null ? null : is(this.baseColumn, PgArray2) ? this.baseColumn.mapToDriverValue(v, true) : this.baseColumn.mapToDriverValue(v));
|
|
1732
|
+
if (isNestedArray) return a;
|
|
1733
|
+
return makePgArray(a);
|
|
1734
|
+
}
|
|
1735
|
+
};
|
|
1736
|
+
|
|
1737
|
+
// ../../node_modules/drizzle-orm/pg-core/columns/enum.js
|
|
1738
|
+
var isPgEnumSym = /* @__PURE__ */ Symbol.for("drizzle:isPgEnum");
|
|
1739
|
+
function isPgEnum(obj) {
|
|
1740
|
+
return !!obj && typeof obj === "function" && isPgEnumSym in obj && obj[isPgEnumSym] === true;
|
|
1741
|
+
}
|
|
1742
|
+
__name(isPgEnum, "isPgEnum");
|
|
1743
|
+
(class PgEnumColumnBuilder2 extends PgColumnBuilder {
|
|
1744
|
+
static {
|
|
1745
|
+
__name(this, "PgEnumColumnBuilder");
|
|
1746
|
+
}
|
|
1747
|
+
static [entityKind] = "PgEnumColumnBuilder";
|
|
1748
|
+
constructor(name, enumInstance) {
|
|
1749
|
+
super(name, "string", "PgEnumColumn");
|
|
1750
|
+
this.config.enum = enumInstance;
|
|
1751
|
+
}
|
|
1752
|
+
/** @internal */
|
|
1753
|
+
build(table) {
|
|
1754
|
+
return new PgEnumColumn(table, this.config);
|
|
1755
|
+
}
|
|
1756
|
+
});
|
|
1757
|
+
var PgEnumColumn = class PgEnumColumn2 extends PgColumn {
|
|
1758
|
+
static {
|
|
1759
|
+
__name(this, "PgEnumColumn");
|
|
1760
|
+
}
|
|
1761
|
+
static [entityKind] = "PgEnumColumn";
|
|
1762
|
+
enum = this.config.enum;
|
|
1763
|
+
enumValues = this.config.enum.enumValues;
|
|
1764
|
+
constructor(table, config3) {
|
|
1765
|
+
super(table, config3);
|
|
1766
|
+
this.enum = config3.enum;
|
|
1767
|
+
}
|
|
1768
|
+
getSQLType() {
|
|
1769
|
+
return this.enum.enumName;
|
|
1770
|
+
}
|
|
1771
|
+
};
|
|
1772
|
+
|
|
1773
|
+
// ../../node_modules/drizzle-orm/subquery.js
|
|
1774
|
+
var Subquery = class Subquery2 {
|
|
1775
|
+
static {
|
|
1776
|
+
__name(this, "Subquery");
|
|
1777
|
+
}
|
|
1778
|
+
static [entityKind] = "Subquery";
|
|
1779
|
+
constructor(sql2, selection, alias, isWith = false) {
|
|
1780
|
+
this._ = {
|
|
1781
|
+
brand: "Subquery",
|
|
1782
|
+
sql: sql2,
|
|
1783
|
+
selectedFields: selection,
|
|
1784
|
+
alias,
|
|
1785
|
+
isWith
|
|
1786
|
+
};
|
|
1787
|
+
}
|
|
1788
|
+
};
|
|
1789
|
+
(class WithSubquery2 extends Subquery {
|
|
1790
|
+
static {
|
|
1791
|
+
__name(this, "WithSubquery");
|
|
1792
|
+
}
|
|
1793
|
+
static [entityKind] = "WithSubquery";
|
|
1794
|
+
});
|
|
1795
|
+
var tracer = {
|
|
1796
|
+
startActiveSpan(name, fn) {
|
|
1797
|
+
{
|
|
1798
|
+
return fn();
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
};
|
|
1802
|
+
|
|
1803
|
+
// ../../node_modules/drizzle-orm/view-common.js
|
|
1804
|
+
var ViewBaseConfig = /* @__PURE__ */ Symbol.for("drizzle:ViewBaseConfig");
|
|
1805
|
+
|
|
1806
|
+
// ../../node_modules/drizzle-orm/sql/sql.js
|
|
1807
|
+
(class FakePrimitiveParam2 {
|
|
1808
|
+
static {
|
|
1809
|
+
__name(this, "FakePrimitiveParam");
|
|
1810
|
+
}
|
|
1811
|
+
static [entityKind] = "FakePrimitiveParam";
|
|
1812
|
+
});
|
|
1813
|
+
function isSQLWrapper(value) {
|
|
1814
|
+
return value !== null && value !== void 0 && typeof value.getSQL === "function";
|
|
1815
|
+
}
|
|
1816
|
+
__name(isSQLWrapper, "isSQLWrapper");
|
|
1817
|
+
function mergeQueries(queries) {
|
|
1818
|
+
const result = {
|
|
1819
|
+
sql: "",
|
|
1820
|
+
params: []
|
|
1821
|
+
};
|
|
1822
|
+
for (const query of queries) {
|
|
1823
|
+
result.sql += query.sql;
|
|
1824
|
+
result.params.push(...query.params);
|
|
1825
|
+
if (query.typings?.length) {
|
|
1826
|
+
if (!result.typings) {
|
|
1827
|
+
result.typings = [];
|
|
1828
|
+
}
|
|
1829
|
+
result.typings.push(...query.typings);
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
return result;
|
|
1833
|
+
}
|
|
1834
|
+
__name(mergeQueries, "mergeQueries");
|
|
1835
|
+
var StringChunk = class StringChunk2 {
|
|
1836
|
+
static {
|
|
1837
|
+
__name(this, "StringChunk");
|
|
1838
|
+
}
|
|
1839
|
+
static [entityKind] = "StringChunk";
|
|
1840
|
+
value;
|
|
1841
|
+
constructor(value) {
|
|
1842
|
+
this.value = Array.isArray(value) ? value : [
|
|
1843
|
+
value
|
|
1844
|
+
];
|
|
1845
|
+
}
|
|
1846
|
+
getSQL() {
|
|
1847
|
+
return new SQL([
|
|
1848
|
+
this
|
|
1849
|
+
]);
|
|
1850
|
+
}
|
|
1851
|
+
};
|
|
1852
|
+
var SQL = class SQL2 {
|
|
1853
|
+
static {
|
|
1854
|
+
__name(this, "SQL");
|
|
1855
|
+
}
|
|
1856
|
+
constructor(queryChunks) {
|
|
1857
|
+
this.queryChunks = queryChunks;
|
|
1858
|
+
}
|
|
1859
|
+
static [entityKind] = "SQL";
|
|
1860
|
+
/** @internal */
|
|
1861
|
+
decoder = noopDecoder;
|
|
1862
|
+
shouldInlineParams = false;
|
|
1863
|
+
append(query) {
|
|
1864
|
+
this.queryChunks.push(...query.queryChunks);
|
|
1865
|
+
return this;
|
|
1866
|
+
}
|
|
1867
|
+
toQuery(config3) {
|
|
1868
|
+
return tracer.startActiveSpan("drizzle.buildSQL", (span) => {
|
|
1869
|
+
const query = this.buildQueryFromSourceParams(this.queryChunks, config3);
|
|
1870
|
+
span?.setAttributes({
|
|
1871
|
+
"drizzle.query.text": query.sql,
|
|
1872
|
+
"drizzle.query.params": JSON.stringify(query.params)
|
|
1873
|
+
});
|
|
1874
|
+
return query;
|
|
1875
|
+
});
|
|
1876
|
+
}
|
|
1877
|
+
buildQueryFromSourceParams(chunks, _config) {
|
|
1878
|
+
const config3 = Object.assign({}, _config, {
|
|
1879
|
+
inlineParams: _config.inlineParams || this.shouldInlineParams,
|
|
1880
|
+
paramStartIndex: _config.paramStartIndex || {
|
|
1881
|
+
value: 0
|
|
1882
|
+
}
|
|
1883
|
+
});
|
|
1884
|
+
const { escapeName, escapeParam, prepareTyping, inlineParams, paramStartIndex } = config3;
|
|
1885
|
+
return mergeQueries(chunks.map((chunk) => {
|
|
1886
|
+
if (is(chunk, StringChunk)) {
|
|
1887
|
+
return {
|
|
1888
|
+
sql: chunk.value.join(""),
|
|
1889
|
+
params: []
|
|
1890
|
+
};
|
|
1891
|
+
}
|
|
1892
|
+
if (is(chunk, Name)) {
|
|
1893
|
+
return {
|
|
1894
|
+
sql: escapeName(chunk.value),
|
|
1895
|
+
params: []
|
|
1896
|
+
};
|
|
1897
|
+
}
|
|
1898
|
+
if (chunk === void 0) {
|
|
1899
|
+
return {
|
|
1900
|
+
sql: "",
|
|
1901
|
+
params: []
|
|
1902
|
+
};
|
|
1903
|
+
}
|
|
1904
|
+
if (Array.isArray(chunk)) {
|
|
1905
|
+
const result = [
|
|
1906
|
+
new StringChunk("(")
|
|
1907
|
+
];
|
|
1908
|
+
for (const [i, p] of chunk.entries()) {
|
|
1909
|
+
result.push(p);
|
|
1910
|
+
if (i < chunk.length - 1) {
|
|
1911
|
+
result.push(new StringChunk(", "));
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
result.push(new StringChunk(")"));
|
|
1915
|
+
return this.buildQueryFromSourceParams(result, config3);
|
|
1916
|
+
}
|
|
1917
|
+
if (is(chunk, SQL2)) {
|
|
1918
|
+
return this.buildQueryFromSourceParams(chunk.queryChunks, {
|
|
1919
|
+
...config3,
|
|
1920
|
+
inlineParams: inlineParams || chunk.shouldInlineParams
|
|
1921
|
+
});
|
|
1922
|
+
}
|
|
1923
|
+
if (is(chunk, Table)) {
|
|
1924
|
+
const schemaName = chunk[Table.Symbol.Schema];
|
|
1925
|
+
const tableName = chunk[Table.Symbol.Name];
|
|
1926
|
+
return {
|
|
1927
|
+
sql: schemaName === void 0 ? escapeName(tableName) : escapeName(schemaName) + "." + escapeName(tableName),
|
|
1928
|
+
params: []
|
|
1929
|
+
};
|
|
1930
|
+
}
|
|
1931
|
+
if (is(chunk, Column)) {
|
|
1932
|
+
if (_config.invokeSource === "indexes") {
|
|
1933
|
+
return {
|
|
1934
|
+
sql: escapeName(chunk.name),
|
|
1935
|
+
params: []
|
|
1936
|
+
};
|
|
1937
|
+
}
|
|
1938
|
+
return {
|
|
1939
|
+
sql: escapeName(chunk.table[Table.Symbol.Name]) + "." + escapeName(chunk.name),
|
|
1940
|
+
params: []
|
|
1941
|
+
};
|
|
1942
|
+
}
|
|
1943
|
+
if (is(chunk, View)) {
|
|
1944
|
+
const schemaName = chunk[ViewBaseConfig].schema;
|
|
1945
|
+
const viewName = chunk[ViewBaseConfig].name;
|
|
1946
|
+
return {
|
|
1947
|
+
sql: schemaName === void 0 ? escapeName(viewName) : escapeName(schemaName) + "." + escapeName(viewName),
|
|
1948
|
+
params: []
|
|
1949
|
+
};
|
|
1950
|
+
}
|
|
1951
|
+
if (is(chunk, Param)) {
|
|
1952
|
+
if (is(chunk.value, Placeholder)) {
|
|
1953
|
+
return {
|
|
1954
|
+
sql: escapeParam(paramStartIndex.value++, chunk),
|
|
1955
|
+
params: [
|
|
1956
|
+
chunk
|
|
1957
|
+
],
|
|
1958
|
+
typings: [
|
|
1959
|
+
"none"
|
|
1960
|
+
]
|
|
1961
|
+
};
|
|
1962
|
+
}
|
|
1963
|
+
const mappedValue = chunk.value === null ? null : chunk.encoder.mapToDriverValue(chunk.value);
|
|
1964
|
+
if (is(mappedValue, SQL2)) {
|
|
1965
|
+
return this.buildQueryFromSourceParams([
|
|
1966
|
+
mappedValue
|
|
1967
|
+
], config3);
|
|
1968
|
+
}
|
|
1969
|
+
if (inlineParams) {
|
|
1970
|
+
return {
|
|
1971
|
+
sql: this.mapInlineParam(mappedValue, config3),
|
|
1972
|
+
params: []
|
|
1973
|
+
};
|
|
1974
|
+
}
|
|
1975
|
+
let typings = [
|
|
1976
|
+
"none"
|
|
1977
|
+
];
|
|
1978
|
+
if (prepareTyping) {
|
|
1979
|
+
typings = [
|
|
1980
|
+
prepareTyping(chunk.encoder)
|
|
1981
|
+
];
|
|
1982
|
+
}
|
|
1983
|
+
return {
|
|
1984
|
+
sql: escapeParam(paramStartIndex.value++, mappedValue),
|
|
1985
|
+
params: [
|
|
1986
|
+
mappedValue
|
|
1987
|
+
],
|
|
1988
|
+
typings
|
|
1989
|
+
};
|
|
1990
|
+
}
|
|
1991
|
+
if (is(chunk, Placeholder)) {
|
|
1992
|
+
return {
|
|
1993
|
+
sql: escapeParam(paramStartIndex.value++, chunk),
|
|
1994
|
+
params: [
|
|
1995
|
+
chunk
|
|
1996
|
+
],
|
|
1997
|
+
typings: [
|
|
1998
|
+
"none"
|
|
1999
|
+
]
|
|
2000
|
+
};
|
|
2001
|
+
}
|
|
2002
|
+
if (is(chunk, SQL2.Aliased) && chunk.fieldAlias !== void 0) {
|
|
2003
|
+
return {
|
|
2004
|
+
sql: escapeName(chunk.fieldAlias),
|
|
2005
|
+
params: []
|
|
2006
|
+
};
|
|
2007
|
+
}
|
|
2008
|
+
if (is(chunk, Subquery)) {
|
|
2009
|
+
if (chunk._.isWith) {
|
|
2010
|
+
return {
|
|
2011
|
+
sql: escapeName(chunk._.alias),
|
|
2012
|
+
params: []
|
|
2013
|
+
};
|
|
2014
|
+
}
|
|
2015
|
+
return this.buildQueryFromSourceParams([
|
|
2016
|
+
new StringChunk("("),
|
|
2017
|
+
chunk._.sql,
|
|
2018
|
+
new StringChunk(") "),
|
|
2019
|
+
new Name(chunk._.alias)
|
|
2020
|
+
], config3);
|
|
2021
|
+
}
|
|
2022
|
+
if (isPgEnum(chunk)) {
|
|
2023
|
+
if (chunk.schema) {
|
|
2024
|
+
return {
|
|
2025
|
+
sql: escapeName(chunk.schema) + "." + escapeName(chunk.enumName),
|
|
2026
|
+
params: []
|
|
2027
|
+
};
|
|
2028
|
+
}
|
|
2029
|
+
return {
|
|
2030
|
+
sql: escapeName(chunk.enumName),
|
|
2031
|
+
params: []
|
|
2032
|
+
};
|
|
2033
|
+
}
|
|
2034
|
+
if (isSQLWrapper(chunk)) {
|
|
2035
|
+
if (chunk.shouldOmitSQLParens?.()) {
|
|
2036
|
+
return this.buildQueryFromSourceParams([
|
|
2037
|
+
chunk.getSQL()
|
|
2038
|
+
], config3);
|
|
2039
|
+
}
|
|
2040
|
+
return this.buildQueryFromSourceParams([
|
|
2041
|
+
new StringChunk("("),
|
|
2042
|
+
chunk.getSQL(),
|
|
2043
|
+
new StringChunk(")")
|
|
2044
|
+
], config3);
|
|
2045
|
+
}
|
|
2046
|
+
if (inlineParams) {
|
|
2047
|
+
return {
|
|
2048
|
+
sql: this.mapInlineParam(chunk, config3),
|
|
2049
|
+
params: []
|
|
2050
|
+
};
|
|
2051
|
+
}
|
|
2052
|
+
return {
|
|
2053
|
+
sql: escapeParam(paramStartIndex.value++, chunk),
|
|
2054
|
+
params: [
|
|
2055
|
+
chunk
|
|
2056
|
+
],
|
|
2057
|
+
typings: [
|
|
2058
|
+
"none"
|
|
2059
|
+
]
|
|
2060
|
+
};
|
|
2061
|
+
}));
|
|
2062
|
+
}
|
|
2063
|
+
mapInlineParam(chunk, { escapeString }) {
|
|
2064
|
+
if (chunk === null) {
|
|
2065
|
+
return "null";
|
|
2066
|
+
}
|
|
2067
|
+
if (typeof chunk === "number" || typeof chunk === "boolean") {
|
|
2068
|
+
return chunk.toString();
|
|
2069
|
+
}
|
|
2070
|
+
if (typeof chunk === "string") {
|
|
2071
|
+
return escapeString(chunk);
|
|
2072
|
+
}
|
|
2073
|
+
if (typeof chunk === "object") {
|
|
2074
|
+
const mappedValueAsString = chunk.toString();
|
|
2075
|
+
if (mappedValueAsString === "[object Object]") {
|
|
2076
|
+
return escapeString(JSON.stringify(chunk));
|
|
2077
|
+
}
|
|
2078
|
+
return escapeString(mappedValueAsString);
|
|
2079
|
+
}
|
|
2080
|
+
throw new Error("Unexpected param value: " + chunk);
|
|
2081
|
+
}
|
|
2082
|
+
getSQL() {
|
|
2083
|
+
return this;
|
|
2084
|
+
}
|
|
2085
|
+
as(alias) {
|
|
2086
|
+
if (alias === void 0) {
|
|
2087
|
+
return this;
|
|
2088
|
+
}
|
|
2089
|
+
return new SQL2.Aliased(this, alias);
|
|
2090
|
+
}
|
|
2091
|
+
mapWith(decoder) {
|
|
2092
|
+
this.decoder = typeof decoder === "function" ? {
|
|
2093
|
+
mapFromDriverValue: decoder
|
|
2094
|
+
} : decoder;
|
|
2095
|
+
return this;
|
|
2096
|
+
}
|
|
2097
|
+
inlineParams() {
|
|
2098
|
+
this.shouldInlineParams = true;
|
|
2099
|
+
return this;
|
|
2100
|
+
}
|
|
2101
|
+
/**
|
|
2102
|
+
* This method is used to conditionally include a part of the query.
|
|
2103
|
+
*
|
|
2104
|
+
* @param condition - Condition to check
|
|
2105
|
+
* @returns itself if the condition is `true`, otherwise `undefined`
|
|
2106
|
+
*/
|
|
2107
|
+
if(condition) {
|
|
2108
|
+
return condition ? this : void 0;
|
|
2109
|
+
}
|
|
2110
|
+
};
|
|
2111
|
+
var Name = class Name2 {
|
|
2112
|
+
static {
|
|
2113
|
+
__name(this, "Name");
|
|
2114
|
+
}
|
|
2115
|
+
constructor(value) {
|
|
2116
|
+
this.value = value;
|
|
2117
|
+
}
|
|
2118
|
+
static [entityKind] = "Name";
|
|
2119
|
+
brand;
|
|
2120
|
+
getSQL() {
|
|
2121
|
+
return new SQL([
|
|
2122
|
+
this
|
|
2123
|
+
]);
|
|
2124
|
+
}
|
|
2125
|
+
};
|
|
2126
|
+
function isDriverValueEncoder(value) {
|
|
2127
|
+
return typeof value === "object" && value !== null && "mapToDriverValue" in value && typeof value.mapToDriverValue === "function";
|
|
2128
|
+
}
|
|
2129
|
+
__name(isDriverValueEncoder, "isDriverValueEncoder");
|
|
2130
|
+
var noopDecoder = {
|
|
2131
|
+
mapFromDriverValue: /* @__PURE__ */ __name((value) => value, "mapFromDriverValue")
|
|
2132
|
+
};
|
|
2133
|
+
var noopEncoder = {
|
|
2134
|
+
mapToDriverValue: /* @__PURE__ */ __name((value) => value, "mapToDriverValue")
|
|
2135
|
+
};
|
|
2136
|
+
({
|
|
2137
|
+
...noopDecoder,
|
|
2138
|
+
...noopEncoder
|
|
2139
|
+
});
|
|
2140
|
+
var Param = class Param2 {
|
|
2141
|
+
static {
|
|
2142
|
+
__name(this, "Param");
|
|
2143
|
+
}
|
|
2144
|
+
/**
|
|
2145
|
+
* @param value - Parameter value
|
|
2146
|
+
* @param encoder - Encoder to convert the value to a driver parameter
|
|
2147
|
+
*/
|
|
2148
|
+
constructor(value, encoder = noopEncoder) {
|
|
2149
|
+
this.value = value;
|
|
2150
|
+
this.encoder = encoder;
|
|
2151
|
+
}
|
|
2152
|
+
static [entityKind] = "Param";
|
|
2153
|
+
brand;
|
|
2154
|
+
getSQL() {
|
|
2155
|
+
return new SQL([
|
|
2156
|
+
this
|
|
2157
|
+
]);
|
|
2158
|
+
}
|
|
2159
|
+
};
|
|
2160
|
+
function sql(strings, ...params) {
|
|
2161
|
+
const queryChunks = [];
|
|
2162
|
+
if (params.length > 0 || strings.length > 0 && strings[0] !== "") {
|
|
2163
|
+
queryChunks.push(new StringChunk(strings[0]));
|
|
2164
|
+
}
|
|
2165
|
+
for (const [paramIndex, param2] of params.entries()) {
|
|
2166
|
+
queryChunks.push(param2, new StringChunk(strings[paramIndex + 1]));
|
|
2167
|
+
}
|
|
2168
|
+
return new SQL(queryChunks);
|
|
2169
|
+
}
|
|
2170
|
+
__name(sql, "sql");
|
|
2171
|
+
((sql2) => {
|
|
2172
|
+
function empty() {
|
|
2173
|
+
return new SQL([]);
|
|
2174
|
+
}
|
|
2175
|
+
__name(empty, "empty");
|
|
2176
|
+
sql2.empty = empty;
|
|
2177
|
+
function fromList(list) {
|
|
2178
|
+
return new SQL(list);
|
|
2179
|
+
}
|
|
2180
|
+
__name(fromList, "fromList");
|
|
2181
|
+
sql2.fromList = fromList;
|
|
2182
|
+
function raw(str) {
|
|
2183
|
+
return new SQL([
|
|
2184
|
+
new StringChunk(str)
|
|
2185
|
+
]);
|
|
2186
|
+
}
|
|
2187
|
+
__name(raw, "raw");
|
|
2188
|
+
sql2.raw = raw;
|
|
2189
|
+
function join(chunks, separator) {
|
|
2190
|
+
const result = [];
|
|
2191
|
+
for (const [i, chunk] of chunks.entries()) {
|
|
2192
|
+
if (i > 0 && separator !== void 0) {
|
|
2193
|
+
result.push(separator);
|
|
2194
|
+
}
|
|
2195
|
+
result.push(chunk);
|
|
2196
|
+
}
|
|
2197
|
+
return new SQL(result);
|
|
2198
|
+
}
|
|
2199
|
+
__name(join, "join");
|
|
2200
|
+
sql2.join = join;
|
|
2201
|
+
function identifier(value) {
|
|
2202
|
+
return new Name(value);
|
|
2203
|
+
}
|
|
2204
|
+
__name(identifier, "identifier");
|
|
2205
|
+
sql2.identifier = identifier;
|
|
2206
|
+
function placeholder2(name2) {
|
|
2207
|
+
return new Placeholder(name2);
|
|
2208
|
+
}
|
|
2209
|
+
__name(placeholder2, "placeholder2");
|
|
2210
|
+
sql2.placeholder = placeholder2;
|
|
2211
|
+
function param2(value, encoder) {
|
|
2212
|
+
return new Param(value, encoder);
|
|
2213
|
+
}
|
|
2214
|
+
__name(param2, "param2");
|
|
2215
|
+
sql2.param = param2;
|
|
2216
|
+
})(sql || (sql = {}));
|
|
2217
|
+
((SQL22) => {
|
|
2218
|
+
let Aliased = class Aliased2 {
|
|
2219
|
+
static {
|
|
2220
|
+
__name(this, "Aliased");
|
|
2221
|
+
}
|
|
2222
|
+
constructor(sql2, fieldAlias) {
|
|
2223
|
+
this.sql = sql2;
|
|
2224
|
+
this.fieldAlias = fieldAlias;
|
|
2225
|
+
}
|
|
2226
|
+
static [entityKind] = "SQL.Aliased";
|
|
2227
|
+
/** @internal */
|
|
2228
|
+
isSelectionField = false;
|
|
2229
|
+
getSQL() {
|
|
2230
|
+
return this.sql;
|
|
2231
|
+
}
|
|
2232
|
+
/** @internal */
|
|
2233
|
+
clone() {
|
|
2234
|
+
return new Aliased2(this.sql, this.fieldAlias);
|
|
2235
|
+
}
|
|
2236
|
+
};
|
|
2237
|
+
SQL22.Aliased = Aliased;
|
|
2238
|
+
})(SQL || (SQL = {}));
|
|
2239
|
+
var Placeholder = class Placeholder2 {
|
|
2240
|
+
static {
|
|
2241
|
+
__name(this, "Placeholder");
|
|
2242
|
+
}
|
|
2243
|
+
constructor(name2) {
|
|
2244
|
+
this.name = name2;
|
|
2245
|
+
}
|
|
2246
|
+
static [entityKind] = "Placeholder";
|
|
2247
|
+
getSQL() {
|
|
2248
|
+
return new SQL([
|
|
2249
|
+
this
|
|
2250
|
+
]);
|
|
2251
|
+
}
|
|
2252
|
+
};
|
|
2253
|
+
var View = class View2 {
|
|
2254
|
+
static {
|
|
2255
|
+
__name(this, "View");
|
|
2256
|
+
}
|
|
2257
|
+
static [entityKind] = "View";
|
|
2258
|
+
/** @internal */
|
|
2259
|
+
[ViewBaseConfig];
|
|
2260
|
+
constructor({ name: name2, schema: schema3, selectedFields, query }) {
|
|
2261
|
+
this[ViewBaseConfig] = {
|
|
2262
|
+
name: name2,
|
|
2263
|
+
originalName: name2,
|
|
2264
|
+
schema: schema3,
|
|
2265
|
+
selectedFields,
|
|
2266
|
+
query,
|
|
2267
|
+
isExisting: !query,
|
|
2268
|
+
isAlias: false
|
|
2269
|
+
};
|
|
2270
|
+
}
|
|
2271
|
+
getSQL() {
|
|
2272
|
+
return new SQL([
|
|
2273
|
+
this
|
|
2274
|
+
]);
|
|
2275
|
+
}
|
|
2276
|
+
};
|
|
2277
|
+
Column.prototype.getSQL = function() {
|
|
2278
|
+
return new SQL([
|
|
2279
|
+
this
|
|
2280
|
+
]);
|
|
2281
|
+
};
|
|
2282
|
+
Table.prototype.getSQL = function() {
|
|
2283
|
+
return new SQL([
|
|
2284
|
+
this
|
|
2285
|
+
]);
|
|
2286
|
+
};
|
|
2287
|
+
Subquery.prototype.getSQL = function() {
|
|
2288
|
+
return new SQL([
|
|
2289
|
+
this
|
|
2290
|
+
]);
|
|
2291
|
+
};
|
|
2292
|
+
|
|
2293
|
+
// ../../node_modules/drizzle-orm/sql/expressions/conditions.js
|
|
2294
|
+
function bindIfParam(value, column) {
|
|
2295
|
+
if (isDriverValueEncoder(column) && !isSQLWrapper(value) && !is(value, Param) && !is(value, Placeholder) && !is(value, Column) && !is(value, Table) && !is(value, View)) {
|
|
2296
|
+
return new Param(value, column);
|
|
2297
|
+
}
|
|
2298
|
+
return value;
|
|
2299
|
+
}
|
|
2300
|
+
__name(bindIfParam, "bindIfParam");
|
|
2301
|
+
var eq = /* @__PURE__ */ __name((left, right) => {
|
|
2302
|
+
return sql`${left} = ${bindIfParam(right, left)}`;
|
|
2303
|
+
}, "eq");
|
|
2304
|
+
function and(...unfilteredConditions) {
|
|
2305
|
+
const conditions = unfilteredConditions.filter((c) => c !== void 0);
|
|
2306
|
+
if (conditions.length === 0) {
|
|
2307
|
+
return void 0;
|
|
2308
|
+
}
|
|
2309
|
+
if (conditions.length === 1) {
|
|
2310
|
+
return new SQL(conditions);
|
|
2311
|
+
}
|
|
2312
|
+
return new SQL([
|
|
2313
|
+
new StringChunk("("),
|
|
2314
|
+
sql.join(conditions, new StringChunk(" and ")),
|
|
2315
|
+
new StringChunk(")")
|
|
2316
|
+
]);
|
|
2317
|
+
}
|
|
2318
|
+
__name(and, "and");
|
|
2319
|
+
function or(...unfilteredConditions) {
|
|
2320
|
+
const conditions = unfilteredConditions.filter((c) => c !== void 0);
|
|
2321
|
+
if (conditions.length === 0) {
|
|
2322
|
+
return void 0;
|
|
2323
|
+
}
|
|
2324
|
+
if (conditions.length === 1) {
|
|
2325
|
+
return new SQL(conditions);
|
|
2326
|
+
}
|
|
2327
|
+
return new SQL([
|
|
2328
|
+
new StringChunk("("),
|
|
2329
|
+
sql.join(conditions, new StringChunk(" or ")),
|
|
2330
|
+
new StringChunk(")")
|
|
2331
|
+
]);
|
|
2332
|
+
}
|
|
2333
|
+
__name(or, "or");
|
|
2334
|
+
function isNull(value) {
|
|
2335
|
+
return sql`${value} is null`;
|
|
2336
|
+
}
|
|
2337
|
+
__name(isNull, "isNull");
|
|
2338
|
+
function isNotNull(value) {
|
|
2339
|
+
return sql`${value} is not null`;
|
|
2340
|
+
}
|
|
2341
|
+
__name(isNotNull, "isNotNull");
|
|
2342
|
+
|
|
2343
|
+
// ../../node_modules/drizzle-orm/sql/expressions/select.js
|
|
2344
|
+
function asc(column) {
|
|
2345
|
+
return sql`${column} asc`;
|
|
2346
|
+
}
|
|
2347
|
+
__name(asc, "asc");
|
|
2348
|
+
function desc(column) {
|
|
2349
|
+
return sql`${column} desc`;
|
|
2350
|
+
}
|
|
2351
|
+
__name(desc, "desc");
|
|
2352
|
+
|
|
2353
|
+
// ../../node_modules/drizzle-orm/utils.js
|
|
2354
|
+
function getTableColumns(table) {
|
|
2355
|
+
return table[Table.Symbol.Columns];
|
|
2356
|
+
}
|
|
2357
|
+
__name(getTableColumns, "getTableColumns");
|
|
2358
|
+
|
|
2359
|
+
// ../../packages/dvss-integration-libs/src/integration-common-utils/dao/integration-configuration.dao.ts
|
|
2360
|
+
function _ts_decorate12(decorators, target, key, desc2) {
|
|
2361
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
2362
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2363
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2364
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2365
|
+
}
|
|
2366
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
2367
|
+
function _ts_metadata9(k, v) {
|
|
2368
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2369
|
+
}
|
|
2370
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
2371
|
+
function _ts_param(paramIndex, decorator) {
|
|
2372
|
+
return function(target, key) {
|
|
2373
|
+
decorator(target, key, paramIndex);
|
|
2374
|
+
};
|
|
2375
|
+
}
|
|
2376
|
+
__name(_ts_param, "_ts_param");
|
|
2377
|
+
exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
|
|
2378
|
+
static {
|
|
2379
|
+
__name(this, "IntegrationConfigurationDao");
|
|
2380
|
+
}
|
|
2381
|
+
conn;
|
|
2382
|
+
logger;
|
|
2383
|
+
fileName = "integration-configuration.dao";
|
|
2384
|
+
constructor(conn, logger) {
|
|
2385
|
+
this.conn = conn;
|
|
2386
|
+
this.logger = logger;
|
|
2387
|
+
}
|
|
2388
|
+
async addCapabilityIntegration(input, loggedInUserId) {
|
|
2389
|
+
this.logger.info(loggedInUserId, this.addCapabilityIntegration.name, this.fileName, `CapabilityDaoService -> addCapabilityIntegration called`);
|
|
2390
|
+
try {
|
|
2391
|
+
return this.conn.transaction(async (tx) => {
|
|
2392
|
+
const [integrationResult] = await tx.insert(dvssBackendModuleDatastore.schema.capabilityIntegration).values(input).$returningId();
|
|
2393
|
+
if (!integrationResult.id) {
|
|
2394
|
+
tx.rollback();
|
|
2395
|
+
return;
|
|
2396
|
+
}
|
|
2397
|
+
if (input.configuredFor) {
|
|
2398
|
+
const insertData = {
|
|
2399
|
+
capabilityIntegrationId: integrationResult.id,
|
|
2400
|
+
configuredForId: input.configuredFor.configuredForId,
|
|
2401
|
+
configuredForType: input.configuredFor.configuredForType,
|
|
2402
|
+
status: capabilityIntegration_model.CAPABILITY_INTEGRATION_STATUS_ENUM.ACTIVE,
|
|
2403
|
+
projectId: input.projectId,
|
|
2404
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
2405
|
+
createdBy: loggedInUserId
|
|
2406
|
+
};
|
|
2407
|
+
await tx.insert(dvssBackendModuleDatastore.schema.capIntegResourceMapping).values(insertData);
|
|
2408
|
+
}
|
|
2409
|
+
return {
|
|
2410
|
+
id: integrationResult.id
|
|
2411
|
+
};
|
|
2412
|
+
});
|
|
2413
|
+
} catch (error) {
|
|
2414
|
+
this.logger.error(loggedInUserId, this.addCapabilityIntegration.name, this.fileName, "Error in addCapabilityIntegration", error, input);
|
|
2415
|
+
throw error;
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
/**
|
|
2419
|
+
* Get capability by id (for add-capability-integration validation).
|
|
2420
|
+
* Copied from project-ms CapabilityDaoService.getCapability.
|
|
2421
|
+
*/
|
|
2422
|
+
async getCapability(request, loggedInUserId) {
|
|
2423
|
+
try {
|
|
2424
|
+
this.logger.info(loggedInUserId, this.getCapability.name, this.fileName, "getCapability called", {
|
|
2425
|
+
request
|
|
2426
|
+
});
|
|
2427
|
+
return await this.conn.query.capability.findFirst({
|
|
2428
|
+
where: and(eq(dvssBackendModuleDatastore.schema.capability.id, request.capabilityId), isNull(dvssBackendModuleDatastore.schema.capability.deletedAt))
|
|
2429
|
+
});
|
|
2430
|
+
} catch (error) {
|
|
2431
|
+
this.logger.error(loggedInUserId, this.getCapability.name, this.fileName, "Error on getCapability", error, {
|
|
2432
|
+
request
|
|
2433
|
+
});
|
|
2434
|
+
throw error;
|
|
2435
|
+
}
|
|
2436
|
+
}
|
|
2437
|
+
/**
|
|
2438
|
+
* Get capability provider by id (for add-capability-integration validation).
|
|
2439
|
+
* Copied from project-ms CapabilityProviderDao.getCapabilityProvider.
|
|
2440
|
+
*/
|
|
2441
|
+
async getCapabilityProvider(request, loggedInUserId) {
|
|
2442
|
+
try {
|
|
2443
|
+
this.logger.info(loggedInUserId, this.getCapabilityProvider.name, this.fileName, "getCapabilityProvider called", {
|
|
2444
|
+
request
|
|
2445
|
+
});
|
|
2446
|
+
return await this.conn.query.capabilityProvider.findFirst({
|
|
2447
|
+
where: and(eq(dvssBackendModuleDatastore.schema.capabilityProvider.id, request.capabilityProviderId), isNull(dvssBackendModuleDatastore.schema.capabilityProvider.deletedAt))
|
|
2448
|
+
});
|
|
2449
|
+
} catch (error) {
|
|
2450
|
+
this.logger.error(loggedInUserId, this.getCapabilityProvider.name, this.fileName, "Error on getCapabilityProvider", error, {
|
|
2451
|
+
request
|
|
2452
|
+
});
|
|
2453
|
+
throw error;
|
|
2454
|
+
}
|
|
2455
|
+
}
|
|
2456
|
+
/**
|
|
2457
|
+
* Updates capability integration in the database.
|
|
2458
|
+
* Copied from project-ms CapabilityIntegrationDao.updateCapabilityIntegration.
|
|
2459
|
+
*
|
|
2460
|
+
* @param input - Object containing the integration ID and update data
|
|
2461
|
+
* @param loggedInUserId - User ID for logging
|
|
2462
|
+
* @returns Promise that resolves to the update operation status
|
|
2463
|
+
*/
|
|
2464
|
+
async updateCapabilityIntegration(input, loggedInUserId) {
|
|
2465
|
+
try {
|
|
2466
|
+
this.logger.info(loggedInUserId, this.updateCapabilityIntegration.name, this.fileName, "Updating capability integration");
|
|
2467
|
+
const response = await this.conn.update(dvssBackendModuleDatastore.schema.capabilityIntegration).set({
|
|
2468
|
+
...input.updateData
|
|
2469
|
+
}).where(eq(dvssBackendModuleDatastore.schema.capabilityIntegration.id, input.id));
|
|
2470
|
+
return {
|
|
2471
|
+
status: response[0].affectedRows > 0
|
|
2472
|
+
};
|
|
2473
|
+
} catch (error) {
|
|
2474
|
+
this.logger.error(loggedInUserId, this.updateCapabilityIntegration.name, this.fileName, "Error updating capability integration", error);
|
|
2475
|
+
throw error;
|
|
2476
|
+
}
|
|
2477
|
+
}
|
|
2478
|
+
/**
|
|
2479
|
+
* Get capability integration by id (for parent validation when parentId is set).
|
|
2480
|
+
* Copied from project-ms CapabilityIntegrationDao.getCapabilityIntegration.
|
|
2481
|
+
*/
|
|
2482
|
+
async getCapabilityIntegration(input, loggedInUserId) {
|
|
2483
|
+
try {
|
|
2484
|
+
this.logger.info(loggedInUserId, this.getCapabilityIntegration.name, this.fileName, "getCapabilityIntegration called", input);
|
|
2485
|
+
return await this.conn.query.capabilityIntegration.findFirst({
|
|
2486
|
+
where: and(isNull(dvssBackendModuleDatastore.schema.capabilityIntegration.deletedAt), eq(dvssBackendModuleDatastore.schema.capabilityIntegration.id, input.capabilityIntegrationId))
|
|
2487
|
+
});
|
|
2488
|
+
} catch (error) {
|
|
2489
|
+
this.logger.error(loggedInUserId, this.getCapabilityIntegration.name, this.fileName, "Error on getCapabilityIntegration", error, input);
|
|
2490
|
+
throw error;
|
|
2491
|
+
}
|
|
2492
|
+
}
|
|
2493
|
+
/**
|
|
2494
|
+
* Retrieves capability integration by ID with resource mapping details.
|
|
2495
|
+
* Copied from project-ms CapabilityIntegrationDao.getCapabilityIntegrationById.
|
|
2496
|
+
*/
|
|
2497
|
+
async getCapabilityIntegrationById(request, loggedInUserId) {
|
|
2498
|
+
try {
|
|
2499
|
+
this.logger.info(loggedInUserId, this.getCapabilityIntegrationById.name, this.fileName, "getCapabilityIntegrationById called", request);
|
|
2500
|
+
const conditions = [
|
|
2501
|
+
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.id, request.id),
|
|
2502
|
+
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.projectId, request.projectId),
|
|
2503
|
+
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.type, capability_model.CAPABILITY_TYPE_ENUM.INTEGRATION),
|
|
2504
|
+
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.status, capabilityIntegration_model.CAPABILITY_INTEGRATION_STATUS_ENUM.ACTIVE),
|
|
2505
|
+
isNull(dvssBackendModuleDatastore.schema.capabilityIntegration.deletedAt),
|
|
2506
|
+
isNull(dvssBackendModuleDatastore.schema.capability.deletedAt)
|
|
2507
|
+
];
|
|
2508
|
+
if (request.category) {
|
|
2509
|
+
conditions.push(eq(dvssBackendModuleDatastore.schema.capabilityIntegration.category, request.category));
|
|
2510
|
+
}
|
|
2511
|
+
const response = await this.conn.select({
|
|
2512
|
+
...getTableColumns(dvssBackendModuleDatastore.schema.capabilityIntegration),
|
|
2513
|
+
resourceMappingId: dvssBackendModuleDatastore.schema.capIntegResourceMapping.id,
|
|
2514
|
+
configuredForId: dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId,
|
|
2515
|
+
configuredForType: dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType,
|
|
2516
|
+
resourceMappingConfig: dvssBackendModuleDatastore.schema.capIntegResourceMapping.config,
|
|
2517
|
+
provider: dvssBackendModuleDatastore.schema.capability.providerIntegrationType
|
|
2518
|
+
}).from(dvssBackendModuleDatastore.schema.capabilityIntegration).innerJoin(dvssBackendModuleDatastore.schema.capability, eq(dvssBackendModuleDatastore.schema.capability.id, dvssBackendModuleDatastore.schema.capabilityIntegration.capabilityId)).leftJoin(dvssBackendModuleDatastore.schema.capIntegResourceMapping, and(eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.capabilityIntegrationId, dvssBackendModuleDatastore.schema.capabilityIntegration.id), eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.projectId, request.projectId), isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt))).where(and(...conditions));
|
|
2519
|
+
return response[0];
|
|
2520
|
+
} catch (error) {
|
|
2521
|
+
this.logger.error(loggedInUserId, this.getCapabilityIntegrationById.name, this.fileName, "Error on getCapabilityIntegrationById", error, request);
|
|
2522
|
+
throw error;
|
|
2523
|
+
}
|
|
2524
|
+
}
|
|
2525
|
+
/**
|
|
2526
|
+
* Retrieves capability integration by provider type and resource mapping.
|
|
2527
|
+
* Copied from project-ms CapabilityIntegrationDao.getCapabilityIntegrationByProvider.
|
|
2528
|
+
*/
|
|
2529
|
+
async getCapabilityIntegrationByProvider(request, loggedInUserId) {
|
|
2530
|
+
try {
|
|
2531
|
+
this.logger.info(loggedInUserId, this.getCapabilityIntegrationByProvider.name, this.fileName, "getCapabilityIntegrationByProvider called", request);
|
|
2532
|
+
const conditions = [
|
|
2533
|
+
isNull(dvssBackendModuleDatastore.schema.capability.deletedAt),
|
|
2534
|
+
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.projectId, request.projectId),
|
|
2535
|
+
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.type, capability_model.CAPABILITY_TYPE_ENUM.INTEGRATION),
|
|
2536
|
+
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.status, capabilityIntegration_model.CAPABILITY_INTEGRATION_STATUS_ENUM.ACTIVE),
|
|
2537
|
+
isNull(dvssBackendModuleDatastore.schema.capabilityIntegration.deletedAt),
|
|
2538
|
+
eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.projectId, request.projectId),
|
|
2539
|
+
eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType, request.configuredForType),
|
|
2540
|
+
eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId, request.configuredForId),
|
|
2541
|
+
isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt)
|
|
2542
|
+
];
|
|
2543
|
+
if (request.category) {
|
|
2544
|
+
conditions.push(eq(dvssBackendModuleDatastore.schema.capabilityIntegration.category, request.category));
|
|
2545
|
+
}
|
|
2546
|
+
const response = await this.conn.select({
|
|
2547
|
+
...getTableColumns(dvssBackendModuleDatastore.schema.capabilityIntegration),
|
|
2548
|
+
resourceMappingId: dvssBackendModuleDatastore.schema.capIntegResourceMapping.id,
|
|
2549
|
+
configuredForId: dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId,
|
|
2550
|
+
configuredForType: dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType,
|
|
2551
|
+
resourceMappingConfig: dvssBackendModuleDatastore.schema.capIntegResourceMapping.config,
|
|
2552
|
+
provider: dvssBackendModuleDatastore.schema.capability.providerIntegrationType
|
|
2553
|
+
}).from(dvssBackendModuleDatastore.schema.capabilityIntegration).innerJoin(dvssBackendModuleDatastore.schema.capability, eq(dvssBackendModuleDatastore.schema.capability.id, dvssBackendModuleDatastore.schema.capabilityIntegration.capabilityId)).innerJoin(dvssBackendModuleDatastore.schema.capIntegResourceMapping, eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.capabilityIntegrationId, dvssBackendModuleDatastore.schema.capabilityIntegration.id)).where(and(...conditions));
|
|
2554
|
+
return response[0];
|
|
2555
|
+
} catch (error) {
|
|
2556
|
+
this.logger.error(loggedInUserId, this.getCapabilityIntegrationByProvider.name, this.fileName, "Error on getCapabilityIntegrationByProvider", error, request);
|
|
2557
|
+
throw error;
|
|
2558
|
+
}
|
|
2559
|
+
}
|
|
2560
|
+
/**
|
|
2561
|
+
* Get capability integrations with pagination, filtering, sorting, and search.
|
|
2562
|
+
* Copied from project-ms CapabilityIntegrationDao.getCapabilityIntegrations.
|
|
2563
|
+
*/
|
|
2564
|
+
async getCapabilityIntegrations(input, loggedInUserId) {
|
|
2565
|
+
try {
|
|
2566
|
+
this.logger.info(loggedInUserId, this.getCapabilityIntegrations.name, this.fileName, "getCapabilityIntegrations called", input);
|
|
2567
|
+
const count = input.options?.count ?? dvssBackendModuleDatastore.MAX_RECORDS_LENGTH;
|
|
2568
|
+
const offset = ((input.options?.page ?? 1) - 1) * count;
|
|
2569
|
+
const sorting = input.options?.sorting;
|
|
2570
|
+
let sortBy = dvssBackendModuleDatastore.schema.capabilityIntegration.id;
|
|
2571
|
+
if (sorting?.by === "CREATED_AT") {
|
|
2572
|
+
sortBy = dvssBackendModuleDatastore.schema.capabilityIntegration.createdAt;
|
|
2573
|
+
} else if (sorting?.by === "UPDATED_AT") {
|
|
2574
|
+
sortBy = dvssBackendModuleDatastore.schema.capabilityIntegration.updatedAt;
|
|
2575
|
+
}
|
|
2576
|
+
const sortOrder = sorting?.order === common_enum.SORTING_ORDER_ENUM.ASC ? asc(sortBy) : desc(sortBy);
|
|
2577
|
+
const searchTerm = input.options?.search;
|
|
2578
|
+
const shouldJoinCapability = Boolean(searchTerm) || Boolean(input.options?.filters?.some((filter) => filter.by === "PROVIDER_INTEGRATION_TYPE"));
|
|
2579
|
+
const whereConditions = [
|
|
2580
|
+
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.projectId, input.projectId),
|
|
2581
|
+
isNull(dvssBackendModuleDatastore.schema.capabilityIntegration.deletedAt)
|
|
2582
|
+
];
|
|
2583
|
+
if (input.category) {
|
|
2584
|
+
whereConditions.push(eq(dvssBackendModuleDatastore.schema.capabilityIntegration.category, input.category));
|
|
2585
|
+
}
|
|
2586
|
+
if (input.options?.filters && input.options.filters.length > 0) {
|
|
2587
|
+
this.applyFilters(whereConditions, input.options);
|
|
2588
|
+
}
|
|
2589
|
+
if (searchTerm) {
|
|
2590
|
+
const searchPattern = `%${searchTerm}%`;
|
|
2591
|
+
whereConditions.push(sql`(${dvssBackendModuleDatastore.schema.capabilityIntegration.nickname} LIKE ${searchPattern} OR ${dvssBackendModuleDatastore.schema.capability.name} LIKE ${searchPattern})`);
|
|
2592
|
+
}
|
|
2593
|
+
if (shouldJoinCapability) {
|
|
2594
|
+
whereConditions.push(isNull(dvssBackendModuleDatastore.schema.capability.deletedAt));
|
|
2595
|
+
}
|
|
2596
|
+
if (input.propertyId) {
|
|
2597
|
+
whereConditions.push(isNotNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.id));
|
|
2598
|
+
}
|
|
2599
|
+
const countWhereConditions = [
|
|
2600
|
+
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.projectId, input.projectId),
|
|
2601
|
+
isNull(dvssBackendModuleDatastore.schema.capabilityIntegration.deletedAt)
|
|
2602
|
+
];
|
|
2603
|
+
if (input.category) {
|
|
2604
|
+
countWhereConditions.push(eq(dvssBackendModuleDatastore.schema.capabilityIntegration.category, input.category));
|
|
2605
|
+
}
|
|
2606
|
+
if (input.options?.filters && input.options.filters.length > 0) {
|
|
2607
|
+
this.applyFilters(countWhereConditions, input.options);
|
|
2608
|
+
}
|
|
2609
|
+
if (searchTerm) {
|
|
2610
|
+
const searchPattern = `%${searchTerm}%`;
|
|
2611
|
+
countWhereConditions.push(sql`(${dvssBackendModuleDatastore.schema.capabilityIntegration.nickname} LIKE ${searchPattern} OR ${dvssBackendModuleDatastore.schema.capability.name} LIKE ${searchPattern})`);
|
|
2612
|
+
}
|
|
2613
|
+
const countQueryBuilder = this.conn.select({
|
|
2614
|
+
count: sql`count(distinct ${dvssBackendModuleDatastore.schema.capabilityIntegration.id})`.as("count")
|
|
2615
|
+
}).from(dvssBackendModuleDatastore.schema.capabilityIntegration);
|
|
2616
|
+
const countQueryWithJoins = shouldJoinCapability ? countQueryBuilder.leftJoin(dvssBackendModuleDatastore.schema.capability, eq(dvssBackendModuleDatastore.schema.capability.id, dvssBackendModuleDatastore.schema.capabilityIntegration.capabilityId)) : countQueryBuilder;
|
|
2617
|
+
if (shouldJoinCapability) {
|
|
2618
|
+
countWhereConditions.push(isNull(dvssBackendModuleDatastore.schema.capability.deletedAt));
|
|
2619
|
+
}
|
|
2620
|
+
const countQueryWithPropertyJoin = input.propertyId ? countQueryWithJoins.leftJoin(dvssBackendModuleDatastore.schema.capIntegResourceMapping, and(eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.capabilityIntegrationId, dvssBackendModuleDatastore.schema.capabilityIntegration.id), eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType, models.CONFIGURED_FOR_TYPE_ENUM.PROPERTY), eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId, BigInt(input.propertyId)), isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt))) : countQueryWithJoins;
|
|
2621
|
+
if (input.propertyId) {
|
|
2622
|
+
countWhereConditions.push(isNotNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.id));
|
|
2623
|
+
}
|
|
2624
|
+
const countQuery = countQueryWithPropertyJoin.where(and(...countWhereConditions));
|
|
2625
|
+
const baseQuery = this.conn.select({
|
|
2626
|
+
...getTableColumns(dvssBackendModuleDatastore.schema.capabilityIntegration),
|
|
2627
|
+
provider: dvssBackendModuleDatastore.schema.capability.providerIntegrationType
|
|
2628
|
+
}).from(dvssBackendModuleDatastore.schema.capabilityIntegration).leftJoin(dvssBackendModuleDatastore.schema.capability, eq(dvssBackendModuleDatastore.schema.capability.id, dvssBackendModuleDatastore.schema.capabilityIntegration.capabilityId));
|
|
2629
|
+
const finalQuery = input.propertyId ? baseQuery.leftJoin(dvssBackendModuleDatastore.schema.capIntegResourceMapping, and(eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.capabilityIntegrationId, dvssBackendModuleDatastore.schema.capabilityIntegration.id), eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType, models.CONFIGURED_FOR_TYPE_ENUM.PROPERTY), eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId, BigInt(input.propertyId)), isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt))).where(and(...whereConditions)) : baseQuery.where(and(...whereConditions));
|
|
2630
|
+
const [{ count: totalCount }, records] = await Promise.all([
|
|
2631
|
+
countQuery.execute().then((result) => result[0]),
|
|
2632
|
+
finalQuery.limit(count).offset(offset).orderBy(sortOrder).execute()
|
|
2633
|
+
]);
|
|
2634
|
+
return {
|
|
2635
|
+
totalCount: Number(totalCount) || 0,
|
|
2636
|
+
records
|
|
2637
|
+
};
|
|
2638
|
+
} catch (error) {
|
|
2639
|
+
this.logger.error(loggedInUserId, this.getCapabilityIntegrations.name, this.fileName, "Error in getCapabilityIntegrations", error, input);
|
|
2640
|
+
throw error;
|
|
2641
|
+
}
|
|
2642
|
+
}
|
|
2643
|
+
/**
|
|
2644
|
+
* Applies filters to where conditions.
|
|
2645
|
+
*/
|
|
2646
|
+
applyFilters(whereConditions, filters) {
|
|
2647
|
+
if (!filters || !filters.filters) {
|
|
2648
|
+
return;
|
|
2649
|
+
}
|
|
2650
|
+
for (const filter of filters.filters) {
|
|
2651
|
+
const filterValues = filter.values;
|
|
2652
|
+
if (!filterValues || filterValues.length === 0) {
|
|
2653
|
+
continue;
|
|
2654
|
+
}
|
|
2655
|
+
switch (filter.by) {
|
|
2656
|
+
case "PROVIDER_INTEGRATION_TYPE": {
|
|
2657
|
+
const valuePlaceholders = filterValues.map((value) => sql`${String(value)}`);
|
|
2658
|
+
const joinedValues = sql.join(valuePlaceholders, sql`, `);
|
|
2659
|
+
whereConditions.push(sql`${dvssBackendModuleDatastore.schema.capability.providerIntegrationType} IN (${joinedValues})`);
|
|
2660
|
+
break;
|
|
2661
|
+
}
|
|
2662
|
+
case "CAPABILITY_INTEGRATION_TYPE": {
|
|
2663
|
+
const parentConditions = [];
|
|
2664
|
+
for (const value of filterValues) {
|
|
2665
|
+
const upperValue = String(value).toUpperCase();
|
|
2666
|
+
if (upperValue === "PARENT") {
|
|
2667
|
+
parentConditions.push(isNull(dvssBackendModuleDatastore.schema.capabilityIntegration.parentId));
|
|
2668
|
+
} else if (upperValue === "CHILD") {
|
|
2669
|
+
parentConditions.push(isNotNull(dvssBackendModuleDatastore.schema.capabilityIntegration.parentId));
|
|
2670
|
+
}
|
|
2671
|
+
}
|
|
2672
|
+
if (parentConditions.length === 1) {
|
|
2673
|
+
whereConditions.push(parentConditions[0]);
|
|
2674
|
+
} else if (parentConditions.length > 1) {
|
|
2675
|
+
const orCondition = or(...parentConditions);
|
|
2676
|
+
if (orCondition) {
|
|
2677
|
+
whereConditions.push(orCondition);
|
|
2678
|
+
}
|
|
2679
|
+
}
|
|
2680
|
+
break;
|
|
2681
|
+
}
|
|
2682
|
+
}
|
|
2683
|
+
}
|
|
2684
|
+
}
|
|
2685
|
+
};
|
|
2686
|
+
exports.IntegrationConfigurationDao = _ts_decorate12([
|
|
2687
|
+
common.Injectable(),
|
|
2688
|
+
_ts_param(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
|
|
2689
|
+
_ts_metadata9("design:type", Function),
|
|
2690
|
+
_ts_metadata9("design:paramtypes", [
|
|
2691
|
+
typeof MySql2Database === "undefined" ? Object : MySql2Database,
|
|
2692
|
+
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
|
|
2693
|
+
])
|
|
2694
|
+
], exports.IntegrationConfigurationDao);
|
|
2695
|
+
function _ts_decorate13(decorators, target, key, desc2) {
|
|
2696
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
2697
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2698
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2699
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2700
|
+
}
|
|
2701
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
2702
|
+
function _ts_metadata10(k, v) {
|
|
2703
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2704
|
+
}
|
|
2705
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
2706
|
+
function _ts_param2(paramIndex, decorator) {
|
|
2707
|
+
return function(target, key) {
|
|
2708
|
+
decorator(target, key, paramIndex);
|
|
2709
|
+
};
|
|
2710
|
+
}
|
|
2711
|
+
__name(_ts_param2, "_ts_param");
|
|
2712
|
+
exports.IntegrationUserManagementDao = class IntegrationUserManagementDao {
|
|
2713
|
+
static {
|
|
2714
|
+
__name(this, "IntegrationUserManagementDao");
|
|
2715
|
+
}
|
|
2716
|
+
conn;
|
|
2717
|
+
constructor(conn) {
|
|
2718
|
+
this.conn = conn;
|
|
2719
|
+
}
|
|
2720
|
+
};
|
|
2721
|
+
exports.IntegrationUserManagementDao = _ts_decorate13([
|
|
2722
|
+
common.Injectable(),
|
|
2723
|
+
_ts_param2(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
|
|
2724
|
+
_ts_metadata10("design:type", Function),
|
|
2725
|
+
_ts_metadata10("design:paramtypes", [
|
|
2726
|
+
typeof MySql2Database === "undefined" ? Object : MySql2Database
|
|
2727
|
+
])
|
|
2728
|
+
], exports.IntegrationUserManagementDao);
|
|
2729
|
+
function _ts_decorate14(decorators, target, key, desc2) {
|
|
2730
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
2731
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2732
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2733
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2734
|
+
}
|
|
2735
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
2736
|
+
function _ts_metadata11(k, v) {
|
|
2737
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2738
|
+
}
|
|
2739
|
+
__name(_ts_metadata11, "_ts_metadata");
|
|
2740
|
+
function _ts_param3(paramIndex, decorator) {
|
|
2741
|
+
return function(target, key) {
|
|
2742
|
+
decorator(target, key, paramIndex);
|
|
2743
|
+
};
|
|
2744
|
+
}
|
|
2745
|
+
__name(_ts_param3, "_ts_param");
|
|
2746
|
+
exports.IntegrationResourceManagementDao = class IntegrationResourceManagementDao {
|
|
2747
|
+
static {
|
|
2748
|
+
__name(this, "IntegrationResourceManagementDao");
|
|
2749
|
+
}
|
|
2750
|
+
conn;
|
|
2751
|
+
logger;
|
|
2752
|
+
fileName = "integration-resource-management.dao";
|
|
2753
|
+
constructor(conn, logger) {
|
|
2754
|
+
this.conn = conn;
|
|
2755
|
+
this.logger = logger;
|
|
2756
|
+
}
|
|
2757
|
+
/**
|
|
2758
|
+
* Adds a capability integration resource mapping (insert into cap_integ_resource_mapping).
|
|
2759
|
+
* Replaces inter-service gRPC call to project-onboarding-ms for add configurations.
|
|
2760
|
+
*
|
|
2761
|
+
* @param input - projectId, capabilityIntegrationId, configuredForId, configuredForType, optional config
|
|
2762
|
+
* @param context - GraphQL context for loggedInUserId
|
|
2763
|
+
* @returns Promise resolving to { status: true, ids: [insertedId] } or { status: false, ids: [] }
|
|
2764
|
+
*/
|
|
2765
|
+
async addCapabilityIntegrationMapping(input, context) {
|
|
2766
|
+
try {
|
|
2767
|
+
this.logger.info(context.loggedInUserId, this.addCapabilityIntegrationMapping.name, this.fileName, "Adding capability integration mapping", input);
|
|
2768
|
+
const insertResult = await this.conn.insert(dvssBackendModuleDatastore.schema.capIntegResourceMapping).values({
|
|
2769
|
+
projectId: input.projectId,
|
|
2770
|
+
status: capabilityIntegration_model.CAPABILITY_INTEGRATION_STATUS_ENUM.ACTIVE,
|
|
2771
|
+
capabilityIntegrationId: input.capabilityIntegrationId,
|
|
2772
|
+
configuredForId: input.configuredForId,
|
|
2773
|
+
configuredForType: input.configuredForType,
|
|
2774
|
+
config: input.config ?? null,
|
|
2775
|
+
createdBy: context.loggedInUserId
|
|
2776
|
+
});
|
|
2777
|
+
const raw = insertResult;
|
|
2778
|
+
const insertedId = raw[0]?.insertId != null ? Number(raw[0].insertId) : 0;
|
|
2779
|
+
const status = insertedId > 0;
|
|
2780
|
+
const ids = status ? [
|
|
2781
|
+
BigInt(insertedId)
|
|
2782
|
+
] : [];
|
|
2783
|
+
this.logger.info(context.loggedInUserId, this.addCapabilityIntegrationMapping.name, this.fileName, `Mapping add ${status ? "successful" : "failed"}`, {
|
|
2784
|
+
insertedId,
|
|
2785
|
+
status
|
|
2786
|
+
});
|
|
2787
|
+
return {
|
|
2788
|
+
status,
|
|
2789
|
+
ids
|
|
2790
|
+
};
|
|
2791
|
+
} catch (error) {
|
|
2792
|
+
this.logger.error(context.loggedInUserId, this.addCapabilityIntegrationMapping.name, this.fileName, "Error adding capability integration mapping", error, input);
|
|
2793
|
+
throw error;
|
|
2794
|
+
}
|
|
2795
|
+
}
|
|
2796
|
+
/**
|
|
2797
|
+
* Checks if a capability integration resource mapping exists.
|
|
2798
|
+
* Validates that the mapping exists for the given capability integration, configured for ID and type.
|
|
2799
|
+
*
|
|
2800
|
+
* @param input - Input containing capability integration ID, configured for ID and type
|
|
2801
|
+
* @param loggedInUserId - ID of the user performing the operation
|
|
2802
|
+
* @returns Promise that resolves to true if mapping exists, false otherwise
|
|
2803
|
+
*/
|
|
2804
|
+
async checkMappingExists(input, loggedInUserId) {
|
|
2805
|
+
try {
|
|
2806
|
+
this.logger.info(loggedInUserId, this.checkMappingExists.name, this.fileName, `${this.checkMappingExists.name} called`, input);
|
|
2807
|
+
const response = await this.conn.select({
|
|
2808
|
+
id: dvssBackendModuleDatastore.schema.capIntegResourceMapping.id
|
|
2809
|
+
}).from(dvssBackendModuleDatastore.schema.capIntegResourceMapping).where(and(eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.capabilityIntegrationId, input.capabilityIntegrationId), eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId, input.configuredForId), eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType, input.configuredForType), isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt))).limit(1);
|
|
2810
|
+
return response.length > 0;
|
|
2811
|
+
} catch (error) {
|
|
2812
|
+
this.logger.error(loggedInUserId, this.checkMappingExists.name, this.fileName, "Error in checkMappingExists", error, input);
|
|
2813
|
+
throw error;
|
|
2814
|
+
}
|
|
2815
|
+
}
|
|
2816
|
+
/**
|
|
2817
|
+
* Removes capability integration resource mapping (soft delete).
|
|
2818
|
+
* Sets deletedAt and deletedBy on the matching cap_integ_resource_mapping row.
|
|
2819
|
+
* Use this from UIF/callers instead of inter-service call to project-onboarding-ms.
|
|
2820
|
+
*
|
|
2821
|
+
* @param input - Delete parameters including capability integration ID, configured for ID and type
|
|
2822
|
+
* @param loggedInUserId - ID of the user performing the operation
|
|
2823
|
+
* @returns Promise resolving to { status: true } if any row was updated, { status: false } otherwise
|
|
2824
|
+
*/
|
|
2825
|
+
async removeCapabilityIntegrationMapping(input, context) {
|
|
2826
|
+
try {
|
|
2827
|
+
this.logger.info(context.loggedInUserId, this.removeCapabilityIntegrationMapping.name, this.fileName, "Removing capability integration mapping", input);
|
|
2828
|
+
const whereConditions = [
|
|
2829
|
+
isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt),
|
|
2830
|
+
eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.capabilityIntegrationId, input.capabilityIntegrationId),
|
|
2831
|
+
eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId, input.configuredForId),
|
|
2832
|
+
eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType, input.configuredForType)
|
|
2833
|
+
];
|
|
2834
|
+
const deleteResult = await this.conn.update(dvssBackendModuleDatastore.schema.capIntegResourceMapping).set({
|
|
2835
|
+
deletedAt: /* @__PURE__ */ new Date(),
|
|
2836
|
+
deletedBy: context.loggedInUserId
|
|
2837
|
+
}).where(and(...whereConditions));
|
|
2838
|
+
const isSuccess = deleteResult[0].affectedRows > 0;
|
|
2839
|
+
this.logger.info(context.loggedInUserId, this.removeCapabilityIntegrationMapping.name, this.fileName, `Mapping removal ${isSuccess ? "successful" : "failed - no matching records"}`, {
|
|
2840
|
+
affectedRows: deleteResult[0].affectedRows
|
|
2841
|
+
});
|
|
2842
|
+
return {
|
|
2843
|
+
status: isSuccess
|
|
2844
|
+
};
|
|
2845
|
+
} catch (error) {
|
|
2846
|
+
this.logger.error(context.loggedInUserId, this.removeCapabilityIntegrationMapping.name, this.fileName, "Error removing capability integration mapping", error, input);
|
|
2847
|
+
throw error;
|
|
2848
|
+
}
|
|
2849
|
+
}
|
|
2850
|
+
/**
|
|
2851
|
+
* Gets a capability integration resource mapping by id (non-deleted only).
|
|
2852
|
+
* Use from UIF wrappers to validate mapping exists before update.
|
|
2853
|
+
*
|
|
2854
|
+
* @param id - cap_integ_resource_mapping.id
|
|
2855
|
+
* @param loggedInUserId - for logging
|
|
2856
|
+
* @returns The mapping row or undefined if not found
|
|
2857
|
+
*/
|
|
2858
|
+
async getCapabilityIntegrationResourceMappingById(id, loggedInUserId) {
|
|
2859
|
+
try {
|
|
2860
|
+
this.logger.info(loggedInUserId, this.getCapabilityIntegrationResourceMappingById.name, this.fileName, `${this.getCapabilityIntegrationResourceMappingById.name} called`, {
|
|
2861
|
+
id: id.toString()
|
|
2862
|
+
});
|
|
2863
|
+
const rows = await this.conn.select({
|
|
2864
|
+
id: dvssBackendModuleDatastore.schema.capIntegResourceMapping.id,
|
|
2865
|
+
capabilityIntegrationId: dvssBackendModuleDatastore.schema.capIntegResourceMapping.capabilityIntegrationId,
|
|
2866
|
+
configuredForId: dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId,
|
|
2867
|
+
configuredForType: dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType
|
|
2868
|
+
}).from(dvssBackendModuleDatastore.schema.capIntegResourceMapping).where(and(eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.id, id), isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt))).limit(1);
|
|
2869
|
+
return rows[0];
|
|
2870
|
+
} catch (error) {
|
|
2871
|
+
this.logger.error(loggedInUserId, this.getCapabilityIntegrationResourceMappingById.name, this.fileName, "Error in getCapabilityIntegrationResourceMappingById", error, {
|
|
2872
|
+
id: id.toString()
|
|
2873
|
+
});
|
|
2874
|
+
throw error;
|
|
2875
|
+
}
|
|
2876
|
+
}
|
|
2877
|
+
/**
|
|
2878
|
+
* Updates capability integration resource mapping config by id.
|
|
2879
|
+
* Replaces inter-service gRPC call to project-onboarding-ms for update capability integration configuration.
|
|
2880
|
+
*
|
|
2881
|
+
* @param input - id (mapping row id), config (new config JSON)
|
|
2882
|
+
* @param context - GraphQL context for loggedInUserId
|
|
2883
|
+
* @returns Promise resolving to { status: true } if row was updated, { status: false } otherwise
|
|
2884
|
+
*/
|
|
2885
|
+
async updateCapabilityIntegrationConfiguration(input, context) {
|
|
2886
|
+
try {
|
|
2887
|
+
this.logger.info(context.loggedInUserId, this.updateCapabilityIntegrationConfiguration.name, this.fileName, "Updating capability integration resource mapping config", {
|
|
2888
|
+
id: input.id.toString()
|
|
2889
|
+
});
|
|
2890
|
+
const updateResult = await this.conn.update(dvssBackendModuleDatastore.schema.capIntegResourceMapping).set({
|
|
2891
|
+
config: input.config,
|
|
2892
|
+
updatedBy: context.loggedInUserId
|
|
2893
|
+
}).where(and(eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.id, input.id), isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt)));
|
|
2894
|
+
const isSuccess = updateResult[0].affectedRows > 0;
|
|
2895
|
+
this.logger.info(context.loggedInUserId, this.updateCapabilityIntegrationConfiguration.name, this.fileName, `Mapping config update ${isSuccess ? "successful" : "failed - no matching records"}`, {
|
|
2896
|
+
affectedRows: updateResult[0].affectedRows
|
|
2897
|
+
});
|
|
2898
|
+
return {
|
|
2899
|
+
status: isSuccess
|
|
2900
|
+
};
|
|
2901
|
+
} catch (error) {
|
|
2902
|
+
this.logger.error(context.loggedInUserId, this.updateCapabilityIntegrationConfiguration.name, this.fileName, "Error updating capability integration resource mapping config", error, input);
|
|
2903
|
+
throw error;
|
|
2904
|
+
}
|
|
2905
|
+
}
|
|
2906
|
+
};
|
|
2907
|
+
exports.IntegrationResourceManagementDao = _ts_decorate14([
|
|
2908
|
+
common.Injectable(),
|
|
2909
|
+
_ts_param3(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
|
|
2910
|
+
_ts_metadata11("design:type", Function),
|
|
2911
|
+
_ts_metadata11("design:paramtypes", [
|
|
2912
|
+
typeof MySql2Database === "undefined" ? Object : MySql2Database,
|
|
2913
|
+
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
|
|
2914
|
+
])
|
|
2915
|
+
], exports.IntegrationResourceManagementDao);
|
|
2916
|
+
function _ts_decorate15(decorators, target, key, desc2) {
|
|
2917
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
2918
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
768
2919
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
769
2920
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
770
2921
|
}
|
|
771
|
-
__name(
|
|
772
|
-
function
|
|
2922
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
2923
|
+
function _ts_metadata12(k, v) {
|
|
773
2924
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
774
2925
|
}
|
|
775
|
-
__name(
|
|
2926
|
+
__name(_ts_metadata12, "_ts_metadata");
|
|
776
2927
|
exports.TrybeCustomerManagement = class _TrybeCustomerManagement {
|
|
777
2928
|
static {
|
|
778
2929
|
__name(this, "TrybeCustomerManagement");
|
|
@@ -788,13 +2939,22 @@ exports.TrybeCustomerManagement = class _TrybeCustomerManagement {
|
|
|
788
2939
|
this.trafficGatewayService = trafficGatewayService;
|
|
789
2940
|
}
|
|
790
2941
|
/**
|
|
791
|
-
*
|
|
792
|
-
* Must be implemented by concrete classes
|
|
2942
|
+
* Create a new customer on Trybe (POST /customers/customers).
|
|
793
2943
|
*
|
|
794
|
-
* @returns Promise resolving
|
|
2944
|
+
* @returns Promise resolving to the created customer
|
|
795
2945
|
*/
|
|
796
|
-
createCustomer() {
|
|
797
|
-
|
|
2946
|
+
async createCustomer(request, integration, loggedInUserId) {
|
|
2947
|
+
this.logger.info(loggedInUserId, this.createCustomer.name, this.fileName, `${_TrybeCustomerManagement.name} -> ${this.createCustomer.name} Called`, {
|
|
2948
|
+
request
|
|
2949
|
+
});
|
|
2950
|
+
const response = await this.trafficGatewayService.executeIntegrationRequest({
|
|
2951
|
+
apiMethod: HTTP_METHOD.POST,
|
|
2952
|
+
url: "/customers/customers",
|
|
2953
|
+
baseUrl: integration.config.platformConfig.baseUrl,
|
|
2954
|
+
headers: integration.headers,
|
|
2955
|
+
body: request
|
|
2956
|
+
}, integration, loggedInUserId);
|
|
2957
|
+
return response.data;
|
|
798
2958
|
}
|
|
799
2959
|
/**
|
|
800
2960
|
* Abstract method to search for wellness customers
|
|
@@ -835,34 +2995,79 @@ exports.TrybeCustomerManagement = class _TrybeCustomerManagement {
|
|
|
835
2995
|
}
|
|
836
2996
|
}
|
|
837
2997
|
/**
|
|
838
|
-
*
|
|
839
|
-
* Must be implemented by concrete classes
|
|
2998
|
+
* Update an existing customer on Trybe (PUT /customers/customers/:id), then fetch and return full customer.
|
|
840
2999
|
*
|
|
841
|
-
* @returns Promise resolving
|
|
3000
|
+
* @returns Promise resolving to the updated customer
|
|
842
3001
|
*/
|
|
843
|
-
updateCustomer() {
|
|
844
|
-
|
|
3002
|
+
async updateCustomer(customerId, request, integration, loggedInUserId) {
|
|
3003
|
+
this.logger.info(loggedInUserId, this.updateCustomer.name, this.fileName, `${_TrybeCustomerManagement.name} -> ${this.updateCustomer.name} Called`, {
|
|
3004
|
+
customerId,
|
|
3005
|
+
request
|
|
3006
|
+
});
|
|
3007
|
+
const response = await this.trafficGatewayService.executeIntegrationRequest({
|
|
3008
|
+
apiMethod: HTTP_METHOD.PUT,
|
|
3009
|
+
url: `/customers/customers/${customerId}`,
|
|
3010
|
+
baseUrl: integration.config.platformConfig.baseUrl,
|
|
3011
|
+
headers: integration.headers,
|
|
3012
|
+
body: request
|
|
3013
|
+
}, integration, loggedInUserId);
|
|
3014
|
+
return response.data;
|
|
3015
|
+
}
|
|
3016
|
+
/**
|
|
3017
|
+
* Delete a customer on Trybe.
|
|
3018
|
+
*/
|
|
3019
|
+
async deleteCustomer(customerId, integration, loggedInUserId) {
|
|
3020
|
+
try {
|
|
3021
|
+
this.logger.info(loggedInUserId, this.deleteCustomer.name, this.fileName, `${_TrybeCustomerManagement.name} -> ${this.deleteCustomer.name} Called`, {
|
|
3022
|
+
customerId
|
|
3023
|
+
});
|
|
3024
|
+
await this.trafficGatewayService.executeIntegrationRequest({
|
|
3025
|
+
apiMethod: HTTP_METHOD.DELETE,
|
|
3026
|
+
url: `/customers/customers/${customerId}`,
|
|
3027
|
+
baseUrl: integration.config.platformConfig.baseUrl,
|
|
3028
|
+
headers: integration.headers
|
|
3029
|
+
}, integration, loggedInUserId);
|
|
3030
|
+
return {
|
|
3031
|
+
status: true
|
|
3032
|
+
};
|
|
3033
|
+
} catch (error) {
|
|
3034
|
+
this.logger.error(loggedInUserId, this.deleteCustomer.name, this.fileName, "Error in deleting customer on Trybe", error);
|
|
3035
|
+
throw error;
|
|
3036
|
+
}
|
|
845
3037
|
}
|
|
846
3038
|
};
|
|
847
|
-
exports.TrybeCustomerManagement =
|
|
3039
|
+
exports.TrybeCustomerManagement = _ts_decorate15([
|
|
848
3040
|
common.Injectable(),
|
|
849
|
-
|
|
850
|
-
|
|
3041
|
+
_ts_metadata12("design:type", Function),
|
|
3042
|
+
_ts_metadata12("design:paramtypes", [
|
|
851
3043
|
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
|
|
852
3044
|
typeof exports.TrafficGatewayService === "undefined" ? Object : exports.TrafficGatewayService
|
|
853
3045
|
])
|
|
854
3046
|
], exports.TrybeCustomerManagement);
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
3047
|
+
|
|
3048
|
+
// ../../packages/dvss-integration-trybe/src/utils/url.utils.ts
|
|
3049
|
+
function isValidHttpUrl(urlString) {
|
|
3050
|
+
try {
|
|
3051
|
+
const url = new URL(urlString);
|
|
3052
|
+
return url.protocol === "http:" || url.protocol === "https:";
|
|
3053
|
+
} catch {
|
|
3054
|
+
return false;
|
|
3055
|
+
}
|
|
3056
|
+
}
|
|
3057
|
+
__name(isValidHttpUrl, "isValidHttpUrl");
|
|
3058
|
+
|
|
3059
|
+
// ../../packages/dvss-integration-trybe/src/capabilities/auth/auth.service.ts
|
|
3060
|
+
function _ts_decorate16(decorators, target, key, desc2) {
|
|
3061
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3062
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
858
3063
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
859
3064
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
860
3065
|
}
|
|
861
|
-
__name(
|
|
862
|
-
function
|
|
3066
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
3067
|
+
function _ts_metadata13(k, v) {
|
|
863
3068
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
864
3069
|
}
|
|
865
|
-
__name(
|
|
3070
|
+
__name(_ts_metadata13, "_ts_metadata");
|
|
866
3071
|
exports.TrybeAuthService = class _TrybeAuthService {
|
|
867
3072
|
static {
|
|
868
3073
|
__name(this, "TrybeAuthService");
|
|
@@ -911,6 +3116,9 @@ exports.TrybeAuthService = class _TrybeAuthService {
|
|
|
911
3116
|
if (!platformConfig.baseUrl) {
|
|
912
3117
|
throw new Error("Platform configuration is invalid: Base URL not found");
|
|
913
3118
|
}
|
|
3119
|
+
if (!isValidHttpUrl(platformConfig.baseUrl)) {
|
|
3120
|
+
throw new Error("Platform configuration is invalid: Base URL is not a valid URL");
|
|
3121
|
+
}
|
|
914
3122
|
} else {
|
|
915
3123
|
throw new Error("Platform configuration is invalid: Platform config is empty");
|
|
916
3124
|
}
|
|
@@ -956,10 +3164,10 @@ exports.TrybeAuthService = class _TrybeAuthService {
|
|
|
956
3164
|
throw new Error("Method not implemented.");
|
|
957
3165
|
}
|
|
958
3166
|
};
|
|
959
|
-
exports.TrybeAuthService =
|
|
3167
|
+
exports.TrybeAuthService = _ts_decorate16([
|
|
960
3168
|
common.Injectable(),
|
|
961
|
-
|
|
962
|
-
|
|
3169
|
+
_ts_metadata13("design:type", Function),
|
|
3170
|
+
_ts_metadata13("design:paramtypes", [
|
|
963
3171
|
typeof exports.TrybeCustomerManagement === "undefined" ? Object : exports.TrybeCustomerManagement,
|
|
964
3172
|
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
|
|
965
3173
|
])
|
|
@@ -976,7 +3184,7 @@ __name(mapStatus, "mapStatus");
|
|
|
976
3184
|
function mapTrybeCreditsToSystem(res, integration) {
|
|
977
3185
|
const groups = /* @__PURE__ */ new Map();
|
|
978
3186
|
for (const t of res.data) {
|
|
979
|
-
const key = `${t.coupon_name}|${t.
|
|
3187
|
+
const key = `${t.coupon_name}|${t.expires_at.split("T")[0]}`;
|
|
980
3188
|
const list = groups.get(key) ?? [];
|
|
981
3189
|
list.push(t);
|
|
982
3190
|
groups.set(key, list);
|
|
@@ -1022,17 +3230,17 @@ function mapTrybeCreditsToSystem(res, integration) {
|
|
|
1022
3230
|
__name(mapTrybeCreditsToSystem, "mapTrybeCreditsToSystem");
|
|
1023
3231
|
|
|
1024
3232
|
// ../../packages/dvss-integration-trybe/src/capabilities/credit-management/credit-booking.service.ts
|
|
1025
|
-
function
|
|
1026
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
1027
|
-
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);
|
|
1028
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;
|
|
1029
3237
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1030
3238
|
}
|
|
1031
|
-
__name(
|
|
1032
|
-
function
|
|
3239
|
+
__name(_ts_decorate17, "_ts_decorate");
|
|
3240
|
+
function _ts_metadata14(k, v) {
|
|
1033
3241
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1034
3242
|
}
|
|
1035
|
-
__name(
|
|
3243
|
+
__name(_ts_metadata14, "_ts_metadata");
|
|
1036
3244
|
exports.TrybeCreditBooking = class _TrybeCreditBooking {
|
|
1037
3245
|
static {
|
|
1038
3246
|
__name(this, "TrybeCreditBooking");
|
|
@@ -1090,10 +3298,10 @@ exports.TrybeCreditBooking = class _TrybeCreditBooking {
|
|
|
1090
3298
|
return mapTrybeCreditsToSystem(raw, validatedIntegration);
|
|
1091
3299
|
}
|
|
1092
3300
|
};
|
|
1093
|
-
exports.TrybeCreditBooking =
|
|
3301
|
+
exports.TrybeCreditBooking = _ts_decorate17([
|
|
1094
3302
|
common.Injectable(),
|
|
1095
|
-
|
|
1096
|
-
|
|
3303
|
+
_ts_metadata14("design:type", Function),
|
|
3304
|
+
_ts_metadata14("design:paramtypes", [
|
|
1097
3305
|
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
|
|
1098
3306
|
typeof exports.TrafficGatewayService === "undefined" ? Object : exports.TrafficGatewayService,
|
|
1099
3307
|
typeof exports.TrybeAuthService === "undefined" ? Object : exports.TrybeAuthService
|
|
@@ -1160,16 +3368,31 @@ var TRYBE_OFFERING_TYPE_ENUM = /* @__PURE__ */ (function(TRYBE_OFFERING_TYPE_ENU
|
|
|
1160
3368
|
TRYBE_OFFERING_TYPE_ENUM2["COURSE"] = "COURSE";
|
|
1161
3369
|
return TRYBE_OFFERING_TYPE_ENUM2;
|
|
1162
3370
|
})({});
|
|
3371
|
+
var TRYBE_OFFERING_TYPE_API = {
|
|
3372
|
+
APPOINTMENT: "appointment",
|
|
3373
|
+
SESSION: "session",
|
|
3374
|
+
COURSE: "course"
|
|
3375
|
+
};
|
|
1163
3376
|
|
|
1164
|
-
// ../../packages/dvss-integration-trybe/src/
|
|
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
|
+
})({});
|
|
1165
3388
|
var TRYBE_WEEKDAYS_MAPPING = {
|
|
1166
|
-
monday: DAY_OF_WEEK.MON,
|
|
1167
|
-
tuesday: DAY_OF_WEEK.TUE,
|
|
1168
|
-
wednesday: DAY_OF_WEEK.WED,
|
|
1169
|
-
thursday: DAY_OF_WEEK.THU,
|
|
1170
|
-
friday: DAY_OF_WEEK.FRI,
|
|
1171
|
-
saturday: DAY_OF_WEEK.SAT,
|
|
1172
|
-
sunday: DAY_OF_WEEK.SUN
|
|
3389
|
+
monday: models.DAY_OF_WEEK.MON,
|
|
3390
|
+
tuesday: models.DAY_OF_WEEK.TUE,
|
|
3391
|
+
wednesday: models.DAY_OF_WEEK.WED,
|
|
3392
|
+
thursday: models.DAY_OF_WEEK.THU,
|
|
3393
|
+
friday: models.DAY_OF_WEEK.FRI,
|
|
3394
|
+
saturday: models.DAY_OF_WEEK.SAT,
|
|
3395
|
+
sunday: models.DAY_OF_WEEK.SUN
|
|
1173
3396
|
};
|
|
1174
3397
|
function mapTrybeImageToMedia(image) {
|
|
1175
3398
|
if (!image) return void 0;
|
|
@@ -1387,6 +3610,32 @@ function mapTrybeCategoryToBookableItemCategory(category, index) {
|
|
|
1387
3610
|
};
|
|
1388
3611
|
}
|
|
1389
3612
|
__name(mapTrybeCategoryToBookableItemCategory, "mapTrybeCategoryToBookableItemCategory");
|
|
3613
|
+
function mapTrybePractitionerToOfferingResource(practitioner, index) {
|
|
3614
|
+
const media = practitioner.avatar != null && typeof practitioner.avatar === "object" ? {
|
|
3615
|
+
meta: practitioner.avatar
|
|
3616
|
+
} : void 0;
|
|
3617
|
+
return {
|
|
3618
|
+
id: BigInt(index + 1),
|
|
3619
|
+
externalId: practitioner.id,
|
|
3620
|
+
name: practitioner.name,
|
|
3621
|
+
type: models.OFFERING_RESOURCE_TYPE.PEOPLE,
|
|
3622
|
+
status: models.STATUS.ACTIVE,
|
|
3623
|
+
media,
|
|
3624
|
+
updatedAt: practitioner.updated_at ? new Date(practitioner.updated_at) : void 0,
|
|
3625
|
+
meta: {
|
|
3626
|
+
organisationId: practitioner.organisation_id,
|
|
3627
|
+
siteIds: practitioner.site_ids,
|
|
3628
|
+
appointmentRestrictions: practitioner.appointment_restrictions,
|
|
3629
|
+
tagIds: practitioner.tag_ids,
|
|
3630
|
+
tags: practitioner.tags,
|
|
3631
|
+
zones: practitioner.zones,
|
|
3632
|
+
canOfferTags: practitioner.can_offer_tags,
|
|
3633
|
+
createdAt: practitioner.created_at,
|
|
3634
|
+
updatedAt: practitioner.updated_at
|
|
3635
|
+
}
|
|
3636
|
+
};
|
|
3637
|
+
}
|
|
3638
|
+
__name(mapTrybePractitionerToOfferingResource, "mapTrybePractitionerToOfferingResource");
|
|
1390
3639
|
function mapTrybeAppointmentsToSystemResponse(appointments, totalCount, courseLookup) {
|
|
1391
3640
|
const records = appointments.map((apt, index) => {
|
|
1392
3641
|
const linkedCourses = courseLookup?.get(apt.id) ?? [];
|
|
@@ -1427,6 +3676,14 @@ function mapTrybeCategoriesToSystemResponse(categories, totalCount) {
|
|
|
1427
3676
|
};
|
|
1428
3677
|
}
|
|
1429
3678
|
__name(mapTrybeCategoriesToSystemResponse, "mapTrybeCategoriesToSystemResponse");
|
|
3679
|
+
function mapTrybePractitionersToSystemResponse(practitioners, totalCount) {
|
|
3680
|
+
const records = practitioners.map((practitioner, index) => mapTrybePractitionerToOfferingResource(practitioner, index));
|
|
3681
|
+
return {
|
|
3682
|
+
totalCount,
|
|
3683
|
+
records
|
|
3684
|
+
};
|
|
3685
|
+
}
|
|
3686
|
+
__name(mapTrybePractitionersToSystemResponse, "mapTrybePractitionersToSystemResponse");
|
|
1430
3687
|
function mapTrybeOfferingTypeToBookableItemType(offeringType) {
|
|
1431
3688
|
switch (offeringType) {
|
|
1432
3689
|
case TRYBE_OFFERING_TYPE_ENUM.APPOINTMENT:
|
|
@@ -1528,17 +3785,17 @@ function mapTrybeAppointmentAvailabilityToSystemResponse(slots) {
|
|
|
1528
3785
|
__name(mapTrybeAppointmentAvailabilityToSystemResponse, "mapTrybeAppointmentAvailabilityToSystemResponse");
|
|
1529
3786
|
|
|
1530
3787
|
// ../../packages/dvss-integration-trybe/src/capabilities/wellness/wellness-management.service.ts
|
|
1531
|
-
function
|
|
1532
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
1533
|
-
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);
|
|
1534
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;
|
|
1535
3792
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1536
3793
|
}
|
|
1537
|
-
__name(
|
|
1538
|
-
function
|
|
3794
|
+
__name(_ts_decorate18, "_ts_decorate");
|
|
3795
|
+
function _ts_metadata15(k, v) {
|
|
1539
3796
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1540
3797
|
}
|
|
1541
|
-
__name(
|
|
3798
|
+
__name(_ts_metadata15, "_ts_metadata");
|
|
1542
3799
|
exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
1543
3800
|
static {
|
|
1544
3801
|
__name(this, "TrybeWellnessManagement");
|
|
@@ -1552,9 +3809,6 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
1552
3809
|
this.trafficGatewayService = trafficGatewayService;
|
|
1553
3810
|
this.trybeAuthService = trybeAuthService;
|
|
1554
3811
|
}
|
|
1555
|
-
fetchPractitioners() {
|
|
1556
|
-
throw new Error("Method not implemented.");
|
|
1557
|
-
}
|
|
1558
3812
|
fetchWellnessAppointmentSession() {
|
|
1559
3813
|
throw new Error("Method not implemented.");
|
|
1560
3814
|
}
|
|
@@ -1570,6 +3824,265 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
1570
3824
|
confirmWellnessAppointmentSessionOrder() {
|
|
1571
3825
|
throw new Error("Method not implemented.");
|
|
1572
3826
|
}
|
|
3827
|
+
async createOrder(request, integration, loggedInUserId) {
|
|
3828
|
+
let orderId;
|
|
3829
|
+
try {
|
|
3830
|
+
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
3831
|
+
const siteId = validated.config.integrationConfig.siteId;
|
|
3832
|
+
const res = await this.trafficGatewayService.executeIntegrationRequest({
|
|
3833
|
+
apiMethod: HTTP_METHOD.POST,
|
|
3834
|
+
url: "/shop/orders",
|
|
3835
|
+
baseUrl: validated.config.platformConfig.baseUrl,
|
|
3836
|
+
headers: validated.headers,
|
|
3837
|
+
body: {
|
|
3838
|
+
site_id: siteId,
|
|
3839
|
+
status: "new"
|
|
3840
|
+
}
|
|
3841
|
+
}, validated, loggedInUserId);
|
|
3842
|
+
orderId = res.data.id;
|
|
3843
|
+
const items = [];
|
|
3844
|
+
await this.addCustomerToOrder(orderId, request.customerId, integration, loggedInUserId);
|
|
3845
|
+
const order = await this.getOrder(orderId, integration, loggedInUserId);
|
|
3846
|
+
for (const bookableItem of request.bookableItems) {
|
|
3847
|
+
const orderItemResponse = await this.addItemToOrder({
|
|
3848
|
+
orderId,
|
|
3849
|
+
item: {
|
|
3850
|
+
offeringId: bookableItem.externalId,
|
|
3851
|
+
offeringType: bookableItem.type,
|
|
3852
|
+
guestIds: order.guests.map((g) => g.id),
|
|
3853
|
+
practitionerIds: request.offeringResources.map((r) => r.externalId),
|
|
3854
|
+
durationMinutes: request.durationInMinutes,
|
|
3855
|
+
timeIso: request.bookingStartTime.toISOString()
|
|
3856
|
+
}
|
|
3857
|
+
}, integration, loggedInUserId);
|
|
3858
|
+
items.push({
|
|
3859
|
+
externalId: bookableItem.externalId,
|
|
3860
|
+
name: orderItemResponse.name,
|
|
3861
|
+
type: bookableItem.type,
|
|
3862
|
+
totalPrice: (orderItemResponse.netTotal ?? 0) / request.currencyMultiplier
|
|
3863
|
+
});
|
|
3864
|
+
}
|
|
3865
|
+
if (request.customerCreditId) {
|
|
3866
|
+
await this.addCustomerCreditsToOrder(orderId, request.customerCreditId, integration, loggedInUserId);
|
|
3867
|
+
}
|
|
3868
|
+
await this.submitOrder(orderId, integration, loggedInUserId);
|
|
3869
|
+
this.logger.info(loggedInUserId, this.createOrder.name, this.fileName, "Created Trybe order for offering booking", {
|
|
3870
|
+
orderId
|
|
3871
|
+
});
|
|
3872
|
+
return {
|
|
3873
|
+
externalBookingId: orderId,
|
|
3874
|
+
items,
|
|
3875
|
+
meta: {
|
|
3876
|
+
orderReference: order.meta.orderReference
|
|
3877
|
+
}
|
|
3878
|
+
};
|
|
3879
|
+
} catch (err) {
|
|
3880
|
+
this.logger.error(loggedInUserId, this.createOrder.name, this.fileName, "Error creating Trybe order for offering booking", err);
|
|
3881
|
+
if (orderId) {
|
|
3882
|
+
await this.cancelOrder(orderId, integration, loggedInUserId);
|
|
3883
|
+
}
|
|
3884
|
+
throw err;
|
|
3885
|
+
}
|
|
3886
|
+
}
|
|
3887
|
+
async addCustomerToOrder(orderId, customerId, integration, loggedInUserId) {
|
|
3888
|
+
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
3889
|
+
await this.trafficGatewayService.executeIntegrationRequest({
|
|
3890
|
+
apiMethod: HTTP_METHOD.POST,
|
|
3891
|
+
url: `/shop/orders/${orderId}/customer`,
|
|
3892
|
+
baseUrl: validated.config.platformConfig.baseUrl,
|
|
3893
|
+
headers: validated.headers,
|
|
3894
|
+
body: {
|
|
3895
|
+
id: customerId,
|
|
3896
|
+
source: "trybe"
|
|
3897
|
+
}
|
|
3898
|
+
}, validated, loggedInUserId);
|
|
3899
|
+
}
|
|
3900
|
+
async getOrder(orderId, integration, loggedInUserId) {
|
|
3901
|
+
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
3902
|
+
const res = await this.trafficGatewayService.executeIntegrationRequest({
|
|
3903
|
+
apiMethod: HTTP_METHOD.GET,
|
|
3904
|
+
url: `/shop/orders/${orderId}`,
|
|
3905
|
+
baseUrl: validated.config.platformConfig.baseUrl,
|
|
3906
|
+
headers: validated.headers
|
|
3907
|
+
}, validated, loggedInUserId);
|
|
3908
|
+
return {
|
|
3909
|
+
orderId: res.data.id,
|
|
3910
|
+
guests: res.data.guests.map((g) => ({
|
|
3911
|
+
id: g.id,
|
|
3912
|
+
name: g.name
|
|
3913
|
+
})),
|
|
3914
|
+
meta: {
|
|
3915
|
+
orderReference: res.data.order_ref
|
|
3916
|
+
},
|
|
3917
|
+
items: res.data.booking_items ?? []
|
|
3918
|
+
};
|
|
3919
|
+
}
|
|
3920
|
+
mapOfferingTypeToTrybeApi(type) {
|
|
3921
|
+
switch (type) {
|
|
3922
|
+
case BOOKABLE_ITEM_TYPE_ENUM.APPOINTMENT:
|
|
3923
|
+
return TRYBE_OFFERING_TYPE_API.APPOINTMENT;
|
|
3924
|
+
case BOOKABLE_ITEM_TYPE_ENUM.SESSION:
|
|
3925
|
+
return TRYBE_OFFERING_TYPE_API.SESSION;
|
|
3926
|
+
case BOOKABLE_ITEM_TYPE_ENUM.COURSE:
|
|
3927
|
+
return TRYBE_OFFERING_TYPE_API.COURSE;
|
|
3928
|
+
default:
|
|
3929
|
+
throw new Error(`Unsupported offering type: ${type}`);
|
|
3930
|
+
}
|
|
3931
|
+
}
|
|
3932
|
+
async addItemToOrder(request, integration, loggedInUserId) {
|
|
3933
|
+
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
3934
|
+
const { orderId, item } = request;
|
|
3935
|
+
const offeringType = this.mapOfferingTypeToTrybeApi(item.offeringType);
|
|
3936
|
+
let body;
|
|
3937
|
+
if (offeringType === TRYBE_OFFERING_TYPE_API.APPOINTMENT) {
|
|
3938
|
+
if (item.durationMinutes == null || !item.timeIso) {
|
|
3939
|
+
throw new Error("durationMinutes and timeIso required for appointment");
|
|
3940
|
+
}
|
|
3941
|
+
body = {
|
|
3942
|
+
offering_type: offeringType,
|
|
3943
|
+
offering_id: item.offeringId,
|
|
3944
|
+
guest_ids: item.guestIds,
|
|
3945
|
+
item_configuration: {
|
|
3946
|
+
duration: item.durationMinutes,
|
|
3947
|
+
skip_availability_checks: false,
|
|
3948
|
+
time: item.timeIso
|
|
3949
|
+
},
|
|
3950
|
+
skip_availability_checks: false
|
|
3951
|
+
};
|
|
3952
|
+
} else if (offeringType === TRYBE_OFFERING_TYPE_API.SESSION) {
|
|
3953
|
+
if (!item.sessionId) {
|
|
3954
|
+
throw new Error("sessionId required for session");
|
|
3955
|
+
}
|
|
3956
|
+
body = {
|
|
3957
|
+
offering_type: offeringType,
|
|
3958
|
+
offering_id: item.offeringId,
|
|
3959
|
+
guest_ids: item.guestIds,
|
|
3960
|
+
item_configuration: {
|
|
3961
|
+
session_id: item.sessionId,
|
|
3962
|
+
skip_availability_checks: false
|
|
3963
|
+
},
|
|
3964
|
+
skip_availability_checks: false
|
|
3965
|
+
};
|
|
3966
|
+
} else {
|
|
3967
|
+
body = {
|
|
3968
|
+
offering_type: offeringType,
|
|
3969
|
+
offering_id: item.offeringId,
|
|
3970
|
+
guest_ids: item.guestIds
|
|
3971
|
+
};
|
|
3972
|
+
}
|
|
3973
|
+
const res = await this.trafficGatewayService.executeIntegrationRequest({
|
|
3974
|
+
apiMethod: HTTP_METHOD.POST,
|
|
3975
|
+
url: `/shop/orders/${orderId}/items`,
|
|
3976
|
+
baseUrl: validated.config.platformConfig.baseUrl,
|
|
3977
|
+
headers: validated.headers,
|
|
3978
|
+
body
|
|
3979
|
+
}, validated, loggedInUserId);
|
|
3980
|
+
const d = res.data;
|
|
3981
|
+
return {
|
|
3982
|
+
name: d.booking_summary?.offering?.name ?? d.type_name ?? void 0,
|
|
3983
|
+
netTotal: d.net_total
|
|
3984
|
+
};
|
|
3985
|
+
}
|
|
3986
|
+
async addCustomerCreditsToOrder(orderId, customerCreditId, integration, loggedInUserId) {
|
|
3987
|
+
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
3988
|
+
await this.trafficGatewayService.executeIntegrationRequest({
|
|
3989
|
+
apiMethod: HTTP_METHOD.POST,
|
|
3990
|
+
url: `/shop/orders/${orderId}/customer-credits`,
|
|
3991
|
+
baseUrl: validated.config.platformConfig.baseUrl,
|
|
3992
|
+
headers: validated.headers,
|
|
3993
|
+
body: {
|
|
3994
|
+
id: customerCreditId
|
|
3995
|
+
}
|
|
3996
|
+
}, validated, loggedInUserId);
|
|
3997
|
+
}
|
|
3998
|
+
async submitOrder(orderId, integration, loggedInUserId) {
|
|
3999
|
+
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4000
|
+
await this.trafficGatewayService.executeIntegrationRequest({
|
|
4001
|
+
apiMethod: HTTP_METHOD.POST,
|
|
4002
|
+
url: `/shop/orders/${orderId}/submit`,
|
|
4003
|
+
baseUrl: validated.config.platformConfig.baseUrl,
|
|
4004
|
+
headers: validated.headers
|
|
4005
|
+
}, validated, loggedInUserId);
|
|
4006
|
+
}
|
|
4007
|
+
async cancelOrder(orderId, integration, loggedInUserId) {
|
|
4008
|
+
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4009
|
+
await this.trafficGatewayService.executeIntegrationRequest({
|
|
4010
|
+
apiMethod: HTTP_METHOD.POST,
|
|
4011
|
+
url: `/shop/orders/${orderId}/cancel`,
|
|
4012
|
+
baseUrl: validated.config.platformConfig.baseUrl,
|
|
4013
|
+
headers: validated.headers
|
|
4014
|
+
}, validated, loggedInUserId);
|
|
4015
|
+
}
|
|
4016
|
+
async updateOrder(request, integration, loggedInUserId) {
|
|
4017
|
+
const order = await this.getOrder(request.orderId, integration, loggedInUserId);
|
|
4018
|
+
const itemId = order.items[0]?.id;
|
|
4019
|
+
if (!itemId) {
|
|
4020
|
+
throw new Error("Item not found in order");
|
|
4021
|
+
}
|
|
4022
|
+
const updateResponse = await this.updateOrderItem(request.orderId, itemId, request, integration, loggedInUserId);
|
|
4023
|
+
return {
|
|
4024
|
+
success: Boolean(updateResponse.data.id),
|
|
4025
|
+
data: updateResponse.data
|
|
4026
|
+
};
|
|
4027
|
+
}
|
|
4028
|
+
async updateOrderItem(orderId, itemId, request, integration, loggedInUserId) {
|
|
4029
|
+
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4030
|
+
const offeringType = this.mapOfferingTypeToTrybeApi(request.item.type);
|
|
4031
|
+
let body;
|
|
4032
|
+
if (offeringType === TRYBE_OFFERING_TYPE_API.APPOINTMENT) {
|
|
4033
|
+
if (request.bookingStartTimeLabel == null || request.durationInMinutes == null || request.bookingStartDateLabel == null) {
|
|
4034
|
+
throw new Error("durationInMinutes, bookingStartDateLabel and bookingStartTimeLabel required for appointment");
|
|
4035
|
+
}
|
|
4036
|
+
const timeIso = dvssBackendModuleUtility.convertDateOnlyToTimestamp(request.timezone, request.bookingStartDateLabel, request.bookingStartTimeLabel).toISOString();
|
|
4037
|
+
body = {
|
|
4038
|
+
offering_id: request.item.externalId,
|
|
4039
|
+
item_configuration: {
|
|
4040
|
+
time: timeIso,
|
|
4041
|
+
duration: request.durationInMinutes,
|
|
4042
|
+
skip_availability_checks: false
|
|
4043
|
+
},
|
|
4044
|
+
skip_availability_checks: false
|
|
4045
|
+
};
|
|
4046
|
+
} else if (offeringType === TRYBE_OFFERING_TYPE_API.SESSION) {
|
|
4047
|
+
if (!request.sessionId) {
|
|
4048
|
+
throw new Error("sessionId required for session");
|
|
4049
|
+
}
|
|
4050
|
+
body = {
|
|
4051
|
+
item_configuration: {
|
|
4052
|
+
session_id: request.sessionId,
|
|
4053
|
+
skip_availability_checks: false
|
|
4054
|
+
}
|
|
4055
|
+
};
|
|
4056
|
+
} else {
|
|
4057
|
+
throw new Error("Course is not updatable");
|
|
4058
|
+
}
|
|
4059
|
+
const res = await this.trafficGatewayService.executeIntegrationRequest({
|
|
4060
|
+
apiMethod: HTTP_METHOD.PUT,
|
|
4061
|
+
url: `/shop/orders/${orderId}/items/${itemId}`,
|
|
4062
|
+
baseUrl: validated.config.platformConfig.baseUrl,
|
|
4063
|
+
headers: validated.headers,
|
|
4064
|
+
body
|
|
4065
|
+
}, validated, loggedInUserId);
|
|
4066
|
+
return res;
|
|
4067
|
+
}
|
|
4068
|
+
async addPaymentToOrder(request, integration, loggedInUserId) {
|
|
4069
|
+
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4070
|
+
await this.trafficGatewayService.executeIntegrationRequest({
|
|
4071
|
+
apiMethod: HTTP_METHOD.POST,
|
|
4072
|
+
url: `/shop/orders/${request.orderId}/payments`,
|
|
4073
|
+
baseUrl: validated.config.platformConfig.baseUrl,
|
|
4074
|
+
headers: validated.headers,
|
|
4075
|
+
body: {
|
|
4076
|
+
amount: request.amount,
|
|
4077
|
+
processor: "manual",
|
|
4078
|
+
status: "paid",
|
|
4079
|
+
processor_data: {
|
|
4080
|
+
notes: "",
|
|
4081
|
+
payment_type_id: request.paymentTypeId
|
|
4082
|
+
}
|
|
4083
|
+
}
|
|
4084
|
+
}, validated, loggedInUserId);
|
|
4085
|
+
}
|
|
1573
4086
|
async fetchAppointments(request, integration, loggedInUserId) {
|
|
1574
4087
|
this.logger.info(loggedInUserId, this.fetchAppointments.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchAppointments.name} Called`, {
|
|
1575
4088
|
request
|
|
@@ -1666,6 +4179,27 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
1666
4179
|
}, validatedIntegration, loggedInUserId));
|
|
1667
4180
|
return mapTrybeCoursesToSystemResponse(records, firstPageResponse.meta.total);
|
|
1668
4181
|
}
|
|
4182
|
+
async fetchPractitioners(request, integration, loggedInUserId) {
|
|
4183
|
+
this.logger.info(loggedInUserId, this.fetchPractitioners.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchPractitioners.name} Called`, {
|
|
4184
|
+
request
|
|
4185
|
+
});
|
|
4186
|
+
const validatedIntegration = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4187
|
+
const siteId = validatedIntegration.config.integrationConfig.siteId;
|
|
4188
|
+
const apiUrl = `/shop/practitioners/?site_id=${siteId}`;
|
|
4189
|
+
const firstPageResponse = await this.trafficGatewayService.executeIntegrationRequest({
|
|
4190
|
+
apiMethod: HTTP_METHOD.GET,
|
|
4191
|
+
url: apiUrl,
|
|
4192
|
+
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4193
|
+
headers: validatedIntegration.headers
|
|
4194
|
+
}, validatedIntegration, loggedInUserId);
|
|
4195
|
+
const records = await fetchAllPages(firstPageResponse, request.shouldFetchAllPractitioners, (page) => this.trafficGatewayService.executeIntegrationRequest({
|
|
4196
|
+
apiMethod: HTTP_METHOD.GET,
|
|
4197
|
+
url: `${apiUrl}&page=${page}`,
|
|
4198
|
+
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4199
|
+
headers: validatedIntegration.headers
|
|
4200
|
+
}, validatedIntegration, loggedInUserId));
|
|
4201
|
+
return mapTrybePractitionersToSystemResponse(records, firstPageResponse.meta.total);
|
|
4202
|
+
}
|
|
1669
4203
|
async fetchCategories(request, integration, loggedInUserId) {
|
|
1670
4204
|
this.logger.info(loggedInUserId, this.fetchCategories.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchCategories.name} Called`, {
|
|
1671
4205
|
request
|
|
@@ -1755,30 +4289,221 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
1755
4289
|
return mapTrybeAppointmentAvailabilityToSystemResponse(response.data);
|
|
1756
4290
|
}
|
|
1757
4291
|
};
|
|
1758
|
-
exports.TrybeWellnessManagement =
|
|
4292
|
+
exports.TrybeWellnessManagement = _ts_decorate18([
|
|
1759
4293
|
common.Injectable(),
|
|
1760
|
-
|
|
1761
|
-
|
|
4294
|
+
_ts_metadata15("design:type", Function),
|
|
4295
|
+
_ts_metadata15("design:paramtypes", [
|
|
1762
4296
|
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
|
|
1763
4297
|
typeof exports.TrafficGatewayService === "undefined" ? Object : exports.TrafficGatewayService,
|
|
1764
4298
|
typeof exports.TrybeAuthService === "undefined" ? Object : exports.TrybeAuthService
|
|
1765
4299
|
])
|
|
1766
4300
|
], exports.TrybeWellnessManagement);
|
|
1767
4301
|
|
|
4302
|
+
// ../../packages/dvss-integration-trybe/src/capabilities/integration-configuration/integration-configuration.mapper.ts
|
|
4303
|
+
function mapTrybeSiteResponseToSystem(response) {
|
|
4304
|
+
return {
|
|
4305
|
+
customPaymentTypes: response.data?.custom_payment_types?.map((paymentType) => ({
|
|
4306
|
+
id: paymentType.id,
|
|
4307
|
+
name: paymentType.name,
|
|
4308
|
+
kind: paymentType.kind
|
|
4309
|
+
}))
|
|
4310
|
+
};
|
|
4311
|
+
}
|
|
4312
|
+
__name(mapTrybeSiteResponseToSystem, "mapTrybeSiteResponseToSystem");
|
|
4313
|
+
|
|
4314
|
+
// ../../packages/dvss-integration-trybe/src/capabilities/integration-configuration/integration-configuration.service.ts
|
|
4315
|
+
function _ts_decorate19(decorators, target, key, desc2) {
|
|
4316
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4317
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
4318
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4319
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4320
|
+
}
|
|
4321
|
+
__name(_ts_decorate19, "_ts_decorate");
|
|
4322
|
+
function _ts_metadata16(k, v) {
|
|
4323
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4324
|
+
}
|
|
4325
|
+
__name(_ts_metadata16, "_ts_metadata");
|
|
4326
|
+
exports.TrybeIntegrationConfigurationService = class TrybeIntegrationConfigurationService extends exports.BaseIntegrationConfiguration {
|
|
4327
|
+
static {
|
|
4328
|
+
__name(this, "TrybeIntegrationConfigurationService");
|
|
4329
|
+
}
|
|
4330
|
+
trybeAuthService;
|
|
4331
|
+
trafficGatewayService;
|
|
4332
|
+
constructor(integrationConfigurationDao, commonValidationDatabaseService, logger, trybeAuthService, trafficGatewayService) {
|
|
4333
|
+
super(integrationConfigurationDao, commonValidationDatabaseService, logger), this.trybeAuthService = trybeAuthService, this.trafficGatewayService = trafficGatewayService;
|
|
4334
|
+
}
|
|
4335
|
+
/**
|
|
4336
|
+
* Add capability integration: validate Trybe config, then configuredFor (offering), then delegate to base.
|
|
4337
|
+
*/
|
|
4338
|
+
async addCapabilityIntegration(input, context) {
|
|
4339
|
+
this.trybeAuthService.validateConfig({
|
|
4340
|
+
config: input.config
|
|
4341
|
+
}, context.loggedInUserId);
|
|
4342
|
+
if (input.configuredFor != null) {
|
|
4343
|
+
await this.validateCapabilityIntegrationConfiguredForInput(input.configuredFor, input.projectId);
|
|
4344
|
+
}
|
|
4345
|
+
return super.addCapabilityIntegration(input, context);
|
|
4346
|
+
}
|
|
4347
|
+
/**
|
|
4348
|
+
* Update capability integration: convert to new signature and delegate to base.
|
|
4349
|
+
*/
|
|
4350
|
+
async updateCapabilityIntegration(request, integration, loggedInUserId) {
|
|
4351
|
+
if (request.updateData.config) {
|
|
4352
|
+
this.trybeAuthService.validateConfig({
|
|
4353
|
+
config: request.updateData.config
|
|
4354
|
+
}, loggedInUserId);
|
|
4355
|
+
}
|
|
4356
|
+
return super.updateCapabilityIntegration(request, integration, loggedInUserId);
|
|
4357
|
+
}
|
|
4358
|
+
/**
|
|
4359
|
+
* Validates configuredFor (offering exists and belongs to project). Same as project-ms validateCapabilityIntegrationConfiguredForInput.
|
|
4360
|
+
*/
|
|
4361
|
+
async validateCapabilityIntegrationConfiguredForInput(configuredFor, projectId) {
|
|
4362
|
+
if (configuredFor.configuredForType !== models.CONFIGURED_FOR_TYPE_ENUM.OFFERING) {
|
|
4363
|
+
throw new Error(`configuredForType not supported: ${configuredFor.configuredForType}`);
|
|
4364
|
+
}
|
|
4365
|
+
await this.commonValidationDatabaseService.getOffering({
|
|
4366
|
+
offeringId: configuredFor.configuredForId,
|
|
4367
|
+
projectId
|
|
4368
|
+
});
|
|
4369
|
+
}
|
|
4370
|
+
/**
|
|
4371
|
+
* Trybe 3rd party: GET /shop/sites/{siteId} via executeIntegrationRequest.
|
|
4372
|
+
*/
|
|
4373
|
+
async getSiteDetailedInformation(integration, loggedInUserId) {
|
|
4374
|
+
const validatedIntegration = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4375
|
+
const siteId = validatedIntegration.config.integrationConfig.siteId;
|
|
4376
|
+
const url = `/shop/sites/${siteId}`;
|
|
4377
|
+
const response = await this.trafficGatewayService.executeIntegrationRequest({
|
|
4378
|
+
apiMethod: HTTP_METHOD.GET,
|
|
4379
|
+
url,
|
|
4380
|
+
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4381
|
+
headers: validatedIntegration.headers
|
|
4382
|
+
}, validatedIntegration, loggedInUserId);
|
|
4383
|
+
return mapTrybeSiteResponseToSystem(response);
|
|
4384
|
+
}
|
|
4385
|
+
};
|
|
4386
|
+
exports.TrybeIntegrationConfigurationService = _ts_decorate19([
|
|
4387
|
+
common.Injectable(),
|
|
4388
|
+
_ts_metadata16("design:type", Function),
|
|
4389
|
+
_ts_metadata16("design:paramtypes", [
|
|
4390
|
+
typeof exports.IntegrationConfigurationDao === "undefined" ? Object : exports.IntegrationConfigurationDao,
|
|
4391
|
+
typeof dvssBackendModuleDatastore.CommonValidationDatabaseService === "undefined" ? Object : dvssBackendModuleDatastore.CommonValidationDatabaseService,
|
|
4392
|
+
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
|
|
4393
|
+
typeof exports.TrybeAuthService === "undefined" ? Object : exports.TrybeAuthService,
|
|
4394
|
+
typeof exports.TrafficGatewayService === "undefined" ? Object : exports.TrafficGatewayService
|
|
4395
|
+
])
|
|
4396
|
+
], exports.TrybeIntegrationConfigurationService);
|
|
4397
|
+
function _ts_decorate20(decorators, target, key, desc2) {
|
|
4398
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4399
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
4400
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4401
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4402
|
+
}
|
|
4403
|
+
__name(_ts_decorate20, "_ts_decorate");
|
|
4404
|
+
function _ts_metadata17(k, v) {
|
|
4405
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4406
|
+
}
|
|
4407
|
+
__name(_ts_metadata17, "_ts_metadata");
|
|
4408
|
+
var OFFERING_INTEGRATION_MAPPING_ALREADY_EXISTS = "OFFERING_INTEGRATION_MAPPING_ALREADY_EXISTS";
|
|
4409
|
+
var VALID_JOURNEY_VALUES = /* @__PURE__ */ new Set([
|
|
4410
|
+
"SESSION",
|
|
4411
|
+
"COURSE",
|
|
4412
|
+
"APPOINTMENT"
|
|
4413
|
+
]);
|
|
4414
|
+
exports.TrybeIntegrationResourceManagementService = class TrybeIntegrationResourceManagementService extends BaseIntegrationResourceManagement {
|
|
4415
|
+
static {
|
|
4416
|
+
__name(this, "TrybeIntegrationResourceManagementService");
|
|
4417
|
+
}
|
|
4418
|
+
constructor(logger, integrationResourceManagementDao) {
|
|
4419
|
+
super(integrationResourceManagementDao, logger);
|
|
4420
|
+
}
|
|
4421
|
+
/**
|
|
4422
|
+
* Validates Trybe resource mapping config (same rules as MS trybe-offering-integration-management.service).
|
|
4423
|
+
* @throws CustomException BAD_REQUEST if config is invalid
|
|
4424
|
+
*/
|
|
4425
|
+
validateResourceMappingConfig(config3) {
|
|
4426
|
+
const resourceMappingConfig = config3;
|
|
4427
|
+
if (!resourceMappingConfig.supportedJourneys || resourceMappingConfig.supportedJourneys.length === 0) {
|
|
4428
|
+
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: supportedJourneys required and must be non-empty");
|
|
4429
|
+
}
|
|
4430
|
+
if (!resourceMappingConfig.catalogingBy || // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
4431
|
+
resourceMappingConfig.catalogingBy !== TRYBE_CATALOGING_BY_ENUM.PEOPLE_RESOURCE) {
|
|
4432
|
+
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: catalogingBy must be PEOPLE_RESOURCE");
|
|
4433
|
+
}
|
|
4434
|
+
if (resourceMappingConfig.isExternalCmsIntegrationEnabled === void 0 || typeof resourceMappingConfig.isExternalCmsIntegrationEnabled !== "boolean" || resourceMappingConfig.isExternalCmsIntegrationEnabled === false) {
|
|
4435
|
+
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: isExternalCmsIntegrationEnabled must be true");
|
|
4436
|
+
}
|
|
4437
|
+
if (!resourceMappingConfig.externalCmsUrl || !isValidHttpUrl(resourceMappingConfig.externalCmsUrl)) {
|
|
4438
|
+
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: externalCmsUrl must be a valid HTTP(S) URL");
|
|
4439
|
+
}
|
|
4440
|
+
if (!resourceMappingConfig.supportedJourneys.some((journey) => VALID_JOURNEY_VALUES.has(journey))) {
|
|
4441
|
+
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: supportedJourneys must contain at least one of SESSION, COURSE, APPOINTMENT");
|
|
4442
|
+
}
|
|
4443
|
+
if (resourceMappingConfig.supportedJourneys.some((journey) => !VALID_JOURNEY_VALUES.has(journey))) {
|
|
4444
|
+
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: supportedJourneys may only contain SESSION, COURSE, APPOINTMENT");
|
|
4445
|
+
}
|
|
4446
|
+
if (!resourceMappingConfig.paymentType || typeof resourceMappingConfig.paymentType !== "string") {
|
|
4447
|
+
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: paymentType required and must be a string");
|
|
4448
|
+
}
|
|
4449
|
+
}
|
|
4450
|
+
async addResourceToIntegration(input, context) {
|
|
4451
|
+
if (input.config != null && typeof input.config === "object") {
|
|
4452
|
+
this.validateResourceMappingConfig(input.config);
|
|
4453
|
+
}
|
|
4454
|
+
const isMappingExists = await this.integrationResourceManagementDao.checkMappingExists({
|
|
4455
|
+
capabilityIntegrationId: input.capabilityIntegrationId,
|
|
4456
|
+
configuredForId: input.offeringId,
|
|
4457
|
+
configuredForType: models.CONFIGURED_FOR_TYPE_ENUM.OFFERING
|
|
4458
|
+
}, context.loggedInUserId);
|
|
4459
|
+
if (isMappingExists) {
|
|
4460
|
+
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, OFFERING_INTEGRATION_MAPPING_ALREADY_EXISTS);
|
|
4461
|
+
}
|
|
4462
|
+
return super.addResourceToIntegration(input, context);
|
|
4463
|
+
}
|
|
4464
|
+
async removeResourceFromIntegration(request, context) {
|
|
4465
|
+
const isMappingExists = await this.integrationResourceManagementDao.checkMappingExists({
|
|
4466
|
+
capabilityIntegrationId: request.capabilityIntegrationId,
|
|
4467
|
+
configuredForId: request.offeringId,
|
|
4468
|
+
configuredForType: models.CONFIGURED_FOR_TYPE_ENUM.OFFERING
|
|
4469
|
+
}, context.loggedInUserId);
|
|
4470
|
+
if (!isMappingExists) {
|
|
4471
|
+
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Mapping not found");
|
|
4472
|
+
}
|
|
4473
|
+
return super.removeResourceFromIntegration(request, context);
|
|
4474
|
+
}
|
|
4475
|
+
async updateOfferingIntegrationResourceConfiguration(input, context) {
|
|
4476
|
+
const resourceMapping = await this.integrationResourceManagementDao.getCapabilityIntegrationResourceMappingById(input.id, context.loggedInUserId);
|
|
4477
|
+
if (!resourceMapping) {
|
|
4478
|
+
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Resource mapping not found");
|
|
4479
|
+
}
|
|
4480
|
+
this.validateResourceMappingConfig(input.config);
|
|
4481
|
+
return await super.updateOfferingIntegrationResourceConfiguration(input, context);
|
|
4482
|
+
}
|
|
4483
|
+
};
|
|
4484
|
+
exports.TrybeIntegrationResourceManagementService = _ts_decorate20([
|
|
4485
|
+
common.Injectable(),
|
|
4486
|
+
_ts_metadata17("design:type", Function),
|
|
4487
|
+
_ts_metadata17("design:paramtypes", [
|
|
4488
|
+
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
|
|
4489
|
+
typeof exports.IntegrationResourceManagementDao === "undefined" ? Object : exports.IntegrationResourceManagementDao
|
|
4490
|
+
])
|
|
4491
|
+
], exports.TrybeIntegrationResourceManagementService);
|
|
4492
|
+
|
|
1768
4493
|
// ../../packages/dvss-integration-trybe/src/app.module.ts
|
|
1769
|
-
function
|
|
1770
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
1771
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
4494
|
+
function _ts_decorate21(decorators, target, key, desc2) {
|
|
4495
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4496
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
1772
4497
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1773
4498
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1774
4499
|
}
|
|
1775
|
-
__name(
|
|
4500
|
+
__name(_ts_decorate21, "_ts_decorate");
|
|
1776
4501
|
exports.IntegrationTrybeModule = class AppModule2 {
|
|
1777
4502
|
static {
|
|
1778
4503
|
__name(this, "AppModule");
|
|
1779
4504
|
}
|
|
1780
4505
|
};
|
|
1781
|
-
exports.IntegrationTrybeModule =
|
|
4506
|
+
exports.IntegrationTrybeModule = _ts_decorate21([
|
|
1782
4507
|
common.Module({
|
|
1783
4508
|
imports: [
|
|
1784
4509
|
// Load environment variables from root .env file
|
|
@@ -1788,7 +4513,8 @@ exports.IntegrationTrybeModule = _ts_decorate15([
|
|
|
1788
4513
|
}),
|
|
1789
4514
|
exports.IntegrationLibsModule,
|
|
1790
4515
|
axios.HttpModule,
|
|
1791
|
-
dvssBackendModuleUtility.LoggerModule
|
|
4516
|
+
dvssBackendModuleUtility.LoggerModule,
|
|
4517
|
+
dvssBackendModuleDatastore.DatastoreModule
|
|
1792
4518
|
],
|
|
1793
4519
|
controllers: [
|
|
1794
4520
|
AppController2
|
|
@@ -1798,31 +4524,43 @@ exports.IntegrationTrybeModule = _ts_decorate15([
|
|
|
1798
4524
|
exports.TrybeAuthService,
|
|
1799
4525
|
exports.TrybeCustomerManagement,
|
|
1800
4526
|
exports.TrybeCreditBooking,
|
|
1801
|
-
exports.TrybeWellnessManagement
|
|
4527
|
+
exports.TrybeWellnessManagement,
|
|
4528
|
+
exports.IntegrationConfigurationDao,
|
|
4529
|
+
exports.IntegrationResourceManagementDao,
|
|
4530
|
+
exports.IntegrationRequestLoggerService,
|
|
4531
|
+
exports.RateLimiterService,
|
|
4532
|
+
exports.TrafficGatewayService,
|
|
4533
|
+
exports.TrybeCustomerManagement,
|
|
4534
|
+
exports.TrybeAuthService,
|
|
4535
|
+
exports.TrybeIntegrationConfigurationService,
|
|
4536
|
+
exports.TrybeIntegrationResourceManagementService,
|
|
4537
|
+
dvssBackendModuleDatastore.CommonValidationDatabaseService
|
|
1802
4538
|
],
|
|
1803
4539
|
exports: [
|
|
1804
4540
|
exports.TrybeAuthService,
|
|
1805
4541
|
exports.TrybeCustomerManagement,
|
|
1806
4542
|
exports.TrybeCreditBooking,
|
|
1807
|
-
exports.TrybeWellnessManagement
|
|
4543
|
+
exports.TrybeWellnessManagement,
|
|
4544
|
+
exports.TrybeIntegrationConfigurationService,
|
|
4545
|
+
exports.TrybeIntegrationResourceManagementService
|
|
1808
4546
|
]
|
|
1809
4547
|
})
|
|
1810
4548
|
], exports.IntegrationTrybeModule);
|
|
1811
4549
|
|
|
1812
4550
|
// src/app.module.ts
|
|
1813
|
-
function
|
|
1814
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
1815
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
4551
|
+
function _ts_decorate22(decorators, target, key, desc2) {
|
|
4552
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4553
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
1816
4554
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1817
4555
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1818
4556
|
}
|
|
1819
|
-
__name(
|
|
4557
|
+
__name(_ts_decorate22, "_ts_decorate");
|
|
1820
4558
|
exports.OfferingIntegrationManager = class AppModule3 {
|
|
1821
4559
|
static {
|
|
1822
4560
|
__name(this, "AppModule");
|
|
1823
4561
|
}
|
|
1824
4562
|
};
|
|
1825
|
-
exports.OfferingIntegrationManager =
|
|
4563
|
+
exports.OfferingIntegrationManager = _ts_decorate22([
|
|
1826
4564
|
common.Module({
|
|
1827
4565
|
imports: [
|
|
1828
4566
|
exports.IntegrationTrybeModule,
|
|
@@ -1855,6 +4593,7 @@ exports.BaseAccountingTaxManagement = BaseAccountingTaxManagement;
|
|
|
1855
4593
|
exports.BaseAuth = BaseAuth;
|
|
1856
4594
|
exports.BaseCreditBooking = BaseCreditBooking;
|
|
1857
4595
|
exports.BaseCustomerManagement = BaseCustomerManagement;
|
|
4596
|
+
exports.BaseIntegrationResourceManagement = BaseIntegrationResourceManagement;
|
|
1858
4597
|
exports.BaseMembershipCustomerManagement = BaseMembershipCustomerManagement;
|
|
1859
4598
|
exports.BaseMembershipManagement = BaseMembershipManagement;
|
|
1860
4599
|
exports.BasePackageManagement = BasePackageManagement;
|
|
@@ -1865,11 +4604,14 @@ exports.BaseWellnessManagement = BaseWellnessManagement;
|
|
|
1865
4604
|
exports.CREDIT_FILTER_BY_ENUM = CREDIT_FILTER_BY_ENUM;
|
|
1866
4605
|
exports.CREDIT_STATUS_ENUM = CREDIT_STATUS_ENUM;
|
|
1867
4606
|
exports.CREDIT_TYPE_ENUM = CREDIT_TYPE_ENUM;
|
|
1868
|
-
exports.DAY_OF_WEEK = DAY_OF_WEEK;
|
|
1869
4607
|
exports.HTTP_METHOD = HTTP_METHOD;
|
|
1870
4608
|
exports.INTEGRATION_PROVIDER_ENUM = INTEGRATION_PROVIDER_ENUM;
|
|
4609
|
+
exports.OFFERING_INTEGRATION_MAPPING_ALREADY_EXISTS = OFFERING_INTEGRATION_MAPPING_ALREADY_EXISTS;
|
|
1871
4610
|
exports.TRAFFIC_ROUTER_CONFIGURATION_STORE_KEY = TRAFFIC_ROUTER_CONFIGURATION_STORE_KEY;
|
|
4611
|
+
exports.TRYBE_CATALOGING_BY_ENUM = TRYBE_CATALOGING_BY_ENUM;
|
|
4612
|
+
exports.TRYBE_OFFERING_TYPE_API = TRYBE_OFFERING_TYPE_API;
|
|
1872
4613
|
exports.TRYBE_OFFERING_TYPE_ENUM = TRYBE_OFFERING_TYPE_ENUM;
|
|
4614
|
+
exports.TRYBE_SUPPORTED_JOURNEYS_ENUM = TRYBE_SUPPORTED_JOURNEYS_ENUM;
|
|
1873
4615
|
exports.convertKeysToCamelCase = convertKeysToCamelCase;
|
|
1874
4616
|
exports.extractTimeFromIsoString = extractTimeFromIsoString;
|
|
1875
4617
|
exports.fetchAllPages = fetchAllPages;
|