@dv4resi/dvss-backend-module-offering-im 0.0.21 → 0.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +276 -85
- package/dist/index.js +968 -335
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -177,7 +177,7 @@ exports.IntegrationRequestLoggerService = class _IntegrationRequestLoggerService
|
|
|
177
177
|
integrationId: logData.integrationId,
|
|
178
178
|
method,
|
|
179
179
|
url,
|
|
180
|
-
headers,
|
|
180
|
+
headers: this.sanitizeHeaders(headers),
|
|
181
181
|
requestBody,
|
|
182
182
|
timestamp: logData.timestamp || /* @__PURE__ */ new Date()
|
|
183
183
|
});
|
|
@@ -232,6 +232,33 @@ exports.IntegrationRequestLoggerService = class _IntegrationRequestLoggerService
|
|
|
232
232
|
this.logRequest(logData);
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* Sanitize headers to remove sensitive information
|
|
237
|
+
*
|
|
238
|
+
* @param headers - The headers to sanitize
|
|
239
|
+
* @returns Sanitized headers
|
|
240
|
+
*/
|
|
241
|
+
sanitizeHeaders(headers) {
|
|
242
|
+
if (!headers) {
|
|
243
|
+
return void 0;
|
|
244
|
+
}
|
|
245
|
+
const sanitized = {
|
|
246
|
+
...headers
|
|
247
|
+
};
|
|
248
|
+
const sensitiveKeys = [
|
|
249
|
+
"authorization",
|
|
250
|
+
"api-key",
|
|
251
|
+
"apikey",
|
|
252
|
+
"x-api-key",
|
|
253
|
+
"cookie"
|
|
254
|
+
];
|
|
255
|
+
for (const key of Object.keys(sanitized)) {
|
|
256
|
+
if (sensitiveKeys.includes(key.toLowerCase())) {
|
|
257
|
+
sanitized[key] = "***REDACTED***";
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return sanitized;
|
|
261
|
+
}
|
|
235
262
|
};
|
|
236
263
|
exports.IntegrationRequestLoggerService = _ts_decorate5([
|
|
237
264
|
common.Injectable(),
|
|
@@ -329,7 +356,7 @@ exports.TrafficGatewayService = class TrafficGatewayService {
|
|
|
329
356
|
} catch (error) {
|
|
330
357
|
const duration = Date.now() - startTime;
|
|
331
358
|
const errorDetails = this.extractErrorDetails(error);
|
|
332
|
-
const baseUrl =
|
|
359
|
+
const baseUrl = request.baseUrl;
|
|
333
360
|
const fullUrl = this.constructFullUrl(baseUrl, request.url);
|
|
334
361
|
this.requestLogger.logError({
|
|
335
362
|
integrationId: integration.id,
|
|
@@ -527,7 +554,7 @@ exports.IntegrationLibsModule = _ts_decorate8([
|
|
|
527
554
|
// ../../packages/dvss-integration-libs/src/integration-traffic-router/constants/traffic-router.constant.ts
|
|
528
555
|
var TRAFFIC_ROUTER_CONFIGURATION_STORE_KEY = "traffic-router-configuration-store";
|
|
529
556
|
|
|
530
|
-
// ../../packages/dvss-integration-libs/src/integration-operation-skeletons/capabilities/auth/auth.base.ts
|
|
557
|
+
// ../../packages/dvss-integration-libs/src/integration-operation-skeletons/capabilities/auth-management/auth.base.ts
|
|
531
558
|
var BaseAuth = class {
|
|
532
559
|
static {
|
|
533
560
|
__name(this, "BaseAuth");
|
|
@@ -556,6 +583,9 @@ var CREDIT_FILTER_BY_ENUM = /* @__PURE__ */ (function(CREDIT_FILTER_BY_ENUM2) {
|
|
|
556
583
|
// ../../packages/dvss-integration-libs/src/integration-operation-skeletons/models/capability-integration.model.ts
|
|
557
584
|
var INTEGRATION_PROVIDER_ENUM = /* @__PURE__ */ (function(INTEGRATION_PROVIDER_ENUM2) {
|
|
558
585
|
INTEGRATION_PROVIDER_ENUM2["TRYBE"] = "TRYBE";
|
|
586
|
+
INTEGRATION_PROVIDER_ENUM2["SUPREMA_BIOSTAR"] = "SUPREMA_BIOSTAR";
|
|
587
|
+
INTEGRATION_PROVIDER_ENUM2["SALTO_PRO"] = "SALTO_PRO";
|
|
588
|
+
INTEGRATION_PROVIDER_ENUM2["SCHINDLER"] = "SCHINDLER";
|
|
559
589
|
return INTEGRATION_PROVIDER_ENUM2;
|
|
560
590
|
})({});
|
|
561
591
|
|
|
@@ -818,6 +848,14 @@ exports.BaseIntegrationConfiguration = class BaseIntegrationConfiguration {
|
|
|
818
848
|
icon: updateData.icon,
|
|
819
849
|
config: configToUpdate,
|
|
820
850
|
parentId: updateData.parentId,
|
|
851
|
+
propertyId: updateData.propertyId,
|
|
852
|
+
capabilityId: updateData.capabilityId,
|
|
853
|
+
providerId: updateData.capabilityProviderId,
|
|
854
|
+
subcategory: updateData.subcategory,
|
|
855
|
+
capabilityIntegrationResourceId: updateData.capabilityIntegrationResourceId,
|
|
856
|
+
groupId: updateData.groupId,
|
|
857
|
+
status: updateData.status,
|
|
858
|
+
availableFor: updateData.availableFor,
|
|
821
859
|
updatedBy: loggedInUserId
|
|
822
860
|
};
|
|
823
861
|
return await this.integrationConfigurationDao.updateCapabilityIntegration({
|
|
@@ -1207,9 +1245,9 @@ var Table = class Table2 {
|
|
|
1207
1245
|
[IsDrizzleTable] = true;
|
|
1208
1246
|
/** @internal */
|
|
1209
1247
|
[ExtraConfigBuilder] = void 0;
|
|
1210
|
-
constructor(name,
|
|
1248
|
+
constructor(name, schema8, baseName) {
|
|
1211
1249
|
this[TableName] = this[OriginalName] = name;
|
|
1212
|
-
this[Schema] =
|
|
1250
|
+
this[Schema] = schema8;
|
|
1213
1251
|
this[BaseName] = baseName;
|
|
1214
1252
|
}
|
|
1215
1253
|
};
|
|
@@ -2185,11 +2223,11 @@ var View = class View2 {
|
|
|
2185
2223
|
static [entityKind] = "View";
|
|
2186
2224
|
/** @internal */
|
|
2187
2225
|
[ViewBaseConfig];
|
|
2188
|
-
constructor({ name: name2, schema:
|
|
2226
|
+
constructor({ name: name2, schema: schema8, selectedFields, query }) {
|
|
2189
2227
|
this[ViewBaseConfig] = {
|
|
2190
2228
|
name: name2,
|
|
2191
2229
|
originalName: name2,
|
|
2192
|
-
schema:
|
|
2230
|
+
schema: schema8,
|
|
2193
2231
|
selectedFields,
|
|
2194
2232
|
query,
|
|
2195
2233
|
isExisting: !query,
|
|
@@ -2284,7 +2322,7 @@ function getTableColumns(table) {
|
|
|
2284
2322
|
}
|
|
2285
2323
|
__name(getTableColumns, "getTableColumns");
|
|
2286
2324
|
|
|
2287
|
-
// ../../packages/dvss-integration-libs/src/integration-common-utils/dao/integration-
|
|
2325
|
+
// ../../packages/dvss-integration-libs/src/integration-common-utils/dao/integration-booking.dao.ts
|
|
2288
2326
|
function _ts_decorate10(decorators, target, key, desc2) {
|
|
2289
2327
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
2290
2328
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
@@ -2302,6 +2340,76 @@ function _ts_param(paramIndex, decorator) {
|
|
|
2302
2340
|
};
|
|
2303
2341
|
}
|
|
2304
2342
|
__name(_ts_param, "_ts_param");
|
|
2343
|
+
exports.IntegrationBookingDao = class IntegrationBookingDao {
|
|
2344
|
+
static {
|
|
2345
|
+
__name(this, "IntegrationBookingDao");
|
|
2346
|
+
}
|
|
2347
|
+
conn;
|
|
2348
|
+
logger;
|
|
2349
|
+
fileName = "integration-booking.dao";
|
|
2350
|
+
constructor(conn, logger) {
|
|
2351
|
+
this.conn = conn;
|
|
2352
|
+
this.logger = logger;
|
|
2353
|
+
}
|
|
2354
|
+
async getOfferingBookingOccurrence(input) {
|
|
2355
|
+
this.logger.debug(input.loggedInUserId, this.getOfferingBookingOccurrence.name, this.fileName, "Getting offering booking occurrence with input: ", input);
|
|
2356
|
+
const conditions = [
|
|
2357
|
+
isNull(dvssBackendModuleDatastore.schema.offeringBookingOccurrence.deletedAt),
|
|
2358
|
+
eq(dvssBackendModuleDatastore.schema.offeringBookingOccurrence.id, input.offeringBookingOccurrenceId),
|
|
2359
|
+
isNull(dvssBackendModuleDatastore.schema.offeringBooking.deletedAt),
|
|
2360
|
+
isNull(dvssBackendModuleDatastore.schema.offering.deletedAt)
|
|
2361
|
+
];
|
|
2362
|
+
if (input.offeringBookingId != null) {
|
|
2363
|
+
conditions.push(eq(dvssBackendModuleDatastore.schema.offeringBooking.id, input.offeringBookingId));
|
|
2364
|
+
}
|
|
2365
|
+
const result = await this.conn.select({
|
|
2366
|
+
offeringBookingOccurrence: dvssBackendModuleDatastore.schema.offeringBookingOccurrence,
|
|
2367
|
+
offering: dvssBackendModuleDatastore.schema.offering,
|
|
2368
|
+
offeringIntentId: dvssBackendModuleDatastore.schema.offeringBooking.offeringIntentId
|
|
2369
|
+
}).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);
|
|
2370
|
+
if (!result[0] || result[0].offeringIntentId == null) return void 0;
|
|
2371
|
+
return {
|
|
2372
|
+
offeringBookingOccurrence: result[0].offeringBookingOccurrence,
|
|
2373
|
+
offering: result[0].offering,
|
|
2374
|
+
offeringIntentId: result[0].offeringIntentId
|
|
2375
|
+
};
|
|
2376
|
+
}
|
|
2377
|
+
/**
|
|
2378
|
+
* Fetches offering intent by id.
|
|
2379
|
+
*/
|
|
2380
|
+
async getOfferingIntent(input) {
|
|
2381
|
+
const row = await this.conn.query.offeringIntent.findFirst({
|
|
2382
|
+
where: and(isNull(dvssBackendModuleDatastore.schema.offeringIntent.deletedAt), eq(dvssBackendModuleDatastore.schema.offeringIntent.id, input.offeringIntentId))
|
|
2383
|
+
});
|
|
2384
|
+
return row ?? void 0;
|
|
2385
|
+
}
|
|
2386
|
+
};
|
|
2387
|
+
exports.IntegrationBookingDao = _ts_decorate10([
|
|
2388
|
+
common.Injectable(),
|
|
2389
|
+
_ts_param(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
|
|
2390
|
+
_ts_metadata7("design:type", Function),
|
|
2391
|
+
_ts_metadata7("design:paramtypes", [
|
|
2392
|
+
typeof MySql2Database === "undefined" ? Object : MySql2Database,
|
|
2393
|
+
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
|
|
2394
|
+
])
|
|
2395
|
+
], exports.IntegrationBookingDao);
|
|
2396
|
+
function _ts_decorate11(decorators, target, key, desc2) {
|
|
2397
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
2398
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2399
|
+
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;
|
|
2400
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2401
|
+
}
|
|
2402
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
2403
|
+
function _ts_metadata8(k, v) {
|
|
2404
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2405
|
+
}
|
|
2406
|
+
__name(_ts_metadata8, "_ts_metadata");
|
|
2407
|
+
function _ts_param2(paramIndex, decorator) {
|
|
2408
|
+
return function(target, key) {
|
|
2409
|
+
decorator(target, key, paramIndex);
|
|
2410
|
+
};
|
|
2411
|
+
}
|
|
2412
|
+
__name(_ts_param2, "_ts_param");
|
|
2305
2413
|
exports.IntegrationCommonDao = class IntegrationCommonDao {
|
|
2306
2414
|
static {
|
|
2307
2415
|
__name(this, "IntegrationCommonDao");
|
|
@@ -2360,32 +2468,32 @@ exports.IntegrationCommonDao = class IntegrationCommonDao {
|
|
|
2360
2468
|
return dvssBackendModuleUtility.DEFAULT_TIMEZONE;
|
|
2361
2469
|
}
|
|
2362
2470
|
};
|
|
2363
|
-
exports.IntegrationCommonDao =
|
|
2471
|
+
exports.IntegrationCommonDao = _ts_decorate11([
|
|
2364
2472
|
common.Injectable(),
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2473
|
+
_ts_param2(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
|
|
2474
|
+
_ts_metadata8("design:type", Function),
|
|
2475
|
+
_ts_metadata8("design:paramtypes", [
|
|
2368
2476
|
typeof MySql2Database === "undefined" ? Object : MySql2Database,
|
|
2369
2477
|
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
|
|
2370
2478
|
])
|
|
2371
2479
|
], exports.IntegrationCommonDao);
|
|
2372
|
-
function
|
|
2480
|
+
function _ts_decorate12(decorators, target, key, desc2) {
|
|
2373
2481
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
2374
2482
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2375
2483
|
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;
|
|
2376
2484
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2377
2485
|
}
|
|
2378
|
-
__name(
|
|
2379
|
-
function
|
|
2486
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
2487
|
+
function _ts_metadata9(k, v) {
|
|
2380
2488
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2381
2489
|
}
|
|
2382
|
-
__name(
|
|
2383
|
-
function
|
|
2490
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
2491
|
+
function _ts_param3(paramIndex, decorator) {
|
|
2384
2492
|
return function(target, key) {
|
|
2385
2493
|
decorator(target, key, paramIndex);
|
|
2386
2494
|
};
|
|
2387
2495
|
}
|
|
2388
|
-
__name(
|
|
2496
|
+
__name(_ts_param3, "_ts_param");
|
|
2389
2497
|
exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
|
|
2390
2498
|
static {
|
|
2391
2499
|
__name(this, "IntegrationConfigurationDao");
|
|
@@ -2475,7 +2583,9 @@ exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
|
|
|
2475
2583
|
*/
|
|
2476
2584
|
async updateCapabilityIntegration(input, loggedInUserId) {
|
|
2477
2585
|
try {
|
|
2478
|
-
this.logger.info(loggedInUserId, this.updateCapabilityIntegration.name, this.fileName, "Updating capability integration"
|
|
2586
|
+
this.logger.info(loggedInUserId, this.updateCapabilityIntegration.name, this.fileName, "Updating capability integration", {
|
|
2587
|
+
input
|
|
2588
|
+
});
|
|
2479
2589
|
const response = await this.conn.update(dvssBackendModuleDatastore.schema.capabilityIntegration).set({
|
|
2480
2590
|
...input.updateData
|
|
2481
2591
|
}).where(eq(dvssBackendModuleDatastore.schema.capabilityIntegration.id, input.id));
|
|
@@ -2695,32 +2805,224 @@ exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
|
|
|
2695
2805
|
}
|
|
2696
2806
|
}
|
|
2697
2807
|
};
|
|
2698
|
-
exports.IntegrationConfigurationDao =
|
|
2808
|
+
exports.IntegrationConfigurationDao = _ts_decorate12([
|
|
2699
2809
|
common.Injectable(),
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2810
|
+
_ts_param3(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
|
|
2811
|
+
_ts_metadata9("design:type", Function),
|
|
2812
|
+
_ts_metadata9("design:paramtypes", [
|
|
2703
2813
|
typeof MySql2Database === "undefined" ? Object : MySql2Database,
|
|
2704
2814
|
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
|
|
2705
2815
|
])
|
|
2706
2816
|
], exports.IntegrationConfigurationDao);
|
|
2707
|
-
function
|
|
2817
|
+
function _ts_decorate13(decorators, target, key, desc2) {
|
|
2708
2818
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
2709
2819
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2710
2820
|
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;
|
|
2711
2821
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2712
2822
|
}
|
|
2713
|
-
__name(
|
|
2714
|
-
function
|
|
2823
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
2824
|
+
function _ts_metadata10(k, v) {
|
|
2715
2825
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2716
2826
|
}
|
|
2717
|
-
__name(
|
|
2718
|
-
function
|
|
2827
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
2828
|
+
function _ts_param4(paramIndex, decorator) {
|
|
2719
2829
|
return function(target, key) {
|
|
2720
2830
|
decorator(target, key, paramIndex);
|
|
2721
2831
|
};
|
|
2722
2832
|
}
|
|
2723
|
-
__name(
|
|
2833
|
+
__name(_ts_param4, "_ts_param");
|
|
2834
|
+
exports.IntegrationSubcapabilityDao = class IntegrationSubcapabilityDao {
|
|
2835
|
+
static {
|
|
2836
|
+
__name(this, "IntegrationSubcapabilityDao");
|
|
2837
|
+
}
|
|
2838
|
+
conn;
|
|
2839
|
+
logger;
|
|
2840
|
+
fileName = "integration-subcapability.dao";
|
|
2841
|
+
constructor(conn, logger) {
|
|
2842
|
+
this.conn = conn;
|
|
2843
|
+
this.logger = logger;
|
|
2844
|
+
}
|
|
2845
|
+
/**
|
|
2846
|
+
* Returns subcapability id for given capabilityId and subcapability name.
|
|
2847
|
+
* Enforces uniqueness: if more than one active row is found, throws an error.
|
|
2848
|
+
* If no active row is found, returns undefined (caller decides how to handle).
|
|
2849
|
+
*/
|
|
2850
|
+
async getSubcapabilityId(input, loggedInUserId) {
|
|
2851
|
+
this.logger.info(loggedInUserId, this.getSubcapabilityId.name, this.fileName, "IntegrationSubcapabilityDao -> getSubcapabilityId called", {
|
|
2852
|
+
input
|
|
2853
|
+
});
|
|
2854
|
+
try {
|
|
2855
|
+
const rows = await this.conn.query.subcapability.findMany({
|
|
2856
|
+
where: and(eq(dvssBackendModuleDatastore.schema.subcapability.capabilityId, input.capabilityId), eq(dvssBackendModuleDatastore.schema.subcapability.name, input.name), isNull(dvssBackendModuleDatastore.schema.subcapability.deletedAt))
|
|
2857
|
+
});
|
|
2858
|
+
if (rows.length === 0) {
|
|
2859
|
+
this.logger.error(loggedInUserId, this.getSubcapabilityId.name, this.fileName, "Subcapability not found for given capabilityId and name", {
|
|
2860
|
+
input
|
|
2861
|
+
});
|
|
2862
|
+
return void 0;
|
|
2863
|
+
}
|
|
2864
|
+
return rows[0].id;
|
|
2865
|
+
} catch (error) {
|
|
2866
|
+
this.logger.error(loggedInUserId, this.getSubcapabilityId.name, this.fileName, "Error in getSubcapabilityId", error, {
|
|
2867
|
+
input
|
|
2868
|
+
});
|
|
2869
|
+
throw error;
|
|
2870
|
+
}
|
|
2871
|
+
}
|
|
2872
|
+
};
|
|
2873
|
+
exports.IntegrationSubcapabilityDao = _ts_decorate13([
|
|
2874
|
+
common.Injectable(),
|
|
2875
|
+
_ts_param4(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
|
|
2876
|
+
_ts_metadata10("design:type", Function),
|
|
2877
|
+
_ts_metadata10("design:paramtypes", [
|
|
2878
|
+
typeof MySql2Database === "undefined" ? Object : MySql2Database,
|
|
2879
|
+
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
|
|
2880
|
+
])
|
|
2881
|
+
], exports.IntegrationSubcapabilityDao);
|
|
2882
|
+
function _ts_decorate14(decorators, target, key, desc2) {
|
|
2883
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
2884
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2885
|
+
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;
|
|
2886
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2887
|
+
}
|
|
2888
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
2889
|
+
function _ts_metadata11(k, v) {
|
|
2890
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2891
|
+
}
|
|
2892
|
+
__name(_ts_metadata11, "_ts_metadata");
|
|
2893
|
+
function _ts_param5(paramIndex, decorator) {
|
|
2894
|
+
return function(target, key) {
|
|
2895
|
+
decorator(target, key, paramIndex);
|
|
2896
|
+
};
|
|
2897
|
+
}
|
|
2898
|
+
__name(_ts_param5, "_ts_param");
|
|
2899
|
+
exports.IntegrationServiceCommunicationTopicDao = class IntegrationServiceCommunicationTopicDao {
|
|
2900
|
+
static {
|
|
2901
|
+
__name(this, "IntegrationServiceCommunicationTopicDao");
|
|
2902
|
+
}
|
|
2903
|
+
conn;
|
|
2904
|
+
logger;
|
|
2905
|
+
fileName = "integration-service-communication-topic.dao";
|
|
2906
|
+
constructor(conn, logger) {
|
|
2907
|
+
this.conn = conn;
|
|
2908
|
+
this.logger = logger;
|
|
2909
|
+
}
|
|
2910
|
+
/**
|
|
2911
|
+
* Upserts a service communication topic for a given deployment + capability/subcapability/operation.
|
|
2912
|
+
* If a matching topic exists (by deploymentId + capability + subcapability + subcapabilityOperation),
|
|
2913
|
+
* it will be updated; otherwise a new row will be inserted.
|
|
2914
|
+
*/
|
|
2915
|
+
async upsertTopic(input, loggedInUserId = dvssBackendModuleUtility.SYSTEM_USER_ID) {
|
|
2916
|
+
this.logger.info(loggedInUserId, this.upsertTopic.name, this.fileName, "IntegrationServiceCommunicationTopicDao -> upsertTopic called", {
|
|
2917
|
+
input
|
|
2918
|
+
});
|
|
2919
|
+
try {
|
|
2920
|
+
const existing = await this.conn.query.serviceCommunicationTopic.findFirst({
|
|
2921
|
+
where: and(
|
|
2922
|
+
eq(dvssBackendModuleDatastore.schema.serviceCommunicationTopic.deploymentId, input.deploymentId),
|
|
2923
|
+
eq(dvssBackendModuleDatastore.schema.serviceCommunicationTopic.projectId, input.projectId),
|
|
2924
|
+
isNull(dvssBackendModuleDatastore.schema.serviceCommunicationTopic.deletedAt),
|
|
2925
|
+
...input.capability ? [
|
|
2926
|
+
eq(dvssBackendModuleDatastore.schema.serviceCommunicationTopic.capability, input.capability)
|
|
2927
|
+
] : [],
|
|
2928
|
+
...input.subcapability ? [
|
|
2929
|
+
eq(dvssBackendModuleDatastore.schema.serviceCommunicationTopic.subcapability, input.subcapability)
|
|
2930
|
+
] : [],
|
|
2931
|
+
eq(dvssBackendModuleDatastore.schema.serviceCommunicationTopic.subcapabilityOperation, input.subcapabilityOperation),
|
|
2932
|
+
...input.capabilityIntegrationId ? [
|
|
2933
|
+
eq(dvssBackendModuleDatastore.schema.serviceCommunicationTopic.capabilityIntegrationId, input.capabilityIntegrationId)
|
|
2934
|
+
] : []
|
|
2935
|
+
)
|
|
2936
|
+
});
|
|
2937
|
+
if (existing) {
|
|
2938
|
+
await this.conn.update(dvssBackendModuleDatastore.schema.serviceCommunicationTopic).set({
|
|
2939
|
+
topicType: input.topicType,
|
|
2940
|
+
topicName: input.topicName,
|
|
2941
|
+
isUniversal: input.isUniversal ?? existing.isUniversal,
|
|
2942
|
+
shouldPublish: input.shouldPublish ?? existing.shouldPublish,
|
|
2943
|
+
shouldSubscribe: input.shouldSubscribe ?? existing.shouldSubscribe,
|
|
2944
|
+
updatedAt: /* @__PURE__ */ new Date(),
|
|
2945
|
+
updatedBy: loggedInUserId
|
|
2946
|
+
}).where(eq(dvssBackendModuleDatastore.schema.serviceCommunicationTopic.id, existing.id));
|
|
2947
|
+
return {
|
|
2948
|
+
status: true
|
|
2949
|
+
};
|
|
2950
|
+
}
|
|
2951
|
+
await this.conn.insert(dvssBackendModuleDatastore.schema.serviceCommunicationTopic).values({
|
|
2952
|
+
projectId: input.projectId,
|
|
2953
|
+
propertyId: input.propertyId,
|
|
2954
|
+
deploymentId: input.deploymentId,
|
|
2955
|
+
capability: input.capability,
|
|
2956
|
+
subcapability: input.subcapability,
|
|
2957
|
+
subcapabilityOperation: input.subcapabilityOperation,
|
|
2958
|
+
topicType: input.topicType,
|
|
2959
|
+
topicName: input.topicName,
|
|
2960
|
+
isUniversal: input.isUniversal ?? false,
|
|
2961
|
+
shouldPublish: input.shouldPublish ?? false,
|
|
2962
|
+
shouldSubscribe: input.shouldSubscribe ?? true,
|
|
2963
|
+
createdBy: loggedInUserId,
|
|
2964
|
+
capabilityIntegrationId: input.capabilityIntegrationId
|
|
2965
|
+
});
|
|
2966
|
+
return {
|
|
2967
|
+
status: true
|
|
2968
|
+
};
|
|
2969
|
+
} catch (error) {
|
|
2970
|
+
this.logger.error(loggedInUserId, this.upsertTopic.name, this.fileName, "Error in upsertTopic", error, {
|
|
2971
|
+
input
|
|
2972
|
+
});
|
|
2973
|
+
throw error;
|
|
2974
|
+
}
|
|
2975
|
+
}
|
|
2976
|
+
/**
|
|
2977
|
+
* Returns all service communication topics for a given integration.
|
|
2978
|
+
* NOTE: Currently filters by deploymentId using the provided integrationId;
|
|
2979
|
+
* once capabilityIntegrationId is available in the public typings, this can
|
|
2980
|
+
* be updated to filter by that column instead.
|
|
2981
|
+
*/
|
|
2982
|
+
async getServiceCommunicationTopics(integrationId, loggedInUserId = dvssBackendModuleUtility.SYSTEM_USER_ID) {
|
|
2983
|
+
this.logger.info(loggedInUserId, this.getServiceCommunicationTopics.name, this.fileName, "IntegrationServiceCommunicationTopicDao -> getServiceCommunicationTopics called", {
|
|
2984
|
+
integrationId
|
|
2985
|
+
});
|
|
2986
|
+
try {
|
|
2987
|
+
const topics = await this.conn.select({
|
|
2988
|
+
...getTableColumns(dvssBackendModuleDatastore.schema.serviceCommunicationTopic),
|
|
2989
|
+
subcapability: getTableColumns(dvssBackendModuleDatastore.schema.subcapability)
|
|
2990
|
+
}).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)));
|
|
2991
|
+
return topics;
|
|
2992
|
+
} catch (error) {
|
|
2993
|
+
this.logger.error(loggedInUserId, this.getServiceCommunicationTopics.name, this.fileName, "Error in getServiceCommunicationTopics", error, {
|
|
2994
|
+
integrationId
|
|
2995
|
+
});
|
|
2996
|
+
throw error;
|
|
2997
|
+
}
|
|
2998
|
+
}
|
|
2999
|
+
};
|
|
3000
|
+
exports.IntegrationServiceCommunicationTopicDao = _ts_decorate14([
|
|
3001
|
+
common.Injectable(),
|
|
3002
|
+
_ts_param5(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
|
|
3003
|
+
_ts_metadata11("design:type", Function),
|
|
3004
|
+
_ts_metadata11("design:paramtypes", [
|
|
3005
|
+
typeof MySql2Database === "undefined" ? Object : MySql2Database,
|
|
3006
|
+
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
|
|
3007
|
+
])
|
|
3008
|
+
], exports.IntegrationServiceCommunicationTopicDao);
|
|
3009
|
+
function _ts_decorate15(decorators, target, key, desc2) {
|
|
3010
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3011
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3012
|
+
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;
|
|
3013
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3014
|
+
}
|
|
3015
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
3016
|
+
function _ts_metadata12(k, v) {
|
|
3017
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
3018
|
+
}
|
|
3019
|
+
__name(_ts_metadata12, "_ts_metadata");
|
|
3020
|
+
function _ts_param6(paramIndex, decorator) {
|
|
3021
|
+
return function(target, key) {
|
|
3022
|
+
decorator(target, key, paramIndex);
|
|
3023
|
+
};
|
|
3024
|
+
}
|
|
3025
|
+
__name(_ts_param6, "_ts_param");
|
|
2724
3026
|
exports.IntegrationResourceManagementDao = class IntegrationResourceManagementDao {
|
|
2725
3027
|
static {
|
|
2726
3028
|
__name(this, "IntegrationResourceManagementDao");
|
|
@@ -2882,32 +3184,32 @@ exports.IntegrationResourceManagementDao = class IntegrationResourceManagementDa
|
|
|
2882
3184
|
}
|
|
2883
3185
|
}
|
|
2884
3186
|
};
|
|
2885
|
-
exports.IntegrationResourceManagementDao =
|
|
3187
|
+
exports.IntegrationResourceManagementDao = _ts_decorate15([
|
|
2886
3188
|
common.Injectable(),
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
3189
|
+
_ts_param6(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
|
|
3190
|
+
_ts_metadata12("design:type", Function),
|
|
3191
|
+
_ts_metadata12("design:paramtypes", [
|
|
2890
3192
|
typeof MySql2Database === "undefined" ? Object : MySql2Database,
|
|
2891
3193
|
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
|
|
2892
3194
|
])
|
|
2893
3195
|
], exports.IntegrationResourceManagementDao);
|
|
2894
|
-
function
|
|
3196
|
+
function _ts_decorate16(decorators, target, key, desc2) {
|
|
2895
3197
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
2896
3198
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2897
3199
|
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;
|
|
2898
3200
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2899
3201
|
}
|
|
2900
|
-
__name(
|
|
2901
|
-
function
|
|
3202
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
3203
|
+
function _ts_metadata13(k, v) {
|
|
2902
3204
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2903
3205
|
}
|
|
2904
|
-
__name(
|
|
2905
|
-
function
|
|
3206
|
+
__name(_ts_metadata13, "_ts_metadata");
|
|
3207
|
+
function _ts_param7(paramIndex, decorator) {
|
|
2906
3208
|
return function(target, key) {
|
|
2907
3209
|
decorator(target, key, paramIndex);
|
|
2908
3210
|
};
|
|
2909
3211
|
}
|
|
2910
|
-
__name(
|
|
3212
|
+
__name(_ts_param7, "_ts_param");
|
|
2911
3213
|
exports.IntegrationUserManagementDao = class IntegrationUserManagementDao {
|
|
2912
3214
|
static {
|
|
2913
3215
|
__name(this, "IntegrationUserManagementDao");
|
|
@@ -2917,57 +3219,166 @@ exports.IntegrationUserManagementDao = class IntegrationUserManagementDao {
|
|
|
2917
3219
|
this.conn = conn;
|
|
2918
3220
|
}
|
|
2919
3221
|
};
|
|
2920
|
-
exports.IntegrationUserManagementDao =
|
|
3222
|
+
exports.IntegrationUserManagementDao = _ts_decorate16([
|
|
2921
3223
|
common.Injectable(),
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
3224
|
+
_ts_param7(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
|
|
3225
|
+
_ts_metadata13("design:type", Function),
|
|
3226
|
+
_ts_metadata13("design:paramtypes", [
|
|
2925
3227
|
typeof MySql2Database === "undefined" ? Object : MySql2Database
|
|
2926
3228
|
])
|
|
2927
3229
|
], exports.IntegrationUserManagementDao);
|
|
2928
|
-
function
|
|
3230
|
+
function _ts_decorate17(decorators, target, key, desc2) {
|
|
2929
3231
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
2930
3232
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2931
3233
|
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;
|
|
2932
3234
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2933
3235
|
}
|
|
2934
|
-
__name(
|
|
2935
|
-
function
|
|
3236
|
+
__name(_ts_decorate17, "_ts_decorate");
|
|
3237
|
+
function _ts_metadata14(k, v) {
|
|
2936
3238
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2937
3239
|
}
|
|
2938
|
-
__name(
|
|
2939
|
-
|
|
3240
|
+
__name(_ts_metadata14, "_ts_metadata");
|
|
3241
|
+
function _ts_param8(paramIndex, decorator) {
|
|
3242
|
+
return function(target, key) {
|
|
3243
|
+
decorator(target, key, paramIndex);
|
|
3244
|
+
};
|
|
3245
|
+
}
|
|
3246
|
+
__name(_ts_param8, "_ts_param");
|
|
3247
|
+
exports.IntegrationOnpremDeploymentDao = class IntegrationOnpremDeploymentDao {
|
|
2940
3248
|
static {
|
|
2941
|
-
__name(this, "
|
|
3249
|
+
__name(this, "IntegrationOnpremDeploymentDao");
|
|
2942
3250
|
}
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
constructor() {
|
|
3251
|
+
conn;
|
|
3252
|
+
logger;
|
|
3253
|
+
fileName = "integration-onprem-deployment.dao";
|
|
3254
|
+
constructor(conn, logger) {
|
|
3255
|
+
this.conn = conn;
|
|
3256
|
+
this.logger = logger;
|
|
2947
3257
|
}
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
3258
|
+
async addUpdateOnpremDeployment(input, loggedInUserId = dvssBackendModuleUtility.SYSTEM_USER_ID) {
|
|
3259
|
+
try {
|
|
3260
|
+
this.logger.info(loggedInUserId, this.addUpdateOnpremDeployment.name, this.fileName, `IntegrationOnpremDeploymentDao -> addUpdateOnpremDeployment called`, {
|
|
3261
|
+
input
|
|
3262
|
+
});
|
|
3263
|
+
const existingEntry = await this.conn.query.onPremDeployment.findFirst({
|
|
3264
|
+
where: and(eq(dvssBackendModuleDatastore.schema.onPremDeployment.projectId, input.projectId), eq(dvssBackendModuleDatastore.schema.onPremDeployment.capabilityIntegrationId, input.capabilityIntegrationId))
|
|
3265
|
+
});
|
|
3266
|
+
if (existingEntry) {
|
|
3267
|
+
await this.updateOnpremDeployment(existingEntry.id, input, loggedInUserId);
|
|
3268
|
+
return {
|
|
3269
|
+
status: true,
|
|
3270
|
+
id: existingEntry.id
|
|
3271
|
+
};
|
|
3272
|
+
}
|
|
3273
|
+
return this.addOnpremDeployment(input, loggedInUserId);
|
|
3274
|
+
} catch (error) {
|
|
3275
|
+
this.logger.error(loggedInUserId, this.addUpdateOnpremDeployment.name, this.fileName, "Error in addCapabilityIntegration", error, {
|
|
3276
|
+
input
|
|
3277
|
+
});
|
|
3278
|
+
throw error;
|
|
3279
|
+
}
|
|
2951
3280
|
}
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
3281
|
+
async addOnpremDeployment(input, loggedInUserId = dvssBackendModuleUtility.SYSTEM_USER_ID) {
|
|
3282
|
+
try {
|
|
3283
|
+
const [insertedResult] = await this.conn.insert(dvssBackendModuleDatastore.schema.onPremDeployment).values(input).$returningId();
|
|
3284
|
+
return {
|
|
3285
|
+
status: true,
|
|
3286
|
+
id: BigInt(insertedResult.id)
|
|
3287
|
+
};
|
|
3288
|
+
} catch (error) {
|
|
3289
|
+
this.logger.error(loggedInUserId, this.addOnpremDeployment.name, this.fileName, "Error in addOnpremDeployment", error, {
|
|
3290
|
+
input
|
|
3291
|
+
});
|
|
3292
|
+
throw error;
|
|
3293
|
+
}
|
|
3294
|
+
}
|
|
3295
|
+
async updateOnpremDeployment(id, updateData, loggedInUserId = dvssBackendModuleUtility.SYSTEM_USER_ID) {
|
|
3296
|
+
try {
|
|
3297
|
+
const result = await this.conn.update(dvssBackendModuleDatastore.schema.onPremDeployment).set(updateData).where(eq(dvssBackendModuleDatastore.schema.onPremDeployment.id, id)).execute();
|
|
3298
|
+
return {
|
|
3299
|
+
status: result[0].affectedRows > 0,
|
|
3300
|
+
id
|
|
3301
|
+
};
|
|
3302
|
+
} catch (error) {
|
|
3303
|
+
this.logger.error(loggedInUserId, this.updateOnpremDeployment.name, this.fileName, "Error in updateOnpremDeployment", error, {
|
|
3304
|
+
id,
|
|
3305
|
+
updateData
|
|
3306
|
+
});
|
|
3307
|
+
throw error;
|
|
3308
|
+
}
|
|
3309
|
+
}
|
|
3310
|
+
/**
|
|
3311
|
+
* Gets an on-prem deployment by capability integration id.
|
|
3312
|
+
* Used by Suprema integration to resolve deployment for a given integration.
|
|
3313
|
+
*/
|
|
3314
|
+
async getOnpremDeployment(input, loggedInUserId = dvssBackendModuleUtility.SYSTEM_USER_ID) {
|
|
3315
|
+
try {
|
|
3316
|
+
this.logger.info(loggedInUserId, this.getOnpremDeployment.name, this.fileName, "IntegrationOnpremDeploymentDao -> getOnpremDeployment called", {
|
|
3317
|
+
input
|
|
3318
|
+
});
|
|
3319
|
+
return await this.conn.query.onPremDeployment.findFirst({
|
|
3320
|
+
where: and(eq(dvssBackendModuleDatastore.schema.onPremDeployment.projectId, input.projectId), eq(dvssBackendModuleDatastore.schema.onPremDeployment.capabilityIntegrationId, input.integrationId), isNull(dvssBackendModuleDatastore.schema.onPremDeployment.deletedAt))
|
|
3321
|
+
});
|
|
3322
|
+
} catch (error) {
|
|
3323
|
+
this.logger.error(loggedInUserId, this.getOnpremDeployment.name, this.fileName, "Error in getOnpremDeployment", error, {
|
|
3324
|
+
input
|
|
3325
|
+
});
|
|
3326
|
+
throw error;
|
|
3327
|
+
}
|
|
3328
|
+
}
|
|
3329
|
+
};
|
|
3330
|
+
exports.IntegrationOnpremDeploymentDao = _ts_decorate17([
|
|
3331
|
+
common.Injectable(),
|
|
3332
|
+
_ts_param8(0, common.Inject(dvssBackendModuleDatastore.appConstants.DB_CONNECTION)),
|
|
3333
|
+
_ts_metadata14("design:type", Function),
|
|
3334
|
+
_ts_metadata14("design:paramtypes", [
|
|
3335
|
+
typeof MySql2Database === "undefined" ? Object : MySql2Database,
|
|
3336
|
+
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
|
|
3337
|
+
])
|
|
3338
|
+
], exports.IntegrationOnpremDeploymentDao);
|
|
3339
|
+
function _ts_decorate18(decorators, target, key, desc2) {
|
|
3340
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3341
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3342
|
+
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
3343
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2965
3344
|
}
|
|
2966
|
-
__name(
|
|
2967
|
-
function
|
|
3345
|
+
__name(_ts_decorate18, "_ts_decorate");
|
|
3346
|
+
function _ts_metadata15(k, v) {
|
|
2968
3347
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2969
3348
|
}
|
|
2970
|
-
__name(
|
|
3349
|
+
__name(_ts_metadata15, "_ts_metadata");
|
|
3350
|
+
var AppService3 = class {
|
|
3351
|
+
static {
|
|
3352
|
+
__name(this, "AppService");
|
|
3353
|
+
}
|
|
3354
|
+
/**
|
|
3355
|
+
* Creates an instance of the app service
|
|
3356
|
+
*/
|
|
3357
|
+
constructor() {
|
|
3358
|
+
}
|
|
3359
|
+
getHello() {
|
|
3360
|
+
console.log(`${this.constructor.name}::getHello`);
|
|
3361
|
+
return "Hello World!";
|
|
3362
|
+
}
|
|
3363
|
+
};
|
|
3364
|
+
AppService3 = _ts_decorate18([
|
|
3365
|
+
common.Injectable(),
|
|
3366
|
+
_ts_metadata15("design:type", Function),
|
|
3367
|
+
_ts_metadata15("design:paramtypes", [])
|
|
3368
|
+
], AppService3);
|
|
3369
|
+
|
|
3370
|
+
// ../../packages/dvss-integration-trybe/src/app.controller.ts
|
|
3371
|
+
function _ts_decorate19(decorators, target, key, desc2) {
|
|
3372
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3373
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3374
|
+
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;
|
|
3375
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3376
|
+
}
|
|
3377
|
+
__name(_ts_decorate19, "_ts_decorate");
|
|
3378
|
+
function _ts_metadata16(k, v) {
|
|
3379
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
3380
|
+
}
|
|
3381
|
+
__name(_ts_metadata16, "_ts_metadata");
|
|
2971
3382
|
var AppController3 = class {
|
|
2972
3383
|
static {
|
|
2973
3384
|
__name(this, "AppController");
|
|
@@ -2980,43 +3391,94 @@ var AppController3 = class {
|
|
|
2980
3391
|
return this.appService.getHello();
|
|
2981
3392
|
}
|
|
2982
3393
|
};
|
|
2983
|
-
|
|
3394
|
+
_ts_decorate19([
|
|
2984
3395
|
common.Get("integration-trybe"),
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
3396
|
+
_ts_metadata16("design:type", Function),
|
|
3397
|
+
_ts_metadata16("design:paramtypes", []),
|
|
3398
|
+
_ts_metadata16("design:returntype", String)
|
|
2988
3399
|
], AppController3.prototype, "getHello", null);
|
|
2989
|
-
AppController3 =
|
|
3400
|
+
AppController3 = _ts_decorate19([
|
|
2990
3401
|
common.Controller(),
|
|
2991
|
-
|
|
2992
|
-
|
|
3402
|
+
_ts_metadata16("design:type", Function),
|
|
3403
|
+
_ts_metadata16("design:paramtypes", [
|
|
2993
3404
|
typeof AppService3 === "undefined" ? Object : AppService3
|
|
2994
3405
|
])
|
|
2995
3406
|
], AppController3);
|
|
2996
|
-
function
|
|
3407
|
+
function _ts_decorate20(decorators, target, key, desc2) {
|
|
2997
3408
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
2998
3409
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2999
3410
|
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;
|
|
3000
3411
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3001
3412
|
}
|
|
3002
|
-
__name(
|
|
3003
|
-
function
|
|
3413
|
+
__name(_ts_decorate20, "_ts_decorate");
|
|
3414
|
+
function _ts_metadata17(k, v) {
|
|
3004
3415
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
3005
3416
|
}
|
|
3006
|
-
__name(
|
|
3417
|
+
__name(_ts_metadata17, "_ts_metadata");
|
|
3418
|
+
exports.TrybeApiClientService = class TrybeApiClientService {
|
|
3419
|
+
static {
|
|
3420
|
+
__name(this, "TrybeApiClientService");
|
|
3421
|
+
}
|
|
3422
|
+
trybeAuthService;
|
|
3423
|
+
trafficGatewayService;
|
|
3424
|
+
constructor(trybeAuthService, trafficGatewayService) {
|
|
3425
|
+
this.trybeAuthService = trybeAuthService;
|
|
3426
|
+
this.trafficGatewayService = trafficGatewayService;
|
|
3427
|
+
}
|
|
3428
|
+
/**
|
|
3429
|
+
* Validates the integration config and executes an API request via
|
|
3430
|
+
* TrafficGatewayService. BaseUrl and auth headers are applied automatically
|
|
3431
|
+
* from the validated config.
|
|
3432
|
+
*/
|
|
3433
|
+
async executeRequest(request, integration, loggedInUserId) {
|
|
3434
|
+
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
3435
|
+
return this.trafficGatewayService.executeIntegrationRequest({
|
|
3436
|
+
...request,
|
|
3437
|
+
baseUrl: validated.config.platformConfig.baseUrl,
|
|
3438
|
+
headers: validated.headers
|
|
3439
|
+
}, validated, loggedInUserId);
|
|
3440
|
+
}
|
|
3441
|
+
};
|
|
3442
|
+
exports.TrybeApiClientService = _ts_decorate20([
|
|
3443
|
+
common.Injectable(),
|
|
3444
|
+
_ts_metadata17("design:type", Function),
|
|
3445
|
+
_ts_metadata17("design:paramtypes", [
|
|
3446
|
+
typeof exports.TrybeAuthService === "undefined" ? Object : exports.TrybeAuthService,
|
|
3447
|
+
typeof exports.TrafficGatewayService === "undefined" ? Object : exports.TrafficGatewayService
|
|
3448
|
+
])
|
|
3449
|
+
], exports.TrybeApiClientService);
|
|
3450
|
+
|
|
3451
|
+
// ../../packages/dvss-integration-trybe/src/capabilities/customer-management/customer-management.service.ts
|
|
3452
|
+
function _ts_decorate21(decorators, target, key, desc2) {
|
|
3453
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3454
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3455
|
+
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;
|
|
3456
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3457
|
+
}
|
|
3458
|
+
__name(_ts_decorate21, "_ts_decorate");
|
|
3459
|
+
function _ts_metadata18(k, v) {
|
|
3460
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
3461
|
+
}
|
|
3462
|
+
__name(_ts_metadata18, "_ts_metadata");
|
|
3463
|
+
function _ts_param9(paramIndex, decorator) {
|
|
3464
|
+
return function(target, key) {
|
|
3465
|
+
decorator(target, key, paramIndex);
|
|
3466
|
+
};
|
|
3467
|
+
}
|
|
3468
|
+
__name(_ts_param9, "_ts_param");
|
|
3007
3469
|
exports.TrybeCustomerManagement = class _TrybeCustomerManagement {
|
|
3008
3470
|
static {
|
|
3009
3471
|
__name(this, "TrybeCustomerManagement");
|
|
3010
3472
|
}
|
|
3011
3473
|
logger;
|
|
3012
|
-
|
|
3474
|
+
trybeApiClientService;
|
|
3013
3475
|
fileName = "customer-management.service";
|
|
3014
3476
|
/**
|
|
3015
3477
|
* Creates an instance of the service
|
|
3016
3478
|
*/
|
|
3017
|
-
constructor(logger,
|
|
3479
|
+
constructor(logger, trybeApiClientService) {
|
|
3018
3480
|
this.logger = logger;
|
|
3019
|
-
this.
|
|
3481
|
+
this.trybeApiClientService = trybeApiClientService;
|
|
3020
3482
|
}
|
|
3021
3483
|
/**
|
|
3022
3484
|
* Create a new customer on Trybe (POST /customers/customers).
|
|
@@ -3027,11 +3489,9 @@ exports.TrybeCustomerManagement = class _TrybeCustomerManagement {
|
|
|
3027
3489
|
this.logger.info(loggedInUserId, this.createCustomer.name, this.fileName, `${_TrybeCustomerManagement.name} -> ${this.createCustomer.name} Called`, {
|
|
3028
3490
|
request
|
|
3029
3491
|
});
|
|
3030
|
-
const response = await this.
|
|
3492
|
+
const response = await this.trybeApiClientService.executeRequest({
|
|
3031
3493
|
apiMethod: HTTP_METHOD.POST,
|
|
3032
3494
|
url: "/customers/customers",
|
|
3033
|
-
baseUrl: integration.config.platformConfig.baseUrl,
|
|
3034
|
-
headers: integration.headers,
|
|
3035
3495
|
body: request
|
|
3036
3496
|
}, integration, loggedInUserId);
|
|
3037
3497
|
return response.data;
|
|
@@ -3050,11 +3510,9 @@ exports.TrybeCustomerManagement = class _TrybeCustomerManagement {
|
|
|
3050
3510
|
throw new Error("Either email or customerId is required to get a customer from Trybe");
|
|
3051
3511
|
}
|
|
3052
3512
|
if (request.customerId) {
|
|
3053
|
-
const response = await this.
|
|
3513
|
+
const response = await this.trybeApiClientService.executeRequest({
|
|
3054
3514
|
apiMethod: HTTP_METHOD.GET,
|
|
3055
|
-
url: `/customers/customers/${request.customerId}
|
|
3056
|
-
baseUrl: integration.config.platformConfig.baseUrl,
|
|
3057
|
-
headers: integration.headers
|
|
3515
|
+
url: `/customers/customers/${request.customerId}`
|
|
3058
3516
|
}, integration, loggedInUserId);
|
|
3059
3517
|
if (!response.data) {
|
|
3060
3518
|
return void 0;
|
|
@@ -3062,11 +3520,9 @@ exports.TrybeCustomerManagement = class _TrybeCustomerManagement {
|
|
|
3062
3520
|
return response.data;
|
|
3063
3521
|
}
|
|
3064
3522
|
if (request.email) {
|
|
3065
|
-
const response = await this.
|
|
3523
|
+
const response = await this.trybeApiClientService.executeRequest({
|
|
3066
3524
|
apiMethod: HTTP_METHOD.GET,
|
|
3067
|
-
url: `/customers/customers/?email=${request.email}
|
|
3068
|
-
baseUrl: integration.config.platformConfig.baseUrl,
|
|
3069
|
-
headers: integration.headers
|
|
3525
|
+
url: `/customers/customers/?email=${request.email}`
|
|
3070
3526
|
}, integration, loggedInUserId);
|
|
3071
3527
|
if (!response.data || !Array.isArray(response.data)) {
|
|
3072
3528
|
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Credentials");
|
|
@@ -3087,11 +3543,9 @@ exports.TrybeCustomerManagement = class _TrybeCustomerManagement {
|
|
|
3087
3543
|
customerId,
|
|
3088
3544
|
request
|
|
3089
3545
|
});
|
|
3090
|
-
const response = await this.
|
|
3546
|
+
const response = await this.trybeApiClientService.executeRequest({
|
|
3091
3547
|
apiMethod: HTTP_METHOD.PUT,
|
|
3092
3548
|
url: `/customers/customers/${customerId}`,
|
|
3093
|
-
baseUrl: integration.config.platformConfig.baseUrl,
|
|
3094
|
-
headers: integration.headers,
|
|
3095
3549
|
body: request
|
|
3096
3550
|
}, integration, loggedInUserId);
|
|
3097
3551
|
return response.data;
|
|
@@ -3104,11 +3558,9 @@ exports.TrybeCustomerManagement = class _TrybeCustomerManagement {
|
|
|
3104
3558
|
this.logger.info(loggedInUserId, this.deleteCustomer.name, this.fileName, `${_TrybeCustomerManagement.name} -> ${this.deleteCustomer.name} Called`, {
|
|
3105
3559
|
customerId
|
|
3106
3560
|
});
|
|
3107
|
-
await this.
|
|
3561
|
+
await this.trybeApiClientService.executeRequest({
|
|
3108
3562
|
apiMethod: HTTP_METHOD.DELETE,
|
|
3109
|
-
url: `/customers/customers/${customerId}
|
|
3110
|
-
baseUrl: integration.config.platformConfig.baseUrl,
|
|
3111
|
-
headers: integration.headers
|
|
3563
|
+
url: `/customers/customers/${customerId}`
|
|
3112
3564
|
}, integration, loggedInUserId);
|
|
3113
3565
|
return {
|
|
3114
3566
|
status: true
|
|
@@ -3119,12 +3571,13 @@ exports.TrybeCustomerManagement = class _TrybeCustomerManagement {
|
|
|
3119
3571
|
}
|
|
3120
3572
|
}
|
|
3121
3573
|
};
|
|
3122
|
-
exports.TrybeCustomerManagement =
|
|
3574
|
+
exports.TrybeCustomerManagement = _ts_decorate21([
|
|
3123
3575
|
common.Injectable(),
|
|
3124
|
-
|
|
3125
|
-
|
|
3576
|
+
_ts_param9(1, common.Inject(common.forwardRef(() => exports.TrybeApiClientService))),
|
|
3577
|
+
_ts_metadata18("design:type", Function),
|
|
3578
|
+
_ts_metadata18("design:paramtypes", [
|
|
3126
3579
|
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
|
|
3127
|
-
typeof exports.
|
|
3580
|
+
typeof exports.TrybeApiClientService === "undefined" ? Object : exports.TrybeApiClientService
|
|
3128
3581
|
])
|
|
3129
3582
|
], exports.TrybeCustomerManagement);
|
|
3130
3583
|
|
|
@@ -3139,18 +3592,18 @@ function isValidHttpUrl(urlString) {
|
|
|
3139
3592
|
}
|
|
3140
3593
|
__name(isValidHttpUrl, "isValidHttpUrl");
|
|
3141
3594
|
|
|
3142
|
-
// ../../packages/dvss-integration-trybe/src/capabilities/auth/auth.service.ts
|
|
3143
|
-
function
|
|
3595
|
+
// ../../packages/dvss-integration-trybe/src/capabilities/auth-management/auth.service.ts
|
|
3596
|
+
function _ts_decorate22(decorators, target, key, desc2) {
|
|
3144
3597
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3145
3598
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3146
3599
|
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;
|
|
3147
3600
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3148
3601
|
}
|
|
3149
|
-
__name(
|
|
3150
|
-
function
|
|
3602
|
+
__name(_ts_decorate22, "_ts_decorate");
|
|
3603
|
+
function _ts_metadata19(k, v) {
|
|
3151
3604
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
3152
3605
|
}
|
|
3153
|
-
__name(
|
|
3606
|
+
__name(_ts_metadata19, "_ts_metadata");
|
|
3154
3607
|
exports.TrybeAuthService = class _TrybeAuthService {
|
|
3155
3608
|
static {
|
|
3156
3609
|
__name(this, "TrybeAuthService");
|
|
@@ -3248,10 +3701,10 @@ exports.TrybeAuthService = class _TrybeAuthService {
|
|
|
3248
3701
|
throw new Error("Method not implemented.");
|
|
3249
3702
|
}
|
|
3250
3703
|
};
|
|
3251
|
-
exports.TrybeAuthService =
|
|
3704
|
+
exports.TrybeAuthService = _ts_decorate22([
|
|
3252
3705
|
common.Injectable(),
|
|
3253
|
-
|
|
3254
|
-
|
|
3706
|
+
_ts_metadata19("design:type", Function),
|
|
3707
|
+
_ts_metadata19("design:paramtypes", [
|
|
3255
3708
|
typeof exports.TrybeCustomerManagement === "undefined" ? Object : exports.TrybeCustomerManagement,
|
|
3256
3709
|
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
|
|
3257
3710
|
])
|
|
@@ -3314,32 +3767,30 @@ function mapTrybeCreditsToSystem(res, integration) {
|
|
|
3314
3767
|
__name(mapTrybeCreditsToSystem, "mapTrybeCreditsToSystem");
|
|
3315
3768
|
|
|
3316
3769
|
// ../../packages/dvss-integration-trybe/src/capabilities/credit-management/credit-booking.service.ts
|
|
3317
|
-
function
|
|
3770
|
+
function _ts_decorate23(decorators, target, key, desc2) {
|
|
3318
3771
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3319
3772
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3320
3773
|
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;
|
|
3321
3774
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3322
3775
|
}
|
|
3323
|
-
__name(
|
|
3324
|
-
function
|
|
3776
|
+
__name(_ts_decorate23, "_ts_decorate");
|
|
3777
|
+
function _ts_metadata20(k, v) {
|
|
3325
3778
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
3326
3779
|
}
|
|
3327
|
-
__name(
|
|
3780
|
+
__name(_ts_metadata20, "_ts_metadata");
|
|
3328
3781
|
exports.TrybeCreditBooking = class _TrybeCreditBooking {
|
|
3329
3782
|
static {
|
|
3330
3783
|
__name(this, "TrybeCreditBooking");
|
|
3331
3784
|
}
|
|
3332
3785
|
logger;
|
|
3333
|
-
|
|
3334
|
-
trybeAuthService;
|
|
3786
|
+
trybeApiClientService;
|
|
3335
3787
|
fileName = "credit-booking.service";
|
|
3336
3788
|
/**
|
|
3337
3789
|
* Creates an instance of the service
|
|
3338
3790
|
*/
|
|
3339
|
-
constructor(logger,
|
|
3791
|
+
constructor(logger, trybeApiClientService) {
|
|
3340
3792
|
this.logger = logger;
|
|
3341
|
-
this.
|
|
3342
|
-
this.trybeAuthService = trybeAuthService;
|
|
3793
|
+
this.trybeApiClientService = trybeApiClientService;
|
|
3343
3794
|
}
|
|
3344
3795
|
/**
|
|
3345
3796
|
* Fetches customer credits from Trybe and returns system-format response
|
|
@@ -3350,7 +3801,6 @@ exports.TrybeCreditBooking = class _TrybeCreditBooking {
|
|
|
3350
3801
|
this.logger.info(loggedInUserId, this.fetchCustomerCredits.name, this.fileName, `${_TrybeCreditBooking.name} -> ${this.fetchCustomerCredits.name} Called`, {
|
|
3351
3802
|
request
|
|
3352
3803
|
});
|
|
3353
|
-
const validatedIntegration = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
3354
3804
|
const query = new URLSearchParams();
|
|
3355
3805
|
const opts = request.options;
|
|
3356
3806
|
if (opts?.page != null) query.set("page", String(opts.page));
|
|
@@ -3373,22 +3823,19 @@ exports.TrybeCreditBooking = class _TrybeCreditBooking {
|
|
|
3373
3823
|
}
|
|
3374
3824
|
const queryString = query.toString();
|
|
3375
3825
|
const url = `/customers/customers/${request.customerId}/credits` + (queryString ? `?${queryString}` : "");
|
|
3376
|
-
const raw = await this.
|
|
3826
|
+
const raw = await this.trybeApiClientService.executeRequest({
|
|
3377
3827
|
apiMethod: HTTP_METHOD.GET,
|
|
3378
|
-
url
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
}, validatedIntegration, loggedInUserId);
|
|
3382
|
-
return mapTrybeCreditsToSystem(raw, validatedIntegration);
|
|
3828
|
+
url
|
|
3829
|
+
}, integration, loggedInUserId);
|
|
3830
|
+
return mapTrybeCreditsToSystem(raw, integration);
|
|
3383
3831
|
}
|
|
3384
3832
|
};
|
|
3385
|
-
exports.TrybeCreditBooking =
|
|
3833
|
+
exports.TrybeCreditBooking = _ts_decorate23([
|
|
3386
3834
|
common.Injectable(),
|
|
3387
|
-
|
|
3388
|
-
|
|
3835
|
+
_ts_metadata20("design:type", Function),
|
|
3836
|
+
_ts_metadata20("design:paramtypes", [
|
|
3389
3837
|
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
|
|
3390
|
-
typeof exports.
|
|
3391
|
-
typeof exports.TrybeAuthService === "undefined" ? Object : exports.TrybeAuthService
|
|
3838
|
+
typeof exports.TrybeApiClientService === "undefined" ? Object : exports.TrybeApiClientService
|
|
3392
3839
|
])
|
|
3393
3840
|
], exports.TrybeCreditBooking);
|
|
3394
3841
|
|
|
@@ -3406,25 +3853,25 @@ function mapTrybeSiteResponseToSystem(response) {
|
|
|
3406
3853
|
__name(mapTrybeSiteResponseToSystem, "mapTrybeSiteResponseToSystem");
|
|
3407
3854
|
|
|
3408
3855
|
// ../../packages/dvss-integration-trybe/src/capabilities/integration-configuration/integration-configuration.service.ts
|
|
3409
|
-
function
|
|
3856
|
+
function _ts_decorate24(decorators, target, key, desc2) {
|
|
3410
3857
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3411
3858
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3412
3859
|
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;
|
|
3413
3860
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3414
3861
|
}
|
|
3415
|
-
__name(
|
|
3416
|
-
function
|
|
3862
|
+
__name(_ts_decorate24, "_ts_decorate");
|
|
3863
|
+
function _ts_metadata21(k, v) {
|
|
3417
3864
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
3418
3865
|
}
|
|
3419
|
-
__name(
|
|
3866
|
+
__name(_ts_metadata21, "_ts_metadata");
|
|
3420
3867
|
exports.TrybeIntegrationConfigurationService = class TrybeIntegrationConfigurationService extends exports.BaseIntegrationConfiguration {
|
|
3421
3868
|
static {
|
|
3422
3869
|
__name(this, "TrybeIntegrationConfigurationService");
|
|
3423
3870
|
}
|
|
3871
|
+
trybeApiClientService;
|
|
3424
3872
|
trybeAuthService;
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
super(integrationConfigurationDao, commonValidationDatabaseService, logger), this.trybeAuthService = trybeAuthService, this.trafficGatewayService = trafficGatewayService;
|
|
3873
|
+
constructor(integrationConfigurationDao, commonValidationDatabaseService, logger, trybeApiClientService, trybeAuthService) {
|
|
3874
|
+
super(integrationConfigurationDao, commonValidationDatabaseService, logger), this.trybeApiClientService = trybeApiClientService, this.trybeAuthService = trybeAuthService;
|
|
3428
3875
|
}
|
|
3429
3876
|
/**
|
|
3430
3877
|
* Add capability integration: validate Trybe config, then configuredFor (offering), then delegate to base.
|
|
@@ -3468,24 +3915,22 @@ exports.TrybeIntegrationConfigurationService = class TrybeIntegrationConfigurati
|
|
|
3468
3915
|
const validatedIntegration = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
3469
3916
|
const siteId = validatedIntegration.config.integrationConfig.siteId;
|
|
3470
3917
|
const url = `/shop/sites/${siteId}`;
|
|
3471
|
-
const response = await this.
|
|
3918
|
+
const response = await this.trybeApiClientService.executeRequest({
|
|
3472
3919
|
apiMethod: HTTP_METHOD.GET,
|
|
3473
|
-
url
|
|
3474
|
-
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
3475
|
-
headers: validatedIntegration.headers
|
|
3920
|
+
url
|
|
3476
3921
|
}, validatedIntegration, loggedInUserId);
|
|
3477
3922
|
return mapTrybeSiteResponseToSystem(response);
|
|
3478
3923
|
}
|
|
3479
3924
|
};
|
|
3480
|
-
exports.TrybeIntegrationConfigurationService =
|
|
3925
|
+
exports.TrybeIntegrationConfigurationService = _ts_decorate24([
|
|
3481
3926
|
common.Injectable(),
|
|
3482
|
-
|
|
3483
|
-
|
|
3927
|
+
_ts_metadata21("design:type", Function),
|
|
3928
|
+
_ts_metadata21("design:paramtypes", [
|
|
3484
3929
|
typeof exports.IntegrationConfigurationDao === "undefined" ? Object : exports.IntegrationConfigurationDao,
|
|
3485
3930
|
typeof dvssBackendModuleDatastore.CommonValidationDatabaseService === "undefined" ? Object : dvssBackendModuleDatastore.CommonValidationDatabaseService,
|
|
3486
3931
|
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
|
|
3487
|
-
typeof exports.
|
|
3488
|
-
typeof exports.
|
|
3932
|
+
typeof exports.TrybeApiClientService === "undefined" ? Object : exports.TrybeApiClientService,
|
|
3933
|
+
typeof exports.TrybeAuthService === "undefined" ? Object : exports.TrybeAuthService
|
|
3489
3934
|
])
|
|
3490
3935
|
], exports.TrybeIntegrationConfigurationService);
|
|
3491
3936
|
|
|
@@ -3502,17 +3947,17 @@ var TRYBE_CATALOGING_BY_ENUM = /* @__PURE__ */ (function(TRYBE_CATALOGING_BY_ENU
|
|
|
3502
3947
|
})({});
|
|
3503
3948
|
|
|
3504
3949
|
// ../../packages/dvss-integration-trybe/src/capabilities/integration-resource-management/integration-resource-management.service.ts
|
|
3505
|
-
function
|
|
3950
|
+
function _ts_decorate25(decorators, target, key, desc2) {
|
|
3506
3951
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3507
3952
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3508
3953
|
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;
|
|
3509
3954
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3510
3955
|
}
|
|
3511
|
-
__name(
|
|
3512
|
-
function
|
|
3956
|
+
__name(_ts_decorate25, "_ts_decorate");
|
|
3957
|
+
function _ts_metadata22(k, v) {
|
|
3513
3958
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
3514
3959
|
}
|
|
3515
|
-
__name(
|
|
3960
|
+
__name(_ts_metadata22, "_ts_metadata");
|
|
3516
3961
|
var OFFERING_INTEGRATION_MAPPING_ALREADY_EXISTS = "OFFERING_INTEGRATION_MAPPING_ALREADY_EXISTS";
|
|
3517
3962
|
var VALID_JOURNEY_VALUES = /* @__PURE__ */ new Set([
|
|
3518
3963
|
"SESSION",
|
|
@@ -3583,10 +4028,10 @@ exports.TrybeIntegrationResourceManagementService = class TrybeIntegrationResour
|
|
|
3583
4028
|
return await super.updateOfferingIntegrationResourceConfiguration(input, context);
|
|
3584
4029
|
}
|
|
3585
4030
|
};
|
|
3586
|
-
exports.TrybeIntegrationResourceManagementService =
|
|
4031
|
+
exports.TrybeIntegrationResourceManagementService = _ts_decorate25([
|
|
3587
4032
|
common.Injectable(),
|
|
3588
|
-
|
|
3589
|
-
|
|
4033
|
+
_ts_metadata22("design:type", Function),
|
|
4034
|
+
_ts_metadata22("design:paramtypes", [
|
|
3590
4035
|
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
|
|
3591
4036
|
typeof exports.IntegrationResourceManagementDao === "undefined" ? Object : exports.IntegrationResourceManagementDao
|
|
3592
4037
|
])
|
|
@@ -3665,6 +4110,263 @@ var fetchAllPages = /* @__PURE__ */ __name(async (firstPageResponse, shouldFetch
|
|
|
3665
4110
|
}
|
|
3666
4111
|
return items;
|
|
3667
4112
|
}, "fetchAllPages");
|
|
4113
|
+
var getLocalDateAndTime = /* @__PURE__ */ __name((zone, utcDate = /* @__PURE__ */ new Date()) => {
|
|
4114
|
+
const localDateInZone = new Date(convertUTCDateToTimezoneDate(zone, new Date(utcDate)));
|
|
4115
|
+
const date = localDateInZone.toISOString().split("T")[0];
|
|
4116
|
+
const time = `${localDateInZone.getHours().toString().padStart(2, "0")}:${localDateInZone.getMinutes().toString().padStart(2, "0")}:${localDateInZone.getSeconds().toString().padStart(2, "0")}`;
|
|
4117
|
+
return {
|
|
4118
|
+
date,
|
|
4119
|
+
time
|
|
4120
|
+
};
|
|
4121
|
+
}, "getLocalDateAndTime");
|
|
4122
|
+
var convertUTCDateToTimezoneDate = /* @__PURE__ */ __name((zone, utcDate) => {
|
|
4123
|
+
const zoneOffset = dvssBackendModuleUtility.getCurrentOffsetFromTimezone(zone, utcDate);
|
|
4124
|
+
const zoneOffsetTimeStamp = zoneOffset * 60 * 1e3;
|
|
4125
|
+
const dateTimeStamp = utcDate.getTime() + zoneOffsetTimeStamp;
|
|
4126
|
+
return new Date(dateTimeStamp).toISOString();
|
|
4127
|
+
}, "convertUTCDateToTimezoneDate");
|
|
4128
|
+
function normalizeTimeOnly(time) {
|
|
4129
|
+
if (!time) {
|
|
4130
|
+
return "";
|
|
4131
|
+
}
|
|
4132
|
+
const parts = time.split(":");
|
|
4133
|
+
const hh = parts[0]?.padStart(2, "0") ?? "00";
|
|
4134
|
+
const mm = parts[1]?.padStart(2, "0") ?? "00";
|
|
4135
|
+
const ss = parts[2]?.padStart(2, "0") ?? "00";
|
|
4136
|
+
return `${hh}:${mm}:${ss}`;
|
|
4137
|
+
}
|
|
4138
|
+
__name(normalizeTimeOnly, "normalizeTimeOnly");
|
|
4139
|
+
function getSummaryLabelsInPropertyTimezone(timezone, summary) {
|
|
4140
|
+
if (!summary?.startTime || !summary.duration) {
|
|
4141
|
+
throw new dvssBackendModuleUtility.CustomException("BAD_REQUEST", void 0, "Missing start_time or duration in booking summary");
|
|
4142
|
+
}
|
|
4143
|
+
const start = new Date(summary.startTime);
|
|
4144
|
+
const durationMinutes = summary.duration;
|
|
4145
|
+
const end = new Date(start.getTime() + durationMinutes * 60 * 1e3);
|
|
4146
|
+
const startInTz = getLocalDateAndTime(timezone, start);
|
|
4147
|
+
const endInTz = getLocalDateAndTime(timezone, end);
|
|
4148
|
+
return {
|
|
4149
|
+
start,
|
|
4150
|
+
end,
|
|
4151
|
+
startDateLabel: startInTz.date,
|
|
4152
|
+
endDateLabel: endInTz.date,
|
|
4153
|
+
startTimeLabel: normalizeTimeOnly(startInTz.time.slice(0, 5)),
|
|
4154
|
+
endTimeLabel: normalizeTimeOnly(endInTz.time.slice(0, 5))
|
|
4155
|
+
};
|
|
4156
|
+
}
|
|
4157
|
+
__name(getSummaryLabelsInPropertyTimezone, "getSummaryLabelsInPropertyTimezone");
|
|
4158
|
+
|
|
4159
|
+
// ../../packages/dvss-integration-trybe/src/utils/webhook/trybe-webhook-util.ts
|
|
4160
|
+
function _ts_decorate26(decorators, target, key, desc2) {
|
|
4161
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4162
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
4163
|
+
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;
|
|
4164
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4165
|
+
}
|
|
4166
|
+
__name(_ts_decorate26, "_ts_decorate");
|
|
4167
|
+
function _ts_metadata23(k, v) {
|
|
4168
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4169
|
+
}
|
|
4170
|
+
__name(_ts_metadata23, "_ts_metadata");
|
|
4171
|
+
exports.TrybeWebhookUtilService = class TrybeWebhookUtilService {
|
|
4172
|
+
static {
|
|
4173
|
+
__name(this, "TrybeWebhookUtilService");
|
|
4174
|
+
}
|
|
4175
|
+
integrationBookingDao;
|
|
4176
|
+
logger;
|
|
4177
|
+
fileName = "trybe-webhook-util";
|
|
4178
|
+
constructor(integrationBookingDao, logger) {
|
|
4179
|
+
this.integrationBookingDao = integrationBookingDao;
|
|
4180
|
+
this.logger = logger;
|
|
4181
|
+
}
|
|
4182
|
+
mapTrybeOrderToBookingInput(bookingData, userIdentityId, ids) {
|
|
4183
|
+
this.logger.debug(dvssBackendModuleUtility.SYSTEM_USER_ID, this.mapTrybeOrderToBookingInput.name, this.fileName, "Mapping Trybe order to booking input", {
|
|
4184
|
+
orderId: bookingData.orderId,
|
|
4185
|
+
bookingItems: bookingData.bookingItems,
|
|
4186
|
+
userIdentityId
|
|
4187
|
+
});
|
|
4188
|
+
const allBookingItems = bookingData.bookingItems ?? [];
|
|
4189
|
+
const bookingItems = allBookingItems.filter((item) => item.status === "confirmed");
|
|
4190
|
+
if (bookingItems.length === 0) {
|
|
4191
|
+
this.logger.warn(dvssBackendModuleUtility.SYSTEM_USER_ID, this.mapTrybeOrderToBookingInput.name, this.fileName, "No confirmed booking items in Trybe order; skipping booking creation", {
|
|
4192
|
+
orderId: bookingData.orderId,
|
|
4193
|
+
allItemsCount: allBookingItems.length,
|
|
4194
|
+
allItemStatuses: allBookingItems.map((b) => ({
|
|
4195
|
+
id: b.id,
|
|
4196
|
+
status: b.status
|
|
4197
|
+
}))
|
|
4198
|
+
});
|
|
4199
|
+
throw new dvssBackendModuleUtility.CustomException("BAD_REQUEST", void 0, "No confirmed booking items in order", {
|
|
4200
|
+
orderId: bookingData.orderId
|
|
4201
|
+
});
|
|
4202
|
+
}
|
|
4203
|
+
if (bookingItems.length > 1) {
|
|
4204
|
+
this.logger.warn(dvssBackendModuleUtility.SYSTEM_USER_ID, this.mapTrybeOrderToBookingInput.name, this.fileName, "Multiple confirmed booking items received from Trybe; processing only first", {
|
|
4205
|
+
orderId: bookingData.orderId,
|
|
4206
|
+
bookingItemIds: bookingItems.map((b) => b.id),
|
|
4207
|
+
totalConfirmedItems: bookingItems.length
|
|
4208
|
+
});
|
|
4209
|
+
}
|
|
4210
|
+
const primaryBookingItem = bookingItems[0];
|
|
4211
|
+
const bookingSummary = primaryBookingItem.bookingSummary;
|
|
4212
|
+
const isCourse = primaryBookingItem.itemType === "course";
|
|
4213
|
+
let bookingStartDateLabel;
|
|
4214
|
+
let bookingStartTimeLabel;
|
|
4215
|
+
let bookingEndTimeLabel;
|
|
4216
|
+
let durationInMinutes;
|
|
4217
|
+
if (isCourse) {
|
|
4218
|
+
const orderCreatedAt = bookingData.createdAt ? new Date(bookingData.createdAt) : /* @__PURE__ */ new Date();
|
|
4219
|
+
bookingStartDateLabel = orderCreatedAt.toISOString().split("T")[0];
|
|
4220
|
+
bookingStartTimeLabel = orderCreatedAt.toTimeString().slice(0, 5);
|
|
4221
|
+
durationInMinutes = void 0;
|
|
4222
|
+
this.logger.info(dvssBackendModuleUtility.SYSTEM_USER_ID, this.mapTrybeOrderToBookingInput.name, this.fileName, "Course booking detected - using order created_at as booking date/time", {
|
|
4223
|
+
orderId: bookingData.orderId,
|
|
4224
|
+
bookingItemId: primaryBookingItem.id,
|
|
4225
|
+
typeId: primaryBookingItem.typeId,
|
|
4226
|
+
bookingStartDateLabel,
|
|
4227
|
+
bookingStartTimeLabel
|
|
4228
|
+
});
|
|
4229
|
+
} else {
|
|
4230
|
+
if (!bookingSummary) {
|
|
4231
|
+
throw new dvssBackendModuleUtility.CustomException("BAD_REQUEST", void 0, "No booking summary in primary booking item", {
|
|
4232
|
+
orderId: bookingData.orderId,
|
|
4233
|
+
bookingItemId: primaryBookingItem.id
|
|
4234
|
+
});
|
|
4235
|
+
}
|
|
4236
|
+
const timezoneForLabels = ids.propertyTimezone ?? dvssBackendModuleUtility.DEFAULT_TIMEZONE;
|
|
4237
|
+
const durationFromPayload = typeof bookingSummary.duration === "number" ? bookingSummary.duration : void 0;
|
|
4238
|
+
if (durationFromPayload === void 0) {
|
|
4239
|
+
this.logger.warn(dvssBackendModuleUtility.SYSTEM_USER_ID, this.mapTrybeOrderToBookingInput.name, this.fileName, "Duration is missing from booking summary, skipping booking creation", {
|
|
4240
|
+
orderId: bookingData.orderId,
|
|
4241
|
+
bookingItemId: primaryBookingItem.id,
|
|
4242
|
+
bookingSummary
|
|
4243
|
+
});
|
|
4244
|
+
throw new dvssBackendModuleUtility.CustomException("BAD_REQUEST", void 0, "Duration is missing from booking summary", {
|
|
4245
|
+
orderId: bookingData.orderId,
|
|
4246
|
+
bookingItemId: primaryBookingItem.id
|
|
4247
|
+
});
|
|
4248
|
+
}
|
|
4249
|
+
const labels = getSummaryLabelsInPropertyTimezone(timezoneForLabels, {
|
|
4250
|
+
startTime: bookingSummary.startTime,
|
|
4251
|
+
duration: durationFromPayload
|
|
4252
|
+
});
|
|
4253
|
+
bookingStartDateLabel = labels.startDateLabel;
|
|
4254
|
+
bookingStartTimeLabel = labels.startTimeLabel;
|
|
4255
|
+
bookingEndTimeLabel = labels.endTimeLabel;
|
|
4256
|
+
durationInMinutes = durationFromPayload;
|
|
4257
|
+
}
|
|
4258
|
+
const totalCost = bookingData.totalCost;
|
|
4259
|
+
const totalPaidOrAuthed = Number(bookingData.totalPaidOrAuthed) || 0;
|
|
4260
|
+
const dueAmount = totalCost - totalPaidOrAuthed;
|
|
4261
|
+
const paymentStatus = dueAmount === 0 ? "paid" : "unpaid";
|
|
4262
|
+
const bookingInput = {
|
|
4263
|
+
name: `Booking from Trybe Order ${bookingData.orderRef || bookingData.orderId}`,
|
|
4264
|
+
description: `Booking created from Trybe order ${bookingData.orderId}`,
|
|
4265
|
+
offeringId: ids.offeringId,
|
|
4266
|
+
offeringIntentId: ids.intentId,
|
|
4267
|
+
offeringJourneyId: ids.journeyId,
|
|
4268
|
+
projectId: ids.projectId,
|
|
4269
|
+
propertyId: ids.propertyId,
|
|
4270
|
+
bookingStartDateLabel,
|
|
4271
|
+
bookingStartTimeLabel,
|
|
4272
|
+
bookingEndTimeLabel,
|
|
4273
|
+
durationInMinutes,
|
|
4274
|
+
items: bookingItems.map((b) => ({
|
|
4275
|
+
externalId: b.typeId,
|
|
4276
|
+
type: this.mapTrybeItemTypeToEnum(b.itemType),
|
|
4277
|
+
resources: b.bookingSummary?.practitioners?.map((p) => ({
|
|
4278
|
+
id: p.id,
|
|
4279
|
+
type: dvssBackendModuleUtility.OFFERING_RESOURCE_TYPE.PEOPLE
|
|
4280
|
+
})) ?? []
|
|
4281
|
+
})),
|
|
4282
|
+
meta: {
|
|
4283
|
+
createdViaWebhook: true,
|
|
4284
|
+
externalId: bookingData.orderId,
|
|
4285
|
+
orderRef: bookingData.orderRef,
|
|
4286
|
+
items: bookingItems.map((b) => ({
|
|
4287
|
+
id: b.id,
|
|
4288
|
+
externalId: b.typeId,
|
|
4289
|
+
type: this.mapTrybeItemTypeToEnum(b.itemType),
|
|
4290
|
+
name: b.typeName,
|
|
4291
|
+
totalPrice: b.totalCost
|
|
4292
|
+
})),
|
|
4293
|
+
payments: bookingData.payments,
|
|
4294
|
+
totalCost,
|
|
4295
|
+
totalPaidOrAuthed,
|
|
4296
|
+
dueAmount,
|
|
4297
|
+
paymentStatus
|
|
4298
|
+
},
|
|
4299
|
+
requestedForUserIdentityId: userIdentityId,
|
|
4300
|
+
bookingType: dvssBackendModuleDatastore.OFFERING_BOOKING_TYPE_ENUM.USER,
|
|
4301
|
+
shouldNotifyUsers: true
|
|
4302
|
+
};
|
|
4303
|
+
return bookingInput;
|
|
4304
|
+
}
|
|
4305
|
+
async mapTrybeOrderToUpdateOfferingBookingStatusInput(offeringBookingOccurrenceId, offeringBookingId, targetStatusCategory, note) {
|
|
4306
|
+
this.logger.debug(dvssBackendModuleUtility.SYSTEM_USER_ID, this.mapTrybeOrderToUpdateOfferingBookingStatusInput.name, this.fileName, "Mapping Trybe order to cancel booking input", {
|
|
4307
|
+
offeringBookingOccurrenceId,
|
|
4308
|
+
offeringBookingId,
|
|
4309
|
+
targetStatusCategory,
|
|
4310
|
+
note
|
|
4311
|
+
});
|
|
4312
|
+
const occurrence = await this.integrationBookingDao.getOfferingBookingOccurrence({
|
|
4313
|
+
offeringBookingOccurrenceId,
|
|
4314
|
+
loggedInUserId: dvssBackendModuleUtility.SYSTEM_USER_ID,
|
|
4315
|
+
offeringBookingId
|
|
4316
|
+
});
|
|
4317
|
+
if (!occurrence) {
|
|
4318
|
+
throw new dvssBackendModuleUtility.CustomException("BAD_REQUEST", void 0, "Offering booking occurrence not found", {
|
|
4319
|
+
offeringBookingOccurrenceId,
|
|
4320
|
+
offeringBookingId
|
|
4321
|
+
});
|
|
4322
|
+
}
|
|
4323
|
+
const intent = await this.integrationBookingDao.getOfferingIntent({
|
|
4324
|
+
offeringIntentId: occurrence.offeringIntentId
|
|
4325
|
+
});
|
|
4326
|
+
if (!intent) {
|
|
4327
|
+
throw new dvssBackendModuleUtility.CustomException("BAD_REQUEST", void 0, "Offering intent not found", {
|
|
4328
|
+
offeringIntentId: occurrence.offeringIntentId
|
|
4329
|
+
});
|
|
4330
|
+
}
|
|
4331
|
+
const statusInput = {
|
|
4332
|
+
offeringId: occurrence.offering.id,
|
|
4333
|
+
offeringBookingOccurrenceIds: [
|
|
4334
|
+
offeringBookingOccurrenceId
|
|
4335
|
+
],
|
|
4336
|
+
targetStatusCategory,
|
|
4337
|
+
note
|
|
4338
|
+
};
|
|
4339
|
+
const response = {
|
|
4340
|
+
statusInput,
|
|
4341
|
+
occurrence: occurrence.offeringBookingOccurrence,
|
|
4342
|
+
offering: occurrence.offering,
|
|
4343
|
+
offeringIntent: intent
|
|
4344
|
+
};
|
|
4345
|
+
return response;
|
|
4346
|
+
}
|
|
4347
|
+
mapTrybeItemTypeToEnum(trybeItemType) {
|
|
4348
|
+
switch (trybeItemType) {
|
|
4349
|
+
case "appointment":
|
|
4350
|
+
return dvssBackendModuleDatastore.OFFERING_BOOKING_BOOKED_ITEM_TYPE.APPOINTMENT;
|
|
4351
|
+
case "session":
|
|
4352
|
+
return dvssBackendModuleDatastore.OFFERING_BOOKING_BOOKED_ITEM_TYPE.SESSION;
|
|
4353
|
+
case "course":
|
|
4354
|
+
return dvssBackendModuleDatastore.OFFERING_BOOKING_BOOKED_ITEM_TYPE.COURSE;
|
|
4355
|
+
default: {
|
|
4356
|
+
const invalid = trybeItemType;
|
|
4357
|
+
throw new dvssBackendModuleUtility.CustomException("BAD_REQUEST", void 0, `Invalid Trybe item type: ${invalid}`);
|
|
4358
|
+
}
|
|
4359
|
+
}
|
|
4360
|
+
}
|
|
4361
|
+
};
|
|
4362
|
+
exports.TrybeWebhookUtilService = _ts_decorate26([
|
|
4363
|
+
common.Injectable(),
|
|
4364
|
+
_ts_metadata23("design:type", Function),
|
|
4365
|
+
_ts_metadata23("design:paramtypes", [
|
|
4366
|
+
typeof exports.IntegrationBookingDao === "undefined" ? Object : exports.IntegrationBookingDao,
|
|
4367
|
+
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService
|
|
4368
|
+
])
|
|
4369
|
+
], exports.TrybeWebhookUtilService);
|
|
3668
4370
|
var TRYBE_WEEKDAYS_MAPPING = {
|
|
3669
4371
|
monday: models.DAY_OF_WEEK.MON,
|
|
3670
4372
|
tuesday: models.DAY_OF_WEEK.TUE,
|
|
@@ -4057,30 +4759,28 @@ function mapTrybeAppointmentAvailabilityToSystemResponse(slots) {
|
|
|
4057
4759
|
__name(mapTrybeAppointmentAvailabilityToSystemResponse, "mapTrybeAppointmentAvailabilityToSystemResponse");
|
|
4058
4760
|
|
|
4059
4761
|
// ../../packages/dvss-integration-trybe/src/capabilities/wellness/wellness-management.service.ts
|
|
4060
|
-
function
|
|
4762
|
+
function _ts_decorate27(decorators, target, key, desc2) {
|
|
4061
4763
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4062
4764
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
4063
4765
|
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;
|
|
4064
4766
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4065
4767
|
}
|
|
4066
|
-
__name(
|
|
4067
|
-
function
|
|
4768
|
+
__name(_ts_decorate27, "_ts_decorate");
|
|
4769
|
+
function _ts_metadata24(k, v) {
|
|
4068
4770
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4069
4771
|
}
|
|
4070
|
-
__name(
|
|
4772
|
+
__name(_ts_metadata24, "_ts_metadata");
|
|
4071
4773
|
exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
4072
4774
|
static {
|
|
4073
4775
|
__name(this, "TrybeWellnessManagement");
|
|
4074
4776
|
}
|
|
4075
4777
|
logger;
|
|
4076
|
-
|
|
4077
|
-
trybeAuthService;
|
|
4778
|
+
trybeApiClientService;
|
|
4078
4779
|
integrationCommonDao;
|
|
4079
4780
|
fileName = "wellness-management.service";
|
|
4080
|
-
constructor(logger,
|
|
4781
|
+
constructor(logger, trybeApiClientService, integrationCommonDao) {
|
|
4081
4782
|
this.logger = logger;
|
|
4082
|
-
this.
|
|
4083
|
-
this.trybeAuthService = trybeAuthService;
|
|
4783
|
+
this.trybeApiClientService = trybeApiClientService;
|
|
4084
4784
|
this.integrationCommonDao = integrationCommonDao;
|
|
4085
4785
|
}
|
|
4086
4786
|
fetchWellnessAppointmentSession() {
|
|
@@ -4119,22 +4819,19 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4119
4819
|
async createOrder(request, integration, loggedInUserId) {
|
|
4120
4820
|
let orderId;
|
|
4121
4821
|
try {
|
|
4122
|
-
const
|
|
4123
|
-
const siteId = validated.config.integrationConfig.siteId;
|
|
4822
|
+
const siteId = integration.config?.integrationConfig?.siteId;
|
|
4124
4823
|
const offering = await this.getOffering({
|
|
4125
4824
|
offeringId: request.bookableItems[0].externalId,
|
|
4126
4825
|
offeringType: request.bookableItems[0].type
|
|
4127
4826
|
}, integration, loggedInUserId);
|
|
4128
|
-
const res = await this.
|
|
4827
|
+
const res = await this.trybeApiClientService.executeRequest({
|
|
4129
4828
|
apiMethod: HTTP_METHOD.POST,
|
|
4130
4829
|
url: "/shop/orders",
|
|
4131
|
-
baseUrl: validated.config.platformConfig.baseUrl,
|
|
4132
|
-
headers: validated.headers,
|
|
4133
4830
|
body: {
|
|
4134
4831
|
site_id: siteId,
|
|
4135
4832
|
status: "new"
|
|
4136
4833
|
}
|
|
4137
|
-
},
|
|
4834
|
+
}, integration, loggedInUserId);
|
|
4138
4835
|
orderId = res.data.id;
|
|
4139
4836
|
const items = [];
|
|
4140
4837
|
await this.addCustomerToOrder(orderId, request.customerId, integration, loggedInUserId);
|
|
@@ -4179,9 +4876,10 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4179
4876
|
orderReference: submitOrderResponse.data?.order_ref ?? order.meta.orderReference,
|
|
4180
4877
|
room: bookableItems.find((item) => item.booking_summary?.room?.id)?.booking_summary?.room,
|
|
4181
4878
|
total: (submitOrderResponse.data?.totals?.total ?? 0) / request.currencyMultiplier,
|
|
4182
|
-
subTotal: (submitOrderResponse.data?.totals?.subtotal ?? 0) / request.currencyMultiplier,
|
|
4183
|
-
totalTax: (submitOrderResponse.data?.
|
|
4184
|
-
discount: (submitOrderResponse.data?.discount_total ?? 0) / request.currencyMultiplier
|
|
4879
|
+
subTotal: ((submitOrderResponse.data?.totals?.subtotal ?? 0) - (submitOrderResponse.data?.totals?.exclusive_tax ?? 0)) / request.currencyMultiplier,
|
|
4880
|
+
totalTax: (submitOrderResponse.data?.taxes?.reduce((acc, tax) => acc + (tax.amount ?? 0), 0) ?? 0) / request.currencyMultiplier,
|
|
4881
|
+
discount: (submitOrderResponse.data?.discount_total ?? 0) / request.currencyMultiplier,
|
|
4882
|
+
serviceCharge: (submitOrderResponse.data?.service_charge?.amount ?? 0) / request.currencyMultiplier
|
|
4185
4883
|
},
|
|
4186
4884
|
items: bookableItems.map((bookableItem) => {
|
|
4187
4885
|
return {
|
|
@@ -4214,17 +4912,14 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4214
4912
|
orderId,
|
|
4215
4913
|
customerId
|
|
4216
4914
|
});
|
|
4217
|
-
|
|
4218
|
-
await this.trafficGatewayService.executeIntegrationRequest({
|
|
4915
|
+
await this.trybeApiClientService.executeRequest({
|
|
4219
4916
|
apiMethod: HTTP_METHOD.POST,
|
|
4220
4917
|
url: `/shop/orders/${orderId}/customer`,
|
|
4221
|
-
baseUrl: validated.config.platformConfig.baseUrl,
|
|
4222
|
-
headers: validated.headers,
|
|
4223
4918
|
body: {
|
|
4224
4919
|
id: customerId,
|
|
4225
4920
|
source: "trybe"
|
|
4226
4921
|
}
|
|
4227
|
-
},
|
|
4922
|
+
}, integration, loggedInUserId);
|
|
4228
4923
|
this.logger.info(loggedInUserId, this.addCustomerToOrder.name, this.fileName, "Successfully added customer to Trybe order", {
|
|
4229
4924
|
orderId,
|
|
4230
4925
|
customerId
|
|
@@ -4234,13 +4929,10 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4234
4929
|
this.logger.info(loggedInUserId, this.getOrder.name, this.fileName, "Fetching Trybe order details", {
|
|
4235
4930
|
orderId
|
|
4236
4931
|
});
|
|
4237
|
-
const
|
|
4238
|
-
const res = await this.trafficGatewayService.executeIntegrationRequest({
|
|
4932
|
+
const res = await this.trybeApiClientService.executeRequest({
|
|
4239
4933
|
apiMethod: HTTP_METHOD.GET,
|
|
4240
|
-
url: `/shop/orders/${orderId}
|
|
4241
|
-
|
|
4242
|
-
headers: validated.headers
|
|
4243
|
-
}, validated, loggedInUserId);
|
|
4934
|
+
url: `/shop/orders/${orderId}`
|
|
4935
|
+
}, integration, loggedInUserId);
|
|
4244
4936
|
this.logger.info(loggedInUserId, this.getOrder.name, this.fileName, "Successfully fetched Trybe order details", {
|
|
4245
4937
|
orderId,
|
|
4246
4938
|
guestCount: res.data.guests.length
|
|
@@ -4275,7 +4967,6 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4275
4967
|
offeringId: request.item.offeringId,
|
|
4276
4968
|
offeringType: request.item.offeringType
|
|
4277
4969
|
});
|
|
4278
|
-
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4279
4970
|
const { orderId, item } = request;
|
|
4280
4971
|
const offeringType = this.mapOfferingTypeToTrybeApi(item.offeringType);
|
|
4281
4972
|
let body;
|
|
@@ -4315,13 +5006,11 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4315
5006
|
guest_ids: item.guestIds
|
|
4316
5007
|
};
|
|
4317
5008
|
}
|
|
4318
|
-
const res = await this.
|
|
5009
|
+
const res = await this.trybeApiClientService.executeRequest({
|
|
4319
5010
|
apiMethod: HTTP_METHOD.POST,
|
|
4320
5011
|
url: `/shop/orders/${orderId}/items`,
|
|
4321
|
-
baseUrl: validated.config.platformConfig.baseUrl,
|
|
4322
|
-
headers: validated.headers,
|
|
4323
5012
|
body
|
|
4324
|
-
},
|
|
5013
|
+
}, integration, loggedInUserId);
|
|
4325
5014
|
const data = res.data;
|
|
4326
5015
|
const result = {
|
|
4327
5016
|
name: data.booking_summary?.offering?.name ?? data.type_name ?? void 0,
|
|
@@ -4340,16 +5029,13 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4340
5029
|
orderId,
|
|
4341
5030
|
customerCreditId
|
|
4342
5031
|
});
|
|
4343
|
-
|
|
4344
|
-
await this.trafficGatewayService.executeIntegrationRequest({
|
|
5032
|
+
await this.trybeApiClientService.executeRequest({
|
|
4345
5033
|
apiMethod: HTTP_METHOD.POST,
|
|
4346
5034
|
url: `/shop/orders/${orderId}/customer-credits`,
|
|
4347
|
-
baseUrl: validated.config.platformConfig.baseUrl,
|
|
4348
|
-
headers: validated.headers,
|
|
4349
5035
|
body: {
|
|
4350
5036
|
id: customerCreditId
|
|
4351
5037
|
}
|
|
4352
|
-
},
|
|
5038
|
+
}, integration, loggedInUserId);
|
|
4353
5039
|
this.logger.info(loggedInUserId, this.addCustomerCreditsToOrder.name, this.fileName, "Successfully added customer credits to Trybe order", {
|
|
4354
5040
|
orderId,
|
|
4355
5041
|
customerCreditId
|
|
@@ -4359,13 +5045,10 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4359
5045
|
this.logger.info(loggedInUserId, this.submitOrder.name, this.fileName, "Submitting Trybe order", {
|
|
4360
5046
|
orderId
|
|
4361
5047
|
});
|
|
4362
|
-
const
|
|
4363
|
-
const response = await this.trafficGatewayService.executeIntegrationRequest({
|
|
5048
|
+
const response = await this.trybeApiClientService.executeRequest({
|
|
4364
5049
|
apiMethod: HTTP_METHOD.POST,
|
|
4365
|
-
url: `/shop/orders/${orderId}/submit
|
|
4366
|
-
|
|
4367
|
-
headers: validated.headers
|
|
4368
|
-
}, validated, loggedInUserId);
|
|
5050
|
+
url: `/shop/orders/${orderId}/submit`
|
|
5051
|
+
}, integration, loggedInUserId);
|
|
4369
5052
|
this.logger.info(loggedInUserId, this.submitOrder.name, this.fileName, "Successfully submitted Trybe order", {
|
|
4370
5053
|
orderId
|
|
4371
5054
|
});
|
|
@@ -4375,13 +5058,10 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4375
5058
|
this.logger.info(loggedInUserId, this.cancelOrder.name, this.fileName, "Cancelling Trybe order", {
|
|
4376
5059
|
orderId
|
|
4377
5060
|
});
|
|
4378
|
-
|
|
4379
|
-
await this.trafficGatewayService.executeIntegrationRequest({
|
|
5061
|
+
await this.trybeApiClientService.executeRequest({
|
|
4380
5062
|
apiMethod: HTTP_METHOD.POST,
|
|
4381
|
-
url: `/shop/orders/${orderId}/cancel
|
|
4382
|
-
|
|
4383
|
-
headers: validated.headers
|
|
4384
|
-
}, validated, loggedInUserId);
|
|
5063
|
+
url: `/shop/orders/${orderId}/cancel`
|
|
5064
|
+
}, integration, loggedInUserId);
|
|
4385
5065
|
this.logger.info(loggedInUserId, this.cancelOrder.name, this.fileName, "Successfully cancelled Trybe order", {
|
|
4386
5066
|
orderId
|
|
4387
5067
|
});
|
|
@@ -4415,7 +5095,6 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4415
5095
|
itemId,
|
|
4416
5096
|
offeringType: request.item.type
|
|
4417
5097
|
});
|
|
4418
|
-
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4419
5098
|
const offeringType = this.mapOfferingTypeToTrybeApi(request.item.type);
|
|
4420
5099
|
let body;
|
|
4421
5100
|
if (offeringType === TRYBE_OFFERING_TYPE_API.APPOINTMENT) {
|
|
@@ -4445,13 +5124,11 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4445
5124
|
} else {
|
|
4446
5125
|
throw new Error("Course is not updatable");
|
|
4447
5126
|
}
|
|
4448
|
-
const response = await this.
|
|
5127
|
+
const response = await this.trybeApiClientService.executeRequest({
|
|
4449
5128
|
apiMethod: HTTP_METHOD.PUT,
|
|
4450
5129
|
url: `/shop/orders/${orderId}/items/${itemId}`,
|
|
4451
|
-
baseUrl: validated.config.platformConfig.baseUrl,
|
|
4452
|
-
headers: validated.headers,
|
|
4453
5130
|
body
|
|
4454
|
-
},
|
|
5131
|
+
}, integration, loggedInUserId);
|
|
4455
5132
|
this.logger.info(loggedInUserId, this.updateOrderItem.name, this.fileName, "Successfully updated Trybe order item", {
|
|
4456
5133
|
orderId,
|
|
4457
5134
|
itemId
|
|
@@ -4464,12 +5141,9 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4464
5141
|
amount: request.amount,
|
|
4465
5142
|
paymentTypeId: request.paymentTypeId
|
|
4466
5143
|
});
|
|
4467
|
-
|
|
4468
|
-
await this.trafficGatewayService.executeIntegrationRequest({
|
|
5144
|
+
await this.trybeApiClientService.executeRequest({
|
|
4469
5145
|
apiMethod: HTTP_METHOD.POST,
|
|
4470
5146
|
url: `/shop/orders/${request.orderId}/payments`,
|
|
4471
|
-
baseUrl: validated.config.platformConfig.baseUrl,
|
|
4472
|
-
headers: validated.headers,
|
|
4473
5147
|
body: {
|
|
4474
5148
|
amount: request.amount,
|
|
4475
5149
|
processor: "manual",
|
|
@@ -4479,7 +5153,7 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4479
5153
|
payment_type_id: request.paymentTypeId
|
|
4480
5154
|
}
|
|
4481
5155
|
}
|
|
4482
|
-
},
|
|
5156
|
+
}, integration, loggedInUserId);
|
|
4483
5157
|
this.logger.info(loggedInUserId, this.addPaymentToOrder.name, this.fileName, "Successfully added payment to Trybe order", {
|
|
4484
5158
|
orderId: request.orderId,
|
|
4485
5159
|
amount: request.amount
|
|
@@ -4490,8 +5164,7 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4490
5164
|
request
|
|
4491
5165
|
});
|
|
4492
5166
|
try {
|
|
4493
|
-
const
|
|
4494
|
-
const siteId = validatedIntegration.config.integrationConfig.siteId;
|
|
5167
|
+
const siteId = integration.config?.integrationConfig?.siteId;
|
|
4495
5168
|
if (request.shouldFetchAllAppointments && request.options?.page !== void 0) {
|
|
4496
5169
|
throw new Error("Pagination options are not supported when fetching all appointments.");
|
|
4497
5170
|
}
|
|
@@ -4504,18 +5177,14 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4504
5177
|
}
|
|
4505
5178
|
const queryString = query.toString();
|
|
4506
5179
|
const apiUrl = `/shop/appointment-types?site_id=${siteId}` + (request.practitionerIds && request.practitionerIds.length > 0 ? `&practitioner_id=${request.practitionerIds.join(",")}` : "") + (queryString ? `&${queryString}` : "");
|
|
4507
|
-
const firstPageResponse = await this.
|
|
5180
|
+
const firstPageResponse = await this.trybeApiClientService.executeRequest({
|
|
4508
5181
|
apiMethod: HTTP_METHOD.GET,
|
|
4509
|
-
url: apiUrl
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
}, validatedIntegration, loggedInUserId);
|
|
4513
|
-
const records = await fetchAllPages(firstPageResponse, request.shouldFetchAllAppointments, (page) => this.trafficGatewayService.executeIntegrationRequest({
|
|
5182
|
+
url: apiUrl
|
|
5183
|
+
}, integration, loggedInUserId);
|
|
5184
|
+
const records = await fetchAllPages(firstPageResponse, request.shouldFetchAllAppointments, (page) => this.trybeApiClientService.executeRequest({
|
|
4514
5185
|
apiMethod: HTTP_METHOD.GET,
|
|
4515
|
-
url: `${apiUrl}&page=${page}
|
|
4516
|
-
|
|
4517
|
-
headers: validatedIntegration.headers
|
|
4518
|
-
}, validatedIntegration, loggedInUserId));
|
|
5186
|
+
url: `${apiUrl}&page=${page}`
|
|
5187
|
+
}, integration, loggedInUserId));
|
|
4519
5188
|
this.logger.info(loggedInUserId, this.fetchAppointments.name, this.fileName, "Successfully fetched Trybe appointments", {
|
|
4520
5189
|
totalRecords: firstPageResponse.meta.total
|
|
4521
5190
|
});
|
|
@@ -4530,15 +5199,12 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4530
5199
|
request
|
|
4531
5200
|
});
|
|
4532
5201
|
try {
|
|
4533
|
-
const
|
|
4534
|
-
const siteId = validatedIntegration.config.integrationConfig.siteId;
|
|
5202
|
+
const siteId = integration.config?.integrationConfig?.siteId;
|
|
4535
5203
|
const apiUrl = `/shop/appointment-types/${request.appointmentId}?site_id=${siteId}`;
|
|
4536
|
-
const response = await this.
|
|
5204
|
+
const response = await this.trybeApiClientService.executeRequest({
|
|
4537
5205
|
apiMethod: HTTP_METHOD.GET,
|
|
4538
|
-
url: apiUrl
|
|
4539
|
-
|
|
4540
|
-
headers: validatedIntegration.headers
|
|
4541
|
-
}, validatedIntegration, loggedInUserId);
|
|
5206
|
+
url: apiUrl
|
|
5207
|
+
}, integration, loggedInUserId);
|
|
4542
5208
|
this.logger.info(loggedInUserId, this.fetchAppointments.name, this.fileName, "Successfully fetched Trybe appointments", {
|
|
4543
5209
|
appointmentId: request.appointmentId
|
|
4544
5210
|
});
|
|
@@ -4553,8 +5219,7 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4553
5219
|
request
|
|
4554
5220
|
});
|
|
4555
5221
|
try {
|
|
4556
|
-
const
|
|
4557
|
-
const siteId = validatedIntegration.config.integrationConfig.siteId;
|
|
5222
|
+
const siteId = integration.config?.integrationConfig?.siteId;
|
|
4558
5223
|
if (request.shouldFetchAllSessions && request.options?.page !== void 0) {
|
|
4559
5224
|
throw new Error("Pagination options are not supported when fetching all sessions.");
|
|
4560
5225
|
}
|
|
@@ -4567,18 +5232,14 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4567
5232
|
}
|
|
4568
5233
|
const queryString = query.toString();
|
|
4569
5234
|
const apiUrl = `/shop/session-types?site_id=${siteId}` + (request.practitionerIds && request.practitionerIds.length > 0 ? `&practitioner_id=${request.practitionerIds.join(",")}` : "") + (queryString ? `&${queryString}` : "");
|
|
4570
|
-
const firstPageResponse = await this.
|
|
5235
|
+
const firstPageResponse = await this.trybeApiClientService.executeRequest({
|
|
4571
5236
|
apiMethod: HTTP_METHOD.GET,
|
|
4572
|
-
url: apiUrl
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
}, validatedIntegration, loggedInUserId);
|
|
4576
|
-
const records = await fetchAllPages(firstPageResponse, request.shouldFetchAllSessions, (page) => this.trafficGatewayService.executeIntegrationRequest({
|
|
5237
|
+
url: apiUrl
|
|
5238
|
+
}, integration, loggedInUserId);
|
|
5239
|
+
const records = await fetchAllPages(firstPageResponse, request.shouldFetchAllSessions, (page) => this.trybeApiClientService.executeRequest({
|
|
4577
5240
|
apiMethod: HTTP_METHOD.GET,
|
|
4578
|
-
url: `${apiUrl}&page=${page}
|
|
4579
|
-
|
|
4580
|
-
headers: validatedIntegration.headers
|
|
4581
|
-
}, validatedIntegration, loggedInUserId));
|
|
5241
|
+
url: `${apiUrl}&page=${page}`
|
|
5242
|
+
}, integration, loggedInUserId));
|
|
4582
5243
|
this.logger.info(loggedInUserId, this.fetchSessions.name, this.fileName, "Successfully fetched Trybe sessions", {
|
|
4583
5244
|
totalRecords: firstPageResponse.meta.total
|
|
4584
5245
|
});
|
|
@@ -4593,15 +5254,12 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4593
5254
|
request
|
|
4594
5255
|
});
|
|
4595
5256
|
try {
|
|
4596
|
-
const
|
|
4597
|
-
const siteId = validatedIntegration.config.integrationConfig.siteId;
|
|
5257
|
+
const siteId = integration.config?.integrationConfig?.siteId;
|
|
4598
5258
|
const apiUrl = `/shop/session-types/${request.sessionId}?site_id=${siteId}`;
|
|
4599
|
-
return await this.
|
|
5259
|
+
return await this.trybeApiClientService.executeRequest({
|
|
4600
5260
|
apiMethod: HTTP_METHOD.GET,
|
|
4601
|
-
url: apiUrl
|
|
4602
|
-
|
|
4603
|
-
headers: validatedIntegration.headers
|
|
4604
|
-
}, validatedIntegration, loggedInUserId);
|
|
5261
|
+
url: apiUrl
|
|
5262
|
+
}, integration, loggedInUserId);
|
|
4605
5263
|
} catch (err) {
|
|
4606
5264
|
this.logger.error(loggedInUserId, this.fetchSession.name, this.fileName, "Error fetching Trybe session", err);
|
|
4607
5265
|
throw err;
|
|
@@ -4612,8 +5270,7 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4612
5270
|
request
|
|
4613
5271
|
});
|
|
4614
5272
|
try {
|
|
4615
|
-
const
|
|
4616
|
-
const organisationId = validatedIntegration.config.integrationConfig.organisationId;
|
|
5273
|
+
const organisationId = integration.config?.integrationConfig?.organisationId;
|
|
4617
5274
|
if (request.shouldFetchAllCourses && request.options?.page !== void 0) {
|
|
4618
5275
|
throw new Error("Pagination options are not supported when fetching all courses.");
|
|
4619
5276
|
}
|
|
@@ -4626,18 +5283,14 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4626
5283
|
}
|
|
4627
5284
|
const queryString = query.toString();
|
|
4628
5285
|
const apiUrl = `/shop/course-types?organisation_id=${organisationId}` + (queryString ? `&${queryString}` : "");
|
|
4629
|
-
const firstPageResponse = await this.
|
|
5286
|
+
const firstPageResponse = await this.trybeApiClientService.executeRequest({
|
|
4630
5287
|
apiMethod: HTTP_METHOD.GET,
|
|
4631
|
-
url: apiUrl
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
}, validatedIntegration, loggedInUserId);
|
|
4635
|
-
const records = await fetchAllPages(firstPageResponse, request.shouldFetchAllCourses, (page) => this.trafficGatewayService.executeIntegrationRequest({
|
|
5288
|
+
url: apiUrl
|
|
5289
|
+
}, integration, loggedInUserId);
|
|
5290
|
+
const records = await fetchAllPages(firstPageResponse, request.shouldFetchAllCourses, (page) => this.trybeApiClientService.executeRequest({
|
|
4636
5291
|
apiMethod: HTTP_METHOD.GET,
|
|
4637
|
-
url: `${apiUrl}&page=${page}
|
|
4638
|
-
|
|
4639
|
-
headers: validatedIntegration.headers
|
|
4640
|
-
}, validatedIntegration, loggedInUserId));
|
|
5292
|
+
url: `${apiUrl}&page=${page}`
|
|
5293
|
+
}, integration, loggedInUserId));
|
|
4641
5294
|
this.logger.info(loggedInUserId, this.fetchCourses.name, this.fileName, "Successfully fetched Trybe courses", {
|
|
4642
5295
|
totalRecords: firstPageResponse.meta.total
|
|
4643
5296
|
});
|
|
@@ -4652,15 +5305,12 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4652
5305
|
request
|
|
4653
5306
|
});
|
|
4654
5307
|
try {
|
|
4655
|
-
const
|
|
4656
|
-
const organisationId = validatedIntegration.config.integrationConfig.organisationId;
|
|
5308
|
+
const organisationId = integration.config?.integrationConfig?.organisationId;
|
|
4657
5309
|
const apiUrl = `/shop/course-types/${request.courseId}?organisation_id=${organisationId}`;
|
|
4658
|
-
const response = await this.
|
|
5310
|
+
const response = await this.trybeApiClientService.executeRequest({
|
|
4659
5311
|
apiMethod: HTTP_METHOD.GET,
|
|
4660
|
-
url: apiUrl
|
|
4661
|
-
|
|
4662
|
-
headers: validatedIntegration.headers
|
|
4663
|
-
}, validatedIntegration, loggedInUserId);
|
|
5312
|
+
url: apiUrl
|
|
5313
|
+
}, integration, loggedInUserId);
|
|
4664
5314
|
this.logger.info(loggedInUserId, this.fetchCourse.name, this.fileName, "Successfully fetched Trybe course", {
|
|
4665
5315
|
courseId: request.courseId
|
|
4666
5316
|
});
|
|
@@ -4675,21 +5325,16 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4675
5325
|
request
|
|
4676
5326
|
});
|
|
4677
5327
|
try {
|
|
4678
|
-
const
|
|
4679
|
-
const siteId = validatedIntegration.config.integrationConfig.siteId;
|
|
5328
|
+
const siteId = integration.config?.integrationConfig?.siteId;
|
|
4680
5329
|
const apiUrl = `/shop/practitioners/?site_id=${siteId}`;
|
|
4681
|
-
const firstPageResponse = await this.
|
|
5330
|
+
const firstPageResponse = await this.trybeApiClientService.executeRequest({
|
|
4682
5331
|
apiMethod: HTTP_METHOD.GET,
|
|
4683
|
-
url: apiUrl
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
}, validatedIntegration, loggedInUserId);
|
|
4687
|
-
const records = await fetchAllPages(firstPageResponse, request.shouldFetchAllPractitioners, (page) => this.trafficGatewayService.executeIntegrationRequest({
|
|
5332
|
+
url: apiUrl
|
|
5333
|
+
}, integration, loggedInUserId);
|
|
5334
|
+
const records = await fetchAllPages(firstPageResponse, request.shouldFetchAllPractitioners, (page) => this.trybeApiClientService.executeRequest({
|
|
4688
5335
|
apiMethod: HTTP_METHOD.GET,
|
|
4689
|
-
url: `${apiUrl}&page=${page}
|
|
4690
|
-
|
|
4691
|
-
headers: validatedIntegration.headers
|
|
4692
|
-
}, validatedIntegration, loggedInUserId));
|
|
5336
|
+
url: `${apiUrl}&page=${page}`
|
|
5337
|
+
}, integration, loggedInUserId));
|
|
4693
5338
|
this.logger.info(loggedInUserId, this.fetchPractitioners.name, this.fileName, "Successfully fetched Trybe practitioners", {
|
|
4694
5339
|
totalRecords: firstPageResponse.meta.total
|
|
4695
5340
|
});
|
|
@@ -4704,8 +5349,7 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4704
5349
|
request
|
|
4705
5350
|
});
|
|
4706
5351
|
try {
|
|
4707
|
-
const
|
|
4708
|
-
const organisationId = validatedIntegration.config.integrationConfig.organisationId;
|
|
5352
|
+
const organisationId = integration.config?.integrationConfig?.organisationId;
|
|
4709
5353
|
if (request.shouldFetchAllCategories && request.options?.page !== void 0) {
|
|
4710
5354
|
throw new Error("Pagination options are not supported when fetching all categories.");
|
|
4711
5355
|
}
|
|
@@ -4718,18 +5362,14 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4718
5362
|
}
|
|
4719
5363
|
const queryString = query.toString();
|
|
4720
5364
|
const apiUrl = `/shop/organisations/${organisationId}/categories` + (queryString ? `?${queryString}` : "");
|
|
4721
|
-
const firstPageResponse = await this.
|
|
5365
|
+
const firstPageResponse = await this.trybeApiClientService.executeRequest({
|
|
4722
5366
|
apiMethod: HTTP_METHOD.GET,
|
|
4723
|
-
url: apiUrl
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
}, validatedIntegration, loggedInUserId);
|
|
4727
|
-
const records = await fetchAllPages(firstPageResponse, request.shouldFetchAllCategories, (page) => this.trafficGatewayService.executeIntegrationRequest({
|
|
5367
|
+
url: apiUrl
|
|
5368
|
+
}, integration, loggedInUserId);
|
|
5369
|
+
const records = await fetchAllPages(firstPageResponse, request.shouldFetchAllCategories, (page) => this.trybeApiClientService.executeRequest({
|
|
4728
5370
|
apiMethod: HTTP_METHOD.GET,
|
|
4729
|
-
url: `${apiUrl}${apiUrl.includes("?") ? "&" : "?"}page=${page}
|
|
4730
|
-
|
|
4731
|
-
headers: validatedIntegration.headers
|
|
4732
|
-
}, validatedIntegration, loggedInUserId));
|
|
5371
|
+
url: `${apiUrl}${apiUrl.includes("?") ? "&" : "?"}page=${page}`
|
|
5372
|
+
}, integration, loggedInUserId));
|
|
4733
5373
|
this.logger.info(loggedInUserId, this.fetchCategories.name, this.fileName, "Successfully fetched Trybe categories", {
|
|
4734
5374
|
totalRecords: firstPageResponse.meta.total
|
|
4735
5375
|
});
|
|
@@ -4744,7 +5384,6 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4744
5384
|
request
|
|
4745
5385
|
});
|
|
4746
5386
|
try {
|
|
4747
|
-
const validatedIntegration = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4748
5387
|
const query = new URLSearchParams();
|
|
4749
5388
|
if (request.options?.page != null) {
|
|
4750
5389
|
query.set("page", String(request.options.page));
|
|
@@ -4754,12 +5393,10 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4754
5393
|
}
|
|
4755
5394
|
const queryString = query.toString();
|
|
4756
5395
|
const apiUrl = `/shop/coupon-codes/${request.couponCodeId}/offering-discounts` + (queryString ? `?${queryString}` : "");
|
|
4757
|
-
const response = await this.
|
|
5396
|
+
const response = await this.trybeApiClientService.executeRequest({
|
|
4758
5397
|
apiMethod: HTTP_METHOD.GET,
|
|
4759
|
-
url: apiUrl
|
|
4760
|
-
|
|
4761
|
-
headers: validatedIntegration.headers
|
|
4762
|
-
}, validatedIntegration, loggedInUserId);
|
|
5398
|
+
url: apiUrl
|
|
5399
|
+
}, integration, loggedInUserId);
|
|
4763
5400
|
this.logger.info(loggedInUserId, this.fetchBookableItemsFromCredit.name, this.fileName, "Successfully fetched bookable items from credit", {
|
|
4764
5401
|
couponCodeId: request.couponCodeId
|
|
4765
5402
|
});
|
|
@@ -4774,8 +5411,7 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4774
5411
|
request
|
|
4775
5412
|
});
|
|
4776
5413
|
try {
|
|
4777
|
-
const
|
|
4778
|
-
const siteId = validatedIntegration.config.integrationConfig.siteId;
|
|
5414
|
+
const siteId = integration.config?.integrationConfig?.siteId;
|
|
4779
5415
|
const finalTimezone = await this.integrationCommonDao.getTimezoneForRequest({
|
|
4780
5416
|
projectId: integration.projectId,
|
|
4781
5417
|
loggedInUserId
|
|
@@ -4788,12 +5424,10 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4788
5424
|
const formattedDateTimeFrom = formatDateForTrybe(request.dateTimeFrom, true, finalTimezone);
|
|
4789
5425
|
const formattedDateTimeTo = formatDateForTrybe(request.dateTimeTo, false, finalTimezone);
|
|
4790
5426
|
const apiUrl = `/shop/item-availability/sessions/${siteId}/${request.externalOfferingBookableItemId}?date_time_from=${encodeURIComponent(formattedDateTimeFrom)}&date_time_to=${encodeURIComponent(formattedDateTimeTo)}&offeringId=${request.externalOfferingBookableItemId}`;
|
|
4791
|
-
const response = await this.
|
|
5427
|
+
const response = await this.trybeApiClientService.executeRequest({
|
|
4792
5428
|
apiMethod: HTTP_METHOD.GET,
|
|
4793
|
-
url: apiUrl
|
|
4794
|
-
|
|
4795
|
-
headers: validatedIntegration.headers
|
|
4796
|
-
}, validatedIntegration, loggedInUserId);
|
|
5429
|
+
url: apiUrl
|
|
5430
|
+
}, integration, loggedInUserId);
|
|
4797
5431
|
this.logger.info(loggedInUserId, this.fetchSessionAvailabilityForOffering.name, this.fileName, "Successfully fetched session availability for offering", {
|
|
4798
5432
|
externalOfferingBookableItemId: request.externalOfferingBookableItemId
|
|
4799
5433
|
});
|
|
@@ -4808,8 +5442,7 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4808
5442
|
request
|
|
4809
5443
|
});
|
|
4810
5444
|
try {
|
|
4811
|
-
const
|
|
4812
|
-
const siteId = validatedIntegration.config.integrationConfig.siteId;
|
|
5445
|
+
const siteId = integration.config?.integrationConfig?.siteId;
|
|
4813
5446
|
const finalTimezone = await this.integrationCommonDao.getTimezoneForRequest({
|
|
4814
5447
|
projectId: integration.projectId,
|
|
4815
5448
|
loggedInUserId
|
|
@@ -4822,12 +5455,10 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4822
5455
|
const formattedDateTimeFrom = formatDateForTrybe(request.dateTimeFrom, true, finalTimezone);
|
|
4823
5456
|
const formattedDateTimeTo = formatDateForTrybe(request.dateTimeTo, false, finalTimezone);
|
|
4824
5457
|
const apiUrl = `/shop/item-availability/appointment-slots/${siteId}/${request.externalOfferingBookableItemId}?date_time_from=${encodeURIComponent(formattedDateTimeFrom)}&date_time_to=${encodeURIComponent(formattedDateTimeTo)}&OfferingID=${request.externalOfferingBookableItemId}`;
|
|
4825
|
-
const response = await this.
|
|
5458
|
+
const response = await this.trybeApiClientService.executeRequest({
|
|
4826
5459
|
apiMethod: HTTP_METHOD.GET,
|
|
4827
|
-
url: apiUrl
|
|
4828
|
-
|
|
4829
|
-
headers: validatedIntegration.headers
|
|
4830
|
-
}, validatedIntegration, loggedInUserId);
|
|
5460
|
+
url: apiUrl
|
|
5461
|
+
}, integration, loggedInUserId);
|
|
4831
5462
|
this.logger.info(loggedInUserId, this.fetchAppointmentAvailabilityForOffering.name, this.fileName, "Successfully fetched appointment availability for offering", {
|
|
4832
5463
|
externalOfferingBookableItemId: request.externalOfferingBookableItemId
|
|
4833
5464
|
});
|
|
@@ -4850,13 +5481,12 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4850
5481
|
}
|
|
4851
5482
|
}
|
|
4852
5483
|
};
|
|
4853
|
-
exports.TrybeWellnessManagement =
|
|
5484
|
+
exports.TrybeWellnessManagement = _ts_decorate27([
|
|
4854
5485
|
common.Injectable(),
|
|
4855
|
-
|
|
4856
|
-
|
|
5486
|
+
_ts_metadata24("design:type", Function),
|
|
5487
|
+
_ts_metadata24("design:paramtypes", [
|
|
4857
5488
|
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
|
|
4858
|
-
typeof exports.
|
|
4859
|
-
typeof exports.TrybeAuthService === "undefined" ? Object : exports.TrybeAuthService,
|
|
5489
|
+
typeof exports.TrybeApiClientService === "undefined" ? Object : exports.TrybeApiClientService,
|
|
4860
5490
|
typeof exports.IntegrationCommonDao === "undefined" ? Object : exports.IntegrationCommonDao
|
|
4861
5491
|
])
|
|
4862
5492
|
], exports.TrybeWellnessManagement);
|
|
@@ -4866,19 +5496,19 @@ dotenv.config({
|
|
|
4866
5496
|
});
|
|
4867
5497
|
|
|
4868
5498
|
// ../../packages/dvss-integration-trybe/src/app.module.ts
|
|
4869
|
-
function
|
|
5499
|
+
function _ts_decorate28(decorators, target, key, desc2) {
|
|
4870
5500
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4871
5501
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
4872
5502
|
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;
|
|
4873
5503
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4874
5504
|
}
|
|
4875
|
-
__name(
|
|
5505
|
+
__name(_ts_decorate28, "_ts_decorate");
|
|
4876
5506
|
exports.IntegrationTrybeModule = class AppModule2 {
|
|
4877
5507
|
static {
|
|
4878
5508
|
__name(this, "AppModule");
|
|
4879
5509
|
}
|
|
4880
5510
|
};
|
|
4881
|
-
exports.IntegrationTrybeModule =
|
|
5511
|
+
exports.IntegrationTrybeModule = _ts_decorate28([
|
|
4882
5512
|
common.Module({
|
|
4883
5513
|
imports: [
|
|
4884
5514
|
// Load environment variables from root .env file
|
|
@@ -4897,46 +5527,49 @@ exports.IntegrationTrybeModule = _ts_decorate22([
|
|
|
4897
5527
|
providers: [
|
|
4898
5528
|
AppService3,
|
|
4899
5529
|
exports.TrybeAuthService,
|
|
5530
|
+
exports.TrybeApiClientService,
|
|
4900
5531
|
exports.TrybeCustomerManagement,
|
|
4901
5532
|
exports.TrybeCreditBooking,
|
|
4902
5533
|
exports.TrybeWellnessManagement,
|
|
5534
|
+
exports.TrybeWebhookUtilService,
|
|
5535
|
+
exports.IntegrationBookingDao,
|
|
4903
5536
|
exports.IntegrationConfigurationDao,
|
|
4904
5537
|
exports.IntegrationResourceManagementDao,
|
|
4905
5538
|
exports.IntegrationCommonDao,
|
|
4906
5539
|
exports.IntegrationRequestLoggerService,
|
|
4907
5540
|
exports.RateLimiterService,
|
|
4908
5541
|
exports.TrafficGatewayService,
|
|
4909
|
-
exports.TrybeCustomerManagement,
|
|
4910
|
-
exports.TrybeAuthService,
|
|
4911
5542
|
exports.TrybeIntegrationConfigurationService,
|
|
4912
5543
|
exports.TrybeIntegrationResourceManagementService,
|
|
4913
5544
|
dvssBackendModuleDatastore.CommonValidationDatabaseService
|
|
4914
5545
|
],
|
|
4915
5546
|
exports: [
|
|
4916
5547
|
exports.TrybeAuthService,
|
|
5548
|
+
exports.TrybeApiClientService,
|
|
4917
5549
|
exports.TrybeCustomerManagement,
|
|
4918
5550
|
exports.TrybeCreditBooking,
|
|
4919
5551
|
exports.TrybeWellnessManagement,
|
|
4920
5552
|
exports.TrybeIntegrationConfigurationService,
|
|
4921
|
-
exports.TrybeIntegrationResourceManagementService
|
|
5553
|
+
exports.TrybeIntegrationResourceManagementService,
|
|
5554
|
+
exports.TrybeWebhookUtilService
|
|
4922
5555
|
]
|
|
4923
5556
|
})
|
|
4924
5557
|
], exports.IntegrationTrybeModule);
|
|
4925
5558
|
|
|
4926
5559
|
// src/app.module.ts
|
|
4927
|
-
function
|
|
5560
|
+
function _ts_decorate29(decorators, target, key, desc2) {
|
|
4928
5561
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4929
5562
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
4930
5563
|
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;
|
|
4931
5564
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4932
5565
|
}
|
|
4933
|
-
__name(
|
|
5566
|
+
__name(_ts_decorate29, "_ts_decorate");
|
|
4934
5567
|
exports.OfferingIntegrationManager = class AppModule3 {
|
|
4935
5568
|
static {
|
|
4936
5569
|
__name(this, "AppModule");
|
|
4937
5570
|
}
|
|
4938
5571
|
};
|
|
4939
|
-
exports.OfferingIntegrationManager =
|
|
5572
|
+
exports.OfferingIntegrationManager = _ts_decorate29([
|
|
4940
5573
|
common.Module({
|
|
4941
5574
|
imports: [
|
|
4942
5575
|
exports.IntegrationTrybeModule,
|