microapps-automation-helper
Advanced tools
Comparing version 1.0.10 to 1.1.0
@@ -111,8 +111,8 @@ /** Class representing a Citrix Cloud. */ | ||
/** | ||
* Get all MicroApps in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
*/ | ||
* Get all MicroApps in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
*/ | ||
getApps({ authInstance, microappsAdminUrl }: GetApps): Promise<any>; | ||
@@ -227,2 +227,9 @@ /** | ||
addSecrets({ authInstance, microappsAdminUrl, integrationId, data }: AddSecrets): Promise<any>; | ||
/** | ||
* Get microapp info - pages, components etc... | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} appId - Id of microapp | ||
*/ | ||
getAppInfo({ authInstance, microappsAdminUrl, appId }: GetAppInfo): Promise<any>; | ||
} | ||
@@ -375,1 +382,6 @@ export declare type AddApp = { | ||
}; | ||
export declare type GetAppInfo = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
appId: string; | ||
}; |
277
dist/api.js
@@ -10,2 +10,3 @@ "use strict"; | ||
const path_1 = __importDefault(require("path")); | ||
const helpers_1 = require("./helpers"); | ||
/** Class representing a Citrix Cloud. */ | ||
@@ -27,3 +28,3 @@ class API { | ||
url: `https://trust.${cwaAPI}.net/${citrixCloudCustomerId}/tokens/clients`, | ||
method: "POST", | ||
method: 'POST', | ||
data: { | ||
@@ -36,3 +37,6 @@ clientId: citrixCloudClientId, | ||
catch (error) { | ||
throw error.stack; | ||
await helpers_1.errorHandle({ | ||
error, | ||
args: { cwaAPI, citrixCloudClientId, citrixCloudClientSecret, citrixCloudCustomerId }, | ||
}); | ||
} | ||
@@ -50,7 +54,10 @@ } | ||
url: `${microappsAdminUrl}/api/service`, | ||
method: "GET", | ||
method: 'GET', | ||
}); | ||
} | ||
catch (error) { | ||
throw error.stack; | ||
await helpers_1.errorHandle({ | ||
error, | ||
args: {}, | ||
}); | ||
} | ||
@@ -68,7 +75,10 @@ } | ||
url: `${microappsAdminUrl}/api/bundleCatalogue`, | ||
method: "GET", | ||
method: 'GET', | ||
}); | ||
} | ||
catch (error) { | ||
throw error.stack; | ||
await helpers_1.errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl }, | ||
}); | ||
} | ||
@@ -87,7 +97,10 @@ } | ||
url: `${microappsAdminUrl}/api/bundleCatalogue/import/${catalogueId}`, | ||
method: "POST", | ||
method: 'POST', | ||
}); | ||
} | ||
catch (error) { | ||
throw error.stack; | ||
await helpers_1.errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, catalogueId }, | ||
}); | ||
} | ||
@@ -107,3 +120,3 @@ } | ||
url: `${microappsAdminUrl}/api/service/${integrationId}`, | ||
method: "PUT", | ||
method: 'PUT', | ||
data: integrationConfiguration, | ||
@@ -113,3 +126,6 @@ }); | ||
catch (error) { | ||
throw error.stack; | ||
await helpers_1.errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, integrationId, integrationConfiguration }, | ||
}); | ||
} | ||
@@ -125,6 +141,14 @@ } | ||
async getIntegration({ authInstance, microappsAdminUrl, integrationId }) { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/service/${integrationId}`, | ||
method: "GET", | ||
}); | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/service/${integrationId}`, | ||
method: 'GET', | ||
}); | ||
} | ||
catch (error) { | ||
await helpers_1.errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, integrationId }, | ||
}); | ||
} | ||
} | ||
@@ -142,7 +166,10 @@ /** | ||
url: `${microappsAdminUrl}/api/auth/serviceAction/logout/${integrationId}`, | ||
method: "GET", | ||
method: 'GET', | ||
}); | ||
} | ||
catch (error) { | ||
throw error.stack; | ||
await helpers_1.errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, integrationId }, | ||
}); | ||
} | ||
@@ -162,3 +189,3 @@ } | ||
url: `${microappsAdminUrl}/api/external-services/${serviceKey}/validate-configuration`, | ||
method: "POST", | ||
method: 'POST', | ||
data: { | ||
@@ -168,3 +195,3 @@ configurationParameters: configuration, | ||
useOnPremProxy: false, | ||
resourceLocation: "", | ||
resourceLocation: '', | ||
}, | ||
@@ -175,3 +202,6 @@ }, | ||
catch (error) { | ||
throw error.stack; | ||
await helpers_1.errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, serviceKey, configuration }, | ||
}); | ||
} | ||
@@ -190,3 +220,3 @@ } | ||
url: `${microappsAdminUrl}/api/app`, | ||
method: "POST", | ||
method: 'POST', | ||
data, | ||
@@ -196,3 +226,6 @@ }); | ||
catch (error) { | ||
throw error.stack; | ||
await helpers_1.errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, data }, | ||
}); | ||
} | ||
@@ -211,7 +244,10 @@ } | ||
url: `${microappsAdminUrl}/api/process/${processId}`, | ||
method: "GET", | ||
method: 'GET', | ||
}); | ||
} | ||
catch (error) { | ||
throw error.stack; | ||
await helpers_1.errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, processId }, | ||
}); | ||
} | ||
@@ -230,7 +266,10 @@ } | ||
url: `${microappsAdminUrl}/api/service/${integrationId}/entities`, | ||
method: "GET", | ||
method: 'GET', | ||
}); | ||
} | ||
catch (error) { | ||
throw error.stack; | ||
await helpers_1.errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, integrationId }, | ||
}); | ||
} | ||
@@ -250,3 +289,3 @@ } | ||
url: `${microappsAdminUrl}/api/service/${integrationId}/entities`, | ||
method: "PUT", | ||
method: 'PUT', | ||
data: entityData, | ||
@@ -256,3 +295,6 @@ }); | ||
catch (error) { | ||
throw error.stack; | ||
await helpers_1.errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, integrationId, entityData }, | ||
}); | ||
} | ||
@@ -271,16 +313,19 @@ } | ||
url: `${microappsAdminUrl}/api/service/${integrationId}/finalize-config`, | ||
method: "POST", | ||
method: 'POST', | ||
}); | ||
} | ||
catch (error) { | ||
throw error.stack; | ||
await helpers_1.errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, integrationId }, | ||
}); | ||
} | ||
} | ||
/** | ||
* Get all MicroApps in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
*/ | ||
* Get all MicroApps in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
*/ | ||
async getApps({ authInstance, microappsAdminUrl }) { | ||
@@ -290,7 +335,10 @@ try { | ||
url: `${microappsAdminUrl}/api/app`, | ||
method: "GET", | ||
method: 'GET', | ||
}); | ||
} | ||
catch (error) { | ||
throw error.stack; | ||
await helpers_1.errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl }, | ||
}); | ||
} | ||
@@ -309,7 +357,10 @@ } | ||
url: `${microappsAdminUrl}/api/notifications/app/${appId}`, | ||
method: "GET", | ||
method: 'GET', | ||
}); | ||
} | ||
catch (error) { | ||
throw error.stack; | ||
await helpers_1.errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, appId }, | ||
}); | ||
} | ||
@@ -327,7 +378,10 @@ } | ||
url: `${microappsAdminUrl}/api/notification/${notificationId}/run`, | ||
method: "POST", | ||
method: 'POST', | ||
}); | ||
} | ||
catch (error) { | ||
throw error.stack; | ||
await helpers_1.errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, notificationId }, | ||
}); | ||
} | ||
@@ -346,7 +400,10 @@ } | ||
url: `${microappsAdminUrl}/api/service/${integrationId}/run/${synchronizationType}`, | ||
method: "POST", | ||
method: 'POST', | ||
}); | ||
} | ||
catch (error) { | ||
throw error.stack; | ||
await helpers_1.errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, integrationId, synchronizationType }, | ||
}); | ||
} | ||
@@ -364,7 +421,10 @@ } | ||
url: `${microappsAdminUrl}/api/app/integrity-check`, | ||
method: "GET", | ||
method: 'GET', | ||
}); | ||
} | ||
catch (error) { | ||
throw error.stack; | ||
await helpers_1.errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl }, | ||
}); | ||
} | ||
@@ -383,7 +443,10 @@ } | ||
url: `${microappsAdminUrl}/api/service/${integrationId}`, | ||
method: "DELETE", | ||
method: 'DELETE', | ||
}); | ||
} | ||
catch (error) { | ||
throw error.stack; | ||
await helpers_1.errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, integrationId }, | ||
}); | ||
} | ||
@@ -402,6 +465,6 @@ } | ||
switch (workspaceIdentityProvider) { | ||
case "ad": | ||
case 'ad': | ||
return await authInstance({ | ||
url: `https://cws.${cwaAPI}.net/${citrixCloudCustomerId}/domainconfigurations`, | ||
method: "GET", | ||
method: 'GET', | ||
params: { | ||
@@ -411,16 +474,16 @@ Provider: workspaceIdentityProvider.toUpperCase(), | ||
}); | ||
case "netscaler": | ||
case 'netscaler': | ||
return await authInstance({ | ||
url: `https://cws.${cwaAPI}.net/${citrixCloudCustomerId}/domainconfigurations`, | ||
method: "GET", | ||
method: 'GET', | ||
params: { | ||
Provider: "AD", | ||
Provider: 'AD', | ||
}, | ||
}); | ||
case "aad": | ||
case 'aad': | ||
return await authInstance({ | ||
url: `https://cws.${cwaAPI}.net/${citrixCloudCustomerId}/AuthDomains`, | ||
method: "GET", | ||
method: 'GET', | ||
}); | ||
case "okta": | ||
case 'okta': | ||
break; | ||
@@ -433,3 +496,6 @@ default: | ||
catch (error) { | ||
throw error.stack; | ||
await helpers_1.errorHandle({ | ||
error, | ||
args: { authInstance, cwaAPI, citrixCloudCustomerId, workspaceIdentityProvider }, | ||
}); | ||
} | ||
@@ -453,9 +519,9 @@ } | ||
url: `https://cws.${cwaAPI}.net/${citrixCloudCustomerId}/users/query`, | ||
method: "POST", | ||
method: 'POST', | ||
data: { | ||
adminUser: "", | ||
adminUser: '', | ||
domain: domainName, | ||
forest: forestName, | ||
idpType: idpType, | ||
key: "", | ||
key: '', | ||
offerings: [ | ||
@@ -465,3 +531,3 @@ { | ||
{ | ||
compatibleIdentity: "OID:/*", | ||
compatibleIdentity: 'OID:/*', | ||
reasons: [], | ||
@@ -474,3 +540,3 @@ }, | ||
query: query, | ||
supportsAzureAdGroups: idpType === "AZUREAD", | ||
supportsAzureAdGroups: idpType === 'AZUREAD', | ||
}, | ||
@@ -480,3 +546,6 @@ }); | ||
catch (error) { | ||
throw error.stack; | ||
await helpers_1.errorHandle({ | ||
error, | ||
args: { authInstance, cwaAPI, domainName, forestName, appId, query, citrixCloudCustomerId, idpType }, | ||
}); | ||
} | ||
@@ -499,3 +568,3 @@ } | ||
const getOID = universalClaims.filter((value) => { | ||
return value.startsWith("OID"); | ||
return value.startsWith('OID'); | ||
}); | ||
@@ -505,11 +574,11 @@ const oid = getOID[0]; | ||
switch (workspaceIdentityProvider) { | ||
case "ad": | ||
case "netscaler": | ||
ipForUpdate = "AD"; | ||
case 'ad': | ||
case 'netscaler': | ||
ipForUpdate = 'AD'; | ||
break; | ||
case "aad": | ||
ipForUpdate = "AzureAD"; | ||
case 'aad': | ||
ipForUpdate = 'AzureAD'; | ||
break; | ||
case "okta": | ||
ipForUpdate = "Okta"; | ||
case 'okta': | ||
ipForUpdate = 'Okta'; | ||
break; | ||
@@ -524,3 +593,3 @@ default: | ||
url: `${microappsAdminUrl}/api/security/app-user/selected-groups/${appId}`, | ||
method: "PUT", | ||
method: 'PUT', | ||
data: [ | ||
@@ -541,3 +610,3 @@ { | ||
universalClaims: universalClaims, | ||
assign: assign === "Add" ? true : false, | ||
assign: assign === 'Add' ? true : false, | ||
}, | ||
@@ -548,3 +617,15 @@ ], | ||
catch (error) { | ||
throw error.stack; | ||
await helpers_1.errorHandle({ | ||
error, | ||
args: { | ||
authInstance, | ||
microappsAdminUrl, | ||
assign, | ||
userDetail, | ||
appId, | ||
domainName, | ||
forestName, | ||
workspaceIdentityProvider, | ||
}, | ||
}); | ||
} | ||
@@ -563,7 +644,10 @@ } | ||
url: `${microappsAdminUrl}/api/security/app-user/selected-groups/${appId}`, | ||
method: "GET", | ||
method: 'GET', | ||
}); | ||
} | ||
catch (error) { | ||
throw error.stack; | ||
await helpers_1.errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, appId }, | ||
}); | ||
} | ||
@@ -585,10 +669,13 @@ } | ||
response = await authInstance({ | ||
method: "GET", | ||
method: 'GET', | ||
url: `${microappsAdminUrl}/api/service/${integrationId}/export`, | ||
params, | ||
responseType: "stream", | ||
responseType: 'stream', | ||
}); | ||
} | ||
catch (error) { | ||
throw error.stack; | ||
await helpers_1.errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, integrationId, filePath, params }, | ||
}); | ||
} | ||
@@ -608,7 +695,10 @@ await response.data.pipe(fs_1.default.createWriteStream(path_1.default.resolve(__dirname, filePath))); | ||
url: `${microappsAdminUrl}/api/event-log?entityRef=${integrationId}&type=${integrationType}&subType=JOB&offset=0&limit=20`, | ||
method: "GET", | ||
method: 'GET', | ||
}); | ||
} | ||
catch (error) { | ||
throw error.stack; | ||
await helpers_1.errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, integrationId, integrationType }, | ||
}); | ||
} | ||
@@ -627,3 +717,3 @@ } | ||
url: `${microappsAdminUrl}/api/service/${integrationId}/secrets`, | ||
method: "POST", | ||
method: 'POST', | ||
data, | ||
@@ -633,6 +723,29 @@ }); | ||
catch (error) { | ||
throw error.stack; | ||
await helpers_1.errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, integrationId, data }, | ||
}); | ||
} | ||
} | ||
/** | ||
* Get microapp info - pages, components etc... | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} appId - Id of microapp | ||
*/ | ||
async getAppInfo({ authInstance, microappsAdminUrl, appId }) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/app/${appId}`, | ||
method: 'GET', | ||
}); | ||
} | ||
catch (error) { | ||
await helpers_1.errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, appId }, | ||
}); | ||
} | ||
} | ||
} | ||
exports.API = API; |
@@ -0,1 +1,2 @@ | ||
import { AxiosError } from 'axios'; | ||
export declare type GetCookie = { | ||
@@ -5,2 +6,7 @@ cookies: any; | ||
}; | ||
export declare type ErrorHandle = { | ||
error: AxiosError; | ||
args: Object; | ||
}; | ||
export declare const getCookie: ({ cookies, cookieName }: GetCookie) => string; | ||
export declare const errorHandle: ({ error, args }: ErrorHandle) => Promise<never>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getCookie = void 0; | ||
exports.errorHandle = exports.getCookie = void 0; | ||
exports.getCookie = ({ cookies, cookieName }) => { | ||
@@ -12,1 +12,95 @@ const regexp = new RegExp(`^${cookieName}=([^;]+);`); | ||
}; | ||
exports.errorHandle = async ({ error, args }) => { | ||
let errorReport = { | ||
ErrorReport: { | ||
invalidValues: [], | ||
possibleReasons: [], | ||
}, | ||
}; | ||
let description; | ||
let invalidValue = false; | ||
for (const [key, value] of Object.entries(args)) { | ||
if (value === undefined || value === null || value === '') { | ||
invalidValue = true; | ||
errorReport.ErrorReport.invalidValues.push(`Value "${key}" is type of "${typeof value}" and has value "${value}". Is the ${key} correctly assigned?`); | ||
} | ||
} | ||
if (invalidValue) { | ||
errorReport.ErrorReport.possibleReasons.push(`Some arguments have incorrect values. Please check if the right values are assigned.`); | ||
} | ||
if (error.response !== undefined) { | ||
switch (error.response.status) { | ||
case 400: { | ||
description = 'The server cannot or will not process the request due to an apparent client error.'; | ||
errorReport.ErrorReport.possibleReasons.push('Request syntax error, please check, if all mandatory values are correctly assigned.'); | ||
break; | ||
} | ||
case 401: { | ||
description = 'Authentication is required and has failed or has not yet been provided.'; | ||
errorReport.ErrorReport.possibleReasons.push('Wrong credentials used, are correct credentials assigned?'); | ||
break; | ||
} | ||
case 402: { | ||
description = 'Payment required or daily limiy of requests is exceeded.'; | ||
break; | ||
} | ||
case 403: { | ||
description = 'Access is forbidden for this request.'; | ||
errorReport.ErrorReport.possibleReasons.push('User has not permission to use this action or the action is prohibited.'); | ||
break; | ||
} | ||
case 404: { | ||
description = 'The requested resource could not be found but may be available in the future.'; | ||
errorReport.ErrorReport.possibleReasons.push('Record does not exist.'); | ||
break; | ||
} | ||
case 405: { | ||
description = 'A request method is not supported for the requested resource.'; | ||
break; | ||
} | ||
case 408: { | ||
description = 'The server timed out waiting for the request.'; | ||
break; | ||
} | ||
case 409: { | ||
description = | ||
'Request could not be processed because of conflict in the current state of the resource.'; | ||
break; | ||
} | ||
case 500: { | ||
description = 'Unexpected condition was encountered and no more specific message is suitable.'; | ||
break; | ||
} | ||
case 501: { | ||
description = | ||
'The server either does not recognize the request method, or it lacks the ability to fulfil the request.'; | ||
break; | ||
} | ||
case 502: { | ||
description = | ||
'The request was not completed. The server received an invalid response from the upstream server.'; | ||
break; | ||
} | ||
case 503: { | ||
description = 'The server cannot handle the request (overloaded or down for maintenance).'; | ||
break; | ||
} | ||
case 504: { | ||
description = 'The gateway has timed out.'; | ||
break; | ||
} | ||
default: { | ||
description = 'No further description for this state of the request'; | ||
break; | ||
} | ||
} | ||
errorReport.ErrorReport.status = `The request failed with status: ${error.response.status} - ${error.response.statusText} - ${description}`; | ||
errorReport.ErrorReport.message = `The request send message: ${error.response.data}`; | ||
} | ||
else { | ||
console.log(error.stack); | ||
errorReport.ErrorReport.possibleReasons.push('Undefined error. Error has been printed.'); | ||
} | ||
console.log(errorReport); | ||
throw new Error('Request failed. Please review the ErrorReport above.'); | ||
}; |
@@ -1,3 +0,3 @@ | ||
import { Page } from 'playwright'; | ||
import { API } from './api'; | ||
import { Page } from "playwright"; | ||
import { API } from "./api"; | ||
/** Class representing a Microapps Admin. */ | ||
@@ -12,3 +12,3 @@ export declare class MicroappsAdmin extends API { | ||
*/ | ||
login({ page, url, username, password, mfa, secretKey }: MicroappsAdminLogin): Promise<void>; | ||
login({ page, url, username, password, mfa, secretKey, }: MicroappsAdminLogin): Promise<void>; | ||
/** | ||
@@ -20,3 +20,3 @@ * Get Integration Id | ||
*/ | ||
getIntegrationId({ authInstance, microappsAdminUrl, integrationName }: GetIntegrationId): Promise<any>; | ||
getIntegrationId({ authInstance, microappsAdminUrl, integrationName, }: GetIntegrationId): Promise<any>; | ||
/** | ||
@@ -29,3 +29,3 @@ * Delete credentiaslds from credentials wallet for specific inregration | ||
*/ | ||
oauthLogout({ authInstance, microappsAdminUrl, integrationName, repeatCount }: OauthLogout): Promise<void>; | ||
oauthLogout({ authInstance, microappsAdminUrl, integrationName, repeatCount, }: OauthLogout): Promise<void>; | ||
/** | ||
@@ -60,3 +60,3 @@ * Wait for syncronization and check the result of sync | ||
*/ | ||
waitForProcessStatus({ authInstance, status, microappsAdminUrl, processId }: WaitForProcessStatus): Promise<any>; | ||
waitForProcessStatus({ authInstance, status, microappsAdminUrl, processId, }: WaitForProcessStatus): Promise<any>; | ||
/** | ||
@@ -76,3 +76,3 @@ * Create Java Integration | ||
*/ | ||
getIntegrationType({ authInstance, microappsAdminUrl, integrationName }: GetIntegrationType): Promise<any>; | ||
getIntegrationType({ authInstance, microappsAdminUrl, integrationName, }: GetIntegrationType): Promise<any>; | ||
/** | ||
@@ -84,3 +84,3 @@ * Get status of Integration | ||
*/ | ||
getStatusIntegration({ authInstance, microappsAdminUrl, integrationName }: GetStatusIntegration): Promise<any>; | ||
getStatusIntegration({ authInstance, microappsAdminUrl, integrationName, }: GetStatusIntegration): Promise<any>; | ||
/** | ||
@@ -92,3 +92,3 @@ * Import integration | ||
*/ | ||
importIntegration({ authInstance, microappsAdminUrl, pathToFile }: ImportIntegration): Promise<any>; | ||
importIntegration({ authInstance, microappsAdminUrl, pathToFile, }: ImportIntegration): Promise<any>; | ||
/** | ||
@@ -110,3 +110,3 @@ * Rename integration | ||
*/ | ||
exportApp({ authInstance, microappsAdminUrl, appId, pathToFile }: ExportApp): Promise<void>; | ||
exportApp({ authInstance, microappsAdminUrl, appId, pathToFile, }: ExportApp): Promise<void>; | ||
/** | ||
@@ -119,3 +119,3 @@ * Get Id of Microapp | ||
*/ | ||
getMicroAppId({ authInstance, microappsAdminUrl, integrationId, appName }: GetMicroAppId): Promise<any>; | ||
getMicroAppId({ authInstance, microappsAdminUrl, integrationId, appName, }: GetMicroAppId): Promise<any>; | ||
/** | ||
@@ -128,3 +128,3 @@ * Get Id of Notification | ||
*/ | ||
getNotificationId({ authInstance, microappsAdminUrl, appId, notificationName }: GetNotificationId): Promise<any>; | ||
getNotificationId({ authInstance, microappsAdminUrl, appId, notificationName, }: GetNotificationId): Promise<any>; | ||
/** | ||
@@ -138,6 +138,6 @@ * Run a Event | ||
*/ | ||
runEvent({ authInstance, microappsAdminUrl, integrationName, appName, notificationName }: RunEvent): Promise<void>; | ||
checkAppMissconfigurations({ authInstance, microappsAdminUrl, appId }: CheckAppMissconfigurations): Promise<void>; | ||
runEvent({ authInstance, microappsAdminUrl, integrationName, appName, notificationName, }: RunEvent): Promise<void>; | ||
checkAppMissconfigurations({ authInstance, microappsAdminUrl, appId, }: CheckAppMissconfigurations): Promise<void>; | ||
addSubscriber({ authInstance, appId, user, config }: AddSubscriber): Promise<void>; | ||
addSubscribers({ authInstance, integrationName, microapps, microappsAdminUrl, config }: AddSubscribers): Promise<{ | ||
addSubscribers({ authInstance, integrationName, microapps, microappsAdminUrl, config, }: AddSubscribers): Promise<{ | ||
microapp: string; | ||
@@ -151,3 +151,3 @@ }[]>; | ||
*/ | ||
importIntegrationUI({ page, microappsAdminUrl, filePath }: ImportIntegrationUI): Promise<void>; | ||
importIntegrationUI({ page, microappsAdminUrl, filePath, }: ImportIntegrationUI): Promise<void>; | ||
/** | ||
@@ -161,3 +161,3 @@ * Imports MicroApp to @param integrationName Integration from an exported MicroApp file | ||
*/ | ||
importMicroAppUI({ page, microappsAdminUrl, filePath, integrationName }: ImportMicroAppUI): Promise<void>; | ||
importMicroAppUI({ page, microappsAdminUrl, filePath, integrationName, }: ImportMicroAppUI): Promise<void>; | ||
/** | ||
@@ -177,3 +177,3 @@ * Exports @param integrationName integation | ||
*/ | ||
exportMicroAppsUI({ page, integrationName, appName }: ExportMicroAppUI): Promise<void>; | ||
exportMicroAppsUI({ page, integrationName, appName, }: ExportMicroAppUI): Promise<void>; | ||
/** | ||
@@ -186,3 +186,13 @@ * Returns last duration of Synchronization | ||
*/ | ||
getLastTimeSync({ authInstance, microappsAdminUrl, integrationName }: GetLastSyncTime): Promise<any>; | ||
getLastTimeSync({ authInstance, microappsAdminUrl, integrationName, }: GetLastSyncTime): Promise<any>; | ||
/** | ||
* Returns Id of component | ||
* | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} integrationName - Name of Integration | ||
* @param {string} appName - Name of Microapp | ||
* @param {string} componentLabel - Label of Component | ||
*/ | ||
getComponentId({ authInstance, microappsAdminUrl, integrationName, appName, pageName, componentLabel, }: GetComponentId): Promise<any>; | ||
} | ||
@@ -337,1 +347,9 @@ export declare type MicroappsAdminLogin = { | ||
}; | ||
export declare type GetComponentId = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
appName: string; | ||
pageName: string; | ||
componentLabel: string; | ||
}; |
@@ -25,13 +25,13 @@ "use strict"; | ||
*/ | ||
async login({ page, url, username, password, mfa = null, secretKey }) { | ||
await page.goto(url, { waitUntil: 'domcontentloaded' }); | ||
await page.waitForSelector('#username'); | ||
await page.type('#username', username); | ||
await page.waitForSelector('#password'); | ||
await page.type('#password', password); | ||
await page.waitForSelector('#submit'); | ||
await page.click('#submit'); | ||
async login({ page, url, username, password, mfa = null, secretKey, }) { | ||
await page.goto(url, { waitUntil: "domcontentloaded" }); | ||
await page.waitForSelector("#username"); | ||
await page.type("#username", username); | ||
await page.waitForSelector("#password"); | ||
await page.type("#password", password); | ||
await page.waitForSelector("#submit"); | ||
await page.click("#submit"); | ||
if (mfa) { | ||
const authCode = await citrixCloud.getAuthenticatorCode({ secretKey }); | ||
await page.waitForSelector('input[inputmode]'); | ||
await page.waitForSelector("input[inputmode]"); | ||
for (let i = 0; i < 6; i++) { | ||
@@ -60,4 +60,7 @@ await page.type(`input[inputmode][name="${i}"]`, authCode[i]); | ||
*/ | ||
async getIntegrationId({ authInstance, microappsAdminUrl, integrationName }) { | ||
const integrations = await this.getIntegrations({ authInstance, microappsAdminUrl }); | ||
async getIntegrationId({ authInstance, microappsAdminUrl, integrationName, }) { | ||
const integrations = await this.getIntegrations({ | ||
authInstance, | ||
microappsAdminUrl, | ||
}); | ||
const integration = integrations.data.find((e) => e.title === integrationName); | ||
@@ -73,6 +76,14 @@ return integration.id; | ||
*/ | ||
async oauthLogout({ authInstance, microappsAdminUrl, integrationName, repeatCount = 1 }) { | ||
const integrationId = await this.getIntegrationId({ authInstance, microappsAdminUrl, integrationName }); | ||
async oauthLogout({ authInstance, microappsAdminUrl, integrationName, repeatCount = 1, }) { | ||
const integrationId = await this.getIntegrationId({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
}); | ||
for (let i = 0; i < repeatCount; i++) { | ||
await this.integrationLogout({ authInstance, microappsAdminUrl, integrationId }); | ||
await this.integrationLogout({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
}); | ||
} | ||
@@ -123,3 +134,7 @@ } | ||
}); | ||
const integration = await this.getIntegration({ authInstance, microappsAdminUrl, integrationId }); | ||
const integration = await this.getIntegration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
}); | ||
const jobRuns = integration.data.jobRuns; | ||
@@ -137,3 +152,7 @@ const getJobRunDetail = jobRuns.find((job) => { | ||
await this.waitForSync({ | ||
getIntegration: () => this.getIntegration({ authInstance, microappsAdminUrl, integrationId }), | ||
getIntegration: () => this.getIntegration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
}), | ||
synchronizationType, | ||
@@ -144,3 +163,7 @@ }); | ||
await this.waitForSync({ | ||
getIntegration: () => this.getIntegration({ authInstance, microappsAdminUrl, integrationId }), | ||
getIntegration: () => this.getIntegration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
}), | ||
synchronizationType, | ||
@@ -157,3 +180,7 @@ }); | ||
await this.waitForSync({ | ||
getIntegration: () => this.getIntegration({ authInstance, microappsAdminUrl, integrationId }), | ||
getIntegration: () => this.getIntegration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
}), | ||
synchronizationType, | ||
@@ -171,7 +198,14 @@ }); | ||
async createHTTPIntegration({ authInstance, microappsAdminUrl, integrationName, integrationConfiguration, }) { | ||
const bundleCatalogue = await this.getBundleCatalogue({ authInstance, microappsAdminUrl }); | ||
const bundleCatalogue = await this.getBundleCatalogue({ | ||
authInstance, | ||
microappsAdminUrl, | ||
}); | ||
const bundleCatalogueData = bundleCatalogue.data; | ||
const catalogueDetail = bundleCatalogueData.find((e) => e.title === integrationName && e.type === 'HTTP'); | ||
const catalogueDetail = bundleCatalogueData.find((e) => e.title === integrationName && e.type === "HTTP"); | ||
const catalogueId = catalogueDetail.uniqueId; | ||
const createdConnector = await this.updateBundleCatalogue({ authInstance, microappsAdminUrl, catalogueId }); | ||
const createdConnector = await this.updateBundleCatalogue({ | ||
authInstance, | ||
microappsAdminUrl, | ||
catalogueId, | ||
}); | ||
const integrationId = createdConnector.data.id; | ||
@@ -193,6 +227,10 @@ await this.updateintegrationConfiguration({ | ||
*/ | ||
async waitForProcessStatus({ authInstance, status, microappsAdminUrl, processId }) { | ||
async waitForProcessStatus({ authInstance, status, microappsAdminUrl, processId, }) { | ||
let processStatus; | ||
for (let i = 0; i < 35; i++) { | ||
processStatus = await this.getProcessStatus({ authInstance, microappsAdminUrl, processId }); | ||
processStatus = await this.getProcessStatus({ | ||
authInstance, | ||
microappsAdminUrl, | ||
processId, | ||
}); | ||
if (processStatus.data.message !== undefined) { | ||
@@ -218,5 +256,6 @@ console.log(processStatus.data.message); | ||
*/ | ||
async createJavaIntegration({ authInstance, microappsAdminUrl, integrationConfiguration, withEntities = true, serviceType = null, serviceKey, name = '', }) { | ||
async createJavaIntegration({ authInstance, microappsAdminUrl, integrationConfiguration, withEntities = true, serviceType = null, serviceKey, name = "", }) { | ||
let processId; | ||
const configurationParameters = integrationConfiguration.serviceData.configuration.configurationParameters; | ||
const configurationParameters = integrationConfiguration.serviceData.configuration | ||
.configurationParameters; | ||
const responseValidation = await this.validateConfiguration({ | ||
@@ -229,6 +268,10 @@ authInstance, | ||
const responseValidationBody = JSON.stringify(responseValidation.data); | ||
if (!responseValidationBody.includes('ok')) { | ||
throw new Error('Configuration is not valid!'); | ||
if (!responseValidationBody.includes("ok")) { | ||
throw new Error("Configuration is not valid!"); | ||
} | ||
const app = await this.addApp({ authInstance, microappsAdminUrl, data: integrationConfiguration }); | ||
const app = await this.addApp({ | ||
authInstance, | ||
microappsAdminUrl, | ||
data: integrationConfiguration, | ||
}); | ||
processId = app.data.processId; | ||
@@ -238,3 +281,3 @@ const processStatus = await this.waitForProcessStatus({ | ||
getProcessStatus: () => this.getProcessStatus({ authInstance, microappsAdminUrl, processId }), | ||
status: 'DONE', | ||
status: "DONE", | ||
microappsAdminUrl, | ||
@@ -247,4 +290,8 @@ processId, | ||
// Some connectors have different flow for getting entities | ||
if (serviceType === 'Service Now' || serviceType === 'Salesforce') { | ||
const services = await this.getIntegration({ authInstance, microappsAdminUrl, integrationId }); | ||
if (serviceType === "Service Now" || serviceType === "Salesforce") { | ||
const services = await this.getIntegration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
}); | ||
entities = services.data.configuration.entities; | ||
@@ -263,7 +310,11 @@ entityFilters = services.data.configuration.entityFilters; | ||
getProcessStatus: () => this.getProcessStatus({ authInstance, microappsAdminUrl, processId }), | ||
status: 'DONE', | ||
status: "DONE", | ||
microappsAdminUrl, | ||
processId, | ||
}); | ||
const processDetail = await this.getProcessStatus({ authInstance, microappsAdminUrl, processId }); | ||
const processDetail = await this.getProcessStatus({ | ||
authInstance, | ||
microappsAdminUrl, | ||
processId, | ||
}); | ||
entities = processDetail.data.detail.data.entities; | ||
@@ -280,3 +331,8 @@ entityFilters = processDetail.data.detail.data.entityFilters; | ||
if (withEntities) { | ||
const entity = await this.createEntity({ authInstance, microappsAdminUrl, integrationId, entityData }); | ||
const entity = await this.createEntity({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
entityData, | ||
}); | ||
processId = entity.data.processId; | ||
@@ -286,7 +342,11 @@ await this.waitForProcessStatus({ | ||
getProcessStatus: () => this.getProcessStatus({ authInstance, microappsAdminUrl, processId }), | ||
status: 'DONE', | ||
status: "DONE", | ||
microappsAdminUrl, | ||
processId, | ||
}); | ||
await this.finalizeConfig({ authInstance, microappsAdminUrl, integrationId }); | ||
await this.finalizeConfig({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
}); | ||
} | ||
@@ -300,4 +360,7 @@ } | ||
*/ | ||
async getIntegrationType({ authInstance, microappsAdminUrl, integrationName }) { | ||
const integrations = await this.getIntegrations({ authInstance, microappsAdminUrl }); | ||
async getIntegrationType({ authInstance, microappsAdminUrl, integrationName, }) { | ||
const integrations = await this.getIntegrations({ | ||
authInstance, | ||
microappsAdminUrl, | ||
}); | ||
const integrationsData = integrations.data; | ||
@@ -316,5 +379,9 @@ const findIntegrationType = integrationsData.find((integration) => { | ||
*/ | ||
async getStatusIntegration({ authInstance, microappsAdminUrl, integrationName }) { | ||
async getStatusIntegration({ authInstance, microappsAdminUrl, integrationName, }) { | ||
try { | ||
const serviceId = await this.getIntegrationId({ authInstance, microappsAdminUrl, integrationName }); | ||
const serviceId = await this.getIntegrationId({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
}); | ||
return serviceId; | ||
@@ -332,12 +399,12 @@ } | ||
*/ | ||
async importIntegration({ authInstance, microappsAdminUrl, pathToFile }) { | ||
async importIntegration({ authInstance, microappsAdminUrl, pathToFile, }) { | ||
const form = new form_data_1.default(); | ||
let response; | ||
form.append('file', fs_1.default.createReadStream(path_1.default.resolve(__dirname, pathToFile))); | ||
form.append("file", fs_1.default.createReadStream(path_1.default.resolve(__dirname, pathToFile))); | ||
try { | ||
response = await authInstance({ | ||
url: `${microappsAdminUrl}/api/service/import`, | ||
method: 'POST', | ||
method: "POST", | ||
headers: { | ||
'content-type': `multipart/form-data; boundary=${form._boundary}`, | ||
"content-type": `multipart/form-data; boundary=${form._boundary}`, | ||
}, | ||
@@ -362,3 +429,7 @@ data: form, | ||
async renameIntegration({ authInstance, microappsAdminUrl, integrationName, newIntegrationName, integrationConfiguration, }) { | ||
const integrationType = await this.getIntegrationType({ authInstance, microappsAdminUrl, integrationName }); | ||
const integrationType = await this.getIntegrationType({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
}); | ||
const data = { | ||
@@ -368,3 +439,7 @@ serviceType: integrationType, | ||
}; | ||
const integrationId = await this.getStatusIntegration({ authInstance, microappsAdminUrl, integrationName }); | ||
const integrationId = await this.getStatusIntegration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
}); | ||
await this.updateintegrationConfiguration({ | ||
@@ -376,3 +451,6 @@ authInstance, | ||
}); | ||
const integrations = await this.getIntegrations({ authInstance, microappsAdminUrl }); | ||
const integrations = await this.getIntegrations({ | ||
authInstance, | ||
microappsAdminUrl, | ||
}); | ||
const integrationsData = integrations.data; | ||
@@ -391,9 +469,9 @@ const IntegrationDetail = integrationsData.filter((e) => { | ||
*/ | ||
async exportApp({ authInstance, microappsAdminUrl, appId, pathToFile }) { | ||
async exportApp({ authInstance, microappsAdminUrl, appId, pathToFile, }) { | ||
let response; | ||
try { | ||
response = await authInstance({ | ||
method: 'GET', | ||
method: "GET", | ||
url: `${microappsAdminUrl}/api/app/${appId}/export`, | ||
responseType: 'stream', | ||
responseType: "stream", | ||
}); | ||
@@ -413,3 +491,3 @@ } | ||
*/ | ||
async getMicroAppId({ authInstance, microappsAdminUrl, integrationId, appName }) { | ||
async getMicroAppId({ authInstance, microappsAdminUrl, integrationId, appName, }) { | ||
let apps; | ||
@@ -434,3 +512,3 @@ try { | ||
*/ | ||
async getNotificationId({ authInstance, microappsAdminUrl, appId, notificationName }) { | ||
async getNotificationId({ authInstance, microappsAdminUrl, appId, notificationName, }) { | ||
const notifications = await this.getNotifications({ | ||
@@ -456,6 +534,15 @@ authInstance, | ||
*/ | ||
async runEvent({ authInstance, microappsAdminUrl, integrationName, appName, notificationName }) { | ||
async runEvent({ authInstance, microappsAdminUrl, integrationName, appName, notificationName, }) { | ||
let notifications; | ||
const integrationId = await this.getIntegrationId({ authInstance, microappsAdminUrl, integrationName }); | ||
const appId = await this.getMicroAppId({ authInstance, microappsAdminUrl, integrationId, appName }); | ||
const integrationId = await this.getIntegrationId({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
}); | ||
const appId = await this.getMicroAppId({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
appName, | ||
}); | ||
const notificationId = await this.getNotificationId({ | ||
@@ -467,5 +554,13 @@ authInstance, | ||
}); | ||
await this.runNotificationEvent({ authInstance, microappsAdminUrl, notificationId }); | ||
await this.runNotificationEvent({ | ||
authInstance, | ||
microappsAdminUrl, | ||
notificationId, | ||
}); | ||
for (let i = 0; i < 10; i++) { | ||
notifications = await this.getNotifications({ authInstance, microappsAdminUrl, appId }); | ||
notifications = await this.getNotifications({ | ||
authInstance, | ||
microappsAdminUrl, | ||
appId, | ||
}); | ||
const running = notifications.data[0].running; | ||
@@ -478,8 +573,11 @@ if ((await running) === false) { | ||
const lastRunStatus = notifications.data[0].lastRunStatus; | ||
if ((await lastRunStatus) !== 'SUCCESS') { | ||
throw new Error('Event run failed!'); | ||
if ((await lastRunStatus) !== "SUCCESS") { | ||
throw new Error("Event run failed!"); | ||
} | ||
} | ||
async checkAppMissconfigurations({ authInstance, microappsAdminUrl, appId }) { | ||
const response = await this.integrityCheck({ authInstance, microappsAdminUrl }); | ||
async checkAppMissconfigurations({ authInstance, microappsAdminUrl, appId, }) { | ||
const response = await this.integrityCheck({ | ||
authInstance, | ||
microappsAdminUrl, | ||
}); | ||
const responseBody = response.data; | ||
@@ -490,7 +588,7 @@ const missconfigurations = responseBody.filter((e) => e.appId === appId); | ||
} | ||
console.log('missconfigurations: ', missconfigurations); | ||
console.log("missconfigurations: ", missconfigurations); | ||
} | ||
//TO-DO add config as parametr | ||
async addSubscriber({ authInstance, appId, user, config }) { | ||
const { microappsAdminUrl, citrixCloudCustomerId, cwaAPI, workspaceIdentityProvider } = config; | ||
const { microappsAdminUrl, citrixCloudCustomerId, cwaAPI, workspaceIdentityProvider, } = config; | ||
// Get Domains | ||
@@ -503,3 +601,3 @@ const domains = await this.getDomain({ | ||
}); | ||
const actionSubscribe = 'Add'; | ||
const actionSubscribe = "Add"; | ||
let domainName; | ||
@@ -509,21 +607,21 @@ let forestName; | ||
switch (workspaceIdentityProvider) { | ||
case 'ad': | ||
case 'netscaler': | ||
case "ad": | ||
case "netscaler": | ||
domainName = domains.data.domains[0].domainName; | ||
forestName = domains.data.domains[0].forestName; | ||
idpType = 'AD'; | ||
idpType = "AD"; | ||
break; | ||
case 'aad': | ||
case "aad": | ||
const domainsData = domains.data; | ||
const domainDetail = domainsData.filter((domain) => { | ||
return domain.idpType === 'AzureAd'; | ||
return domain.idpType === "AzureAd"; | ||
}); | ||
domainName = 'todo'; | ||
domainName = "todo"; | ||
forestName = domainDetail[0].idpProperties.tid; | ||
idpType = 'AZUREAD'; | ||
idpType = "AZUREAD"; | ||
break; | ||
case 'okta': | ||
case "okta": | ||
domainName = null; | ||
forestName = null; | ||
idpType = 'OKTA'; | ||
idpType = "OKTA"; | ||
break; | ||
@@ -570,5 +668,9 @@ default: | ||
} | ||
async addSubscribers({ authInstance, integrationName, microapps, microappsAdminUrl, config }) { | ||
const integrationId = await this.getIntegrationId({ authInstance, microappsAdminUrl, integrationName }); | ||
const subscribe = async ({ microapps, microapp, authInstance, integrationId }) => { | ||
async addSubscribers({ authInstance, integrationName, microapps, microappsAdminUrl, config, }) { | ||
const integrationId = await this.getIntegrationId({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
}); | ||
const subscribe = async ({ microapps, microapp, authInstance, integrationId, }) => { | ||
console.log(`[${integrationName}] - Adding subscribers for: ${microapp}`); | ||
@@ -587,3 +689,3 @@ const subscribers = microapps[microapp].subscribers; | ||
user: subscriber, | ||
config | ||
config, | ||
}); | ||
@@ -605,3 +707,3 @@ } | ||
*/ | ||
async importIntegrationUI({ page, microappsAdminUrl, filePath }) { | ||
async importIntegrationUI({ page, microappsAdminUrl, filePath, }) { | ||
await page.waitForSelector('[data-testid="add-integration-button"]'); | ||
@@ -611,7 +713,8 @@ await page.click('[data-testid="add-integration-button"]'); | ||
await page.click('[data-testid="new-integration-upload"]'); | ||
const uploadFile = await page.$('input[type=file]'); | ||
const uploadFile = await page.$("input[type=file]"); | ||
await uploadFile.setInputFiles(path_1.default.resolve(__dirname, filePath)); | ||
await page.waitForSelector('[data-testid="upload-submit-button"]'); | ||
await page.click('[data-testid="upload-submit-button"]'); | ||
await page.waitForResponse((response) => response.url() === `${microappsAdminUrl}/api/service/import` && response.status() === 200); | ||
await page.waitForResponse((response) => response.url() === `${microappsAdminUrl}/api/service/import` && | ||
response.status() === 200); | ||
} | ||
@@ -626,3 +729,3 @@ /** | ||
*/ | ||
async importMicroAppUI({ page, microappsAdminUrl, filePath, integrationName }) { | ||
async importMicroAppUI({ page, microappsAdminUrl, filePath, integrationName, }) { | ||
await page.waitForSelector(`//div[@data-testid="integration-name-${integrationName}"] //button[@data-testid="toggle-integration-options-dropdown"]`); | ||
@@ -632,7 +735,8 @@ await page.click(`//div[@data-testid="integration-name-${integrationName}"] //button[@data-testid="toggle-integration-options-dropdown"]`); | ||
await page.click(`//div[@data-testid="integration-name-${integrationName}"] //button[@data-testid="open-import-app"]`); | ||
const uploadFile = await page.$('input[type=file]'); | ||
const uploadFile = await page.$("input[type=file]"); | ||
await uploadFile.setInputFiles(path_1.default.resolve(__dirname, filePath)); | ||
await page.waitForSelector('[data-testid="upload-submit-button"]'); | ||
await page.click('[data-testid="upload-submit-button"]'); | ||
await page.waitForResponse((response) => response.url() === `${microappsAdminUrl}/api/app` && response.status() === 200); | ||
await page.waitForResponse((response) => response.url() === `${microappsAdminUrl}/api/app` && | ||
response.status() === 200); | ||
} | ||
@@ -652,5 +756,5 @@ /** | ||
await page.click(`//button[@data-testid="export-integration-commit-button"]`); | ||
const download = await page.waitForEvent('download'); | ||
const download = await page.waitForEvent("download"); | ||
if ((await download.path()) === null) { | ||
throw new Error('No file was downloaded'); | ||
throw new Error("No file was downloaded"); | ||
} | ||
@@ -665,3 +769,3 @@ } | ||
*/ | ||
async exportMicroAppsUI({ page, integrationName, appName }) { | ||
async exportMicroAppsUI({ page, integrationName, appName, }) { | ||
await page.waitForSelector(`//div[@data-testid="integration-name-${integrationName}"] //tr[descendant::a[contains(text(), "${appName}")]] //button[starts-with(@class, "PlainButton")]`); | ||
@@ -671,5 +775,5 @@ await page.click(`//div[@data-testid="integration-name-${integrationName}"] //tr[descendant::a[contains(text(), "${appName}")]] //button[starts-with(@class, "PlainButton")]`); | ||
await page.click(`//div[@data-testid="integration-name-${integrationName}"] //tr[descendant::a[contains(text(), "${appName}")]] //button[@data-testid="do-app-export"]`); | ||
const download = await page.waitForEvent('download'); | ||
const download = await page.waitForEvent("download"); | ||
if ((await download.path()) === null) { | ||
throw new Error('No file was downloaded'); | ||
throw new Error("No file was downloaded"); | ||
} | ||
@@ -684,9 +788,22 @@ } | ||
*/ | ||
async getLastTimeSync({ authInstance, microappsAdminUrl, integrationName }) { | ||
async getLastTimeSync({ authInstance, microappsAdminUrl, integrationName, }) { | ||
const regex = new RegExp(/\d*:\d*:\d*.\d*/); | ||
const integrationId = await this.getIntegrationId({ authInstance, microappsAdminUrl, integrationName }); | ||
const integrationType = await this.getIntegrationType({ authInstance, microappsAdminUrl, integrationName }); | ||
const logs = await this.getIntegrationLog({ authInstance, microappsAdminUrl, integrationId, integrationType }); | ||
const integrationId = await this.getIntegrationId({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
}); | ||
const integrationType = await this.getIntegrationType({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
}); | ||
const logs = await this.getIntegrationLog({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
integrationType, | ||
}); | ||
for (const line of logs.data.data) { | ||
if (line.message.includes('Service synchronization finished in')) { | ||
if (line.message.includes("Service synchronization finished in")) { | ||
return line.message.match(regex)[0]; | ||
@@ -696,3 +813,36 @@ } | ||
} | ||
/** | ||
* Returns Id of component | ||
* | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} integrationName - Name of Integration | ||
* @param {string} appName - Name of Microapp | ||
* @param {string} componentLabel - Label of Component | ||
*/ | ||
async getComponentId({ authInstance, microappsAdminUrl, integrationName, appName, pageName, componentLabel, }) { | ||
const integrationId = await this.getIntegrationId({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
}); | ||
const appId = await this.getMicroAppId({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
appName, | ||
}); | ||
const selectedAppData = await this.getAppInfo({ | ||
authInstance, | ||
microappsAdminUrl, | ||
appId, | ||
}); | ||
const pagesData = selectedAppData.data.app.pages; | ||
const getPage = pagesData.filter((app) => app.title === pageName); | ||
const components = getPage[0].components; | ||
const getComponent = components.filter((component) => component.label === componentLabel); | ||
const componentId = getComponent[0].id; | ||
return componentId; | ||
} | ||
} | ||
exports.MicroappsAdmin = MicroappsAdmin; |
@@ -13,3 +13,3 @@ import { Page, BrowserContext } from "playwright"; | ||
*/ | ||
login({ page, workspaceUrl, workspaceUsername, workspacePassword, workspaceIdentityProvider }: Login): Promise<void>; | ||
login({ page, workspaceUrl, workspaceUsername, workspacePassword, workspaceIdentityProvider, }: Login): Promise<void>; | ||
/** | ||
@@ -45,3 +45,3 @@ * Skip Tour | ||
*/ | ||
waitForFeedCardId({ page, repeatMax, waitTime, recordId, notificationId }: WaitForFeedCardId): Promise<any>; | ||
waitForFeedCardId({ page, repeatMax, waitTime, recordId, notificationId, }: WaitForFeedCardId): Promise<any>; | ||
/** | ||
@@ -71,3 +71,4 @@ * Returns button on FeedCard | ||
}>; | ||
createDsAuthInstance({ citrixToken, jSessionId }: CreateDsAuthInstance): Promise<import("axios").AxiosInstance>; | ||
createDsAuthInstance({ citrixToken, jSessionId, }: CreateDsAuthInstance): Promise<import("axios").AxiosInstance>; | ||
getUserData({ dSauthInstance, microappsAdminUrl, appId, componentId, dataLimit, initiatorType, initiatorData, pageId, authDomain, }: GetUserData): Promise<any>; | ||
} | ||
@@ -138,1 +139,12 @@ export declare type Login = { | ||
}; | ||
export declare type GetUserData = { | ||
dSauthInstance: any; | ||
microappsAdminUrl: string; | ||
appId: string; | ||
componentId: string; | ||
dataLimit: string; | ||
initiatorType: string; | ||
initiatorData: string; | ||
pageId: string; | ||
authDomain: string; | ||
}; |
@@ -20,3 +20,3 @@ "use strict"; | ||
*/ | ||
async login({ page, workspaceUrl, workspaceUsername, workspacePassword, workspaceIdentityProvider }) { | ||
async login({ page, workspaceUrl, workspaceUsername, workspacePassword, workspaceIdentityProvider, }) { | ||
console.log("Login to Workspace", new Date()); | ||
@@ -106,3 +106,4 @@ await page.goto(workspaceUrl, { waitUntil: "domcontentloaded" }); | ||
await page.selectOption("select", "CREATED_AT"); | ||
const notifications = await page.waitForResponse((response) => response.url().match(new RegExp("notification")) && response.status() === 200); | ||
const notifications = await page.waitForResponse((response) => response.url().match(new RegExp("notification")) && | ||
response.status() === 200); | ||
const notificationsBody = await notifications.json(); | ||
@@ -119,3 +120,3 @@ return notificationsBody; | ||
*/ | ||
async waitForFeedCardId({ page, repeatMax = 50, waitTime = 5000, recordId, notificationId = "" }) { | ||
async waitForFeedCardId({ page, repeatMax = 50, waitTime = 5000, recordId, notificationId = "", }) { | ||
let feedCardId; | ||
@@ -129,3 +130,4 @@ for (let i = 0; i < repeatMax; i++) { | ||
const feedCardDetail = data.filter((e) => { | ||
return e.recordId.includes(recordId) && e.source.notification.id.includes(notificationId); | ||
return (e.recordId.includes(recordId) && | ||
e.source.notification.id.includes(notificationId)); | ||
}); | ||
@@ -199,7 +201,16 @@ try { | ||
const cookies = response.headers["set-cookie"]; | ||
const jSessionId = await helpers_1.getCookie({ cookies: cookies, cookieName: "JSESSIONID" }); | ||
const jSessionId = await helpers_1.getCookie({ | ||
cookies: cookies, | ||
cookieName: "JSESSIONID", | ||
}); | ||
return { citrixToken, jSessionId }; | ||
} | ||
async getDsauthTokens({ page, context, workspaceUrl, workspaceUsername, workspacePassword, workspaceIdentityProvider, builderDomain, authDomain, }) { | ||
await this.login({ page, workspaceUrl, workspaceUsername, workspacePassword, workspaceIdentityProvider }); | ||
await this.login({ | ||
page, | ||
workspaceUrl, | ||
workspaceUsername, | ||
workspacePassword, | ||
workspaceIdentityProvider, | ||
}); | ||
const cookies = await context.cookies(); | ||
@@ -220,6 +231,10 @@ const csfrTokenCookie = cookies.find((e) => e.name === "CsrfToken"); | ||
}); | ||
const { citrixToken, jSessionId } = await this.getTokens({ builderDomain, authDomain, oneTimeToken }); | ||
const { citrixToken, jSessionId } = await this.getTokens({ | ||
builderDomain, | ||
authDomain, | ||
oneTimeToken, | ||
}); | ||
return { citrixToken, jSessionId }; | ||
} | ||
async createDsAuthInstance({ citrixToken, jSessionId }) { | ||
async createDsAuthInstance({ citrixToken, jSessionId, }) { | ||
const dSauthInstance = axios_1.default.create({}); | ||
@@ -231,3 +246,20 @@ dSauthInstance.defaults.headers.common["citrix-csrf-token"] = `${citrixToken}`; | ||
} | ||
async getUserData({ dSauthInstance, microappsAdminUrl, appId, componentId, dataLimit, initiatorType, initiatorData, pageId, authDomain, }) { | ||
const response = await dSauthInstance({ | ||
url: `${microappsAdminUrl}/app/api/app/${appId}/component/${componentId}/data`, | ||
method: "GET", | ||
queryParameters: { | ||
offset: 0, | ||
limit: dataLimit, | ||
orderDirection: "ASC", | ||
initiator_type: initiatorType, | ||
initiator_id: pageId, | ||
initiator_appId: appId, | ||
initiator_data: initiatorData, | ||
authDomain, | ||
}, | ||
}); | ||
return response.data.data; | ||
} | ||
} | ||
exports.Workspace = Workspace; |
111
main.d.ts
@@ -111,8 +111,8 @@ /** Class representing a Citrix Cloud. */ | ||
/** | ||
* Get all MicroApps in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* Get all MicroApps in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
*/ | ||
*/ | ||
getApps({ authInstance, microappsAdminUrl }: GetApps): Promise<any>; | ||
@@ -227,2 +227,9 @@ /** | ||
addSecrets({ authInstance, microappsAdminUrl, integrationId, data }: AddSecrets): Promise<any>; | ||
/** | ||
* Get microapp info - pages, components etc... | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} appId - Id of microapp | ||
*/ | ||
getAppInfo({ authInstance, microappsAdminUrl, appId }: GetAppInfo): Promise<any>; | ||
} | ||
@@ -375,4 +382,8 @@ export declare type AddApp = { | ||
}; | ||
export declare type GetAppInfo = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
appId: string; | ||
}; | ||
/** Class representing a Citrix Cloud. */ | ||
@@ -415,2 +426,15 @@ export declare class CitrixCloud extends API { | ||
import { AxiosError } from 'axios'; | ||
export declare type GetCookie = { | ||
cookies: any; | ||
cookieName: string; | ||
}; | ||
export declare type ErrorHandle = { | ||
error: AxiosError; | ||
args: Object; | ||
}; | ||
export declare const getCookie: ({ cookies, cookieName }: GetCookie) => string; | ||
export declare const errorHandle: ({ error, args }: ErrorHandle) => Promise<never>; | ||
/** Class representing a Microapps Admin. */ | ||
@@ -425,3 +449,3 @@ export declare class MicroappsAdmin extends API { | ||
*/ | ||
login({ page, url, username, password, mfa, secretKey }: MicroappsAdminLogin): Promise<void>; | ||
login({ page, url, username, password, mfa, secretKey, }: MicroappsAdminLogin): Promise<void>; | ||
/** | ||
@@ -433,3 +457,3 @@ * Get Integration Id | ||
*/ | ||
getIntegrationId({ authInstance, microappsAdminUrl, integrationName }: GetIntegrationId): Promise<any>; | ||
getIntegrationId({ authInstance, microappsAdminUrl, integrationName, }: GetIntegrationId): Promise<any>; | ||
/** | ||
@@ -442,3 +466,3 @@ * Delete credentiaslds from credentials wallet for specific inregration | ||
*/ | ||
oauthLogout({ authInstance, microappsAdminUrl, integrationName, repeatCount }: OauthLogout): Promise<void>; | ||
oauthLogout({ authInstance, microappsAdminUrl, integrationName, repeatCount, }: OauthLogout): Promise<void>; | ||
/** | ||
@@ -473,3 +497,3 @@ * Wait for syncronization and check the result of sync | ||
*/ | ||
waitForProcessStatus({ authInstance, status, microappsAdminUrl, processId }: WaitForProcessStatus): Promise<any>; | ||
waitForProcessStatus({ authInstance, status, microappsAdminUrl, processId, }: WaitForProcessStatus): Promise<any>; | ||
/** | ||
@@ -489,3 +513,3 @@ * Create Java Integration | ||
*/ | ||
getIntegrationType({ authInstance, microappsAdminUrl, integrationName }: GetIntegrationType): Promise<any>; | ||
getIntegrationType({ authInstance, microappsAdminUrl, integrationName, }: GetIntegrationType): Promise<any>; | ||
/** | ||
@@ -497,3 +521,3 @@ * Get status of Integration | ||
*/ | ||
getStatusIntegration({ authInstance, microappsAdminUrl, integrationName }: GetStatusIntegration): Promise<any>; | ||
getStatusIntegration({ authInstance, microappsAdminUrl, integrationName, }: GetStatusIntegration): Promise<any>; | ||
/** | ||
@@ -505,3 +529,3 @@ * Import integration | ||
*/ | ||
importIntegration({ authInstance, microappsAdminUrl, pathToFile }: ImportIntegration): Promise<any>; | ||
importIntegration({ authInstance, microappsAdminUrl, pathToFile, }: ImportIntegration): Promise<any>; | ||
/** | ||
@@ -523,3 +547,3 @@ * Rename integration | ||
*/ | ||
exportApp({ authInstance, microappsAdminUrl, appId, pathToFile }: ExportApp): Promise<void>; | ||
exportApp({ authInstance, microappsAdminUrl, appId, pathToFile, }: ExportApp): Promise<void>; | ||
/** | ||
@@ -532,3 +556,3 @@ * Get Id of Microapp | ||
*/ | ||
getMicroAppId({ authInstance, microappsAdminUrl, integrationId, appName }: GetMicroAppId): Promise<any>; | ||
getMicroAppId({ authInstance, microappsAdminUrl, integrationId, appName, }: GetMicroAppId): Promise<any>; | ||
/** | ||
@@ -541,3 +565,3 @@ * Get Id of Notification | ||
*/ | ||
getNotificationId({ authInstance, microappsAdminUrl, appId, notificationName }: GetNotificationId): Promise<any>; | ||
getNotificationId({ authInstance, microappsAdminUrl, appId, notificationName, }: GetNotificationId): Promise<any>; | ||
/** | ||
@@ -551,6 +575,6 @@ * Run a Event | ||
*/ | ||
runEvent({ authInstance, microappsAdminUrl, integrationName, appName, notificationName }: RunEvent): Promise<void>; | ||
checkAppMissconfigurations({ authInstance, microappsAdminUrl, appId }: CheckAppMissconfigurations): Promise<void>; | ||
runEvent({ authInstance, microappsAdminUrl, integrationName, appName, notificationName, }: RunEvent): Promise<void>; | ||
checkAppMissconfigurations({ authInstance, microappsAdminUrl, appId, }: CheckAppMissconfigurations): Promise<void>; | ||
addSubscriber({ authInstance, appId, user, config }: AddSubscriber): Promise<void>; | ||
addSubscribers({ authInstance, integrationName, microapps, microappsAdminUrl, config }: AddSubscribers): Promise<{ | ||
addSubscribers({ authInstance, integrationName, microapps, microappsAdminUrl, config, }: AddSubscribers): Promise<{ | ||
microapp: string; | ||
@@ -564,3 +588,3 @@ }[]>; | ||
*/ | ||
importIntegrationUI({ page, microappsAdminUrl, filePath }: ImportIntegrationUI): Promise<void>; | ||
importIntegrationUI({ page, microappsAdminUrl, filePath, }: ImportIntegrationUI): Promise<void>; | ||
/** | ||
@@ -574,3 +598,3 @@ * Imports MicroApp to @param integrationName Integration from an exported MicroApp file | ||
*/ | ||
importMicroAppUI({ page, microappsAdminUrl, filePath, integrationName }: ImportMicroAppUI): Promise<void>; | ||
importMicroAppUI({ page, microappsAdminUrl, filePath, integrationName, }: ImportMicroAppUI): Promise<void>; | ||
/** | ||
@@ -590,3 +614,3 @@ * Exports @param integrationName integation | ||
*/ | ||
exportMicroAppsUI({ page, integrationName, appName }: ExportMicroAppUI): Promise<void>; | ||
exportMicroAppsUI({ page, integrationName, appName, }: ExportMicroAppUI): Promise<void>; | ||
/** | ||
@@ -599,3 +623,13 @@ * Returns last duration of Synchronization | ||
*/ | ||
getLastTimeSync({ authInstance, microappsAdminUrl, integrationName }: GetLastSyncTime): Promise<any>; | ||
getLastTimeSync({ authInstance, microappsAdminUrl, integrationName, }: GetLastSyncTime): Promise<any>; | ||
/** | ||
* Returns Id of component | ||
* | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} integrationName - Name of Integration | ||
* @param {string} appName - Name of Microapp | ||
* @param {string} componentLabel - Label of Component | ||
*/ | ||
getComponentId({ authInstance, microappsAdminUrl, integrationName, appName, pageName, componentLabel, }: GetComponentId): Promise<any>; | ||
} | ||
@@ -750,4 +784,13 @@ export declare type MicroappsAdminLogin = { | ||
}; | ||
export declare type GetComponentId = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
appName: string; | ||
pageName: string; | ||
componentLabel: string; | ||
}; | ||
import { Page, BrowserContext } from "playwright"; | ||
@@ -765,3 +808,3 @@ /** Class representing a Workspace. */ | ||
*/ | ||
login({ page, workspaceUrl, workspaceUsername, workspacePassword, workspaceIdentityProvider }: Login): Promise<void>; | ||
login({ page, workspaceUrl, workspaceUsername, workspacePassword, workspaceIdentityProvider, }: Login): Promise<void>; | ||
/** | ||
@@ -797,3 +840,3 @@ * Skip Tour | ||
*/ | ||
waitForFeedCardId({ page, repeatMax, waitTime, recordId, notificationId }: WaitForFeedCardId): Promise<any>; | ||
waitForFeedCardId({ page, repeatMax, waitTime, recordId, notificationId, }: WaitForFeedCardId): Promise<any>; | ||
/** | ||
@@ -823,3 +866,4 @@ * Returns button on FeedCard | ||
}>; | ||
createDsAuthInstance({ citrixToken, jSessionId }: CreateDsAuthInstance): Promise<import("axios").AxiosInstance>; | ||
createDsAuthInstance({ citrixToken, jSessionId, }: CreateDsAuthInstance): Promise<import("axios").AxiosInstance>; | ||
getUserData({ dSauthInstance, microappsAdminUrl, appId, componentId, dataLimit, initiatorType, initiatorData, pageId, authDomain, }: GetUserData): Promise<any>; | ||
} | ||
@@ -890,7 +934,12 @@ export declare type Login = { | ||
}; | ||
export declare type GetCookie = { | ||
cookies: any; | ||
cookieName: string; | ||
export declare type GetUserData = { | ||
dSauthInstance: any; | ||
microappsAdminUrl: string; | ||
appId: string; | ||
componentId: string; | ||
dataLimit: string; | ||
initiatorType: string; | ||
initiatorData: string; | ||
pageId: string; | ||
authDomain: string; | ||
}; | ||
export declare const getCookie: ({ cookies, cookieName }: GetCookie) => string; |
{ | ||
"name": "microapps-automation-helper", | ||
"version": "1.0.10", | ||
"version": "1.1.0", | ||
"description": "> library which provides common functions to test integration between Microapps Admin and Citrix Worskspace", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
1530
src/api.ts
@@ -1,305 +0,313 @@ | ||
import axios from "axios"; | ||
import fs from "fs"; | ||
import path from "path"; | ||
import axios from 'axios'; | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import { errorHandle } from './helpers'; | ||
/** Class representing a Citrix Cloud. */ | ||
export class API { | ||
constructor() {} | ||
/** | ||
* Get Citrix Cloud Tokens | ||
* | ||
* @param {string} cwaAPI - Api Environment | ||
* @param {string} citrixCloudCustomerId - Customer Id | ||
* @param {string} citrixCloudClientId - Client Id | ||
* @param {string} citrixCloudClientSecret - Client Secret | ||
*/ | ||
constructor() {} | ||
/** | ||
* Get Citrix Cloud Tokens | ||
* | ||
* @param {string} cwaAPI - Api Environment | ||
* @param {string} citrixCloudCustomerId - Customer Id | ||
* @param {string} citrixCloudClientId - Client Id | ||
* @param {string} citrixCloudClientSecret - Client Secret | ||
*/ | ||
async getCitrixCloudTokens({ | ||
cwaAPI, | ||
citrixCloudCustomerId, | ||
citrixCloudClientId, | ||
citrixCloudClientSecret, | ||
}: GetCitrixCloudTokens) { | ||
try { | ||
return await axios({ | ||
timeout: 180000, | ||
url: `https://trust.${cwaAPI}.net/${citrixCloudCustomerId}/tokens/clients`, | ||
method: "POST", | ||
data: { | ||
clientId: citrixCloudClientId, | ||
clientSecret: citrixCloudClientSecret, | ||
}, | ||
}); | ||
} catch (error) { | ||
throw error.stack; | ||
async getCitrixCloudTokens({ | ||
cwaAPI, | ||
citrixCloudCustomerId, | ||
citrixCloudClientId, | ||
citrixCloudClientSecret, | ||
}: GetCitrixCloudTokens) { | ||
try { | ||
return await axios({ | ||
timeout: 180000, | ||
url: `https://trust.${cwaAPI}.net/${citrixCloudCustomerId}/tokens/clients`, | ||
method: 'POST', | ||
data: { | ||
clientId: citrixCloudClientId, | ||
clientSecret: citrixCloudClientSecret, | ||
}, | ||
}); | ||
} catch (error) { | ||
await errorHandle({ | ||
error, | ||
args: { cwaAPI, citrixCloudClientId, citrixCloudClientSecret, citrixCloudCustomerId }, | ||
}); | ||
} | ||
} | ||
} | ||
/** | ||
* Get all Integrations in Miroapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
*/ | ||
async getIntegrations({ authInstance, microappsAdminUrl }: GetIntegrations) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/service`, | ||
method: "GET", | ||
}); | ||
} catch (error) { | ||
throw error.stack; | ||
/** | ||
* Get all Integrations in Miroapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
*/ | ||
async getIntegrations({ authInstance, microappsAdminUrl }: GetIntegrations) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/service`, | ||
method: 'GET', | ||
}); | ||
} catch (error) { | ||
await errorHandle({ | ||
error, | ||
args: {}, | ||
}); | ||
} | ||
} | ||
} | ||
/** | ||
* Get Bundle Catalogue in Miroapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
*/ | ||
/** | ||
* Get Bundle Catalogue in Miroapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
*/ | ||
async getBundleCatalogue({ | ||
authInstance, | ||
microappsAdminUrl, | ||
}: GetBundleCatalogue) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/bundleCatalogue`, | ||
method: "GET", | ||
}); | ||
} catch (error) { | ||
throw error.stack; | ||
async getBundleCatalogue({ authInstance, microappsAdminUrl }: GetBundleCatalogue) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/bundleCatalogue`, | ||
method: 'GET', | ||
}); | ||
} catch (error) { | ||
await errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl }, | ||
}); | ||
} | ||
} | ||
} | ||
/** | ||
* Update Bundle Catalogue in Miroapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} catalogueId - Catalogue Id | ||
*/ | ||
async updateBundleCatalogue({ | ||
authInstance, | ||
microappsAdminUrl, | ||
catalogueId, | ||
}: UpdateBundleCatalogue) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/bundleCatalogue/import/${catalogueId}`, | ||
method: "POST", | ||
}); | ||
} catch (error) { | ||
throw error.stack; | ||
/** | ||
* Update Bundle Catalogue in Miroapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} catalogueId - Catalogue Id | ||
*/ | ||
async updateBundleCatalogue({ authInstance, microappsAdminUrl, catalogueId }: UpdateBundleCatalogue) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/bundleCatalogue/import/${catalogueId}`, | ||
method: 'POST', | ||
}); | ||
} catch (error) { | ||
await errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, catalogueId }, | ||
}); | ||
} | ||
} | ||
} | ||
/** | ||
* Update Integration Configuration in Miroapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} integrationId - Integration Id | ||
* @param {string} integrationConfiguration - integrationConfiguration | ||
*/ | ||
async updateintegrationConfiguration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
integrationConfiguration, | ||
}: UpdateintegrationConfiguration) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/service/${integrationId}`, | ||
method: "PUT", | ||
data: integrationConfiguration, | ||
}); | ||
} catch (error) { | ||
throw error.stack; | ||
/** | ||
* Update Integration Configuration in Miroapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} integrationId - Integration Id | ||
* @param {string} integrationConfiguration - integrationConfiguration | ||
*/ | ||
async updateintegrationConfiguration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
integrationConfiguration, | ||
}: UpdateintegrationConfiguration) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/service/${integrationId}`, | ||
method: 'PUT', | ||
data: integrationConfiguration, | ||
}); | ||
} catch (error) { | ||
await errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, integrationId, integrationConfiguration }, | ||
}); | ||
} | ||
} | ||
} | ||
/** | ||
* Get one specific Integration in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} integrationId - Integration Id | ||
*/ | ||
async getIntegration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
}: GetIntegration) { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/service/${integrationId}`, | ||
method: "GET", | ||
}); | ||
} | ||
/** | ||
* Get one specific Integration in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} integrationId - Integration Id | ||
*/ | ||
async getIntegration({ authInstance, microappsAdminUrl, integrationId }: GetIntegration) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/service/${integrationId}`, | ||
method: 'GET', | ||
}); | ||
} catch (error) { | ||
await errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, integrationId }, | ||
}); | ||
} | ||
} | ||
/** | ||
* Auth logout in Integration in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} integrationId - Integration Id | ||
*/ | ||
async integrationLogout({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
}: IntegrationLogout) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/auth/serviceAction/logout/${integrationId}`, | ||
method: "GET", | ||
}); | ||
} catch (error) { | ||
throw error.stack; | ||
/** | ||
* Auth logout in Integration in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} integrationId - Integration Id | ||
*/ | ||
async integrationLogout({ authInstance, microappsAdminUrl, integrationId }: IntegrationLogout) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/auth/serviceAction/logout/${integrationId}`, | ||
method: 'GET', | ||
}); | ||
} catch (error) { | ||
await errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, integrationId }, | ||
}); | ||
} | ||
} | ||
} | ||
/** | ||
* Validate configuration of Integration in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} serviceKey - ServiceKey of Integration | ||
* @param {string} configuration - Configuration parameters of Integration | ||
*/ | ||
async validateConfiguration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
serviceKey, | ||
configuration, | ||
}: ValidateConfiguration) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/external-services/${serviceKey}/validate-configuration`, | ||
method: "POST", | ||
data: { | ||
configurationParameters: configuration, | ||
onPremProxyConfiguration: { | ||
useOnPremProxy: false, | ||
resourceLocation: "", | ||
}, | ||
}, | ||
}); | ||
} catch (error) { | ||
throw error.stack; | ||
/** | ||
* Validate configuration of Integration in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} serviceKey - ServiceKey of Integration | ||
* @param {string} configuration - Configuration parameters of Integration | ||
*/ | ||
async validateConfiguration({ authInstance, microappsAdminUrl, serviceKey, configuration }: ValidateConfiguration) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/external-services/${serviceKey}/validate-configuration`, | ||
method: 'POST', | ||
data: { | ||
configurationParameters: configuration, | ||
onPremProxyConfiguration: { | ||
useOnPremProxy: false, | ||
resourceLocation: '', | ||
}, | ||
}, | ||
}); | ||
} catch (error) { | ||
await errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, serviceKey, configuration }, | ||
}); | ||
} | ||
} | ||
} | ||
/** | ||
* Add MicroApp in Integration in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} data - Data of the MicroApp | ||
*/ | ||
async addApp({ authInstance, microappsAdminUrl, data }: AddApp) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/app`, | ||
method: "POST", | ||
data, | ||
}); | ||
} catch (error) { | ||
throw error.stack; | ||
/** | ||
* Add MicroApp in Integration in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} data - Data of the MicroApp | ||
*/ | ||
async addApp({ authInstance, microappsAdminUrl, data }: AddApp) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/app`, | ||
method: 'POST', | ||
data, | ||
}); | ||
} catch (error) { | ||
await errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, data }, | ||
}); | ||
} | ||
} | ||
} | ||
/** | ||
* Get status of one specific process | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} processId - Id of the process | ||
*/ | ||
async getProcessStatus({ | ||
authInstance, | ||
microappsAdminUrl, | ||
processId, | ||
}: GetProcessStatus) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/process/${processId}`, | ||
method: "GET", | ||
}); | ||
} catch (error) { | ||
throw error.stack; | ||
/** | ||
* Get status of one specific process | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} processId - Id of the process | ||
*/ | ||
async getProcessStatus({ authInstance, microappsAdminUrl, processId }: GetProcessStatus) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/process/${processId}`, | ||
method: 'GET', | ||
}); | ||
} catch (error) { | ||
await errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, processId }, | ||
}); | ||
} | ||
} | ||
} | ||
/** | ||
* Get all Entities of Integration in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} integrationId - Integration Id | ||
*/ | ||
async getEntities({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
}: GetEntities) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/service/${integrationId}/entities`, | ||
method: "GET", | ||
}); | ||
} catch (error) { | ||
throw error.stack; | ||
/** | ||
* Get all Entities of Integration in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} integrationId - Integration Id | ||
*/ | ||
async getEntities({ authInstance, microappsAdminUrl, integrationId }: GetEntities) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/service/${integrationId}/entities`, | ||
method: 'GET', | ||
}); | ||
} catch (error) { | ||
await errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, integrationId }, | ||
}); | ||
} | ||
} | ||
} | ||
/** | ||
* Create Entity in Integration in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} integrationId - Integration Id | ||
* @param {string} entityData - Data of the Entity | ||
*/ | ||
async createEntity({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
entityData, | ||
}: CreateEntity) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/service/${integrationId}/entities`, | ||
method: "PUT", | ||
data: entityData, | ||
}); | ||
} catch (error) { | ||
throw error.stack; | ||
/** | ||
* Create Entity in Integration in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} integrationId - Integration Id | ||
* @param {string} entityData - Data of the Entity | ||
*/ | ||
async createEntity({ authInstance, microappsAdminUrl, integrationId, entityData }: CreateEntity) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/service/${integrationId}/entities`, | ||
method: 'PUT', | ||
data: entityData, | ||
}); | ||
} catch (error) { | ||
await errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, integrationId, entityData }, | ||
}); | ||
} | ||
} | ||
} | ||
/** | ||
* Finalize configuration of Integration in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} integrationId - Integration Id | ||
*/ | ||
async finalizeConfig({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
}: FinalizeConfig) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/service/${integrationId}/finalize-config`, | ||
method: "POST", | ||
}); | ||
} catch (error) { | ||
throw error.stack; | ||
/** | ||
* Finalize configuration of Integration in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} integrationId - Integration Id | ||
*/ | ||
async finalizeConfig({ authInstance, microappsAdminUrl, integrationId }: FinalizeConfig) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/service/${integrationId}/finalize-config`, | ||
method: 'POST', | ||
}); | ||
} catch (error) { | ||
await errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, integrationId }, | ||
}); | ||
} | ||
} | ||
} | ||
/** | ||
/** | ||
* Get all MicroApps in Microapps Admin | ||
@@ -311,601 +319,603 @@ * | ||
*/ | ||
async getApps({ authInstance, microappsAdminUrl }: GetApps) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/app`, | ||
method: "GET", | ||
}); | ||
} catch (error) { | ||
throw error.stack; | ||
async getApps({ authInstance, microappsAdminUrl }: GetApps) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/app`, | ||
method: 'GET', | ||
}); | ||
} catch (error) { | ||
await errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl }, | ||
}); | ||
} | ||
} | ||
} | ||
/** | ||
* Get Notifications of MicroApp in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} appId - Id of the MicroApp | ||
*/ | ||
async getNotifications({ | ||
authInstance, | ||
microappsAdminUrl, | ||
appId, | ||
}: GetNotifications) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/notifications/app/${appId}`, | ||
method: "GET", | ||
}); | ||
} catch (error) { | ||
throw error.stack; | ||
/** | ||
* Get Notifications of MicroApp in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} appId - Id of the MicroApp | ||
*/ | ||
async getNotifications({ authInstance, microappsAdminUrl, appId }: GetNotifications) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/notifications/app/${appId}`, | ||
method: 'GET', | ||
}); | ||
} catch (error) { | ||
await errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, appId }, | ||
}); | ||
} | ||
} | ||
} | ||
/** | ||
* Run Event in MicroApp in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
*/ | ||
async runNotificationEvent({ | ||
authInstance, | ||
microappsAdminUrl, | ||
notificationId, | ||
}: RunNotificationEvent) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/notification/${notificationId}/run`, | ||
method: "POST", | ||
}); | ||
} catch (error) { | ||
throw error.stack; | ||
/** | ||
* Run Event in MicroApp in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
*/ | ||
async runNotificationEvent({ authInstance, microappsAdminUrl, notificationId }: RunNotificationEvent) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/notification/${notificationId}/run`, | ||
method: 'POST', | ||
}); | ||
} catch (error) { | ||
await errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, notificationId }, | ||
}); | ||
} | ||
} | ||
} | ||
/** | ||
* Start Synchronization of Integration in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} integrationId - Integration Id | ||
*/ | ||
async startSynchronization({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
synchronizationType, | ||
}: StartSynchronization) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/service/${integrationId}/run/${synchronizationType}`, | ||
method: "POST", | ||
}); | ||
} catch (error) { | ||
throw error.stack; | ||
/** | ||
* Start Synchronization of Integration in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} integrationId - Integration Id | ||
*/ | ||
async startSynchronization({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
synchronizationType, | ||
}: StartSynchronization) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/service/${integrationId}/run/${synchronizationType}`, | ||
method: 'POST', | ||
}); | ||
} catch (error) { | ||
await errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, integrationId, synchronizationType }, | ||
}); | ||
} | ||
} | ||
} | ||
/** | ||
* Check integrity of all MicroApps in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
*/ | ||
async integrityCheck({ authInstance, microappsAdminUrl }: IntegrityCheck) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/app/integrity-check`, | ||
method: "GET", | ||
}); | ||
} catch (error) { | ||
throw error.stack; | ||
/** | ||
* Check integrity of all MicroApps in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
*/ | ||
async integrityCheck({ authInstance, microappsAdminUrl }: IntegrityCheck) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/app/integrity-check`, | ||
method: 'GET', | ||
}); | ||
} catch (error) { | ||
await errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl }, | ||
}); | ||
} | ||
} | ||
} | ||
/** | ||
* Delete Integration in Microaaps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} integrationId - Integration Id | ||
*/ | ||
async deleteIntegration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
}: DeleteIntegration) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/service/${integrationId}`, | ||
method: "DELETE", | ||
}); | ||
} catch (error) { | ||
throw error.stack; | ||
/** | ||
* Delete Integration in Microaaps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} integrationId - Integration Id | ||
*/ | ||
async deleteIntegration({ authInstance, microappsAdminUrl, integrationId }: DeleteIntegration) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/service/${integrationId}`, | ||
method: 'DELETE', | ||
}); | ||
} catch (error) { | ||
await errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, integrationId }, | ||
}); | ||
} | ||
} | ||
} | ||
/** | ||
* Sets Domain in authInstance for specific Workspace Identity Provider | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} cwaAPI - Api Environment | ||
* @param {string} citrixCloudCustomerId - Customer Id | ||
* @param {string} workspaceIdentityProvider - Identity Provider of Workspace | ||
*/ | ||
async getDomain({ | ||
authInstance, | ||
cwaAPI, | ||
citrixCloudCustomerId, | ||
workspaceIdentityProvider, | ||
}: GetDomain) { | ||
try { | ||
switch (workspaceIdentityProvider) { | ||
case "ad": | ||
return await authInstance({ | ||
url: `https://cws.${cwaAPI}.net/${citrixCloudCustomerId}/domainconfigurations`, | ||
method: "GET", | ||
params: { | ||
Provider: workspaceIdentityProvider.toUpperCase(), | ||
}, | ||
}); | ||
case "netscaler": | ||
return await authInstance({ | ||
url: `https://cws.${cwaAPI}.net/${citrixCloudCustomerId}/domainconfigurations`, | ||
method: "GET", | ||
params: { | ||
Provider: "AD", | ||
}, | ||
}); | ||
case "aad": | ||
return await authInstance({ | ||
url: `https://cws.${cwaAPI}.net/${citrixCloudCustomerId}/AuthDomains`, | ||
method: "GET", | ||
}); | ||
case "okta": | ||
break; | ||
default: | ||
console.log( | ||
`getDomain is currently not implemented for this idp: ${workspaceIdentityProvider}` | ||
); | ||
break; | ||
} | ||
} catch (error) { | ||
throw error.stack; | ||
/** | ||
* Sets Domain in authInstance for specific Workspace Identity Provider | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} cwaAPI - Api Environment | ||
* @param {string} citrixCloudCustomerId - Customer Id | ||
* @param {string} workspaceIdentityProvider - Identity Provider of Workspace | ||
*/ | ||
async getDomain({ authInstance, cwaAPI, citrixCloudCustomerId, workspaceIdentityProvider }: GetDomain) { | ||
try { | ||
switch (workspaceIdentityProvider) { | ||
case 'ad': | ||
return await authInstance({ | ||
url: `https://cws.${cwaAPI}.net/${citrixCloudCustomerId}/domainconfigurations`, | ||
method: 'GET', | ||
params: { | ||
Provider: workspaceIdentityProvider.toUpperCase(), | ||
}, | ||
}); | ||
case 'netscaler': | ||
return await authInstance({ | ||
url: `https://cws.${cwaAPI}.net/${citrixCloudCustomerId}/domainconfigurations`, | ||
method: 'GET', | ||
params: { | ||
Provider: 'AD', | ||
}, | ||
}); | ||
case 'aad': | ||
return await authInstance({ | ||
url: `https://cws.${cwaAPI}.net/${citrixCloudCustomerId}/AuthDomains`, | ||
method: 'GET', | ||
}); | ||
case 'okta': | ||
break; | ||
default: | ||
console.log(`getDomain is currently not implemented for this idp: ${workspaceIdentityProvider}`); | ||
break; | ||
} | ||
} catch (error) { | ||
await errorHandle({ | ||
error, | ||
args: { authInstance, cwaAPI, citrixCloudCustomerId, workspaceIdentityProvider }, | ||
}); | ||
} | ||
} | ||
} | ||
/** | ||
* Get data of specific Users for Subscribing to MicroApp in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} cwaAPI - Api Environment | ||
* @param {string} domainName - Domain name | ||
* @param {string} forestName - Forest name | ||
* @param {string} appId - Id of the MicroApp | ||
* @param {string} query - List of Subscribers | ||
* @param {string} citrixCloudCustomerId - Customer Id | ||
* @param {string} idpType - Identity Provider of Workspace | ||
*/ | ||
async getUsers({ | ||
authInstance, | ||
cwaAPI, | ||
domainName, | ||
forestName, | ||
appId, | ||
query, | ||
citrixCloudCustomerId, | ||
idpType, | ||
}: GetUsers) { | ||
try { | ||
return await authInstance({ | ||
url: `https://cws.${cwaAPI}.net/${citrixCloudCustomerId}/users/query`, | ||
method: "POST", | ||
data: { | ||
adminUser: "", | ||
domain: domainName, | ||
forest: forestName, | ||
idpType: idpType, | ||
key: "", | ||
offerings: [ | ||
{ | ||
compatibleIdentities: [ | ||
{ | ||
compatibleIdentity: "OID:/*", | ||
reasons: [], | ||
/** | ||
* Get data of specific Users for Subscribing to MicroApp in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} cwaAPI - Api Environment | ||
* @param {string} domainName - Domain name | ||
* @param {string} forestName - Forest name | ||
* @param {string} appId - Id of the MicroApp | ||
* @param {string} query - List of Subscribers | ||
* @param {string} citrixCloudCustomerId - Customer Id | ||
* @param {string} idpType - Identity Provider of Workspace | ||
*/ | ||
async getUsers({ | ||
authInstance, | ||
cwaAPI, | ||
domainName, | ||
forestName, | ||
appId, | ||
query, | ||
citrixCloudCustomerId, | ||
idpType, | ||
}: GetUsers) { | ||
try { | ||
return await authInstance({ | ||
url: `https://cws.${cwaAPI}.net/${citrixCloudCustomerId}/users/query`, | ||
method: 'POST', | ||
data: { | ||
adminUser: '', | ||
domain: domainName, | ||
forest: forestName, | ||
idpType: idpType, | ||
key: '', | ||
offerings: [ | ||
{ | ||
compatibleIdentities: [ | ||
{ | ||
compatibleIdentity: 'OID:/*', | ||
reasons: [], | ||
}, | ||
], | ||
offeringId: appId, | ||
}, | ||
], | ||
query: query, | ||
supportsAzureAdGroups: idpType === 'AZUREAD', | ||
}, | ||
], | ||
offeringId: appId, | ||
}, | ||
], | ||
query: query, | ||
supportsAzureAdGroups: idpType === "AZUREAD", | ||
}, | ||
}); | ||
} catch (error) { | ||
throw error.stack; | ||
}); | ||
} catch (error) { | ||
await errorHandle({ | ||
error, | ||
args: { authInstance, cwaAPI, domainName, forestName, appId, query, citrixCloudCustomerId, idpType }, | ||
}); | ||
} | ||
} | ||
} | ||
/** | ||
* Update Subscribers of MicroApp in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} assign - Action type | ||
* @param {string} userDetail - List of Subscribers | ||
* @param {string} appId - Id of the MicroApp | ||
* @param {string} domainName - Domain name | ||
* @param {string} forestName - Forest name | ||
* @param {string} workspaceIdentityProvider - Identity Provider of Workspace | ||
*/ | ||
async updateSubscribers({ | ||
authInstance, | ||
microappsAdminUrl, | ||
assign, | ||
userDetail, | ||
appId, | ||
domainName, | ||
forestName, | ||
workspaceIdentityProvider, | ||
}: UpdateSubscribers) { | ||
const { | ||
accountName, | ||
displayName, | ||
universalClaims, | ||
identityInformation, | ||
isGroup, | ||
} = userDetail[0]; | ||
/** | ||
* Update Subscribers of MicroApp in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} assign - Action type | ||
* @param {string} userDetail - List of Subscribers | ||
* @param {string} appId - Id of the MicroApp | ||
* @param {string} domainName - Domain name | ||
* @param {string} forestName - Forest name | ||
* @param {string} workspaceIdentityProvider - Identity Provider of Workspace | ||
*/ | ||
async updateSubscribers({ | ||
authInstance, | ||
microappsAdminUrl, | ||
assign, | ||
userDetail, | ||
appId, | ||
domainName, | ||
forestName, | ||
workspaceIdentityProvider, | ||
}: UpdateSubscribers) { | ||
const { accountName, displayName, universalClaims, identityInformation, isGroup } = userDetail[0]; | ||
const getOID = universalClaims.filter((value: string) => { | ||
return value.startsWith("OID"); | ||
}); | ||
const getOID = universalClaims.filter((value: string) => { | ||
return value.startsWith('OID'); | ||
}); | ||
const oid = getOID[0]; | ||
const oid = getOID[0]; | ||
let ipForUpdate; | ||
switch (workspaceIdentityProvider) { | ||
case "ad": | ||
case "netscaler": | ||
ipForUpdate = "AD"; | ||
break; | ||
case "aad": | ||
ipForUpdate = "AzureAD"; | ||
break; | ||
case "okta": | ||
ipForUpdate = "Okta"; | ||
break; | ||
default: | ||
ipForUpdate = null; | ||
console.log( | ||
`Adding subscribers is currently not implemented for this idp` | ||
); | ||
break; | ||
} | ||
let ipForUpdate; | ||
switch (workspaceIdentityProvider) { | ||
case 'ad': | ||
case 'netscaler': | ||
ipForUpdate = 'AD'; | ||
break; | ||
case 'aad': | ||
ipForUpdate = 'AzureAD'; | ||
break; | ||
case 'okta': | ||
ipForUpdate = 'Okta'; | ||
break; | ||
default: | ||
ipForUpdate = null; | ||
console.log(`Adding subscribers is currently not implemented for this idp`); | ||
break; | ||
} | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/security/app-user/selected-groups/${appId}`, | ||
method: "PUT", | ||
data: [ | ||
{ | ||
oid: oid, | ||
accountName: accountName, | ||
displayName: displayName, | ||
directoryContext: { | ||
domain: domainName, | ||
forest: forestName, | ||
identityProvider: ipForUpdate, | ||
}, | ||
email: identityInformation.email, | ||
isGroup: isGroup, | ||
domain: domainName, | ||
userPrincipalName: identityInformation.email, | ||
universalClaims: universalClaims, | ||
assign: assign === "Add" ? true : false, | ||
}, | ||
], | ||
}); | ||
} catch (error) { | ||
throw error.stack; | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/security/app-user/selected-groups/${appId}`, | ||
method: 'PUT', | ||
data: [ | ||
{ | ||
oid: oid, | ||
accountName: accountName, | ||
displayName: displayName, | ||
directoryContext: { | ||
domain: domainName, | ||
forest: forestName, | ||
identityProvider: ipForUpdate, | ||
}, | ||
email: identityInformation.email, | ||
isGroup: isGroup, | ||
domain: domainName, | ||
userPrincipalName: identityInformation.email, | ||
universalClaims: universalClaims, | ||
assign: assign === 'Add' ? true : false, | ||
}, | ||
], | ||
}); | ||
} catch (error) { | ||
await errorHandle({ | ||
error, | ||
args: { | ||
authInstance, | ||
microappsAdminUrl, | ||
assign, | ||
userDetail, | ||
appId, | ||
domainName, | ||
forestName, | ||
workspaceIdentityProvider, | ||
}, | ||
}); | ||
} | ||
} | ||
} | ||
/** | ||
* Get all Subscribers of MicroApp in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} appId - Id of the MicroApp | ||
*/ | ||
async getSubscribers({ | ||
authInstance, | ||
microappsAdminUrl, | ||
appId, | ||
}: GetSubscribers) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/security/app-user/selected-groups/${appId}`, | ||
method: "GET", | ||
}); | ||
} catch (error) { | ||
throw error.stack; | ||
/** | ||
* Get all Subscribers of MicroApp in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} appId - Id of the MicroApp | ||
*/ | ||
async getSubscribers({ authInstance, microappsAdminUrl, appId }: GetSubscribers) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/security/app-user/selected-groups/${appId}`, | ||
method: 'GET', | ||
}); | ||
} catch (error) { | ||
await errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, appId }, | ||
}); | ||
} | ||
} | ||
} | ||
/** | ||
* Import Integration from an exported Integration file | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} integrationId - Id of itntegration | ||
* @param {string} filePath - Path where to file will be saved | ||
* @param {string} params - Mandatadory params are vendor, appId (which apps will be exported) and optional param description. | ||
* Example: vendor=Citrix&appId=myAppId1&appId=myAppId2&description= | ||
*/ | ||
async exportIntegration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
filePath, | ||
params, | ||
}: ExportIntegration) { | ||
let response; | ||
try { | ||
response = await authInstance({ | ||
method: "GET", | ||
url: `${microappsAdminUrl}/api/service/${integrationId}/export`, | ||
params, | ||
responseType: "stream", | ||
}); | ||
} catch (error) { | ||
throw error.stack; | ||
/** | ||
* Import Integration from an exported Integration file | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} integrationId - Id of itntegration | ||
* @param {string} filePath - Path where to file will be saved | ||
* @param {string} params - Mandatadory params are vendor, appId (which apps will be exported) and optional param description. | ||
* Example: vendor=Citrix&appId=myAppId1&appId=myAppId2&description= | ||
*/ | ||
async exportIntegration({ authInstance, microappsAdminUrl, integrationId, filePath, params }: ExportIntegration) { | ||
let response; | ||
try { | ||
response = await authInstance({ | ||
method: 'GET', | ||
url: `${microappsAdminUrl}/api/service/${integrationId}/export`, | ||
params, | ||
responseType: 'stream', | ||
}); | ||
} catch (error) { | ||
await errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, integrationId, filePath, params }, | ||
}); | ||
} | ||
await response.data.pipe(fs.createWriteStream(path.resolve(__dirname, filePath))); | ||
} | ||
await response.data.pipe( | ||
fs.createWriteStream(path.resolve(__dirname, filePath)) | ||
); | ||
} | ||
/** | ||
* get integration log | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} integrationName - Name of Integration | ||
* @param {string} integrationType - Type of Integration | ||
*/ | ||
async getIntegrationLog({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
integrationType, | ||
}: GetIntegrationLog) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/event-log?entityRef=${integrationId}&type=${integrationType}&subType=JOB&offset=0&limit=20`, | ||
method: "GET", | ||
}); | ||
} catch (error) { | ||
throw error.stack; | ||
/** | ||
* get integration log | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} integrationName - Name of Integration | ||
* @param {string} integrationType - Type of Integration | ||
*/ | ||
async getIntegrationLog({ authInstance, microappsAdminUrl, integrationId, integrationType }: GetIntegrationLog) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/event-log?entityRef=${integrationId}&type=${integrationType}&subType=JOB&offset=0&limit=20`, | ||
method: 'GET', | ||
}); | ||
} catch (error) { | ||
await errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, integrationId, integrationType }, | ||
}); | ||
} | ||
} | ||
} | ||
/** | ||
* Update integration with secrets | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} integrationId - Id of Integration | ||
* @param {string} data - Secrest which should be add to the integration | ||
*/ | ||
async addSecrets({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
data, | ||
}: AddSecrets) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/service/${integrationId}/secrets`, | ||
method: "POST", | ||
data, | ||
}); | ||
} catch (error) { | ||
throw error.stack; | ||
/** | ||
* Update integration with secrets | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} integrationId - Id of Integration | ||
* @param {string} data - Secrest which should be add to the integration | ||
*/ | ||
async addSecrets({ authInstance, microappsAdminUrl, integrationId, data }: AddSecrets) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/service/${integrationId}/secrets`, | ||
method: 'POST', | ||
data, | ||
}); | ||
} catch (error) { | ||
await errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, integrationId, data }, | ||
}); | ||
} | ||
} | ||
} | ||
/** | ||
* Get microapp info - pages, components etc... | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} appId - Id of microapp | ||
*/ | ||
async getAppInfo({ authInstance, microappsAdminUrl, appId }: GetAppInfo) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/app/${appId}`, | ||
method: "GET", | ||
}); | ||
} catch (error) { | ||
throw error.stack; | ||
/** | ||
* Get microapp info - pages, components etc... | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} appId - Id of microapp | ||
*/ | ||
async getAppInfo({ authInstance, microappsAdminUrl, appId }: GetAppInfo) { | ||
try { | ||
return await authInstance({ | ||
url: `${microappsAdminUrl}/api/app/${appId}`, | ||
method: 'GET', | ||
}); | ||
} catch (error) { | ||
await errorHandle({ | ||
error, | ||
args: { authInstance, microappsAdminUrl, appId }, | ||
}); | ||
} | ||
} | ||
} | ||
} | ||
export type AddApp = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
data: string; | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
data: string; | ||
}; | ||
export type GetBundleCatalogue = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
}; | ||
export type GetIntegration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
}; | ||
export type GetIntegrations = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
}; | ||
export type GetProcessStatus = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
processId: string; | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
processId: string; | ||
}; | ||
export type IntegrationLogout = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
}; | ||
export type UpdateBundleCatalogue = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
catalogueId: string; | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
catalogueId: string; | ||
}; | ||
export type UpdateintegrationConfiguration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
integrationConfiguration: any; | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
integrationConfiguration: any; | ||
}; | ||
export type ValidateConfiguration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
serviceKey: string; | ||
configuration: string; | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
serviceKey: string; | ||
configuration: string; | ||
}; | ||
export type GetEntities = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
}; | ||
export type CreateEntity = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
entityData: any; | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
entityData: any; | ||
}; | ||
export type FinalizeConfig = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
}; | ||
export type GetApps = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
}; | ||
export type GetNotifications = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
appId: string; | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
appId: string; | ||
}; | ||
export type RunNotificationEvent = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
notificationId: string; | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
notificationId: string; | ||
}; | ||
export type StartSynchronization = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
synchronizationType: string; | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
synchronizationType: string; | ||
}; | ||
export type IntegrityCheck = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
}; | ||
export type DeleteIntegration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
}; | ||
export type GetDomain = { | ||
authInstance: any; | ||
cwaAPI: string; | ||
citrixCloudCustomerId: string; | ||
workspaceIdentityProvider: string; | ||
authInstance: any; | ||
cwaAPI: string; | ||
citrixCloudCustomerId: string; | ||
workspaceIdentityProvider: string; | ||
}; | ||
export type GetUsers = { | ||
authInstance: any; | ||
cwaAPI: string; | ||
domainName: string; | ||
forestName: string; | ||
appId: string; | ||
query: string; | ||
citrixCloudCustomerId: string; | ||
idpType: any; | ||
authInstance: any; | ||
cwaAPI: string; | ||
domainName: string; | ||
forestName: string; | ||
appId: string; | ||
query: string; | ||
citrixCloudCustomerId: string; | ||
idpType: any; | ||
}; | ||
export type UpdateSubscribers = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
assign: string; | ||
userDetail: any; | ||
appId: string; | ||
domainName: string; | ||
forestName: string; | ||
workspaceIdentityProvider: string; | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
assign: string; | ||
userDetail: any; | ||
appId: string; | ||
domainName: string; | ||
forestName: string; | ||
workspaceIdentityProvider: string; | ||
}; | ||
export type GetSubscribers = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
appId: string; | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
appId: string; | ||
}; | ||
export type ExportIntegration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
filePath: any; | ||
params: any; | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
filePath: any; | ||
params: any; | ||
}; | ||
export type GetIntegrationLog = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
integrationType: string; | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
integrationType: string; | ||
}; | ||
export type GetCitrixCloudTokens = { | ||
cwaAPI: string; | ||
citrixCloudCustomerId: string; | ||
citrixCloudClientId: string; | ||
citrixCloudClientSecret: string; | ||
cwaAPI: string; | ||
citrixCloudCustomerId: string; | ||
citrixCloudClientId: string; | ||
citrixCloudClientSecret: string; | ||
}; | ||
export type AddSecrets = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
data: any; | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
data: any; | ||
}; | ||
export type GetAppInfo = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
appId: string; | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
appId: string; | ||
}; |
@@ -0,15 +1,135 @@ | ||
import { AxiosError } from 'axios'; | ||
export type GetCookie = { | ||
cookies: any; | ||
cookieName: string; | ||
cookies: any; | ||
cookieName: string; | ||
}; | ||
export type ErrorHandle = { | ||
error: AxiosError; | ||
args: Object; | ||
}; | ||
export const getCookie = ({ cookies, cookieName }: GetCookie): string => { | ||
const regexp = new RegExp(`^${cookieName}=([^;]+);`); | ||
const cookie = cookies.find((cookieString: { match: (arg0: RegExp) => null }) => cookieString.match(regexp) !== null); | ||
const regexp = new RegExp(`^${cookieName}=([^;]+);`); | ||
const cookie = cookies.find( | ||
(cookieString: { match: (arg0: RegExp) => null }) => cookieString.match(regexp) !== null | ||
); | ||
if (!cookie) { | ||
throw new Error(`Cookie ${cookieName} not found`); | ||
} | ||
if (!cookie) { | ||
throw new Error(`Cookie ${cookieName} not found`); | ||
} | ||
return cookie.match(regexp)[1]; | ||
return cookie.match(regexp)[1]; | ||
}; | ||
export const errorHandle = async ({ error, args }: ErrorHandle) => { | ||
let errorReport: any = { | ||
ErrorReport: { | ||
invalidValues: [], | ||
possibleReasons: [], | ||
}, | ||
}; | ||
let description: string; | ||
let invalidValue: boolean = false; | ||
for (const [key, value] of Object.entries(args)) { | ||
if (value === undefined || value === null || value === '') { | ||
invalidValue = true; | ||
errorReport.ErrorReport.invalidValues.push( | ||
`Value "${key}" is type of "${typeof value}" and has value "${value}". Is the ${key} correctly assigned?` | ||
); | ||
} | ||
} | ||
if (invalidValue) { | ||
errorReport.ErrorReport.possibleReasons.push( | ||
`Some arguments have incorrect values. Please check if the right values are assigned.` | ||
); | ||
} | ||
if (error.response !== undefined) { | ||
switch (error.response.status) { | ||
case 400: { | ||
description = 'The server cannot or will not process the request due to an apparent client error.'; | ||
errorReport.ErrorReport.possibleReasons.push( | ||
'Request syntax error, please check, if all mandatory values are correctly assigned.' | ||
); | ||
break; | ||
} | ||
case 401: { | ||
description = 'Authentication is required and has failed or has not yet been provided.'; | ||
errorReport.ErrorReport.possibleReasons.push( | ||
'Wrong credentials used, are correct credentials assigned?' | ||
); | ||
break; | ||
} | ||
case 402: { | ||
description = 'Payment required or daily limiy of requests is exceeded.'; | ||
break; | ||
} | ||
case 403: { | ||
description = 'Access is forbidden for this request.'; | ||
errorReport.ErrorReport.possibleReasons.push( | ||
'User has not permission to use this action or the action is prohibited.' | ||
); | ||
break; | ||
} | ||
case 404: { | ||
description = 'The requested resource could not be found but may be available in the future.'; | ||
errorReport.ErrorReport.possibleReasons.push('Record does not exist.'); | ||
break; | ||
} | ||
case 405: { | ||
description = 'A request method is not supported for the requested resource.'; | ||
break; | ||
} | ||
case 408: { | ||
description = 'The server timed out waiting for the request.'; | ||
break; | ||
} | ||
case 409: { | ||
description = | ||
'Request could not be processed because of conflict in the current state of the resource.'; | ||
break; | ||
} | ||
case 500: { | ||
description = 'Unexpected condition was encountered and no more specific message is suitable.'; | ||
break; | ||
} | ||
case 501: { | ||
description = | ||
'The server either does not recognize the request method, or it lacks the ability to fulfil the request.'; | ||
break; | ||
} | ||
case 502: { | ||
description = | ||
'The request was not completed. The server received an invalid response from the upstream server.'; | ||
break; | ||
} | ||
case 503: { | ||
description = 'The server cannot handle the request (overloaded or down for maintenance).'; | ||
break; | ||
} | ||
case 504: { | ||
description = 'The gateway has timed out.'; | ||
break; | ||
} | ||
default: { | ||
description = 'No further description for this state of the request'; | ||
break; | ||
} | ||
} | ||
errorReport.ErrorReport.status = `The request failed with status: ${error.response.status} - ${error.response.statusText} - ${description}`; | ||
errorReport.ErrorReport.message = `The request send message: ${error.response.data}`; | ||
} else { | ||
console.log(error.stack); | ||
errorReport.ErrorReport.possibleReasons.push('Undefined error. Error has been printed.'); | ||
} | ||
console.log(errorReport); | ||
throw new Error('Request failed. Please review the ErrorReport above.'); | ||
}; |
@@ -14,2 +14,3 @@ { | ||
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */ | ||
"strictNullChecks": false | ||
}, | ||
@@ -16,0 +17,0 @@ "include": ["src/**/*"], |
279575
23
6354