@dv4resi/dvss-backend-module-calendar-im 0.0.3 → 0.0.4
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/README.md +247 -0
- package/dist/index.d.ts +229 -117
- package/dist/index.js +1507 -2061
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -10,9 +10,11 @@ var rxjs = require('rxjs');
|
|
|
10
10
|
var dotenv = require('dotenv');
|
|
11
11
|
var models = require('@dv4resi/dvss-backend-module-datastore/dist/datastore/models');
|
|
12
12
|
var dvssBackendModuleDatastore = require('@dv4resi/dvss-backend-module-datastore');
|
|
13
|
+
var drizzleOrm = require('drizzle-orm');
|
|
13
14
|
var common_enum = require('@dv4resi/dvss-backend-module-datastore/dist/datastore/commons/common.enum');
|
|
14
15
|
var capabilityIntegration_model = require('@dv4resi/dvss-backend-module-datastore/dist/datastore/models/capability-integration.model');
|
|
15
16
|
var capability_model = require('@dv4resi/dvss-backend-module-datastore/dist/datastore/models/capability.model');
|
|
17
|
+
var crypto = require('crypto');
|
|
16
18
|
|
|
17
19
|
function _interopNamespace(e) {
|
|
18
20
|
if (e && e.__esModule) return e;
|
|
@@ -351,6 +353,27 @@ function _ts_metadata3(k, v) {
|
|
|
351
353
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
352
354
|
}
|
|
353
355
|
__name(_ts_metadata3, "_ts_metadata");
|
|
356
|
+
var REDACTED = "***REDACTED***";
|
|
357
|
+
var SENSITIVE_HEADER_KEYS = /* @__PURE__ */ new Set([
|
|
358
|
+
"authorization",
|
|
359
|
+
"api-key",
|
|
360
|
+
"apikey",
|
|
361
|
+
"x-api-key",
|
|
362
|
+
"cookie"
|
|
363
|
+
]);
|
|
364
|
+
var SENSITIVE_BODY_KEYS = /* @__PURE__ */ new Set([
|
|
365
|
+
"access_token",
|
|
366
|
+
"refresh_token",
|
|
367
|
+
"id_token",
|
|
368
|
+
"token",
|
|
369
|
+
"client_secret",
|
|
370
|
+
"clientsecret",
|
|
371
|
+
"password",
|
|
372
|
+
"secret",
|
|
373
|
+
"api_key",
|
|
374
|
+
"apikey",
|
|
375
|
+
"authorization"
|
|
376
|
+
]);
|
|
354
377
|
exports.IntegrationRequestLoggerService = class _IntegrationRequestLoggerService {
|
|
355
378
|
static {
|
|
356
379
|
__name(this, "IntegrationRequestLoggerService");
|
|
@@ -372,7 +395,7 @@ exports.IntegrationRequestLoggerService = class _IntegrationRequestLoggerService
|
|
|
372
395
|
method,
|
|
373
396
|
url,
|
|
374
397
|
headers: this.sanitizeHeaders(headers),
|
|
375
|
-
requestBody,
|
|
398
|
+
requestBody: this.sanitizePayload(requestBody),
|
|
376
399
|
timestamp: logData.timestamp || /* @__PURE__ */ new Date()
|
|
377
400
|
});
|
|
378
401
|
}
|
|
@@ -389,7 +412,7 @@ exports.IntegrationRequestLoggerService = class _IntegrationRequestLoggerService
|
|
|
389
412
|
url,
|
|
390
413
|
statusCode,
|
|
391
414
|
duration,
|
|
392
|
-
responseBody,
|
|
415
|
+
responseBody: this.sanitizePayload(responseBody),
|
|
393
416
|
timestamp: logData.timestamp || /* @__PURE__ */ new Date()
|
|
394
417
|
});
|
|
395
418
|
}
|
|
@@ -406,8 +429,8 @@ exports.IntegrationRequestLoggerService = class _IntegrationRequestLoggerService
|
|
|
406
429
|
url,
|
|
407
430
|
statusCode,
|
|
408
431
|
duration,
|
|
409
|
-
error,
|
|
410
|
-
responseBody,
|
|
432
|
+
error: this.sanitizePayload(error),
|
|
433
|
+
responseBody: this.sanitizePayload(responseBody),
|
|
411
434
|
timestamp: logData.timestamp || /* @__PURE__ */ new Date()
|
|
412
435
|
});
|
|
413
436
|
}
|
|
@@ -439,20 +462,71 @@ exports.IntegrationRequestLoggerService = class _IntegrationRequestLoggerService
|
|
|
439
462
|
const sanitized = {
|
|
440
463
|
...headers
|
|
441
464
|
};
|
|
442
|
-
const sensitiveKeys = [
|
|
443
|
-
"authorization",
|
|
444
|
-
"api-key",
|
|
445
|
-
"apikey",
|
|
446
|
-
"x-api-key",
|
|
447
|
-
"cookie"
|
|
448
|
-
];
|
|
449
465
|
for (const key of Object.keys(sanitized)) {
|
|
450
|
-
if (
|
|
451
|
-
sanitized[key] =
|
|
466
|
+
if (SENSITIVE_HEADER_KEYS.has(key.toLowerCase())) {
|
|
467
|
+
sanitized[key] = REDACTED;
|
|
452
468
|
}
|
|
453
469
|
}
|
|
454
470
|
return sanitized;
|
|
455
471
|
}
|
|
472
|
+
/**
|
|
473
|
+
* Redact sensitive fields from request/response/error payloads before logging.
|
|
474
|
+
* Handles plain objects, arrays, and `application/x-www-form-urlencoded` strings.
|
|
475
|
+
*/
|
|
476
|
+
sanitizePayload(payload, depth = 0) {
|
|
477
|
+
if (payload == null || depth > 8) {
|
|
478
|
+
return payload;
|
|
479
|
+
}
|
|
480
|
+
if (typeof payload === "string") {
|
|
481
|
+
return this.sanitizeFormEncodedString(payload);
|
|
482
|
+
}
|
|
483
|
+
if (Array.isArray(payload)) {
|
|
484
|
+
return payload.map((item) => this.sanitizePayload(item, depth + 1));
|
|
485
|
+
}
|
|
486
|
+
if (typeof payload === "object") {
|
|
487
|
+
if (payload instanceof Error) {
|
|
488
|
+
return {
|
|
489
|
+
name: payload.name,
|
|
490
|
+
message: payload.message
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
const record = payload;
|
|
494
|
+
const sanitized = {};
|
|
495
|
+
for (const [key, value] of Object.entries(record)) {
|
|
496
|
+
if (SENSITIVE_BODY_KEYS.has(key.toLowerCase())) {
|
|
497
|
+
sanitized[key] = REDACTED;
|
|
498
|
+
continue;
|
|
499
|
+
}
|
|
500
|
+
sanitized[key] = this.sanitizePayload(value, depth + 1);
|
|
501
|
+
}
|
|
502
|
+
return sanitized;
|
|
503
|
+
}
|
|
504
|
+
return payload;
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Redacts known secret keys in URL-encoded form bodies (e.g. OAuth client_credentials).
|
|
508
|
+
* Non-form strings are returned unchanged.
|
|
509
|
+
*/
|
|
510
|
+
sanitizeFormEncodedString(value) {
|
|
511
|
+
if (!value.includes("=")) {
|
|
512
|
+
return value;
|
|
513
|
+
}
|
|
514
|
+
try {
|
|
515
|
+
const params = new URLSearchParams(value);
|
|
516
|
+
let didMutate = false;
|
|
517
|
+
for (const key of [
|
|
518
|
+
...params.keys()
|
|
519
|
+
]) {
|
|
520
|
+
if (SENSITIVE_BODY_KEYS.has(key.toLowerCase())) {
|
|
521
|
+
params.set(key, REDACTED);
|
|
522
|
+
didMutate = true;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
return didMutate ? params.toString() : value;
|
|
526
|
+
} catch {
|
|
527
|
+
return value;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
456
530
|
};
|
|
457
531
|
exports.IntegrationRequestLoggerService = _ts_decorate4([
|
|
458
532
|
common.Injectable(),
|
|
@@ -1429,1553 +1503,234 @@ var BaseAccountingMiscellaneousManagement = class {
|
|
|
1429
1503
|
}
|
|
1430
1504
|
};
|
|
1431
1505
|
|
|
1432
|
-
// ../../packages/dvss-integration-libs/src/integration-operation-skeletons/capabilities/
|
|
1506
|
+
// ../../packages/dvss-integration-libs/src/integration-operation-skeletons/capabilities/resource-management/resource-management.base.ts
|
|
1433
1507
|
var BaseCalendarResourceManagement = class {
|
|
1434
1508
|
static {
|
|
1435
1509
|
__name(this, "BaseCalendarResourceManagement");
|
|
1436
1510
|
}
|
|
1437
1511
|
};
|
|
1438
1512
|
|
|
1439
|
-
// ../../packages/dvss-integration-libs/src/integration-operation-skeletons/capabilities/
|
|
1513
|
+
// ../../packages/dvss-integration-libs/src/integration-operation-skeletons/capabilities/booking-management/booking-management.base.ts
|
|
1440
1514
|
var BaseCalendarBookingManagement = class {
|
|
1441
1515
|
static {
|
|
1442
1516
|
__name(this, "BaseCalendarBookingManagement");
|
|
1443
1517
|
}
|
|
1444
1518
|
};
|
|
1445
1519
|
|
|
1446
|
-
// ../../packages/dvss-integration-libs/src/integration-operation-skeletons/capabilities/
|
|
1520
|
+
// ../../packages/dvss-integration-libs/src/integration-operation-skeletons/capabilities/webhook-management/webhook-management.base.ts
|
|
1447
1521
|
var BaseCalendarWebhookManagement = class {
|
|
1448
1522
|
static {
|
|
1449
1523
|
__name(this, "BaseCalendarWebhookManagement");
|
|
1450
1524
|
}
|
|
1451
1525
|
};
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
return false;
|
|
1458
|
-
}
|
|
1459
|
-
if (value instanceof type) {
|
|
1460
|
-
return true;
|
|
1461
|
-
}
|
|
1462
|
-
if (!Object.prototype.hasOwnProperty.call(type, entityKind)) {
|
|
1463
|
-
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.`);
|
|
1464
|
-
}
|
|
1465
|
-
let cls = value.constructor;
|
|
1466
|
-
if (cls) {
|
|
1467
|
-
while (cls) {
|
|
1468
|
-
if (entityKind in cls && cls[entityKind] === type[entityKind]) {
|
|
1469
|
-
return true;
|
|
1470
|
-
}
|
|
1471
|
-
cls = Object.getPrototypeOf(cls);
|
|
1472
|
-
}
|
|
1473
|
-
}
|
|
1474
|
-
return false;
|
|
1526
|
+
function _ts_decorate9(decorators, target, key, desc2) {
|
|
1527
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
1528
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
1529
|
+
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;
|
|
1530
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1475
1531
|
}
|
|
1476
|
-
__name(
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1532
|
+
__name(_ts_decorate9, "_ts_decorate");
|
|
1533
|
+
function _ts_metadata6(k, v) {
|
|
1534
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1535
|
+
}
|
|
1536
|
+
__name(_ts_metadata6, "_ts_metadata");
|
|
1537
|
+
function _ts_param3(paramIndex, decorator) {
|
|
1538
|
+
return function(target, key) {
|
|
1539
|
+
decorator(target, key, paramIndex);
|
|
1540
|
+
};
|
|
1541
|
+
}
|
|
1542
|
+
__name(_ts_param3, "_ts_param");
|
|
1543
|
+
exports.IntegrationBookingDao = class IntegrationBookingDao {
|
|
1480
1544
|
static {
|
|
1481
|
-
__name(this, "
|
|
1482
|
-
}
|
|
1483
|
-
constructor(table, config2) {
|
|
1484
|
-
this.table = table;
|
|
1485
|
-
this.config = config2;
|
|
1486
|
-
this.name = config2.name;
|
|
1487
|
-
this.notNull = config2.notNull;
|
|
1488
|
-
this.default = config2.default;
|
|
1489
|
-
this.defaultFn = config2.defaultFn;
|
|
1490
|
-
this.onUpdateFn = config2.onUpdateFn;
|
|
1491
|
-
this.hasDefault = config2.hasDefault;
|
|
1492
|
-
this.primary = config2.primaryKey;
|
|
1493
|
-
this.isUnique = config2.isUnique;
|
|
1494
|
-
this.uniqueName = config2.uniqueName;
|
|
1495
|
-
this.uniqueType = config2.uniqueType;
|
|
1496
|
-
this.dataType = config2.dataType;
|
|
1497
|
-
this.columnType = config2.columnType;
|
|
1498
|
-
this.generated = config2.generated;
|
|
1499
|
-
this.generatedIdentity = config2.generatedIdentity;
|
|
1500
|
-
}
|
|
1501
|
-
static [entityKind] = "Column";
|
|
1502
|
-
name;
|
|
1503
|
-
primary;
|
|
1504
|
-
notNull;
|
|
1505
|
-
default;
|
|
1506
|
-
defaultFn;
|
|
1507
|
-
onUpdateFn;
|
|
1508
|
-
hasDefault;
|
|
1509
|
-
isUnique;
|
|
1510
|
-
uniqueName;
|
|
1511
|
-
uniqueType;
|
|
1512
|
-
dataType;
|
|
1513
|
-
columnType;
|
|
1514
|
-
enumValues = void 0;
|
|
1515
|
-
generated = void 0;
|
|
1516
|
-
generatedIdentity = void 0;
|
|
1517
|
-
config;
|
|
1518
|
-
mapFromDriverValue(value) {
|
|
1519
|
-
return value;
|
|
1520
|
-
}
|
|
1521
|
-
mapToDriverValue(value) {
|
|
1522
|
-
return value;
|
|
1545
|
+
__name(this, "IntegrationBookingDao");
|
|
1523
1546
|
}
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1547
|
+
conn;
|
|
1548
|
+
logger;
|
|
1549
|
+
fileName = "integration-booking.dao";
|
|
1550
|
+
constructor(conn, logger) {
|
|
1551
|
+
this.conn = conn;
|
|
1552
|
+
this.logger = logger;
|
|
1527
1553
|
}
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
generated: void 0
|
|
1554
|
+
async getOfferingBookingOccurrence(input) {
|
|
1555
|
+
this.logger.debug(input.loggedInUserId, this.getOfferingBookingOccurrence.name, this.fileName, "Getting offering booking occurrence with input: ", input);
|
|
1556
|
+
const conditions = [
|
|
1557
|
+
drizzleOrm.isNull(dvssBackendModuleDatastore.schema.offeringBookingOccurrence.deletedAt),
|
|
1558
|
+
drizzleOrm.eq(dvssBackendModuleDatastore.schema.offeringBookingOccurrence.id, input.offeringBookingOccurrenceId),
|
|
1559
|
+
drizzleOrm.isNull(dvssBackendModuleDatastore.schema.offeringBooking.deletedAt),
|
|
1560
|
+
drizzleOrm.isNull(dvssBackendModuleDatastore.schema.offering.deletedAt)
|
|
1561
|
+
];
|
|
1562
|
+
if (input.offeringBookingId != null) {
|
|
1563
|
+
conditions.push(drizzleOrm.eq(dvssBackendModuleDatastore.schema.offeringBooking.id, input.offeringBookingId));
|
|
1564
|
+
}
|
|
1565
|
+
const result = await this.conn.select({
|
|
1566
|
+
offeringBookingOccurrence: dvssBackendModuleDatastore.schema.offeringBookingOccurrence,
|
|
1567
|
+
offering: dvssBackendModuleDatastore.schema.offering,
|
|
1568
|
+
offeringIntentId: dvssBackendModuleDatastore.schema.offeringBooking.offeringIntentId
|
|
1569
|
+
}).from(dvssBackendModuleDatastore.schema.offeringBookingOccurrence).innerJoin(dvssBackendModuleDatastore.schema.offeringBooking, drizzleOrm.eq(dvssBackendModuleDatastore.schema.offeringBookingOccurrence.offeringBookingId, dvssBackendModuleDatastore.schema.offeringBooking.id)).innerJoin(dvssBackendModuleDatastore.schema.offering, drizzleOrm.eq(dvssBackendModuleDatastore.schema.offeringBooking.offeringId, dvssBackendModuleDatastore.schema.offering.id)).where(drizzleOrm.and(...conditions)).limit(1);
|
|
1570
|
+
if (!result[0] || result[0].offeringIntentId == null) return void 0;
|
|
1571
|
+
return {
|
|
1572
|
+
offeringBookingOccurrence: result[0].offeringBookingOccurrence,
|
|
1573
|
+
offering: result[0].offering,
|
|
1574
|
+
offeringIntentId: result[0].offeringIntentId
|
|
1550
1575
|
};
|
|
1551
1576
|
}
|
|
1552
1577
|
/**
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
* });
|
|
1561
|
-
* ```
|
|
1562
|
-
*/
|
|
1563
|
-
$type() {
|
|
1564
|
-
return this;
|
|
1565
|
-
}
|
|
1566
|
-
/**
|
|
1567
|
-
* Adds a `not null` clause to the column definition.
|
|
1568
|
-
*
|
|
1569
|
-
* Affects the `select` model of the table - columns *without* `not null` will be nullable on select.
|
|
1570
|
-
*/
|
|
1571
|
-
notNull() {
|
|
1572
|
-
this.config.notNull = true;
|
|
1573
|
-
return this;
|
|
1574
|
-
}
|
|
1575
|
-
/**
|
|
1576
|
-
* Adds a `default <value>` clause to the column definition.
|
|
1577
|
-
*
|
|
1578
|
-
* Affects the `insert` model of the table - columns *with* `default` are optional on insert.
|
|
1579
|
-
*
|
|
1580
|
-
* If you need to set a dynamic default value, use {@link $defaultFn} instead.
|
|
1581
|
-
*/
|
|
1582
|
-
default(value) {
|
|
1583
|
-
this.config.default = value;
|
|
1584
|
-
this.config.hasDefault = true;
|
|
1585
|
-
return this;
|
|
1586
|
-
}
|
|
1587
|
-
/**
|
|
1588
|
-
* Adds a dynamic default value to the column.
|
|
1589
|
-
* The function will be called when the row is inserted, and the returned value will be used as the column value.
|
|
1590
|
-
*
|
|
1591
|
-
* **Note:** This value does not affect the `drizzle-kit` behavior, it is only used at runtime in `drizzle-orm`.
|
|
1592
|
-
*/
|
|
1593
|
-
$defaultFn(fn) {
|
|
1594
|
-
this.config.defaultFn = fn;
|
|
1595
|
-
this.config.hasDefault = true;
|
|
1596
|
-
return this;
|
|
1597
|
-
}
|
|
1598
|
-
/**
|
|
1599
|
-
* Alias for {@link $defaultFn}.
|
|
1600
|
-
*/
|
|
1601
|
-
$default = this.$defaultFn;
|
|
1602
|
-
/**
|
|
1603
|
-
* Adds a dynamic update value to the column.
|
|
1604
|
-
* 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.
|
|
1605
|
-
* 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.
|
|
1606
|
-
*
|
|
1607
|
-
* **Note:** This value does not affect the `drizzle-kit` behavior, it is only used at runtime in `drizzle-orm`.
|
|
1608
|
-
*/
|
|
1609
|
-
$onUpdateFn(fn) {
|
|
1610
|
-
this.config.onUpdateFn = fn;
|
|
1611
|
-
this.config.hasDefault = true;
|
|
1612
|
-
return this;
|
|
1613
|
-
}
|
|
1614
|
-
/**
|
|
1615
|
-
* Alias for {@link $onUpdateFn}.
|
|
1616
|
-
*/
|
|
1617
|
-
$onUpdate = this.$onUpdateFn;
|
|
1618
|
-
/**
|
|
1619
|
-
* Adds a `primary key` clause to the column definition. This implicitly makes the column `not null`.
|
|
1620
|
-
*
|
|
1621
|
-
* In SQLite, `integer primary key` implicitly makes the column auto-incrementing.
|
|
1622
|
-
*/
|
|
1623
|
-
primaryKey() {
|
|
1624
|
-
this.config.primaryKey = true;
|
|
1625
|
-
this.config.notNull = true;
|
|
1626
|
-
return this;
|
|
1578
|
+
* Fetches offering intent by id.
|
|
1579
|
+
*/
|
|
1580
|
+
async getOfferingIntent(input) {
|
|
1581
|
+
const row = await this.conn.query.offeringIntent.findFirst({
|
|
1582
|
+
where: drizzleOrm.and(drizzleOrm.isNull(dvssBackendModuleDatastore.schema.offeringIntent.deletedAt), drizzleOrm.eq(dvssBackendModuleDatastore.schema.offeringIntent.id, input.offeringIntentId))
|
|
1583
|
+
});
|
|
1584
|
+
return row ?? void 0;
|
|
1627
1585
|
}
|
|
1628
1586
|
};
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
var
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
BaseName,
|
|
1653
|
-
IsAlias,
|
|
1654
|
-
ExtraConfigBuilder
|
|
1587
|
+
exports.IntegrationBookingDao = _ts_decorate9([
|
|
1588
|
+
common.Injectable(),
|
|
1589
|
+
_ts_param3(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
|
|
1590
|
+
_ts_metadata6("design:type", Function),
|
|
1591
|
+
_ts_metadata6("design:paramtypes", [
|
|
1592
|
+
typeof MySql2Database === "undefined" ? Object : MySql2Database,
|
|
1593
|
+
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
|
|
1594
|
+
])
|
|
1595
|
+
], exports.IntegrationBookingDao);
|
|
1596
|
+
function _ts_decorate10(decorators, target, key, desc2) {
|
|
1597
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
1598
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
1599
|
+
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;
|
|
1600
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1601
|
+
}
|
|
1602
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
1603
|
+
function _ts_metadata7(k, v) {
|
|
1604
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1605
|
+
}
|
|
1606
|
+
__name(_ts_metadata7, "_ts_metadata");
|
|
1607
|
+
function _ts_param4(paramIndex, decorator) {
|
|
1608
|
+
return function(target, key) {
|
|
1609
|
+
decorator(target, key, paramIndex);
|
|
1655
1610
|
};
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
*/
|
|
1660
|
-
[TableName];
|
|
1661
|
-
/**
|
|
1662
|
-
* @internal
|
|
1663
|
-
* Used to store the original name of the table, before any aliasing.
|
|
1664
|
-
*/
|
|
1665
|
-
[OriginalName];
|
|
1666
|
-
/** @internal */
|
|
1667
|
-
[Schema];
|
|
1668
|
-
/** @internal */
|
|
1669
|
-
[Columns];
|
|
1670
|
-
/** @internal */
|
|
1671
|
-
[ExtraConfigColumns];
|
|
1672
|
-
/**
|
|
1673
|
-
* @internal
|
|
1674
|
-
* Used to store the table name before the transformation via the `tableCreator` functions.
|
|
1675
|
-
*/
|
|
1676
|
-
[BaseName];
|
|
1677
|
-
/** @internal */
|
|
1678
|
-
[IsAlias] = false;
|
|
1679
|
-
/** @internal */
|
|
1680
|
-
[IsDrizzleTable] = true;
|
|
1681
|
-
/** @internal */
|
|
1682
|
-
[ExtraConfigBuilder] = void 0;
|
|
1683
|
-
constructor(name, schema9, baseName) {
|
|
1684
|
-
this[TableName] = this[OriginalName] = name;
|
|
1685
|
-
this[Schema] = schema9;
|
|
1686
|
-
this[BaseName] = baseName;
|
|
1687
|
-
}
|
|
1688
|
-
};
|
|
1689
|
-
|
|
1690
|
-
// ../../node_modules/drizzle-orm/pg-core/table.js
|
|
1691
|
-
var InlineForeignKeys = /* @__PURE__ */ Symbol.for("drizzle:PgInlineForeignKeys");
|
|
1692
|
-
var PgTable = class PgTable2 extends Table {
|
|
1693
|
-
static {
|
|
1694
|
-
__name(this, "PgTable");
|
|
1695
|
-
}
|
|
1696
|
-
static [entityKind] = "PgTable";
|
|
1697
|
-
/** @internal */
|
|
1698
|
-
static Symbol = Object.assign({}, Table.Symbol, {
|
|
1699
|
-
InlineForeignKeys
|
|
1700
|
-
});
|
|
1701
|
-
/**@internal */
|
|
1702
|
-
[InlineForeignKeys] = [];
|
|
1703
|
-
/** @internal */
|
|
1704
|
-
[Table.Symbol.ExtraConfigBuilder] = void 0;
|
|
1705
|
-
};
|
|
1706
|
-
|
|
1707
|
-
// ../../node_modules/drizzle-orm/pg-core/foreign-keys.js
|
|
1708
|
-
var ForeignKeyBuilder = class ForeignKeyBuilder2 {
|
|
1611
|
+
}
|
|
1612
|
+
__name(_ts_param4, "_ts_param");
|
|
1613
|
+
exports.IntegrationCommonDao = class IntegrationCommonDao {
|
|
1709
1614
|
static {
|
|
1710
|
-
__name(this, "
|
|
1711
|
-
}
|
|
1712
|
-
static [entityKind] = "PgForeignKeyBuilder";
|
|
1713
|
-
/** @internal */
|
|
1714
|
-
reference;
|
|
1715
|
-
/** @internal */
|
|
1716
|
-
_onUpdate = "no action";
|
|
1717
|
-
/** @internal */
|
|
1718
|
-
_onDelete = "no action";
|
|
1719
|
-
constructor(config2, actions) {
|
|
1720
|
-
this.reference = () => {
|
|
1721
|
-
const { name, columns, foreignColumns } = config2();
|
|
1722
|
-
return {
|
|
1723
|
-
name,
|
|
1724
|
-
columns,
|
|
1725
|
-
foreignTable: foreignColumns[0].table,
|
|
1726
|
-
foreignColumns
|
|
1727
|
-
};
|
|
1728
|
-
};
|
|
1729
|
-
if (actions) {
|
|
1730
|
-
this._onUpdate = actions.onUpdate;
|
|
1731
|
-
this._onDelete = actions.onDelete;
|
|
1732
|
-
}
|
|
1733
|
-
}
|
|
1734
|
-
onUpdate(action) {
|
|
1735
|
-
this._onUpdate = action === void 0 ? "no action" : action;
|
|
1736
|
-
return this;
|
|
1737
|
-
}
|
|
1738
|
-
onDelete(action) {
|
|
1739
|
-
this._onDelete = action === void 0 ? "no action" : action;
|
|
1740
|
-
return this;
|
|
1615
|
+
__name(this, "IntegrationCommonDao");
|
|
1741
1616
|
}
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1617
|
+
conn;
|
|
1618
|
+
logger;
|
|
1619
|
+
fileName = "integration-common.dao";
|
|
1620
|
+
constructor(conn, logger) {
|
|
1621
|
+
this.conn = conn;
|
|
1622
|
+
this.logger = logger;
|
|
1745
1623
|
}
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1624
|
+
/**
|
|
1625
|
+
* Gets timezone using userContext (first propertyId) with fallback to projectId
|
|
1626
|
+
* First tries to get timezone from user's first propertyId, then falls back to projectId
|
|
1627
|
+
* @param input - Object containing projectId and loggedInUserId
|
|
1628
|
+
* @returns Promise resolving to timezone string
|
|
1629
|
+
*/
|
|
1630
|
+
async getTimezoneForRequest(input) {
|
|
1631
|
+
const { projectId, loggedInUserId } = input;
|
|
1632
|
+
try {
|
|
1633
|
+
const userBehavior = await this.conn.query.userIdentityBehaviorMapping.findFirst({
|
|
1634
|
+
where: drizzleOrm.and(drizzleOrm.eq(dvssBackendModuleDatastore.schema.userIdentityBehaviorMapping.userIdentityId, loggedInUserId), drizzleOrm.isNotNull(dvssBackendModuleDatastore.schema.userIdentityBehaviorMapping.propertyId), drizzleOrm.isNull(dvssBackendModuleDatastore.schema.userIdentityBehaviorMapping.deletedAt)),
|
|
1635
|
+
with: {
|
|
1636
|
+
property: true
|
|
1637
|
+
}
|
|
1638
|
+
});
|
|
1639
|
+
if (userBehavior?.propertyId && userBehavior.property?.timezone) {
|
|
1640
|
+
this.logger.info(loggedInUserId, this.getTimezoneForRequest.name, this.fileName, "Successfully fetched property timezone using userContext", {
|
|
1641
|
+
projectId,
|
|
1642
|
+
loggedInUserId,
|
|
1643
|
+
propertyId: userBehavior.propertyId,
|
|
1644
|
+
timezone: userBehavior.property.timezone
|
|
1645
|
+
});
|
|
1646
|
+
return userBehavior.property.timezone;
|
|
1647
|
+
}
|
|
1648
|
+
if (projectId) {
|
|
1649
|
+
const properties = await this.conn.query.property.findMany({
|
|
1650
|
+
where: drizzleOrm.and(drizzleOrm.eq(dvssBackendModuleDatastore.schema.property.projectId, projectId), drizzleOrm.isNull(dvssBackendModuleDatastore.schema.property.deletedAt)),
|
|
1651
|
+
limit: 1
|
|
1652
|
+
});
|
|
1653
|
+
if (properties.length > 0 && properties[0].timezone) {
|
|
1654
|
+
this.logger.info(loggedInUserId, this.getTimezoneForRequest.name, this.fileName, "Successfully fetched property timezone using projectId", {
|
|
1655
|
+
projectId,
|
|
1656
|
+
propertyId: properties[0].id,
|
|
1657
|
+
timezone: properties[0].timezone
|
|
1658
|
+
});
|
|
1659
|
+
return properties[0].timezone;
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
} catch (error) {
|
|
1663
|
+
this.logger.warn(loggedInUserId, this.getTimezoneForRequest.name, this.fileName, "Error fetching property timezone, using default", {
|
|
1664
|
+
projectId,
|
|
1665
|
+
error
|
|
1666
|
+
});
|
|
1667
|
+
}
|
|
1668
|
+
return dvssBackendModuleUtility.DEFAULT_TIMEZONE;
|
|
1772
1669
|
}
|
|
1773
1670
|
};
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1671
|
+
exports.IntegrationCommonDao = _ts_decorate10([
|
|
1672
|
+
common.Injectable(),
|
|
1673
|
+
_ts_param4(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
|
|
1674
|
+
_ts_metadata7("design:type", Function),
|
|
1675
|
+
_ts_metadata7("design:paramtypes", [
|
|
1676
|
+
typeof MySql2Database === "undefined" ? Object : MySql2Database,
|
|
1677
|
+
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
|
|
1678
|
+
])
|
|
1679
|
+
], exports.IntegrationCommonDao);
|
|
1680
|
+
function _ts_decorate11(decorators, target, key, desc2) {
|
|
1681
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
1682
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
1683
|
+
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;
|
|
1684
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1778
1685
|
}
|
|
1779
|
-
__name(
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1686
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
1687
|
+
function _ts_metadata8(k, v) {
|
|
1688
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1689
|
+
}
|
|
1690
|
+
__name(_ts_metadata8, "_ts_metadata");
|
|
1691
|
+
function _ts_param5(paramIndex, decorator) {
|
|
1692
|
+
return function(target, key) {
|
|
1693
|
+
decorator(target, key, paramIndex);
|
|
1694
|
+
};
|
|
1784
1695
|
}
|
|
1785
|
-
__name(
|
|
1786
|
-
|
|
1696
|
+
__name(_ts_param5, "_ts_param");
|
|
1697
|
+
exports.IntegrationSubcapabilityDao = class IntegrationSubcapabilityDao {
|
|
1787
1698
|
static {
|
|
1788
|
-
__name(this, "
|
|
1789
|
-
}
|
|
1790
|
-
constructor(columns, name) {
|
|
1791
|
-
this.name = name;
|
|
1792
|
-
this.columns = columns;
|
|
1699
|
+
__name(this, "IntegrationSubcapabilityDao");
|
|
1793
1700
|
}
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
this.nullsNotDistinctConfig = true;
|
|
1801
|
-
return this;
|
|
1701
|
+
conn;
|
|
1702
|
+
logger;
|
|
1703
|
+
fileName = "integration-subcapability.dao";
|
|
1704
|
+
constructor(conn, logger) {
|
|
1705
|
+
this.conn = conn;
|
|
1706
|
+
this.logger = logger;
|
|
1802
1707
|
}
|
|
1803
|
-
/**
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
(
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
}
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
this.name = name ?? uniqueKeyName(this.table, this.columns.map((column) => column.name));
|
|
1830
|
-
this.nullsNotDistinct = nullsNotDistinct;
|
|
1831
|
-
}
|
|
1832
|
-
static [entityKind] = "PgUniqueConstraint";
|
|
1833
|
-
columns;
|
|
1834
|
-
name;
|
|
1835
|
-
nullsNotDistinct = false;
|
|
1836
|
-
getName() {
|
|
1837
|
-
return this.name;
|
|
1838
|
-
}
|
|
1839
|
-
};
|
|
1840
|
-
|
|
1841
|
-
// ../../node_modules/drizzle-orm/pg-core/utils/array.js
|
|
1842
|
-
function parsePgArrayValue(arrayString, startFrom, inQuotes) {
|
|
1843
|
-
for (let i = startFrom; i < arrayString.length; i++) {
|
|
1844
|
-
const char = arrayString[i];
|
|
1845
|
-
if (char === "\\") {
|
|
1846
|
-
i++;
|
|
1847
|
-
continue;
|
|
1848
|
-
}
|
|
1849
|
-
if (char === '"') {
|
|
1850
|
-
return [
|
|
1851
|
-
arrayString.slice(startFrom, i).replace(/\\/g, ""),
|
|
1852
|
-
i + 1
|
|
1853
|
-
];
|
|
1854
|
-
}
|
|
1855
|
-
if (inQuotes) {
|
|
1856
|
-
continue;
|
|
1857
|
-
}
|
|
1858
|
-
if (char === "," || char === "}") {
|
|
1859
|
-
return [
|
|
1860
|
-
arrayString.slice(startFrom, i).replace(/\\/g, ""),
|
|
1861
|
-
i
|
|
1862
|
-
];
|
|
1863
|
-
}
|
|
1864
|
-
}
|
|
1865
|
-
return [
|
|
1866
|
-
arrayString.slice(startFrom).replace(/\\/g, ""),
|
|
1867
|
-
arrayString.length
|
|
1868
|
-
];
|
|
1869
|
-
}
|
|
1870
|
-
__name(parsePgArrayValue, "parsePgArrayValue");
|
|
1871
|
-
function parsePgNestedArray(arrayString, startFrom = 0) {
|
|
1872
|
-
const result = [];
|
|
1873
|
-
let i = startFrom;
|
|
1874
|
-
let lastCharIsComma = false;
|
|
1875
|
-
while (i < arrayString.length) {
|
|
1876
|
-
const char = arrayString[i];
|
|
1877
|
-
if (char === ",") {
|
|
1878
|
-
if (lastCharIsComma || i === startFrom) {
|
|
1879
|
-
result.push("");
|
|
1880
|
-
}
|
|
1881
|
-
lastCharIsComma = true;
|
|
1882
|
-
i++;
|
|
1883
|
-
continue;
|
|
1884
|
-
}
|
|
1885
|
-
lastCharIsComma = false;
|
|
1886
|
-
if (char === "\\") {
|
|
1887
|
-
i += 2;
|
|
1888
|
-
continue;
|
|
1889
|
-
}
|
|
1890
|
-
if (char === '"') {
|
|
1891
|
-
const [value2, startFrom2] = parsePgArrayValue(arrayString, i + 1, true);
|
|
1892
|
-
result.push(value2);
|
|
1893
|
-
i = startFrom2;
|
|
1894
|
-
continue;
|
|
1895
|
-
}
|
|
1896
|
-
if (char === "}") {
|
|
1897
|
-
return [
|
|
1898
|
-
result,
|
|
1899
|
-
i + 1
|
|
1900
|
-
];
|
|
1901
|
-
}
|
|
1902
|
-
if (char === "{") {
|
|
1903
|
-
const [value2, startFrom2] = parsePgNestedArray(arrayString, i + 1);
|
|
1904
|
-
result.push(value2);
|
|
1905
|
-
i = startFrom2;
|
|
1906
|
-
continue;
|
|
1907
|
-
}
|
|
1908
|
-
const [value, newStartFrom] = parsePgArrayValue(arrayString, i, false);
|
|
1909
|
-
result.push(value);
|
|
1910
|
-
i = newStartFrom;
|
|
1911
|
-
}
|
|
1912
|
-
return [
|
|
1913
|
-
result,
|
|
1914
|
-
i
|
|
1915
|
-
];
|
|
1916
|
-
}
|
|
1917
|
-
__name(parsePgNestedArray, "parsePgNestedArray");
|
|
1918
|
-
function parsePgArray(arrayString) {
|
|
1919
|
-
const [result] = parsePgNestedArray(arrayString, 1);
|
|
1920
|
-
return result;
|
|
1921
|
-
}
|
|
1922
|
-
__name(parsePgArray, "parsePgArray");
|
|
1923
|
-
function makePgArray(array) {
|
|
1924
|
-
return `{${array.map((item) => {
|
|
1925
|
-
if (Array.isArray(item)) {
|
|
1926
|
-
return makePgArray(item);
|
|
1927
|
-
}
|
|
1928
|
-
if (typeof item === "string") {
|
|
1929
|
-
return `"${item.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
1930
|
-
}
|
|
1931
|
-
return `${item}`;
|
|
1932
|
-
}).join(",")}}`;
|
|
1933
|
-
}
|
|
1934
|
-
__name(makePgArray, "makePgArray");
|
|
1935
|
-
|
|
1936
|
-
// ../../node_modules/drizzle-orm/pg-core/columns/common.js
|
|
1937
|
-
var PgColumnBuilder = class PgColumnBuilder2 extends ColumnBuilder {
|
|
1938
|
-
static {
|
|
1939
|
-
__name(this, "PgColumnBuilder");
|
|
1940
|
-
}
|
|
1941
|
-
foreignKeyConfigs = [];
|
|
1942
|
-
static [entityKind] = "PgColumnBuilder";
|
|
1943
|
-
array(size) {
|
|
1944
|
-
return new PgArrayBuilder(this.config.name, this, size);
|
|
1945
|
-
}
|
|
1946
|
-
references(ref, actions = {}) {
|
|
1947
|
-
this.foreignKeyConfigs.push({
|
|
1948
|
-
ref,
|
|
1949
|
-
actions
|
|
1950
|
-
});
|
|
1951
|
-
return this;
|
|
1952
|
-
}
|
|
1953
|
-
unique(name, config2) {
|
|
1954
|
-
this.config.isUnique = true;
|
|
1955
|
-
this.config.uniqueName = name;
|
|
1956
|
-
this.config.uniqueType = config2?.nulls;
|
|
1957
|
-
return this;
|
|
1958
|
-
}
|
|
1959
|
-
generatedAlwaysAs(as) {
|
|
1960
|
-
this.config.generated = {
|
|
1961
|
-
as,
|
|
1962
|
-
type: "always",
|
|
1963
|
-
mode: "stored"
|
|
1964
|
-
};
|
|
1965
|
-
return this;
|
|
1966
|
-
}
|
|
1967
|
-
/** @internal */
|
|
1968
|
-
buildForeignKeys(column, table) {
|
|
1969
|
-
return this.foreignKeyConfigs.map(({ ref, actions }) => {
|
|
1970
|
-
return iife((ref2, actions2) => {
|
|
1971
|
-
const builder = new ForeignKeyBuilder(() => {
|
|
1972
|
-
const foreignColumn = ref2();
|
|
1973
|
-
return {
|
|
1974
|
-
columns: [
|
|
1975
|
-
column
|
|
1976
|
-
],
|
|
1977
|
-
foreignColumns: [
|
|
1978
|
-
foreignColumn
|
|
1979
|
-
]
|
|
1980
|
-
};
|
|
1981
|
-
});
|
|
1982
|
-
if (actions2.onUpdate) {
|
|
1983
|
-
builder.onUpdate(actions2.onUpdate);
|
|
1984
|
-
}
|
|
1985
|
-
if (actions2.onDelete) {
|
|
1986
|
-
builder.onDelete(actions2.onDelete);
|
|
1987
|
-
}
|
|
1988
|
-
return builder.build(table);
|
|
1989
|
-
}, ref, actions);
|
|
1990
|
-
});
|
|
1991
|
-
}
|
|
1992
|
-
/** @internal */
|
|
1993
|
-
buildExtraConfigColumn(table) {
|
|
1994
|
-
return new ExtraConfigColumn(table, this.config);
|
|
1995
|
-
}
|
|
1996
|
-
};
|
|
1997
|
-
var PgColumn = class PgColumn2 extends Column {
|
|
1998
|
-
static {
|
|
1999
|
-
__name(this, "PgColumn");
|
|
2000
|
-
}
|
|
2001
|
-
constructor(table, config2) {
|
|
2002
|
-
if (!config2.uniqueName) {
|
|
2003
|
-
config2.uniqueName = uniqueKeyName(table, [
|
|
2004
|
-
config2.name
|
|
2005
|
-
]);
|
|
2006
|
-
}
|
|
2007
|
-
super(table, config2);
|
|
2008
|
-
this.table = table;
|
|
2009
|
-
}
|
|
2010
|
-
static [entityKind] = "PgColumn";
|
|
2011
|
-
};
|
|
2012
|
-
var ExtraConfigColumn = class ExtraConfigColumn2 extends PgColumn {
|
|
2013
|
-
static {
|
|
2014
|
-
__name(this, "ExtraConfigColumn");
|
|
2015
|
-
}
|
|
2016
|
-
static [entityKind] = "ExtraConfigColumn";
|
|
2017
|
-
getSQLType() {
|
|
2018
|
-
return this.getSQLType();
|
|
2019
|
-
}
|
|
2020
|
-
indexConfig = {
|
|
2021
|
-
order: this.config.order ?? "asc",
|
|
2022
|
-
nulls: this.config.nulls ?? "last",
|
|
2023
|
-
opClass: this.config.opClass
|
|
2024
|
-
};
|
|
2025
|
-
defaultConfig = {
|
|
2026
|
-
order: "asc",
|
|
2027
|
-
nulls: "last",
|
|
2028
|
-
opClass: void 0
|
|
2029
|
-
};
|
|
2030
|
-
asc() {
|
|
2031
|
-
this.indexConfig.order = "asc";
|
|
2032
|
-
return this;
|
|
2033
|
-
}
|
|
2034
|
-
desc() {
|
|
2035
|
-
this.indexConfig.order = "desc";
|
|
2036
|
-
return this;
|
|
2037
|
-
}
|
|
2038
|
-
nullsFirst() {
|
|
2039
|
-
this.indexConfig.nulls = "first";
|
|
2040
|
-
return this;
|
|
2041
|
-
}
|
|
2042
|
-
nullsLast() {
|
|
2043
|
-
this.indexConfig.nulls = "last";
|
|
2044
|
-
return this;
|
|
2045
|
-
}
|
|
2046
|
-
/**
|
|
2047
|
-
* ### PostgreSQL documentation quote
|
|
2048
|
-
*
|
|
2049
|
-
* > An operator class with optional parameters can be specified for each column of an index.
|
|
2050
|
-
* The operator class identifies the operators to be used by the index for that column.
|
|
2051
|
-
* For example, a B-tree index on four-byte integers would use the int4_ops class;
|
|
2052
|
-
* this operator class includes comparison functions for four-byte integers.
|
|
2053
|
-
* In practice the default operator class for the column's data type is usually sufficient.
|
|
2054
|
-
* The main point of having operator classes is that for some data types, there could be more than one meaningful ordering.
|
|
2055
|
-
* For example, we might want to sort a complex-number data type either by absolute value or by real part.
|
|
2056
|
-
* We could do this by defining two operator classes for the data type and then selecting the proper class when creating an index.
|
|
2057
|
-
* More information about operator classes check:
|
|
2058
|
-
*
|
|
2059
|
-
* ### Useful links
|
|
2060
|
-
* https://www.postgresql.org/docs/current/sql-createindex.html
|
|
2061
|
-
*
|
|
2062
|
-
* https://www.postgresql.org/docs/current/indexes-opclass.html
|
|
2063
|
-
*
|
|
2064
|
-
* https://www.postgresql.org/docs/current/xindex.html
|
|
2065
|
-
*
|
|
2066
|
-
* ### Additional types
|
|
2067
|
-
* If you have the `pg_vector` extension installed in your database, you can use the
|
|
2068
|
-
* `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.
|
|
2069
|
-
*
|
|
2070
|
-
* **You can always specify any string you want in the operator class, in case Drizzle doesn't have it natively in its types**
|
|
2071
|
-
*
|
|
2072
|
-
* @param opClass
|
|
2073
|
-
* @returns
|
|
2074
|
-
*/
|
|
2075
|
-
op(opClass) {
|
|
2076
|
-
this.indexConfig.opClass = opClass;
|
|
2077
|
-
return this;
|
|
2078
|
-
}
|
|
2079
|
-
};
|
|
2080
|
-
(class IndexedColumn2 {
|
|
2081
|
-
static {
|
|
2082
|
-
__name(this, "IndexedColumn");
|
|
2083
|
-
}
|
|
2084
|
-
static [entityKind] = "IndexedColumn";
|
|
2085
|
-
constructor(name, type, indexConfig) {
|
|
2086
|
-
this.name = name;
|
|
2087
|
-
this.type = type;
|
|
2088
|
-
this.indexConfig = indexConfig;
|
|
2089
|
-
}
|
|
2090
|
-
name;
|
|
2091
|
-
type;
|
|
2092
|
-
indexConfig;
|
|
2093
|
-
});
|
|
2094
|
-
var PgArrayBuilder = class PgArrayBuilder2 extends PgColumnBuilder {
|
|
2095
|
-
static {
|
|
2096
|
-
__name(this, "PgArrayBuilder");
|
|
2097
|
-
}
|
|
2098
|
-
static [entityKind] = "PgArrayBuilder";
|
|
2099
|
-
constructor(name, baseBuilder, size) {
|
|
2100
|
-
super(name, "array", "PgArray");
|
|
2101
|
-
this.config.baseBuilder = baseBuilder;
|
|
2102
|
-
this.config.size = size;
|
|
2103
|
-
}
|
|
2104
|
-
/** @internal */
|
|
2105
|
-
build(table) {
|
|
2106
|
-
const baseColumn = this.config.baseBuilder.build(table);
|
|
2107
|
-
return new PgArray(table, this.config, baseColumn);
|
|
2108
|
-
}
|
|
2109
|
-
};
|
|
2110
|
-
var PgArray = class PgArray2 extends PgColumn {
|
|
2111
|
-
static {
|
|
2112
|
-
__name(this, "PgArray");
|
|
2113
|
-
}
|
|
2114
|
-
constructor(table, config2, baseColumn, range) {
|
|
2115
|
-
super(table, config2);
|
|
2116
|
-
this.baseColumn = baseColumn;
|
|
2117
|
-
this.range = range;
|
|
2118
|
-
this.size = config2.size;
|
|
2119
|
-
}
|
|
2120
|
-
size;
|
|
2121
|
-
static [entityKind] = "PgArray";
|
|
2122
|
-
getSQLType() {
|
|
2123
|
-
return `${this.baseColumn.getSQLType()}[${typeof this.size === "number" ? this.size : ""}]`;
|
|
2124
|
-
}
|
|
2125
|
-
mapFromDriverValue(value) {
|
|
2126
|
-
if (typeof value === "string") {
|
|
2127
|
-
value = parsePgArray(value);
|
|
2128
|
-
}
|
|
2129
|
-
return value.map((v) => this.baseColumn.mapFromDriverValue(v));
|
|
2130
|
-
}
|
|
2131
|
-
mapToDriverValue(value, isNestedArray = false) {
|
|
2132
|
-
const a = value.map((v) => v === null ? null : is(this.baseColumn, PgArray2) ? this.baseColumn.mapToDriverValue(v, true) : this.baseColumn.mapToDriverValue(v));
|
|
2133
|
-
if (isNestedArray) return a;
|
|
2134
|
-
return makePgArray(a);
|
|
2135
|
-
}
|
|
2136
|
-
};
|
|
2137
|
-
|
|
2138
|
-
// ../../node_modules/drizzle-orm/pg-core/columns/enum.js
|
|
2139
|
-
var isPgEnumSym = /* @__PURE__ */ Symbol.for("drizzle:isPgEnum");
|
|
2140
|
-
function isPgEnum(obj) {
|
|
2141
|
-
return !!obj && typeof obj === "function" && isPgEnumSym in obj && obj[isPgEnumSym] === true;
|
|
2142
|
-
}
|
|
2143
|
-
__name(isPgEnum, "isPgEnum");
|
|
2144
|
-
(class PgEnumColumnBuilder2 extends PgColumnBuilder {
|
|
2145
|
-
static {
|
|
2146
|
-
__name(this, "PgEnumColumnBuilder");
|
|
2147
|
-
}
|
|
2148
|
-
static [entityKind] = "PgEnumColumnBuilder";
|
|
2149
|
-
constructor(name, enumInstance) {
|
|
2150
|
-
super(name, "string", "PgEnumColumn");
|
|
2151
|
-
this.config.enum = enumInstance;
|
|
2152
|
-
}
|
|
2153
|
-
/** @internal */
|
|
2154
|
-
build(table) {
|
|
2155
|
-
return new PgEnumColumn(table, this.config);
|
|
2156
|
-
}
|
|
2157
|
-
});
|
|
2158
|
-
var PgEnumColumn = class PgEnumColumn2 extends PgColumn {
|
|
2159
|
-
static {
|
|
2160
|
-
__name(this, "PgEnumColumn");
|
|
2161
|
-
}
|
|
2162
|
-
static [entityKind] = "PgEnumColumn";
|
|
2163
|
-
enum = this.config.enum;
|
|
2164
|
-
enumValues = this.config.enum.enumValues;
|
|
2165
|
-
constructor(table, config2) {
|
|
2166
|
-
super(table, config2);
|
|
2167
|
-
this.enum = config2.enum;
|
|
2168
|
-
}
|
|
2169
|
-
getSQLType() {
|
|
2170
|
-
return this.enum.enumName;
|
|
2171
|
-
}
|
|
2172
|
-
};
|
|
2173
|
-
|
|
2174
|
-
// ../../node_modules/drizzle-orm/subquery.js
|
|
2175
|
-
var Subquery = class Subquery2 {
|
|
2176
|
-
static {
|
|
2177
|
-
__name(this, "Subquery");
|
|
2178
|
-
}
|
|
2179
|
-
static [entityKind] = "Subquery";
|
|
2180
|
-
constructor(sql2, selection, alias, isWith = false) {
|
|
2181
|
-
this._ = {
|
|
2182
|
-
brand: "Subquery",
|
|
2183
|
-
sql: sql2,
|
|
2184
|
-
selectedFields: selection,
|
|
2185
|
-
alias,
|
|
2186
|
-
isWith
|
|
2187
|
-
};
|
|
2188
|
-
}
|
|
2189
|
-
};
|
|
2190
|
-
(class WithSubquery2 extends Subquery {
|
|
2191
|
-
static {
|
|
2192
|
-
__name(this, "WithSubquery");
|
|
2193
|
-
}
|
|
2194
|
-
static [entityKind] = "WithSubquery";
|
|
2195
|
-
});
|
|
2196
|
-
var tracer = {
|
|
2197
|
-
startActiveSpan(name, fn) {
|
|
2198
|
-
{
|
|
2199
|
-
return fn();
|
|
2200
|
-
}
|
|
2201
|
-
}
|
|
2202
|
-
};
|
|
2203
|
-
|
|
2204
|
-
// ../../node_modules/drizzle-orm/view-common.js
|
|
2205
|
-
var ViewBaseConfig = /* @__PURE__ */ Symbol.for("drizzle:ViewBaseConfig");
|
|
2206
|
-
|
|
2207
|
-
// ../../node_modules/drizzle-orm/sql/sql.js
|
|
2208
|
-
(class FakePrimitiveParam2 {
|
|
2209
|
-
static {
|
|
2210
|
-
__name(this, "FakePrimitiveParam");
|
|
2211
|
-
}
|
|
2212
|
-
static [entityKind] = "FakePrimitiveParam";
|
|
2213
|
-
});
|
|
2214
|
-
function isSQLWrapper(value) {
|
|
2215
|
-
return value !== null && value !== void 0 && typeof value.getSQL === "function";
|
|
2216
|
-
}
|
|
2217
|
-
__name(isSQLWrapper, "isSQLWrapper");
|
|
2218
|
-
function mergeQueries(queries) {
|
|
2219
|
-
const result = {
|
|
2220
|
-
sql: "",
|
|
2221
|
-
params: []
|
|
2222
|
-
};
|
|
2223
|
-
for (const query of queries) {
|
|
2224
|
-
result.sql += query.sql;
|
|
2225
|
-
result.params.push(...query.params);
|
|
2226
|
-
if (query.typings?.length) {
|
|
2227
|
-
if (!result.typings) {
|
|
2228
|
-
result.typings = [];
|
|
2229
|
-
}
|
|
2230
|
-
result.typings.push(...query.typings);
|
|
2231
|
-
}
|
|
2232
|
-
}
|
|
2233
|
-
return result;
|
|
2234
|
-
}
|
|
2235
|
-
__name(mergeQueries, "mergeQueries");
|
|
2236
|
-
var StringChunk = class StringChunk2 {
|
|
2237
|
-
static {
|
|
2238
|
-
__name(this, "StringChunk");
|
|
2239
|
-
}
|
|
2240
|
-
static [entityKind] = "StringChunk";
|
|
2241
|
-
value;
|
|
2242
|
-
constructor(value) {
|
|
2243
|
-
this.value = Array.isArray(value) ? value : [
|
|
2244
|
-
value
|
|
2245
|
-
];
|
|
2246
|
-
}
|
|
2247
|
-
getSQL() {
|
|
2248
|
-
return new SQL([
|
|
2249
|
-
this
|
|
2250
|
-
]);
|
|
2251
|
-
}
|
|
2252
|
-
};
|
|
2253
|
-
var SQL = class SQL2 {
|
|
2254
|
-
static {
|
|
2255
|
-
__name(this, "SQL");
|
|
2256
|
-
}
|
|
2257
|
-
constructor(queryChunks) {
|
|
2258
|
-
this.queryChunks = queryChunks;
|
|
2259
|
-
}
|
|
2260
|
-
static [entityKind] = "SQL";
|
|
2261
|
-
/** @internal */
|
|
2262
|
-
decoder = noopDecoder;
|
|
2263
|
-
shouldInlineParams = false;
|
|
2264
|
-
append(query) {
|
|
2265
|
-
this.queryChunks.push(...query.queryChunks);
|
|
2266
|
-
return this;
|
|
2267
|
-
}
|
|
2268
|
-
toQuery(config2) {
|
|
2269
|
-
return tracer.startActiveSpan("drizzle.buildSQL", (span) => {
|
|
2270
|
-
const query = this.buildQueryFromSourceParams(this.queryChunks, config2);
|
|
2271
|
-
span?.setAttributes({
|
|
2272
|
-
"drizzle.query.text": query.sql,
|
|
2273
|
-
"drizzle.query.params": JSON.stringify(query.params)
|
|
2274
|
-
});
|
|
2275
|
-
return query;
|
|
2276
|
-
});
|
|
2277
|
-
}
|
|
2278
|
-
buildQueryFromSourceParams(chunks, _config) {
|
|
2279
|
-
const config2 = Object.assign({}, _config, {
|
|
2280
|
-
inlineParams: _config.inlineParams || this.shouldInlineParams,
|
|
2281
|
-
paramStartIndex: _config.paramStartIndex || {
|
|
2282
|
-
value: 0
|
|
2283
|
-
}
|
|
2284
|
-
});
|
|
2285
|
-
const { escapeName, escapeParam, prepareTyping, inlineParams, paramStartIndex } = config2;
|
|
2286
|
-
return mergeQueries(chunks.map((chunk) => {
|
|
2287
|
-
if (is(chunk, StringChunk)) {
|
|
2288
|
-
return {
|
|
2289
|
-
sql: chunk.value.join(""),
|
|
2290
|
-
params: []
|
|
2291
|
-
};
|
|
2292
|
-
}
|
|
2293
|
-
if (is(chunk, Name)) {
|
|
2294
|
-
return {
|
|
2295
|
-
sql: escapeName(chunk.value),
|
|
2296
|
-
params: []
|
|
2297
|
-
};
|
|
2298
|
-
}
|
|
2299
|
-
if (chunk === void 0) {
|
|
2300
|
-
return {
|
|
2301
|
-
sql: "",
|
|
2302
|
-
params: []
|
|
2303
|
-
};
|
|
2304
|
-
}
|
|
2305
|
-
if (Array.isArray(chunk)) {
|
|
2306
|
-
const result = [
|
|
2307
|
-
new StringChunk("(")
|
|
2308
|
-
];
|
|
2309
|
-
for (const [i, p] of chunk.entries()) {
|
|
2310
|
-
result.push(p);
|
|
2311
|
-
if (i < chunk.length - 1) {
|
|
2312
|
-
result.push(new StringChunk(", "));
|
|
2313
|
-
}
|
|
2314
|
-
}
|
|
2315
|
-
result.push(new StringChunk(")"));
|
|
2316
|
-
return this.buildQueryFromSourceParams(result, config2);
|
|
2317
|
-
}
|
|
2318
|
-
if (is(chunk, SQL2)) {
|
|
2319
|
-
return this.buildQueryFromSourceParams(chunk.queryChunks, {
|
|
2320
|
-
...config2,
|
|
2321
|
-
inlineParams: inlineParams || chunk.shouldInlineParams
|
|
2322
|
-
});
|
|
2323
|
-
}
|
|
2324
|
-
if (is(chunk, Table)) {
|
|
2325
|
-
const schemaName = chunk[Table.Symbol.Schema];
|
|
2326
|
-
const tableName = chunk[Table.Symbol.Name];
|
|
2327
|
-
return {
|
|
2328
|
-
sql: schemaName === void 0 ? escapeName(tableName) : escapeName(schemaName) + "." + escapeName(tableName),
|
|
2329
|
-
params: []
|
|
2330
|
-
};
|
|
2331
|
-
}
|
|
2332
|
-
if (is(chunk, Column)) {
|
|
2333
|
-
if (_config.invokeSource === "indexes") {
|
|
2334
|
-
return {
|
|
2335
|
-
sql: escapeName(chunk.name),
|
|
2336
|
-
params: []
|
|
2337
|
-
};
|
|
2338
|
-
}
|
|
2339
|
-
return {
|
|
2340
|
-
sql: escapeName(chunk.table[Table.Symbol.Name]) + "." + escapeName(chunk.name),
|
|
2341
|
-
params: []
|
|
2342
|
-
};
|
|
2343
|
-
}
|
|
2344
|
-
if (is(chunk, View)) {
|
|
2345
|
-
const schemaName = chunk[ViewBaseConfig].schema;
|
|
2346
|
-
const viewName = chunk[ViewBaseConfig].name;
|
|
2347
|
-
return {
|
|
2348
|
-
sql: schemaName === void 0 ? escapeName(viewName) : escapeName(schemaName) + "." + escapeName(viewName),
|
|
2349
|
-
params: []
|
|
2350
|
-
};
|
|
2351
|
-
}
|
|
2352
|
-
if (is(chunk, Param)) {
|
|
2353
|
-
if (is(chunk.value, Placeholder)) {
|
|
2354
|
-
return {
|
|
2355
|
-
sql: escapeParam(paramStartIndex.value++, chunk),
|
|
2356
|
-
params: [
|
|
2357
|
-
chunk
|
|
2358
|
-
],
|
|
2359
|
-
typings: [
|
|
2360
|
-
"none"
|
|
2361
|
-
]
|
|
2362
|
-
};
|
|
2363
|
-
}
|
|
2364
|
-
const mappedValue = chunk.value === null ? null : chunk.encoder.mapToDriverValue(chunk.value);
|
|
2365
|
-
if (is(mappedValue, SQL2)) {
|
|
2366
|
-
return this.buildQueryFromSourceParams([
|
|
2367
|
-
mappedValue
|
|
2368
|
-
], config2);
|
|
2369
|
-
}
|
|
2370
|
-
if (inlineParams) {
|
|
2371
|
-
return {
|
|
2372
|
-
sql: this.mapInlineParam(mappedValue, config2),
|
|
2373
|
-
params: []
|
|
2374
|
-
};
|
|
2375
|
-
}
|
|
2376
|
-
let typings = [
|
|
2377
|
-
"none"
|
|
2378
|
-
];
|
|
2379
|
-
if (prepareTyping) {
|
|
2380
|
-
typings = [
|
|
2381
|
-
prepareTyping(chunk.encoder)
|
|
2382
|
-
];
|
|
2383
|
-
}
|
|
2384
|
-
return {
|
|
2385
|
-
sql: escapeParam(paramStartIndex.value++, mappedValue),
|
|
2386
|
-
params: [
|
|
2387
|
-
mappedValue
|
|
2388
|
-
],
|
|
2389
|
-
typings
|
|
2390
|
-
};
|
|
2391
|
-
}
|
|
2392
|
-
if (is(chunk, Placeholder)) {
|
|
2393
|
-
return {
|
|
2394
|
-
sql: escapeParam(paramStartIndex.value++, chunk),
|
|
2395
|
-
params: [
|
|
2396
|
-
chunk
|
|
2397
|
-
],
|
|
2398
|
-
typings: [
|
|
2399
|
-
"none"
|
|
2400
|
-
]
|
|
2401
|
-
};
|
|
2402
|
-
}
|
|
2403
|
-
if (is(chunk, SQL2.Aliased) && chunk.fieldAlias !== void 0) {
|
|
2404
|
-
return {
|
|
2405
|
-
sql: escapeName(chunk.fieldAlias),
|
|
2406
|
-
params: []
|
|
2407
|
-
};
|
|
2408
|
-
}
|
|
2409
|
-
if (is(chunk, Subquery)) {
|
|
2410
|
-
if (chunk._.isWith) {
|
|
2411
|
-
return {
|
|
2412
|
-
sql: escapeName(chunk._.alias),
|
|
2413
|
-
params: []
|
|
2414
|
-
};
|
|
2415
|
-
}
|
|
2416
|
-
return this.buildQueryFromSourceParams([
|
|
2417
|
-
new StringChunk("("),
|
|
2418
|
-
chunk._.sql,
|
|
2419
|
-
new StringChunk(") "),
|
|
2420
|
-
new Name(chunk._.alias)
|
|
2421
|
-
], config2);
|
|
2422
|
-
}
|
|
2423
|
-
if (isPgEnum(chunk)) {
|
|
2424
|
-
if (chunk.schema) {
|
|
2425
|
-
return {
|
|
2426
|
-
sql: escapeName(chunk.schema) + "." + escapeName(chunk.enumName),
|
|
2427
|
-
params: []
|
|
2428
|
-
};
|
|
2429
|
-
}
|
|
2430
|
-
return {
|
|
2431
|
-
sql: escapeName(chunk.enumName),
|
|
2432
|
-
params: []
|
|
2433
|
-
};
|
|
2434
|
-
}
|
|
2435
|
-
if (isSQLWrapper(chunk)) {
|
|
2436
|
-
if (chunk.shouldOmitSQLParens?.()) {
|
|
2437
|
-
return this.buildQueryFromSourceParams([
|
|
2438
|
-
chunk.getSQL()
|
|
2439
|
-
], config2);
|
|
2440
|
-
}
|
|
2441
|
-
return this.buildQueryFromSourceParams([
|
|
2442
|
-
new StringChunk("("),
|
|
2443
|
-
chunk.getSQL(),
|
|
2444
|
-
new StringChunk(")")
|
|
2445
|
-
], config2);
|
|
2446
|
-
}
|
|
2447
|
-
if (inlineParams) {
|
|
2448
|
-
return {
|
|
2449
|
-
sql: this.mapInlineParam(chunk, config2),
|
|
2450
|
-
params: []
|
|
2451
|
-
};
|
|
2452
|
-
}
|
|
2453
|
-
return {
|
|
2454
|
-
sql: escapeParam(paramStartIndex.value++, chunk),
|
|
2455
|
-
params: [
|
|
2456
|
-
chunk
|
|
2457
|
-
],
|
|
2458
|
-
typings: [
|
|
2459
|
-
"none"
|
|
2460
|
-
]
|
|
2461
|
-
};
|
|
2462
|
-
}));
|
|
2463
|
-
}
|
|
2464
|
-
mapInlineParam(chunk, { escapeString }) {
|
|
2465
|
-
if (chunk === null) {
|
|
2466
|
-
return "null";
|
|
2467
|
-
}
|
|
2468
|
-
if (typeof chunk === "number" || typeof chunk === "boolean") {
|
|
2469
|
-
return chunk.toString();
|
|
2470
|
-
}
|
|
2471
|
-
if (typeof chunk === "string") {
|
|
2472
|
-
return escapeString(chunk);
|
|
2473
|
-
}
|
|
2474
|
-
if (typeof chunk === "object") {
|
|
2475
|
-
const mappedValueAsString = chunk.toString();
|
|
2476
|
-
if (mappedValueAsString === "[object Object]") {
|
|
2477
|
-
return escapeString(JSON.stringify(chunk));
|
|
2478
|
-
}
|
|
2479
|
-
return escapeString(mappedValueAsString);
|
|
2480
|
-
}
|
|
2481
|
-
throw new Error("Unexpected param value: " + chunk);
|
|
2482
|
-
}
|
|
2483
|
-
getSQL() {
|
|
2484
|
-
return this;
|
|
2485
|
-
}
|
|
2486
|
-
as(alias) {
|
|
2487
|
-
if (alias === void 0) {
|
|
2488
|
-
return this;
|
|
2489
|
-
}
|
|
2490
|
-
return new SQL2.Aliased(this, alias);
|
|
2491
|
-
}
|
|
2492
|
-
mapWith(decoder) {
|
|
2493
|
-
this.decoder = typeof decoder === "function" ? {
|
|
2494
|
-
mapFromDriverValue: decoder
|
|
2495
|
-
} : decoder;
|
|
2496
|
-
return this;
|
|
2497
|
-
}
|
|
2498
|
-
inlineParams() {
|
|
2499
|
-
this.shouldInlineParams = true;
|
|
2500
|
-
return this;
|
|
2501
|
-
}
|
|
2502
|
-
/**
|
|
2503
|
-
* This method is used to conditionally include a part of the query.
|
|
2504
|
-
*
|
|
2505
|
-
* @param condition - Condition to check
|
|
2506
|
-
* @returns itself if the condition is `true`, otherwise `undefined`
|
|
2507
|
-
*/
|
|
2508
|
-
if(condition) {
|
|
2509
|
-
return condition ? this : void 0;
|
|
2510
|
-
}
|
|
2511
|
-
};
|
|
2512
|
-
var Name = class Name2 {
|
|
2513
|
-
static {
|
|
2514
|
-
__name(this, "Name");
|
|
2515
|
-
}
|
|
2516
|
-
constructor(value) {
|
|
2517
|
-
this.value = value;
|
|
2518
|
-
}
|
|
2519
|
-
static [entityKind] = "Name";
|
|
2520
|
-
brand;
|
|
2521
|
-
getSQL() {
|
|
2522
|
-
return new SQL([
|
|
2523
|
-
this
|
|
2524
|
-
]);
|
|
2525
|
-
}
|
|
2526
|
-
};
|
|
2527
|
-
function isDriverValueEncoder(value) {
|
|
2528
|
-
return typeof value === "object" && value !== null && "mapToDriverValue" in value && typeof value.mapToDriverValue === "function";
|
|
2529
|
-
}
|
|
2530
|
-
__name(isDriverValueEncoder, "isDriverValueEncoder");
|
|
2531
|
-
var noopDecoder = {
|
|
2532
|
-
mapFromDriverValue: /* @__PURE__ */ __name((value) => value, "mapFromDriverValue")
|
|
2533
|
-
};
|
|
2534
|
-
var noopEncoder = {
|
|
2535
|
-
mapToDriverValue: /* @__PURE__ */ __name((value) => value, "mapToDriverValue")
|
|
2536
|
-
};
|
|
2537
|
-
({
|
|
2538
|
-
...noopDecoder,
|
|
2539
|
-
...noopEncoder
|
|
2540
|
-
});
|
|
2541
|
-
var Param = class Param2 {
|
|
2542
|
-
static {
|
|
2543
|
-
__name(this, "Param");
|
|
2544
|
-
}
|
|
2545
|
-
/**
|
|
2546
|
-
* @param value - Parameter value
|
|
2547
|
-
* @param encoder - Encoder to convert the value to a driver parameter
|
|
2548
|
-
*/
|
|
2549
|
-
constructor(value, encoder = noopEncoder) {
|
|
2550
|
-
this.value = value;
|
|
2551
|
-
this.encoder = encoder;
|
|
2552
|
-
}
|
|
2553
|
-
static [entityKind] = "Param";
|
|
2554
|
-
brand;
|
|
2555
|
-
getSQL() {
|
|
2556
|
-
return new SQL([
|
|
2557
|
-
this
|
|
2558
|
-
]);
|
|
2559
|
-
}
|
|
2560
|
-
};
|
|
2561
|
-
function sql(strings, ...params) {
|
|
2562
|
-
const queryChunks = [];
|
|
2563
|
-
if (params.length > 0 || strings.length > 0 && strings[0] !== "") {
|
|
2564
|
-
queryChunks.push(new StringChunk(strings[0]));
|
|
2565
|
-
}
|
|
2566
|
-
for (const [paramIndex, param2] of params.entries()) {
|
|
2567
|
-
queryChunks.push(param2, new StringChunk(strings[paramIndex + 1]));
|
|
2568
|
-
}
|
|
2569
|
-
return new SQL(queryChunks);
|
|
2570
|
-
}
|
|
2571
|
-
__name(sql, "sql");
|
|
2572
|
-
((sql2) => {
|
|
2573
|
-
function empty() {
|
|
2574
|
-
return new SQL([]);
|
|
2575
|
-
}
|
|
2576
|
-
__name(empty, "empty");
|
|
2577
|
-
sql2.empty = empty;
|
|
2578
|
-
function fromList(list) {
|
|
2579
|
-
return new SQL(list);
|
|
2580
|
-
}
|
|
2581
|
-
__name(fromList, "fromList");
|
|
2582
|
-
sql2.fromList = fromList;
|
|
2583
|
-
function raw(str) {
|
|
2584
|
-
return new SQL([
|
|
2585
|
-
new StringChunk(str)
|
|
2586
|
-
]);
|
|
2587
|
-
}
|
|
2588
|
-
__name(raw, "raw");
|
|
2589
|
-
sql2.raw = raw;
|
|
2590
|
-
function join(chunks, separator) {
|
|
2591
|
-
const result = [];
|
|
2592
|
-
for (const [i, chunk] of chunks.entries()) {
|
|
2593
|
-
if (i > 0 && separator !== void 0) {
|
|
2594
|
-
result.push(separator);
|
|
2595
|
-
}
|
|
2596
|
-
result.push(chunk);
|
|
2597
|
-
}
|
|
2598
|
-
return new SQL(result);
|
|
2599
|
-
}
|
|
2600
|
-
__name(join, "join");
|
|
2601
|
-
sql2.join = join;
|
|
2602
|
-
function identifier(value) {
|
|
2603
|
-
return new Name(value);
|
|
2604
|
-
}
|
|
2605
|
-
__name(identifier, "identifier");
|
|
2606
|
-
sql2.identifier = identifier;
|
|
2607
|
-
function placeholder2(name2) {
|
|
2608
|
-
return new Placeholder(name2);
|
|
2609
|
-
}
|
|
2610
|
-
__name(placeholder2, "placeholder2");
|
|
2611
|
-
sql2.placeholder = placeholder2;
|
|
2612
|
-
function param2(value, encoder) {
|
|
2613
|
-
return new Param(value, encoder);
|
|
2614
|
-
}
|
|
2615
|
-
__name(param2, "param2");
|
|
2616
|
-
sql2.param = param2;
|
|
2617
|
-
})(sql || (sql = {}));
|
|
2618
|
-
((SQL22) => {
|
|
2619
|
-
let Aliased = class Aliased2 {
|
|
2620
|
-
static {
|
|
2621
|
-
__name(this, "Aliased");
|
|
2622
|
-
}
|
|
2623
|
-
constructor(sql2, fieldAlias) {
|
|
2624
|
-
this.sql = sql2;
|
|
2625
|
-
this.fieldAlias = fieldAlias;
|
|
2626
|
-
}
|
|
2627
|
-
static [entityKind] = "SQL.Aliased";
|
|
2628
|
-
/** @internal */
|
|
2629
|
-
isSelectionField = false;
|
|
2630
|
-
getSQL() {
|
|
2631
|
-
return this.sql;
|
|
2632
|
-
}
|
|
2633
|
-
/** @internal */
|
|
2634
|
-
clone() {
|
|
2635
|
-
return new Aliased2(this.sql, this.fieldAlias);
|
|
2636
|
-
}
|
|
2637
|
-
};
|
|
2638
|
-
SQL22.Aliased = Aliased;
|
|
2639
|
-
})(SQL || (SQL = {}));
|
|
2640
|
-
var Placeholder = class Placeholder2 {
|
|
2641
|
-
static {
|
|
2642
|
-
__name(this, "Placeholder");
|
|
2643
|
-
}
|
|
2644
|
-
constructor(name2) {
|
|
2645
|
-
this.name = name2;
|
|
2646
|
-
}
|
|
2647
|
-
static [entityKind] = "Placeholder";
|
|
2648
|
-
getSQL() {
|
|
2649
|
-
return new SQL([
|
|
2650
|
-
this
|
|
2651
|
-
]);
|
|
2652
|
-
}
|
|
2653
|
-
};
|
|
2654
|
-
var View = class View2 {
|
|
2655
|
-
static {
|
|
2656
|
-
__name(this, "View");
|
|
2657
|
-
}
|
|
2658
|
-
static [entityKind] = "View";
|
|
2659
|
-
/** @internal */
|
|
2660
|
-
[ViewBaseConfig];
|
|
2661
|
-
constructor({ name: name2, schema: schema9, selectedFields, query }) {
|
|
2662
|
-
this[ViewBaseConfig] = {
|
|
2663
|
-
name: name2,
|
|
2664
|
-
originalName: name2,
|
|
2665
|
-
schema: schema9,
|
|
2666
|
-
selectedFields,
|
|
2667
|
-
query,
|
|
2668
|
-
isExisting: !query,
|
|
2669
|
-
isAlias: false
|
|
2670
|
-
};
|
|
2671
|
-
}
|
|
2672
|
-
getSQL() {
|
|
2673
|
-
return new SQL([
|
|
2674
|
-
this
|
|
2675
|
-
]);
|
|
2676
|
-
}
|
|
2677
|
-
};
|
|
2678
|
-
Column.prototype.getSQL = function() {
|
|
2679
|
-
return new SQL([
|
|
2680
|
-
this
|
|
2681
|
-
]);
|
|
2682
|
-
};
|
|
2683
|
-
Table.prototype.getSQL = function() {
|
|
2684
|
-
return new SQL([
|
|
2685
|
-
this
|
|
2686
|
-
]);
|
|
2687
|
-
};
|
|
2688
|
-
Subquery.prototype.getSQL = function() {
|
|
2689
|
-
return new SQL([
|
|
2690
|
-
this
|
|
2691
|
-
]);
|
|
2692
|
-
};
|
|
2693
|
-
|
|
2694
|
-
// ../../node_modules/drizzle-orm/sql/expressions/conditions.js
|
|
2695
|
-
function bindIfParam(value, column) {
|
|
2696
|
-
if (isDriverValueEncoder(column) && !isSQLWrapper(value) && !is(value, Param) && !is(value, Placeholder) && !is(value, Column) && !is(value, Table) && !is(value, View)) {
|
|
2697
|
-
return new Param(value, column);
|
|
2698
|
-
}
|
|
2699
|
-
return value;
|
|
2700
|
-
}
|
|
2701
|
-
__name(bindIfParam, "bindIfParam");
|
|
2702
|
-
var eq = /* @__PURE__ */ __name((left, right) => {
|
|
2703
|
-
return sql`${left} = ${bindIfParam(right, left)}`;
|
|
2704
|
-
}, "eq");
|
|
2705
|
-
function and(...unfilteredConditions) {
|
|
2706
|
-
const conditions = unfilteredConditions.filter((c) => c !== void 0);
|
|
2707
|
-
if (conditions.length === 0) {
|
|
2708
|
-
return void 0;
|
|
2709
|
-
}
|
|
2710
|
-
if (conditions.length === 1) {
|
|
2711
|
-
return new SQL(conditions);
|
|
2712
|
-
}
|
|
2713
|
-
return new SQL([
|
|
2714
|
-
new StringChunk("("),
|
|
2715
|
-
sql.join(conditions, new StringChunk(" and ")),
|
|
2716
|
-
new StringChunk(")")
|
|
2717
|
-
]);
|
|
2718
|
-
}
|
|
2719
|
-
__name(and, "and");
|
|
2720
|
-
function or(...unfilteredConditions) {
|
|
2721
|
-
const conditions = unfilteredConditions.filter((c) => c !== void 0);
|
|
2722
|
-
if (conditions.length === 0) {
|
|
2723
|
-
return void 0;
|
|
2724
|
-
}
|
|
2725
|
-
if (conditions.length === 1) {
|
|
2726
|
-
return new SQL(conditions);
|
|
2727
|
-
}
|
|
2728
|
-
return new SQL([
|
|
2729
|
-
new StringChunk("("),
|
|
2730
|
-
sql.join(conditions, new StringChunk(" or ")),
|
|
2731
|
-
new StringChunk(")")
|
|
2732
|
-
]);
|
|
2733
|
-
}
|
|
2734
|
-
__name(or, "or");
|
|
2735
|
-
function inArray(column, values) {
|
|
2736
|
-
if (Array.isArray(values)) {
|
|
2737
|
-
if (values.length === 0) {
|
|
2738
|
-
return sql`false`;
|
|
2739
|
-
}
|
|
2740
|
-
return sql`${column} in ${values.map((v) => bindIfParam(v, column))}`;
|
|
2741
|
-
}
|
|
2742
|
-
return sql`${column} in ${bindIfParam(values, column)}`;
|
|
2743
|
-
}
|
|
2744
|
-
__name(inArray, "inArray");
|
|
2745
|
-
function isNull(value) {
|
|
2746
|
-
return sql`${value} is null`;
|
|
2747
|
-
}
|
|
2748
|
-
__name(isNull, "isNull");
|
|
2749
|
-
function isNotNull(value) {
|
|
2750
|
-
return sql`${value} is not null`;
|
|
2751
|
-
}
|
|
2752
|
-
__name(isNotNull, "isNotNull");
|
|
2753
|
-
|
|
2754
|
-
// ../../node_modules/drizzle-orm/sql/expressions/select.js
|
|
2755
|
-
function asc(column) {
|
|
2756
|
-
return sql`${column} asc`;
|
|
2757
|
-
}
|
|
2758
|
-
__name(asc, "asc");
|
|
2759
|
-
function desc(column) {
|
|
2760
|
-
return sql`${column} desc`;
|
|
2761
|
-
}
|
|
2762
|
-
__name(desc, "desc");
|
|
2763
|
-
|
|
2764
|
-
// ../../node_modules/drizzle-orm/utils.js
|
|
2765
|
-
function getTableColumns(table) {
|
|
2766
|
-
return table[Table.Symbol.Columns];
|
|
2767
|
-
}
|
|
2768
|
-
__name(getTableColumns, "getTableColumns");
|
|
2769
|
-
|
|
2770
|
-
// ../../packages/dvss-integration-libs/src/integration-common-utils/dao/integration-booking.dao.ts
|
|
2771
|
-
function _ts_decorate9(decorators, target, key, desc2) {
|
|
2772
|
-
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
2773
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2774
|
-
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;
|
|
2775
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2776
|
-
}
|
|
2777
|
-
__name(_ts_decorate9, "_ts_decorate");
|
|
2778
|
-
function _ts_metadata6(k, v) {
|
|
2779
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2780
|
-
}
|
|
2781
|
-
__name(_ts_metadata6, "_ts_metadata");
|
|
2782
|
-
function _ts_param3(paramIndex, decorator) {
|
|
2783
|
-
return function(target, key) {
|
|
2784
|
-
decorator(target, key, paramIndex);
|
|
2785
|
-
};
|
|
2786
|
-
}
|
|
2787
|
-
__name(_ts_param3, "_ts_param");
|
|
2788
|
-
exports.IntegrationBookingDao = class IntegrationBookingDao {
|
|
2789
|
-
static {
|
|
2790
|
-
__name(this, "IntegrationBookingDao");
|
|
2791
|
-
}
|
|
2792
|
-
conn;
|
|
2793
|
-
logger;
|
|
2794
|
-
fileName = "integration-booking.dao";
|
|
2795
|
-
constructor(conn, logger) {
|
|
2796
|
-
this.conn = conn;
|
|
2797
|
-
this.logger = logger;
|
|
2798
|
-
}
|
|
2799
|
-
async getOfferingBookingOccurrence(input) {
|
|
2800
|
-
this.logger.debug(input.loggedInUserId, this.getOfferingBookingOccurrence.name, this.fileName, "Getting offering booking occurrence with input: ", input);
|
|
2801
|
-
const conditions = [
|
|
2802
|
-
isNull(dvssBackendModuleDatastore.schema.offeringBookingOccurrence.deletedAt),
|
|
2803
|
-
eq(dvssBackendModuleDatastore.schema.offeringBookingOccurrence.id, input.offeringBookingOccurrenceId),
|
|
2804
|
-
isNull(dvssBackendModuleDatastore.schema.offeringBooking.deletedAt),
|
|
2805
|
-
isNull(dvssBackendModuleDatastore.schema.offering.deletedAt)
|
|
2806
|
-
];
|
|
2807
|
-
if (input.offeringBookingId != null) {
|
|
2808
|
-
conditions.push(eq(dvssBackendModuleDatastore.schema.offeringBooking.id, input.offeringBookingId));
|
|
2809
|
-
}
|
|
2810
|
-
const result = await this.conn.select({
|
|
2811
|
-
offeringBookingOccurrence: dvssBackendModuleDatastore.schema.offeringBookingOccurrence,
|
|
2812
|
-
offering: dvssBackendModuleDatastore.schema.offering,
|
|
2813
|
-
offeringIntentId: dvssBackendModuleDatastore.schema.offeringBooking.offeringIntentId
|
|
2814
|
-
}).from(dvssBackendModuleDatastore.schema.offeringBookingOccurrence).innerJoin(dvssBackendModuleDatastore.schema.offeringBooking, eq(dvssBackendModuleDatastore.schema.offeringBookingOccurrence.offeringBookingId, dvssBackendModuleDatastore.schema.offeringBooking.id)).innerJoin(dvssBackendModuleDatastore.schema.offering, eq(dvssBackendModuleDatastore.schema.offeringBooking.offeringId, dvssBackendModuleDatastore.schema.offering.id)).where(and(...conditions)).limit(1);
|
|
2815
|
-
if (!result[0] || result[0].offeringIntentId == null) return void 0;
|
|
2816
|
-
return {
|
|
2817
|
-
offeringBookingOccurrence: result[0].offeringBookingOccurrence,
|
|
2818
|
-
offering: result[0].offering,
|
|
2819
|
-
offeringIntentId: result[0].offeringIntentId
|
|
2820
|
-
};
|
|
2821
|
-
}
|
|
2822
|
-
/**
|
|
2823
|
-
* Fetches offering intent by id.
|
|
2824
|
-
*/
|
|
2825
|
-
async getOfferingIntent(input) {
|
|
2826
|
-
const row = await this.conn.query.offeringIntent.findFirst({
|
|
2827
|
-
where: and(isNull(dvssBackendModuleDatastore.schema.offeringIntent.deletedAt), eq(dvssBackendModuleDatastore.schema.offeringIntent.id, input.offeringIntentId))
|
|
2828
|
-
});
|
|
2829
|
-
return row ?? void 0;
|
|
2830
|
-
}
|
|
2831
|
-
};
|
|
2832
|
-
exports.IntegrationBookingDao = _ts_decorate9([
|
|
2833
|
-
common.Injectable(),
|
|
2834
|
-
_ts_param3(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
|
|
2835
|
-
_ts_metadata6("design:type", Function),
|
|
2836
|
-
_ts_metadata6("design:paramtypes", [
|
|
2837
|
-
typeof MySql2Database === "undefined" ? Object : MySql2Database,
|
|
2838
|
-
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
|
|
2839
|
-
])
|
|
2840
|
-
], exports.IntegrationBookingDao);
|
|
2841
|
-
function _ts_decorate10(decorators, target, key, desc2) {
|
|
2842
|
-
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
2843
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2844
|
-
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;
|
|
2845
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2846
|
-
}
|
|
2847
|
-
__name(_ts_decorate10, "_ts_decorate");
|
|
2848
|
-
function _ts_metadata7(k, v) {
|
|
2849
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2850
|
-
}
|
|
2851
|
-
__name(_ts_metadata7, "_ts_metadata");
|
|
2852
|
-
function _ts_param4(paramIndex, decorator) {
|
|
2853
|
-
return function(target, key) {
|
|
2854
|
-
decorator(target, key, paramIndex);
|
|
2855
|
-
};
|
|
2856
|
-
}
|
|
2857
|
-
__name(_ts_param4, "_ts_param");
|
|
2858
|
-
exports.IntegrationCommonDao = class IntegrationCommonDao {
|
|
2859
|
-
static {
|
|
2860
|
-
__name(this, "IntegrationCommonDao");
|
|
2861
|
-
}
|
|
2862
|
-
conn;
|
|
2863
|
-
logger;
|
|
2864
|
-
fileName = "integration-common.dao";
|
|
2865
|
-
constructor(conn, logger) {
|
|
2866
|
-
this.conn = conn;
|
|
2867
|
-
this.logger = logger;
|
|
2868
|
-
}
|
|
2869
|
-
/**
|
|
2870
|
-
* Gets timezone using userContext (first propertyId) with fallback to projectId
|
|
2871
|
-
* First tries to get timezone from user's first propertyId, then falls back to projectId
|
|
2872
|
-
* @param input - Object containing projectId and loggedInUserId
|
|
2873
|
-
* @returns Promise resolving to timezone string
|
|
2874
|
-
*/
|
|
2875
|
-
async getTimezoneForRequest(input) {
|
|
2876
|
-
const { projectId, loggedInUserId } = input;
|
|
2877
|
-
try {
|
|
2878
|
-
const userBehavior = await this.conn.query.userIdentityBehaviorMapping.findFirst({
|
|
2879
|
-
where: and(eq(dvssBackendModuleDatastore.schema.userIdentityBehaviorMapping.userIdentityId, loggedInUserId), isNotNull(dvssBackendModuleDatastore.schema.userIdentityBehaviorMapping.propertyId), isNull(dvssBackendModuleDatastore.schema.userIdentityBehaviorMapping.deletedAt)),
|
|
2880
|
-
with: {
|
|
2881
|
-
property: true
|
|
2882
|
-
}
|
|
2883
|
-
});
|
|
2884
|
-
if (userBehavior?.propertyId && userBehavior.property?.timezone) {
|
|
2885
|
-
this.logger.info(loggedInUserId, this.getTimezoneForRequest.name, this.fileName, "Successfully fetched property timezone using userContext", {
|
|
2886
|
-
projectId,
|
|
2887
|
-
loggedInUserId,
|
|
2888
|
-
propertyId: userBehavior.propertyId,
|
|
2889
|
-
timezone: userBehavior.property.timezone
|
|
2890
|
-
});
|
|
2891
|
-
return userBehavior.property.timezone;
|
|
2892
|
-
}
|
|
2893
|
-
if (projectId) {
|
|
2894
|
-
const properties = await this.conn.query.property.findMany({
|
|
2895
|
-
where: and(eq(dvssBackendModuleDatastore.schema.property.projectId, projectId), isNull(dvssBackendModuleDatastore.schema.property.deletedAt)),
|
|
2896
|
-
limit: 1
|
|
2897
|
-
});
|
|
2898
|
-
if (properties.length > 0 && properties[0].timezone) {
|
|
2899
|
-
this.logger.info(loggedInUserId, this.getTimezoneForRequest.name, this.fileName, "Successfully fetched property timezone using projectId", {
|
|
2900
|
-
projectId,
|
|
2901
|
-
propertyId: properties[0].id,
|
|
2902
|
-
timezone: properties[0].timezone
|
|
2903
|
-
});
|
|
2904
|
-
return properties[0].timezone;
|
|
2905
|
-
}
|
|
2906
|
-
}
|
|
2907
|
-
} catch (error) {
|
|
2908
|
-
this.logger.warn(loggedInUserId, this.getTimezoneForRequest.name, this.fileName, "Error fetching property timezone, using default", {
|
|
2909
|
-
projectId,
|
|
2910
|
-
error
|
|
2911
|
-
});
|
|
2912
|
-
}
|
|
2913
|
-
return dvssBackendModuleUtility.DEFAULT_TIMEZONE;
|
|
2914
|
-
}
|
|
2915
|
-
};
|
|
2916
|
-
exports.IntegrationCommonDao = _ts_decorate10([
|
|
2917
|
-
common.Injectable(),
|
|
2918
|
-
_ts_param4(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
|
|
2919
|
-
_ts_metadata7("design:type", Function),
|
|
2920
|
-
_ts_metadata7("design:paramtypes", [
|
|
2921
|
-
typeof MySql2Database === "undefined" ? Object : MySql2Database,
|
|
2922
|
-
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
|
|
2923
|
-
])
|
|
2924
|
-
], exports.IntegrationCommonDao);
|
|
2925
|
-
function _ts_decorate11(decorators, target, key, desc2) {
|
|
2926
|
-
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
2927
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2928
|
-
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;
|
|
2929
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2930
|
-
}
|
|
2931
|
-
__name(_ts_decorate11, "_ts_decorate");
|
|
2932
|
-
function _ts_metadata8(k, v) {
|
|
2933
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2934
|
-
}
|
|
2935
|
-
__name(_ts_metadata8, "_ts_metadata");
|
|
2936
|
-
function _ts_param5(paramIndex, decorator) {
|
|
2937
|
-
return function(target, key) {
|
|
2938
|
-
decorator(target, key, paramIndex);
|
|
2939
|
-
};
|
|
2940
|
-
}
|
|
2941
|
-
__name(_ts_param5, "_ts_param");
|
|
2942
|
-
exports.IntegrationSubcapabilityDao = class IntegrationSubcapabilityDao {
|
|
2943
|
-
static {
|
|
2944
|
-
__name(this, "IntegrationSubcapabilityDao");
|
|
2945
|
-
}
|
|
2946
|
-
conn;
|
|
2947
|
-
logger;
|
|
2948
|
-
fileName = "integration-subcapability.dao";
|
|
2949
|
-
constructor(conn, logger) {
|
|
2950
|
-
this.conn = conn;
|
|
2951
|
-
this.logger = logger;
|
|
2952
|
-
}
|
|
2953
|
-
/**
|
|
2954
|
-
* Returns subcapability id for given capabilityId and subcapability name.
|
|
2955
|
-
* Enforces uniqueness: if more than one active row is found, throws an error.
|
|
2956
|
-
* If no active row is found, returns undefined (caller decides how to handle).
|
|
2957
|
-
*/
|
|
2958
|
-
async getSubcapabilityId(input, loggedInUserId) {
|
|
2959
|
-
this.logger.info(loggedInUserId, this.getSubcapabilityId.name, this.fileName, "IntegrationSubcapabilityDao -> getSubcapabilityId called", {
|
|
2960
|
-
input
|
|
2961
|
-
});
|
|
2962
|
-
try {
|
|
2963
|
-
const rows = await this.conn.query.subcapability.findMany({
|
|
2964
|
-
where: and(eq(dvssBackendModuleDatastore.schema.subcapability.capabilityId, input.capabilityId), eq(dvssBackendModuleDatastore.schema.subcapability.name, input.name), isNull(dvssBackendModuleDatastore.schema.subcapability.deletedAt))
|
|
2965
|
-
});
|
|
2966
|
-
if (rows.length === 0) {
|
|
2967
|
-
this.logger.error(loggedInUserId, this.getSubcapabilityId.name, this.fileName, "Subcapability not found for given capabilityId and name", {
|
|
2968
|
-
input
|
|
2969
|
-
});
|
|
2970
|
-
return void 0;
|
|
2971
|
-
}
|
|
2972
|
-
return rows[0].id;
|
|
2973
|
-
} catch (error) {
|
|
2974
|
-
this.logger.error(loggedInUserId, this.getSubcapabilityId.name, this.fileName, "Error in getSubcapabilityId", error, {
|
|
2975
|
-
input
|
|
2976
|
-
});
|
|
2977
|
-
throw error;
|
|
2978
|
-
}
|
|
1708
|
+
/**
|
|
1709
|
+
* Returns subcapability id for given capabilityId and subcapability name.
|
|
1710
|
+
* Enforces uniqueness: if more than one active row is found, throws an error.
|
|
1711
|
+
* If no active row is found, returns undefined (caller decides how to handle).
|
|
1712
|
+
*/
|
|
1713
|
+
async getSubcapabilityId(input, loggedInUserId) {
|
|
1714
|
+
this.logger.info(loggedInUserId, this.getSubcapabilityId.name, this.fileName, "IntegrationSubcapabilityDao -> getSubcapabilityId called", {
|
|
1715
|
+
input
|
|
1716
|
+
});
|
|
1717
|
+
try {
|
|
1718
|
+
const rows = await this.conn.query.subcapability.findMany({
|
|
1719
|
+
where: drizzleOrm.and(drizzleOrm.eq(dvssBackendModuleDatastore.schema.subcapability.capabilityId, input.capabilityId), drizzleOrm.eq(dvssBackendModuleDatastore.schema.subcapability.name, input.name), drizzleOrm.isNull(dvssBackendModuleDatastore.schema.subcapability.deletedAt))
|
|
1720
|
+
});
|
|
1721
|
+
if (rows.length === 0) {
|
|
1722
|
+
this.logger.error(loggedInUserId, this.getSubcapabilityId.name, this.fileName, "Subcapability not found for given capabilityId and name", {
|
|
1723
|
+
input
|
|
1724
|
+
});
|
|
1725
|
+
return void 0;
|
|
1726
|
+
}
|
|
1727
|
+
return rows[0].id;
|
|
1728
|
+
} catch (error) {
|
|
1729
|
+
this.logger.error(loggedInUserId, this.getSubcapabilityId.name, this.fileName, "Error in getSubcapabilityId", error, {
|
|
1730
|
+
input
|
|
1731
|
+
});
|
|
1732
|
+
throw error;
|
|
1733
|
+
}
|
|
2979
1734
|
}
|
|
2980
1735
|
async getSubcapabilities(input, loggedInUserId) {
|
|
2981
1736
|
this.logger.info(loggedInUserId, this.getSubcapabilities.name, this.fileName, "IntegrationSubcapabilityDao -> getSubcapabilities called", {
|
|
@@ -2983,7 +1738,7 @@ exports.IntegrationSubcapabilityDao = class IntegrationSubcapabilityDao {
|
|
|
2983
1738
|
});
|
|
2984
1739
|
try {
|
|
2985
1740
|
return await this.conn.query.subcapability.findMany({
|
|
2986
|
-
where: and(eq(dvssBackendModuleDatastore.schema.subcapability.capabilityId, input.capabilityId), isNull(dvssBackendModuleDatastore.schema.subcapability.deletedAt))
|
|
1741
|
+
where: drizzleOrm.and(drizzleOrm.eq(dvssBackendModuleDatastore.schema.subcapability.capabilityId, input.capabilityId), drizzleOrm.isNull(dvssBackendModuleDatastore.schema.subcapability.deletedAt))
|
|
2987
1742
|
});
|
|
2988
1743
|
} catch (error) {
|
|
2989
1744
|
this.logger.error(loggedInUserId, this.getSubcapabilities.name, this.fileName, "Error in getSubcapabilities", error, {
|
|
@@ -3022,13 +1777,13 @@ var IntegrationVisitorCredentialMappingDao = class {
|
|
|
3022
1777
|
return;
|
|
3023
1778
|
}
|
|
3024
1779
|
const officeVisitorConfigProfile = await input.db.query.officeVisitorConfigProfile.findFirst({
|
|
3025
|
-
where: and(eq(dvssBackendModuleDatastore.schema.officeVisitorConfigProfile.projectId, input.projectId), isNull(dvssBackendModuleDatastore.schema.officeVisitorConfigProfile.deletedAt))
|
|
1780
|
+
where: drizzleOrm.and(drizzleOrm.eq(dvssBackendModuleDatastore.schema.officeVisitorConfigProfile.projectId, input.projectId), drizzleOrm.isNull(dvssBackendModuleDatastore.schema.officeVisitorConfigProfile.deletedAt))
|
|
3026
1781
|
});
|
|
3027
1782
|
if (!officeVisitorConfigProfile) {
|
|
3028
1783
|
return;
|
|
3029
1784
|
}
|
|
3030
1785
|
const capIntegResourceMapping = await input.db.query.capIntegResourceMapping.findFirst({
|
|
3031
|
-
where: and(eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.capabilityIntegrationId, input.capabilityIntegrationId), eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType, this.capIntegResourceMappingOfficeVisitorType), eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId, officeVisitorConfigProfile.id), isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt))
|
|
1786
|
+
where: drizzleOrm.and(drizzleOrm.eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.capabilityIntegrationId, input.capabilityIntegrationId), drizzleOrm.eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType, this.capIntegResourceMappingOfficeVisitorType), drizzleOrm.eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId, officeVisitorConfigProfile.id), drizzleOrm.isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt))
|
|
3032
1787
|
});
|
|
3033
1788
|
const currentConfig = capIntegResourceMapping?.config;
|
|
3034
1789
|
const isCurrentGenerateCredentialEnabled = currentConfig?.generateCredential === true;
|
|
@@ -3040,7 +1795,7 @@ var IntegrationVisitorCredentialMappingDao = class {
|
|
|
3040
1795
|
},
|
|
3041
1796
|
updatedAt: /* @__PURE__ */ new Date(),
|
|
3042
1797
|
updatedBy: input.loggedInUserId
|
|
3043
|
-
}).where(eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.id, capIntegResourceMapping.id));
|
|
1798
|
+
}).where(drizzleOrm.eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.id, capIntegResourceMapping.id));
|
|
3044
1799
|
}
|
|
3045
1800
|
return;
|
|
3046
1801
|
}
|
|
@@ -3171,7 +1926,7 @@ exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
|
|
|
3171
1926
|
request
|
|
3172
1927
|
});
|
|
3173
1928
|
return await this.conn.query.capability.findFirst({
|
|
3174
|
-
where: and(eq(dvssBackendModuleDatastore.schema.capability.id, request.capabilityId), isNull(dvssBackendModuleDatastore.schema.capability.deletedAt))
|
|
1929
|
+
where: drizzleOrm.and(drizzleOrm.eq(dvssBackendModuleDatastore.schema.capability.id, request.capabilityId), drizzleOrm.isNull(dvssBackendModuleDatastore.schema.capability.deletedAt))
|
|
3175
1930
|
});
|
|
3176
1931
|
} catch (error) {
|
|
3177
1932
|
this.logger.error(loggedInUserId, this.getCapability.name, this.fileName, "Error on getCapability", error, {
|
|
@@ -3190,7 +1945,7 @@ exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
|
|
|
3190
1945
|
request
|
|
3191
1946
|
});
|
|
3192
1947
|
return await this.conn.query.capabilityProvider.findFirst({
|
|
3193
|
-
where: and(eq(dvssBackendModuleDatastore.schema.capabilityProvider.id, request.capabilityProviderId), isNull(dvssBackendModuleDatastore.schema.capabilityProvider.deletedAt))
|
|
1948
|
+
where: drizzleOrm.and(drizzleOrm.eq(dvssBackendModuleDatastore.schema.capabilityProvider.id, request.capabilityProviderId), drizzleOrm.isNull(dvssBackendModuleDatastore.schema.capabilityProvider.deletedAt))
|
|
3194
1949
|
});
|
|
3195
1950
|
} catch (error) {
|
|
3196
1951
|
this.logger.error(loggedInUserId, this.getCapabilityProvider.name, this.fileName, "Error on getCapabilityProvider", error, {
|
|
@@ -3214,7 +1969,7 @@ exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
|
|
|
3214
1969
|
});
|
|
3215
1970
|
const response = await this.conn.update(dvssBackendModuleDatastore.schema.capabilityIntegration).set({
|
|
3216
1971
|
...input.updateData
|
|
3217
|
-
}).where(eq(dvssBackendModuleDatastore.schema.capabilityIntegration.id, input.id));
|
|
1972
|
+
}).where(drizzleOrm.eq(dvssBackendModuleDatastore.schema.capabilityIntegration.id, input.id));
|
|
3218
1973
|
const isGenerateCredentialsForVisitorEnabled = this.integrationVisitorCredentialMappingDao.extractGenerateCredentialsForVisitorValue(input.updateData.config);
|
|
3219
1974
|
if (typeof isGenerateCredentialsForVisitorEnabled === "boolean") {
|
|
3220
1975
|
await this.integrationVisitorCredentialMappingDao.syncVisitorCredentialMapping({
|
|
@@ -3239,9 +1994,9 @@ exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
|
|
|
3239
1994
|
this.logger.info(loggedInUserId, this.updateCapabilityIntegrationAccessDetails.name, this.fileName, "Updating capability integration access details", {
|
|
3240
1995
|
capabilityIntegrationId
|
|
3241
1996
|
});
|
|
3242
|
-
const expiryAtExpression = sql`DATE_FORMAT(UTC_TIMESTAMP() + INTERVAL ${expiresInSeconds} SECOND, '%Y-%m-%dT%H:%i:%sZ')`;
|
|
1997
|
+
const expiryAtExpression = drizzleOrm.sql`DATE_FORMAT(UTC_TIMESTAMP() + INTERVAL ${expiresInSeconds} SECOND, '%Y-%m-%dT%H:%i:%sZ')`;
|
|
3243
1998
|
await this.conn.update(dvssBackendModuleDatastore.schema.capabilityIntegration).set({
|
|
3244
|
-
config: sql`
|
|
1999
|
+
config: drizzleOrm.sql`
|
|
3245
2000
|
JSON_SET(
|
|
3246
2001
|
JSON_SET(
|
|
3247
2002
|
COALESCE(${dvssBackendModuleDatastore.schema.capabilityIntegration.config}, JSON_OBJECT()),
|
|
@@ -3253,7 +2008,7 @@ exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
|
|
|
3253
2008
|
)
|
|
3254
2009
|
`,
|
|
3255
2010
|
updatedBy: loggedInUserId
|
|
3256
|
-
}).where(and(eq(dvssBackendModuleDatastore.schema.capabilityIntegration.id, capabilityIntegrationId), isNull(dvssBackendModuleDatastore.schema.capabilityIntegration.deletedAt)));
|
|
2011
|
+
}).where(drizzleOrm.and(drizzleOrm.eq(dvssBackendModuleDatastore.schema.capabilityIntegration.id, capabilityIntegrationId), drizzleOrm.isNull(dvssBackendModuleDatastore.schema.capabilityIntegration.deletedAt)));
|
|
3257
2012
|
} catch (error) {
|
|
3258
2013
|
this.logger.error(loggedInUserId, this.updateCapabilityIntegrationAccessDetails.name, this.fileName, "Error updating capability integration access details", error, {
|
|
3259
2014
|
capabilityIntegrationId
|
|
@@ -3282,7 +2037,7 @@ exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
|
|
|
3282
2037
|
id: dvssBackendModuleDatastore.schema.capIntegResourceMapping.id,
|
|
3283
2038
|
configuredForId: dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId,
|
|
3284
2039
|
configuredForType: dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType
|
|
3285
|
-
}).from(dvssBackendModuleDatastore.schema.capIntegResourceMapping).where(and(eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.capabilityIntegrationId, input.capabilityIntegrationId), eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.projectId, input.projectId), isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt)));
|
|
2040
|
+
}).from(dvssBackendModuleDatastore.schema.capIntegResourceMapping).where(drizzleOrm.and(drizzleOrm.eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.capabilityIntegrationId, input.capabilityIntegrationId), drizzleOrm.eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.projectId, input.projectId), drizzleOrm.isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt)));
|
|
3286
2041
|
const existingMap = /* @__PURE__ */ new Map();
|
|
3287
2042
|
for (const e of existing) {
|
|
3288
2043
|
existingMap.set(`${e.configuredForId}:${e.configuredForType}`, e);
|
|
@@ -3312,7 +2067,7 @@ exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
|
|
|
3312
2067
|
await tx.update(dvssBackendModuleDatastore.schema.capIntegResourceMapping).set({
|
|
3313
2068
|
deletedAt: /* @__PURE__ */ new Date(),
|
|
3314
2069
|
deletedBy: loggedInUserId
|
|
3315
|
-
}).where(inArray(dvssBackendModuleDatastore.schema.capIntegResourceMapping.id, toDeleteIds));
|
|
2070
|
+
}).where(drizzleOrm.inArray(dvssBackendModuleDatastore.schema.capIntegResourceMapping.id, toDeleteIds));
|
|
3316
2071
|
}
|
|
3317
2072
|
if (toInsert.length > 0) {
|
|
3318
2073
|
await tx.insert(dvssBackendModuleDatastore.schema.capIntegResourceMapping).values(toInsert);
|
|
@@ -3334,7 +2089,7 @@ exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
|
|
|
3334
2089
|
try {
|
|
3335
2090
|
this.logger.info(loggedInUserId, this.getCapabilityIntegration.name, this.fileName, "getCapabilityIntegration called", input);
|
|
3336
2091
|
return await this.conn.query.capabilityIntegration.findFirst({
|
|
3337
|
-
where: and(isNull(dvssBackendModuleDatastore.schema.capabilityIntegration.deletedAt), eq(dvssBackendModuleDatastore.schema.capabilityIntegration.id, input.capabilityIntegrationId))
|
|
2092
|
+
where: drizzleOrm.and(drizzleOrm.isNull(dvssBackendModuleDatastore.schema.capabilityIntegration.deletedAt), drizzleOrm.eq(dvssBackendModuleDatastore.schema.capabilityIntegration.id, input.capabilityIntegrationId))
|
|
3338
2093
|
});
|
|
3339
2094
|
} catch (error) {
|
|
3340
2095
|
this.logger.error(loggedInUserId, this.getCapabilityIntegration.name, this.fileName, "Error on getCapabilityIntegration", error, input);
|
|
@@ -3349,24 +2104,24 @@ exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
|
|
|
3349
2104
|
try {
|
|
3350
2105
|
this.logger.info(loggedInUserId, this.getCapabilityIntegrationById.name, this.fileName, "getCapabilityIntegrationById called", request);
|
|
3351
2106
|
const conditions = [
|
|
3352
|
-
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.id, request.id),
|
|
3353
|
-
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.projectId, request.projectId),
|
|
3354
|
-
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.type, capability_model.CAPABILITY_TYPE_ENUM.INTEGRATION),
|
|
3355
|
-
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.status, capabilityIntegration_model.CAPABILITY_INTEGRATION_STATUS_ENUM.ACTIVE),
|
|
3356
|
-
isNull(dvssBackendModuleDatastore.schema.capabilityIntegration.deletedAt),
|
|
3357
|
-
isNull(dvssBackendModuleDatastore.schema.capability.deletedAt)
|
|
2107
|
+
drizzleOrm.eq(dvssBackendModuleDatastore.schema.capabilityIntegration.id, request.id),
|
|
2108
|
+
drizzleOrm.eq(dvssBackendModuleDatastore.schema.capabilityIntegration.projectId, request.projectId),
|
|
2109
|
+
drizzleOrm.eq(dvssBackendModuleDatastore.schema.capabilityIntegration.type, capability_model.CAPABILITY_TYPE_ENUM.INTEGRATION),
|
|
2110
|
+
drizzleOrm.eq(dvssBackendModuleDatastore.schema.capabilityIntegration.status, capabilityIntegration_model.CAPABILITY_INTEGRATION_STATUS_ENUM.ACTIVE),
|
|
2111
|
+
drizzleOrm.isNull(dvssBackendModuleDatastore.schema.capabilityIntegration.deletedAt),
|
|
2112
|
+
drizzleOrm.isNull(dvssBackendModuleDatastore.schema.capability.deletedAt)
|
|
3358
2113
|
];
|
|
3359
2114
|
if (request.category) {
|
|
3360
|
-
conditions.push(eq(dvssBackendModuleDatastore.schema.capabilityIntegration.category, request.category));
|
|
2115
|
+
conditions.push(drizzleOrm.eq(dvssBackendModuleDatastore.schema.capabilityIntegration.category, request.category));
|
|
3361
2116
|
}
|
|
3362
2117
|
const response = await this.conn.select({
|
|
3363
|
-
...getTableColumns(dvssBackendModuleDatastore.schema.capabilityIntegration),
|
|
2118
|
+
...drizzleOrm.getTableColumns(dvssBackendModuleDatastore.schema.capabilityIntegration),
|
|
3364
2119
|
resourceMappingId: dvssBackendModuleDatastore.schema.capIntegResourceMapping.id,
|
|
3365
2120
|
configuredForId: dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId,
|
|
3366
2121
|
configuredForType: dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType,
|
|
3367
2122
|
resourceMappingConfig: dvssBackendModuleDatastore.schema.capIntegResourceMapping.config,
|
|
3368
2123
|
provider: dvssBackendModuleDatastore.schema.capability.providerIntegrationType
|
|
3369
|
-
}).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));
|
|
2124
|
+
}).from(dvssBackendModuleDatastore.schema.capabilityIntegration).innerJoin(dvssBackendModuleDatastore.schema.capability, drizzleOrm.eq(dvssBackendModuleDatastore.schema.capability.id, dvssBackendModuleDatastore.schema.capabilityIntegration.capabilityId)).leftJoin(dvssBackendModuleDatastore.schema.capIntegResourceMapping, drizzleOrm.and(drizzleOrm.eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.capabilityIntegrationId, dvssBackendModuleDatastore.schema.capabilityIntegration.id), drizzleOrm.eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.projectId, request.projectId), drizzleOrm.isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt))).where(drizzleOrm.and(...conditions));
|
|
3370
2125
|
return response[0];
|
|
3371
2126
|
} catch (error) {
|
|
3372
2127
|
this.logger.error(loggedInUserId, this.getCapabilityIntegrationById.name, this.fileName, "Error on getCapabilityIntegrationById", error, request);
|
|
@@ -3381,27 +2136,27 @@ exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
|
|
|
3381
2136
|
try {
|
|
3382
2137
|
this.logger.info(loggedInUserId, this.getCapabilityIntegrationByProvider.name, this.fileName, "getCapabilityIntegrationByProvider called", request);
|
|
3383
2138
|
const conditions = [
|
|
3384
|
-
isNull(dvssBackendModuleDatastore.schema.capability.deletedAt),
|
|
3385
|
-
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.projectId, request.projectId),
|
|
3386
|
-
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.type, capability_model.CAPABILITY_TYPE_ENUM.INTEGRATION),
|
|
3387
|
-
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.status, capabilityIntegration_model.CAPABILITY_INTEGRATION_STATUS_ENUM.ACTIVE),
|
|
3388
|
-
isNull(dvssBackendModuleDatastore.schema.capabilityIntegration.deletedAt),
|
|
3389
|
-
eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.projectId, request.projectId),
|
|
3390
|
-
eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType, request.configuredForType),
|
|
3391
|
-
eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId, request.configuredForId),
|
|
3392
|
-
isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt)
|
|
2139
|
+
drizzleOrm.isNull(dvssBackendModuleDatastore.schema.capability.deletedAt),
|
|
2140
|
+
drizzleOrm.eq(dvssBackendModuleDatastore.schema.capabilityIntegration.projectId, request.projectId),
|
|
2141
|
+
drizzleOrm.eq(dvssBackendModuleDatastore.schema.capabilityIntegration.type, capability_model.CAPABILITY_TYPE_ENUM.INTEGRATION),
|
|
2142
|
+
drizzleOrm.eq(dvssBackendModuleDatastore.schema.capabilityIntegration.status, capabilityIntegration_model.CAPABILITY_INTEGRATION_STATUS_ENUM.ACTIVE),
|
|
2143
|
+
drizzleOrm.isNull(dvssBackendModuleDatastore.schema.capabilityIntegration.deletedAt),
|
|
2144
|
+
drizzleOrm.eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.projectId, request.projectId),
|
|
2145
|
+
drizzleOrm.eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType, request.configuredForType),
|
|
2146
|
+
drizzleOrm.eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId, request.configuredForId),
|
|
2147
|
+
drizzleOrm.isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt)
|
|
3393
2148
|
];
|
|
3394
2149
|
if (request.category) {
|
|
3395
|
-
conditions.push(eq(dvssBackendModuleDatastore.schema.capabilityIntegration.category, request.category));
|
|
2150
|
+
conditions.push(drizzleOrm.eq(dvssBackendModuleDatastore.schema.capabilityIntegration.category, request.category));
|
|
3396
2151
|
}
|
|
3397
2152
|
const response = await this.conn.select({
|
|
3398
|
-
...getTableColumns(dvssBackendModuleDatastore.schema.capabilityIntegration),
|
|
2153
|
+
...drizzleOrm.getTableColumns(dvssBackendModuleDatastore.schema.capabilityIntegration),
|
|
3399
2154
|
resourceMappingId: dvssBackendModuleDatastore.schema.capIntegResourceMapping.id,
|
|
3400
2155
|
configuredForId: dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId,
|
|
3401
2156
|
configuredForType: dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType,
|
|
3402
2157
|
resourceMappingConfig: dvssBackendModuleDatastore.schema.capIntegResourceMapping.config,
|
|
3403
2158
|
provider: dvssBackendModuleDatastore.schema.capability.providerIntegrationType
|
|
3404
|
-
}).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));
|
|
2159
|
+
}).from(dvssBackendModuleDatastore.schema.capabilityIntegration).innerJoin(dvssBackendModuleDatastore.schema.capability, drizzleOrm.eq(dvssBackendModuleDatastore.schema.capability.id, dvssBackendModuleDatastore.schema.capabilityIntegration.capabilityId)).innerJoin(dvssBackendModuleDatastore.schema.capIntegResourceMapping, drizzleOrm.eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.capabilityIntegrationId, dvssBackendModuleDatastore.schema.capabilityIntegration.id)).where(drizzleOrm.and(...conditions));
|
|
3405
2160
|
return response[0];
|
|
3406
2161
|
} catch (error) {
|
|
3407
2162
|
this.logger.error(loggedInUserId, this.getCapabilityIntegrationByProvider.name, this.fileName, "Error on getCapabilityIntegrationByProvider", error, request);
|
|
@@ -3424,60 +2179,60 @@ exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
|
|
|
3424
2179
|
} else if (sorting?.by === "UPDATED_AT") {
|
|
3425
2180
|
sortBy = dvssBackendModuleDatastore.schema.capabilityIntegration.updatedAt;
|
|
3426
2181
|
}
|
|
3427
|
-
const sortOrder = sorting?.order === common_enum.SORTING_ORDER_ENUM.ASC ? asc(sortBy) : desc(sortBy);
|
|
2182
|
+
const sortOrder = sorting?.order === common_enum.SORTING_ORDER_ENUM.ASC ? drizzleOrm.asc(sortBy) : drizzleOrm.desc(sortBy);
|
|
3428
2183
|
const searchTerm = input.options?.search;
|
|
3429
2184
|
const shouldJoinCapability = Boolean(searchTerm) || Boolean(input.options?.filters?.some((filter) => filter.by === "PROVIDER_INTEGRATION_TYPE"));
|
|
3430
2185
|
const whereConditions = [
|
|
3431
|
-
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.projectId, input.projectId),
|
|
3432
|
-
isNull(dvssBackendModuleDatastore.schema.capabilityIntegration.deletedAt)
|
|
2186
|
+
drizzleOrm.eq(dvssBackendModuleDatastore.schema.capabilityIntegration.projectId, input.projectId),
|
|
2187
|
+
drizzleOrm.isNull(dvssBackendModuleDatastore.schema.capabilityIntegration.deletedAt)
|
|
3433
2188
|
];
|
|
3434
2189
|
if (input.category) {
|
|
3435
|
-
whereConditions.push(eq(dvssBackendModuleDatastore.schema.capabilityIntegration.category, input.category));
|
|
2190
|
+
whereConditions.push(drizzleOrm.eq(dvssBackendModuleDatastore.schema.capabilityIntegration.category, input.category));
|
|
3436
2191
|
}
|
|
3437
2192
|
if (input.options?.filters && input.options.filters.length > 0) {
|
|
3438
2193
|
this.applyFilters(whereConditions, input.options);
|
|
3439
2194
|
}
|
|
3440
2195
|
if (searchTerm) {
|
|
3441
2196
|
const searchPattern = `%${searchTerm}%`;
|
|
3442
|
-
whereConditions.push(sql`(${dvssBackendModuleDatastore.schema.capabilityIntegration.nickname} LIKE ${searchPattern} OR ${dvssBackendModuleDatastore.schema.capability.name} LIKE ${searchPattern})`);
|
|
2197
|
+
whereConditions.push(drizzleOrm.sql`(${dvssBackendModuleDatastore.schema.capabilityIntegration.nickname} LIKE ${searchPattern} OR ${dvssBackendModuleDatastore.schema.capability.name} LIKE ${searchPattern})`);
|
|
3443
2198
|
}
|
|
3444
2199
|
if (shouldJoinCapability) {
|
|
3445
|
-
whereConditions.push(isNull(dvssBackendModuleDatastore.schema.capability.deletedAt));
|
|
2200
|
+
whereConditions.push(drizzleOrm.isNull(dvssBackendModuleDatastore.schema.capability.deletedAt));
|
|
3446
2201
|
}
|
|
3447
2202
|
if (input.propertyId) {
|
|
3448
|
-
whereConditions.push(isNotNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.id));
|
|
2203
|
+
whereConditions.push(drizzleOrm.isNotNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.id));
|
|
3449
2204
|
}
|
|
3450
2205
|
const countWhereConditions = [
|
|
3451
|
-
eq(dvssBackendModuleDatastore.schema.capabilityIntegration.projectId, input.projectId),
|
|
3452
|
-
isNull(dvssBackendModuleDatastore.schema.capabilityIntegration.deletedAt)
|
|
2206
|
+
drizzleOrm.eq(dvssBackendModuleDatastore.schema.capabilityIntegration.projectId, input.projectId),
|
|
2207
|
+
drizzleOrm.isNull(dvssBackendModuleDatastore.schema.capabilityIntegration.deletedAt)
|
|
3453
2208
|
];
|
|
3454
2209
|
if (input.category) {
|
|
3455
|
-
countWhereConditions.push(eq(dvssBackendModuleDatastore.schema.capabilityIntegration.category, input.category));
|
|
2210
|
+
countWhereConditions.push(drizzleOrm.eq(dvssBackendModuleDatastore.schema.capabilityIntegration.category, input.category));
|
|
3456
2211
|
}
|
|
3457
2212
|
if (input.options?.filters && input.options.filters.length > 0) {
|
|
3458
2213
|
this.applyFilters(countWhereConditions, input.options);
|
|
3459
2214
|
}
|
|
3460
2215
|
if (searchTerm) {
|
|
3461
2216
|
const searchPattern = `%${searchTerm}%`;
|
|
3462
|
-
countWhereConditions.push(sql`(${dvssBackendModuleDatastore.schema.capabilityIntegration.nickname} LIKE ${searchPattern} OR ${dvssBackendModuleDatastore.schema.capability.name} LIKE ${searchPattern})`);
|
|
2217
|
+
countWhereConditions.push(drizzleOrm.sql`(${dvssBackendModuleDatastore.schema.capabilityIntegration.nickname} LIKE ${searchPattern} OR ${dvssBackendModuleDatastore.schema.capability.name} LIKE ${searchPattern})`);
|
|
3463
2218
|
}
|
|
3464
2219
|
const countQueryBuilder = this.conn.select({
|
|
3465
|
-
count: sql`count(distinct ${dvssBackendModuleDatastore.schema.capabilityIntegration.id})`.as("count")
|
|
2220
|
+
count: drizzleOrm.sql`count(distinct ${dvssBackendModuleDatastore.schema.capabilityIntegration.id})`.as("count")
|
|
3466
2221
|
}).from(dvssBackendModuleDatastore.schema.capabilityIntegration);
|
|
3467
|
-
const countQueryWithJoins = shouldJoinCapability ? countQueryBuilder.leftJoin(dvssBackendModuleDatastore.schema.capability, eq(dvssBackendModuleDatastore.schema.capability.id, dvssBackendModuleDatastore.schema.capabilityIntegration.capabilityId)) : countQueryBuilder;
|
|
2222
|
+
const countQueryWithJoins = shouldJoinCapability ? countQueryBuilder.leftJoin(dvssBackendModuleDatastore.schema.capability, drizzleOrm.eq(dvssBackendModuleDatastore.schema.capability.id, dvssBackendModuleDatastore.schema.capabilityIntegration.capabilityId)) : countQueryBuilder;
|
|
3468
2223
|
if (shouldJoinCapability) {
|
|
3469
|
-
countWhereConditions.push(isNull(dvssBackendModuleDatastore.schema.capability.deletedAt));
|
|
2224
|
+
countWhereConditions.push(drizzleOrm.isNull(dvssBackendModuleDatastore.schema.capability.deletedAt));
|
|
3470
2225
|
}
|
|
3471
|
-
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;
|
|
2226
|
+
const countQueryWithPropertyJoin = input.propertyId ? countQueryWithJoins.leftJoin(dvssBackendModuleDatastore.schema.capIntegResourceMapping, drizzleOrm.and(drizzleOrm.eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.capabilityIntegrationId, dvssBackendModuleDatastore.schema.capabilityIntegration.id), drizzleOrm.eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType, models.CONFIGURED_FOR_TYPE_ENUM.PROPERTY), drizzleOrm.eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId, BigInt(input.propertyId)), drizzleOrm.isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt))) : countQueryWithJoins;
|
|
3472
2227
|
if (input.propertyId) {
|
|
3473
|
-
countWhereConditions.push(isNotNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.id));
|
|
2228
|
+
countWhereConditions.push(drizzleOrm.isNotNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.id));
|
|
3474
2229
|
}
|
|
3475
|
-
const countQuery = countQueryWithPropertyJoin.where(and(...countWhereConditions));
|
|
2230
|
+
const countQuery = countQueryWithPropertyJoin.where(drizzleOrm.and(...countWhereConditions));
|
|
3476
2231
|
const baseQuery = this.conn.select({
|
|
3477
|
-
...getTableColumns(dvssBackendModuleDatastore.schema.capabilityIntegration),
|
|
2232
|
+
...drizzleOrm.getTableColumns(dvssBackendModuleDatastore.schema.capabilityIntegration),
|
|
3478
2233
|
provider: dvssBackendModuleDatastore.schema.capability.providerIntegrationType
|
|
3479
|
-
}).from(dvssBackendModuleDatastore.schema.capabilityIntegration).leftJoin(dvssBackendModuleDatastore.schema.capability, eq(dvssBackendModuleDatastore.schema.capability.id, dvssBackendModuleDatastore.schema.capabilityIntegration.capabilityId));
|
|
3480
|
-
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));
|
|
2234
|
+
}).from(dvssBackendModuleDatastore.schema.capabilityIntegration).leftJoin(dvssBackendModuleDatastore.schema.capability, drizzleOrm.eq(dvssBackendModuleDatastore.schema.capability.id, dvssBackendModuleDatastore.schema.capabilityIntegration.capabilityId));
|
|
2235
|
+
const finalQuery = input.propertyId ? baseQuery.leftJoin(dvssBackendModuleDatastore.schema.capIntegResourceMapping, drizzleOrm.and(drizzleOrm.eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.capabilityIntegrationId, dvssBackendModuleDatastore.schema.capabilityIntegration.id), drizzleOrm.eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType, models.CONFIGURED_FOR_TYPE_ENUM.PROPERTY), drizzleOrm.eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId, BigInt(input.propertyId)), drizzleOrm.isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt))).where(drizzleOrm.and(...whereConditions)) : baseQuery.where(drizzleOrm.and(...whereConditions));
|
|
3481
2236
|
const [{ count: totalCount }, records] = await Promise.all([
|
|
3482
2237
|
countQuery.execute().then((result) => result[0]),
|
|
3483
2238
|
finalQuery.limit(count).offset(offset).orderBy(sortOrder).execute()
|
|
@@ -3505,9 +2260,9 @@ exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
|
|
|
3505
2260
|
}
|
|
3506
2261
|
switch (filter.by) {
|
|
3507
2262
|
case "PROVIDER_INTEGRATION_TYPE": {
|
|
3508
|
-
const valuePlaceholders = filterValues.map((value) => sql`${String(value)}`);
|
|
3509
|
-
const joinedValues = sql.join(valuePlaceholders, sql`, `);
|
|
3510
|
-
whereConditions.push(sql`${dvssBackendModuleDatastore.schema.capability.providerIntegrationType} IN (${joinedValues})`);
|
|
2263
|
+
const valuePlaceholders = filterValues.map((value) => drizzleOrm.sql`${String(value)}`);
|
|
2264
|
+
const joinedValues = drizzleOrm.sql.join(valuePlaceholders, drizzleOrm.sql`, `);
|
|
2265
|
+
whereConditions.push(drizzleOrm.sql`${dvssBackendModuleDatastore.schema.capability.providerIntegrationType} IN (${joinedValues})`);
|
|
3511
2266
|
break;
|
|
3512
2267
|
}
|
|
3513
2268
|
case "CAPABILITY_INTEGRATION_TYPE": {
|
|
@@ -3515,15 +2270,15 @@ exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
|
|
|
3515
2270
|
for (const value of filterValues) {
|
|
3516
2271
|
const upperValue = String(value).toUpperCase();
|
|
3517
2272
|
if (upperValue === "PARENT") {
|
|
3518
|
-
parentConditions.push(isNull(dvssBackendModuleDatastore.schema.capabilityIntegration.parentId));
|
|
2273
|
+
parentConditions.push(drizzleOrm.isNull(dvssBackendModuleDatastore.schema.capabilityIntegration.parentId));
|
|
3519
2274
|
} else if (upperValue === "CHILD") {
|
|
3520
|
-
parentConditions.push(isNotNull(dvssBackendModuleDatastore.schema.capabilityIntegration.parentId));
|
|
2275
|
+
parentConditions.push(drizzleOrm.isNotNull(dvssBackendModuleDatastore.schema.capabilityIntegration.parentId));
|
|
3521
2276
|
}
|
|
3522
2277
|
}
|
|
3523
2278
|
if (parentConditions.length === 1) {
|
|
3524
2279
|
whereConditions.push(parentConditions[0]);
|
|
3525
2280
|
} else if (parentConditions.length > 1) {
|
|
3526
|
-
const orCondition = or(...parentConditions);
|
|
2281
|
+
const orCondition = drizzleOrm.or(...parentConditions);
|
|
3527
2282
|
if (orCondition) {
|
|
3528
2283
|
whereConditions.push(orCondition);
|
|
3529
2284
|
}
|
|
@@ -3583,19 +2338,19 @@ exports.IntegrationServiceCommunicationTopicDao = class IntegrationServiceCommun
|
|
|
3583
2338
|
});
|
|
3584
2339
|
try {
|
|
3585
2340
|
const existing = await this.conn.query.serviceCommunicationTopic.findFirst({
|
|
3586
|
-
where: and(
|
|
3587
|
-
eq(dvssBackendModuleDatastore.schema.serviceCommunicationTopic.deploymentId, input.deploymentId),
|
|
3588
|
-
eq(dvssBackendModuleDatastore.schema.serviceCommunicationTopic.projectId, input.projectId),
|
|
3589
|
-
isNull(dvssBackendModuleDatastore.schema.serviceCommunicationTopic.deletedAt),
|
|
2341
|
+
where: drizzleOrm.and(
|
|
2342
|
+
drizzleOrm.eq(dvssBackendModuleDatastore.schema.serviceCommunicationTopic.deploymentId, input.deploymentId),
|
|
2343
|
+
drizzleOrm.eq(dvssBackendModuleDatastore.schema.serviceCommunicationTopic.projectId, input.projectId),
|
|
2344
|
+
drizzleOrm.isNull(dvssBackendModuleDatastore.schema.serviceCommunicationTopic.deletedAt),
|
|
3590
2345
|
...input.capability ? [
|
|
3591
|
-
eq(dvssBackendModuleDatastore.schema.serviceCommunicationTopic.capability, input.capability)
|
|
2346
|
+
drizzleOrm.eq(dvssBackendModuleDatastore.schema.serviceCommunicationTopic.capability, input.capability)
|
|
3592
2347
|
] : [],
|
|
3593
2348
|
...input.subcapability ? [
|
|
3594
|
-
eq(dvssBackendModuleDatastore.schema.serviceCommunicationTopic.subcapability, input.subcapability)
|
|
2349
|
+
drizzleOrm.eq(dvssBackendModuleDatastore.schema.serviceCommunicationTopic.subcapability, input.subcapability)
|
|
3595
2350
|
] : [],
|
|
3596
|
-
eq(dvssBackendModuleDatastore.schema.serviceCommunicationTopic.subcapabilityOperation, input.subcapabilityOperation),
|
|
2351
|
+
drizzleOrm.eq(dvssBackendModuleDatastore.schema.serviceCommunicationTopic.subcapabilityOperation, input.subcapabilityOperation),
|
|
3597
2352
|
...input.capabilityIntegrationId ? [
|
|
3598
|
-
eq(dvssBackendModuleDatastore.schema.serviceCommunicationTopic.capabilityIntegrationId, input.capabilityIntegrationId)
|
|
2353
|
+
drizzleOrm.eq(dvssBackendModuleDatastore.schema.serviceCommunicationTopic.capabilityIntegrationId, input.capabilityIntegrationId)
|
|
3599
2354
|
] : []
|
|
3600
2355
|
)
|
|
3601
2356
|
});
|
|
@@ -3608,7 +2363,7 @@ exports.IntegrationServiceCommunicationTopicDao = class IntegrationServiceCommun
|
|
|
3608
2363
|
shouldSubscribe: input.shouldSubscribe ?? existing.shouldSubscribe,
|
|
3609
2364
|
updatedAt: /* @__PURE__ */ new Date(),
|
|
3610
2365
|
updatedBy: loggedInUserId
|
|
3611
|
-
}).where(eq(dvssBackendModuleDatastore.schema.serviceCommunicationTopic.id, existing.id));
|
|
2366
|
+
}).where(drizzleOrm.eq(dvssBackendModuleDatastore.schema.serviceCommunicationTopic.id, existing.id));
|
|
3612
2367
|
return {
|
|
3613
2368
|
status: true
|
|
3614
2369
|
};
|
|
@@ -3650,9 +2405,9 @@ exports.IntegrationServiceCommunicationTopicDao = class IntegrationServiceCommun
|
|
|
3650
2405
|
});
|
|
3651
2406
|
try {
|
|
3652
2407
|
const topics = await this.conn.select({
|
|
3653
|
-
...getTableColumns(dvssBackendModuleDatastore.schema.serviceCommunicationTopic),
|
|
3654
|
-
subcapability: getTableColumns(dvssBackendModuleDatastore.schema.subcapability)
|
|
3655
|
-
}).from(dvssBackendModuleDatastore.schema.serviceCommunicationTopic).innerJoin(dvssBackendModuleDatastore.schema.subcapability, eq(dvssBackendModuleDatastore.schema.subcapability.id, dvssBackendModuleDatastore.schema.serviceCommunicationTopic.subcapability)).where(and(eq(dvssBackendModuleDatastore.schema.serviceCommunicationTopic.capabilityIntegrationId, integrationId), isNull(dvssBackendModuleDatastore.schema.serviceCommunicationTopic.deletedAt)));
|
|
2408
|
+
...drizzleOrm.getTableColumns(dvssBackendModuleDatastore.schema.serviceCommunicationTopic),
|
|
2409
|
+
subcapability: drizzleOrm.getTableColumns(dvssBackendModuleDatastore.schema.subcapability)
|
|
2410
|
+
}).from(dvssBackendModuleDatastore.schema.serviceCommunicationTopic).innerJoin(dvssBackendModuleDatastore.schema.subcapability, drizzleOrm.eq(dvssBackendModuleDatastore.schema.subcapability.id, dvssBackendModuleDatastore.schema.serviceCommunicationTopic.subcapability)).where(drizzleOrm.and(drizzleOrm.eq(dvssBackendModuleDatastore.schema.serviceCommunicationTopic.capabilityIntegrationId, integrationId), drizzleOrm.isNull(dvssBackendModuleDatastore.schema.serviceCommunicationTopic.deletedAt)));
|
|
3656
2411
|
return topics;
|
|
3657
2412
|
} catch (error) {
|
|
3658
2413
|
this.logger.error(loggedInUserId, this.getServiceCommunicationTopics.name, this.fileName, "Error in getServiceCommunicationTopics", error, {
|
|
@@ -3719,288 +2474,1041 @@ exports.IntegrationResourceManagementDao = class IntegrationResourceManagementDa
|
|
|
3719
2474
|
config: input.config ?? null,
|
|
3720
2475
|
createdBy: context.loggedInUserId
|
|
3721
2476
|
});
|
|
3722
|
-
const raw = insertResult;
|
|
3723
|
-
const insertedId = raw[0]?.insertId != null ? Number(raw[0].insertId) : 0;
|
|
3724
|
-
const isInserted = insertedId > 0;
|
|
3725
|
-
const ids = isInserted ? [
|
|
3726
|
-
BigInt(insertedId)
|
|
3727
|
-
] : [];
|
|
3728
|
-
this.logger.info(context.loggedInUserId, this.addCapabilityIntegrationMapping.name, this.fileName, `Mapping add ${isInserted ? "successful" : "failed"}`, {
|
|
3729
|
-
insertedId,
|
|
3730
|
-
status: isInserted
|
|
2477
|
+
const raw = insertResult;
|
|
2478
|
+
const insertedId = raw[0]?.insertId != null ? Number(raw[0].insertId) : 0;
|
|
2479
|
+
const isInserted = insertedId > 0;
|
|
2480
|
+
const ids = isInserted ? [
|
|
2481
|
+
BigInt(insertedId)
|
|
2482
|
+
] : [];
|
|
2483
|
+
this.logger.info(context.loggedInUserId, this.addCapabilityIntegrationMapping.name, this.fileName, `Mapping add ${isInserted ? "successful" : "failed"}`, {
|
|
2484
|
+
insertedId,
|
|
2485
|
+
status: isInserted
|
|
2486
|
+
});
|
|
2487
|
+
return {
|
|
2488
|
+
status: isInserted,
|
|
2489
|
+
ids
|
|
2490
|
+
};
|
|
2491
|
+
} catch (error) {
|
|
2492
|
+
this.logger.error(context.loggedInUserId, this.addCapabilityIntegrationMapping.name, this.fileName, "Error adding capability integration mapping", error, input);
|
|
2493
|
+
throw error;
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2496
|
+
/**
|
|
2497
|
+
* Checks if a capability integration resource mapping exists.
|
|
2498
|
+
* Validates that the mapping exists for the given capability integration, configured for ID and type.
|
|
2499
|
+
*
|
|
2500
|
+
* @param input - Input containing capability integration ID, configured for ID and type
|
|
2501
|
+
* @param loggedInUserId - ID of the user performing the operation
|
|
2502
|
+
* @returns Promise that resolves to true if mapping exists, false otherwise
|
|
2503
|
+
*/
|
|
2504
|
+
async checkMappingExists(input, loggedInUserId) {
|
|
2505
|
+
try {
|
|
2506
|
+
this.logger.info(loggedInUserId, this.checkMappingExists.name, this.fileName, `${this.checkMappingExists.name} called`, input);
|
|
2507
|
+
const response = await this.conn.select({
|
|
2508
|
+
id: dvssBackendModuleDatastore.schema.capIntegResourceMapping.id
|
|
2509
|
+
}).from(dvssBackendModuleDatastore.schema.capIntegResourceMapping).where(drizzleOrm.and(drizzleOrm.eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.capabilityIntegrationId, input.capabilityIntegrationId), drizzleOrm.eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId, input.configuredForId), drizzleOrm.eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType, input.configuredForType), drizzleOrm.isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt))).limit(1);
|
|
2510
|
+
return response.length > 0;
|
|
2511
|
+
} catch (error) {
|
|
2512
|
+
this.logger.error(loggedInUserId, this.checkMappingExists.name, this.fileName, "Error in checkMappingExists", error, input);
|
|
2513
|
+
throw error;
|
|
2514
|
+
}
|
|
2515
|
+
}
|
|
2516
|
+
/**
|
|
2517
|
+
* Removes capability integration resource mapping (soft delete).
|
|
2518
|
+
* Sets deletedAt and deletedBy on the matching cap_integ_resource_mapping row.
|
|
2519
|
+
* Use this from UIF/callers instead of inter-service call to project-onboarding-ms.
|
|
2520
|
+
*
|
|
2521
|
+
* @param input - Delete parameters including capability integration ID, configured for ID and type
|
|
2522
|
+
* @param loggedInUserId - ID of the user performing the operation
|
|
2523
|
+
* @returns Promise resolving to { status: true } if any row was updated, { status: false } otherwise
|
|
2524
|
+
*/
|
|
2525
|
+
async removeCapabilityIntegrationMapping(input, context) {
|
|
2526
|
+
try {
|
|
2527
|
+
this.logger.info(context.loggedInUserId, this.removeCapabilityIntegrationMapping.name, this.fileName, "Removing capability integration mapping", input);
|
|
2528
|
+
const whereConditions = [
|
|
2529
|
+
drizzleOrm.isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt),
|
|
2530
|
+
drizzleOrm.eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.capabilityIntegrationId, input.capabilityIntegrationId),
|
|
2531
|
+
drizzleOrm.eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId, input.configuredForId),
|
|
2532
|
+
drizzleOrm.eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType, input.configuredForType)
|
|
2533
|
+
];
|
|
2534
|
+
const deleteResult = await this.conn.update(dvssBackendModuleDatastore.schema.capIntegResourceMapping).set({
|
|
2535
|
+
deletedAt: /* @__PURE__ */ new Date(),
|
|
2536
|
+
deletedBy: context.loggedInUserId
|
|
2537
|
+
}).where(drizzleOrm.and(...whereConditions));
|
|
2538
|
+
const isSuccess = deleteResult[0].affectedRows > 0;
|
|
2539
|
+
this.logger.info(context.loggedInUserId, this.removeCapabilityIntegrationMapping.name, this.fileName, `Mapping removal ${isSuccess ? "successful" : "failed - no matching records"}`, {
|
|
2540
|
+
affectedRows: deleteResult[0].affectedRows
|
|
2541
|
+
});
|
|
2542
|
+
return {
|
|
2543
|
+
status: isSuccess
|
|
2544
|
+
};
|
|
2545
|
+
} catch (error) {
|
|
2546
|
+
this.logger.error(context.loggedInUserId, this.removeCapabilityIntegrationMapping.name, this.fileName, "Error removing capability integration mapping", error, input);
|
|
2547
|
+
throw error;
|
|
2548
|
+
}
|
|
2549
|
+
}
|
|
2550
|
+
/**
|
|
2551
|
+
* Gets a capability integration resource mapping by id (non-deleted only).
|
|
2552
|
+
* Use from UIF wrappers to validate mapping exists before update.
|
|
2553
|
+
*
|
|
2554
|
+
* @param id - cap_integ_resource_mapping.id
|
|
2555
|
+
* @param loggedInUserId - for logging
|
|
2556
|
+
* @returns The mapping row or undefined if not found
|
|
2557
|
+
*/
|
|
2558
|
+
async getCapabilityIntegrationResourceMappingById(id, loggedInUserId) {
|
|
2559
|
+
try {
|
|
2560
|
+
this.logger.info(loggedInUserId, this.getCapabilityIntegrationResourceMappingById.name, this.fileName, `${this.getCapabilityIntegrationResourceMappingById.name} called`, {
|
|
2561
|
+
id: id.toString()
|
|
2562
|
+
});
|
|
2563
|
+
const rows = await this.conn.select({
|
|
2564
|
+
id: dvssBackendModuleDatastore.schema.capIntegResourceMapping.id,
|
|
2565
|
+
capabilityIntegrationId: dvssBackendModuleDatastore.schema.capIntegResourceMapping.capabilityIntegrationId,
|
|
2566
|
+
configuredForId: dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId,
|
|
2567
|
+
configuredForType: dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType
|
|
2568
|
+
}).from(dvssBackendModuleDatastore.schema.capIntegResourceMapping).where(drizzleOrm.and(drizzleOrm.eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.id, id), drizzleOrm.isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt))).limit(1);
|
|
2569
|
+
return rows[0];
|
|
2570
|
+
} catch (error) {
|
|
2571
|
+
this.logger.error(loggedInUserId, this.getCapabilityIntegrationResourceMappingById.name, this.fileName, "Error in getCapabilityIntegrationResourceMappingById", error, {
|
|
2572
|
+
id: id.toString()
|
|
2573
|
+
});
|
|
2574
|
+
throw error;
|
|
2575
|
+
}
|
|
2576
|
+
}
|
|
2577
|
+
/**
|
|
2578
|
+
* Updates capability integration resource mapping config by id.
|
|
2579
|
+
* Replaces inter-service gRPC call to project-onboarding-ms for update capability integration configuration.
|
|
2580
|
+
*
|
|
2581
|
+
* @param input - id (mapping row id), config (new config JSON)
|
|
2582
|
+
* @param context - GraphQL context for loggedInUserId
|
|
2583
|
+
* @returns Promise resolving to { status: true } if row was updated, { status: false } otherwise
|
|
2584
|
+
*/
|
|
2585
|
+
async updateCapabilityIntegrationConfiguration(input, context) {
|
|
2586
|
+
try {
|
|
2587
|
+
this.logger.info(context.loggedInUserId, this.updateCapabilityIntegrationConfiguration.name, this.fileName, "Updating capability integration resource mapping config", {
|
|
2588
|
+
id: input.id.toString()
|
|
2589
|
+
});
|
|
2590
|
+
const updateResult = await this.conn.update(dvssBackendModuleDatastore.schema.capIntegResourceMapping).set({
|
|
2591
|
+
config: input.config,
|
|
2592
|
+
updatedBy: context.loggedInUserId
|
|
2593
|
+
}).where(drizzleOrm.and(drizzleOrm.eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.id, input.id), drizzleOrm.isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt)));
|
|
2594
|
+
const isSuccess = updateResult[0].affectedRows > 0;
|
|
2595
|
+
this.logger.info(context.loggedInUserId, this.updateCapabilityIntegrationConfiguration.name, this.fileName, `Mapping config update ${isSuccess ? "successful" : "failed - no matching records"}`, {
|
|
2596
|
+
affectedRows: updateResult[0].affectedRows
|
|
2597
|
+
});
|
|
2598
|
+
return {
|
|
2599
|
+
status: isSuccess
|
|
2600
|
+
};
|
|
2601
|
+
} catch (error) {
|
|
2602
|
+
this.logger.error(context.loggedInUserId, this.updateCapabilityIntegrationConfiguration.name, this.fileName, "Error updating capability integration resource mapping config", error, input);
|
|
2603
|
+
throw error;
|
|
2604
|
+
}
|
|
2605
|
+
}
|
|
2606
|
+
};
|
|
2607
|
+
exports.IntegrationResourceManagementDao = _ts_decorate14([
|
|
2608
|
+
common.Injectable(),
|
|
2609
|
+
_ts_param8(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
|
|
2610
|
+
_ts_metadata11("design:type", Function),
|
|
2611
|
+
_ts_metadata11("design:paramtypes", [
|
|
2612
|
+
typeof MySql2Database === "undefined" ? Object : MySql2Database,
|
|
2613
|
+
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
|
|
2614
|
+
])
|
|
2615
|
+
], exports.IntegrationResourceManagementDao);
|
|
2616
|
+
function _ts_decorate15(decorators, target, key, desc2) {
|
|
2617
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
2618
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2619
|
+
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;
|
|
2620
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2621
|
+
}
|
|
2622
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
2623
|
+
function _ts_metadata12(k, v) {
|
|
2624
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2625
|
+
}
|
|
2626
|
+
__name(_ts_metadata12, "_ts_metadata");
|
|
2627
|
+
function _ts_param9(paramIndex, decorator) {
|
|
2628
|
+
return function(target, key) {
|
|
2629
|
+
decorator(target, key, paramIndex);
|
|
2630
|
+
};
|
|
2631
|
+
}
|
|
2632
|
+
__name(_ts_param9, "_ts_param");
|
|
2633
|
+
exports.IntegrationUserManagementDao = class IntegrationUserManagementDao {
|
|
2634
|
+
static {
|
|
2635
|
+
__name(this, "IntegrationUserManagementDao");
|
|
2636
|
+
}
|
|
2637
|
+
conn;
|
|
2638
|
+
constructor(conn) {
|
|
2639
|
+
this.conn = conn;
|
|
2640
|
+
}
|
|
2641
|
+
};
|
|
2642
|
+
exports.IntegrationUserManagementDao = _ts_decorate15([
|
|
2643
|
+
common.Injectable(),
|
|
2644
|
+
_ts_param9(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
|
|
2645
|
+
_ts_metadata12("design:type", Function),
|
|
2646
|
+
_ts_metadata12("design:paramtypes", [
|
|
2647
|
+
typeof MySql2Database === "undefined" ? Object : MySql2Database
|
|
2648
|
+
])
|
|
2649
|
+
], exports.IntegrationUserManagementDao);
|
|
2650
|
+
function _ts_decorate16(decorators, target, key, desc2) {
|
|
2651
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
2652
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2653
|
+
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;
|
|
2654
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2655
|
+
}
|
|
2656
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
2657
|
+
function _ts_metadata13(k, v) {
|
|
2658
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2659
|
+
}
|
|
2660
|
+
__name(_ts_metadata13, "_ts_metadata");
|
|
2661
|
+
function _ts_param10(paramIndex, decorator) {
|
|
2662
|
+
return function(target, key) {
|
|
2663
|
+
decorator(target, key, paramIndex);
|
|
2664
|
+
};
|
|
2665
|
+
}
|
|
2666
|
+
__name(_ts_param10, "_ts_param");
|
|
2667
|
+
exports.IntegrationOnpremDeploymentDao = class IntegrationOnpremDeploymentDao {
|
|
2668
|
+
static {
|
|
2669
|
+
__name(this, "IntegrationOnpremDeploymentDao");
|
|
2670
|
+
}
|
|
2671
|
+
conn;
|
|
2672
|
+
logger;
|
|
2673
|
+
fileName = "integration-onprem-deployment.dao";
|
|
2674
|
+
constructor(conn, logger) {
|
|
2675
|
+
this.conn = conn;
|
|
2676
|
+
this.logger = logger;
|
|
2677
|
+
}
|
|
2678
|
+
async addUpdateOnpremDeployment(input, loggedInUserId = dvssBackendModuleUtility.SYSTEM_USER_ID) {
|
|
2679
|
+
try {
|
|
2680
|
+
this.logger.info(loggedInUserId, this.addUpdateOnpremDeployment.name, this.fileName, `IntegrationOnpremDeploymentDao -> addUpdateOnpremDeployment called`, {
|
|
2681
|
+
input
|
|
2682
|
+
});
|
|
2683
|
+
const existingEntry = await this.conn.query.onPremDeployment.findFirst({
|
|
2684
|
+
where: drizzleOrm.and(drizzleOrm.eq(dvssBackendModuleDatastore.schema.onPremDeployment.projectId, input.projectId), drizzleOrm.eq(dvssBackendModuleDatastore.schema.onPremDeployment.capabilityIntegrationId, input.capabilityIntegrationId))
|
|
3731
2685
|
});
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
2686
|
+
if (existingEntry) {
|
|
2687
|
+
await this.updateOnpremDeployment(existingEntry.id, input, loggedInUserId);
|
|
2688
|
+
return {
|
|
2689
|
+
status: true,
|
|
2690
|
+
id: existingEntry.id
|
|
2691
|
+
};
|
|
2692
|
+
}
|
|
2693
|
+
return this.addOnpremDeployment(input, loggedInUserId);
|
|
3736
2694
|
} catch (error) {
|
|
3737
|
-
this.logger.error(
|
|
2695
|
+
this.logger.error(loggedInUserId, this.addUpdateOnpremDeployment.name, this.fileName, "Error in addCapabilityIntegration", error, {
|
|
2696
|
+
input
|
|
2697
|
+
});
|
|
3738
2698
|
throw error;
|
|
3739
2699
|
}
|
|
3740
2700
|
}
|
|
3741
|
-
|
|
3742
|
-
* Checks if a capability integration resource mapping exists.
|
|
3743
|
-
* Validates that the mapping exists for the given capability integration, configured for ID and type.
|
|
3744
|
-
*
|
|
3745
|
-
* @param input - Input containing capability integration ID, configured for ID and type
|
|
3746
|
-
* @param loggedInUserId - ID of the user performing the operation
|
|
3747
|
-
* @returns Promise that resolves to true if mapping exists, false otherwise
|
|
3748
|
-
*/
|
|
3749
|
-
async checkMappingExists(input, loggedInUserId) {
|
|
2701
|
+
async addOnpremDeployment(input, loggedInUserId = dvssBackendModuleUtility.SYSTEM_USER_ID) {
|
|
3750
2702
|
try {
|
|
3751
|
-
this.
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
2703
|
+
const [insertedResult] = await this.conn.insert(dvssBackendModuleDatastore.schema.onPremDeployment).values(input).$returningId();
|
|
2704
|
+
return {
|
|
2705
|
+
status: true,
|
|
2706
|
+
id: BigInt(insertedResult.id)
|
|
2707
|
+
};
|
|
3756
2708
|
} catch (error) {
|
|
3757
|
-
this.logger.error(loggedInUserId, this.
|
|
2709
|
+
this.logger.error(loggedInUserId, this.addOnpremDeployment.name, this.fileName, "Error in addOnpremDeployment", error, {
|
|
2710
|
+
input
|
|
2711
|
+
});
|
|
3758
2712
|
throw error;
|
|
3759
2713
|
}
|
|
3760
2714
|
}
|
|
3761
|
-
|
|
3762
|
-
* Removes capability integration resource mapping (soft delete).
|
|
3763
|
-
* Sets deletedAt and deletedBy on the matching cap_integ_resource_mapping row.
|
|
3764
|
-
* Use this from UIF/callers instead of inter-service call to project-onboarding-ms.
|
|
3765
|
-
*
|
|
3766
|
-
* @param input - Delete parameters including capability integration ID, configured for ID and type
|
|
3767
|
-
* @param loggedInUserId - ID of the user performing the operation
|
|
3768
|
-
* @returns Promise resolving to { status: true } if any row was updated, { status: false } otherwise
|
|
3769
|
-
*/
|
|
3770
|
-
async removeCapabilityIntegrationMapping(input, context) {
|
|
2715
|
+
async updateOnpremDeployment(id, updateData, loggedInUserId = dvssBackendModuleUtility.SYSTEM_USER_ID) {
|
|
3771
2716
|
try {
|
|
3772
|
-
this.
|
|
3773
|
-
const whereConditions = [
|
|
3774
|
-
isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt),
|
|
3775
|
-
eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.capabilityIntegrationId, input.capabilityIntegrationId),
|
|
3776
|
-
eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId, input.configuredForId),
|
|
3777
|
-
eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType, input.configuredForType)
|
|
3778
|
-
];
|
|
3779
|
-
const deleteResult = await this.conn.update(dvssBackendModuleDatastore.schema.capIntegResourceMapping).set({
|
|
3780
|
-
deletedAt: /* @__PURE__ */ new Date(),
|
|
3781
|
-
deletedBy: context.loggedInUserId
|
|
3782
|
-
}).where(and(...whereConditions));
|
|
3783
|
-
const isSuccess = deleteResult[0].affectedRows > 0;
|
|
3784
|
-
this.logger.info(context.loggedInUserId, this.removeCapabilityIntegrationMapping.name, this.fileName, `Mapping removal ${isSuccess ? "successful" : "failed - no matching records"}`, {
|
|
3785
|
-
affectedRows: deleteResult[0].affectedRows
|
|
3786
|
-
});
|
|
2717
|
+
const result = await this.conn.update(dvssBackendModuleDatastore.schema.onPremDeployment).set(updateData).where(drizzleOrm.eq(dvssBackendModuleDatastore.schema.onPremDeployment.id, id)).execute();
|
|
3787
2718
|
return {
|
|
3788
|
-
status:
|
|
2719
|
+
status: result[0].affectedRows > 0,
|
|
2720
|
+
id
|
|
3789
2721
|
};
|
|
3790
2722
|
} catch (error) {
|
|
3791
|
-
this.logger.error(
|
|
2723
|
+
this.logger.error(loggedInUserId, this.updateOnpremDeployment.name, this.fileName, "Error in updateOnpremDeployment", error, {
|
|
2724
|
+
id,
|
|
2725
|
+
updateData
|
|
2726
|
+
});
|
|
3792
2727
|
throw error;
|
|
3793
2728
|
}
|
|
3794
2729
|
}
|
|
3795
2730
|
/**
|
|
3796
|
-
* Gets
|
|
3797
|
-
*
|
|
3798
|
-
*
|
|
3799
|
-
* @param id - cap_integ_resource_mapping.id
|
|
3800
|
-
* @param loggedInUserId - for logging
|
|
3801
|
-
* @returns The mapping row or undefined if not found
|
|
2731
|
+
* Gets an on-prem deployment by capability integration id.
|
|
2732
|
+
* Used by Suprema integration to resolve deployment for a given integration.
|
|
3802
2733
|
*/
|
|
3803
|
-
async
|
|
2734
|
+
async getOnpremDeployment(input, loggedInUserId = dvssBackendModuleUtility.SYSTEM_USER_ID) {
|
|
3804
2735
|
try {
|
|
3805
|
-
this.logger.info(loggedInUserId, this.
|
|
3806
|
-
|
|
2736
|
+
this.logger.info(loggedInUserId, this.getOnpremDeployment.name, this.fileName, "IntegrationOnpremDeploymentDao -> getOnpremDeployment called", {
|
|
2737
|
+
input
|
|
2738
|
+
});
|
|
2739
|
+
return await this.conn.query.onPremDeployment.findFirst({
|
|
2740
|
+
where: drizzleOrm.and(drizzleOrm.eq(dvssBackendModuleDatastore.schema.onPremDeployment.projectId, input.projectId), drizzleOrm.eq(dvssBackendModuleDatastore.schema.onPremDeployment.capabilityIntegrationId, input.integrationId), drizzleOrm.isNull(dvssBackendModuleDatastore.schema.onPremDeployment.deletedAt))
|
|
3807
2741
|
});
|
|
3808
|
-
const rows = await this.conn.select({
|
|
3809
|
-
id: dvssBackendModuleDatastore.schema.capIntegResourceMapping.id,
|
|
3810
|
-
capabilityIntegrationId: dvssBackendModuleDatastore.schema.capIntegResourceMapping.capabilityIntegrationId,
|
|
3811
|
-
configuredForId: dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForId,
|
|
3812
|
-
configuredForType: dvssBackendModuleDatastore.schema.capIntegResourceMapping.configuredForType
|
|
3813
|
-
}).from(dvssBackendModuleDatastore.schema.capIntegResourceMapping).where(and(eq(dvssBackendModuleDatastore.schema.capIntegResourceMapping.id, id), isNull(dvssBackendModuleDatastore.schema.capIntegResourceMapping.deletedAt))).limit(1);
|
|
3814
|
-
return rows[0];
|
|
3815
2742
|
} catch (error) {
|
|
3816
|
-
this.logger.error(loggedInUserId, this.
|
|
3817
|
-
|
|
2743
|
+
this.logger.error(loggedInUserId, this.getOnpremDeployment.name, this.fileName, "Error in getOnpremDeployment", error, {
|
|
2744
|
+
input
|
|
3818
2745
|
});
|
|
3819
2746
|
throw error;
|
|
3820
2747
|
}
|
|
3821
2748
|
}
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
2749
|
+
};
|
|
2750
|
+
exports.IntegrationOnpremDeploymentDao = _ts_decorate16([
|
|
2751
|
+
common.Injectable(),
|
|
2752
|
+
_ts_param10(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
|
|
2753
|
+
_ts_metadata13("design:type", Function),
|
|
2754
|
+
_ts_metadata13("design:paramtypes", [
|
|
2755
|
+
typeof MySql2Database === "undefined" ? Object : MySql2Database,
|
|
2756
|
+
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
|
|
2757
|
+
])
|
|
2758
|
+
], exports.IntegrationOnpremDeploymentDao);
|
|
2759
|
+
function substituteUrlPlaceholders(url, params = {}) {
|
|
2760
|
+
return url.replace(/\{(\w+)\}/g, (matched, name) => params[name] ?? matched);
|
|
2761
|
+
}
|
|
2762
|
+
__name(substituteUrlPlaceholders, "substituteUrlPlaceholders");
|
|
2763
|
+
function hasPersistedIntegrationId(id) {
|
|
2764
|
+
return id != null && id !== BigInt(0);
|
|
2765
|
+
}
|
|
2766
|
+
__name(hasPersistedIntegrationId, "hasPersistedIntegrationId");
|
|
2767
|
+
function secondsUntil(expiresAt, nowMs = Date.now()) {
|
|
2768
|
+
return Math.max(0, Math.floor((expiresAt.getTime() - nowMs) / 1e3));
|
|
2769
|
+
}
|
|
2770
|
+
__name(secondsUntil, "secondsUntil");
|
|
2771
|
+
var OAUTH_TOKEN_FRESHNESS_BUFFER_MS = 6e4;
|
|
2772
|
+
function isTokenFresh(expiresAt, nowMs = Date.now()) {
|
|
2773
|
+
return expiresAt.getTime() - OAUTH_TOKEN_FRESHNESS_BUFFER_MS > nowMs;
|
|
2774
|
+
}
|
|
2775
|
+
__name(isTokenFresh, "isTokenFresh");
|
|
2776
|
+
function getIntegrationConfigKmsKeyId() {
|
|
2777
|
+
return process.env.INTEGRATION_CONFIG_KMS_KEY_ID || "";
|
|
2778
|
+
}
|
|
2779
|
+
__name(getIntegrationConfigKmsKeyId, "getIntegrationConfigKmsKeyId");
|
|
2780
|
+
function delay(ms) {
|
|
2781
|
+
return new Promise((resolve3) => {
|
|
2782
|
+
setTimeout(resolve3, ms);
|
|
2783
|
+
});
|
|
2784
|
+
}
|
|
2785
|
+
__name(delay, "delay");
|
|
2786
|
+
function getOauthTokenCacheKey(capabilityIntegrationId) {
|
|
2787
|
+
return `${dvssBackendModuleDatastore.ENV_PREFIX}${dvssBackendModuleDatastore.OAUTH_TOKEN_CACHE_PREFIX}${capabilityIntegrationId.toString()}`;
|
|
2788
|
+
}
|
|
2789
|
+
__name(getOauthTokenCacheKey, "getOauthTokenCacheKey");
|
|
2790
|
+
function getOauthTokenLockKey(capabilityIntegrationId) {
|
|
2791
|
+
return `${dvssBackendModuleDatastore.ENV_PREFIX}${dvssBackendModuleDatastore.OAUTH_TOKEN_LOCK_PREFIX}${capabilityIntegrationId.toString()}`;
|
|
2792
|
+
}
|
|
2793
|
+
__name(getOauthTokenLockKey, "getOauthTokenLockKey");
|
|
2794
|
+
|
|
2795
|
+
// ../../packages/dvss-integration-oauth/src/cache/oauth-token-cache.ts
|
|
2796
|
+
function _ts_decorate17(decorators, target, key, desc2) {
|
|
2797
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
2798
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2799
|
+
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;
|
|
2800
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2801
|
+
}
|
|
2802
|
+
__name(_ts_decorate17, "_ts_decorate");
|
|
2803
|
+
function _ts_metadata14(k, v) {
|
|
2804
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2805
|
+
}
|
|
2806
|
+
__name(_ts_metadata14, "_ts_metadata");
|
|
2807
|
+
var OauthTokenCache = class {
|
|
2808
|
+
static {
|
|
2809
|
+
__name(this, "OauthTokenCache");
|
|
2810
|
+
}
|
|
2811
|
+
redisCacheStoreService;
|
|
2812
|
+
constructor(redisCacheStoreService) {
|
|
2813
|
+
this.redisCacheStoreService = redisCacheStoreService;
|
|
2814
|
+
}
|
|
2815
|
+
async get(capabilityIntegrationId) {
|
|
2816
|
+
const cached = await this.redisCacheStoreService.get(getOauthTokenCacheKey(capabilityIntegrationId));
|
|
2817
|
+
if (!cached?.accessToken || !cached.expiresAt) {
|
|
2818
|
+
return void 0;
|
|
2819
|
+
}
|
|
2820
|
+
return {
|
|
2821
|
+
accessToken: cached.accessToken,
|
|
2822
|
+
tokenType: cached.tokenType,
|
|
2823
|
+
expiresAt: new Date(cached.expiresAt),
|
|
2824
|
+
refreshToken: cached.refreshToken
|
|
2825
|
+
};
|
|
2826
|
+
}
|
|
2827
|
+
async set(capabilityIntegrationId, token) {
|
|
2828
|
+
const ttlSeconds = secondsUntil(token.expiresAt);
|
|
2829
|
+
if (ttlSeconds <= 0) {
|
|
2830
|
+
return;
|
|
2831
|
+
}
|
|
2832
|
+
await this.redisCacheStoreService.set(getOauthTokenCacheKey(capabilityIntegrationId), {
|
|
2833
|
+
accessToken: token.accessToken,
|
|
2834
|
+
tokenType: token.tokenType,
|
|
2835
|
+
expiresAt: token.expiresAt.toISOString(),
|
|
2836
|
+
refreshToken: token.refreshToken
|
|
2837
|
+
}, ttlSeconds);
|
|
2838
|
+
}
|
|
2839
|
+
async del(capabilityIntegrationId) {
|
|
2840
|
+
await this.redisCacheStoreService.del(getOauthTokenCacheKey(capabilityIntegrationId));
|
|
2841
|
+
}
|
|
2842
|
+
};
|
|
2843
|
+
OauthTokenCache = _ts_decorate17([
|
|
2844
|
+
common.Injectable(),
|
|
2845
|
+
_ts_metadata14("design:type", Function),
|
|
2846
|
+
_ts_metadata14("design:paramtypes", [
|
|
2847
|
+
typeof dvssBackendModuleDatastore.RedisCacheStoreService === "undefined" ? Object : dvssBackendModuleDatastore.RedisCacheStoreService
|
|
2848
|
+
])
|
|
2849
|
+
], OauthTokenCache);
|
|
2850
|
+
function _ts_decorate18(decorators, target, key, desc2) {
|
|
2851
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
2852
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2853
|
+
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;
|
|
2854
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2855
|
+
}
|
|
2856
|
+
__name(_ts_decorate18, "_ts_decorate");
|
|
2857
|
+
var AuthorizationCodeGrantHandler = class {
|
|
2858
|
+
static {
|
|
2859
|
+
__name(this, "AuthorizationCodeGrantHandler");
|
|
2860
|
+
}
|
|
2861
|
+
mint(request) {
|
|
2862
|
+
throw new Error(`NotImplemented: authorization_code grant is not supported (${request.tokenUrl})`);
|
|
2863
|
+
}
|
|
2864
|
+
};
|
|
2865
|
+
AuthorizationCodeGrantHandler = _ts_decorate18([
|
|
2866
|
+
common.Injectable()
|
|
2867
|
+
], AuthorizationCodeGrantHandler);
|
|
2868
|
+
|
|
2869
|
+
// ../../packages/dvss-integration-oauth/src/models/oauth.model.ts
|
|
2870
|
+
var OAUTH_GRANT_TYPE = {
|
|
2871
|
+
CLIENT_CREDENTIALS: "CLIENT_CREDENTIALS"
|
|
2872
|
+
};
|
|
2873
|
+
var OAUTH_RFC_GRANT_TYPE = {
|
|
2874
|
+
CLIENT_CREDENTIALS: "client_credentials"
|
|
2875
|
+
};
|
|
2876
|
+
var OAUTH_DEFAULT_TOKEN_TYPE = "Bearer";
|
|
2877
|
+
var OAUTH_TOKEN_HEADERS = {
|
|
2878
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2879
|
+
Accept: "application/json",
|
|
2880
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2881
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
2882
|
+
};
|
|
2883
|
+
|
|
2884
|
+
// ../../packages/dvss-integration-oauth/src/grants/client-credentials.handler.ts
|
|
2885
|
+
function _ts_decorate19(decorators, target, key, desc2) {
|
|
2886
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
2887
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2888
|
+
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;
|
|
2889
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2890
|
+
}
|
|
2891
|
+
__name(_ts_decorate19, "_ts_decorate");
|
|
2892
|
+
function _ts_metadata15(k, v) {
|
|
2893
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2894
|
+
}
|
|
2895
|
+
__name(_ts_metadata15, "_ts_metadata");
|
|
2896
|
+
var ClientCredentialsGrantHandler = class {
|
|
2897
|
+
static {
|
|
2898
|
+
__name(this, "ClientCredentialsGrantHandler");
|
|
2899
|
+
}
|
|
2900
|
+
logger;
|
|
2901
|
+
trafficGatewayService;
|
|
2902
|
+
fileName = "client-credentials.handler";
|
|
2903
|
+
constructor(logger, trafficGatewayService) {
|
|
2904
|
+
this.logger = logger;
|
|
2905
|
+
this.trafficGatewayService = trafficGatewayService;
|
|
2906
|
+
}
|
|
2907
|
+
async mint(request) {
|
|
2908
|
+
const tokenUrl = new URL(request.tokenUrl);
|
|
2909
|
+
const body = new URLSearchParams({
|
|
2910
|
+
client_id: request.credentials.clientId,
|
|
2911
|
+
client_secret: request.credentials.clientSecret,
|
|
2912
|
+
grant_type: OAUTH_RFC_GRANT_TYPE.CLIENT_CREDENTIALS
|
|
2913
|
+
});
|
|
2914
|
+
if (request.scope) {
|
|
2915
|
+
body.set("scope", request.scope);
|
|
2916
|
+
}
|
|
2917
|
+
const loggedInUserId = request.loggedInUserId;
|
|
2918
|
+
const integrationContext = {
|
|
2919
|
+
id: request.integration.id,
|
|
2920
|
+
capabilityId: request.integration.capabilityId,
|
|
2921
|
+
providerId: request.integration.providerId,
|
|
2922
|
+
projectId: request.integration.projectId,
|
|
2923
|
+
headers: OAUTH_TOKEN_HEADERS,
|
|
2924
|
+
config: {
|
|
2925
|
+
platformConfig: {
|
|
2926
|
+
authUrl: request.tokenUrl,
|
|
2927
|
+
baseUrl: tokenUrl.origin
|
|
2928
|
+
},
|
|
2929
|
+
integrationConfig: {}
|
|
2930
|
+
}
|
|
2931
|
+
};
|
|
2932
|
+
this.logger.info(loggedInUserId, this.mint.name, this.fileName, "Minting OAuth access token with client_credentials");
|
|
2933
|
+
const response = await this.trafficGatewayService.executeIntegrationRequest({
|
|
2934
|
+
apiMethod: HTTP_METHOD.POST,
|
|
2935
|
+
baseUrl: tokenUrl.origin,
|
|
2936
|
+
url: `${tokenUrl.pathname}${tokenUrl.search}`,
|
|
2937
|
+
body: body.toString(),
|
|
2938
|
+
headers: OAUTH_TOKEN_HEADERS
|
|
2939
|
+
}, integrationContext, loggedInUserId);
|
|
2940
|
+
if (!response.access_token) {
|
|
2941
|
+
throw new Error("OAuth token response is missing access_token");
|
|
2942
|
+
}
|
|
2943
|
+
const expiresInSeconds = response.expires_in ?? 0;
|
|
2944
|
+
return {
|
|
2945
|
+
accessToken: response.access_token,
|
|
2946
|
+
tokenType: response.token_type ?? OAUTH_DEFAULT_TOKEN_TYPE,
|
|
2947
|
+
expiresAt: new Date(Date.now() + expiresInSeconds * 1e3),
|
|
2948
|
+
refreshToken: response.refresh_token
|
|
2949
|
+
};
|
|
2950
|
+
}
|
|
2951
|
+
};
|
|
2952
|
+
ClientCredentialsGrantHandler = _ts_decorate19([
|
|
2953
|
+
common.Injectable(),
|
|
2954
|
+
_ts_metadata15("design:type", Function),
|
|
2955
|
+
_ts_metadata15("design:paramtypes", [
|
|
2956
|
+
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
|
|
2957
|
+
typeof exports.TrafficGatewayService === "undefined" ? Object : exports.TrafficGatewayService
|
|
2958
|
+
])
|
|
2959
|
+
], ClientCredentialsGrantHandler);
|
|
2960
|
+
function _ts_decorate20(decorators, target, key, desc2) {
|
|
2961
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
2962
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2963
|
+
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;
|
|
2964
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2965
|
+
}
|
|
2966
|
+
__name(_ts_decorate20, "_ts_decorate");
|
|
2967
|
+
function _ts_metadata16(k, v) {
|
|
2968
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2969
|
+
}
|
|
2970
|
+
__name(_ts_metadata16, "_ts_metadata");
|
|
2971
|
+
var GrantHandlerRegistry = class {
|
|
2972
|
+
static {
|
|
2973
|
+
__name(this, "GrantHandlerRegistry");
|
|
2974
|
+
}
|
|
2975
|
+
clientCredentialsGrantHandler;
|
|
2976
|
+
authorizationCodeGrantHandler;
|
|
2977
|
+
constructor(clientCredentialsGrantHandler, authorizationCodeGrantHandler) {
|
|
2978
|
+
this.clientCredentialsGrantHandler = clientCredentialsGrantHandler;
|
|
2979
|
+
this.authorizationCodeGrantHandler = authorizationCodeGrantHandler;
|
|
2980
|
+
}
|
|
2981
|
+
get(grantType) {
|
|
2982
|
+
if (grantType === OAUTH_GRANT_TYPE.CLIENT_CREDENTIALS) {
|
|
2983
|
+
return this.clientCredentialsGrantHandler;
|
|
2984
|
+
}
|
|
2985
|
+
return this.authorizationCodeGrantHandler;
|
|
2986
|
+
}
|
|
2987
|
+
resolvePreferredGrant(supportedGrantTypes) {
|
|
2988
|
+
if (supportedGrantTypes?.includes(OAUTH_GRANT_TYPE.CLIENT_CREDENTIALS)) {
|
|
2989
|
+
return OAUTH_GRANT_TYPE.CLIENT_CREDENTIALS;
|
|
2990
|
+
}
|
|
2991
|
+
if (supportedGrantTypes?.length) {
|
|
2992
|
+
return supportedGrantTypes[0];
|
|
3849
2993
|
}
|
|
2994
|
+
return OAUTH_GRANT_TYPE.CLIENT_CREDENTIALS;
|
|
3850
2995
|
}
|
|
3851
2996
|
};
|
|
3852
|
-
|
|
2997
|
+
GrantHandlerRegistry = _ts_decorate20([
|
|
3853
2998
|
common.Injectable(),
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
typeof
|
|
3858
|
-
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
|
|
2999
|
+
_ts_metadata16("design:type", Function),
|
|
3000
|
+
_ts_metadata16("design:paramtypes", [
|
|
3001
|
+
typeof ClientCredentialsGrantHandler === "undefined" ? Object : ClientCredentialsGrantHandler,
|
|
3002
|
+
typeof AuthorizationCodeGrantHandler === "undefined" ? Object : AuthorizationCodeGrantHandler
|
|
3859
3003
|
])
|
|
3860
|
-
],
|
|
3861
|
-
function
|
|
3004
|
+
], GrantHandlerRegistry);
|
|
3005
|
+
function _ts_decorate21(decorators, target, key, desc2) {
|
|
3862
3006
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3863
3007
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3864
3008
|
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;
|
|
3865
3009
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3866
3010
|
}
|
|
3867
|
-
__name(
|
|
3868
|
-
function
|
|
3011
|
+
__name(_ts_decorate21, "_ts_decorate");
|
|
3012
|
+
function _ts_metadata17(k, v) {
|
|
3869
3013
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
3870
3014
|
}
|
|
3871
|
-
__name(
|
|
3872
|
-
function
|
|
3015
|
+
__name(_ts_metadata17, "_ts_metadata");
|
|
3016
|
+
function _ts_param11(paramIndex, decorator) {
|
|
3873
3017
|
return function(target, key) {
|
|
3874
3018
|
decorator(target, key, paramIndex);
|
|
3875
3019
|
};
|
|
3876
3020
|
}
|
|
3877
|
-
__name(
|
|
3878
|
-
|
|
3021
|
+
__name(_ts_param11, "_ts_param");
|
|
3022
|
+
var OauthProviderDao = class {
|
|
3879
3023
|
static {
|
|
3880
|
-
__name(this, "
|
|
3024
|
+
__name(this, "OauthProviderDao");
|
|
3881
3025
|
}
|
|
3882
3026
|
conn;
|
|
3883
|
-
|
|
3027
|
+
logger;
|
|
3028
|
+
fileName = "oauth-provider.dao";
|
|
3029
|
+
constructor(conn, logger) {
|
|
3884
3030
|
this.conn = conn;
|
|
3031
|
+
this.logger = logger;
|
|
3032
|
+
}
|
|
3033
|
+
async findByCapabilityAndProvider(capabilityId, providerId, loggedInUserId) {
|
|
3034
|
+
this.logger.info(loggedInUserId, this.findByCapabilityAndProvider.name, this.fileName, "Loading OAuth provider catalog row", {
|
|
3035
|
+
capabilityId,
|
|
3036
|
+
providerId
|
|
3037
|
+
});
|
|
3038
|
+
try {
|
|
3039
|
+
const rows = await this.conn.select().from(dvssBackendModuleDatastore.schema.integrationOauthProvider).where(drizzleOrm.and(drizzleOrm.eq(dvssBackendModuleDatastore.schema.integrationOauthProvider.capabilityId, capabilityId), drizzleOrm.eq(dvssBackendModuleDatastore.schema.integrationOauthProvider.providerId, providerId), drizzleOrm.isNull(dvssBackendModuleDatastore.schema.integrationOauthProvider.deletedAt)));
|
|
3040
|
+
return rows[0];
|
|
3041
|
+
} catch (error) {
|
|
3042
|
+
throw dvssBackendModuleDatastore.errorHandler(loggedInUserId, this.findByCapabilityAndProvider.name, this.fileName, dvssBackendModuleDatastore.DATABASE_ERROR_NAMES.DATABASE_ERROR, dvssBackendModuleDatastore.MODULE_NAME.COMMON, error, {
|
|
3043
|
+
capabilityId,
|
|
3044
|
+
providerId
|
|
3045
|
+
});
|
|
3046
|
+
}
|
|
3885
3047
|
}
|
|
3886
3048
|
};
|
|
3887
|
-
|
|
3049
|
+
OauthProviderDao = _ts_decorate21([
|
|
3888
3050
|
common.Injectable(),
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
typeof MySql2Database === "undefined" ? Object : MySql2Database
|
|
3051
|
+
_ts_param11(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
|
|
3052
|
+
_ts_metadata17("design:type", Function),
|
|
3053
|
+
_ts_metadata17("design:paramtypes", [
|
|
3054
|
+
typeof MySql2Database === "undefined" ? Object : MySql2Database,
|
|
3055
|
+
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
|
|
3893
3056
|
])
|
|
3894
|
-
],
|
|
3895
|
-
function
|
|
3057
|
+
], OauthProviderDao);
|
|
3058
|
+
function _ts_decorate22(decorators, target, key, desc2) {
|
|
3896
3059
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3897
3060
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3898
3061
|
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;
|
|
3899
3062
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3900
3063
|
}
|
|
3901
|
-
__name(
|
|
3902
|
-
function
|
|
3064
|
+
__name(_ts_decorate22, "_ts_decorate");
|
|
3065
|
+
function _ts_metadata18(k, v) {
|
|
3903
3066
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
3904
3067
|
}
|
|
3905
|
-
__name(
|
|
3906
|
-
function
|
|
3068
|
+
__name(_ts_metadata18, "_ts_metadata");
|
|
3069
|
+
function _ts_param12(paramIndex, decorator) {
|
|
3907
3070
|
return function(target, key) {
|
|
3908
3071
|
decorator(target, key, paramIndex);
|
|
3909
3072
|
};
|
|
3910
3073
|
}
|
|
3911
|
-
__name(
|
|
3912
|
-
|
|
3074
|
+
__name(_ts_param12, "_ts_param");
|
|
3075
|
+
var OauthTokenDao = class {
|
|
3913
3076
|
static {
|
|
3914
|
-
__name(this, "
|
|
3077
|
+
__name(this, "OauthTokenDao");
|
|
3915
3078
|
}
|
|
3916
3079
|
conn;
|
|
3917
3080
|
logger;
|
|
3918
|
-
fileName = "
|
|
3081
|
+
fileName = "oauth-token.dao";
|
|
3919
3082
|
constructor(conn, logger) {
|
|
3920
3083
|
this.conn = conn;
|
|
3921
3084
|
this.logger = logger;
|
|
3922
3085
|
}
|
|
3923
|
-
async
|
|
3086
|
+
async findByCapabilityIntegrationId(capabilityIntegrationId, loggedInUserId) {
|
|
3087
|
+
this.logger.info(loggedInUserId, this.findByCapabilityIntegrationId.name, this.fileName, "Loading OAuth token row", {
|
|
3088
|
+
capabilityIntegrationId
|
|
3089
|
+
});
|
|
3924
3090
|
try {
|
|
3925
|
-
this.
|
|
3926
|
-
|
|
3927
|
-
});
|
|
3928
|
-
const existingEntry = await this.conn.query.onPremDeployment.findFirst({
|
|
3929
|
-
where: and(eq(dvssBackendModuleDatastore.schema.onPremDeployment.projectId, input.projectId), eq(dvssBackendModuleDatastore.schema.onPremDeployment.capabilityIntegrationId, input.capabilityIntegrationId))
|
|
3930
|
-
});
|
|
3931
|
-
if (existingEntry) {
|
|
3932
|
-
await this.updateOnpremDeployment(existingEntry.id, input, loggedInUserId);
|
|
3933
|
-
return {
|
|
3934
|
-
status: true,
|
|
3935
|
-
id: existingEntry.id
|
|
3936
|
-
};
|
|
3937
|
-
}
|
|
3938
|
-
return this.addOnpremDeployment(input, loggedInUserId);
|
|
3091
|
+
const rows = await this.conn.select().from(dvssBackendModuleDatastore.schema.integrationOauthToken).where(drizzleOrm.and(drizzleOrm.eq(dvssBackendModuleDatastore.schema.integrationOauthToken.capabilityIntegrationId, capabilityIntegrationId), drizzleOrm.isNull(dvssBackendModuleDatastore.schema.integrationOauthToken.deletedAt)));
|
|
3092
|
+
return rows[0];
|
|
3939
3093
|
} catch (error) {
|
|
3940
|
-
|
|
3941
|
-
|
|
3094
|
+
throw dvssBackendModuleDatastore.errorHandler(loggedInUserId, this.findByCapabilityIntegrationId.name, this.fileName, dvssBackendModuleDatastore.DATABASE_ERROR_NAMES.DATABASE_ERROR, dvssBackendModuleDatastore.MODULE_NAME.COMMON, error, {
|
|
3095
|
+
capabilityIntegrationId
|
|
3942
3096
|
});
|
|
3943
|
-
throw error;
|
|
3944
3097
|
}
|
|
3945
3098
|
}
|
|
3946
|
-
async
|
|
3099
|
+
async upsert(input) {
|
|
3100
|
+
this.logger.info(input.loggedInUserId, this.upsert.name, this.fileName, "Upserting OAuth token row", {
|
|
3101
|
+
capabilityIntegrationId: input.capabilityIntegrationId
|
|
3102
|
+
});
|
|
3103
|
+
const existing = await this.findByCapabilityIntegrationId(input.capabilityIntegrationId, input.loggedInUserId);
|
|
3104
|
+
const now = /* @__PURE__ */ new Date();
|
|
3947
3105
|
try {
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3106
|
+
if (existing) {
|
|
3107
|
+
await this.conn.update(dvssBackendModuleDatastore.schema.integrationOauthToken).set({
|
|
3108
|
+
accessToken: input.accessToken,
|
|
3109
|
+
refreshToken: input.refreshToken ?? null,
|
|
3110
|
+
expiresAt: input.expiresAt,
|
|
3111
|
+
refreshExpiredAt: input.refreshExpiredAt ?? null,
|
|
3112
|
+
tokenMetadata: input.tokenMetadata ?? null,
|
|
3113
|
+
updatedAt: now,
|
|
3114
|
+
updatedBy: input.loggedInUserId,
|
|
3115
|
+
deletedAt: null,
|
|
3116
|
+
deletedBy: null
|
|
3117
|
+
}).where(drizzleOrm.eq(dvssBackendModuleDatastore.schema.integrationOauthToken.id, existing.id));
|
|
3118
|
+
return;
|
|
3119
|
+
}
|
|
3120
|
+
await this.conn.insert(dvssBackendModuleDatastore.schema.integrationOauthToken).values({
|
|
3121
|
+
capabilityIntegrationId: input.capabilityIntegrationId,
|
|
3122
|
+
accessToken: input.accessToken,
|
|
3123
|
+
refreshToken: input.refreshToken ?? null,
|
|
3124
|
+
expiresAt: input.expiresAt,
|
|
3125
|
+
refreshExpiredAt: input.refreshExpiredAt ?? null,
|
|
3126
|
+
tokenMetadata: input.tokenMetadata ?? null,
|
|
3127
|
+
createdAt: now,
|
|
3128
|
+
createdBy: input.loggedInUserId
|
|
3129
|
+
});
|
|
3953
3130
|
} catch (error) {
|
|
3954
|
-
|
|
3955
|
-
input
|
|
3131
|
+
throw dvssBackendModuleDatastore.errorHandler(input.loggedInUserId, this.upsert.name, this.fileName, dvssBackendModuleDatastore.DATABASE_ERROR_NAMES.DATABASE_ERROR, dvssBackendModuleDatastore.MODULE_NAME.COMMON, error, {
|
|
3132
|
+
capabilityIntegrationId: input.capabilityIntegrationId
|
|
3956
3133
|
});
|
|
3957
|
-
throw error;
|
|
3958
3134
|
}
|
|
3959
3135
|
}
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3136
|
+
};
|
|
3137
|
+
OauthTokenDao = _ts_decorate22([
|
|
3138
|
+
common.Injectable(),
|
|
3139
|
+
_ts_param12(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
|
|
3140
|
+
_ts_metadata18("design:type", Function),
|
|
3141
|
+
_ts_metadata18("design:paramtypes", [
|
|
3142
|
+
typeof MySql2Database === "undefined" ? Object : MySql2Database,
|
|
3143
|
+
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
|
|
3144
|
+
])
|
|
3145
|
+
], OauthTokenDao);
|
|
3146
|
+
|
|
3147
|
+
// ../../packages/dvss-integration-oauth/src/token-manager/oauth-token-manager.ts
|
|
3148
|
+
function _ts_decorate23(decorators, target, key, desc2) {
|
|
3149
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3150
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3151
|
+
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;
|
|
3152
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3153
|
+
}
|
|
3154
|
+
__name(_ts_decorate23, "_ts_decorate");
|
|
3155
|
+
function _ts_metadata19(k, v) {
|
|
3156
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
3157
|
+
}
|
|
3158
|
+
__name(_ts_metadata19, "_ts_metadata");
|
|
3159
|
+
function _ts_param13(paramIndex, decorator) {
|
|
3160
|
+
return function(target, key) {
|
|
3161
|
+
decorator(target, key, paramIndex);
|
|
3162
|
+
};
|
|
3163
|
+
}
|
|
3164
|
+
__name(_ts_param13, "_ts_param");
|
|
3165
|
+
var oauthSecretProviderToken = dvssBackendModuleUtility.SECRET_PROVIDER ?? /* @__PURE__ */ Symbol("SECRET_PROVIDER");
|
|
3166
|
+
var OAUTH_LOCK_TTL_SECONDS = 30;
|
|
3167
|
+
var OAUTH_LOCK_WAIT_MS = 100;
|
|
3168
|
+
var OAUTH_LOCK_MAX_WAIT_MS = 1e4;
|
|
3169
|
+
var OauthTokenManager = class {
|
|
3170
|
+
static {
|
|
3171
|
+
__name(this, "OauthTokenManager");
|
|
3172
|
+
}
|
|
3173
|
+
logger;
|
|
3174
|
+
tokenDao;
|
|
3175
|
+
providerDao;
|
|
3176
|
+
tokenCache;
|
|
3177
|
+
redisCacheStoreService;
|
|
3178
|
+
grantHandlerRegistry;
|
|
3179
|
+
secretProvider;
|
|
3180
|
+
fileName = "oauth-token-manager";
|
|
3181
|
+
sessions = /* @__PURE__ */ new Map();
|
|
3182
|
+
constructor(logger, tokenDao, providerDao, tokenCache, redisCacheStoreService, grantHandlerRegistry, secretProvider) {
|
|
3183
|
+
this.logger = logger;
|
|
3184
|
+
this.tokenDao = tokenDao;
|
|
3185
|
+
this.providerDao = providerDao;
|
|
3186
|
+
this.tokenCache = tokenCache;
|
|
3187
|
+
this.redisCacheStoreService = redisCacheStoreService;
|
|
3188
|
+
this.grantHandlerRegistry = grantHandlerRegistry;
|
|
3189
|
+
this.secretProvider = secretProvider;
|
|
3190
|
+
}
|
|
3191
|
+
async getValidAccessToken(capabilityIntegrationId, opts = {}) {
|
|
3192
|
+
const loggedInUserId = opts.loggedInUserId ?? dvssBackendModuleUtility.SYSTEM_USER_ID;
|
|
3193
|
+
const shouldForceRefresh = opts.forceRefresh === true;
|
|
3194
|
+
if (!shouldForceRefresh && hasPersistedIntegrationId(capabilityIntegrationId)) {
|
|
3195
|
+
const cached = await this.readCachedToken(capabilityIntegrationId, loggedInUserId);
|
|
3196
|
+
if (cached) {
|
|
3197
|
+
return cached;
|
|
3198
|
+
}
|
|
3199
|
+
}
|
|
3200
|
+
if (!hasPersistedIntegrationId(capabilityIntegrationId)) {
|
|
3201
|
+
return this.mintToken(void 0, opts, loggedInUserId);
|
|
3202
|
+
}
|
|
3203
|
+
return this.mintWithDistributedLock(capabilityIntegrationId, opts, loggedInUserId, shouldForceRefresh);
|
|
3204
|
+
}
|
|
3205
|
+
async storeToken(capabilityIntegrationId, token, loggedInUserId = dvssBackendModuleUtility.SYSTEM_USER_ID) {
|
|
3206
|
+
await this.persistToken(capabilityIntegrationId, token, loggedInUserId);
|
|
3207
|
+
this.writeMemory(capabilityIntegrationId, token);
|
|
3208
|
+
await this.tokenCache.set(capabilityIntegrationId, token);
|
|
3209
|
+
}
|
|
3210
|
+
async invalidate(capabilityIntegrationId) {
|
|
3211
|
+
this.sessions.delete(capabilityIntegrationId.toString());
|
|
3212
|
+
await this.tokenCache.del(capabilityIntegrationId);
|
|
3213
|
+
}
|
|
3214
|
+
async mintWithDistributedLock(capabilityIntegrationId, opts, loggedInUserId, shouldForceRefresh) {
|
|
3215
|
+
const lockKey = getOauthTokenLockKey(capabilityIntegrationId);
|
|
3216
|
+
const deadline = Date.now() + OAUTH_LOCK_MAX_WAIT_MS;
|
|
3217
|
+
while (Date.now() < deadline) {
|
|
3218
|
+
if (!shouldForceRefresh) {
|
|
3219
|
+
const cached = await this.readCachedToken(capabilityIntegrationId, loggedInUserId);
|
|
3220
|
+
if (cached) {
|
|
3221
|
+
return cached;
|
|
3222
|
+
}
|
|
3223
|
+
}
|
|
3224
|
+
const ownerId = crypto.randomUUID();
|
|
3225
|
+
const isAcquired = await this.redisCacheStoreService.setIfAbsent(lockKey, ownerId, OAUTH_LOCK_TTL_SECONDS);
|
|
3226
|
+
if (isAcquired) {
|
|
3227
|
+
this.logger.info(loggedInUserId, this.mintWithDistributedLock.name, this.fileName, "OAuth token lock acquired", {
|
|
3228
|
+
capabilityIntegrationId: capabilityIntegrationId.toString()
|
|
3229
|
+
});
|
|
3230
|
+
try {
|
|
3231
|
+
if (!shouldForceRefresh) {
|
|
3232
|
+
const cached = await this.readCachedToken(capabilityIntegrationId, loggedInUserId);
|
|
3233
|
+
if (cached) {
|
|
3234
|
+
return cached;
|
|
3235
|
+
}
|
|
3236
|
+
}
|
|
3237
|
+
return await this.mintToken(capabilityIntegrationId, opts, loggedInUserId);
|
|
3238
|
+
} finally {
|
|
3239
|
+
await this.releaseLockIfOwner(lockKey, ownerId);
|
|
3240
|
+
}
|
|
3241
|
+
}
|
|
3242
|
+
const existingLock = await this.redisCacheStoreService.get(lockKey);
|
|
3243
|
+
if (existingLock == null) {
|
|
3244
|
+
this.logger.warn(loggedInUserId, this.mintWithDistributedLock.name, this.fileName, "OAuth token lock unavailable; minting without lock", {
|
|
3245
|
+
capabilityIntegrationId: capabilityIntegrationId.toString()
|
|
3246
|
+
});
|
|
3247
|
+
if (!shouldForceRefresh) {
|
|
3248
|
+
const cached = await this.readCachedToken(capabilityIntegrationId, loggedInUserId);
|
|
3249
|
+
if (cached) {
|
|
3250
|
+
return cached;
|
|
3251
|
+
}
|
|
3252
|
+
}
|
|
3253
|
+
return this.mintToken(capabilityIntegrationId, opts, loggedInUserId);
|
|
3254
|
+
}
|
|
3255
|
+
this.logger.info(loggedInUserId, this.mintWithDistributedLock.name, this.fileName, "OAuth token lock contention; waiting", {
|
|
3256
|
+
capabilityIntegrationId: capabilityIntegrationId.toString()
|
|
3257
|
+
});
|
|
3258
|
+
await delay(OAUTH_LOCK_WAIT_MS);
|
|
3259
|
+
}
|
|
3260
|
+
this.logger.warn(loggedInUserId, this.mintWithDistributedLock.name, this.fileName, "OAuth token lock wait timed out; minting without lock", {
|
|
3261
|
+
capabilityIntegrationId: capabilityIntegrationId.toString()
|
|
3262
|
+
});
|
|
3263
|
+
if (!shouldForceRefresh) {
|
|
3264
|
+
const cached = await this.readCachedToken(capabilityIntegrationId, loggedInUserId);
|
|
3265
|
+
if (cached) {
|
|
3266
|
+
return cached;
|
|
3267
|
+
}
|
|
3268
|
+
}
|
|
3269
|
+
return this.mintToken(capabilityIntegrationId, opts, loggedInUserId);
|
|
3270
|
+
}
|
|
3271
|
+
async releaseLockIfOwner(lockKey, ownerId) {
|
|
3272
|
+
const current = await this.redisCacheStoreService.get(lockKey);
|
|
3273
|
+
if (current === ownerId) {
|
|
3274
|
+
await this.redisCacheStoreService.del(lockKey);
|
|
3275
|
+
}
|
|
3276
|
+
}
|
|
3277
|
+
async readCachedToken(capabilityIntegrationId, loggedInUserId) {
|
|
3278
|
+
const memory = this.sessions.get(capabilityIntegrationId.toString());
|
|
3279
|
+
if (memory && isTokenFresh(memory.tokenExpiry)) {
|
|
3963
3280
|
return {
|
|
3964
|
-
|
|
3965
|
-
|
|
3281
|
+
accessToken: memory.token,
|
|
3282
|
+
tokenType: memory.tokenType,
|
|
3283
|
+
expiresAt: memory.tokenExpiry,
|
|
3284
|
+
refreshToken: memory.refreshToken
|
|
3966
3285
|
};
|
|
3967
|
-
} catch (error) {
|
|
3968
|
-
this.logger.error(loggedInUserId, this.updateOnpremDeployment.name, this.fileName, "Error in updateOnpremDeployment", error, {
|
|
3969
|
-
id,
|
|
3970
|
-
updateData
|
|
3971
|
-
});
|
|
3972
|
-
throw error;
|
|
3973
3286
|
}
|
|
3287
|
+
const redisToken = await this.tokenCache.get(capabilityIntegrationId);
|
|
3288
|
+
if (redisToken && isTokenFresh(redisToken.expiresAt)) {
|
|
3289
|
+
this.writeMemory(capabilityIntegrationId, redisToken);
|
|
3290
|
+
return redisToken;
|
|
3291
|
+
}
|
|
3292
|
+
const row = await this.tokenDao.findByCapabilityIntegrationId(capabilityIntegrationId, loggedInUserId);
|
|
3293
|
+
if (!row || !isTokenFresh(row.expiresAt)) {
|
|
3294
|
+
return void 0;
|
|
3295
|
+
}
|
|
3296
|
+
const accessToken = await this.decryptToken(row.accessToken);
|
|
3297
|
+
const refreshToken = row.refreshToken ? await this.decryptToken(row.refreshToken) : void 0;
|
|
3298
|
+
const token = {
|
|
3299
|
+
accessToken,
|
|
3300
|
+
tokenType: row.tokenMetadata?.tokenType ?? "Bearer",
|
|
3301
|
+
expiresAt: row.expiresAt,
|
|
3302
|
+
refreshToken,
|
|
3303
|
+
metadata: row.tokenMetadata ?? void 0
|
|
3304
|
+
};
|
|
3305
|
+
this.writeMemory(capabilityIntegrationId, token);
|
|
3306
|
+
await this.tokenCache.set(capabilityIntegrationId, token);
|
|
3307
|
+
return token;
|
|
3974
3308
|
}
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3309
|
+
async mintToken(capabilityIntegrationId, opts, loggedInUserId) {
|
|
3310
|
+
if (!opts.credentials) {
|
|
3311
|
+
throw new Error("OAuth mint credentials are required when no valid cached token exists");
|
|
3312
|
+
}
|
|
3313
|
+
const { tokenUrl, scope, grantType } = await this.resolveMintContext(opts.credentials, opts, loggedInUserId);
|
|
3314
|
+
const handler = this.grantHandlerRegistry.get(grantType);
|
|
3315
|
+
this.logger.info(loggedInUserId, this.mintToken.name, this.fileName, "Minting OAuth token", {
|
|
3316
|
+
capabilityIntegrationId: capabilityIntegrationId?.toString(),
|
|
3317
|
+
grantType
|
|
3318
|
+
});
|
|
3980
3319
|
try {
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3320
|
+
const minted = await handler.mint({
|
|
3321
|
+
credentials: opts.credentials,
|
|
3322
|
+
tokenUrl,
|
|
3323
|
+
scope,
|
|
3324
|
+
integration: {
|
|
3325
|
+
id: capabilityIntegrationId,
|
|
3326
|
+
capabilityId: opts.capabilityId,
|
|
3327
|
+
providerId: opts.providerId
|
|
3328
|
+
},
|
|
3329
|
+
loggedInUserId
|
|
3986
3330
|
});
|
|
3331
|
+
if (!minted.accessToken) {
|
|
3332
|
+
throw new Error("OAuth mint returned an empty access token");
|
|
3333
|
+
}
|
|
3334
|
+
if (hasPersistedIntegrationId(capabilityIntegrationId)) {
|
|
3335
|
+
await this.storeToken(capabilityIntegrationId, minted, loggedInUserId);
|
|
3336
|
+
}
|
|
3337
|
+
return minted;
|
|
3987
3338
|
} catch (error) {
|
|
3988
|
-
this.logger.error(loggedInUserId, this.
|
|
3989
|
-
input
|
|
3990
|
-
});
|
|
3339
|
+
this.logger.error(loggedInUserId, this.mintToken.name, this.fileName, "OAuth token mint failed", error);
|
|
3991
3340
|
throw error;
|
|
3992
3341
|
}
|
|
3993
3342
|
}
|
|
3343
|
+
async resolveMintContext(credentials, opts, loggedInUserId) {
|
|
3344
|
+
let tokenUrl = credentials.tokenUrl;
|
|
3345
|
+
let supportedGrantTypes;
|
|
3346
|
+
let defaultScopes;
|
|
3347
|
+
if (opts.capabilityId != null && opts.providerId != null) {
|
|
3348
|
+
const provider = await this.providerDao.findByCapabilityAndProvider(opts.capabilityId, opts.providerId, loggedInUserId);
|
|
3349
|
+
if (provider) {
|
|
3350
|
+
tokenUrl = substituteUrlPlaceholders(provider.tokenUrl, credentials.urlParams);
|
|
3351
|
+
supportedGrantTypes = provider.supportedGrantTypes;
|
|
3352
|
+
defaultScopes = provider.defaultScopes;
|
|
3353
|
+
}
|
|
3354
|
+
}
|
|
3355
|
+
tokenUrl = substituteUrlPlaceholders(tokenUrl, credentials.urlParams);
|
|
3356
|
+
const scope = credentials.scope ?? (defaultScopes?.length ? defaultScopes.join(" ") : void 0);
|
|
3357
|
+
const grantType = this.grantHandlerRegistry.resolvePreferredGrant(supportedGrantTypes);
|
|
3358
|
+
return {
|
|
3359
|
+
tokenUrl,
|
|
3360
|
+
scope,
|
|
3361
|
+
grantType
|
|
3362
|
+
};
|
|
3363
|
+
}
|
|
3364
|
+
async persistToken(capabilityIntegrationId, token, loggedInUserId) {
|
|
3365
|
+
const encryptedAccessToken = await this.encryptToken(token.accessToken);
|
|
3366
|
+
const encryptedRefreshToken = token.refreshToken ? await this.encryptToken(token.refreshToken) : void 0;
|
|
3367
|
+
await this.tokenDao.upsert({
|
|
3368
|
+
capabilityIntegrationId,
|
|
3369
|
+
accessToken: encryptedAccessToken,
|
|
3370
|
+
refreshToken: encryptedRefreshToken,
|
|
3371
|
+
expiresAt: token.expiresAt,
|
|
3372
|
+
tokenMetadata: {
|
|
3373
|
+
...token.metadata ?? {},
|
|
3374
|
+
tokenType: token.tokenType
|
|
3375
|
+
},
|
|
3376
|
+
loggedInUserId
|
|
3377
|
+
});
|
|
3378
|
+
}
|
|
3379
|
+
writeMemory(capabilityIntegrationId, token) {
|
|
3380
|
+
this.sessions.set(capabilityIntegrationId.toString(), {
|
|
3381
|
+
token: token.accessToken,
|
|
3382
|
+
tokenType: token.tokenType,
|
|
3383
|
+
tokenExpiry: token.expiresAt,
|
|
3384
|
+
refreshToken: token.refreshToken
|
|
3385
|
+
});
|
|
3386
|
+
}
|
|
3387
|
+
async encryptToken(value) {
|
|
3388
|
+
const keyId = getIntegrationConfigKmsKeyId();
|
|
3389
|
+
if (!this.secretProvider || !keyId) {
|
|
3390
|
+
throw new Error("OAuth token persist requires SECRET_PROVIDER and INTEGRATION_CONFIG_KMS_KEY_ID");
|
|
3391
|
+
}
|
|
3392
|
+
return this.secretProvider.encrypt(value, keyId);
|
|
3393
|
+
}
|
|
3394
|
+
async decryptToken(value) {
|
|
3395
|
+
const keyId = getIntegrationConfigKmsKeyId();
|
|
3396
|
+
if (!this.secretProvider || !keyId) {
|
|
3397
|
+
throw new Error("OAuth token decrypt requires SECRET_PROVIDER and INTEGRATION_CONFIG_KMS_KEY_ID");
|
|
3398
|
+
}
|
|
3399
|
+
return this.secretProvider.decrypt(value, keyId);
|
|
3400
|
+
}
|
|
3401
|
+
};
|
|
3402
|
+
OauthTokenManager = _ts_decorate23([
|
|
3403
|
+
common.Injectable(),
|
|
3404
|
+
_ts_param13(6, common.Optional()),
|
|
3405
|
+
_ts_param13(6, common.Inject(oauthSecretProviderToken)),
|
|
3406
|
+
_ts_metadata19("design:type", Function),
|
|
3407
|
+
_ts_metadata19("design:paramtypes", [
|
|
3408
|
+
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
|
|
3409
|
+
typeof OauthTokenDao === "undefined" ? Object : OauthTokenDao,
|
|
3410
|
+
typeof OauthProviderDao === "undefined" ? Object : OauthProviderDao,
|
|
3411
|
+
typeof OauthTokenCache === "undefined" ? Object : OauthTokenCache,
|
|
3412
|
+
typeof dvssBackendModuleDatastore.RedisCacheStoreService === "undefined" ? Object : dvssBackendModuleDatastore.RedisCacheStoreService,
|
|
3413
|
+
typeof GrantHandlerRegistry === "undefined" ? Object : GrantHandlerRegistry,
|
|
3414
|
+
typeof SecretProvider === "undefined" ? Object : SecretProvider
|
|
3415
|
+
])
|
|
3416
|
+
], OauthTokenManager);
|
|
3417
|
+
|
|
3418
|
+
// ../../packages/dvss-integration-oauth/src/oauth2.provider.ts
|
|
3419
|
+
function _ts_decorate24(decorators, target, key, desc2) {
|
|
3420
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3421
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3422
|
+
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;
|
|
3423
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3424
|
+
}
|
|
3425
|
+
__name(_ts_decorate24, "_ts_decorate");
|
|
3426
|
+
function _ts_metadata20(k, v) {
|
|
3427
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
3428
|
+
}
|
|
3429
|
+
__name(_ts_metadata20, "_ts_metadata");
|
|
3430
|
+
var OAuth2Provider = class {
|
|
3431
|
+
static {
|
|
3432
|
+
__name(this, "OAuth2Provider");
|
|
3433
|
+
}
|
|
3434
|
+
tokenManager;
|
|
3435
|
+
constructor(tokenManager) {
|
|
3436
|
+
this.tokenManager = tokenManager;
|
|
3437
|
+
}
|
|
3438
|
+
async getValidAccessToken(capabilityIntegrationId, opts = {}) {
|
|
3439
|
+
return this.tokenManager.getValidAccessToken(capabilityIntegrationId, opts);
|
|
3440
|
+
}
|
|
3441
|
+
async getAuthenticationHeaders(capabilityIntegrationId, opts = {}) {
|
|
3442
|
+
const token = await this.getValidAccessToken(capabilityIntegrationId, opts);
|
|
3443
|
+
return {
|
|
3444
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
3445
|
+
Authorization: `${token.tokenType} ${token.accessToken}`
|
|
3446
|
+
};
|
|
3447
|
+
}
|
|
3448
|
+
async testIntegration(integration, loggedInUserId, credentials) {
|
|
3449
|
+
const token = await this.getValidAccessToken(integration.id, {
|
|
3450
|
+
forceRefresh: true,
|
|
3451
|
+
loggedInUserId,
|
|
3452
|
+
credentials,
|
|
3453
|
+
capabilityId: integration.capabilityId,
|
|
3454
|
+
providerId: integration.providerId
|
|
3455
|
+
});
|
|
3456
|
+
if (!token.accessToken) {
|
|
3457
|
+
throw new Error("OAuth integration test failed: empty access token");
|
|
3458
|
+
}
|
|
3459
|
+
return true;
|
|
3460
|
+
}
|
|
3461
|
+
async storeToken(capabilityIntegrationId, token, loggedInUserId) {
|
|
3462
|
+
await this.tokenManager.storeToken(capabilityIntegrationId, token, loggedInUserId ?? dvssBackendModuleUtility.SYSTEM_USER_ID);
|
|
3463
|
+
}
|
|
3464
|
+
async invalidate(capabilityIntegrationId) {
|
|
3465
|
+
await this.tokenManager.invalidate(capabilityIntegrationId);
|
|
3466
|
+
}
|
|
3467
|
+
};
|
|
3468
|
+
OAuth2Provider = _ts_decorate24([
|
|
3469
|
+
common.Injectable(),
|
|
3470
|
+
_ts_metadata20("design:type", Function),
|
|
3471
|
+
_ts_metadata20("design:paramtypes", [
|
|
3472
|
+
typeof OauthTokenManager === "undefined" ? Object : OauthTokenManager
|
|
3473
|
+
])
|
|
3474
|
+
], OAuth2Provider);
|
|
3475
|
+
|
|
3476
|
+
// ../../packages/dvss-integration-oauth/src/oauth.module.ts
|
|
3477
|
+
function _ts_decorate25(decorators, target, key, desc2) {
|
|
3478
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3479
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3480
|
+
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;
|
|
3481
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3482
|
+
}
|
|
3483
|
+
__name(_ts_decorate25, "_ts_decorate");
|
|
3484
|
+
var IntegrationOauthModule = class {
|
|
3485
|
+
static {
|
|
3486
|
+
__name(this, "IntegrationOauthModule");
|
|
3487
|
+
}
|
|
3994
3488
|
};
|
|
3995
|
-
|
|
3996
|
-
common.
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
3489
|
+
IntegrationOauthModule = _ts_decorate25([
|
|
3490
|
+
common.Module({
|
|
3491
|
+
imports: [
|
|
3492
|
+
exports.IntegrationLibsModule,
|
|
3493
|
+
dvssBackendModuleUtility.LoggerModule,
|
|
3494
|
+
dvssBackendModuleDatastore.DatastoreModule
|
|
3495
|
+
],
|
|
3496
|
+
providers: [
|
|
3497
|
+
OauthTokenDao,
|
|
3498
|
+
OauthProviderDao,
|
|
3499
|
+
OauthTokenCache,
|
|
3500
|
+
ClientCredentialsGrantHandler,
|
|
3501
|
+
AuthorizationCodeGrantHandler,
|
|
3502
|
+
GrantHandlerRegistry,
|
|
3503
|
+
OauthTokenManager,
|
|
3504
|
+
OAuth2Provider
|
|
3505
|
+
],
|
|
3506
|
+
exports: [
|
|
3507
|
+
OAuth2Provider,
|
|
3508
|
+
OauthTokenManager
|
|
3509
|
+
]
|
|
3510
|
+
})
|
|
3511
|
+
], IntegrationOauthModule);
|
|
4004
3512
|
|
|
4005
3513
|
// ../../packages/dvss-integration-microsoft/src/common/microsoft.constant.ts
|
|
4006
3514
|
var MICROSOFT_GRAPH_PATHS = {
|
|
@@ -4064,23 +3572,23 @@ var MICROSOFT_TOKEN_HEADERS = {
|
|
|
4064
3572
|
};
|
|
4065
3573
|
|
|
4066
3574
|
// ../../packages/dvss-integration-microsoft/src/capabilities/auth/auth.service.ts
|
|
4067
|
-
function
|
|
3575
|
+
function _ts_decorate26(decorators, target, key, desc2) {
|
|
4068
3576
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4069
3577
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
4070
3578
|
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;
|
|
4071
3579
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4072
3580
|
}
|
|
4073
|
-
__name(
|
|
4074
|
-
function
|
|
3581
|
+
__name(_ts_decorate26, "_ts_decorate");
|
|
3582
|
+
function _ts_metadata21(k, v) {
|
|
4075
3583
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4076
3584
|
}
|
|
4077
|
-
__name(
|
|
4078
|
-
function
|
|
3585
|
+
__name(_ts_metadata21, "_ts_metadata");
|
|
3586
|
+
function _ts_param14(paramIndex, decorator) {
|
|
4079
3587
|
return function(target, key) {
|
|
4080
3588
|
decorator(target, key, paramIndex);
|
|
4081
3589
|
};
|
|
4082
3590
|
}
|
|
4083
|
-
__name(
|
|
3591
|
+
__name(_ts_param14, "_ts_param");
|
|
4084
3592
|
function requireNonEmpty(value, fieldName) {
|
|
4085
3593
|
if (value == null || typeof value === "string" && value.trim() === "") {
|
|
4086
3594
|
throw new Error(`Microsoft integration configuration: ${fieldName} is required`);
|
|
@@ -4098,32 +3606,25 @@ exports.MicrosoftAuthService = class MicrosoftAuthService {
|
|
|
4098
3606
|
__name(this, "MicrosoftAuthService");
|
|
4099
3607
|
}
|
|
4100
3608
|
logger;
|
|
4101
|
-
|
|
4102
|
-
integrationConfigurationDao;
|
|
3609
|
+
oauth2Provider;
|
|
4103
3610
|
secureStorage;
|
|
4104
3611
|
fileName = "auth.service";
|
|
4105
|
-
constructor(logger,
|
|
3612
|
+
constructor(logger, oauth2Provider, secureStorage) {
|
|
4106
3613
|
this.logger = logger;
|
|
4107
|
-
this.
|
|
4108
|
-
this.integrationConfigurationDao = integrationConfigurationDao;
|
|
3614
|
+
this.oauth2Provider = oauth2Provider;
|
|
4109
3615
|
this.secureStorage = secureStorage;
|
|
4110
3616
|
}
|
|
4111
3617
|
/**
|
|
4112
|
-
* Validates Azure AD / Graph integration configuration
|
|
4113
|
-
*
|
|
3618
|
+
* Validates Azure AD / Graph integration configuration.
|
|
3619
|
+
* Authorization headers are resolved on demand via OAuth2Provider (not from config.accessDetails).
|
|
4114
3620
|
*/
|
|
4115
3621
|
validateConfig(integration, loggedInUserId) {
|
|
4116
3622
|
const config2 = this.parseAndValidateConfig(integration, loggedInUserId);
|
|
4117
|
-
const headers = {};
|
|
4118
|
-
if (config2.accessDetails?.accessToken) {
|
|
4119
|
-
const tokenType = config2.accessDetails.tokenType || MICROSOFT_DEFAULT_ACCESS_TOKEN_TYPE;
|
|
4120
|
-
headers.Authorization = `${tokenType} ${config2.accessDetails.accessToken}`;
|
|
4121
|
-
}
|
|
4122
3623
|
return {
|
|
4123
3624
|
...integration,
|
|
4124
|
-
id: integration.id
|
|
3625
|
+
id: integration.id,
|
|
4125
3626
|
config: config2,
|
|
4126
|
-
headers
|
|
3627
|
+
headers: {}
|
|
4127
3628
|
};
|
|
4128
3629
|
}
|
|
4129
3630
|
/**
|
|
@@ -4148,10 +3649,7 @@ exports.MicrosoftAuthService = class MicrosoftAuthService {
|
|
|
4148
3649
|
}, raw);
|
|
4149
3650
|
requireNonEmpty(config2.platformConfig.authUrl, "platformConfig.authUrl");
|
|
4150
3651
|
requireNonEmpty(config2.platformConfig.baseUrl, "platformConfig.baseUrl");
|
|
4151
|
-
return
|
|
4152
|
-
...config2,
|
|
4153
|
-
accessDetails: raw.accessDetails
|
|
4154
|
-
};
|
|
3652
|
+
return config2;
|
|
4155
3653
|
}
|
|
4156
3654
|
/**
|
|
4157
3655
|
* Decrypts stored secure-storage envelopes when present, then validates.
|
|
@@ -4174,11 +3672,27 @@ exports.MicrosoftAuthService = class MicrosoftAuthService {
|
|
|
4174
3672
|
}
|
|
4175
3673
|
async getAccessToken(integration, loggedInUserId, forceRefresh = false) {
|
|
4176
3674
|
const config2 = await this.resolvePlaintextConfig(integration, loggedInUserId);
|
|
4177
|
-
const
|
|
4178
|
-
|
|
4179
|
-
|
|
3675
|
+
const token = await this.oauth2Provider.getValidAccessToken("id" in integration ? integration.id : void 0, {
|
|
3676
|
+
forceRefresh,
|
|
3677
|
+
loggedInUserId: loggedInUserId ?? dvssBackendModuleUtility.SYSTEM_USER_ID,
|
|
3678
|
+
credentials: this.toMintCredentials(config2),
|
|
3679
|
+
capabilityId: integration.capabilityId,
|
|
3680
|
+
providerId: integration.providerId
|
|
3681
|
+
});
|
|
3682
|
+
return this.toMicrosoftAccessToken(token);
|
|
3683
|
+
}
|
|
3684
|
+
/**
|
|
3685
|
+
* Persists a previously minted token after capability_integration insert.
|
|
3686
|
+
*/
|
|
3687
|
+
async persistMintedAccessToken(capabilityIntegrationId, token, loggedInUserId) {
|
|
3688
|
+
if (token.expiresIn <= 0) {
|
|
3689
|
+
return;
|
|
4180
3690
|
}
|
|
4181
|
-
|
|
3691
|
+
await this.oauth2Provider.storeToken(capabilityIntegrationId, {
|
|
3692
|
+
accessToken: token.accessToken,
|
|
3693
|
+
tokenType: token.tokenType || MICROSOFT_DEFAULT_ACCESS_TOKEN_TYPE,
|
|
3694
|
+
expiresAt: new Date(Date.now() + token.expiresIn * 1e3)
|
|
3695
|
+
}, loggedInUserId);
|
|
4182
3696
|
}
|
|
4183
3697
|
/**
|
|
4184
3698
|
* BaseAuth contract — returns the access token string.
|
|
@@ -4192,116 +3706,68 @@ exports.MicrosoftAuthService = class MicrosoftAuthService {
|
|
|
4192
3706
|
*/
|
|
4193
3707
|
async testIntegration(integration, loggedInUserId) {
|
|
4194
3708
|
this.logger.info(loggedInUserId, this.testIntegration.name, this.fileName, "Testing Microsoft Graph integration");
|
|
4195
|
-
const
|
|
4196
|
-
|
|
4197
|
-
throw new Error("Microsoft integration test failed: empty access token");
|
|
4198
|
-
}
|
|
3709
|
+
const config2 = await this.resolvePlaintextConfig(integration, loggedInUserId);
|
|
3710
|
+
const isSuccessful = await this.oauth2Provider.testIntegration(integration, loggedInUserId, this.toMintCredentials(config2));
|
|
4199
3711
|
this.logger.info(loggedInUserId, this.testIntegration.name, this.fileName, "Microsoft Graph integration test successful");
|
|
4200
|
-
return
|
|
3712
|
+
return isSuccessful;
|
|
4201
3713
|
}
|
|
4202
|
-
|
|
4203
|
-
const cachedToken = config2.accessDetails?.accessToken;
|
|
4204
|
-
const cachedExpiryIso = config2.accessDetails?.expiryAt;
|
|
4205
|
-
if (!cachedToken || !cachedExpiryIso) {
|
|
4206
|
-
return void 0;
|
|
4207
|
-
}
|
|
4208
|
-
const expiryTimeMs = new Date(cachedExpiryIso).getTime();
|
|
4209
|
-
if (Number.isNaN(expiryTimeMs) || expiryTimeMs <= Date.now()) {
|
|
4210
|
-
return void 0;
|
|
4211
|
-
}
|
|
3714
|
+
toMintCredentials(config2) {
|
|
4212
3715
|
return {
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
};
|
|
4217
|
-
}
|
|
4218
|
-
async requestAccessToken(integration, config2, loggedInUserId) {
|
|
4219
|
-
const tokenUrl = new URL(config2.platformConfig.authUrl.replace("{tenantId}", config2.integrationConfig.tenantId));
|
|
4220
|
-
const body = new URLSearchParams({
|
|
4221
|
-
client_id: config2.integrationConfig.clientId,
|
|
4222
|
-
client_secret: config2.integrationConfig.clientSecret,
|
|
3716
|
+
tokenUrl: config2.platformConfig.authUrl,
|
|
3717
|
+
clientId: config2.integrationConfig.clientId,
|
|
3718
|
+
clientSecret: config2.integrationConfig.clientSecret,
|
|
4223
3719
|
scope: MICROSOFT_DEFAULT_GRAPH_SCOPE,
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
...integration,
|
|
4228
|
-
id: "id" in integration && integration.id != null ? integration.id : BigInt(0),
|
|
4229
|
-
headers: MICROSOFT_TOKEN_HEADERS
|
|
4230
|
-
};
|
|
4231
|
-
const effectiveLoggedInUserId = loggedInUserId ?? dvssBackendModuleUtility.SYSTEM_USER_ID;
|
|
4232
|
-
this.logger.info(effectiveLoggedInUserId, this.requestAccessToken.name, this.fileName, "Fetching Microsoft Graph access token");
|
|
4233
|
-
const response = await this.trafficGatewayService.executeIntegrationRequest({
|
|
4234
|
-
apiMethod: HTTP_METHOD.POST,
|
|
4235
|
-
baseUrl: tokenUrl.origin,
|
|
4236
|
-
url: `${tokenUrl.pathname}${tokenUrl.search}`,
|
|
4237
|
-
body,
|
|
4238
|
-
headers: MICROSOFT_TOKEN_HEADERS
|
|
4239
|
-
}, integrationContext, effectiveLoggedInUserId);
|
|
4240
|
-
if (!response.access_token) {
|
|
4241
|
-
throw new Error("Microsoft access token response is missing access_token");
|
|
4242
|
-
}
|
|
4243
|
-
const token = {
|
|
4244
|
-
accessToken: response.access_token,
|
|
4245
|
-
tokenType: response.token_type ?? MICROSOFT_DEFAULT_ACCESS_TOKEN_TYPE,
|
|
4246
|
-
expiresIn: response.expires_in ?? 0
|
|
3720
|
+
urlParams: {
|
|
3721
|
+
tenantId: config2.integrationConfig.tenantId
|
|
3722
|
+
}
|
|
4247
3723
|
};
|
|
4248
|
-
await this.persistAccessDetails(integration, config2, token, effectiveLoggedInUserId);
|
|
4249
|
-
return token;
|
|
4250
3724
|
}
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
config2.accessDetails = {
|
|
4254
|
-
accessToken: token.accessToken,
|
|
4255
|
-
expiryAt: new Date(Date.now() + Math.max(token.expiresIn, 0) * 1e3).toISOString(),
|
|
4256
|
-
tokenType: token.tokenType
|
|
4257
|
-
};
|
|
4258
|
-
return;
|
|
4259
|
-
}
|
|
4260
|
-
await this.integrationConfigurationDao.updateCapabilityIntegrationAccessDetails(integration.id, token.accessToken, token.expiresIn, loggedInUserId);
|
|
4261
|
-
config2.accessDetails = {
|
|
3725
|
+
toMicrosoftAccessToken(token) {
|
|
3726
|
+
return {
|
|
4262
3727
|
accessToken: token.accessToken,
|
|
4263
|
-
|
|
4264
|
-
|
|
3728
|
+
tokenType: token.tokenType || MICROSOFT_DEFAULT_ACCESS_TOKEN_TYPE,
|
|
3729
|
+
expiresIn: secondsUntil(token.expiresAt)
|
|
4265
3730
|
};
|
|
4266
3731
|
}
|
|
4267
3732
|
};
|
|
4268
|
-
exports.MicrosoftAuthService =
|
|
3733
|
+
exports.MicrosoftAuthService = _ts_decorate26([
|
|
4269
3734
|
common.Injectable(),
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
3735
|
+
_ts_param14(2, common.Optional()),
|
|
3736
|
+
_ts_param14(2, common.Inject(MICROSOFT_SECURE_STORAGE)),
|
|
3737
|
+
_ts_metadata21("design:type", Function),
|
|
3738
|
+
_ts_metadata21("design:paramtypes", [
|
|
4274
3739
|
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
|
|
4275
|
-
typeof
|
|
4276
|
-
typeof exports.IntegrationConfigurationDao === "undefined" ? Object : exports.IntegrationConfigurationDao,
|
|
3740
|
+
typeof OAuth2Provider === "undefined" ? Object : OAuth2Provider,
|
|
4277
3741
|
typeof IntegrationConfigSecureStorageService === "undefined" ? Object : IntegrationConfigSecureStorageService
|
|
4278
3742
|
])
|
|
4279
3743
|
], exports.MicrosoftAuthService);
|
|
4280
3744
|
|
|
4281
3745
|
// ../../packages/dvss-integration-microsoft/src/adapter/microsoft-api-client.service.ts
|
|
4282
|
-
function
|
|
3746
|
+
function _ts_decorate27(decorators, target, key, desc2) {
|
|
4283
3747
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4284
3748
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
4285
3749
|
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;
|
|
4286
3750
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4287
3751
|
}
|
|
4288
|
-
__name(
|
|
4289
|
-
function
|
|
3752
|
+
__name(_ts_decorate27, "_ts_decorate");
|
|
3753
|
+
function _ts_metadata22(k, v) {
|
|
4290
3754
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4291
3755
|
}
|
|
4292
|
-
__name(
|
|
3756
|
+
__name(_ts_metadata22, "_ts_metadata");
|
|
4293
3757
|
exports.MicrosoftApiClientService = class MicrosoftApiClientService {
|
|
4294
3758
|
static {
|
|
4295
3759
|
__name(this, "MicrosoftApiClientService");
|
|
4296
3760
|
}
|
|
4297
3761
|
logger;
|
|
4298
3762
|
authService;
|
|
3763
|
+
oauth2Provider;
|
|
4299
3764
|
trafficGatewayService;
|
|
4300
3765
|
fileName = "microsoft-api-client.service";
|
|
4301
3766
|
maxAuthRetryCount = 2;
|
|
4302
|
-
constructor(logger, authService, trafficGatewayService) {
|
|
3767
|
+
constructor(logger, authService, oauth2Provider, trafficGatewayService) {
|
|
4303
3768
|
this.logger = logger;
|
|
4304
3769
|
this.authService = authService;
|
|
3770
|
+
this.oauth2Provider = oauth2Provider;
|
|
4305
3771
|
this.trafficGatewayService = trafficGatewayService;
|
|
4306
3772
|
}
|
|
4307
3773
|
async apiCall(request, integration, loggedInUserId = dvssBackendModuleUtility.SYSTEM_USER_ID) {
|
|
@@ -4309,16 +3775,17 @@ exports.MicrosoftApiClientService = class MicrosoftApiClientService {
|
|
|
4309
3775
|
}
|
|
4310
3776
|
async executeWithRetry(request, integration, loggedInUserId, retryCount) {
|
|
4311
3777
|
const config2 = await this.authService.resolvePlaintextConfig(integration, loggedInUserId);
|
|
4312
|
-
const
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
3778
|
+
const authHeaders = await this.oauth2Provider.getAuthenticationHeaders(integration.id, {
|
|
3779
|
+
forceRefresh: retryCount > 0,
|
|
3780
|
+
loggedInUserId,
|
|
3781
|
+
credentials: this.authService.toMintCredentials(config2),
|
|
3782
|
+
capabilityId: integration.capabilityId,
|
|
3783
|
+
providerId: integration.providerId
|
|
3784
|
+
});
|
|
4317
3785
|
const headers = {
|
|
4318
3786
|
...MICROSOFT_DEFAULT_HEADERS,
|
|
4319
3787
|
...request.headers ?? {},
|
|
4320
|
-
|
|
4321
|
-
Authorization: `${accessToken.tokenType || MICROSOFT_DEFAULT_ACCESS_TOKEN_TYPE} ${accessToken.accessToken}`
|
|
3788
|
+
...authHeaders
|
|
4322
3789
|
};
|
|
4323
3790
|
const validatedIntegration = {
|
|
4324
3791
|
...integration,
|
|
@@ -4342,7 +3809,9 @@ exports.MicrosoftApiClientService = class MicrosoftApiClientService {
|
|
|
4342
3809
|
if (!this.isUnauthorizedError(error) || retryCount >= this.maxAuthRetryCount) {
|
|
4343
3810
|
throw error;
|
|
4344
3811
|
}
|
|
4345
|
-
|
|
3812
|
+
if (integration.id != null) {
|
|
3813
|
+
await this.oauth2Provider.invalidate(integration.id);
|
|
3814
|
+
}
|
|
4346
3815
|
this.logger.info(loggedInUserId, this.executeWithRetry.name, this.fileName, "Retrying Microsoft Graph API call after unauthorized response", {
|
|
4347
3816
|
retryCount: retryCount + 1,
|
|
4348
3817
|
url: request.url
|
|
@@ -4354,24 +3823,19 @@ exports.MicrosoftApiClientService = class MicrosoftApiClientService {
|
|
|
4354
3823
|
const errorObject = error;
|
|
4355
3824
|
return errorObject.response?.status === 401 || errorObject.status === 401;
|
|
4356
3825
|
}
|
|
4357
|
-
clearCachedAccessDetails(integration) {
|
|
4358
|
-
const config2 = integration.config;
|
|
4359
|
-
if (config2) {
|
|
4360
|
-
config2.accessDetails = void 0;
|
|
4361
|
-
}
|
|
4362
|
-
}
|
|
4363
3826
|
};
|
|
4364
|
-
exports.MicrosoftApiClientService =
|
|
3827
|
+
exports.MicrosoftApiClientService = _ts_decorate27([
|
|
4365
3828
|
common.Injectable(),
|
|
4366
|
-
|
|
4367
|
-
|
|
3829
|
+
_ts_metadata22("design:type", Function),
|
|
3830
|
+
_ts_metadata22("design:paramtypes", [
|
|
4368
3831
|
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
|
|
4369
3832
|
typeof exports.MicrosoftAuthService === "undefined" ? Object : exports.MicrosoftAuthService,
|
|
3833
|
+
typeof OAuth2Provider === "undefined" ? Object : OAuth2Provider,
|
|
4370
3834
|
typeof exports.TrafficGatewayService === "undefined" ? Object : exports.TrafficGatewayService
|
|
4371
3835
|
])
|
|
4372
3836
|
], exports.MicrosoftApiClientService);
|
|
4373
3837
|
|
|
4374
|
-
// ../../packages/dvss-integration-microsoft/src/capabilities/
|
|
3838
|
+
// ../../packages/dvss-integration-microsoft/src/capabilities/booking-management/booking-management.mapper.ts
|
|
4375
3839
|
var GRAPH_EVENT_KNOWN_KEYS = /* @__PURE__ */ new Set([
|
|
4376
3840
|
"id",
|
|
4377
3841
|
"subject",
|
|
@@ -4549,25 +4013,25 @@ function collectUnknownGraphFields(graph) {
|
|
|
4549
4013
|
}
|
|
4550
4014
|
__name(collectUnknownGraphFields, "collectUnknownGraphFields");
|
|
4551
4015
|
|
|
4552
|
-
// ../../packages/dvss-integration-microsoft/src/capabilities/
|
|
4553
|
-
function
|
|
4016
|
+
// ../../packages/dvss-integration-microsoft/src/capabilities/booking-management/booking-management.service.ts
|
|
4017
|
+
function _ts_decorate28(decorators, target, key, desc2) {
|
|
4554
4018
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4555
4019
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
4556
4020
|
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;
|
|
4557
4021
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4558
4022
|
}
|
|
4559
|
-
__name(
|
|
4560
|
-
function
|
|
4023
|
+
__name(_ts_decorate28, "_ts_decorate");
|
|
4024
|
+
function _ts_metadata23(k, v) {
|
|
4561
4025
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4562
4026
|
}
|
|
4563
|
-
__name(
|
|
4027
|
+
__name(_ts_metadata23, "_ts_metadata");
|
|
4564
4028
|
exports.MicrosoftCalendarBookingService = class MicrosoftCalendarBookingService extends BaseCalendarBookingManagement {
|
|
4565
4029
|
static {
|
|
4566
4030
|
__name(this, "MicrosoftCalendarBookingService");
|
|
4567
4031
|
}
|
|
4568
4032
|
logger;
|
|
4569
4033
|
microsoftApiClient;
|
|
4570
|
-
fileName = "
|
|
4034
|
+
fileName = "booking-management.service";
|
|
4571
4035
|
constructor(logger, microsoftApiClient) {
|
|
4572
4036
|
super(), this.logger = logger, this.microsoftApiClient = microsoftApiClient;
|
|
4573
4037
|
}
|
|
@@ -4746,13 +4210,6 @@ exports.MicrosoftCalendarBookingService = class MicrosoftCalendarBookingService
|
|
|
4746
4210
|
void this.microsoftApiClient;
|
|
4747
4211
|
return Promise.reject(new common.NotImplementedException("MicrosoftCalendarBookingService.syncEvents is not implemented yet"));
|
|
4748
4212
|
}
|
|
4749
|
-
getRoomAvailability(request, integration, loggedInUserId) {
|
|
4750
|
-
this.logger.info(loggedInUserId, this.getRoomAvailability.name, this.fileName, "Get Microsoft Graph room availability", {
|
|
4751
|
-
resourceCount: request.resourceIds.length
|
|
4752
|
-
});
|
|
4753
|
-
void this.microsoftApiClient;
|
|
4754
|
-
return Promise.reject(new common.NotImplementedException("MicrosoftCalendarBookingService.getRoomAvailability is not implemented yet"));
|
|
4755
|
-
}
|
|
4756
4213
|
async deleteGraphEvent(mailboxEmail, resourceId, eventId, integration, loggedInUserId) {
|
|
4757
4214
|
this.assertResourceId(resourceId);
|
|
4758
4215
|
this.assertEventId(eventId);
|
|
@@ -4794,32 +4251,32 @@ exports.MicrosoftCalendarBookingService = class MicrosoftCalendarBookingService
|
|
|
4794
4251
|
}
|
|
4795
4252
|
}
|
|
4796
4253
|
};
|
|
4797
|
-
exports.MicrosoftCalendarBookingService =
|
|
4254
|
+
exports.MicrosoftCalendarBookingService = _ts_decorate28([
|
|
4798
4255
|
common.Injectable(),
|
|
4799
|
-
|
|
4800
|
-
|
|
4256
|
+
_ts_metadata23("design:type", Function),
|
|
4257
|
+
_ts_metadata23("design:paramtypes", [
|
|
4801
4258
|
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
|
|
4802
4259
|
typeof exports.MicrosoftApiClientService === "undefined" ? Object : exports.MicrosoftApiClientService
|
|
4803
4260
|
])
|
|
4804
4261
|
], exports.MicrosoftCalendarBookingService);
|
|
4805
|
-
function
|
|
4262
|
+
function _ts_decorate29(decorators, target, key, desc2) {
|
|
4806
4263
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4807
4264
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
4808
4265
|
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;
|
|
4809
4266
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4810
4267
|
}
|
|
4811
|
-
__name(
|
|
4812
|
-
function
|
|
4268
|
+
__name(_ts_decorate29, "_ts_decorate");
|
|
4269
|
+
function _ts_metadata24(k, v) {
|
|
4813
4270
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4814
4271
|
}
|
|
4815
|
-
__name(
|
|
4272
|
+
__name(_ts_metadata24, "_ts_metadata");
|
|
4816
4273
|
exports.MicrosoftCalendarResourceService = class MicrosoftCalendarResourceService extends BaseCalendarResourceManagement {
|
|
4817
4274
|
static {
|
|
4818
4275
|
__name(this, "MicrosoftCalendarResourceService");
|
|
4819
4276
|
}
|
|
4820
4277
|
logger;
|
|
4821
4278
|
microsoftApiClient;
|
|
4822
|
-
fileName = "
|
|
4279
|
+
fileName = "resource-management.service";
|
|
4823
4280
|
constructor(logger, microsoftApiClient) {
|
|
4824
4281
|
super(), this.logger = logger, this.microsoftApiClient = microsoftApiClient;
|
|
4825
4282
|
}
|
|
@@ -4855,25 +4312,25 @@ exports.MicrosoftCalendarResourceService = class MicrosoftCalendarResourceServic
|
|
|
4855
4312
|
};
|
|
4856
4313
|
}
|
|
4857
4314
|
};
|
|
4858
|
-
exports.MicrosoftCalendarResourceService =
|
|
4315
|
+
exports.MicrosoftCalendarResourceService = _ts_decorate29([
|
|
4859
4316
|
common.Injectable(),
|
|
4860
|
-
|
|
4861
|
-
|
|
4317
|
+
_ts_metadata24("design:type", Function),
|
|
4318
|
+
_ts_metadata24("design:paramtypes", [
|
|
4862
4319
|
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
|
|
4863
4320
|
typeof exports.MicrosoftApiClientService === "undefined" ? Object : exports.MicrosoftApiClientService
|
|
4864
4321
|
])
|
|
4865
4322
|
], exports.MicrosoftCalendarResourceService);
|
|
4866
|
-
function
|
|
4323
|
+
function _ts_decorate30(decorators, target, key, desc2) {
|
|
4867
4324
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4868
4325
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
4869
4326
|
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;
|
|
4870
4327
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4871
4328
|
}
|
|
4872
|
-
__name(
|
|
4873
|
-
function
|
|
4329
|
+
__name(_ts_decorate30, "_ts_decorate");
|
|
4330
|
+
function _ts_metadata25(k, v) {
|
|
4874
4331
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4875
4332
|
}
|
|
4876
|
-
__name(
|
|
4333
|
+
__name(_ts_metadata25, "_ts_metadata");
|
|
4877
4334
|
var GRAPH_SUBSCRIPTION_KNOWN_KEYS = /* @__PURE__ */ new Set([
|
|
4878
4335
|
"id",
|
|
4879
4336
|
"resource",
|
|
@@ -4888,7 +4345,7 @@ exports.MicrosoftCalendarWebhookService = class MicrosoftCalendarWebhookService
|
|
|
4888
4345
|
}
|
|
4889
4346
|
logger;
|
|
4890
4347
|
microsoftApiClient;
|
|
4891
|
-
fileName = "
|
|
4348
|
+
fileName = "webhook-management.service";
|
|
4892
4349
|
constructor(logger, microsoftApiClient) {
|
|
4893
4350
|
super(), this.logger = logger, this.microsoftApiClient = microsoftApiClient;
|
|
4894
4351
|
}
|
|
@@ -5007,31 +4464,31 @@ exports.MicrosoftCalendarWebhookService = class MicrosoftCalendarWebhookService
|
|
|
5007
4464
|
}
|
|
5008
4465
|
}
|
|
5009
4466
|
};
|
|
5010
|
-
exports.MicrosoftCalendarWebhookService =
|
|
4467
|
+
exports.MicrosoftCalendarWebhookService = _ts_decorate30([
|
|
5011
4468
|
common.Injectable(),
|
|
5012
|
-
|
|
5013
|
-
|
|
4469
|
+
_ts_metadata25("design:type", Function),
|
|
4470
|
+
_ts_metadata25("design:paramtypes", [
|
|
5014
4471
|
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
|
|
5015
4472
|
typeof exports.MicrosoftApiClientService === "undefined" ? Object : exports.MicrosoftApiClientService
|
|
5016
4473
|
])
|
|
5017
4474
|
], exports.MicrosoftCalendarWebhookService);
|
|
5018
|
-
function
|
|
4475
|
+
function _ts_decorate31(decorators, target, key, desc2) {
|
|
5019
4476
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
5020
4477
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
5021
4478
|
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;
|
|
5022
4479
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5023
4480
|
}
|
|
5024
|
-
__name(
|
|
5025
|
-
function
|
|
4481
|
+
__name(_ts_decorate31, "_ts_decorate");
|
|
4482
|
+
function _ts_metadata26(k, v) {
|
|
5026
4483
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
5027
4484
|
}
|
|
5028
|
-
__name(
|
|
5029
|
-
function
|
|
4485
|
+
__name(_ts_metadata26, "_ts_metadata");
|
|
4486
|
+
function _ts_param15(paramIndex, decorator) {
|
|
5030
4487
|
return function(target, key) {
|
|
5031
4488
|
decorator(target, key, paramIndex);
|
|
5032
4489
|
};
|
|
5033
4490
|
}
|
|
5034
|
-
__name(
|
|
4491
|
+
__name(_ts_param15, "_ts_param");
|
|
5035
4492
|
var MICROSOFT_SECURE_STORAGE_OPTIONS = {
|
|
5036
4493
|
useSecureStorage: true,
|
|
5037
4494
|
get kmsKeyId() {
|
|
@@ -5058,22 +4515,19 @@ exports.MicrosoftIntegrationConfigurationService = class MicrosoftIntegrationCon
|
|
|
5058
4515
|
clientSecret: integrationConfig.clientSecret
|
|
5059
4516
|
}, rawConfig);
|
|
5060
4517
|
const token = await this.microsoftAuthService.getAccessToken({
|
|
5061
|
-
config: microsoftConfig
|
|
4518
|
+
config: microsoftConfig,
|
|
4519
|
+
capabilityId: input.capabilityId,
|
|
4520
|
+
providerId: input.capabilityProviderId
|
|
5062
4521
|
}, context.loggedInUserId, true);
|
|
5063
|
-
|
|
4522
|
+
const result = await super.addCapabilityIntegration({
|
|
5064
4523
|
...input,
|
|
5065
|
-
config:
|
|
5066
|
-
...microsoftConfig,
|
|
5067
|
-
accessDetails: {
|
|
5068
|
-
accessToken: token.accessToken,
|
|
5069
|
-
expiryAt: new Date(Date.now() + token.expiresIn * 1e3).toISOString(),
|
|
5070
|
-
tokenType: token.tokenType || MICROSOFT_DEFAULT_ACCESS_TOKEN_TYPE
|
|
5071
|
-
}
|
|
5072
|
-
}
|
|
4524
|
+
config: microsoftConfig
|
|
5073
4525
|
}, context, {
|
|
5074
4526
|
useSecureStorage: MICROSOFT_SECURE_STORAGE_OPTIONS.useSecureStorage,
|
|
5075
4527
|
kmsKeyId: MICROSOFT_SECURE_STORAGE_OPTIONS.kmsKeyId
|
|
5076
4528
|
});
|
|
4529
|
+
await this.microsoftAuthService.persistMintedAccessToken(BigInt(result.id), token, context.loggedInUserId);
|
|
4530
|
+
return result;
|
|
5077
4531
|
}
|
|
5078
4532
|
async updateCapabilityIntegration(request, integration, loggedInUserId) {
|
|
5079
4533
|
if (!request.updateData.config) {
|
|
@@ -5096,33 +4550,25 @@ exports.MicrosoftIntegrationConfigurationService = class MicrosoftIntegrationCon
|
|
|
5096
4550
|
const mergedConfig = buildMicrosoftIntegrationConfig(mergedCredentials, platformConfig ? {
|
|
5097
4551
|
platformConfig
|
|
5098
4552
|
} : void 0);
|
|
5099
|
-
|
|
4553
|
+
await this.microsoftAuthService.getAccessToken({
|
|
5100
4554
|
id: request.id,
|
|
5101
|
-
config: mergedConfig
|
|
4555
|
+
config: mergedConfig,
|
|
4556
|
+
capabilityId: integration?.capabilityId,
|
|
4557
|
+
providerId: integration?.providerId
|
|
5102
4558
|
}, loggedInUserId, true);
|
|
5103
|
-
const accessDetails = {
|
|
5104
|
-
accessToken: token.accessToken,
|
|
5105
|
-
expiryAt: new Date(Date.now() + token.expiresIn * 1e3).toISOString(),
|
|
5106
|
-
tokenType: token.tokenType || MICROSOFT_DEFAULT_ACCESS_TOKEN_TYPE
|
|
5107
|
-
};
|
|
5108
|
-
const configWithAccessDetails = {
|
|
5109
|
-
...mergedConfig,
|
|
5110
|
-
accessDetails
|
|
5111
|
-
};
|
|
5112
4559
|
const updateRequest = {
|
|
5113
4560
|
...request,
|
|
5114
4561
|
updateData: {
|
|
5115
4562
|
...request.updateData,
|
|
5116
4563
|
config: {
|
|
5117
4564
|
...request.updateData.config,
|
|
5118
|
-
...
|
|
5119
|
-
accessDetails
|
|
4565
|
+
...mergedConfig
|
|
5120
4566
|
}
|
|
5121
4567
|
}
|
|
5122
4568
|
};
|
|
5123
4569
|
const integrationForUpdate = integration ? {
|
|
5124
4570
|
...integration,
|
|
5125
|
-
config:
|
|
4571
|
+
config: mergedConfig
|
|
5126
4572
|
} : integration;
|
|
5127
4573
|
return super.updateCapabilityIntegration(updateRequest, integrationForUpdate, loggedInUserId, {
|
|
5128
4574
|
useSecureStorage: MICROSOFT_SECURE_STORAGE_OPTIONS.useSecureStorage,
|
|
@@ -5130,14 +4576,14 @@ exports.MicrosoftIntegrationConfigurationService = class MicrosoftIntegrationCon
|
|
|
5130
4576
|
});
|
|
5131
4577
|
}
|
|
5132
4578
|
};
|
|
5133
|
-
exports.MicrosoftIntegrationConfigurationService =
|
|
4579
|
+
exports.MicrosoftIntegrationConfigurationService = _ts_decorate31([
|
|
5134
4580
|
common.Injectable(),
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
4581
|
+
_ts_param15(4, common.Optional()),
|
|
4582
|
+
_ts_param15(4, common.Inject(exports.IntegrationConfigSecureStorageService)),
|
|
4583
|
+
_ts_param15(5, common.Optional()),
|
|
4584
|
+
_ts_param15(5, common.Inject(dvssBackendModuleUtility.SECRET_PROVIDER)),
|
|
4585
|
+
_ts_metadata26("design:type", Function),
|
|
4586
|
+
_ts_metadata26("design:paramtypes", [
|
|
5141
4587
|
typeof exports.IntegrationConfigurationDao === "undefined" ? Object : exports.IntegrationConfigurationDao,
|
|
5142
4588
|
typeof dvssBackendModuleDatastore.CommonValidationDatabaseService === "undefined" ? Object : dvssBackendModuleDatastore.CommonValidationDatabaseService,
|
|
5143
4589
|
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
|
|
@@ -5148,24 +4594,25 @@ exports.MicrosoftIntegrationConfigurationService = _ts_decorate22([
|
|
|
5148
4594
|
], exports.MicrosoftIntegrationConfigurationService);
|
|
5149
4595
|
|
|
5150
4596
|
// ../../packages/dvss-integration-microsoft/src/app.module.ts
|
|
5151
|
-
function
|
|
4597
|
+
function _ts_decorate32(decorators, target, key, desc2) {
|
|
5152
4598
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
5153
4599
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
5154
4600
|
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;
|
|
5155
4601
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5156
4602
|
}
|
|
5157
|
-
__name(
|
|
4603
|
+
__name(_ts_decorate32, "_ts_decorate");
|
|
5158
4604
|
exports.IntegrationMicrosoftModule = class AppModule2 {
|
|
5159
4605
|
static {
|
|
5160
4606
|
__name(this, "AppModule");
|
|
5161
4607
|
}
|
|
5162
4608
|
};
|
|
5163
|
-
exports.IntegrationMicrosoftModule =
|
|
4609
|
+
exports.IntegrationMicrosoftModule = _ts_decorate32([
|
|
5164
4610
|
common.Module({
|
|
5165
4611
|
imports: [
|
|
5166
4612
|
exports.IntegrationLibsModule,
|
|
5167
4613
|
dvssBackendModuleUtility.LoggerModule,
|
|
5168
|
-
dvssBackendModuleDatastore.DatastoreModule
|
|
4614
|
+
dvssBackendModuleDatastore.DatastoreModule,
|
|
4615
|
+
IntegrationOauthModule
|
|
5169
4616
|
],
|
|
5170
4617
|
providers: [
|
|
5171
4618
|
exports.MicrosoftAuthService,
|
|
@@ -5189,18 +4636,20 @@ exports.IntegrationMicrosoftModule = _ts_decorate23([
|
|
|
5189
4636
|
exports.MicrosoftCalendarResourceService,
|
|
5190
4637
|
exports.MicrosoftCalendarBookingService,
|
|
5191
4638
|
exports.MicrosoftCalendarWebhookService,
|
|
4639
|
+
exports.IntegrationSubcapabilityDao,
|
|
5192
4640
|
exports.IntegrationConfigurationDao,
|
|
5193
|
-
dvssBackendModuleDatastore.CommonValidationDatabaseService
|
|
4641
|
+
dvssBackendModuleDatastore.CommonValidationDatabaseService,
|
|
4642
|
+
IntegrationOauthModule
|
|
5194
4643
|
]
|
|
5195
4644
|
})
|
|
5196
4645
|
], exports.IntegrationMicrosoftModule);
|
|
5197
|
-
function
|
|
4646
|
+
function _ts_decorate33(decorators, target, key, desc2) {
|
|
5198
4647
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
5199
4648
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
5200
4649
|
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;
|
|
5201
4650
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5202
4651
|
}
|
|
5203
|
-
__name(
|
|
4652
|
+
__name(_ts_decorate33, "_ts_decorate");
|
|
5204
4653
|
exports.AdapterFactoryService = class AdapterFactoryService {
|
|
5205
4654
|
static {
|
|
5206
4655
|
__name(this, "AdapterFactoryService");
|
|
@@ -5213,7 +4662,7 @@ exports.AdapterFactoryService = class AdapterFactoryService {
|
|
|
5213
4662
|
return adapter;
|
|
5214
4663
|
}
|
|
5215
4664
|
};
|
|
5216
|
-
exports.AdapterFactoryService =
|
|
4665
|
+
exports.AdapterFactoryService = _ts_decorate33([
|
|
5217
4666
|
common.Injectable()
|
|
5218
4667
|
], exports.AdapterFactoryService);
|
|
5219
4668
|
|
|
@@ -5231,17 +4680,17 @@ var ICalendarAuthHandler = class {
|
|
|
5231
4680
|
};
|
|
5232
4681
|
|
|
5233
4682
|
// src/providers/microsoft/microsoft-calendar-auth.handler.ts
|
|
5234
|
-
function
|
|
4683
|
+
function _ts_decorate34(decorators, target, key, desc2) {
|
|
5235
4684
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
5236
4685
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
5237
4686
|
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;
|
|
5238
4687
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5239
4688
|
}
|
|
5240
|
-
__name(
|
|
5241
|
-
function
|
|
4689
|
+
__name(_ts_decorate34, "_ts_decorate");
|
|
4690
|
+
function _ts_metadata27(k, v) {
|
|
5242
4691
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
5243
4692
|
}
|
|
5244
|
-
__name(
|
|
4693
|
+
__name(_ts_metadata27, "_ts_metadata");
|
|
5245
4694
|
exports.MicrosoftCalendarAuthHandler = class MicrosoftCalendarAuthHandler extends ICalendarAuthHandler {
|
|
5246
4695
|
static {
|
|
5247
4696
|
__name(this, "MicrosoftCalendarAuthHandler");
|
|
@@ -5260,26 +4709,26 @@ exports.MicrosoftCalendarAuthHandler = class MicrosoftCalendarAuthHandler extend
|
|
|
5260
4709
|
return this.microsoftAuthService.fetchAccessToken(integration, loggedInUserId);
|
|
5261
4710
|
}
|
|
5262
4711
|
};
|
|
5263
|
-
exports.MicrosoftCalendarAuthHandler =
|
|
4712
|
+
exports.MicrosoftCalendarAuthHandler = _ts_decorate34([
|
|
5264
4713
|
common.Injectable(),
|
|
5265
|
-
|
|
5266
|
-
|
|
4714
|
+
_ts_metadata27("design:type", Function),
|
|
4715
|
+
_ts_metadata27("design:paramtypes", [
|
|
5267
4716
|
typeof exports.MicrosoftAuthService === "undefined" ? Object : exports.MicrosoftAuthService
|
|
5268
4717
|
])
|
|
5269
4718
|
], exports.MicrosoftCalendarAuthHandler);
|
|
5270
4719
|
|
|
5271
4720
|
// src/adapters/calendar-auth.adapter.factory.ts
|
|
5272
|
-
function
|
|
4721
|
+
function _ts_decorate35(decorators, target, key, desc2) {
|
|
5273
4722
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
5274
4723
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
5275
4724
|
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;
|
|
5276
4725
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5277
4726
|
}
|
|
5278
|
-
__name(
|
|
5279
|
-
function
|
|
4727
|
+
__name(_ts_decorate35, "_ts_decorate");
|
|
4728
|
+
function _ts_metadata28(k, v) {
|
|
5280
4729
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
5281
4730
|
}
|
|
5282
|
-
__name(
|
|
4731
|
+
__name(_ts_metadata28, "_ts_metadata");
|
|
5283
4732
|
exports.CalendarAuthAdapterFactory = class CalendarAuthAdapterFactory extends exports.AdapterFactoryService {
|
|
5284
4733
|
static {
|
|
5285
4734
|
__name(this, "CalendarAuthAdapterFactory");
|
|
@@ -5292,10 +4741,10 @@ exports.CalendarAuthAdapterFactory = class CalendarAuthAdapterFactory extends ex
|
|
|
5292
4741
|
};
|
|
5293
4742
|
}
|
|
5294
4743
|
};
|
|
5295
|
-
exports.CalendarAuthAdapterFactory =
|
|
4744
|
+
exports.CalendarAuthAdapterFactory = _ts_decorate35([
|
|
5296
4745
|
common.Injectable(),
|
|
5297
|
-
|
|
5298
|
-
|
|
4746
|
+
_ts_metadata28("design:type", Function),
|
|
4747
|
+
_ts_metadata28("design:paramtypes", [
|
|
5299
4748
|
typeof exports.MicrosoftCalendarAuthHandler === "undefined" ? Object : exports.MicrosoftCalendarAuthHandler
|
|
5300
4749
|
])
|
|
5301
4750
|
], exports.CalendarAuthAdapterFactory);
|
|
@@ -5308,17 +4757,17 @@ var ICalendarBookingHandler = class {
|
|
|
5308
4757
|
};
|
|
5309
4758
|
|
|
5310
4759
|
// src/providers/microsoft/microsoft-calendar-booking.handler.ts
|
|
5311
|
-
function
|
|
4760
|
+
function _ts_decorate36(decorators, target, key, desc2) {
|
|
5312
4761
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
5313
4762
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
5314
4763
|
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;
|
|
5315
4764
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5316
4765
|
}
|
|
5317
|
-
__name(
|
|
5318
|
-
function
|
|
4766
|
+
__name(_ts_decorate36, "_ts_decorate");
|
|
4767
|
+
function _ts_metadata29(k, v) {
|
|
5319
4768
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
5320
4769
|
}
|
|
5321
|
-
__name(
|
|
4770
|
+
__name(_ts_metadata29, "_ts_metadata");
|
|
5322
4771
|
exports.MicrosoftCalendarBookingHandler = class MicrosoftCalendarBookingHandler extends ICalendarBookingHandler {
|
|
5323
4772
|
static {
|
|
5324
4773
|
__name(this, "MicrosoftCalendarBookingHandler");
|
|
@@ -5348,30 +4797,27 @@ exports.MicrosoftCalendarBookingHandler = class MicrosoftCalendarBookingHandler
|
|
|
5348
4797
|
async syncCalendarBookings(request, integration, loggedInUserId) {
|
|
5349
4798
|
return this.microsoftCalendarBookingService.syncEvents(request, integration, loggedInUserId);
|
|
5350
4799
|
}
|
|
5351
|
-
async getRoomAvailability(request, integration, loggedInUserId) {
|
|
5352
|
-
return this.microsoftCalendarBookingService.getRoomAvailability(request, integration, loggedInUserId);
|
|
5353
|
-
}
|
|
5354
4800
|
};
|
|
5355
|
-
exports.MicrosoftCalendarBookingHandler =
|
|
4801
|
+
exports.MicrosoftCalendarBookingHandler = _ts_decorate36([
|
|
5356
4802
|
common.Injectable(),
|
|
5357
|
-
|
|
5358
|
-
|
|
4803
|
+
_ts_metadata29("design:type", Function),
|
|
4804
|
+
_ts_metadata29("design:paramtypes", [
|
|
5359
4805
|
typeof exports.MicrosoftCalendarBookingService === "undefined" ? Object : exports.MicrosoftCalendarBookingService
|
|
5360
4806
|
])
|
|
5361
4807
|
], exports.MicrosoftCalendarBookingHandler);
|
|
5362
4808
|
|
|
5363
4809
|
// src/adapters/calendar-booking.adapter.factory.ts
|
|
5364
|
-
function
|
|
4810
|
+
function _ts_decorate37(decorators, target, key, desc2) {
|
|
5365
4811
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
5366
4812
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
5367
4813
|
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;
|
|
5368
4814
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5369
4815
|
}
|
|
5370
|
-
__name(
|
|
5371
|
-
function
|
|
4816
|
+
__name(_ts_decorate37, "_ts_decorate");
|
|
4817
|
+
function _ts_metadata30(k, v) {
|
|
5372
4818
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
5373
4819
|
}
|
|
5374
|
-
__name(
|
|
4820
|
+
__name(_ts_metadata30, "_ts_metadata");
|
|
5375
4821
|
exports.CalendarBookingAdapterFactory = class CalendarBookingAdapterFactory extends exports.AdapterFactoryService {
|
|
5376
4822
|
static {
|
|
5377
4823
|
__name(this, "CalendarBookingAdapterFactory");
|
|
@@ -5384,10 +4830,10 @@ exports.CalendarBookingAdapterFactory = class CalendarBookingAdapterFactory exte
|
|
|
5384
4830
|
};
|
|
5385
4831
|
}
|
|
5386
4832
|
};
|
|
5387
|
-
exports.CalendarBookingAdapterFactory =
|
|
4833
|
+
exports.CalendarBookingAdapterFactory = _ts_decorate37([
|
|
5388
4834
|
common.Injectable(),
|
|
5389
|
-
|
|
5390
|
-
|
|
4835
|
+
_ts_metadata30("design:type", Function),
|
|
4836
|
+
_ts_metadata30("design:paramtypes", [
|
|
5391
4837
|
typeof exports.MicrosoftCalendarBookingHandler === "undefined" ? Object : exports.MicrosoftCalendarBookingHandler
|
|
5392
4838
|
])
|
|
5393
4839
|
], exports.CalendarBookingAdapterFactory);
|
|
@@ -5400,17 +4846,17 @@ var ICalendarIntegrationConfigurationHandler = class {
|
|
|
5400
4846
|
};
|
|
5401
4847
|
|
|
5402
4848
|
// src/providers/microsoft/microsoft-calendar-integration-configuration.handler.ts
|
|
5403
|
-
function
|
|
4849
|
+
function _ts_decorate38(decorators, target, key, desc2) {
|
|
5404
4850
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
5405
4851
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
5406
4852
|
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;
|
|
5407
4853
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5408
4854
|
}
|
|
5409
|
-
__name(
|
|
5410
|
-
function
|
|
4855
|
+
__name(_ts_decorate38, "_ts_decorate");
|
|
4856
|
+
function _ts_metadata31(k, v) {
|
|
5411
4857
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
5412
4858
|
}
|
|
5413
|
-
__name(
|
|
4859
|
+
__name(_ts_metadata31, "_ts_metadata");
|
|
5414
4860
|
exports.MicrosoftCalendarIntegrationConfigurationHandler = class MicrosoftCalendarIntegrationConfigurationHandler extends ICalendarIntegrationConfigurationHandler {
|
|
5415
4861
|
static {
|
|
5416
4862
|
__name(this, "MicrosoftCalendarIntegrationConfigurationHandler");
|
|
@@ -5432,26 +4878,26 @@ exports.MicrosoftCalendarIntegrationConfigurationHandler = class MicrosoftCalend
|
|
|
5432
4878
|
return this.microsoftIntegrationConfigurationService.getCapabilityIntegration(input, context);
|
|
5433
4879
|
}
|
|
5434
4880
|
};
|
|
5435
|
-
exports.MicrosoftCalendarIntegrationConfigurationHandler =
|
|
4881
|
+
exports.MicrosoftCalendarIntegrationConfigurationHandler = _ts_decorate38([
|
|
5436
4882
|
common.Injectable(),
|
|
5437
|
-
|
|
5438
|
-
|
|
4883
|
+
_ts_metadata31("design:type", Function),
|
|
4884
|
+
_ts_metadata31("design:paramtypes", [
|
|
5439
4885
|
typeof exports.MicrosoftIntegrationConfigurationService === "undefined" ? Object : exports.MicrosoftIntegrationConfigurationService
|
|
5440
4886
|
])
|
|
5441
4887
|
], exports.MicrosoftCalendarIntegrationConfigurationHandler);
|
|
5442
4888
|
|
|
5443
4889
|
// src/adapters/calendar-integration-configuration.adapter.factory.ts
|
|
5444
|
-
function
|
|
4890
|
+
function _ts_decorate39(decorators, target, key, desc2) {
|
|
5445
4891
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
5446
4892
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
5447
4893
|
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;
|
|
5448
4894
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5449
4895
|
}
|
|
5450
|
-
__name(
|
|
5451
|
-
function
|
|
4896
|
+
__name(_ts_decorate39, "_ts_decorate");
|
|
4897
|
+
function _ts_metadata32(k, v) {
|
|
5452
4898
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
5453
4899
|
}
|
|
5454
|
-
__name(
|
|
4900
|
+
__name(_ts_metadata32, "_ts_metadata");
|
|
5455
4901
|
exports.CalendarIntegrationConfigurationAdapterFactory = class CalendarIntegrationConfigurationAdapterFactory extends exports.AdapterFactoryService {
|
|
5456
4902
|
static {
|
|
5457
4903
|
__name(this, "CalendarIntegrationConfigurationAdapterFactory");
|
|
@@ -5464,10 +4910,10 @@ exports.CalendarIntegrationConfigurationAdapterFactory = class CalendarIntegrati
|
|
|
5464
4910
|
};
|
|
5465
4911
|
}
|
|
5466
4912
|
};
|
|
5467
|
-
exports.CalendarIntegrationConfigurationAdapterFactory =
|
|
4913
|
+
exports.CalendarIntegrationConfigurationAdapterFactory = _ts_decorate39([
|
|
5468
4914
|
common.Injectable(),
|
|
5469
|
-
|
|
5470
|
-
|
|
4915
|
+
_ts_metadata32("design:type", Function),
|
|
4916
|
+
_ts_metadata32("design:paramtypes", [
|
|
5471
4917
|
typeof exports.MicrosoftCalendarIntegrationConfigurationHandler === "undefined" ? Object : exports.MicrosoftCalendarIntegrationConfigurationHandler
|
|
5472
4918
|
])
|
|
5473
4919
|
], exports.CalendarIntegrationConfigurationAdapterFactory);
|
|
@@ -5480,17 +4926,17 @@ var ICalendarResourceHandler = class {
|
|
|
5480
4926
|
};
|
|
5481
4927
|
|
|
5482
4928
|
// src/providers/microsoft/microsoft-calendar-resource.handler.ts
|
|
5483
|
-
function
|
|
4929
|
+
function _ts_decorate40(decorators, target, key, desc2) {
|
|
5484
4930
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
5485
4931
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
5486
4932
|
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;
|
|
5487
4933
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5488
4934
|
}
|
|
5489
|
-
__name(
|
|
5490
|
-
function
|
|
4935
|
+
__name(_ts_decorate40, "_ts_decorate");
|
|
4936
|
+
function _ts_metadata33(k, v) {
|
|
5491
4937
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
5492
4938
|
}
|
|
5493
|
-
__name(
|
|
4939
|
+
__name(_ts_metadata33, "_ts_metadata");
|
|
5494
4940
|
exports.MicrosoftCalendarResourceHandler = class MicrosoftCalendarResourceHandler extends ICalendarResourceHandler {
|
|
5495
4941
|
static {
|
|
5496
4942
|
__name(this, "MicrosoftCalendarResourceHandler");
|
|
@@ -5503,26 +4949,26 @@ exports.MicrosoftCalendarResourceHandler = class MicrosoftCalendarResourceHandle
|
|
|
5503
4949
|
return this.microsoftCalendarResourceService.getResources(request, integration, loggedInUserId);
|
|
5504
4950
|
}
|
|
5505
4951
|
};
|
|
5506
|
-
exports.MicrosoftCalendarResourceHandler =
|
|
4952
|
+
exports.MicrosoftCalendarResourceHandler = _ts_decorate40([
|
|
5507
4953
|
common.Injectable(),
|
|
5508
|
-
|
|
5509
|
-
|
|
4954
|
+
_ts_metadata33("design:type", Function),
|
|
4955
|
+
_ts_metadata33("design:paramtypes", [
|
|
5510
4956
|
typeof exports.MicrosoftCalendarResourceService === "undefined" ? Object : exports.MicrosoftCalendarResourceService
|
|
5511
4957
|
])
|
|
5512
4958
|
], exports.MicrosoftCalendarResourceHandler);
|
|
5513
4959
|
|
|
5514
4960
|
// src/adapters/calendar-resource.adapter.factory.ts
|
|
5515
|
-
function
|
|
4961
|
+
function _ts_decorate41(decorators, target, key, desc2) {
|
|
5516
4962
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
5517
4963
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
5518
4964
|
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;
|
|
5519
4965
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5520
4966
|
}
|
|
5521
|
-
__name(
|
|
5522
|
-
function
|
|
4967
|
+
__name(_ts_decorate41, "_ts_decorate");
|
|
4968
|
+
function _ts_metadata34(k, v) {
|
|
5523
4969
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
5524
4970
|
}
|
|
5525
|
-
__name(
|
|
4971
|
+
__name(_ts_metadata34, "_ts_metadata");
|
|
5526
4972
|
exports.CalendarResourceAdapterFactory = class CalendarResourceAdapterFactory extends exports.AdapterFactoryService {
|
|
5527
4973
|
static {
|
|
5528
4974
|
__name(this, "CalendarResourceAdapterFactory");
|
|
@@ -5535,10 +4981,10 @@ exports.CalendarResourceAdapterFactory = class CalendarResourceAdapterFactory ex
|
|
|
5535
4981
|
};
|
|
5536
4982
|
}
|
|
5537
4983
|
};
|
|
5538
|
-
exports.CalendarResourceAdapterFactory =
|
|
4984
|
+
exports.CalendarResourceAdapterFactory = _ts_decorate41([
|
|
5539
4985
|
common.Injectable(),
|
|
5540
|
-
|
|
5541
|
-
|
|
4986
|
+
_ts_metadata34("design:type", Function),
|
|
4987
|
+
_ts_metadata34("design:paramtypes", [
|
|
5542
4988
|
typeof exports.MicrosoftCalendarResourceHandler === "undefined" ? Object : exports.MicrosoftCalendarResourceHandler
|
|
5543
4989
|
])
|
|
5544
4990
|
], exports.CalendarResourceAdapterFactory);
|
|
@@ -5551,17 +4997,17 @@ var ICalendarWebhookHandler = class {
|
|
|
5551
4997
|
};
|
|
5552
4998
|
|
|
5553
4999
|
// src/providers/microsoft/microsoft-calendar-webhook.handler.ts
|
|
5554
|
-
function
|
|
5000
|
+
function _ts_decorate42(decorators, target, key, desc2) {
|
|
5555
5001
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
5556
5002
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
5557
5003
|
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;
|
|
5558
5004
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5559
5005
|
}
|
|
5560
|
-
__name(
|
|
5561
|
-
function
|
|
5006
|
+
__name(_ts_decorate42, "_ts_decorate");
|
|
5007
|
+
function _ts_metadata35(k, v) {
|
|
5562
5008
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
5563
5009
|
}
|
|
5564
|
-
__name(
|
|
5010
|
+
__name(_ts_metadata35, "_ts_metadata");
|
|
5565
5011
|
exports.MicrosoftCalendarWebhookHandler = class MicrosoftCalendarWebhookHandler extends ICalendarWebhookHandler {
|
|
5566
5012
|
static {
|
|
5567
5013
|
__name(this, "MicrosoftCalendarWebhookHandler");
|
|
@@ -5580,26 +5026,26 @@ exports.MicrosoftCalendarWebhookHandler = class MicrosoftCalendarWebhookHandler
|
|
|
5580
5026
|
return this.microsoftCalendarWebhookService.deleteSubscription(request, integration, loggedInUserId);
|
|
5581
5027
|
}
|
|
5582
5028
|
};
|
|
5583
|
-
exports.MicrosoftCalendarWebhookHandler =
|
|
5029
|
+
exports.MicrosoftCalendarWebhookHandler = _ts_decorate42([
|
|
5584
5030
|
common.Injectable(),
|
|
5585
|
-
|
|
5586
|
-
|
|
5031
|
+
_ts_metadata35("design:type", Function),
|
|
5032
|
+
_ts_metadata35("design:paramtypes", [
|
|
5587
5033
|
typeof exports.MicrosoftCalendarWebhookService === "undefined" ? Object : exports.MicrosoftCalendarWebhookService
|
|
5588
5034
|
])
|
|
5589
5035
|
], exports.MicrosoftCalendarWebhookHandler);
|
|
5590
5036
|
|
|
5591
5037
|
// src/adapters/calendar-webhook.adapter.factory.ts
|
|
5592
|
-
function
|
|
5038
|
+
function _ts_decorate43(decorators, target, key, desc2) {
|
|
5593
5039
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
5594
5040
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
5595
5041
|
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;
|
|
5596
5042
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5597
5043
|
}
|
|
5598
|
-
__name(
|
|
5599
|
-
function
|
|
5044
|
+
__name(_ts_decorate43, "_ts_decorate");
|
|
5045
|
+
function _ts_metadata36(k, v) {
|
|
5600
5046
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
5601
5047
|
}
|
|
5602
|
-
__name(
|
|
5048
|
+
__name(_ts_metadata36, "_ts_metadata");
|
|
5603
5049
|
exports.CalendarWebhookAdapterFactory = class CalendarWebhookAdapterFactory extends exports.AdapterFactoryService {
|
|
5604
5050
|
static {
|
|
5605
5051
|
__name(this, "CalendarWebhookAdapterFactory");
|
|
@@ -5612,22 +5058,22 @@ exports.CalendarWebhookAdapterFactory = class CalendarWebhookAdapterFactory exte
|
|
|
5612
5058
|
};
|
|
5613
5059
|
}
|
|
5614
5060
|
};
|
|
5615
|
-
exports.CalendarWebhookAdapterFactory =
|
|
5061
|
+
exports.CalendarWebhookAdapterFactory = _ts_decorate43([
|
|
5616
5062
|
common.Injectable(),
|
|
5617
|
-
|
|
5618
|
-
|
|
5063
|
+
_ts_metadata36("design:type", Function),
|
|
5064
|
+
_ts_metadata36("design:paramtypes", [
|
|
5619
5065
|
typeof exports.MicrosoftCalendarWebhookHandler === "undefined" ? Object : exports.MicrosoftCalendarWebhookHandler
|
|
5620
5066
|
])
|
|
5621
5067
|
], exports.CalendarWebhookAdapterFactory);
|
|
5622
5068
|
|
|
5623
5069
|
// src/app.module.ts
|
|
5624
|
-
function
|
|
5070
|
+
function _ts_decorate44(decorators, target, key, desc2) {
|
|
5625
5071
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
5626
5072
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
5627
5073
|
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;
|
|
5628
5074
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5629
5075
|
}
|
|
5630
|
-
__name(
|
|
5076
|
+
__name(_ts_decorate44, "_ts_decorate");
|
|
5631
5077
|
var microsoftHandlers = [
|
|
5632
5078
|
exports.MicrosoftCalendarBookingHandler,
|
|
5633
5079
|
exports.MicrosoftCalendarResourceHandler,
|
|
@@ -5647,7 +5093,7 @@ exports.CalendarIntegrationManager = class AppModule3 {
|
|
|
5647
5093
|
__name(this, "AppModule");
|
|
5648
5094
|
}
|
|
5649
5095
|
};
|
|
5650
|
-
exports.CalendarIntegrationManager =
|
|
5096
|
+
exports.CalendarIntegrationManager = _ts_decorate44([
|
|
5651
5097
|
common.Module({
|
|
5652
5098
|
imports: [
|
|
5653
5099
|
exports.IntegrationLibsModule,
|