@dv4resi/dvss-backend-module-offering-im 0.0.13 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +284 -40
- package/dist/index.d.ts +178 -8
- package/dist/index.js +376 -254
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -99,8 +99,8 @@ var AppService2 = class {
|
|
|
99
99
|
__name(this, "AppService");
|
|
100
100
|
}
|
|
101
101
|
/**
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
* Creates an instance of the app service
|
|
103
|
+
*/
|
|
104
104
|
constructor() {
|
|
105
105
|
}
|
|
106
106
|
getHello() {
|
|
@@ -238,10 +238,10 @@ exports.IntegrationRequestLoggerService = class _IntegrationRequestLoggerService
|
|
|
238
238
|
this.logger = logger;
|
|
239
239
|
}
|
|
240
240
|
/**
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
241
|
+
* Log integration request (before making the API call)
|
|
242
|
+
*
|
|
243
|
+
* @param logData - The request log data to be logged
|
|
244
|
+
*/
|
|
245
245
|
logRequest(logData) {
|
|
246
246
|
const { loggedInUserId, method, url, headers, requestBody } = logData;
|
|
247
247
|
this.logger.info(loggedInUserId || dvssBackendModuleUtility.SYSTEM_USER_ID, this.logRequest.name, this.className, `Integration API Request: ${method} ${url}`, {
|
|
@@ -254,10 +254,10 @@ exports.IntegrationRequestLoggerService = class _IntegrationRequestLoggerService
|
|
|
254
254
|
});
|
|
255
255
|
}
|
|
256
256
|
/**
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
257
|
+
* Log integration response (after successful API call)
|
|
258
|
+
*
|
|
259
|
+
* @param logData - The response log data to be logged
|
|
260
|
+
*/
|
|
261
261
|
logResponse(logData) {
|
|
262
262
|
const { loggedInUserId, method, url, statusCode, duration, responseBody } = logData;
|
|
263
263
|
this.logger.info(loggedInUserId || dvssBackendModuleUtility.SYSTEM_USER_ID, this.logResponse.name, this.className, `Integration API Response: ${method} ${url} - ${statusCode} (${duration}ms)`, {
|
|
@@ -271,10 +271,10 @@ exports.IntegrationRequestLoggerService = class _IntegrationRequestLoggerService
|
|
|
271
271
|
});
|
|
272
272
|
}
|
|
273
273
|
/**
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
274
|
+
* Log integration error (after failed API call)
|
|
275
|
+
*
|
|
276
|
+
* @param logData - The error log data to be logged
|
|
277
|
+
*/
|
|
278
278
|
logError(logData) {
|
|
279
279
|
const { loggedInUserId, method, url, statusCode, duration, error, responseBody } = logData;
|
|
280
280
|
this.logger.error(loggedInUserId || dvssBackendModuleUtility.SYSTEM_USER_ID, this.logError.name, this.className, `Integration API Error: ${method} ${url} - ${statusCode || "N/A"} (${duration || 0}ms)`, {
|
|
@@ -289,11 +289,11 @@ exports.IntegrationRequestLoggerService = class _IntegrationRequestLoggerService
|
|
|
289
289
|
});
|
|
290
290
|
}
|
|
291
291
|
/**
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
292
|
+
* Log integration request (legacy method for backward compatibility)
|
|
293
|
+
* This method determines whether to log as request, response, or error based on the logData
|
|
294
|
+
*
|
|
295
|
+
* @param logData - The request log data to be logged
|
|
296
|
+
*/
|
|
297
297
|
logIntegrationRequest(logData) {
|
|
298
298
|
if (logData.error) {
|
|
299
299
|
this.logError(logData);
|
|
@@ -323,10 +323,10 @@ exports.RateLimiterService = class RateLimiterService {
|
|
|
323
323
|
__name(this, "RateLimiterService");
|
|
324
324
|
}
|
|
325
325
|
/**
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
326
|
+
* Validate and enforce rate limit
|
|
327
|
+
*
|
|
328
|
+
* @returns Promise resolving when the rate limit is validated and enforced
|
|
329
|
+
*/
|
|
330
330
|
async validateAndEnforceRateLimit() {
|
|
331
331
|
}
|
|
332
332
|
};
|
|
@@ -359,17 +359,17 @@ exports.TrafficGatewayService = class TrafficGatewayService {
|
|
|
359
359
|
this.rateLimiter = rateLimiter;
|
|
360
360
|
}
|
|
361
361
|
/**
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
362
|
+
* Execute a generic API call to a third-party integration
|
|
363
|
+
*
|
|
364
|
+
* @template TResponse - The expected response type
|
|
365
|
+
* @template TRequestBody - The request body type (optional)
|
|
366
|
+
* @param request - The API call request configuration
|
|
367
|
+
* @param integration - The integration configuration
|
|
368
|
+
* @param loggedInUserId - Optional user ID for logging purposes
|
|
369
|
+
* @param _context - Optional context for deriving rate limits and other settings (projectId, propertyId, etc.)
|
|
370
|
+
* @returns Promise resolving to the API response data
|
|
371
|
+
* @throws Error if the request fails or rate limit is exceeded
|
|
372
|
+
*/
|
|
373
373
|
async executeIntegrationRequest(request, integration, loggedInUserId, _context) {
|
|
374
374
|
const startTime = Date.now();
|
|
375
375
|
try {
|
|
@@ -423,13 +423,13 @@ exports.TrafficGatewayService = class TrafficGatewayService {
|
|
|
423
423
|
}
|
|
424
424
|
}
|
|
425
425
|
/**
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
426
|
+
* Prepare headers for the API request
|
|
427
|
+
*
|
|
428
|
+
* @private
|
|
429
|
+
* @param request - The API call request configuration
|
|
430
|
+
* @param apiKey - The API key for authorization
|
|
431
|
+
* @returns Prepared headers object
|
|
432
|
+
*/
|
|
433
433
|
prepareHeaders(request) {
|
|
434
434
|
request.headerType = request.headerType || "json";
|
|
435
435
|
const headers = {
|
|
@@ -444,13 +444,13 @@ exports.TrafficGatewayService = class TrafficGatewayService {
|
|
|
444
444
|
return headers;
|
|
445
445
|
}
|
|
446
446
|
/**
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
447
|
+
* Prepare request configuration object
|
|
448
|
+
*
|
|
449
|
+
* @private
|
|
450
|
+
* @param request - The API call request configuration
|
|
451
|
+
* @param headers - Prepared headers
|
|
452
|
+
* @returns Request configuration object
|
|
453
|
+
*/
|
|
454
454
|
prepareRequestConfig(request, headers) {
|
|
455
455
|
const requestConfig = {
|
|
456
456
|
headers
|
|
@@ -461,30 +461,30 @@ exports.TrafficGatewayService = class TrafficGatewayService {
|
|
|
461
461
|
return requestConfig;
|
|
462
462
|
}
|
|
463
463
|
/**
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
464
|
+
* Construct full URL from base URL and request URL
|
|
465
|
+
* Handles trailing slashes properly
|
|
466
|
+
*
|
|
467
|
+
* @private
|
|
468
|
+
* @param baseUrl - The base URL from platform config
|
|
469
|
+
* @param requestUrl - The request URL path
|
|
470
|
+
* @returns Constructed full URL
|
|
471
|
+
*/
|
|
472
472
|
constructFullUrl(baseUrl, requestUrl) {
|
|
473
473
|
const normalizedBaseUrl = baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
|
|
474
474
|
const normalizedRequestUrl = requestUrl.startsWith("/") ? requestUrl : `/${requestUrl}`;
|
|
475
475
|
return `${normalizedBaseUrl}${normalizedRequestUrl}`;
|
|
476
476
|
}
|
|
477
477
|
/**
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
478
|
+
* Execute HTTP request based on the method
|
|
479
|
+
*
|
|
480
|
+
* @private
|
|
481
|
+
* @template TResponse - The expected response type
|
|
482
|
+
* @param request - The API call request configuration
|
|
483
|
+
* @param fullUrl - The full URL to make the request to
|
|
484
|
+
* @param requestConfig - The request configuration
|
|
485
|
+
* @returns Promise resolving to the HTTP response
|
|
486
|
+
* @throws Error if the HTTP method is unsupported
|
|
487
|
+
*/
|
|
488
488
|
async executeHttpRequest(request, fullUrl, requestConfig) {
|
|
489
489
|
switch (request.apiMethod) {
|
|
490
490
|
case HTTP_METHOD.GET: {
|
|
@@ -508,18 +508,18 @@ exports.TrafficGatewayService = class TrafficGatewayService {
|
|
|
508
508
|
}
|
|
509
509
|
}
|
|
510
510
|
/**
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
511
|
+
* Extract error details from an error object (e.g. Axios error).
|
|
512
|
+
* Provider-agnostic: derives apiMessage from common response shapes so any integration
|
|
513
|
+
* (Trybe, OAuth, REST, etc.) gets a readable reason. Callers can use statusCode and
|
|
514
|
+
* responseBody to map to their own exceptions (e.g. 404 -> RESOURCE_NOT_FOUND).
|
|
515
|
+
*
|
|
516
|
+
* Supported response.data fields (first string wins): message, error_description,
|
|
517
|
+
* error, detail, msg.
|
|
518
|
+
*
|
|
519
|
+
* @private
|
|
520
|
+
* @param error - The error object
|
|
521
|
+
* @returns Extracted error details including apiMessage for logging and callers
|
|
522
|
+
*/
|
|
523
523
|
extractErrorDetails(error) {
|
|
524
524
|
const errorObject = error;
|
|
525
525
|
const responseData = errorObject.response?.data;
|
|
@@ -779,9 +779,9 @@ exports.BaseIntegrationConfiguration = class BaseIntegrationConfiguration {
|
|
|
779
779
|
this.logger = logger;
|
|
780
780
|
}
|
|
781
781
|
/**
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
782
|
+
* Validates add-capability-integration input (project, property, parent, capability, provider, configuredFor).
|
|
783
|
+
* Logic copied from project-ms CapabilityIntegrationService.validateAddCapabilityIntegrationInput.
|
|
784
|
+
*/
|
|
785
785
|
async validateAddCapabilityIntegrationInput(input, context) {
|
|
786
786
|
await this.commonValidationDatabaseService.getProject({
|
|
787
787
|
projectId: input.projectId
|
|
@@ -830,9 +830,9 @@ exports.BaseIntegrationConfiguration = class BaseIntegrationConfiguration {
|
|
|
830
830
|
};
|
|
831
831
|
}
|
|
832
832
|
/**
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
833
|
+
* Add a capability integration (validate then persist via DAO).
|
|
834
|
+
* Same name as project MS call: addCapabilityIntegration.
|
|
835
|
+
*/
|
|
836
836
|
async addCapabilityIntegration(input, context) {
|
|
837
837
|
const { capability, capabilityProvider } = await this.validateAddCapabilityIntegrationInput(input, context);
|
|
838
838
|
const addCapabilityIntegrationInput = {
|
|
@@ -851,14 +851,14 @@ exports.BaseIntegrationConfiguration = class BaseIntegrationConfiguration {
|
|
|
851
851
|
return result;
|
|
852
852
|
}
|
|
853
853
|
/**
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
854
|
+
* Update capability integration with config merging support.
|
|
855
|
+
* Handles merging of integrationConfig and platformConfig from existing integration.
|
|
856
|
+
*
|
|
857
|
+
* @param request - Update request with id and updateData
|
|
858
|
+
* @param integration - Optional existing integration for config merging
|
|
859
|
+
* @param loggedInUserId - User ID for logging and audit
|
|
860
|
+
* @returns Promise resolving to update status
|
|
861
|
+
*/
|
|
862
862
|
async updateCapabilityIntegration(request, integration, loggedInUserId) {
|
|
863
863
|
if (!loggedInUserId) {
|
|
864
864
|
throw new Error("loggedInUserId is required");
|
|
@@ -897,8 +897,8 @@ exports.BaseIntegrationConfiguration = class BaseIntegrationConfiguration {
|
|
|
897
897
|
}, loggedInUserId);
|
|
898
898
|
}
|
|
899
899
|
/**
|
|
900
|
-
|
|
901
|
-
|
|
900
|
+
* Validates icon and nickname. Can be overridden in subclasses for provider-specific validation.
|
|
901
|
+
*/
|
|
902
902
|
validateIconAndNickName(updateData, loggedInUserId) {
|
|
903
903
|
if (updateData.nickname !== void 0 && (updateData.nickname === "" || updateData.nickname.trim() === "")) {
|
|
904
904
|
this.logger.error(loggedInUserId, this.validateIconAndNickName.name, this.fileName, "Validation failed: nickname cannot be empty or null");
|
|
@@ -913,20 +913,20 @@ exports.BaseIntegrationConfiguration = class BaseIntegrationConfiguration {
|
|
|
913
913
|
}
|
|
914
914
|
}
|
|
915
915
|
/**
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
916
|
+
* Get capability integrations with pagination, filtering, sorting, and search.
|
|
917
|
+
* Delegates to DAO for database operations.
|
|
918
|
+
*
|
|
919
|
+
* @param request - Request with projectId, category, and options
|
|
920
|
+
* @param loggedInUserId - User ID for logging
|
|
921
|
+
* @returns Promise resolving to list of capability integrations with total count
|
|
922
|
+
*/
|
|
923
923
|
async getCapabilityIntegrations(request, loggedInUserId) {
|
|
924
924
|
return await this.integrationConfigurationDao.getCapabilityIntegrations(request, loggedInUserId);
|
|
925
925
|
}
|
|
926
926
|
/**
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
927
|
+
* Get capability integration by id or by fetchBy (configuredFor).
|
|
928
|
+
* Same business logic as project-ms CapabilityIntegrationService.getCapabilityIntegration.
|
|
929
|
+
*/
|
|
930
930
|
async getCapabilityIntegration(input, context) {
|
|
931
931
|
if (!input.projectId) {
|
|
932
932
|
throw new Error("Project ID is required");
|
|
@@ -976,15 +976,15 @@ var BaseIntegrationResourceManagement = class {
|
|
|
976
976
|
this.logger = logger;
|
|
977
977
|
}
|
|
978
978
|
/**
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
979
|
+
* Adds a resource (capability integration) to an offering integration via UIF.
|
|
980
|
+
* Inter-service implementation only: performs DAO insert. Wrapper must validate
|
|
981
|
+
* config and mapping-exists before calling; caller (MS) does getOffering, getIntegration,
|
|
982
|
+
* updateOffering and runAfterAddIfNeeded.
|
|
983
|
+
*
|
|
984
|
+
* @param input - projectId, offeringId, capabilityIntegrationId, optional config
|
|
985
|
+
* @param context - GraphQL context
|
|
986
|
+
* @returns Promise resolving to { status, ids }
|
|
987
|
+
*/
|
|
988
988
|
async addResourceToIntegration(input, context) {
|
|
989
989
|
this.logger.info(context.loggedInUserId, this.addResourceToIntegration.name, this.fileName, "addResourceToIntegration called", {
|
|
990
990
|
offeringId: input.offeringId.toString(),
|
|
@@ -1008,9 +1008,9 @@ var BaseIntegrationResourceManagement = class {
|
|
|
1008
1008
|
return result;
|
|
1009
1009
|
}
|
|
1010
1010
|
/**
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1011
|
+
* Removes a resource from an offering integration.
|
|
1012
|
+
* Generic validation and DAO call; Trybe service adds mapping-exists check before calling.
|
|
1013
|
+
*/
|
|
1014
1014
|
async removeResourceFromIntegration(request, context) {
|
|
1015
1015
|
const result = await this.integrationResourceManagementDao.removeCapabilityIntegrationMapping({
|
|
1016
1016
|
capabilityIntegrationId: request.capabilityIntegrationId,
|
|
@@ -1022,15 +1022,15 @@ var BaseIntegrationResourceManagement = class {
|
|
|
1022
1022
|
};
|
|
1023
1023
|
}
|
|
1024
1024
|
/**
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1025
|
+
* Updates offering integration resource configuration (cap_integ_resource_mapping.config by id).
|
|
1026
|
+
* Inter-service implementation only: performs DAO update. Wrapper must validate config before calling
|
|
1027
|
+
* (e.g. Trybe validates via validateResourceMappingConfig). Caller (MS) does getOffering,
|
|
1028
|
+
* getIntegration, and runAfterUpdateIfNeeded (e.g. handleTrybeIntegration).
|
|
1029
|
+
*
|
|
1030
|
+
* @param input - id (resource mapping row id), config
|
|
1031
|
+
* @param context - GraphQL context
|
|
1032
|
+
* @returns Promise resolving to { status }
|
|
1033
|
+
*/
|
|
1034
1034
|
async updateOfferingIntegrationResourceConfiguration(input, context) {
|
|
1035
1035
|
this.logger.info(context.loggedInUserId, this.updateOfferingIntegrationResourceConfiguration.name, this.fileName, "updateOfferingIntegrationResourceConfiguration called", {
|
|
1036
1036
|
id: input.id.toString()
|
|
@@ -2415,9 +2415,9 @@ exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
|
|
|
2415
2415
|
}
|
|
2416
2416
|
}
|
|
2417
2417
|
/**
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2418
|
+
* Get capability by id (for add-capability-integration validation).
|
|
2419
|
+
* Copied from project-ms CapabilityDaoService.getCapability.
|
|
2420
|
+
*/
|
|
2421
2421
|
async getCapability(request, loggedInUserId) {
|
|
2422
2422
|
try {
|
|
2423
2423
|
this.logger.info(loggedInUserId, this.getCapability.name, this.fileName, "getCapability called", {
|
|
@@ -2434,9 +2434,9 @@ exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
|
|
|
2434
2434
|
}
|
|
2435
2435
|
}
|
|
2436
2436
|
/**
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2437
|
+
* Get capability provider by id (for add-capability-integration validation).
|
|
2438
|
+
* Copied from project-ms CapabilityProviderDao.getCapabilityProvider.
|
|
2439
|
+
*/
|
|
2440
2440
|
async getCapabilityProvider(request, loggedInUserId) {
|
|
2441
2441
|
try {
|
|
2442
2442
|
this.logger.info(loggedInUserId, this.getCapabilityProvider.name, this.fileName, "getCapabilityProvider called", {
|
|
@@ -2453,13 +2453,13 @@ exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
|
|
|
2453
2453
|
}
|
|
2454
2454
|
}
|
|
2455
2455
|
/**
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2456
|
+
* Updates capability integration in the database.
|
|
2457
|
+
* Copied from project-ms CapabilityIntegrationDao.updateCapabilityIntegration.
|
|
2458
|
+
*
|
|
2459
|
+
* @param input - Object containing the integration ID and update data
|
|
2460
|
+
* @param loggedInUserId - User ID for logging
|
|
2461
|
+
* @returns Promise that resolves to the update operation status
|
|
2462
|
+
*/
|
|
2463
2463
|
async updateCapabilityIntegration(input, loggedInUserId) {
|
|
2464
2464
|
try {
|
|
2465
2465
|
this.logger.info(loggedInUserId, this.updateCapabilityIntegration.name, this.fileName, "Updating capability integration");
|
|
@@ -2475,9 +2475,9 @@ exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
|
|
|
2475
2475
|
}
|
|
2476
2476
|
}
|
|
2477
2477
|
/**
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2478
|
+
* Get capability integration by id (for parent validation when parentId is set).
|
|
2479
|
+
* Copied from project-ms CapabilityIntegrationDao.getCapabilityIntegration.
|
|
2480
|
+
*/
|
|
2481
2481
|
async getCapabilityIntegration(input, loggedInUserId) {
|
|
2482
2482
|
try {
|
|
2483
2483
|
this.logger.info(loggedInUserId, this.getCapabilityIntegration.name, this.fileName, "getCapabilityIntegration called", input);
|
|
@@ -2490,9 +2490,9 @@ exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
|
|
|
2490
2490
|
}
|
|
2491
2491
|
}
|
|
2492
2492
|
/**
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2493
|
+
* Retrieves capability integration by ID with resource mapping details.
|
|
2494
|
+
* Copied from project-ms CapabilityIntegrationDao.getCapabilityIntegrationById.
|
|
2495
|
+
*/
|
|
2496
2496
|
async getCapabilityIntegrationById(request, loggedInUserId) {
|
|
2497
2497
|
try {
|
|
2498
2498
|
this.logger.info(loggedInUserId, this.getCapabilityIntegrationById.name, this.fileName, "getCapabilityIntegrationById called", request);
|
|
@@ -2522,9 +2522,9 @@ exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
|
|
|
2522
2522
|
}
|
|
2523
2523
|
}
|
|
2524
2524
|
/**
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2525
|
+
* Retrieves capability integration by provider type and resource mapping.
|
|
2526
|
+
* Copied from project-ms CapabilityIntegrationDao.getCapabilityIntegrationByProvider.
|
|
2527
|
+
*/
|
|
2528
2528
|
async getCapabilityIntegrationByProvider(request, loggedInUserId) {
|
|
2529
2529
|
try {
|
|
2530
2530
|
this.logger.info(loggedInUserId, this.getCapabilityIntegrationByProvider.name, this.fileName, "getCapabilityIntegrationByProvider called", request);
|
|
@@ -2557,9 +2557,9 @@ exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
|
|
|
2557
2557
|
}
|
|
2558
2558
|
}
|
|
2559
2559
|
/**
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2560
|
+
* Get capability integrations with pagination, filtering, sorting, and search.
|
|
2561
|
+
* Copied from project-ms CapabilityIntegrationDao.getCapabilityIntegrations.
|
|
2562
|
+
*/
|
|
2563
2563
|
async getCapabilityIntegrations(input, loggedInUserId) {
|
|
2564
2564
|
try {
|
|
2565
2565
|
this.logger.info(loggedInUserId, this.getCapabilityIntegrations.name, this.fileName, "getCapabilityIntegrations called", input);
|
|
@@ -2640,8 +2640,8 @@ exports.IntegrationConfigurationDao = class IntegrationConfigurationDao2 {
|
|
|
2640
2640
|
}
|
|
2641
2641
|
}
|
|
2642
2642
|
/**
|
|
2643
|
-
|
|
2644
|
-
|
|
2643
|
+
* Applies filters to where conditions.
|
|
2644
|
+
*/
|
|
2645
2645
|
applyFilters(whereConditions, filters) {
|
|
2646
2646
|
if (!filters || !filters.filters) {
|
|
2647
2647
|
return;
|
|
@@ -2754,13 +2754,13 @@ exports.IntegrationResourceManagementDao = class IntegrationResourceManagementDa
|
|
|
2754
2754
|
this.logger = logger;
|
|
2755
2755
|
}
|
|
2756
2756
|
/**
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2757
|
+
* Adds a capability integration resource mapping (insert into cap_integ_resource_mapping).
|
|
2758
|
+
* Replaces inter-service gRPC call to project-onboarding-ms for add configurations.
|
|
2759
|
+
*
|
|
2760
|
+
* @param input - projectId, capabilityIntegrationId, configuredForId, configuredForType, optional config
|
|
2761
|
+
* @param context - GraphQL context for loggedInUserId
|
|
2762
|
+
* @returns Promise resolving to { status: true, ids: [insertedId] } or { status: false, ids: [] }
|
|
2763
|
+
*/
|
|
2764
2764
|
async addCapabilityIntegrationMapping(input, context) {
|
|
2765
2765
|
try {
|
|
2766
2766
|
this.logger.info(context.loggedInUserId, this.addCapabilityIntegrationMapping.name, this.fileName, "Adding capability integration mapping", input);
|
|
@@ -2793,13 +2793,13 @@ exports.IntegrationResourceManagementDao = class IntegrationResourceManagementDa
|
|
|
2793
2793
|
}
|
|
2794
2794
|
}
|
|
2795
2795
|
/**
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2796
|
+
* Checks if a capability integration resource mapping exists.
|
|
2797
|
+
* Validates that the mapping exists for the given capability integration, configured for ID and type.
|
|
2798
|
+
*
|
|
2799
|
+
* @param input - Input containing capability integration ID, configured for ID and type
|
|
2800
|
+
* @param loggedInUserId - ID of the user performing the operation
|
|
2801
|
+
* @returns Promise that resolves to true if mapping exists, false otherwise
|
|
2802
|
+
*/
|
|
2803
2803
|
async checkMappingExists(input, loggedInUserId) {
|
|
2804
2804
|
try {
|
|
2805
2805
|
this.logger.info(loggedInUserId, this.checkMappingExists.name, this.fileName, `${this.checkMappingExists.name} called`, input);
|
|
@@ -2813,14 +2813,14 @@ exports.IntegrationResourceManagementDao = class IntegrationResourceManagementDa
|
|
|
2813
2813
|
}
|
|
2814
2814
|
}
|
|
2815
2815
|
/**
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2816
|
+
* Removes capability integration resource mapping (soft delete).
|
|
2817
|
+
* Sets deletedAt and deletedBy on the matching cap_integ_resource_mapping row.
|
|
2818
|
+
* Use this from UIF/callers instead of inter-service call to project-onboarding-ms.
|
|
2819
|
+
*
|
|
2820
|
+
* @param input - Delete parameters including capability integration ID, configured for ID and type
|
|
2821
|
+
* @param loggedInUserId - ID of the user performing the operation
|
|
2822
|
+
* @returns Promise resolving to { status: true } if any row was updated, { status: false } otherwise
|
|
2823
|
+
*/
|
|
2824
2824
|
async removeCapabilityIntegrationMapping(input, context) {
|
|
2825
2825
|
try {
|
|
2826
2826
|
this.logger.info(context.loggedInUserId, this.removeCapabilityIntegrationMapping.name, this.fileName, "Removing capability integration mapping", input);
|
|
@@ -2847,13 +2847,13 @@ exports.IntegrationResourceManagementDao = class IntegrationResourceManagementDa
|
|
|
2847
2847
|
}
|
|
2848
2848
|
}
|
|
2849
2849
|
/**
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2850
|
+
* Gets a capability integration resource mapping by id (non-deleted only).
|
|
2851
|
+
* Use from UIF wrappers to validate mapping exists before update.
|
|
2852
|
+
*
|
|
2853
|
+
* @param id - cap_integ_resource_mapping.id
|
|
2854
|
+
* @param loggedInUserId - for logging
|
|
2855
|
+
* @returns The mapping row or undefined if not found
|
|
2856
|
+
*/
|
|
2857
2857
|
async getCapabilityIntegrationResourceMappingById(id, loggedInUserId) {
|
|
2858
2858
|
try {
|
|
2859
2859
|
this.logger.info(loggedInUserId, this.getCapabilityIntegrationResourceMappingById.name, this.fileName, `${this.getCapabilityIntegrationResourceMappingById.name} called`, {
|
|
@@ -2874,13 +2874,13 @@ exports.IntegrationResourceManagementDao = class IntegrationResourceManagementDa
|
|
|
2874
2874
|
}
|
|
2875
2875
|
}
|
|
2876
2876
|
/**
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2877
|
+
* Updates capability integration resource mapping config by id.
|
|
2878
|
+
* Replaces inter-service gRPC call to project-onboarding-ms for update capability integration configuration.
|
|
2879
|
+
*
|
|
2880
|
+
* @param input - id (mapping row id), config (new config JSON)
|
|
2881
|
+
* @param context - GraphQL context for loggedInUserId
|
|
2882
|
+
* @returns Promise resolving to { status: true } if row was updated, { status: false } otherwise
|
|
2883
|
+
*/
|
|
2884
2884
|
async updateCapabilityIntegrationConfiguration(input, context) {
|
|
2885
2885
|
try {
|
|
2886
2886
|
this.logger.info(context.loggedInUserId, this.updateCapabilityIntegrationConfiguration.name, this.fileName, "Updating capability integration resource mapping config", {
|
|
@@ -2931,17 +2931,17 @@ exports.TrybeCustomerManagement = class _TrybeCustomerManagement {
|
|
|
2931
2931
|
trafficGatewayService;
|
|
2932
2932
|
fileName = "customer-management.service";
|
|
2933
2933
|
/**
|
|
2934
|
-
|
|
2935
|
-
|
|
2934
|
+
* Creates an instance of the service
|
|
2935
|
+
*/
|
|
2936
2936
|
constructor(logger, trafficGatewayService) {
|
|
2937
2937
|
this.logger = logger;
|
|
2938
2938
|
this.trafficGatewayService = trafficGatewayService;
|
|
2939
2939
|
}
|
|
2940
2940
|
/**
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2941
|
+
* Create a new customer on Trybe (POST /customers/customers).
|
|
2942
|
+
*
|
|
2943
|
+
* @returns Promise resolving to the created customer
|
|
2944
|
+
*/
|
|
2945
2945
|
async createCustomer(request, integration, loggedInUserId) {
|
|
2946
2946
|
this.logger.info(loggedInUserId, this.createCustomer.name, this.fileName, `${_TrybeCustomerManagement.name} -> ${this.createCustomer.name} Called`, {
|
|
2947
2947
|
request
|
|
@@ -2956,11 +2956,11 @@ exports.TrybeCustomerManagement = class _TrybeCustomerManagement {
|
|
|
2956
2956
|
return response.data;
|
|
2957
2957
|
}
|
|
2958
2958
|
/**
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2959
|
+
* Abstract method to search for wellness customers
|
|
2960
|
+
* Must be implemented by concrete classes
|
|
2961
|
+
*
|
|
2962
|
+
* @returns Promise resolving when the search is completed
|
|
2963
|
+
*/
|
|
2964
2964
|
async searchCustomer(request, integration, loggedInUserId) {
|
|
2965
2965
|
this.logger.info(loggedInUserId, this.searchCustomer.name, this.fileName, `${_TrybeCustomerManagement.name} -> ${this.searchCustomer.name} Called`, {
|
|
2966
2966
|
request
|
|
@@ -2994,10 +2994,10 @@ exports.TrybeCustomerManagement = class _TrybeCustomerManagement {
|
|
|
2994
2994
|
}
|
|
2995
2995
|
}
|
|
2996
2996
|
/**
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
2997
|
+
* Update an existing customer on Trybe (PUT /customers/customers/:id), then fetch and return full customer.
|
|
2998
|
+
*
|
|
2999
|
+
* @returns Promise resolving to the updated customer
|
|
3000
|
+
*/
|
|
3001
3001
|
async updateCustomer(customerId, request, integration, loggedInUserId) {
|
|
3002
3002
|
this.logger.info(loggedInUserId, this.updateCustomer.name, this.fileName, `${_TrybeCustomerManagement.name} -> ${this.updateCustomer.name} Called`, {
|
|
3003
3003
|
customerId,
|
|
@@ -3013,8 +3013,8 @@ exports.TrybeCustomerManagement = class _TrybeCustomerManagement {
|
|
|
3013
3013
|
return response.data;
|
|
3014
3014
|
}
|
|
3015
3015
|
/**
|
|
3016
|
-
|
|
3017
|
-
|
|
3016
|
+
* Delete a customer on Trybe.
|
|
3017
|
+
*/
|
|
3018
3018
|
async deleteCustomer(customerId, integration, loggedInUserId) {
|
|
3019
3019
|
try {
|
|
3020
3020
|
this.logger.info(loggedInUserId, this.deleteCustomer.name, this.fileName, `${_TrybeCustomerManagement.name} -> ${this.deleteCustomer.name} Called`, {
|
|
@@ -3075,21 +3075,21 @@ exports.TrybeAuthService = class _TrybeAuthService {
|
|
|
3075
3075
|
logger;
|
|
3076
3076
|
fileName = "auth.service";
|
|
3077
3077
|
/**
|
|
3078
|
-
|
|
3079
|
-
|
|
3078
|
+
* Creates an instance of the Trybe authentication service
|
|
3079
|
+
*/
|
|
3080
3080
|
constructor(trybeCustomerManagement, logger) {
|
|
3081
3081
|
this.trybeCustomerManagement = trybeCustomerManagement;
|
|
3082
3082
|
this.logger = logger;
|
|
3083
3083
|
}
|
|
3084
3084
|
/**
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3085
|
+
* Validates Trybe integration configuration
|
|
3086
|
+
* Checks for required fields: apiKey, siteId, organisationId, and baseUrl
|
|
3087
|
+
*
|
|
3088
|
+
* @param config - Integration configuration object
|
|
3089
|
+
* @param loggedInUserId - User ID for logging
|
|
3090
|
+
* @returns Promise resolving to validated configuration
|
|
3091
|
+
* @throws Error if config is invalid
|
|
3092
|
+
*/
|
|
3093
3093
|
validateConfig(integration, loggedInUserId) {
|
|
3094
3094
|
this.logger.info(loggedInUserId, this.validateConfig.name, this.fileName, `${_TrybeAuthService.name} -> ${this.validateConfig.name} Called`, {
|
|
3095
3095
|
integration
|
|
@@ -3131,14 +3131,14 @@ exports.TrybeAuthService = class _TrybeAuthService {
|
|
|
3131
3131
|
};
|
|
3132
3132
|
}
|
|
3133
3133
|
/**
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3134
|
+
* Tests Trybe integration by making a test API call
|
|
3135
|
+
* Uses a test customer lookup to verify credentials are valid
|
|
3136
|
+
*
|
|
3137
|
+
* @param integration - Integration object with configuration
|
|
3138
|
+
* @param loggedInUserId - User ID for logging
|
|
3139
|
+
* @returns Promise resolving when test is completed
|
|
3140
|
+
* @throws Error if authentication fails or API call fails
|
|
3141
|
+
*/
|
|
3142
3142
|
async testIntegration(integration, loggedInUserId) {
|
|
3143
3143
|
this.logger.info(loggedInUserId, this.testIntegration.name, this.fileName, `${_TrybeAuthService.name} -> ${this.testIntegration.name} Called`, {
|
|
3144
3144
|
integration
|
|
@@ -3151,12 +3151,12 @@ exports.TrybeAuthService = class _TrybeAuthService {
|
|
|
3151
3151
|
return true;
|
|
3152
3152
|
}
|
|
3153
3153
|
/**
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3154
|
+
* Fetches an access token from the Trybe integration provider.
|
|
3155
|
+
*
|
|
3156
|
+
* @param integration - Integration object with configuration
|
|
3157
|
+
* @param loggedInUserId - User ID for logging
|
|
3158
|
+
* @returns Promise resolving to the access token string
|
|
3159
|
+
*/
|
|
3160
3160
|
fetchAccessToken(integration, loggedInUserId) {
|
|
3161
3161
|
this.logger.info(loggedInUserId, this.fetchAccessToken.name, this.fileName, `${_TrybeAuthService.name} -> ${this.fetchAccessToken.name} Called`, {
|
|
3162
3162
|
integration
|
|
@@ -3250,18 +3250,18 @@ exports.TrybeCreditBooking = class _TrybeCreditBooking {
|
|
|
3250
3250
|
trybeAuthService;
|
|
3251
3251
|
fileName = "credit-booking.service";
|
|
3252
3252
|
/**
|
|
3253
|
-
|
|
3254
|
-
|
|
3253
|
+
* Creates an instance of the service
|
|
3254
|
+
*/
|
|
3255
3255
|
constructor(logger, trafficGatewayService, trybeAuthService) {
|
|
3256
3256
|
this.logger = logger;
|
|
3257
3257
|
this.trafficGatewayService = trafficGatewayService;
|
|
3258
3258
|
this.trybeAuthService = trybeAuthService;
|
|
3259
3259
|
}
|
|
3260
3260
|
/**
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3261
|
+
* Fetches customer credits from Trybe and returns system-format response
|
|
3262
|
+
*
|
|
3263
|
+
* @returns Promise resolving to the system customer credits response
|
|
3264
|
+
*/
|
|
3265
3265
|
async fetchCustomerCredits(request, integration, loggedInUserId) {
|
|
3266
3266
|
this.logger.info(loggedInUserId, this.fetchCustomerCredits.name, this.fileName, `${_TrybeCreditBooking.name} -> ${this.fetchCustomerCredits.name} Called`, {
|
|
3267
3267
|
request
|
|
@@ -3775,8 +3775,6 @@ function mapTrybeAppointmentAvailabilityToSystemResponse(slots) {
|
|
|
3775
3775
|
};
|
|
3776
3776
|
}
|
|
3777
3777
|
__name(mapTrybeAppointmentAvailabilityToSystemResponse, "mapTrybeAppointmentAvailabilityToSystemResponse");
|
|
3778
|
-
|
|
3779
|
-
// ../../packages/dvss-integration-trybe/src/capabilities/wellness/wellness-management.service.ts
|
|
3780
3778
|
function _ts_decorate18(decorators, target, key, desc2) {
|
|
3781
3779
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3782
3780
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
@@ -3816,11 +3814,33 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
3816
3814
|
confirmWellnessAppointmentSessionOrder() {
|
|
3817
3815
|
throw new Error("Method not implemented.");
|
|
3818
3816
|
}
|
|
3817
|
+
async getOffering(request, integration, loggedInUserId) {
|
|
3818
|
+
switch (request.offeringType) {
|
|
3819
|
+
case TRYBE_OFFERING_TYPE_ENUM.SESSION:
|
|
3820
|
+
return this.fetchSession({
|
|
3821
|
+
sessionId: request.offeringId
|
|
3822
|
+
}, integration, loggedInUserId);
|
|
3823
|
+
case TRYBE_OFFERING_TYPE_ENUM.COURSE:
|
|
3824
|
+
return this.fetchCourse({
|
|
3825
|
+
courseId: request.offeringId
|
|
3826
|
+
}, integration, loggedInUserId);
|
|
3827
|
+
case TRYBE_OFFERING_TYPE_ENUM.APPOINTMENT:
|
|
3828
|
+
return this.fetchAppointment({
|
|
3829
|
+
appointmentId: request.offeringId
|
|
3830
|
+
}, integration, loggedInUserId);
|
|
3831
|
+
default:
|
|
3832
|
+
throw new Error(`Unsupported offering type: ${request.offeringType}`);
|
|
3833
|
+
}
|
|
3834
|
+
}
|
|
3819
3835
|
async createOrder(request, integration, loggedInUserId) {
|
|
3820
3836
|
let orderId;
|
|
3821
3837
|
try {
|
|
3822
3838
|
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
3823
3839
|
const siteId = validated.config.integrationConfig.siteId;
|
|
3840
|
+
const offering = await this.getOffering({
|
|
3841
|
+
offeringId: request.bookableItems[0].externalId,
|
|
3842
|
+
offeringType: request.bookableItems[0].type
|
|
3843
|
+
}, integration, loggedInUserId);
|
|
3824
3844
|
const res = await this.trafficGatewayService.executeIntegrationRequest({
|
|
3825
3845
|
apiMethod: HTTP_METHOD.POST,
|
|
3826
3846
|
url: "/shop/orders",
|
|
@@ -3852,22 +3872,46 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
3852
3872
|
externalId: bookableItem.externalId,
|
|
3853
3873
|
name: orderItemResponse.name,
|
|
3854
3874
|
type: bookableItem.type,
|
|
3855
|
-
totalPrice: (orderItemResponse.netTotal ?? 0) / request.currencyMultiplier
|
|
3875
|
+
totalPrice: (orderItemResponse.netTotal ?? 0) / request.currencyMultiplier,
|
|
3876
|
+
primaryAsset: bookableItem.externalId === offering.data.id ? offering.data.image?.original_url ? {
|
|
3877
|
+
provider: models.MEDIA_PROVIDER_ENUM.CUSTOM_URL,
|
|
3878
|
+
meta: {
|
|
3879
|
+
url: offering.data.image.original_url
|
|
3880
|
+
}
|
|
3881
|
+
} : void 0 : void 0
|
|
3856
3882
|
});
|
|
3857
3883
|
}
|
|
3858
3884
|
if (request.customerCreditId) {
|
|
3859
3885
|
await this.addCustomerCreditsToOrder(orderId, request.customerCreditId, integration, loggedInUserId);
|
|
3860
3886
|
}
|
|
3861
|
-
await this.submitOrder(orderId, integration, loggedInUserId);
|
|
3887
|
+
const submitOrderResponse = await this.submitOrder(orderId, integration, loggedInUserId);
|
|
3862
3888
|
this.logger.info(loggedInUserId, this.createOrder.name, this.fileName, "Created Trybe order for offering booking", {
|
|
3863
3889
|
orderId
|
|
3864
3890
|
});
|
|
3865
3891
|
return {
|
|
3866
3892
|
externalBookingId: orderId,
|
|
3867
|
-
items,
|
|
3868
3893
|
meta: {
|
|
3869
|
-
orderReference: order.meta.orderReference
|
|
3870
|
-
|
|
3894
|
+
orderReference: submitOrderResponse.data?.order_ref ?? order.meta.orderReference,
|
|
3895
|
+
room: submitOrderResponse.data?.booking_items?.find((item) => item.booking_summary?.room?.id)?.booking_summary?.room,
|
|
3896
|
+
total: (submitOrderResponse.data?.totals?.total ?? 0) / request.currencyMultiplier,
|
|
3897
|
+
subTotal: (submitOrderResponse.data?.totals?.subtotal ?? 0) / request.currencyMultiplier,
|
|
3898
|
+
totalTax: (submitOrderResponse.data?.total_tax ?? 0) / request.currencyMultiplier,
|
|
3899
|
+
discount: (submitOrderResponse.data?.discount_total ?? 0) / request.currencyMultiplier
|
|
3900
|
+
},
|
|
3901
|
+
items: submitOrderResponse.data?.booking_items?.map((bookableItem) => {
|
|
3902
|
+
return {
|
|
3903
|
+
externalId: bookableItem.type_id,
|
|
3904
|
+
name: bookableItem.type_name,
|
|
3905
|
+
type: bookableItem.item_type,
|
|
3906
|
+
totalPrice: bookableItem.net_total,
|
|
3907
|
+
primaryAsset: offering.data.image?.original_url ? {
|
|
3908
|
+
provider: models.MEDIA_PROVIDER_ENUM.CUSTOM_URL,
|
|
3909
|
+
meta: {
|
|
3910
|
+
url: offering.data.image.original_url
|
|
3911
|
+
}
|
|
3912
|
+
} : void 0
|
|
3913
|
+
};
|
|
3914
|
+
}) ?? []
|
|
3871
3915
|
};
|
|
3872
3916
|
} catch (err) {
|
|
3873
3917
|
this.logger.error(loggedInUserId, this.createOrder.name, this.fileName, "Error creating Trybe order for offering booking", err);
|
|
@@ -4028,7 +4072,7 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4028
4072
|
orderId
|
|
4029
4073
|
});
|
|
4030
4074
|
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4031
|
-
await this.trafficGatewayService.executeIntegrationRequest({
|
|
4075
|
+
const response = await this.trafficGatewayService.executeIntegrationRequest({
|
|
4032
4076
|
apiMethod: HTTP_METHOD.POST,
|
|
4033
4077
|
url: `/shop/orders/${orderId}/submit`,
|
|
4034
4078
|
baseUrl: validated.config.platformConfig.baseUrl,
|
|
@@ -4037,6 +4081,7 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4037
4081
|
this.logger.info(loggedInUserId, this.submitOrder.name, this.fileName, "Successfully submitted Trybe order", {
|
|
4038
4082
|
orderId
|
|
4039
4083
|
});
|
|
4084
|
+
return response;
|
|
4040
4085
|
}
|
|
4041
4086
|
async cancelOrder(orderId, integration, loggedInUserId) {
|
|
4042
4087
|
this.logger.info(loggedInUserId, this.cancelOrder.name, this.fileName, "Cancelling Trybe order", {
|
|
@@ -4192,6 +4237,29 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4192
4237
|
throw err;
|
|
4193
4238
|
}
|
|
4194
4239
|
}
|
|
4240
|
+
async fetchAppointment(request, integration, loggedInUserId) {
|
|
4241
|
+
this.logger.info(loggedInUserId, this.fetchAppointment.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchAppointment.name} Called`, {
|
|
4242
|
+
request
|
|
4243
|
+
});
|
|
4244
|
+
try {
|
|
4245
|
+
const validatedIntegration = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4246
|
+
const siteId = validatedIntegration.config.integrationConfig.siteId;
|
|
4247
|
+
const apiUrl = `/shop/appointment-types/${request.appointmentId}?site_id=${siteId}`;
|
|
4248
|
+
const response = await this.trafficGatewayService.executeIntegrationRequest({
|
|
4249
|
+
apiMethod: HTTP_METHOD.GET,
|
|
4250
|
+
url: apiUrl,
|
|
4251
|
+
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4252
|
+
headers: validatedIntegration.headers
|
|
4253
|
+
}, validatedIntegration, loggedInUserId);
|
|
4254
|
+
this.logger.info(loggedInUserId, this.fetchAppointments.name, this.fileName, "Successfully fetched Trybe appointments", {
|
|
4255
|
+
appointmentId: request.appointmentId
|
|
4256
|
+
});
|
|
4257
|
+
return response;
|
|
4258
|
+
} catch (err) {
|
|
4259
|
+
this.logger.error(loggedInUserId, this.fetchAppointments.name, this.fileName, "Error fetching Trybe appointments", err);
|
|
4260
|
+
throw err;
|
|
4261
|
+
}
|
|
4262
|
+
}
|
|
4195
4263
|
async fetchSessions(request, integration, loggedInUserId) {
|
|
4196
4264
|
this.logger.info(loggedInUserId, this.fetchSessions.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchSessions.name} Called`, {
|
|
4197
4265
|
request
|
|
@@ -4232,6 +4300,25 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4232
4300
|
throw err;
|
|
4233
4301
|
}
|
|
4234
4302
|
}
|
|
4303
|
+
async fetchSession(request, integration, loggedInUserId) {
|
|
4304
|
+
this.logger.info(loggedInUserId, this.fetchSession.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchSession.name} Called`, {
|
|
4305
|
+
request
|
|
4306
|
+
});
|
|
4307
|
+
try {
|
|
4308
|
+
const validatedIntegration = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4309
|
+
const siteId = validatedIntegration.config.integrationConfig.siteId;
|
|
4310
|
+
const apiUrl = `/shop/session-types/${request.sessionId}?site_id=${siteId}`;
|
|
4311
|
+
return await this.trafficGatewayService.executeIntegrationRequest({
|
|
4312
|
+
apiMethod: HTTP_METHOD.GET,
|
|
4313
|
+
url: apiUrl,
|
|
4314
|
+
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4315
|
+
headers: validatedIntegration.headers
|
|
4316
|
+
}, validatedIntegration, loggedInUserId);
|
|
4317
|
+
} catch (err) {
|
|
4318
|
+
this.logger.error(loggedInUserId, this.fetchSession.name, this.fileName, "Error fetching Trybe session", err);
|
|
4319
|
+
throw err;
|
|
4320
|
+
}
|
|
4321
|
+
}
|
|
4235
4322
|
async fetchCourses(request, integration, loggedInUserId) {
|
|
4236
4323
|
this.logger.info(loggedInUserId, this.fetchCourses.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchCourses.name} Called`, {
|
|
4237
4324
|
request
|
|
@@ -4272,6 +4359,29 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4272
4359
|
throw err;
|
|
4273
4360
|
}
|
|
4274
4361
|
}
|
|
4362
|
+
async fetchCourse(request, integration, loggedInUserId) {
|
|
4363
|
+
this.logger.info(loggedInUserId, this.fetchCourse.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchCourse.name} Called`, {
|
|
4364
|
+
request
|
|
4365
|
+
});
|
|
4366
|
+
try {
|
|
4367
|
+
const validatedIntegration = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4368
|
+
const organisationId = validatedIntegration.config.integrationConfig.organisationId;
|
|
4369
|
+
const apiUrl = `/shop/course-types/${request.courseId}?organisation_id=${organisationId}`;
|
|
4370
|
+
const response = await this.trafficGatewayService.executeIntegrationRequest({
|
|
4371
|
+
apiMethod: HTTP_METHOD.GET,
|
|
4372
|
+
url: apiUrl,
|
|
4373
|
+
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4374
|
+
headers: validatedIntegration.headers
|
|
4375
|
+
}, validatedIntegration, loggedInUserId);
|
|
4376
|
+
this.logger.info(loggedInUserId, this.fetchCourse.name, this.fileName, "Successfully fetched Trybe course", {
|
|
4377
|
+
courseId: request.courseId
|
|
4378
|
+
});
|
|
4379
|
+
return response;
|
|
4380
|
+
} catch (err) {
|
|
4381
|
+
this.logger.error(loggedInUserId, this.fetchCourse.name, this.fileName, "Error fetching Trybe course", err);
|
|
4382
|
+
throw err;
|
|
4383
|
+
}
|
|
4384
|
+
}
|
|
4275
4385
|
async fetchPractitioners(request, integration, loggedInUserId) {
|
|
4276
4386
|
this.logger.info(loggedInUserId, this.fetchPractitioners.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchPractitioners.name} Called`, {
|
|
4277
4387
|
request
|
|
@@ -4421,6 +4531,18 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4421
4531
|
throw err;
|
|
4422
4532
|
}
|
|
4423
4533
|
}
|
|
4534
|
+
mapTrybeOfferingTypeToBookableItemType(offeringType) {
|
|
4535
|
+
switch (offeringType) {
|
|
4536
|
+
case "appointment":
|
|
4537
|
+
return BOOKABLE_ITEM_TYPE_ENUM.APPOINTMENT;
|
|
4538
|
+
case "session":
|
|
4539
|
+
return BOOKABLE_ITEM_TYPE_ENUM.SESSION;
|
|
4540
|
+
case "course":
|
|
4541
|
+
return BOOKABLE_ITEM_TYPE_ENUM.COURSE;
|
|
4542
|
+
default:
|
|
4543
|
+
throw new Error(`Unsupported offering type: ${offeringType}`);
|
|
4544
|
+
}
|
|
4545
|
+
}
|
|
4424
4546
|
};
|
|
4425
4547
|
exports.TrybeWellnessManagement = _ts_decorate18([
|
|
4426
4548
|
common.Injectable(),
|
|
@@ -4466,8 +4588,8 @@ exports.TrybeIntegrationConfigurationService = class TrybeIntegrationConfigurati
|
|
|
4466
4588
|
super(integrationConfigurationDao, commonValidationDatabaseService, logger), this.trybeAuthService = trybeAuthService, this.trafficGatewayService = trafficGatewayService;
|
|
4467
4589
|
}
|
|
4468
4590
|
/**
|
|
4469
|
-
|
|
4470
|
-
|
|
4591
|
+
* Add capability integration: validate Trybe config, then configuredFor (offering), then delegate to base.
|
|
4592
|
+
*/
|
|
4471
4593
|
async addCapabilityIntegration(input, context) {
|
|
4472
4594
|
this.trybeAuthService.validateConfig({
|
|
4473
4595
|
config: input.config
|
|
@@ -4478,8 +4600,8 @@ exports.TrybeIntegrationConfigurationService = class TrybeIntegrationConfigurati
|
|
|
4478
4600
|
return super.addCapabilityIntegration(input, context);
|
|
4479
4601
|
}
|
|
4480
4602
|
/**
|
|
4481
|
-
|
|
4482
|
-
|
|
4603
|
+
* Update capability integration: convert to new signature and delegate to base.
|
|
4604
|
+
*/
|
|
4483
4605
|
async updateCapabilityIntegration(request, integration, loggedInUserId) {
|
|
4484
4606
|
if (request.updateData.config) {
|
|
4485
4607
|
this.trybeAuthService.validateConfig({
|
|
@@ -4489,8 +4611,8 @@ exports.TrybeIntegrationConfigurationService = class TrybeIntegrationConfigurati
|
|
|
4489
4611
|
return super.updateCapabilityIntegration(request, integration, loggedInUserId);
|
|
4490
4612
|
}
|
|
4491
4613
|
/**
|
|
4492
|
-
|
|
4493
|
-
|
|
4614
|
+
* Validates configuredFor (offering exists and belongs to project). Same as project-ms validateCapabilityIntegrationConfiguredForInput.
|
|
4615
|
+
*/
|
|
4494
4616
|
async validateCapabilityIntegrationConfiguredForInput(configuredFor, projectId) {
|
|
4495
4617
|
if (configuredFor.configuredForType !== models.CONFIGURED_FOR_TYPE_ENUM.OFFERING) {
|
|
4496
4618
|
throw new Error(`configuredForType not supported: ${configuredFor.configuredForType}`);
|
|
@@ -4501,8 +4623,8 @@ exports.TrybeIntegrationConfigurationService = class TrybeIntegrationConfigurati
|
|
|
4501
4623
|
});
|
|
4502
4624
|
}
|
|
4503
4625
|
/**
|
|
4504
|
-
|
|
4505
|
-
|
|
4626
|
+
* Trybe 3rd party: GET /shop/sites/{siteId} via executeIntegrationRequest.
|
|
4627
|
+
*/
|
|
4506
4628
|
async getSiteDetailedInformation(integration, loggedInUserId) {
|
|
4507
4629
|
const validatedIntegration = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4508
4630
|
const siteId = validatedIntegration.config.integrationConfig.siteId;
|
|
@@ -4552,9 +4674,9 @@ exports.TrybeIntegrationResourceManagementService = class TrybeIntegrationResour
|
|
|
4552
4674
|
super(integrationResourceManagementDao, logger);
|
|
4553
4675
|
}
|
|
4554
4676
|
/**
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4677
|
+
* Validates Trybe resource mapping config (same rules as MS trybe-offering-integration-management.service).
|
|
4678
|
+
* @throws CustomException BAD_REQUEST if config is invalid
|
|
4679
|
+
*/
|
|
4558
4680
|
validateResourceMappingConfig(config3) {
|
|
4559
4681
|
const resourceMappingConfig = config3;
|
|
4560
4682
|
if (!resourceMappingConfig.supportedJourneys || resourceMappingConfig.supportedJourneys.length === 0) {
|