microapps-automation-helper
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -0,1 +1,2 @@ | ||
import type { AddApp, AddSecrets, CreateEntity, DeleteIntegration, ExportIntegration, FinalizeConfig, GetAppInfo, GetApps, GetBundleCatalogue, GetCitrixCloudTokens, GetDomain, GetEntities, GetIntegration, GetIntegrationLog, GetIntegrations, GetNotifications, GetProcessStatus, GetSubscribers, GetUsers, IntegrationLogout, IntegrityCheck, RunNotificationEvent, StartSynchronization, UpdateBundleCatalogue, UpdateintegrationConfiguration, UpdateSubscribers, ValidateConfiguration } from './types/api'; | ||
/** Class representing a Citrix Cloud. */ | ||
@@ -234,152 +235,1 @@ export declare class API { | ||
} | ||
export declare type AddApp = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
data: string; | ||
}; | ||
export declare type GetBundleCatalogue = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
}; | ||
export declare type GetIntegration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
}; | ||
export declare type GetIntegrations = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
}; | ||
export declare type GetProcessStatus = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
processId: string; | ||
}; | ||
export declare type IntegrationLogout = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
}; | ||
export declare type UpdateBundleCatalogue = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
catalogueId: string; | ||
}; | ||
export declare type UpdateintegrationConfiguration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
integrationConfiguration: any; | ||
}; | ||
export declare type ValidateConfiguration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
serviceKey: string; | ||
configuration: string; | ||
}; | ||
export declare type GetEntities = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
}; | ||
export declare type CreateEntity = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
entityData: any; | ||
}; | ||
export declare type FinalizeConfig = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
}; | ||
export declare type GetApps = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
}; | ||
export declare type GetNotifications = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
appId: string; | ||
}; | ||
export declare type RunNotificationEvent = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
notificationId: string; | ||
}; | ||
export declare type StartSynchronization = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
synchronizationType: string; | ||
}; | ||
export declare type IntegrityCheck = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
}; | ||
export declare type DeleteIntegration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
}; | ||
export declare type GetDomain = { | ||
authInstance: any; | ||
cwaAPI: string; | ||
citrixCloudCustomerId: string; | ||
workspaceIdentityProvider: string; | ||
}; | ||
export declare type GetUsers = { | ||
authInstance: any; | ||
cwaAPI: string; | ||
domainName: string; | ||
forestName: string; | ||
appId: string; | ||
query: string; | ||
citrixCloudCustomerId: string; | ||
idpType: any; | ||
}; | ||
export declare type UpdateSubscribers = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
assign: string; | ||
userDetail: any; | ||
appId: string; | ||
domainName: string; | ||
forestName: string; | ||
workspaceIdentityProvider: string; | ||
}; | ||
export declare type GetSubscribers = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
appId: string; | ||
}; | ||
export declare type ExportIntegration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
filePath: any; | ||
params: any; | ||
}; | ||
export declare type GetIntegrationLog = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
integrationType: string; | ||
}; | ||
export declare type GetCitrixCloudTokens = { | ||
cwaAPI: string; | ||
citrixCloudCustomerId: string; | ||
citrixCloudClientId: string; | ||
citrixCloudClientSecret: string; | ||
}; | ||
export declare type AddSecrets = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
data: any; | ||
}; | ||
export declare type GetAppInfo = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
appId: string; | ||
}; |
import { API } from './api'; | ||
import type { GetAuthenticatorCode, GetCCBearerToken, CreateAuthInstance } from './types/citrixCloud'; | ||
/** Class representing a Citrix Cloud. */ | ||
@@ -25,13 +26,1 @@ export declare class CitrixCloud extends API { | ||
} | ||
export declare type GetAuthenticatorCode = { | ||
secretKey: string; | ||
}; | ||
export declare type GetCCBearerToken = { | ||
cwaAPI: string; | ||
citrixCloudCustomerId: string; | ||
citrixCloudClientId: string; | ||
citrixCloudClientSecret: string; | ||
}; | ||
export declare type CreateAuthInstance = { | ||
bearerToken: string; | ||
}; |
@@ -1,11 +0,4 @@ | ||
import { AxiosError } from 'axios'; | ||
export declare type GetCookie = { | ||
cookies: any; | ||
cookieName: string; | ||
}; | ||
export declare type ErrorHandle = { | ||
error: AxiosError; | ||
args: Object; | ||
}; | ||
import type { GetCookie, ErrorHandle, ParamsCheck } from './types/helpers'; | ||
export declare const getCookie: ({ cookies, cookieName }: GetCookie) => string; | ||
export declare const errorHandle: ({ error, args }: ErrorHandle) => Promise<never>; | ||
export declare const paramsCheck: ({ params, functionType, source }: ParamsCheck) => Promise<string>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.errorHandle = exports.getCookie = void 0; | ||
exports.paramsCheck = exports.errorHandle = exports.getCookie = void 0; | ||
exports.getCookie = ({ cookies, cookieName }) => { | ||
@@ -97,3 +97,3 @@ const regexp = new RegExp(`^${cookieName}=([^;]+);`); | ||
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}`; | ||
errorReport.ErrorReport.message = `The request send message: ${error.response.data.message}`; | ||
} | ||
@@ -107,1 +107,25 @@ else { | ||
}; | ||
exports.paramsCheck = async ({ params, functionType, source }) => { | ||
let invalidValues = { InvalidValues: [] }; | ||
let invalidKey; | ||
for (const [key, value] of Object.entries(params)) { | ||
if (value === undefined || value === null || value === '') { | ||
invalidKey = key; | ||
invalidValues.InvalidValues.push(`Value "${key}" is type of "${typeof value}" and has value "${value}".`); | ||
} | ||
} | ||
if (invalidValues.InvalidValues.length > 0) { | ||
console.log(invalidValues); | ||
switch (functionType) { | ||
case 'find': { | ||
return `Failed to find '${invalidKey}' in '${source}' list`; | ||
} | ||
case 'filter': { | ||
return `Failed to filter '${invalidKey}' in '${source}' list`; | ||
} | ||
default: { | ||
return `Failed to get property '${invalidKey}' in '${source}'`; | ||
} | ||
} | ||
} | ||
}; |
@@ -1,3 +0,4 @@ | ||
import { Page } from "playwright"; | ||
import { API } from "./api"; | ||
import { API } from './api'; | ||
import { AxiosResponse } from 'axios'; | ||
import type { AddSubscriber, AddSubscribers, CheckAppMissconfigurations, CreateHTTPIntegration, CreateJavaIntegration, ExportApp, ExportIntegrationUI, ExportMicroAppUI, GetComponentId, GetIntegrationId, GetIntegrationType, GetLastSyncTime, GetMicroAppId, GetNotificationId, GetStatusIntegration, ImportIntegration, ImportIntegrationUI, ImportMicroAppUI, MicroappsAdminLogin, OauthLogout, RenameIntegration, RunEvent, RunSynchronization, WaitForProcessStatus, WaitForSync } from './types/microappsAdmin'; | ||
/** Class representing a Microapps Admin. */ | ||
@@ -12,3 +13,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 +21,3 @@ * Get Integration Id | ||
*/ | ||
getIntegrationId({ authInstance, microappsAdminUrl, integrationName, }: GetIntegrationId): Promise<any>; | ||
getIntegrationId({ authInstance, microappsAdminUrl, integrationName }: GetIntegrationId): Promise<any>; | ||
/** | ||
@@ -29,3 +30,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>; | ||
/** | ||
@@ -36,3 +37,3 @@ * Wait for syncronization and check the result of sync | ||
*/ | ||
waitForSync({ getIntegration, synchronizationType }: WaitForSync): Promise<void>; | ||
waitForSync({ getIntegration, synchronizationType, integrationName }: WaitForSync): Promise<any>; | ||
/** | ||
@@ -61,3 +62,3 @@ * Run syncronization for specific Integration | ||
*/ | ||
waitForProcessStatus({ authInstance, status, microappsAdminUrl, processId, }: WaitForProcessStatus): Promise<any>; | ||
waitForProcessStatus({ authInstance, status, microappsAdminUrl, processId }: WaitForProcessStatus): Promise<any>; | ||
/** | ||
@@ -77,3 +78,3 @@ * Create Java Integration | ||
*/ | ||
getIntegrationType({ authInstance, microappsAdminUrl, integrationName, }: GetIntegrationType): Promise<any>; | ||
getIntegrationType({ authInstance, microappsAdminUrl, integrationName }: GetIntegrationType): Promise<any>; | ||
/** | ||
@@ -85,3 +86,3 @@ * Get status of Integration | ||
*/ | ||
getStatusIntegration({ authInstance, microappsAdminUrl, integrationName, }: GetStatusIntegration): Promise<any>; | ||
getStatusIntegration({ authInstance, microappsAdminUrl, integrationName }: GetStatusIntegration): Promise<any>; | ||
/** | ||
@@ -93,3 +94,3 @@ * Import integration | ||
*/ | ||
importIntegration({ authInstance, microappsAdminUrl, pathToFile, }: ImportIntegration): Promise<any>; | ||
importIntegration({ authInstance, microappsAdminUrl, pathToFile }: ImportIntegration): Promise<AxiosResponse<any>>; | ||
/** | ||
@@ -111,3 +112,3 @@ * Rename integration | ||
*/ | ||
exportApp({ authInstance, microappsAdminUrl, appId, pathToFile, }: ExportApp): Promise<void>; | ||
exportApp({ authInstance, microappsAdminUrl, appId, pathToFile }: ExportApp): Promise<void>; | ||
/** | ||
@@ -120,3 +121,3 @@ * Get Id of Microapp | ||
*/ | ||
getMicroAppId({ authInstance, microappsAdminUrl, integrationId, appName, }: GetMicroAppId): Promise<any>; | ||
getMicroAppId({ authInstance, microappsAdminUrl, integrationId, appName }: GetMicroAppId): Promise<any>; | ||
/** | ||
@@ -129,3 +130,3 @@ * Get Id of Notification | ||
*/ | ||
getNotificationId({ authInstance, microappsAdminUrl, appId, notificationName, }: GetNotificationId): Promise<any>; | ||
getNotificationId({ authInstance, microappsAdminUrl, appId, notificationName }: GetNotificationId): Promise<any>; | ||
/** | ||
@@ -139,6 +140,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; | ||
@@ -152,3 +153,3 @@ }[]>; | ||
*/ | ||
importIntegrationUI({ page, microappsAdminUrl, filePath, }: ImportIntegrationUI): Promise<void>; | ||
importIntegrationUI({ page, microappsAdminUrl, filePath }: ImportIntegrationUI): Promise<void>; | ||
/** | ||
@@ -162,3 +163,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>; | ||
/** | ||
@@ -178,3 +179,3 @@ * Exports @param integrationName integation | ||
*/ | ||
exportMicroAppsUI({ page, integrationName, appName, }: ExportMicroAppUI): Promise<void>; | ||
exportMicroAppsUI({ page, integrationName, appName }: ExportMicroAppUI): Promise<void>; | ||
/** | ||
@@ -187,3 +188,3 @@ * Returns last duration of Synchronization | ||
*/ | ||
getLastTimeSync({ authInstance, microappsAdminUrl, integrationName, }: GetLastSyncTime): Promise<any>; | ||
getLastTimeSync({ authInstance, microappsAdminUrl, integrationName }: GetLastSyncTime): Promise<any>; | ||
/** | ||
@@ -200,157 +201,1 @@ * Returns Id of component | ||
} | ||
export declare type MicroappsAdminLogin = { | ||
page: Page; | ||
url: string; | ||
username: string; | ||
password: string; | ||
mfa: any | boolean; | ||
secretKey: string; | ||
}; | ||
export declare type GetIntegrationId = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
}; | ||
export declare type OauthLogout = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
repeatCount?: number; | ||
}; | ||
export declare type WaitForSync = { | ||
getIntegration: () => any; | ||
synchronizationType: string; | ||
}; | ||
export declare type RunSynchronization = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
synchronizationType: string; | ||
}; | ||
export declare type CreateHTTPIntegration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
integrationConfiguration: any; | ||
}; | ||
export declare type WaitForProcessStatus = { | ||
authInstance: any; | ||
getProcessStatus: () => any; | ||
status: string; | ||
microappsAdminUrl: string; | ||
processId: string; | ||
}; | ||
export declare type CreateJavaIntegration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
data: string; | ||
integrationConfiguration: any; | ||
withEntities: boolean; | ||
serviceType: any; | ||
serviceKey: string; | ||
name: string; | ||
}; | ||
export declare type GetIntegrationType = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
}; | ||
export declare type GetStatusIntegration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
}; | ||
export declare type ImportIntegration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
pathToFile: string; | ||
}; | ||
export declare type RenameIntegration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
newIntegrationName: string; | ||
integrationConfiguration: string; | ||
}; | ||
export declare type ExportApp = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
appId: string; | ||
pathToFile: string; | ||
}; | ||
export declare type GetMicroAppId = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
appName: string; | ||
}; | ||
export declare type GetNotificationId = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
appId: string; | ||
notificationName: string; | ||
}; | ||
export declare type RunEvent = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
appName: string; | ||
notificationName: string; | ||
}; | ||
export declare type CheckAppMissconfigurations = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
appId: string; | ||
}; | ||
export declare type ImportIntegrationUI = { | ||
page: Page; | ||
microappsAdminUrl: string; | ||
filePath: string; | ||
}; | ||
export declare type ImportMicroAppUI = { | ||
page: Page; | ||
microappsAdminUrl: string; | ||
filePath: string; | ||
integrationName: string; | ||
}; | ||
export declare type AddSubscriber = { | ||
authInstance: any; | ||
appId: string; | ||
user: string; | ||
config: any; | ||
}; | ||
export declare type AddSubscribers = { | ||
authInstance: any; | ||
integrationName: string; | ||
microappsAdminUrl: string; | ||
microapps?: any; | ||
config: any; | ||
}; | ||
export declare type Subscribe = { | ||
authInstance: any; | ||
microapps: any; | ||
microapp: string; | ||
integrationId: string; | ||
}; | ||
export declare type ExportIntegrationUI = { | ||
page: Page; | ||
integrationName: string; | ||
}; | ||
export declare type ExportMicroAppUI = { | ||
page: Page; | ||
appName: string; | ||
integrationName: string; | ||
}; | ||
export declare type GetLastSyncTime = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
}; | ||
export declare type GetComponentId = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
appName: string; | ||
pageName: string; | ||
componentLabel: string; | ||
}; |
@@ -13,2 +13,3 @@ "use strict"; | ||
const api_1 = require("./api"); | ||
const helpers_1 = require("./helpers"); | ||
const citrixCloud = new citrixCloud_1.CitrixCloud(); | ||
@@ -26,13 +27,13 @@ /** Class representing a Microapps Admin. */ | ||
*/ | ||
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++) { | ||
@@ -61,9 +62,18 @@ await page.type(`input[inputmode][name="${i}"]`, authCode[i]); | ||
*/ | ||
async getIntegrationId({ authInstance, microappsAdminUrl, integrationName, }) { | ||
const integrations = await this.getIntegrations({ | ||
authInstance, | ||
microappsAdminUrl, | ||
}); | ||
const integration = integrations.data.find((e) => e.title === integrationName); | ||
return integration.id; | ||
async getIntegrationId({ authInstance, microappsAdminUrl, integrationName }) { | ||
let integrationId; | ||
let integration; | ||
const integrations = await this.getIntegrations({ authInstance, microappsAdminUrl }); | ||
try { | ||
integration = integrations.data.find((e) => e.title === integrationName); | ||
integrationId = integration.id; | ||
} | ||
catch (error) { | ||
throw new Error(await helpers_1.paramsCheck({ | ||
params: { integration, integrationId, integrations }, | ||
functionType: 'find', | ||
source: 'integrations', | ||
})); | ||
} | ||
return integrationId; | ||
} | ||
@@ -77,3 +87,3 @@ /** | ||
*/ | ||
async oauthLogout({ authInstance, microappsAdminUrl, integrationName, repeatCount = 1, }) { | ||
async oauthLogout({ authInstance, microappsAdminUrl, integrationName, repeatCount = 1 }) { | ||
const integrationId = await this.getIntegrationId({ | ||
@@ -97,26 +107,40 @@ authInstance, | ||
*/ | ||
async waitForSync({ getIntegration, synchronizationType }) { | ||
let lastRunSuccess; | ||
let cancelled; | ||
let running; | ||
for (;;) { | ||
async waitForSync({ getIntegration, synchronizationType, integrationName = '' }) { | ||
let jobRun; | ||
for (let i = 0;; i++) { | ||
if (i % 6 === 0) { | ||
console.log(`${integrationName && `[${integrationName}] - `}Waiting for synchronization to finish`); | ||
} | ||
const integration = await getIntegration(); | ||
const jobRuns = integration.data.jobRuns; | ||
const getJobRunDetail = jobRuns.find((job) => { | ||
return job.synchronizationTypeId === synchronizationType; | ||
}); | ||
running = getJobRunDetail.running; | ||
cancelled = getJobRunDetail.cancelled; | ||
lastRunSuccess = getJobRunDetail.lastRunSuccess; | ||
if ((await running) === false) { | ||
break; | ||
if (integration.data.jobRuns.length > 0) { | ||
const jobRuns = integration.data.jobRuns; | ||
try { | ||
[jobRun] = jobRuns.filter((job) => job.synchronizationTypeId === synchronizationType); | ||
} | ||
catch (error) { | ||
throw new Error(await helpers_1.paramsCheck({ | ||
params: { jobRun, jobRuns }, | ||
functionType: 'filter', | ||
source: 'jobRuns', | ||
})); | ||
} | ||
if (jobRun.running === false) { | ||
break; | ||
} | ||
await new Promise((resolve) => setTimeout(resolve, 5000)); | ||
} | ||
await new Promise((resolve) => setTimeout(resolve, 5000)); | ||
else { | ||
throw new Error(`No jobRuns found.`); | ||
} | ||
} | ||
if ((await lastRunSuccess) === false) { | ||
throw new Error(`Sync failed!`); | ||
if (jobRun.lastRunSuccess === false || jobRun.lastRunException) { | ||
if (jobRun.lastRunException) { | ||
throw new Error(`Sync failed with: ${jobRun.lastRunException}`); | ||
} | ||
throw new Error(`Sync failed without Exception!`); | ||
} | ||
else if (cancelled === true) { | ||
else if (jobRun.cancelled === true) { | ||
throw new Error(`Sync was cancelled!`); | ||
} | ||
return jobRun; | ||
} | ||
@@ -142,22 +166,16 @@ /** | ||
const jobRuns = integration.data.jobRuns; | ||
const getJobRunDetail = jobRuns.find((job) => { | ||
return job.synchronizationTypeId === synchronizationType; | ||
}); | ||
if (getJobRunDetail === undefined) { | ||
await this.startSynchronization({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
synchronizationType, | ||
let getJobRunDetail; | ||
try { | ||
getJobRunDetail = jobRuns.find((job) => { | ||
return job.synchronizationTypeId === synchronizationType; | ||
}); | ||
await this.waitForSync({ | ||
getIntegration: () => this.getIntegration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
}), | ||
synchronizationType, | ||
}); | ||
} | ||
else if (getJobRunDetail.running === true) { | ||
catch (error) { | ||
throw new Error(await helpers_1.paramsCheck({ | ||
params: { integration, jobRuns, getJobRunDetail }, | ||
functionType: 'find', | ||
source: 'jobRuns', | ||
})); | ||
} | ||
if (getJobRunDetail.running === true) { | ||
await this.waitForSync({ | ||
@@ -202,4 +220,15 @@ getIntegration: () => this.getIntegration({ | ||
const bundleCatalogueData = bundleCatalogue.data; | ||
const catalogueDetail = bundleCatalogueData.find((e) => e.title === integrationName && e.type === "HTTP"); | ||
const catalogueId = catalogueDetail.uniqueId; | ||
let catalogueDetail; | ||
let catalogueId; | ||
try { | ||
catalogueDetail = bundleCatalogueData.find((e) => e.title === integrationName && e.type === 'HTTP'); | ||
catalogueId = catalogueDetail.uniqueId; | ||
} | ||
catch (error) { | ||
throw new Error(await helpers_1.paramsCheck({ | ||
params: { catalogueDetail, catalogueId, bundleCatalogueData }, | ||
functionType: 'find', | ||
source: 'bundleCatalogueData', | ||
})); | ||
} | ||
const createdConnector = await this.updateBundleCatalogue({ | ||
@@ -226,3 +255,3 @@ authInstance, | ||
*/ | ||
async waitForProcessStatus({ authInstance, status, microappsAdminUrl, processId, }) { | ||
async waitForProcessStatus({ authInstance, status, microappsAdminUrl, processId }) { | ||
let processStatus; | ||
@@ -255,6 +284,14 @@ for (let i = 0; i < 35; i++) { | ||
*/ | ||
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; | ||
let configurationParameters; | ||
try { | ||
configurationParameters = integrationConfiguration.serviceData.configuration.configurationParameters; | ||
} | ||
catch (error) { | ||
throw new Error(await helpers_1.paramsCheck({ | ||
params: { configurationParameters, integrationConfiguration }, | ||
source: 'integrationConfiguration', | ||
})); | ||
} | ||
const responseValidation = await this.validateConfiguration({ | ||
@@ -267,4 +304,4 @@ 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!'); | ||
} | ||
@@ -280,3 +317,3 @@ const app = await this.addApp({ | ||
getProcessStatus: () => this.getProcessStatus({ authInstance, microappsAdminUrl, processId }), | ||
status: "DONE", | ||
status: 'DONE', | ||
microappsAdminUrl, | ||
@@ -289,3 +326,3 @@ processId, | ||
// Some connectors have different flow for getting entities | ||
if (serviceType === "Service Now" || serviceType === "Salesforce") { | ||
if (serviceType === 'Service Now' || serviceType === 'Salesforce') { | ||
const services = await this.getIntegration({ | ||
@@ -309,3 +346,3 @@ authInstance, | ||
getProcessStatus: () => this.getProcessStatus({ authInstance, microappsAdminUrl, processId }), | ||
status: "DONE", | ||
status: 'DONE', | ||
microappsAdminUrl, | ||
@@ -340,3 +377,3 @@ processId, | ||
getProcessStatus: () => this.getProcessStatus({ authInstance, microappsAdminUrl, processId }), | ||
status: "DONE", | ||
status: 'DONE', | ||
microappsAdminUrl, | ||
@@ -358,3 +395,3 @@ processId, | ||
*/ | ||
async getIntegrationType({ authInstance, microappsAdminUrl, integrationName, }) { | ||
async getIntegrationType({ authInstance, microappsAdminUrl, integrationName }) { | ||
const integrations = await this.getIntegrations({ | ||
@@ -365,6 +402,17 @@ authInstance, | ||
const integrationsData = integrations.data; | ||
const findIntegrationType = integrationsData.find((integration) => { | ||
return integration.title === integrationName; | ||
}); | ||
const integrationType = findIntegrationType.serviceType; | ||
let findIntegrationType; | ||
let integrationType; | ||
try { | ||
findIntegrationType = integrationsData.find((integration) => { | ||
return integration.title === integrationName; | ||
}); | ||
integrationType = findIntegrationType.serviceType; | ||
} | ||
catch (error) { | ||
throw new Error(await helpers_1.paramsCheck({ | ||
params: { findIntegrationType, integrationType, integrationsData }, | ||
functionType: 'find', | ||
source: 'integrationsData', | ||
})); | ||
} | ||
return integrationType; | ||
@@ -378,3 +426,3 @@ } | ||
*/ | ||
async getStatusIntegration({ authInstance, microappsAdminUrl, integrationName, }) { | ||
async getStatusIntegration({ authInstance, microappsAdminUrl, integrationName }) { | ||
try { | ||
@@ -398,12 +446,12 @@ const serviceId = await this.getIntegrationId({ | ||
*/ | ||
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}`, | ||
}, | ||
@@ -428,11 +476,2 @@ data: form, | ||
async renameIntegration({ authInstance, microappsAdminUrl, integrationName, newIntegrationName, integrationConfiguration, }) { | ||
const integrationType = await this.getIntegrationType({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
}); | ||
const data = { | ||
serviceType: integrationType, | ||
title: newIntegrationName, | ||
}; | ||
const integrationId = await this.getStatusIntegration({ | ||
@@ -454,6 +493,16 @@ authInstance, | ||
const integrationsData = integrations.data; | ||
const IntegrationDetail = integrationsData.filter((e) => { | ||
return e.title === integrationName && e.id === newIntegrationName; | ||
}); | ||
console.log(`Integration ${integrationName} with id: ${IntegrationDetail[0].id} was renamed to: ${integrationsData[0].title}`); | ||
let integrationDetail; | ||
try { | ||
integrationDetail = integrationsData.filter((e) => { | ||
return e.title === integrationName && e.id === newIntegrationName; | ||
}); | ||
} | ||
catch (error) { | ||
throw new Error(await helpers_1.paramsCheck({ | ||
params: { integrationDetail, integrationsData }, | ||
functionType: 'filter', | ||
source: 'integrationsData', | ||
})); | ||
} | ||
console.log(`Integration ${integrationName} with id: ${integrationDetail[0].id} was renamed to: ${integrationsData[0].title}`); | ||
} | ||
@@ -467,9 +516,9 @@ /** | ||
*/ | ||
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', | ||
}); | ||
@@ -489,3 +538,3 @@ } | ||
*/ | ||
async getMicroAppId({ authInstance, microappsAdminUrl, integrationId, appName, }) { | ||
async getMicroAppId({ authInstance, microappsAdminUrl, integrationId, appName }) { | ||
let apps; | ||
@@ -510,3 +559,3 @@ try { | ||
*/ | ||
async getNotificationId({ authInstance, microappsAdminUrl, appId, notificationName, }) { | ||
async getNotificationId({ authInstance, microappsAdminUrl, appId, notificationName }) { | ||
const notifications = await this.getNotifications({ | ||
@@ -518,6 +567,17 @@ authInstance, | ||
const notificationsData = notifications.data; | ||
const getNotificationId = notificationsData.find((e) => { | ||
return e.label === notificationName; | ||
}); | ||
const notificationId = getNotificationId.id; | ||
let getNotificationId; | ||
let notificationId; | ||
try { | ||
getNotificationId = notificationsData.find((e) => { | ||
return e.label === notificationName; | ||
}); | ||
notificationId = getNotificationId.id; | ||
} | ||
catch (error) { | ||
throw new Error(await helpers_1.paramsCheck({ | ||
params: { getNotificationId, notificationId, notificationsData }, | ||
functionType: 'find', | ||
source: 'notificationsData', | ||
})); | ||
} | ||
return notificationId; | ||
@@ -533,3 +593,3 @@ } | ||
*/ | ||
async runEvent({ authInstance, microappsAdminUrl, integrationName, appName, notificationName, }) { | ||
async runEvent({ authInstance, microappsAdminUrl, integrationName, appName, notificationName }) { | ||
let notifications; | ||
@@ -571,7 +631,7 @@ const integrationId = await this.getIntegrationId({ | ||
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, }) { | ||
async checkAppMissconfigurations({ authInstance, microappsAdminUrl, appId }) { | ||
const response = await this.integrityCheck({ | ||
@@ -582,11 +642,21 @@ authInstance, | ||
const responseBody = response.data; | ||
const missconfigurations = responseBody.filter((e) => e.appId === appId); | ||
let missconfigurations; | ||
try { | ||
missconfigurations = responseBody.filter((e) => e.appId === appId); | ||
} | ||
catch (error) { | ||
throw new Error(await helpers_1.paramsCheck({ | ||
params: { missconfigurations, responseBody }, | ||
functionType: 'filter', | ||
source: 'responseBody', | ||
})); | ||
} | ||
if (!Array.isArray(missconfigurations) || !missconfigurations.length) { | ||
console.log(`appId: ${appId} has no missconfigurations`); | ||
} | ||
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 | ||
@@ -599,3 +669,3 @@ const domains = await this.getDomain({ | ||
}); | ||
const actionSubscribe = "Add"; | ||
const actionSubscribe = 'Add'; | ||
let domainName; | ||
@@ -605,21 +675,31 @@ 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"; | ||
}); | ||
domainName = "todo"; | ||
forestName = domainDetail[0].idpProperties.tid; | ||
idpType = "AZUREAD"; | ||
let domainDetail; | ||
try { | ||
const domainDetail = domainsData.filter((domain) => { | ||
return domain.idpType === 'AzureAd'; | ||
}); | ||
domainName = 'todo'; | ||
forestName = domainDetail[0].idpProperties.tid; | ||
idpType = 'AZUREAD'; | ||
} | ||
catch (error) { | ||
throw new Error(await helpers_1.paramsCheck({ | ||
params: { domainDetail, domainsData }, | ||
functionType: 'filter', | ||
source: 'domainsData', | ||
})); | ||
} | ||
break; | ||
case "okta": | ||
case 'okta': | ||
domainName = null; | ||
forestName = null; | ||
idpType = "OKTA"; | ||
idpType = 'OKTA'; | ||
break; | ||
@@ -645,5 +725,14 @@ default: | ||
const userData = users.data.results; | ||
userDetail = userData.filter((e) => { | ||
return e.accountName === user; | ||
}); | ||
try { | ||
userDetail = userData.filter((e) => { | ||
return e.accountName === user; | ||
}); | ||
} | ||
catch (error) { | ||
throw new Error(await helpers_1.paramsCheck({ | ||
params: { userDetail, userData }, | ||
functionType: 'filter', | ||
source: 'userData', | ||
})); | ||
} | ||
} | ||
@@ -667,3 +756,3 @@ // Update Subscribers | ||
} | ||
async addSubscribers({ authInstance, integrationName, microapps, microappsAdminUrl, config, }) { | ||
async addSubscribers({ authInstance, integrationName, microapps, microappsAdminUrl, config }) { | ||
const integrationId = await this.getIntegrationId({ | ||
@@ -674,3 +763,3 @@ authInstance, | ||
}); | ||
const subscribe = async ({ microapps, microapp, authInstance, integrationId, }) => { | ||
const subscribe = async ({ microapps, microapp, authInstance, integrationId }) => { | ||
console.log(`[${integrationName}] - Adding subscribers for: ${microapp}`); | ||
@@ -706,3 +795,3 @@ const subscribers = microapps[microapp].subscribers; | ||
*/ | ||
async importIntegrationUI({ page, microappsAdminUrl, filePath, }) { | ||
async importIntegrationUI({ page, microappsAdminUrl, filePath }) { | ||
await page.waitForSelector('[data-testid="add-integration-button"]'); | ||
@@ -712,8 +801,7 @@ 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); | ||
} | ||
@@ -728,3 +816,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"]`); | ||
@@ -734,8 +822,7 @@ 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); | ||
} | ||
@@ -755,5 +842,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'); | ||
} | ||
@@ -768,3 +855,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")]`); | ||
@@ -774,5 +861,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'); | ||
} | ||
@@ -787,3 +874,3 @@ } | ||
*/ | ||
async getLastTimeSync({ authInstance, microappsAdminUrl, integrationName, }) { | ||
async getLastTimeSync({ authInstance, microappsAdminUrl, integrationName }) { | ||
const regex = new RegExp(/\d*:\d*:\d*.\d*/); | ||
@@ -807,3 +894,3 @@ const integrationId = await this.getIntegrationId({ | ||
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]; | ||
@@ -840,6 +927,28 @@ } | ||
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; | ||
let getPage; | ||
let components; | ||
try { | ||
getPage = pagesData.filter((app) => app.title === pageName); | ||
components = getPage[0].components; | ||
} | ||
catch (error) { | ||
throw new Error(await helpers_1.paramsCheck({ | ||
params: { getPage, components, pagesData }, | ||
functionType: 'filter', | ||
source: 'pagesData', | ||
})); | ||
} | ||
let getComponent; | ||
let componentId; | ||
try { | ||
getComponent = components.filter((component) => component.label === componentLabel); | ||
componentId = getComponent[0].id; | ||
} | ||
catch (error) { | ||
throw new Error(await helpers_1.paramsCheck({ | ||
params: { getComponent, componentId, components }, | ||
functionType: 'filter', | ||
source: 'components', | ||
})); | ||
} | ||
return componentId; | ||
@@ -846,0 +955,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { Page, BrowserContext } from "playwright"; | ||
import type { Login, CreateDsAuthInstance, GoToActions, StartAction, SkipTour, GetDsauthTokens, GetFeedCardButton, GetFeedNotifications, GetOneTimeToken, GetTokens, GetUserData, WaitForFeedCardId, WaitForPopUp } from './types/workspace'; | ||
/** Class representing a Workspace. */ | ||
@@ -13,3 +13,3 @@ export declare class Workspace { | ||
*/ | ||
login({ page, workspaceUrl, workspaceUsername, workspacePassword, workspaceIdentityProvider, }: Login): Promise<void>; | ||
login({ page, workspaceUrl, workspaceUsername, workspacePassword, workspaceIdentityProvider }: Login): Promise<void>; | ||
/** | ||
@@ -70,79 +70,4 @@ * Skip Tour | ||
}>; | ||
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>; | ||
} | ||
export declare type Login = { | ||
page: Page; | ||
workspaceUrl: string; | ||
workspaceUsername: string; | ||
workspacePassword: string; | ||
workspaceIdentityProvider: string; | ||
}; | ||
export declare type SkipTour = { | ||
page: Page; | ||
}; | ||
export declare type GoToActions = { | ||
page: Page; | ||
}; | ||
export declare type StartAction = { | ||
page: Page; | ||
actionName: string; | ||
integrationName: string; | ||
}; | ||
export declare type GetFeedNotifications = { | ||
page: Page; | ||
}; | ||
export declare type WaitForFeedCardId = { | ||
page: Page; | ||
repeatMax?: number; | ||
waitTime?: number; | ||
recordId: string; | ||
notificationId: string; | ||
}; | ||
export declare type GetFeedCardButton = { | ||
page: Page; | ||
feedCardId: string; | ||
buttonName: string; | ||
}; | ||
export declare type WaitForPopUp = { | ||
page: Page; | ||
text: string; | ||
}; | ||
export declare type GetOneTimeToken = { | ||
workspaceUrl: string; | ||
builderDomain: string; | ||
csrfToken: string; | ||
sessionId: string; | ||
ctxsAuthId: string; | ||
authDomain: string; | ||
}; | ||
export declare type GetTokens = { | ||
builderDomain: string; | ||
authDomain: string; | ||
oneTimeToken: string; | ||
}; | ||
export declare type GetDsauthTokens = { | ||
page: Page; | ||
workspaceUrl: string; | ||
workspaceUsername: string; | ||
workspacePassword: string; | ||
workspaceIdentityProvider: string; | ||
context: BrowserContext; | ||
builderDomain: string; | ||
authDomain: string; | ||
}; | ||
export declare type CreateDsAuthInstance = { | ||
citrixToken: string; | ||
jSessionId: string; | ||
}; | ||
export declare type GetUserData = { | ||
dSauthInstance: any; | ||
microappsAdminUrl: string; | ||
appId: string; | ||
componentId: string; | ||
dataLimit: string; | ||
initiatorType: string; | ||
initiatorData: string; | ||
pageId: string; | ||
authDomain: string; | ||
}; |
@@ -20,22 +20,22 @@ "use strict"; | ||
*/ | ||
async login({ page, workspaceUrl, workspaceUsername, workspacePassword, workspaceIdentityProvider, }) { | ||
console.log("Login to Workspace", new Date()); | ||
await page.goto(workspaceUrl, { waitUntil: "domcontentloaded" }); | ||
async login({ page, workspaceUrl, workspaceUsername, workspacePassword, workspaceIdentityProvider }) { | ||
console.log('Login to Workspace', new Date()); | ||
await page.goto(workspaceUrl, { waitUntil: 'domcontentloaded' }); | ||
switch (workspaceIdentityProvider) { | ||
case "ad": | ||
await page.waitForSelector("#username"); | ||
await page.type("#username", workspaceUsername); | ||
await page.waitForSelector("#password"); | ||
await page.type("#password", workspacePassword); | ||
await page.waitForSelector("#loginBtn"); | ||
await page.click("#loginBtn"); | ||
case 'ad': | ||
await page.waitForSelector('#username'); | ||
await page.type('#username', workspaceUsername); | ||
await page.waitForSelector('#password'); | ||
await page.type('#password', workspacePassword); | ||
await page.waitForSelector('#loginBtn'); | ||
await page.click('#loginBtn'); | ||
break; | ||
case "netscaler": | ||
await page.waitForSelector("#login"); | ||
await page.type("#login", workspaceUsername); | ||
await page.waitForSelector("#passwd"); | ||
await page.type("#passwd", workspacePassword); | ||
await page.click("#nsg-x1-logon-button"); | ||
case 'netscaler': | ||
await page.waitForSelector('#login'); | ||
await page.type('#login', workspaceUsername); | ||
await page.waitForSelector('#passwd'); | ||
await page.type('#passwd', workspacePassword); | ||
await page.click('#nsg-x1-logon-button'); | ||
break; | ||
case "aad": | ||
case 'aad': | ||
await page.waitForSelector('input[name="loginfmt"]'); | ||
@@ -52,14 +52,14 @@ await page.type('input[name="loginfmt"]', workspaceUsername); | ||
break; | ||
case "okta": | ||
await page.waitForSelector("#okta-signin-username"); | ||
await page.type("#okta-signin-username", workspaceUsername); | ||
await page.waitForSelector("#okta-signin-password"); | ||
await page.type("#okta-signin-password", workspacePassword); | ||
await page.waitForSelector("#okta-signin-submit"); | ||
await page.click("#okta-signin-submit"); | ||
case 'okta': | ||
await page.waitForSelector('#okta-signin-username'); | ||
await page.type('#okta-signin-username', workspaceUsername); | ||
await page.waitForSelector('#okta-signin-password'); | ||
await page.type('#okta-signin-password', workspacePassword); | ||
await page.waitForSelector('#okta-signin-submit'); | ||
await page.click('#okta-signin-submit'); | ||
break; | ||
default: | ||
console.log("Identity provider was not specified."); | ||
console.log('Identity provider was not specified.'); | ||
} | ||
await page.waitForSelector("#content", { timeout: 90000 }); | ||
await page.waitForSelector('#content', { timeout: 90000 }); | ||
await this.skipTour({ page }); | ||
@@ -73,6 +73,6 @@ } | ||
try { | ||
await page.waitForSelector(".cta-link a", { timeout: 5000 }); | ||
const link = await page.$(".cta-link a"); | ||
await page.waitForSelector('.cta-link a', { timeout: 5000 }); | ||
const link = await page.$('.cta-link a'); | ||
if (await link) { | ||
await page.click(".cta-link a"); | ||
await page.click('.cta-link a'); | ||
} | ||
@@ -87,5 +87,5 @@ } | ||
async goToActions({ page }) { | ||
await page.waitForSelector("span >> text=Actions"); | ||
await page.click("span >> text=Actions"); | ||
await page.waitForLoadState("networkidle"); | ||
await page.waitForSelector('span >> text=Actions'); | ||
await page.click('span >> text=Actions'); | ||
await page.waitForLoadState('networkidle'); | ||
} | ||
@@ -107,6 +107,5 @@ /** | ||
async getFeedNotifications({ page }) { | ||
await page.waitForSelector("select"); | ||
await page.selectOption("select", "CREATED_AT"); | ||
const notifications = await page.waitForResponse((response) => response.url().match(new RegExp("notification")) && | ||
response.status() === 200); | ||
await page.waitForSelector('select'); | ||
await page.selectOption('select', 'CREATED_AT'); | ||
const notifications = await page.waitForResponse((response) => response.url().match(new RegExp('notification')) && response.status() === 200); | ||
const notificationsBody = await notifications.json(); | ||
@@ -123,7 +122,7 @@ return notificationsBody; | ||
*/ | ||
async waitForFeedCardId({ page, repeatMax = 50, waitTime = 5000, recordId, notificationId = "", }) { | ||
async waitForFeedCardId({ page, repeatMax = 50, waitTime = 5000, recordId, notificationId = '', }) { | ||
let feedCardId; | ||
for (let i = 0; i < repeatMax; i++) { | ||
if (i === repeatMax - 1) { | ||
throw new Error("Have not found expected feedcard id."); | ||
throw new Error('Have not found expected feedcard id.'); | ||
} | ||
@@ -133,4 +132,3 @@ const feedNotification = await this.getFeedNotifications({ page }); | ||
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); | ||
}); | ||
@@ -172,3 +170,3 @@ try { | ||
if (alertPopUp.length !== 0) { | ||
throw new Error("Service action failed"); | ||
throw new Error('Service action failed'); | ||
} | ||
@@ -179,6 +177,6 @@ } | ||
url: `${workspaceUrl}/Citrix/StoreWeb/Sso/Proxy`, | ||
method: "POST", | ||
method: 'POST', | ||
headers: { | ||
"Citrix-WSP-Proxy-URL": `${builderDomain}/app/api/auth/dsauth`, | ||
"Csrf-Token": `${csrfToken}`, | ||
'Citrix-WSP-Proxy-URL': `${builderDomain}/app/api/auth/dsauth`, | ||
'Csrf-Token': `${csrfToken}`, | ||
Cookie: `CsrfToken=${csrfToken}; ASP.NET_SessionId=${sessionId}; CtxsAuthId=${ctxsAuthId}`, | ||
@@ -195,5 +193,5 @@ }, | ||
url: `${builderDomain}/app/api/auth/dsauth`, | ||
method: "GET", | ||
method: 'GET', | ||
headers: { | ||
accept: "application/json", | ||
accept: 'application/json', | ||
}, | ||
@@ -206,6 +204,6 @@ params: { | ||
const citrixToken = response.data.csrf; | ||
const cookies = response.headers["set-cookie"]; | ||
const cookies = response.headers['set-cookie']; | ||
const jSessionId = await helpers_1.getCookie({ | ||
cookies: cookies, | ||
cookieName: "JSESSIONID", | ||
cookieName: 'JSESSIONID', | ||
}); | ||
@@ -223,5 +221,5 @@ return { citrixToken, jSessionId }; | ||
const cookies = await context.cookies(); | ||
const csfrTokenCookie = cookies.find((e) => e.name === "CsrfToken"); | ||
const sessionIdCookie = cookies.find((e) => e.name === "ASP.NET_SessionId"); | ||
const ctxsAuthIdCookie = cookies.find((e) => e.name === "CtxsAuthId"); | ||
const csfrTokenCookie = cookies.find((e) => e.name === 'CsrfToken'); | ||
const sessionIdCookie = cookies.find((e) => e.name === 'ASP.NET_SessionId'); | ||
const ctxsAuthIdCookie = cookies.find((e) => e.name === 'CtxsAuthId'); | ||
const csrfToken = csfrTokenCookie === null || csfrTokenCookie === void 0 ? void 0 : csfrTokenCookie.value; | ||
@@ -245,6 +243,6 @@ const sessionId = sessionIdCookie === null || sessionIdCookie === void 0 ? void 0 : sessionIdCookie.value; | ||
} | ||
async createDsAuthInstance({ citrixToken, jSessionId, }) { | ||
async createDsAuthInstance({ citrixToken, jSessionId }) { | ||
const dSauthInstance = axios_1.default.create({}); | ||
dSauthInstance.defaults.headers.common["citrix-csrf-token"] = `${citrixToken}`; | ||
dSauthInstance.defaults.headers.common["cookie"] = `JSESSIONID=${jSessionId}`; | ||
dSauthInstance.defaults.headers.common['citrix-csrf-token'] = `${citrixToken}`; | ||
dSauthInstance.defaults.headers.common['cookie'] = `JSESSIONID=${jSessionId}`; | ||
dSauthInstance.defaults.timeout = 90000; | ||
@@ -256,7 +254,7 @@ return dSauthInstance; | ||
url: `${microappsAdminUrl}/app/api/app/${appId}/component/${componentId}/data`, | ||
method: "GET", | ||
method: 'GET', | ||
queryParameters: { | ||
offset: 0, | ||
limit: dataLimit, | ||
orderDirection: "ASC", | ||
orderDirection: 'ASC', | ||
initiator_type: initiatorType, | ||
@@ -263,0 +261,0 @@ initiator_id: pageId, |
1031
main.d.ts
@@ -1,234 +0,4 @@ | ||
/** Class representing a Citrix Cloud. */ | ||
export declare 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 | ||
*/ | ||
getCitrixCloudTokens({ cwaAPI, citrixCloudCustomerId, citrixCloudClientId, citrixCloudClientSecret, }: GetCitrixCloudTokens): Promise<import("axios").AxiosResponse<any>>; | ||
/** | ||
* Get all Integrations in Miroapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
*/ | ||
getIntegrations({ authInstance, microappsAdminUrl }: GetIntegrations): Promise<any>; | ||
/** | ||
* Get Bundle Catalogue in Miroapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
*/ | ||
getBundleCatalogue({ authInstance, microappsAdminUrl }: GetBundleCatalogue): Promise<any>; | ||
/** | ||
* Update Bundle Catalogue in Miroapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} catalogueId - Catalogue Id | ||
*/ | ||
updateBundleCatalogue({ authInstance, microappsAdminUrl, catalogueId }: UpdateBundleCatalogue): Promise<any>; | ||
/** | ||
* 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 | ||
*/ | ||
updateintegrationConfiguration({ authInstance, microappsAdminUrl, integrationId, integrationConfiguration, }: UpdateintegrationConfiguration): Promise<any>; | ||
/** | ||
* Get one specific Integration in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} integrationId - Integration Id | ||
*/ | ||
getIntegration({ authInstance, microappsAdminUrl, integrationId }: GetIntegration): Promise<any>; | ||
/** | ||
* Auth logout in Integration in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} integrationId - Integration Id | ||
*/ | ||
integrationLogout({ authInstance, microappsAdminUrl, integrationId }: IntegrationLogout): Promise<any>; | ||
/** | ||
* 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 | ||
*/ | ||
validateConfiguration({ authInstance, microappsAdminUrl, serviceKey, configuration }: ValidateConfiguration): Promise<any>; | ||
/** | ||
* 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 | ||
*/ | ||
addApp({ authInstance, microappsAdminUrl, data }: AddApp): Promise<any>; | ||
/** | ||
* Get status of one specific process | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} processId - Id of the process | ||
*/ | ||
getProcessStatus({ authInstance, microappsAdminUrl, processId }: GetProcessStatus): Promise<any>; | ||
/** | ||
* Get all Entities of Integration in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} integrationId - Integration Id | ||
*/ | ||
getEntities({ authInstance, microappsAdminUrl, integrationId }: GetEntities): Promise<any>; | ||
/** | ||
* 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 | ||
*/ | ||
createEntity({ authInstance, microappsAdminUrl, integrationId, entityData }: CreateEntity): Promise<any>; | ||
/** | ||
* Finalize configuration of Integration in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} integrationId - Integration Id | ||
*/ | ||
finalizeConfig({ authInstance, microappsAdminUrl, integrationId }: FinalizeConfig): Promise<any>; | ||
/** | ||
* Get all MicroApps in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
import { AxiosResponse } from 'axios'; | ||
import { Page, BrowserContext } from 'playwright'; | ||
*/ | ||
getApps({ authInstance, microappsAdminUrl }: GetApps): Promise<any>; | ||
/** | ||
* 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 | ||
*/ | ||
getNotifications({ authInstance, microappsAdminUrl, appId }: GetNotifications): Promise<any>; | ||
/** | ||
* Run Event in MicroApp in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
*/ | ||
runNotificationEvent({ authInstance, microappsAdminUrl, notificationId }: RunNotificationEvent): Promise<any>; | ||
/** | ||
* Start Synchronization of Integration in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} integrationId - Integration Id | ||
*/ | ||
startSynchronization({ authInstance, microappsAdminUrl, integrationId, synchronizationType, }: StartSynchronization): Promise<any>; | ||
/** | ||
* Check integrity of all MicroApps in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
*/ | ||
integrityCheck({ authInstance, microappsAdminUrl }: IntegrityCheck): Promise<any>; | ||
/** | ||
* Delete Integration in Microaaps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} integrationId - Integration Id | ||
*/ | ||
deleteIntegration({ authInstance, microappsAdminUrl, integrationId }: DeleteIntegration): Promise<any>; | ||
/** | ||
* 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 | ||
*/ | ||
getDomain({ authInstance, cwaAPI, citrixCloudCustomerId, workspaceIdentityProvider }: GetDomain): Promise<any>; | ||
/** | ||
* 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 | ||
*/ | ||
getUsers({ authInstance, cwaAPI, domainName, forestName, appId, query, citrixCloudCustomerId, idpType, }: GetUsers): Promise<any>; | ||
/** | ||
* 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 | ||
*/ | ||
updateSubscribers({ authInstance, microappsAdminUrl, assign, userDetail, appId, domainName, forestName, workspaceIdentityProvider, }: UpdateSubscribers): Promise<any>; | ||
/** | ||
* 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 | ||
*/ | ||
getSubscribers({ authInstance, microappsAdminUrl, appId }: GetSubscribers): Promise<any>; | ||
/** | ||
* 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= | ||
*/ | ||
exportIntegration({ authInstance, microappsAdminUrl, integrationId, filePath, params }: ExportIntegration): Promise<void>; | ||
/** | ||
* 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 | ||
*/ | ||
getIntegrationLog({ authInstance, microappsAdminUrl, integrationId, integrationType }: GetIntegrationLog): Promise<any>; | ||
/** | ||
* 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 | ||
*/ | ||
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>; | ||
} | ||
export declare type AddApp = { | ||
@@ -386,3 +156,501 @@ authInstance: any; | ||
export declare type GetAuthenticatorCode = { | ||
secretKey: string; | ||
}; | ||
export declare type GetCCBearerToken = { | ||
cwaAPI: string; | ||
citrixCloudCustomerId: string; | ||
citrixCloudClientId: string; | ||
citrixCloudClientSecret: string; | ||
}; | ||
export declare type CreateAuthInstance = { | ||
bearerToken: string; | ||
}; | ||
import { AxiosError } from 'axios'; | ||
export declare type GetCookie = { | ||
cookies: any; | ||
cookieName: string; | ||
}; | ||
export declare type ErrorHandle = { | ||
error: AxiosError; | ||
args: Object; | ||
}; | ||
export declare type ParamsCheck = { | ||
params: Object; | ||
functionType?: string; | ||
source: string; | ||
}; | ||
export declare type MicroappsAdminLogin = { | ||
page: Page; | ||
url: string; | ||
username: string; | ||
password: string; | ||
mfa: any | boolean; | ||
secretKey: string; | ||
}; | ||
export declare type GetIntegrationId = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
}; | ||
export declare type OauthLogout = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
repeatCount?: number; | ||
}; | ||
export declare type WaitForSync = { | ||
getIntegration: () => any; | ||
synchronizationType: string; | ||
integrationName?: string; | ||
}; | ||
export declare type RunSynchronization = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
synchronizationType: string; | ||
}; | ||
export declare type CreateHTTPIntegration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
integrationConfiguration: any; | ||
}; | ||
export declare type WaitForProcessStatus = { | ||
authInstance: any; | ||
getProcessStatus: () => any; | ||
status: string; | ||
microappsAdminUrl: string; | ||
processId: string; | ||
}; | ||
export declare type CreateJavaIntegration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
data: string; | ||
integrationConfiguration: any; | ||
withEntities: boolean; | ||
serviceType: any; | ||
serviceKey: string; | ||
name: string; | ||
}; | ||
export declare type GetIntegrationType = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
}; | ||
export declare type GetStatusIntegration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
}; | ||
export declare type ImportIntegration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
pathToFile: string; | ||
}; | ||
export declare type RenameIntegration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
newIntegrationName: string; | ||
integrationConfiguration: string; | ||
}; | ||
export declare type ExportApp = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
appId: string; | ||
pathToFile: string; | ||
}; | ||
export declare type GetMicroAppId = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
appName: string; | ||
}; | ||
export declare type GetNotificationId = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
appId: string; | ||
notificationName: string; | ||
}; | ||
export declare type RunEvent = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
appName: string; | ||
notificationName: string; | ||
}; | ||
export declare type CheckAppMissconfigurations = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
appId: string; | ||
}; | ||
export declare type ImportIntegrationUI = { | ||
page: Page; | ||
microappsAdminUrl: string; | ||
filePath: string; | ||
}; | ||
export declare type ImportMicroAppUI = { | ||
page: Page; | ||
microappsAdminUrl: string; | ||
filePath: string; | ||
integrationName: string; | ||
}; | ||
export declare type AddSubscriber = { | ||
authInstance: any; | ||
appId: string; | ||
user: string; | ||
config: any; | ||
}; | ||
export declare type AddSubscribers = { | ||
authInstance: any; | ||
integrationName: string; | ||
microappsAdminUrl: string; | ||
microapps?: any; | ||
config: any; | ||
}; | ||
export declare type Subscribe = { | ||
authInstance: any; | ||
microapps: any; | ||
microapp: string; | ||
integrationId: string; | ||
}; | ||
export declare type ExportIntegrationUI = { | ||
page: Page; | ||
integrationName: string; | ||
}; | ||
export declare type ExportMicroAppUI = { | ||
page: Page; | ||
appName: string; | ||
integrationName: string; | ||
}; | ||
export declare type GetLastSyncTime = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
}; | ||
export declare type GetComponentId = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
appName: string; | ||
pageName: string; | ||
componentLabel: string; | ||
}; | ||
export declare type Login = { | ||
page: Page; | ||
workspaceUrl: string; | ||
workspaceUsername: string; | ||
workspacePassword: string; | ||
workspaceIdentityProvider: string; | ||
}; | ||
export declare type SkipTour = { | ||
page: Page; | ||
}; | ||
export declare type GoToActions = { | ||
page: Page; | ||
}; | ||
export declare type StartAction = { | ||
page: Page; | ||
actionName: string; | ||
integrationName: string; | ||
}; | ||
export declare type GetFeedNotifications = { | ||
page: Page; | ||
}; | ||
export declare type WaitForFeedCardId = { | ||
page: Page; | ||
repeatMax?: number; | ||
waitTime?: number; | ||
recordId: string; | ||
notificationId: string; | ||
}; | ||
export declare type GetFeedCardButton = { | ||
page: Page; | ||
feedCardId: string; | ||
buttonName: string; | ||
}; | ||
export declare type WaitForPopUp = { | ||
page: Page; | ||
text: string; | ||
}; | ||
export declare type GetOneTimeToken = { | ||
workspaceUrl: string; | ||
builderDomain: string; | ||
csrfToken: string; | ||
sessionId: string; | ||
ctxsAuthId: string; | ||
authDomain: string; | ||
}; | ||
export declare type GetTokens = { | ||
builderDomain: string; | ||
authDomain: string; | ||
oneTimeToken: string; | ||
}; | ||
export declare type GetDsauthTokens = { | ||
page: Page; | ||
workspaceUrl: string; | ||
workspaceUsername: string; | ||
workspacePassword: string; | ||
workspaceIdentityProvider: string; | ||
context: BrowserContext; | ||
builderDomain: string; | ||
authDomain: string; | ||
}; | ||
export declare type CreateDsAuthInstance = { | ||
citrixToken: string; | ||
jSessionId: string; | ||
}; | ||
export declare type GetUserData = { | ||
dSauthInstance: any; | ||
microappsAdminUrl: string; | ||
appId: string; | ||
componentId: string; | ||
dataLimit: string; | ||
initiatorType: string; | ||
initiatorData: string; | ||
pageId: string; | ||
authDomain: string; | ||
}; | ||
/** Class representing a Citrix Cloud. */ | ||
export declare 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 | ||
*/ | ||
getCitrixCloudTokens({ cwaAPI, citrixCloudCustomerId, citrixCloudClientId, citrixCloudClientSecret, }: GetCitrixCloudTokens): Promise<import("axios").AxiosResponse<any>>; | ||
/** | ||
* Get all Integrations in Miroapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
*/ | ||
getIntegrations({ authInstance, microappsAdminUrl }: GetIntegrations): Promise<any>; | ||
/** | ||
* Get Bundle Catalogue in Miroapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
*/ | ||
getBundleCatalogue({ authInstance, microappsAdminUrl }: GetBundleCatalogue): Promise<any>; | ||
/** | ||
* Update Bundle Catalogue in Miroapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} catalogueId - Catalogue Id | ||
*/ | ||
updateBundleCatalogue({ authInstance, microappsAdminUrl, catalogueId }: UpdateBundleCatalogue): Promise<any>; | ||
/** | ||
* 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 | ||
*/ | ||
updateintegrationConfiguration({ authInstance, microappsAdminUrl, integrationId, integrationConfiguration, }: UpdateintegrationConfiguration): Promise<any>; | ||
/** | ||
* Get one specific Integration in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} integrationId - Integration Id | ||
*/ | ||
getIntegration({ authInstance, microappsAdminUrl, integrationId }: GetIntegration): Promise<any>; | ||
/** | ||
* Auth logout in Integration in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} integrationId - Integration Id | ||
*/ | ||
integrationLogout({ authInstance, microappsAdminUrl, integrationId }: IntegrationLogout): Promise<any>; | ||
/** | ||
* 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 | ||
*/ | ||
validateConfiguration({ authInstance, microappsAdminUrl, serviceKey, configuration }: ValidateConfiguration): Promise<any>; | ||
/** | ||
* 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 | ||
*/ | ||
addApp({ authInstance, microappsAdminUrl, data }: AddApp): Promise<any>; | ||
/** | ||
* Get status of one specific process | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} processId - Id of the process | ||
*/ | ||
getProcessStatus({ authInstance, microappsAdminUrl, processId }: GetProcessStatus): Promise<any>; | ||
/** | ||
* Get all Entities of Integration in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} integrationId - Integration Id | ||
*/ | ||
getEntities({ authInstance, microappsAdminUrl, integrationId }: GetEntities): Promise<any>; | ||
/** | ||
* 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 | ||
*/ | ||
createEntity({ authInstance, microappsAdminUrl, integrationId, entityData }: CreateEntity): Promise<any>; | ||
/** | ||
* Finalize configuration of Integration in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} integrationId - Integration Id | ||
*/ | ||
finalizeConfig({ authInstance, microappsAdminUrl, integrationId }: FinalizeConfig): Promise<any>; | ||
/** | ||
* Get all MicroApps in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
*/ | ||
getApps({ authInstance, microappsAdminUrl }: GetApps): Promise<any>; | ||
/** | ||
* 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 | ||
*/ | ||
getNotifications({ authInstance, microappsAdminUrl, appId }: GetNotifications): Promise<any>; | ||
/** | ||
* Run Event in MicroApp in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
*/ | ||
runNotificationEvent({ authInstance, microappsAdminUrl, notificationId }: RunNotificationEvent): Promise<any>; | ||
/** | ||
* Start Synchronization of Integration in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} integrationId - Integration Id | ||
*/ | ||
startSynchronization({ authInstance, microappsAdminUrl, integrationId, synchronizationType, }: StartSynchronization): Promise<any>; | ||
/** | ||
* Check integrity of all MicroApps in Microapps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
*/ | ||
integrityCheck({ authInstance, microappsAdminUrl }: IntegrityCheck): Promise<any>; | ||
/** | ||
* Delete Integration in Microaaps Admin | ||
* | ||
* @param {object} authInstance - Axios instance | ||
* @param {string} microappsAdminUrl - Microapps Admin Url | ||
* @param {string} integrationId - Integration Id | ||
*/ | ||
deleteIntegration({ authInstance, microappsAdminUrl, integrationId }: DeleteIntegration): Promise<any>; | ||
/** | ||
* 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 | ||
*/ | ||
getDomain({ authInstance, cwaAPI, citrixCloudCustomerId, workspaceIdentityProvider }: GetDomain): Promise<any>; | ||
/** | ||
* 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 | ||
*/ | ||
getUsers({ authInstance, cwaAPI, domainName, forestName, appId, query, citrixCloudCustomerId, idpType, }: GetUsers): Promise<any>; | ||
/** | ||
* 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 | ||
*/ | ||
updateSubscribers({ authInstance, microappsAdminUrl, assign, userDetail, appId, domainName, forestName, workspaceIdentityProvider, }: UpdateSubscribers): Promise<any>; | ||
/** | ||
* 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 | ||
*/ | ||
getSubscribers({ authInstance, microappsAdminUrl, appId }: GetSubscribers): Promise<any>; | ||
/** | ||
* 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= | ||
*/ | ||
exportIntegration({ authInstance, microappsAdminUrl, integrationId, filePath, params }: ExportIntegration): Promise<void>; | ||
/** | ||
* 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 | ||
*/ | ||
getIntegrationLog({ authInstance, microappsAdminUrl, integrationId, integrationType }: GetIntegrationLog): Promise<any>; | ||
/** | ||
* 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 | ||
*/ | ||
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>; | ||
} | ||
/** Class representing a Citrix Cloud. */ | ||
export declare class CitrixCloud extends API { | ||
@@ -410,29 +678,10 @@ constructor(); | ||
} | ||
export declare type GetAuthenticatorCode = { | ||
secretKey: string; | ||
}; | ||
export declare type GetCCBearerToken = { | ||
cwaAPI: string; | ||
citrixCloudCustomerId: string; | ||
citrixCloudClientId: string; | ||
citrixCloudClientSecret: string; | ||
}; | ||
export declare type CreateAuthInstance = { | ||
bearerToken: string; | ||
}; | ||
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>; | ||
export declare const paramsCheck: ({ params, functionType, source }: ParamsCheck) => Promise<string>; | ||
/** Class representing a Microapps Admin. */ | ||
@@ -447,3 +696,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>; | ||
/** | ||
@@ -455,3 +704,3 @@ * Get Integration Id | ||
*/ | ||
getIntegrationId({ authInstance, microappsAdminUrl, integrationName, }: GetIntegrationId): Promise<any>; | ||
getIntegrationId({ authInstance, microappsAdminUrl, integrationName }: GetIntegrationId): Promise<any>; | ||
/** | ||
@@ -464,3 +713,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>; | ||
/** | ||
@@ -471,3 +720,3 @@ * Wait for syncronization and check the result of sync | ||
*/ | ||
waitForSync({ getIntegration, synchronizationType }: WaitForSync): Promise<void>; | ||
waitForSync({ getIntegration, synchronizationType, integrationName }: WaitForSync): Promise<any>; | ||
/** | ||
@@ -496,3 +745,3 @@ * Run syncronization for specific Integration | ||
*/ | ||
waitForProcessStatus({ authInstance, status, microappsAdminUrl, processId, }: WaitForProcessStatus): Promise<any>; | ||
waitForProcessStatus({ authInstance, status, microappsAdminUrl, processId }: WaitForProcessStatus): Promise<any>; | ||
/** | ||
@@ -512,3 +761,3 @@ * Create Java Integration | ||
*/ | ||
getIntegrationType({ authInstance, microappsAdminUrl, integrationName, }: GetIntegrationType): Promise<any>; | ||
getIntegrationType({ authInstance, microappsAdminUrl, integrationName }: GetIntegrationType): Promise<any>; | ||
/** | ||
@@ -520,3 +769,3 @@ * Get status of Integration | ||
*/ | ||
getStatusIntegration({ authInstance, microappsAdminUrl, integrationName, }: GetStatusIntegration): Promise<any>; | ||
getStatusIntegration({ authInstance, microappsAdminUrl, integrationName }: GetStatusIntegration): Promise<any>; | ||
/** | ||
@@ -528,3 +777,3 @@ * Import integration | ||
*/ | ||
importIntegration({ authInstance, microappsAdminUrl, pathToFile, }: ImportIntegration): Promise<any>; | ||
importIntegration({ authInstance, microappsAdminUrl, pathToFile }: ImportIntegration): Promise<AxiosResponse<any>>; | ||
/** | ||
@@ -546,3 +795,3 @@ * Rename integration | ||
*/ | ||
exportApp({ authInstance, microappsAdminUrl, appId, pathToFile, }: ExportApp): Promise<void>; | ||
exportApp({ authInstance, microappsAdminUrl, appId, pathToFile }: ExportApp): Promise<void>; | ||
/** | ||
@@ -555,3 +804,3 @@ * Get Id of Microapp | ||
*/ | ||
getMicroAppId({ authInstance, microappsAdminUrl, integrationId, appName, }: GetMicroAppId): Promise<any>; | ||
getMicroAppId({ authInstance, microappsAdminUrl, integrationId, appName }: GetMicroAppId): Promise<any>; | ||
/** | ||
@@ -564,3 +813,3 @@ * Get Id of Notification | ||
*/ | ||
getNotificationId({ authInstance, microappsAdminUrl, appId, notificationName, }: GetNotificationId): Promise<any>; | ||
getNotificationId({ authInstance, microappsAdminUrl, appId, notificationName }: GetNotificationId): Promise<any>; | ||
/** | ||
@@ -574,6 +823,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; | ||
@@ -587,3 +836,3 @@ }[]>; | ||
*/ | ||
importIntegrationUI({ page, microappsAdminUrl, filePath, }: ImportIntegrationUI): Promise<void>; | ||
importIntegrationUI({ page, microappsAdminUrl, filePath }: ImportIntegrationUI): Promise<void>; | ||
/** | ||
@@ -597,3 +846,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>; | ||
/** | ||
@@ -613,3 +862,3 @@ * Exports @param integrationName integation | ||
*/ | ||
exportMicroAppsUI({ page, integrationName, appName, }: ExportMicroAppUI): Promise<void>; | ||
exportMicroAppsUI({ page, integrationName, appName }: ExportMicroAppUI): Promise<void>; | ||
/** | ||
@@ -622,3 +871,3 @@ * Returns last duration of Synchronization | ||
*/ | ||
getLastTimeSync({ authInstance, microappsAdminUrl, integrationName, }: GetLastSyncTime): Promise<any>; | ||
getLastTimeSync({ authInstance, microappsAdminUrl, integrationName }: GetLastSyncTime): Promise<any>; | ||
/** | ||
@@ -635,162 +884,3 @@ * Returns Id of component | ||
} | ||
export declare type MicroappsAdminLogin = { | ||
page: Page; | ||
url: string; | ||
username: string; | ||
password: string; | ||
mfa: any | boolean; | ||
secretKey: string; | ||
}; | ||
export declare type GetIntegrationId = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
}; | ||
export declare type OauthLogout = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
repeatCount?: number; | ||
}; | ||
export declare type WaitForSync = { | ||
getIntegration: () => any; | ||
synchronizationType: string; | ||
}; | ||
export declare type RunSynchronization = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
synchronizationType: string; | ||
}; | ||
export declare type CreateHTTPIntegration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
integrationConfiguration: any; | ||
}; | ||
export declare type WaitForProcessStatus = { | ||
authInstance: any; | ||
getProcessStatus: () => any; | ||
status: string; | ||
microappsAdminUrl: string; | ||
processId: string; | ||
}; | ||
export declare type CreateJavaIntegration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
data: string; | ||
integrationConfiguration: any; | ||
withEntities: boolean; | ||
serviceType: any; | ||
serviceKey: string; | ||
name: string; | ||
}; | ||
export declare type GetIntegrationType = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
}; | ||
export declare type GetStatusIntegration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
}; | ||
export declare type ImportIntegration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
pathToFile: string; | ||
}; | ||
export declare type RenameIntegration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
newIntegrationName: string; | ||
integrationConfiguration: string; | ||
}; | ||
export declare type ExportApp = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
appId: string; | ||
pathToFile: string; | ||
}; | ||
export declare type GetMicroAppId = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
appName: string; | ||
}; | ||
export declare type GetNotificationId = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
appId: string; | ||
notificationName: string; | ||
}; | ||
export declare type RunEvent = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
appName: string; | ||
notificationName: string; | ||
}; | ||
export declare type CheckAppMissconfigurations = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
appId: string; | ||
}; | ||
export declare type ImportIntegrationUI = { | ||
page: Page; | ||
microappsAdminUrl: string; | ||
filePath: string; | ||
}; | ||
export declare type ImportMicroAppUI = { | ||
page: Page; | ||
microappsAdminUrl: string; | ||
filePath: string; | ||
integrationName: string; | ||
}; | ||
export declare type AddSubscriber = { | ||
authInstance: any; | ||
appId: string; | ||
user: string; | ||
config: any; | ||
}; | ||
export declare type AddSubscribers = { | ||
authInstance: any; | ||
integrationName: string; | ||
microappsAdminUrl: string; | ||
microapps?: any; | ||
config: any; | ||
}; | ||
export declare type Subscribe = { | ||
authInstance: any; | ||
microapps: any; | ||
microapp: string; | ||
integrationId: string; | ||
}; | ||
export declare type ExportIntegrationUI = { | ||
page: Page; | ||
integrationName: string; | ||
}; | ||
export declare type ExportMicroAppUI = { | ||
page: Page; | ||
appName: string; | ||
integrationName: string; | ||
}; | ||
export declare type GetLastSyncTime = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
}; | ||
export declare type GetComponentId = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
appName: string; | ||
pageName: string; | ||
componentLabel: string; | ||
}; | ||
import { Page, BrowserContext } from "playwright"; | ||
/** Class representing a Workspace. */ | ||
@@ -807,3 +897,3 @@ export declare class Workspace { | ||
*/ | ||
login({ page, workspaceUrl, workspaceUsername, workspacePassword, workspaceIdentityProvider, }: Login): Promise<void>; | ||
login({ page, workspaceUrl, workspaceUsername, workspacePassword, workspaceIdentityProvider }: Login): Promise<void>; | ||
/** | ||
@@ -864,79 +954,4 @@ * Skip Tour | ||
}>; | ||
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>; | ||
} | ||
export declare type Login = { | ||
page: Page; | ||
workspaceUrl: string; | ||
workspaceUsername: string; | ||
workspacePassword: string; | ||
workspaceIdentityProvider: string; | ||
}; | ||
export declare type SkipTour = { | ||
page: Page; | ||
}; | ||
export declare type GoToActions = { | ||
page: Page; | ||
}; | ||
export declare type StartAction = { | ||
page: Page; | ||
actionName: string; | ||
integrationName: string; | ||
}; | ||
export declare type GetFeedNotifications = { | ||
page: Page; | ||
}; | ||
export declare type WaitForFeedCardId = { | ||
page: Page; | ||
repeatMax?: number; | ||
waitTime?: number; | ||
recordId: string; | ||
notificationId: string; | ||
}; | ||
export declare type GetFeedCardButton = { | ||
page: Page; | ||
feedCardId: string; | ||
buttonName: string; | ||
}; | ||
export declare type WaitForPopUp = { | ||
page: Page; | ||
text: string; | ||
}; | ||
export declare type GetOneTimeToken = { | ||
workspaceUrl: string; | ||
builderDomain: string; | ||
csrfToken: string; | ||
sessionId: string; | ||
ctxsAuthId: string; | ||
authDomain: string; | ||
}; | ||
export declare type GetTokens = { | ||
builderDomain: string; | ||
authDomain: string; | ||
oneTimeToken: string; | ||
}; | ||
export declare type GetDsauthTokens = { | ||
page: Page; | ||
workspaceUrl: string; | ||
workspaceUsername: string; | ||
workspacePassword: string; | ||
workspaceIdentityProvider: string; | ||
context: BrowserContext; | ||
builderDomain: string; | ||
authDomain: string; | ||
}; | ||
export declare type CreateDsAuthInstance = { | ||
citrixToken: string; | ||
jSessionId: string; | ||
}; | ||
export declare type GetUserData = { | ||
dSauthInstance: any; | ||
microappsAdminUrl: string; | ||
appId: string; | ||
componentId: string; | ||
dataLimit: string; | ||
initiatorType: string; | ||
initiatorData: string; | ||
pageId: string; | ||
authDomain: string; | ||
}; |
{ | ||
"name": "microapps-automation-helper", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "> library which provides common functions to test integration between Microapps Admin and Citrix Worskspace", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
207
src/api.ts
@@ -5,2 +5,31 @@ import axios from 'axios'; | ||
import { errorHandle } from './helpers'; | ||
import type { | ||
AddApp, | ||
AddSecrets, | ||
CreateEntity, | ||
DeleteIntegration, | ||
ExportIntegration, | ||
FinalizeConfig, | ||
GetAppInfo, | ||
GetApps, | ||
GetBundleCatalogue, | ||
GetCitrixCloudTokens, | ||
GetDomain, | ||
GetEntities, | ||
GetIntegration, | ||
GetIntegrationLog, | ||
GetIntegrations, | ||
GetNotifications, | ||
GetProcessStatus, | ||
GetSubscribers, | ||
GetUsers, | ||
IntegrationLogout, | ||
IntegrityCheck, | ||
RunNotificationEvent, | ||
StartSynchronization, | ||
UpdateBundleCatalogue, | ||
UpdateintegrationConfiguration, | ||
UpdateSubscribers, | ||
ValidateConfiguration, | ||
} from './types/api'; | ||
@@ -744,179 +773,1 @@ /** Class representing a Citrix Cloud. */ | ||
} | ||
export type AddApp = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
data: string; | ||
}; | ||
export type GetBundleCatalogue = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
}; | ||
export type GetIntegration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
}; | ||
export type GetIntegrations = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
}; | ||
export type GetProcessStatus = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
processId: string; | ||
}; | ||
export type IntegrationLogout = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
}; | ||
export type UpdateBundleCatalogue = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
catalogueId: string; | ||
}; | ||
export type UpdateintegrationConfiguration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
integrationConfiguration: any; | ||
}; | ||
export type ValidateConfiguration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
serviceKey: string; | ||
configuration: string; | ||
}; | ||
export type GetEntities = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
}; | ||
export type CreateEntity = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
entityData: any; | ||
}; | ||
export type FinalizeConfig = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
}; | ||
export type GetApps = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
}; | ||
export type GetNotifications = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
appId: string; | ||
}; | ||
export type RunNotificationEvent = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
notificationId: string; | ||
}; | ||
export type StartSynchronization = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
synchronizationType: string; | ||
}; | ||
export type IntegrityCheck = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
}; | ||
export type DeleteIntegration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
}; | ||
export type GetDomain = { | ||
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; | ||
}; | ||
export type UpdateSubscribers = { | ||
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; | ||
}; | ||
export type ExportIntegration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
filePath: any; | ||
params: any; | ||
}; | ||
export type GetIntegrationLog = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
integrationType: string; | ||
}; | ||
export type GetCitrixCloudTokens = { | ||
cwaAPI: string; | ||
citrixCloudCustomerId: string; | ||
citrixCloudClientId: string; | ||
citrixCloudClientSecret: string; | ||
}; | ||
export type AddSecrets = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
data: any; | ||
}; | ||
export type GetAppInfo = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
appId: string; | ||
}; |
import axios from 'axios'; | ||
import { authenticator } from 'otplib'; | ||
import { API } from './api'; | ||
import type { GetAuthenticatorCode, GetCCBearerToken, CreateAuthInstance } from './types/citrixCloud'; | ||
authenticator.options = { digits: 6 }; | ||
@@ -15,3 +15,3 @@ | ||
* Generates auth code for login to Citrix Cloud | ||
* | ||
* | ||
* @param {string} secretKey - SecretKey for generating the code | ||
@@ -58,16 +58,1 @@ */ | ||
} | ||
export type GetAuthenticatorCode = { | ||
secretKey: string; | ||
}; | ||
export type GetCCBearerToken = { | ||
cwaAPI: string; | ||
citrixCloudCustomerId: string; | ||
citrixCloudClientId: string; | ||
citrixCloudClientSecret: string; | ||
}; | ||
export type CreateAuthInstance = { | ||
bearerToken: string; | ||
} |
@@ -1,13 +0,3 @@ | ||
import { AxiosError } from 'axios'; | ||
import type { GetCookie, ErrorHandle, ParamsCheck } from './types/helpers'; | ||
export type GetCookie = { | ||
cookies: any; | ||
cookieName: string; | ||
}; | ||
export type ErrorHandle = { | ||
error: AxiosError; | ||
args: Object; | ||
}; | ||
export const getCookie = ({ cookies, cookieName }: GetCookie): string => { | ||
@@ -125,3 +115,3 @@ const regexp = new RegExp(`^${cookieName}=([^;]+);`); | ||
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}`; | ||
errorReport.ErrorReport.message = `The request send message: ${error.response.data.message}`; | ||
} else { | ||
@@ -137,1 +127,27 @@ console.log(error.stack); | ||
}; | ||
export const paramsCheck = async ({ params, functionType, source }: ParamsCheck) => { | ||
let invalidValues: any = { InvalidValues: [] }; | ||
let invalidKey; | ||
for (const [key, value] of Object.entries(params)) { | ||
if (value === undefined || value === null || value === '') { | ||
invalidKey = key; | ||
invalidValues.InvalidValues.push(`Value "${key}" is type of "${typeof value}" and has value "${value}".`); | ||
} | ||
} | ||
if (invalidValues.InvalidValues.length > 0) { | ||
console.log(invalidValues); | ||
switch (functionType) { | ||
case 'find': { | ||
return `Failed to find '${invalidKey}' in '${source}' list`; | ||
} | ||
case 'filter': { | ||
return `Failed to filter '${invalidKey}' in '${source}' list`; | ||
} | ||
default: { | ||
return `Failed to get property '${invalidKey}' in '${source}'`; | ||
} | ||
} | ||
} | ||
}; |
@@ -1,8 +0,37 @@ | ||
import { Page } from "playwright"; | ||
import FormData from "form-data"; | ||
import fs from "fs"; | ||
import path from "path"; | ||
import assert from "assert"; | ||
import { CitrixCloud } from "./citrixCloud"; | ||
import { API } from "./api"; | ||
import FormData from 'form-data'; | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import assert from 'assert'; | ||
import { CitrixCloud } from './citrixCloud'; | ||
import { API } from './api'; | ||
import { paramsCheck } from './helpers'; | ||
import { AxiosResponse } from 'axios'; | ||
import type { | ||
AddSubscriber, | ||
AddSubscribers, | ||
CheckAppMissconfigurations, | ||
CreateHTTPIntegration, | ||
CreateJavaIntegration, | ||
ExportApp, | ||
ExportIntegrationUI, | ||
ExportMicroAppUI, | ||
GetComponentId, | ||
GetIntegrationId, | ||
GetIntegrationType, | ||
GetLastSyncTime, | ||
GetMicroAppId, | ||
GetNotificationId, | ||
GetStatusIntegration, | ||
ImportIntegration, | ||
ImportIntegrationUI, | ||
ImportMicroAppUI, | ||
MicroappsAdminLogin, | ||
OauthLogout, | ||
RenameIntegration, | ||
RunEvent, | ||
RunSynchronization, | ||
Subscribe, | ||
WaitForProcessStatus, | ||
WaitForSync, | ||
} from './types/microappsAdmin'; | ||
@@ -13,1291 +42,1106 @@ const citrixCloud = new CitrixCloud(); | ||
export class MicroappsAdmin extends API { | ||
constructor() { | ||
super(); | ||
} | ||
constructor() { | ||
super(); | ||
} | ||
/** | ||
* Login to cloud | ||
* @param {string} - Microapps cloud login url | ||
* @param {string} - Username | ||
* @param {string} - Password | ||
*/ | ||
/** | ||
* Login to cloud | ||
* @param {string} - Microapps cloud login url | ||
* @param {string} - Username | ||
* @param {string} - Password | ||
*/ | ||
async login({ | ||
page, | ||
url, | ||
username, | ||
password, | ||
mfa = null, | ||
secretKey, | ||
}: MicroappsAdminLogin) { | ||
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 }: MicroappsAdminLogin) { | ||
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 }); | ||
if (mfa) { | ||
const authCode = await citrixCloud.getAuthenticatorCode({ secretKey }); | ||
await page.waitForSelector("input[inputmode]"); | ||
for (let i = 0; i < 6; i++) { | ||
await page.type(`input[inputmode][name="${i}"]`, authCode[i]); | ||
} | ||
await page.waitForSelector('input[inputmode]'); | ||
for (let i = 0; i < 6; i++) { | ||
await page.type(`input[inputmode][name="${i}"]`, authCode[i]); | ||
} | ||
await page.waitForSelector('button[type="button"]:not([disabled])'); | ||
await page.click('button[type="button"]:not([disabled])'); | ||
await page.waitForSelector('button[type="button"]:not([disabled])'); | ||
await page.click('button[type="button"]:not([disabled])'); | ||
try { | ||
for (;;) { | ||
if ( | ||
(await page.$( | ||
`input[inputmode][name="0"][value="${authCode[0]}"]` | ||
)) !== null | ||
) { | ||
await page.waitForTimeout(300); | ||
} else break; | ||
try { | ||
for (;;) { | ||
if ((await page.$(`input[inputmode][name="0"][value="${authCode[0]}"]`)) !== null) { | ||
await page.waitForTimeout(300); | ||
} else break; | ||
} | ||
} catch (error) {} | ||
} | ||
} catch (error) {} | ||
} | ||
} | ||
/** | ||
* Get Integration Id | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} integrationName - Name of integration | ||
*/ | ||
/** | ||
* Get Integration Id | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} integrationName - Name of integration | ||
*/ | ||
async getIntegrationId({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
}: GetIntegrationId) { | ||
const integrations = await this.getIntegrations({ | ||
authInstance, | ||
microappsAdminUrl, | ||
}); | ||
const integration = integrations.data.find( | ||
(e: { title: string }) => e.title === integrationName | ||
); | ||
return integration.id; | ||
} | ||
async getIntegrationId({ authInstance, microappsAdminUrl, integrationName }: GetIntegrationId) { | ||
let integrationId; | ||
let integration; | ||
/** | ||
* Delete credentiaslds from credentials wallet for specific inregration | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} integrationName - Name of integration | ||
* @param {number} repeatCount - Set count for retries | ||
*/ | ||
const integrations = await this.getIntegrations({ authInstance, microappsAdminUrl }); | ||
async oauthLogout({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
repeatCount = 1, | ||
}: OauthLogout) { | ||
const integrationId = await this.getIntegrationId({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
}); | ||
for (let i = 0; i < repeatCount; i++) { | ||
await this.integrationLogout({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
}); | ||
try { | ||
integration = integrations.data.find((e: { title: string }) => e.title === integrationName); | ||
integrationId = integration.id; | ||
} catch (error) { | ||
throw new Error( | ||
await paramsCheck({ | ||
params: { integration, integrationId, integrations }, | ||
functionType: 'find', | ||
source: 'integrations', | ||
}) | ||
); | ||
} | ||
return integrationId; | ||
} | ||
} | ||
/** | ||
* Wait for syncronization and check the result of sync | ||
* @param {Function} getIntegration - Fetch status of integration | ||
* @param {string} synchronizationType - Set type of syncronization full/incremental | ||
*/ | ||
/** | ||
* Delete credentiaslds from credentials wallet for specific inregration | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} integrationName - Name of integration | ||
* @param {number} repeatCount - Set count for retries | ||
*/ | ||
async waitForSync({ getIntegration, synchronizationType }: WaitForSync) { | ||
let lastRunSuccess; | ||
let cancelled; | ||
let running; | ||
for (;;) { | ||
const integration = await getIntegration(); | ||
const jobRuns = integration.data.jobRuns; | ||
const getJobRunDetail = jobRuns.find( | ||
(job: { synchronizationTypeId: string }) => { | ||
return job.synchronizationTypeId === synchronizationType; | ||
async oauthLogout({ authInstance, microappsAdminUrl, integrationName, repeatCount = 1 }: OauthLogout) { | ||
const integrationId = await this.getIntegrationId({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
}); | ||
for (let i = 0; i < repeatCount; i++) { | ||
await this.integrationLogout({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
}); | ||
} | ||
); | ||
} | ||
running = getJobRunDetail.running; | ||
/** | ||
* Wait for syncronization and check the result of sync | ||
* @param {Function} getIntegration - Fetch status of integration | ||
* @param {string} synchronizationType - Set type of syncronization full/incremental | ||
*/ | ||
cancelled = getJobRunDetail.cancelled; | ||
async waitForSync({ getIntegration, synchronizationType, integrationName = '' }: WaitForSync) { | ||
let jobRun; | ||
lastRunSuccess = getJobRunDetail.lastRunSuccess; | ||
for (let i = 0; ; i++) { | ||
if (i % 6 === 0) { | ||
console.log(`${integrationName && `[${integrationName}] - `}Waiting for synchronization to finish`); | ||
} | ||
const integration = await getIntegration(); | ||
if (integration.data.jobRuns.length > 0) { | ||
const jobRuns = integration.data.jobRuns; | ||
try { | ||
[jobRun] = jobRuns.filter( | ||
(job: { synchronizationTypeId: string }) => job.synchronizationTypeId === synchronizationType | ||
); | ||
} catch (error) { | ||
throw new Error( | ||
await paramsCheck({ | ||
params: { jobRun, jobRuns }, | ||
functionType: 'filter', | ||
source: 'jobRuns', | ||
}) | ||
); | ||
} | ||
if (jobRun.running === false) { | ||
break; | ||
} | ||
await new Promise((resolve) => setTimeout(resolve, 5000)); | ||
} else { | ||
throw new Error(`No jobRuns found.`); | ||
} | ||
} | ||
if ((await running) === false) { | ||
break; | ||
} | ||
await new Promise((resolve) => setTimeout(resolve, 5000)); | ||
} | ||
if (jobRun.lastRunSuccess === false || jobRun.lastRunException) { | ||
if (jobRun.lastRunException) { | ||
throw new Error(`Sync failed with: ${jobRun.lastRunException}`); | ||
} | ||
if ((await lastRunSuccess) === false) { | ||
throw new Error(`Sync failed!`); | ||
} else if (cancelled === true) { | ||
throw new Error(`Sync was cancelled!`); | ||
throw new Error(`Sync failed without Exception!`); | ||
} else if (jobRun.cancelled === true) { | ||
throw new Error(`Sync was cancelled!`); | ||
} | ||
return jobRun; | ||
} | ||
} | ||
/** | ||
* Run syncronization for specific Integration | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} integrationName - Name of integration | ||
* @param {string} synchronizationType - Set type of syncronization full/incremental | ||
*/ | ||
/** | ||
* Run syncronization for specific Integration | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} integrationName - Name of integration | ||
* @param {string} synchronizationType - Set type of syncronization full/incremental | ||
*/ | ||
async runSynchronization({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
synchronizationType, | ||
}: RunSynchronization) { | ||
const integrationId = await this.getIntegrationId({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
}); | ||
const integration = await this.getIntegration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
}); | ||
const jobRuns = integration.data.jobRuns; | ||
const getJobRunDetail = jobRuns.find( | ||
(job: { synchronizationTypeId: string }) => { | ||
return job.synchronizationTypeId === synchronizationType; | ||
} | ||
); | ||
if (getJobRunDetail === undefined) { | ||
await this.startSynchronization({ | ||
async runSynchronization({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
integrationName, | ||
synchronizationType, | ||
}); | ||
await this.waitForSync({ | ||
getIntegration: () => | ||
this.getIntegration({ | ||
}: RunSynchronization) { | ||
const integrationId = await this.getIntegrationId({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
}), | ||
synchronizationType, | ||
}); | ||
} else if (getJobRunDetail.running === true) { | ||
await this.waitForSync({ | ||
getIntegration: () => | ||
this.getIntegration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
}), | ||
synchronizationType, | ||
}); | ||
} else { | ||
await this.startSynchronization({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
synchronizationType, | ||
}); | ||
integrationName, | ||
}); | ||
await this.waitForSync({ | ||
getIntegration: () => | ||
this.getIntegration({ | ||
const integration = await this.getIntegration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
}), | ||
synchronizationType, | ||
}); | ||
} | ||
} | ||
}); | ||
/** | ||
* Create HTTP Integration | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} integrationName - Name of integration | ||
* @param {string} integrationConfiguration - Additional integration configuration | ||
*/ | ||
const jobRuns = integration.data.jobRuns; | ||
async createHTTPIntegration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
integrationConfiguration, | ||
}: CreateHTTPIntegration) { | ||
const bundleCatalogue = await this.getBundleCatalogue({ | ||
authInstance, | ||
microappsAdminUrl, | ||
}); | ||
const bundleCatalogueData = bundleCatalogue.data; | ||
const catalogueDetail = bundleCatalogueData.find( | ||
(e: any) => e.title === integrationName && e.type === "HTTP" | ||
); | ||
const catalogueId = catalogueDetail.uniqueId; | ||
const createdConnector = await this.updateBundleCatalogue({ | ||
authInstance, | ||
microappsAdminUrl, | ||
catalogueId, | ||
}); | ||
const integrationId = createdConnector.data.id; | ||
let getJobRunDetail: { running: boolean }; | ||
try { | ||
getJobRunDetail = jobRuns.find((job: { synchronizationTypeId: string }) => { | ||
return job.synchronizationTypeId === synchronizationType; | ||
}); | ||
} catch (error) { | ||
throw new Error( | ||
await paramsCheck({ | ||
params: { integration, jobRuns, getJobRunDetail }, | ||
functionType: 'find', | ||
source: 'jobRuns', | ||
}) | ||
); | ||
} | ||
await this.updateintegrationConfiguration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
integrationConfiguration, | ||
}); | ||
if (getJobRunDetail.running === true) { | ||
await this.waitForSync({ | ||
getIntegration: () => | ||
this.getIntegration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
}), | ||
synchronizationType, | ||
}); | ||
} else { | ||
await this.startSynchronization({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
synchronizationType, | ||
}); | ||
return integrationId; | ||
} | ||
await this.waitForSync({ | ||
getIntegration: () => | ||
this.getIntegration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
}), | ||
synchronizationType, | ||
}); | ||
} | ||
} | ||
/** | ||
* Wait for process status | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} status - specific status of process | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} processId - Id of process | ||
*/ | ||
/** | ||
* Create HTTP Integration | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} integrationName - Name of integration | ||
* @param {string} integrationConfiguration - Additional integration configuration | ||
*/ | ||
async waitForProcessStatus({ | ||
authInstance, | ||
status, | ||
microappsAdminUrl, | ||
processId, | ||
}: WaitForProcessStatus) { | ||
let processStatus; | ||
for (let i = 0; i < 35; i++) { | ||
processStatus = await this.getProcessStatus({ | ||
async createHTTPIntegration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
processId, | ||
}); | ||
if (processStatus.data.message !== undefined) { | ||
console.log(processStatus.data.message); | ||
} | ||
integrationName, | ||
integrationConfiguration, | ||
}: CreateHTTPIntegration) { | ||
const bundleCatalogue = await this.getBundleCatalogue({ | ||
authInstance, | ||
microappsAdminUrl, | ||
}); | ||
const bundleCatalogueData = bundleCatalogue.data; | ||
let catalogueDetail; | ||
let catalogueId; | ||
try { | ||
catalogueDetail = bundleCatalogueData.find( | ||
(e: { title: string; type: string }) => e.title === integrationName && e.type === 'HTTP' | ||
); | ||
catalogueId = catalogueDetail.uniqueId; | ||
} catch (error) { | ||
throw new Error( | ||
await paramsCheck({ | ||
params: { catalogueDetail, catalogueId, bundleCatalogueData }, | ||
functionType: 'find', | ||
source: 'bundleCatalogueData', | ||
}) | ||
); | ||
} | ||
const createdConnector = await this.updateBundleCatalogue({ | ||
authInstance, | ||
microappsAdminUrl, | ||
catalogueId, | ||
}); | ||
const integrationId = createdConnector.data.id; | ||
if ((await processStatus.data.status) === status) { | ||
break; | ||
} | ||
await new Promise((resolve) => setTimeout(resolve, 5000)); | ||
await this.updateintegrationConfiguration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
integrationConfiguration, | ||
}); | ||
return integrationId; | ||
} | ||
if ((await processStatus.data.status) !== status) { | ||
throw new Error(`Process status is: ${processStatus.data.status}`); | ||
} | ||
return processStatus; | ||
} | ||
/** | ||
* Create Java Integration | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} integrationName - Name of integration | ||
* @param {string} integrationConfiguration - Additional integration configuration | ||
*/ | ||
/** | ||
* Wait for process status | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} status - specific status of process | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} processId - Id of process | ||
*/ | ||
async createJavaIntegration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationConfiguration, | ||
withEntities = true, | ||
serviceType = null, | ||
serviceKey, | ||
name = "", | ||
}: CreateJavaIntegration) { | ||
let processId: string; | ||
async waitForProcessStatus({ authInstance, status, microappsAdminUrl, processId }: WaitForProcessStatus) { | ||
let processStatus; | ||
for (let i = 0; i < 35; i++) { | ||
processStatus = await this.getProcessStatus({ | ||
authInstance, | ||
microappsAdminUrl, | ||
processId, | ||
}); | ||
if (processStatus.data.message !== undefined) { | ||
console.log(processStatus.data.message); | ||
} | ||
const configurationParameters = | ||
integrationConfiguration.serviceData.configuration | ||
.configurationParameters; | ||
const responseValidation = await this.validateConfiguration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
serviceKey, | ||
configuration: configurationParameters, | ||
}); | ||
const responseValidationBody = JSON.stringify(responseValidation.data); | ||
if (!responseValidationBody.includes("ok")) { | ||
throw new Error("Configuration is not valid!"); | ||
if ((await processStatus.data.status) === status) { | ||
break; | ||
} | ||
await new Promise((resolve) => setTimeout(resolve, 5000)); | ||
} | ||
if ((await processStatus.data.status) !== status) { | ||
throw new Error(`Process status is: ${processStatus.data.status}`); | ||
} | ||
return processStatus; | ||
} | ||
const app = await this.addApp({ | ||
authInstance, | ||
microappsAdminUrl, | ||
data: integrationConfiguration, | ||
}); | ||
/** | ||
* Create Java Integration | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} integrationName - Name of integration | ||
* @param {string} integrationConfiguration - Additional integration configuration | ||
*/ | ||
processId = app.data.processId; | ||
const processStatus = await this.waitForProcessStatus({ | ||
authInstance, | ||
getProcessStatus: () => | ||
this.getProcessStatus({ authInstance, microappsAdminUrl, processId }), | ||
status: "DONE", | ||
microappsAdminUrl, | ||
processId, | ||
}); | ||
const integrationId = processStatus.data.detail.service.id; | ||
let entities; | ||
let entityFilters; | ||
// Some connectors have different flow for getting entities | ||
if (serviceType === "Service Now" || serviceType === "Salesforce") { | ||
const services = await this.getIntegration({ | ||
async createJavaIntegration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
}); | ||
integrationConfiguration, | ||
withEntities = true, | ||
serviceType = null, | ||
serviceKey, | ||
name = '', | ||
}: CreateJavaIntegration) { | ||
let processId: string; | ||
entities = services.data.configuration.entities; | ||
let configurationParameters: any; | ||
try { | ||
configurationParameters = integrationConfiguration.serviceData.configuration.configurationParameters; | ||
} catch (error) { | ||
throw new Error( | ||
await paramsCheck({ | ||
params: { configurationParameters, integrationConfiguration }, | ||
source: 'integrationConfiguration', | ||
}) | ||
); | ||
} | ||
entityFilters = services.data.configuration.entityFilters; | ||
} else { | ||
const response = await this.getEntities({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
}); | ||
const responseValidation = await this.validateConfiguration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
serviceKey, | ||
configuration: configurationParameters, | ||
}); | ||
processId = response.data.processId; | ||
const responseValidationBody = JSON.stringify(responseValidation.data); | ||
if (!responseValidationBody.includes('ok')) { | ||
throw new Error('Configuration is not valid!'); | ||
} | ||
await this.waitForProcessStatus({ | ||
authInstance, | ||
getProcessStatus: () => | ||
this.getProcessStatus({ authInstance, microappsAdminUrl, processId }), | ||
status: "DONE", | ||
microappsAdminUrl, | ||
processId, | ||
}); | ||
const app = await this.addApp({ | ||
authInstance, | ||
microappsAdminUrl, | ||
data: integrationConfiguration, | ||
}); | ||
const processDetail = await this.getProcessStatus({ | ||
authInstance, | ||
microappsAdminUrl, | ||
processId, | ||
}); | ||
entities = processDetail.data.detail.data.entities; | ||
entityFilters = processDetail.data.detail.data.entityFilters; | ||
} | ||
processId = app.data.processId; | ||
const entityNames: any[] = []; | ||
const processStatus = await this.waitForProcessStatus({ | ||
authInstance, | ||
getProcessStatus: () => this.getProcessStatus({ authInstance, microappsAdminUrl, processId }), | ||
status: 'DONE', | ||
microappsAdminUrl, | ||
processId, | ||
}); | ||
entities.forEach((el: { name: any }) => entityNames.push(el.name)); | ||
const integrationId = processStatus.data.detail.service.id; | ||
const entityData = { | ||
entityNames: entityNames, | ||
entityAttributeNamesMap: {}, | ||
entityFilters: entityFilters, | ||
}; | ||
let entities; | ||
let entityFilters; | ||
if (withEntities) { | ||
const entity = await this.createEntity({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
entityData, | ||
}); | ||
// Some connectors have different flow for getting entities | ||
if (serviceType === 'Service Now' || serviceType === 'Salesforce') { | ||
const services = await this.getIntegration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
}); | ||
processId = entity.data.processId; | ||
entities = services.data.configuration.entities; | ||
await this.waitForProcessStatus({ | ||
authInstance, | ||
getProcessStatus: () => | ||
this.getProcessStatus({ authInstance, microappsAdminUrl, processId }), | ||
status: "DONE", | ||
microappsAdminUrl, | ||
processId, | ||
}); | ||
await this.finalizeConfig({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
}); | ||
} | ||
} | ||
entityFilters = services.data.configuration.entityFilters; | ||
} else { | ||
const response = await this.getEntities({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
}); | ||
/** | ||
* Get type of Integration | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} integrationName - Name of integration | ||
*/ | ||
processId = response.data.processId; | ||
async getIntegrationType({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
}: GetIntegrationType) { | ||
const integrations = await this.getIntegrations({ | ||
authInstance, | ||
microappsAdminUrl, | ||
}); | ||
await this.waitForProcessStatus({ | ||
authInstance, | ||
getProcessStatus: () => this.getProcessStatus({ authInstance, microappsAdminUrl, processId }), | ||
status: 'DONE', | ||
microappsAdminUrl, | ||
processId, | ||
}); | ||
const integrationsData = integrations.data; | ||
const processDetail = await this.getProcessStatus({ | ||
authInstance, | ||
microappsAdminUrl, | ||
processId, | ||
}); | ||
entities = processDetail.data.detail.data.entities; | ||
entityFilters = processDetail.data.detail.data.entityFilters; | ||
} | ||
const findIntegrationType = integrationsData.find( | ||
(integration: { title: string }) => { | ||
return integration.title === integrationName; | ||
} | ||
); | ||
const entityNames: Array<string> = []; | ||
const integrationType = findIntegrationType.serviceType; | ||
return integrationType; | ||
} | ||
entities.forEach((el: { name: string }) => entityNames.push(el.name)); | ||
/** | ||
* Get status of Integration | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} integrationName - Name of integration | ||
*/ | ||
const entityData = { | ||
entityNames: entityNames, | ||
entityAttributeNamesMap: {}, | ||
entityFilters: entityFilters, | ||
}; | ||
async getStatusIntegration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
}: GetStatusIntegration) { | ||
try { | ||
const serviceId = await this.getIntegrationId({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
}); | ||
return serviceId; | ||
} catch (e) { | ||
return null; | ||
} | ||
} | ||
if (withEntities) { | ||
const entity = await this.createEntity({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
entityData, | ||
}); | ||
/** | ||
* Import integration | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} pathToFile - path to file.mapp which should be imported | ||
*/ | ||
processId = entity.data.processId; | ||
async importIntegration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
pathToFile, | ||
}: ImportIntegration) { | ||
const form: any = new FormData(); | ||
let response; | ||
form.append( | ||
"file", | ||
fs.createReadStream(path.resolve(__dirname, pathToFile)) | ||
); | ||
try { | ||
response = await authInstance({ | ||
url: `${microappsAdminUrl}/api/service/import`, | ||
method: "POST", | ||
headers: { | ||
"content-type": `multipart/form-data; boundary=${form._boundary}`, | ||
}, | ||
data: form, | ||
}); | ||
} catch (error) { | ||
throw error.stack; | ||
await this.waitForProcessStatus({ | ||
authInstance, | ||
getProcessStatus: () => this.getProcessStatus({ authInstance, microappsAdminUrl, processId }), | ||
status: 'DONE', | ||
microappsAdminUrl, | ||
processId, | ||
}); | ||
await this.finalizeConfig({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
}); | ||
} | ||
} | ||
await assert.deepStrictEqual( | ||
response.status, | ||
200, | ||
`Response status ${response.status} doesn't match expected 200` | ||
); | ||
return response; | ||
} | ||
/** | ||
* Get type of Integration | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} integrationName - Name of integration | ||
*/ | ||
/** | ||
* Rename integration | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} integrationName - Name of integration | ||
* @param {string} newIntegrationName - New Name of integration | ||
* @param {string} integrationConfiguration - Configuration for integration | ||
*/ | ||
async getIntegrationType({ authInstance, microappsAdminUrl, integrationName }: GetIntegrationType) { | ||
const integrations = await this.getIntegrations({ | ||
authInstance, | ||
microappsAdminUrl, | ||
}); | ||
async renameIntegration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
newIntegrationName, | ||
integrationConfiguration, | ||
}: RenameIntegration) { | ||
const integrationType = await this.getIntegrationType({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
}); | ||
const data = { | ||
serviceType: integrationType, | ||
title: newIntegrationName, | ||
}; | ||
const integrationId = await this.getStatusIntegration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
}); | ||
const integrationsData = integrations.data; | ||
await this.updateintegrationConfiguration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
integrationConfiguration, | ||
}); | ||
let findIntegrationType; | ||
let integrationType; | ||
try { | ||
findIntegrationType = integrationsData.find((integration: { title: string }) => { | ||
return integration.title === integrationName; | ||
}); | ||
const integrations = await this.getIntegrations({ | ||
authInstance, | ||
microappsAdminUrl, | ||
}); | ||
const integrationsData = integrations.data; | ||
const IntegrationDetail = integrationsData.filter( | ||
(e: { title: any; id: any }) => { | ||
return e.title === integrationName && e.id === newIntegrationName; | ||
} | ||
); | ||
console.log( | ||
`Integration ${integrationName} with id: ${IntegrationDetail[0].id} was renamed to: ${integrationsData[0].title}` | ||
); | ||
} | ||
/** | ||
* Export Application | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} appId - Id of target App | ||
* @param {string} pathToFile - path where file should be saved | ||
*/ | ||
async exportApp({ | ||
authInstance, | ||
microappsAdminUrl, | ||
appId, | ||
pathToFile, | ||
}: ExportApp) { | ||
let response; | ||
try { | ||
response = await authInstance({ | ||
method: "GET", | ||
url: `${microappsAdminUrl}/api/app/${appId}/export`, | ||
responseType: "stream", | ||
}); | ||
} catch (error) { | ||
throw error.stack; | ||
integrationType = findIntegrationType.serviceType; | ||
} catch (error) { | ||
throw new Error( | ||
await paramsCheck({ | ||
params: { findIntegrationType, integrationType, integrationsData }, | ||
functionType: 'find', | ||
source: 'integrationsData', | ||
}) | ||
); | ||
} | ||
return integrationType; | ||
} | ||
await response.data.pipe( | ||
fs.createWriteStream(path.resolve(__dirname, pathToFile)) | ||
); | ||
} | ||
/** | ||
* Get Id of Microapp | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} integrationId - Name of integration | ||
* @param {string} appName - Name Application | ||
*/ | ||
/** | ||
* Get status of Integration | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} integrationName - Name of integration | ||
*/ | ||
async getMicroAppId({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
appName, | ||
}: GetMicroAppId) { | ||
let apps; | ||
try { | ||
apps = await this.getApps({ authInstance, microappsAdminUrl }); | ||
const appsData = apps.data; | ||
const getAppDetail = appsData.filter( | ||
(app: { app: { title: string; serviceId: string } }) => | ||
app.app.title === appName && app.app.serviceId === integrationId | ||
); | ||
return getAppDetail[0].id; | ||
} catch (e) { | ||
console.log(e); | ||
return null; | ||
async getStatusIntegration({ authInstance, microappsAdminUrl, integrationName }: GetStatusIntegration) { | ||
try { | ||
const serviceId = await this.getIntegrationId({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
}); | ||
return serviceId; | ||
} catch (e) { | ||
return null; | ||
} | ||
} | ||
} | ||
/** | ||
* Get Id of Notification | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} appId - Name of App | ||
* @param {string} notificationName - Name of Notification | ||
*/ | ||
/** | ||
* Import integration | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} pathToFile - path to file.mapp which should be imported | ||
*/ | ||
async getNotificationId({ | ||
authInstance, | ||
microappsAdminUrl, | ||
appId, | ||
notificationName, | ||
}: GetNotificationId) { | ||
const notifications = await this.getNotifications({ | ||
authInstance, | ||
microappsAdminUrl, | ||
appId, | ||
}); | ||
async importIntegration({ authInstance, microappsAdminUrl, pathToFile }: ImportIntegration) { | ||
const form: any = new FormData(); | ||
let response: AxiosResponse; | ||
const notificationsData = notifications.data; | ||
form.append('file', fs.createReadStream(path.resolve(__dirname, pathToFile))); | ||
const getNotificationId = notificationsData.find((e: { label: string }) => { | ||
return e.label === notificationName; | ||
}); | ||
try { | ||
response = await authInstance({ | ||
url: `${microappsAdminUrl}/api/service/import`, | ||
method: 'POST', | ||
headers: { | ||
'content-type': `multipart/form-data; boundary=${form._boundary}`, | ||
}, | ||
data: form, | ||
}); | ||
} catch (error) { | ||
throw error.stack; | ||
} | ||
const notificationId = getNotificationId.id; | ||
await assert.deepStrictEqual( | ||
response.status, | ||
200, | ||
`Response status ${response.status} doesn't match expected 200` | ||
); | ||
return response; | ||
} | ||
return notificationId; | ||
} | ||
/** | ||
* Rename integration | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} integrationName - Name of integration | ||
* @param {string} newIntegrationName - New Name of integration | ||
* @param {string} integrationConfiguration - Configuration for integration | ||
*/ | ||
/** | ||
* Run a Event | ||
* @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 App | ||
* @param {string} notificationName - Name of Notification | ||
*/ | ||
async runEvent({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
appName, | ||
notificationName, | ||
}: RunEvent) { | ||
let notifications; | ||
const integrationId = await this.getIntegrationId({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
}); | ||
const appId = await this.getMicroAppId({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
appName, | ||
}); | ||
const notificationId = await this.getNotificationId({ | ||
authInstance, | ||
appId, | ||
microappsAdminUrl, | ||
notificationName, | ||
}); | ||
await this.runNotificationEvent({ | ||
authInstance, | ||
microappsAdminUrl, | ||
notificationId, | ||
}); | ||
for (let i = 0; i < 10; i++) { | ||
notifications = await this.getNotifications({ | ||
async renameIntegration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
appId, | ||
}); | ||
integrationName, | ||
newIntegrationName, | ||
integrationConfiguration, | ||
}: RenameIntegration) { | ||
const integrationId = await this.getStatusIntegration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
}); | ||
const running = notifications.data[0].running; | ||
await this.updateintegrationConfiguration({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
integrationConfiguration, | ||
}); | ||
if ((await running) === false) { | ||
break; | ||
} | ||
const integrations = await this.getIntegrations({ | ||
authInstance, | ||
microappsAdminUrl, | ||
}); | ||
const integrationsData = integrations.data; | ||
let integrationDetail; | ||
try { | ||
integrationDetail = integrationsData.filter((e: { title: string; id: string }) => { | ||
return e.title === integrationName && e.id === newIntegrationName; | ||
}); | ||
} catch (error) { | ||
throw new Error( | ||
await paramsCheck({ | ||
params: { integrationDetail, integrationsData }, | ||
functionType: 'filter', | ||
source: 'integrationsData', | ||
}) | ||
); | ||
} | ||
await new Promise((resolve) => setTimeout(resolve, 5000)); | ||
console.log( | ||
`Integration ${integrationName} with id: ${integrationDetail[0].id} was renamed to: ${integrationsData[0].title}` | ||
); | ||
} | ||
const lastRunStatus = notifications.data[0].lastRunStatus; | ||
if ((await lastRunStatus) !== "SUCCESS") { | ||
throw new Error("Event run failed!"); | ||
} | ||
} | ||
async checkAppMissconfigurations({ | ||
authInstance, | ||
microappsAdminUrl, | ||
appId, | ||
}: CheckAppMissconfigurations) { | ||
const response = await this.integrityCheck({ | ||
authInstance, | ||
microappsAdminUrl, | ||
}); | ||
const responseBody = response.data; | ||
const missconfigurations: any = responseBody.filter( | ||
(e: { appId: string }) => e.appId === appId | ||
); | ||
/** | ||
* Export Application | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} appId - Id of target App | ||
* @param {string} pathToFile - path where file should be saved | ||
*/ | ||
if (!Array.isArray(missconfigurations) || !missconfigurations.length) { | ||
console.log(`appId: ${appId} has no missconfigurations`); | ||
async exportApp({ authInstance, microappsAdminUrl, appId, pathToFile }: ExportApp) { | ||
let response; | ||
try { | ||
response = await authInstance({ | ||
method: 'GET', | ||
url: `${microappsAdminUrl}/api/app/${appId}/export`, | ||
responseType: 'stream', | ||
}); | ||
} catch (error) { | ||
throw error.stack; | ||
} | ||
await response.data.pipe(fs.createWriteStream(path.resolve(__dirname, pathToFile))); | ||
} | ||
console.log("missconfigurations: ", missconfigurations); | ||
} | ||
/** | ||
* Get Id of Microapp | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} integrationId - Name of integration | ||
* @param {string} appName - Name Application | ||
*/ | ||
//TO-DO add config as parametr | ||
async addSubscriber({ authInstance, appId, user, config }: AddSubscriber) { | ||
const { | ||
microappsAdminUrl, | ||
citrixCloudCustomerId, | ||
cwaAPI, | ||
workspaceIdentityProvider, | ||
} = config; | ||
// Get Domains | ||
const domains = await this.getDomain({ | ||
authInstance, | ||
cwaAPI, | ||
citrixCloudCustomerId, | ||
workspaceIdentityProvider, | ||
}); | ||
async getMicroAppId({ authInstance, microappsAdminUrl, integrationId, appName }: GetMicroAppId) { | ||
let apps; | ||
try { | ||
apps = await this.getApps({ authInstance, microappsAdminUrl }); | ||
const appsData = apps.data; | ||
const getAppDetail = appsData.filter( | ||
(app: { app: { title: string; serviceId: string } }) => | ||
app.app.title === appName && app.app.serviceId === integrationId | ||
); | ||
const actionSubscribe = "Add"; | ||
let domainName; | ||
let forestName; | ||
let idpType; | ||
switch (workspaceIdentityProvider) { | ||
case "ad": | ||
case "netscaler": | ||
domainName = domains.data.domains[0].domainName; | ||
forestName = domains.data.domains[0].forestName; | ||
idpType = "AD"; | ||
break; | ||
case "aad": | ||
const domainsData = domains.data; | ||
const domainDetail = domainsData.filter( | ||
(domain: { idpType: string }) => { | ||
return domain.idpType === "AzureAd"; | ||
} | ||
); | ||
domainName = "todo"; | ||
forestName = domainDetail[0].idpProperties.tid; | ||
idpType = "AZUREAD"; | ||
break; | ||
case "okta": | ||
domainName = null; | ||
forestName = null; | ||
idpType = "OKTA"; | ||
break; | ||
default: | ||
console.log( | ||
`Adding subscribers is currently not implemented for this idp: ${workspaceIdentityProvider}` | ||
); | ||
break; | ||
return getAppDetail[0].id; | ||
} catch (e) { | ||
console.log(e); | ||
return null; | ||
} | ||
} | ||
// Get user | ||
const users = await this.getUsers({ | ||
authInstance, | ||
cwaAPI, | ||
domainName, | ||
forestName, | ||
appId, | ||
query: user, | ||
citrixCloudCustomerId, | ||
idpType, | ||
}); | ||
let userDetail = users.data.results; | ||
/** | ||
* Get Id of Notification | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} appId - Name of App | ||
* @param {string} notificationName - Name of Notification | ||
*/ | ||
if (userDetail.length > 1) { | ||
// filter group to subscribe | ||
const userData = users.data.results; | ||
userDetail = userData.filter((e: { accountName: string }) => { | ||
return e.accountName === user; | ||
}); | ||
} | ||
async getNotificationId({ authInstance, microappsAdminUrl, appId, notificationName }: GetNotificationId) { | ||
const notifications = await this.getNotifications({ | ||
authInstance, | ||
microappsAdminUrl, | ||
appId, | ||
}); | ||
// Update Subscribers | ||
await this.updateSubscribers({ | ||
authInstance, | ||
microappsAdminUrl, | ||
assign: actionSubscribe, | ||
userDetail, | ||
appId, | ||
domainName, | ||
forestName, | ||
workspaceIdentityProvider, | ||
}); | ||
const notificationsData = notifications.data; | ||
await this.getSubscribers({ | ||
authInstance, | ||
microappsAdminUrl, | ||
appId, | ||
}); | ||
} | ||
async addSubscribers({ | ||
authInstance, | ||
integrationName, | ||
microapps, | ||
microappsAdminUrl, | ||
config, | ||
}: AddSubscribers) { | ||
const integrationId = await this.getIntegrationId({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
}); | ||
let getNotificationId; | ||
let notificationId; | ||
try { | ||
getNotificationId = notificationsData.find((e: { label: string }) => { | ||
return e.label === notificationName; | ||
}); | ||
const subscribe = async ({ | ||
microapps, | ||
microapp, | ||
authInstance, | ||
integrationId, | ||
}: Subscribe) => { | ||
console.log(`[${integrationName}] - Adding subscribers for: ${microapp}`); | ||
const subscribers = microapps[microapp].subscribers; | ||
const microappId = await this.getMicroAppId({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
appName: microapp, | ||
}); | ||
for (const subscriber of subscribers) { | ||
await this.addSubscriber({ | ||
authInstance, | ||
appId: microappId, | ||
user: subscriber, | ||
config, | ||
}); | ||
} | ||
return { microapp }; | ||
}; | ||
notificationId = getNotificationId.id; | ||
} catch (error) { | ||
throw new Error( | ||
await paramsCheck({ | ||
params: { getNotificationId, notificationId, notificationsData }, | ||
functionType: 'find', | ||
source: 'notificationsData', | ||
}) | ||
); | ||
} | ||
const microappsPromises = []; | ||
for (const microapp in microapps) { | ||
microappsPromises.push( | ||
subscribe({ microapps, microapp, authInstance, integrationId }) | ||
); | ||
return notificationId; | ||
} | ||
return await Promise.all(microappsPromises); | ||
} | ||
/** | ||
* Import Integration from an exported Integration file | ||
* | ||
* @param {Page} page - Methods to interact with a single tab or extension background page in Browser | ||
* @param {string} filePath - Path to the exported Integration file that will be imported | ||
*/ | ||
async importIntegrationUI({ | ||
page, | ||
microappsAdminUrl, | ||
filePath, | ||
}: ImportIntegrationUI) { | ||
await page.waitForSelector('[data-testid="add-integration-button"]'); | ||
await page.click('[data-testid="add-integration-button"]'); | ||
/** | ||
* Run a Event | ||
* @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 App | ||
* @param {string} notificationName - Name of Notification | ||
*/ | ||
await page.waitForSelector('[data-testid="new-integration-upload"]'); | ||
await page.click('[data-testid="new-integration-upload"]'); | ||
async runEvent({ authInstance, microappsAdminUrl, integrationName, appName, notificationName }: RunEvent) { | ||
let notifications; | ||
const integrationId = await this.getIntegrationId({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
}); | ||
const uploadFile: any = await page.$("input[type=file]"); | ||
await uploadFile.setInputFiles(path.resolve(__dirname, filePath)); | ||
const appId = await this.getMicroAppId({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
appName, | ||
}); | ||
await page.waitForSelector('[data-testid="upload-submit-button"]'); | ||
await page.click('[data-testid="upload-submit-button"]'); | ||
const notificationId = await this.getNotificationId({ | ||
authInstance, | ||
appId, | ||
microappsAdminUrl, | ||
notificationName, | ||
}); | ||
await page.waitForResponse( | ||
(response: { url: () => string; status: () => number }) => | ||
response.url() === `${microappsAdminUrl}/api/service/import` && | ||
response.status() === 200 | ||
); | ||
} | ||
await this.runNotificationEvent({ | ||
authInstance, | ||
microappsAdminUrl, | ||
notificationId, | ||
}); | ||
/** | ||
* Imports MicroApp to @param integrationName Integration from an exported MicroApp file | ||
* | ||
* @param {Page} page - Methods to interact with a single tab or extension background page in Browser | ||
* @param {string} microappsAdminUrl - MicroApps Admin URL | ||
* @param {string} filePath - Path to the exported MicroApp file that will be imported | ||
* @param {string} integrationName - Name of Integration in which the MicroApp will be imported | ||
*/ | ||
async importMicroAppUI({ | ||
page, | ||
microappsAdminUrl, | ||
filePath, | ||
integrationName, | ||
}: ImportMicroAppUI) { | ||
await page.waitForSelector( | ||
`//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="toggle-integration-options-dropdown"]` | ||
); | ||
for (let i = 0; i < 10; i++) { | ||
notifications = await this.getNotifications({ | ||
authInstance, | ||
microappsAdminUrl, | ||
appId, | ||
}); | ||
await page.waitForSelector( | ||
`//div[@data-testid="integration-name-${integrationName}"] //button[@data-testid="open-import-app"]` | ||
); | ||
await page.click( | ||
`//div[@data-testid="integration-name-${integrationName}"] //button[@data-testid="open-import-app"]` | ||
); | ||
const running = notifications.data[0].running; | ||
const uploadFile: any = await page.$("input[type=file]"); | ||
await uploadFile.setInputFiles(path.resolve(__dirname, filePath)); | ||
await page.waitForSelector('[data-testid="upload-submit-button"]'); | ||
await page.click('[data-testid="upload-submit-button"]'); | ||
if ((await running) === false) { | ||
break; | ||
} | ||
await page.waitForResponse( | ||
(response: { url: () => string; status: () => number }) => | ||
response.url() === `${microappsAdminUrl}/api/app` && | ||
response.status() === 200 | ||
); | ||
} | ||
await new Promise((resolve) => setTimeout(resolve, 5000)); | ||
} | ||
const lastRunStatus = notifications.data[0].lastRunStatus; | ||
if ((await lastRunStatus) !== 'SUCCESS') { | ||
throw new Error('Event run failed!'); | ||
} | ||
} | ||
/** | ||
* Exports @param integrationName integation | ||
* | ||
* @param {Page} page - Methods to interact with a single tab or extension background page in Browser | ||
* @param {string} integrationName - Name of Integration which will be exported | ||
*/ | ||
async exportIntegrationUI({ page, integrationName }: ExportIntegrationUI) { | ||
await page.waitForSelector( | ||
`//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="toggle-integration-options-dropdown"]` | ||
); | ||
async checkAppMissconfigurations({ authInstance, microappsAdminUrl, appId }: CheckAppMissconfigurations) { | ||
const response = await this.integrityCheck({ | ||
authInstance, | ||
microappsAdminUrl, | ||
}); | ||
const responseBody = response.data; | ||
await page.waitForSelector( | ||
`//div[@data-testid="integration-name-${integrationName}"] //button[@data-testid="open-export-integration"]` | ||
); | ||
await page.click( | ||
`//div[@data-testid="integration-name-${integrationName}"] //button[@data-testid="open-export-integration"]` | ||
); | ||
let missconfigurations; | ||
try { | ||
missconfigurations = responseBody.filter((e: { appId: string }) => e.appId === appId); | ||
} catch (error) { | ||
throw new Error( | ||
await paramsCheck({ | ||
params: { missconfigurations, responseBody }, | ||
functionType: 'filter', | ||
source: 'responseBody', | ||
}) | ||
); | ||
} | ||
await page.waitForSelector(`//legend[(text()= 'Include Microapps')]`); | ||
if (!Array.isArray(missconfigurations) || !missconfigurations.length) { | ||
console.log(`appId: ${appId} has no missconfigurations`); | ||
} | ||
await page.click( | ||
`//button[@data-testid="export-integration-commit-button"]` | ||
); | ||
const download = await page.waitForEvent("download"); | ||
if ((await download.path()) === null) { | ||
throw new Error("No file was downloaded"); | ||
console.log('missconfigurations: ', missconfigurations); | ||
} | ||
} | ||
/** | ||
* Export @param appName MicroApp from @param integrationName Integration | ||
* | ||
* @param {Page} page - Methods to interact with a single tab or extension background page in Browser | ||
* @param {string} integrationName - Name of Integration in which the MicroApp will be imported | ||
* @param {string} appName - Name of MicroApp that will be exported | ||
*/ | ||
async exportMicroAppsUI({ | ||
page, | ||
integrationName, | ||
appName, | ||
}: ExportMicroAppUI) { | ||
await page.waitForSelector( | ||
`//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[starts-with(@class, "PlainButton")]` | ||
); | ||
await page.waitForSelector( | ||
`//div[@data-testid="integration-name-${integrationName}"] //tr[descendant::a[contains(text(), "${appName}")]] //button[@data-testid="do-app-export"]` | ||
); | ||
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"); | ||
//TO-DO add config as parametr | ||
async addSubscriber({ authInstance, appId, user, config }: AddSubscriber) { | ||
const { microappsAdminUrl, citrixCloudCustomerId, cwaAPI, workspaceIdentityProvider } = config; | ||
// Get Domains | ||
const domains = await this.getDomain({ | ||
authInstance, | ||
cwaAPI, | ||
citrixCloudCustomerId, | ||
workspaceIdentityProvider, | ||
}); | ||
if ((await download.path()) === null) { | ||
throw new Error("No file was downloaded"); | ||
} | ||
} | ||
const actionSubscribe = 'Add'; | ||
let domainName; | ||
let forestName; | ||
let idpType; | ||
/** | ||
* Returns last duration of Synchronization | ||
* | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} integrationName - Name of Integration | ||
*/ | ||
async getLastTimeSync({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
}: GetLastSyncTime) { | ||
const regex = new RegExp(/\d*:\d*:\d*.\d*/); | ||
switch (workspaceIdentityProvider) { | ||
case 'ad': | ||
case 'netscaler': | ||
domainName = domains.data.domains[0].domainName; | ||
forestName = domains.data.domains[0].forestName; | ||
idpType = 'AD'; | ||
break; | ||
case 'aad': | ||
const domainsData = domains.data; | ||
let domainDetail; | ||
try { | ||
const domainDetail = domainsData.filter((domain: { idpType: string }) => { | ||
return domain.idpType === 'AzureAd'; | ||
}); | ||
domainName = 'todo'; | ||
forestName = domainDetail[0].idpProperties.tid; | ||
idpType = 'AZUREAD'; | ||
} catch (error) { | ||
throw new Error( | ||
await paramsCheck({ | ||
params: { domainDetail, domainsData }, | ||
functionType: 'filter', | ||
source: 'domainsData', | ||
}) | ||
); | ||
} | ||
break; | ||
case 'okta': | ||
domainName = null; | ||
forestName = null; | ||
idpType = 'OKTA'; | ||
break; | ||
default: | ||
console.log( | ||
`Adding subscribers is currently not implemented for this idp: ${workspaceIdentityProvider}` | ||
); | ||
break; | ||
} | ||
const integrationId = await this.getIntegrationId({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
}); | ||
// Get user | ||
const users = await this.getUsers({ | ||
authInstance, | ||
cwaAPI, | ||
domainName, | ||
forestName, | ||
appId, | ||
query: user, | ||
citrixCloudCustomerId, | ||
idpType, | ||
}); | ||
let userDetail = users.data.results; | ||
const integrationType = await this.getIntegrationType({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
}); | ||
if (userDetail.length > 1) { | ||
// filter group to subscribe | ||
const userData = users.data.results; | ||
try { | ||
userDetail = userData.filter((e: { accountName: string }) => { | ||
return e.accountName === user; | ||
}); | ||
} catch (error) { | ||
throw new Error( | ||
await paramsCheck({ | ||
params: { userDetail, userData }, | ||
functionType: 'filter', | ||
source: 'userData', | ||
}) | ||
); | ||
} | ||
} | ||
const logs = await this.getIntegrationLog({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
integrationType, | ||
}); | ||
// Update Subscribers | ||
await this.updateSubscribers({ | ||
authInstance, | ||
microappsAdminUrl, | ||
assign: actionSubscribe, | ||
userDetail, | ||
appId, | ||
domainName, | ||
forestName, | ||
workspaceIdentityProvider, | ||
}); | ||
for (const line of logs.data.data) { | ||
if (line.message.includes("Service synchronization finished in")) { | ||
return line.message.match(regex)[0]; | ||
} | ||
await this.getSubscribers({ | ||
authInstance, | ||
microappsAdminUrl, | ||
appId, | ||
}); | ||
} | ||
} | ||
async addSubscribers({ authInstance, integrationName, microapps, microappsAdminUrl, config }: AddSubscribers) { | ||
const integrationId = await this.getIntegrationId({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
}); | ||
/** | ||
* 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, | ||
}: GetComponentId) { | ||
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: { title: any }) => app.title === pageName | ||
); | ||
const components = getPage[0].components; | ||
const getComponent = components.filter( | ||
(component: { label: any }) => component.label === componentLabel | ||
); | ||
const componentId = getComponent[0].id; | ||
return componentId; | ||
} | ||
} | ||
const subscribe = async ({ microapps, microapp, authInstance, integrationId }: Subscribe) => { | ||
console.log(`[${integrationName}] - Adding subscribers for: ${microapp}`); | ||
const subscribers = microapps[microapp].subscribers; | ||
const microappId = await this.getMicroAppId({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
appName: microapp, | ||
}); | ||
for (const subscriber of subscribers) { | ||
await this.addSubscriber({ | ||
authInstance, | ||
appId: microappId, | ||
user: subscriber, | ||
config, | ||
}); | ||
} | ||
return { microapp }; | ||
}; | ||
export type MicroappsAdminLogin = { | ||
page: Page; | ||
url: string; | ||
username: string; | ||
password: string; | ||
mfa: any | boolean; | ||
secretKey: string; | ||
}; | ||
const microappsPromises = []; | ||
for (const microapp in microapps) { | ||
microappsPromises.push(subscribe({ microapps, microapp, authInstance, integrationId })); | ||
} | ||
export type GetIntegrationId = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
}; | ||
return await Promise.all(microappsPromises); | ||
} | ||
/** | ||
* Import Integration from an exported Integration file | ||
* | ||
* @param {Page} page - Methods to interact with a single tab or extension background page in Browser | ||
* @param {string} filePath - Path to the exported Integration file that will be imported | ||
*/ | ||
async importIntegrationUI({ page, microappsAdminUrl, filePath }: ImportIntegrationUI) { | ||
await page.waitForSelector('[data-testid="add-integration-button"]'); | ||
await page.click('[data-testid="add-integration-button"]'); | ||
export type OauthLogout = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
repeatCount?: number; | ||
}; | ||
await page.waitForSelector('[data-testid="new-integration-upload"]'); | ||
await page.click('[data-testid="new-integration-upload"]'); | ||
export type WaitForSync = { | ||
getIntegration: () => any; | ||
synchronizationType: string; | ||
}; | ||
const uploadFile: any = await page.$('input[type=file]'); | ||
await uploadFile.setInputFiles(path.resolve(__dirname, filePath)); | ||
export type RunSynchronization = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
synchronizationType: string; | ||
}; | ||
await page.waitForSelector('[data-testid="upload-submit-button"]'); | ||
await page.click('[data-testid="upload-submit-button"]'); | ||
export type CreateHTTPIntegration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
integrationConfiguration: any; | ||
}; | ||
await page.waitForResponse( | ||
(response: { url: () => string; status: () => number }) => | ||
response.url() === `${microappsAdminUrl}/api/service/import` && response.status() === 200 | ||
); | ||
} | ||
export type WaitForProcessStatus = { | ||
authInstance: any; | ||
getProcessStatus: () => any; | ||
status: string; | ||
microappsAdminUrl: string; | ||
processId: string; | ||
}; | ||
/** | ||
* Imports MicroApp to @param integrationName Integration from an exported MicroApp file | ||
* | ||
* @param {Page} page - Methods to interact with a single tab or extension background page in Browser | ||
* @param {string} microappsAdminUrl - MicroApps Admin URL | ||
* @param {string} filePath - Path to the exported MicroApp file that will be imported | ||
* @param {string} integrationName - Name of Integration in which the MicroApp will be imported | ||
*/ | ||
async importMicroAppUI({ page, microappsAdminUrl, filePath, integrationName }: ImportMicroAppUI) { | ||
await page.waitForSelector( | ||
`//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="toggle-integration-options-dropdown"]` | ||
); | ||
export type CreateJavaIntegration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
data: string; | ||
integrationConfiguration: any; | ||
withEntities: boolean; | ||
serviceType: any; | ||
serviceKey: string; | ||
name: string; | ||
}; | ||
await page.waitForSelector( | ||
`//div[@data-testid="integration-name-${integrationName}"] //button[@data-testid="open-import-app"]` | ||
); | ||
await page.click( | ||
`//div[@data-testid="integration-name-${integrationName}"] //button[@data-testid="open-import-app"]` | ||
); | ||
export type GetIntegrationType = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
}; | ||
const uploadFile: any = await page.$('input[type=file]'); | ||
await uploadFile.setInputFiles(path.resolve(__dirname, filePath)); | ||
await page.waitForSelector('[data-testid="upload-submit-button"]'); | ||
await page.click('[data-testid="upload-submit-button"]'); | ||
export type GetStatusIntegration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
}; | ||
await page.waitForResponse( | ||
(response: { url: () => string; status: () => number }) => | ||
response.url() === `${microappsAdminUrl}/api/app` && response.status() === 200 | ||
); | ||
} | ||
export type ImportIntegration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
pathToFile: string; | ||
}; | ||
/** | ||
* Exports @param integrationName integation | ||
* | ||
* @param {Page} page - Methods to interact with a single tab or extension background page in Browser | ||
* @param {string} integrationName - Name of Integration which will be exported | ||
*/ | ||
async exportIntegrationUI({ page, integrationName }: ExportIntegrationUI) { | ||
await page.waitForSelector( | ||
`//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="toggle-integration-options-dropdown"]` | ||
); | ||
export type RenameIntegration = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
newIntegrationName: string; | ||
integrationConfiguration: string; | ||
}; | ||
await page.waitForSelector( | ||
`//div[@data-testid="integration-name-${integrationName}"] //button[@data-testid="open-export-integration"]` | ||
); | ||
await page.click( | ||
`//div[@data-testid="integration-name-${integrationName}"] //button[@data-testid="open-export-integration"]` | ||
); | ||
export type ExportApp = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
appId: string; | ||
pathToFile: string; | ||
}; | ||
await page.waitForSelector(`//legend[(text()= 'Include Microapps')]`); | ||
export type GetMicroAppId = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationId: string; | ||
appName: string; | ||
}; | ||
await page.click(`//button[@data-testid="export-integration-commit-button"]`); | ||
export type GetNotificationId = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
appId: string; | ||
notificationName: string; | ||
}; | ||
const download = await page.waitForEvent('download'); | ||
export type RunEvent = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
appName: string; | ||
notificationName: string; | ||
}; | ||
if ((await download.path()) === null) { | ||
throw new Error('No file was downloaded'); | ||
} | ||
} | ||
export type CheckAppMissconfigurations = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
appId: string; | ||
}; | ||
/** | ||
* Export @param appName MicroApp from @param integrationName Integration | ||
* | ||
* @param {Page} page - Methods to interact with a single tab or extension background page in Browser | ||
* @param {string} integrationName - Name of Integration in which the MicroApp will be imported | ||
* @param {string} appName - Name of MicroApp that will be exported | ||
*/ | ||
async exportMicroAppsUI({ page, integrationName, appName }: ExportMicroAppUI) { | ||
await page.waitForSelector( | ||
`//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[starts-with(@class, "PlainButton")]` | ||
); | ||
await page.waitForSelector( | ||
`//div[@data-testid="integration-name-${integrationName}"] //tr[descendant::a[contains(text(), "${appName}")]] //button[@data-testid="do-app-export"]` | ||
); | ||
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'); | ||
export type ImportIntegrationUI = { | ||
page: Page; | ||
microappsAdminUrl: string; | ||
filePath: string; | ||
}; | ||
if ((await download.path()) === null) { | ||
throw new Error('No file was downloaded'); | ||
} | ||
} | ||
export type ImportMicroAppUI = { | ||
page: Page; | ||
microappsAdminUrl: string; | ||
filePath: string; | ||
integrationName: string; | ||
}; | ||
export type AddSubscriber = { | ||
authInstance: any; | ||
appId: string; | ||
user: string; | ||
config: any; | ||
}; | ||
/** | ||
* Returns last duration of Synchronization | ||
* | ||
* @param {Object} authInstance - Authorized instance for API calls | ||
* @param {string} microappsAdminUrl - Microapps admin url | ||
* @param {string} integrationName - Name of Integration | ||
*/ | ||
async getLastTimeSync({ authInstance, microappsAdminUrl, integrationName }: GetLastSyncTime) { | ||
const regex = new RegExp(/\d*:\d*:\d*.\d*/); | ||
export type AddSubscribers = { | ||
authInstance: any; | ||
integrationName: string; | ||
microappsAdminUrl: string; | ||
microapps?: any; | ||
config: any; | ||
}; | ||
const integrationId = await this.getIntegrationId({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
}); | ||
export type Subscribe = { | ||
authInstance: any; | ||
microapps: any; | ||
microapp: string; | ||
integrationId: string; | ||
}; | ||
const integrationType = await this.getIntegrationType({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationName, | ||
}); | ||
export type ExportIntegrationUI = { | ||
page: Page; | ||
integrationName: string; | ||
}; | ||
const logs = await this.getIntegrationLog({ | ||
authInstance, | ||
microappsAdminUrl, | ||
integrationId, | ||
integrationType, | ||
}); | ||
export type ExportMicroAppUI = { | ||
page: Page; | ||
appName: string; | ||
integrationName: string; | ||
}; | ||
for (const line of logs.data.data) { | ||
if (line.message.includes('Service synchronization finished in')) { | ||
return line.message.match(regex)[0]; | ||
} | ||
} | ||
} | ||
export type GetLastSyncTime = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
}; | ||
/** | ||
* 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, | ||
}: GetComponentId) { | ||
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; | ||
export type GetComponentId = { | ||
authInstance: any; | ||
microappsAdminUrl: string; | ||
integrationName: string; | ||
appName: string; | ||
pageName: string; | ||
componentLabel: string; | ||
}; | ||
let getPage; | ||
let components; | ||
try { | ||
getPage = pagesData.filter((app: { title: string }) => app.title === pageName); | ||
components = getPage[0].components; | ||
} catch (error) { | ||
throw new Error( | ||
await paramsCheck({ | ||
params: { getPage, components, pagesData }, | ||
functionType: 'filter', | ||
source: 'pagesData', | ||
}) | ||
); | ||
} | ||
let getComponent; | ||
let componentId; | ||
try { | ||
getComponent = components.filter((component: { label: string }) => component.label === componentLabel); | ||
componentId = getComponent[0].id; | ||
} catch (error) { | ||
throw new Error( | ||
await paramsCheck({ | ||
params: { getComponent, componentId, components }, | ||
functionType: 'filter', | ||
source: 'components', | ||
}) | ||
); | ||
} | ||
return componentId; | ||
} | ||
} |
@@ -1,427 +0,328 @@ | ||
import { Page, BrowserContext } from "playwright"; | ||
import axios from "axios"; | ||
import { getCookie } from "./helpers"; | ||
import axios from 'axios'; | ||
import { getCookie } from './helpers'; | ||
import type { | ||
Login, | ||
CreateDsAuthInstance, | ||
GoToActions, | ||
StartAction, | ||
SkipTour, | ||
GetDsauthTokens, | ||
GetFeedCardButton, | ||
GetFeedNotifications, | ||
GetOneTimeToken, | ||
GetTokens, | ||
GetUserData, | ||
WaitForFeedCardId, | ||
WaitForPopUp, | ||
} from './types/workspace'; | ||
/** Class representing a Workspace. */ | ||
export class Workspace { | ||
constructor() {} | ||
/** | ||
* Login to Workspace | ||
* @param {Object} page - Methods to interact with a single tab or extension background page in Browser | ||
* @param {string} workspaceUrl - Workspace login url | ||
* @param {string} workspaceUsername - Workspace Username | ||
* @param {string} workspacePassword - Workspace Password | ||
* @param {string} workspaceIdentityProvider - Identity provider (ad | netscaler | aad) | ||
*/ | ||
async login({ | ||
page, | ||
workspaceUrl, | ||
workspaceUsername, | ||
workspacePassword, | ||
workspaceIdentityProvider, | ||
}: Login) { | ||
console.log("Login to Workspace", new Date()); | ||
await page.goto(workspaceUrl, { waitUntil: "domcontentloaded" }); | ||
switch (workspaceIdentityProvider) { | ||
case "ad": | ||
await page.waitForSelector("#username"); | ||
await page.type("#username", workspaceUsername); | ||
await page.waitForSelector("#password"); | ||
await page.type("#password", workspacePassword); | ||
await page.waitForSelector("#loginBtn"); | ||
await page.click("#loginBtn"); | ||
break; | ||
case "netscaler": | ||
await page.waitForSelector("#login"); | ||
await page.type("#login", workspaceUsername); | ||
await page.waitForSelector("#passwd"); | ||
await page.type("#passwd", workspacePassword); | ||
await page.click("#nsg-x1-logon-button"); | ||
break; | ||
case "aad": | ||
await page.waitForSelector('input[name="loginfmt"]'); | ||
await page.type('input[name="loginfmt"]', workspaceUsername); | ||
await page.waitForSelector('input[value="Next"]'); | ||
await page.click('input[value="Next"]'); | ||
await page.waitForSelector('input[name="passwd"]'); | ||
await page.type('input[name="passwd"]', workspacePassword); | ||
await page.waitForSelector('input[value="Sign in"]'); | ||
await page.click('input[value="Sign in"]'); | ||
await page.waitForSelector('input[value="Yes"]'); | ||
await page.click('input[value="Yes"]'); | ||
break; | ||
case "okta": | ||
await page.waitForSelector("#okta-signin-username"); | ||
await page.type("#okta-signin-username", workspaceUsername); | ||
await page.waitForSelector("#okta-signin-password"); | ||
await page.type("#okta-signin-password", workspacePassword); | ||
await page.waitForSelector("#okta-signin-submit"); | ||
await page.click("#okta-signin-submit"); | ||
break; | ||
default: | ||
console.log("Identity provider was not specified."); | ||
constructor() {} | ||
/** | ||
* Login to Workspace | ||
* @param {Object} page - Methods to interact with a single tab or extension background page in Browser | ||
* @param {string} workspaceUrl - Workspace login url | ||
* @param {string} workspaceUsername - Workspace Username | ||
* @param {string} workspacePassword - Workspace Password | ||
* @param {string} workspaceIdentityProvider - Identity provider (ad | netscaler | aad) | ||
*/ | ||
async login({ page, workspaceUrl, workspaceUsername, workspacePassword, workspaceIdentityProvider }: Login) { | ||
console.log('Login to Workspace', new Date()); | ||
await page.goto(workspaceUrl, { waitUntil: 'domcontentloaded' }); | ||
switch (workspaceIdentityProvider) { | ||
case 'ad': | ||
await page.waitForSelector('#username'); | ||
await page.type('#username', workspaceUsername); | ||
await page.waitForSelector('#password'); | ||
await page.type('#password', workspacePassword); | ||
await page.waitForSelector('#loginBtn'); | ||
await page.click('#loginBtn'); | ||
break; | ||
case 'netscaler': | ||
await page.waitForSelector('#login'); | ||
await page.type('#login', workspaceUsername); | ||
await page.waitForSelector('#passwd'); | ||
await page.type('#passwd', workspacePassword); | ||
await page.click('#nsg-x1-logon-button'); | ||
break; | ||
case 'aad': | ||
await page.waitForSelector('input[name="loginfmt"]'); | ||
await page.type('input[name="loginfmt"]', workspaceUsername); | ||
await page.waitForSelector('input[value="Next"]'); | ||
await page.click('input[value="Next"]'); | ||
await page.waitForSelector('input[name="passwd"]'); | ||
await page.type('input[name="passwd"]', workspacePassword); | ||
await page.waitForSelector('input[value="Sign in"]'); | ||
await page.click('input[value="Sign in"]'); | ||
await page.waitForSelector('input[value="Yes"]'); | ||
await page.click('input[value="Yes"]'); | ||
break; | ||
case 'okta': | ||
await page.waitForSelector('#okta-signin-username'); | ||
await page.type('#okta-signin-username', workspaceUsername); | ||
await page.waitForSelector('#okta-signin-password'); | ||
await page.type('#okta-signin-password', workspacePassword); | ||
await page.waitForSelector('#okta-signin-submit'); | ||
await page.click('#okta-signin-submit'); | ||
break; | ||
default: | ||
console.log('Identity provider was not specified.'); | ||
} | ||
await page.waitForSelector('#content', { timeout: 90000 }); | ||
await this.skipTour({ page }); | ||
} | ||
await page.waitForSelector("#content", { timeout: 90000 }); | ||
await this.skipTour({ page }); | ||
} | ||
/** | ||
* Skip Tour | ||
* @param {Object} page - Methods to interact with a single tab or extension background page in Browser | ||
*/ | ||
/** | ||
* Skip Tour | ||
* @param {Object} page - Methods to interact with a single tab or extension background page in Browser | ||
*/ | ||
async skipTour({ page }: SkipTour) { | ||
try { | ||
await page.waitForSelector(".cta-link a", { timeout: 5000 }); | ||
const link = await page.$(".cta-link a"); | ||
async skipTour({ page }: SkipTour) { | ||
try { | ||
await page.waitForSelector('.cta-link a', { timeout: 5000 }); | ||
const link = await page.$('.cta-link a'); | ||
if (await link) { | ||
await page.click(".cta-link a"); | ||
} | ||
} catch (error) {} | ||
} | ||
if (await link) { | ||
await page.click('.cta-link a'); | ||
} | ||
} catch (error) {} | ||
} | ||
/** | ||
* Go to Actions | ||
* @param {Object} page - Methods to interact with a single tab or extension background page in Browser | ||
*/ | ||
/** | ||
* Go to Actions | ||
* @param {Object} page - Methods to interact with a single tab or extension background page in Browser | ||
*/ | ||
async goToActions({ page }: GoToActions) { | ||
await page.waitForSelector("span >> text=Actions"); | ||
await page.click("span >> text=Actions"); | ||
await page.waitForLoadState("networkidle"); | ||
} | ||
async goToActions({ page }: GoToActions) { | ||
await page.waitForSelector('span >> text=Actions'); | ||
await page.click('span >> text=Actions'); | ||
await page.waitForLoadState('networkidle'); | ||
} | ||
/** | ||
* Start Action | ||
* @param {Object} page - Methods to interact with a single tab or extension background page in Browser | ||
* @param {string} actionName - name of Action what should be executed | ||
* @param {string} integrationName - name of Integration the action belongs to | ||
*/ | ||
/** | ||
* Start Action | ||
* @param {Object} page - Methods to interact with a single tab or extension background page in Browser | ||
* @param {string} actionName - name of Action what should be executed | ||
* @param {string} integrationName - name of Integration the action belongs to | ||
*/ | ||
async startAction({ page, actionName, integrationName }: StartAction) { | ||
console.log(`Choosing action ${actionName}`, new Date()); | ||
await page.click( | ||
`//button[descendant::div[@title="${integrationName}"]] //div[contains(text(), "${actionName}")]` | ||
); | ||
} | ||
async startAction({ page, actionName, integrationName }: StartAction) { | ||
console.log(`Choosing action ${actionName}`, new Date()); | ||
await page.click( | ||
`//button[descendant::div[@title="${integrationName}"]] //div[contains(text(), "${actionName}")]` | ||
); | ||
} | ||
/** | ||
* Get Feed Notifications | ||
* @param {Object} page - Methods to interact with a single tab or extension background page in Browser | ||
*/ | ||
/** | ||
* Get Feed Notifications | ||
* @param {Object} page - Methods to interact with a single tab or extension background page in Browser | ||
*/ | ||
async getFeedNotifications({ page }: GetFeedNotifications) { | ||
await page.waitForSelector("select"); | ||
await page.selectOption("select", "CREATED_AT"); | ||
const notifications = await page.waitForResponse( | ||
(response: any) => | ||
response.url().match(new RegExp("notification")) && | ||
response.status() === 200 | ||
); | ||
const notificationsBody = await notifications.json(); | ||
return notificationsBody; | ||
} | ||
async getFeedNotifications({ page }: GetFeedNotifications) { | ||
await page.waitForSelector('select'); | ||
await page.selectOption('select', 'CREATED_AT'); | ||
const notifications = await page.waitForResponse( | ||
(response: any) => response.url().match(new RegExp('notification')) && response.status() === 200 | ||
); | ||
const notificationsBody = await notifications.json(); | ||
return notificationsBody; | ||
} | ||
/** | ||
* Wait for FeedCard to show up in Notifications | ||
* | ||
* @param {Object} page - Methods to interact with a single tab or extension background page in Browser | ||
* @param {string} recordId - Id of the record | ||
* @param {number} repeatMax - Max number of tries to find the FeedCard | ||
* @param {number} waitTime - Time in miliseconds to wait after each try | ||
*/ | ||
async waitForFeedCardId({ | ||
page, | ||
repeatMax = 50, | ||
waitTime = 5000, | ||
recordId, | ||
notificationId = "", | ||
}: WaitForFeedCardId) { | ||
let feedCardId; | ||
for (let i = 0; i < repeatMax; i++) { | ||
if (i === repeatMax - 1) { | ||
throw new Error("Have not found expected feedcard id."); | ||
} | ||
/** | ||
* Wait for FeedCard to show up in Notifications | ||
* | ||
* @param {Object} page - Methods to interact with a single tab or extension background page in Browser | ||
* @param {string} recordId - Id of the record | ||
* @param {number} repeatMax - Max number of tries to find the FeedCard | ||
* @param {number} waitTime - Time in miliseconds to wait after each try | ||
*/ | ||
async waitForFeedCardId({ | ||
page, | ||
repeatMax = 50, | ||
waitTime = 5000, | ||
recordId, | ||
notificationId = '', | ||
}: WaitForFeedCardId) { | ||
let feedCardId; | ||
for (let i = 0; i < repeatMax; i++) { | ||
if (i === repeatMax - 1) { | ||
throw new Error('Have not found expected feedcard id.'); | ||
} | ||
const feedNotification: any = await this.getFeedNotifications({ page }); | ||
const data = feedNotification.items; | ||
const feedCardDetail = data.filter( | ||
(e: { | ||
recordId: string | string[]; | ||
source: { notification: { id: string | string[] } }; | ||
}) => { | ||
return ( | ||
e.recordId.includes(recordId) && | ||
e.source.notification.id.includes(notificationId) | ||
); | ||
} | ||
); | ||
const feedNotification: any = await this.getFeedNotifications({ page }); | ||
const data = feedNotification.items; | ||
const feedCardDetail = data.filter( | ||
(e: { recordId: string | string[]; source: { notification: { id: string | string[] } } }) => { | ||
return e.recordId.includes(recordId) && e.source.notification.id.includes(notificationId); | ||
} | ||
); | ||
try { | ||
feedCardId = feedCardDetail[0].id; | ||
} catch (error) {} | ||
try { | ||
feedCardId = feedCardDetail[0].id; | ||
} catch (error) {} | ||
await page.waitForTimeout(waitTime); | ||
await page.waitForTimeout(waitTime); | ||
if (feedCardDetail.length >= 1) { | ||
break; | ||
} | ||
if (feedCardDetail.length >= 1) { | ||
break; | ||
} | ||
} | ||
console.log(feedCardId); | ||
return feedCardId; | ||
} | ||
console.log(feedCardId); | ||
return feedCardId; | ||
} | ||
/** | ||
* Returns button on FeedCard | ||
* | ||
* @param {Object} page - Methods to interact with a single tab or extension background page in Browser | ||
* @param {string} feedCardId - Id of the FeedCard | ||
* @param {string} buttonName - Text on the Button | ||
*/ | ||
async getFeedCardButton({ page, feedCardId, buttonName }: GetFeedCardButton) { | ||
return page.$$( | ||
`xpath=//*[@id="feed-card-body-${feedCardId}"]/ancestor::div[@role="listitem"]//button//div[contains(text(), '${buttonName}')]` | ||
); | ||
} | ||
/** | ||
* Returns button on FeedCard | ||
* | ||
* @param {Object} page - Methods to interact with a single tab or extension background page in Browser | ||
* @param {string} feedCardId - Id of the FeedCard | ||
* @param {string} buttonName - Text on the Button | ||
*/ | ||
async getFeedCardButton({ page, feedCardId, buttonName }: GetFeedCardButton) { | ||
return page.$$( | ||
`xpath=//*[@id="feed-card-body-${feedCardId}"]/ancestor::div[@role="listitem"]//button//div[contains(text(), '${buttonName}')]` | ||
); | ||
} | ||
/** | ||
* Wait for success or error pop-up message | ||
* | ||
* @param {Object} page - Methods to interact with a single tab or extension background page in Browser | ||
* @param {string} text - Text that should be in success message | ||
*/ | ||
async waitForPopUp({ page, text }: WaitForPopUp) { | ||
await Promise.race([ | ||
page.waitForSelector( | ||
`xpath=//div[contains(text(), "We're unable to process your request")]` | ||
), | ||
page.waitForSelector(`xpath=//div[contains(text(), '${text}')]`), | ||
]); | ||
const alertPopUp = await page.$$( | ||
`xpath=//div[contains(text(), "We're unable to process your request")]` | ||
); | ||
if (alertPopUp.length !== 0) { | ||
throw new Error("Service action failed"); | ||
/** | ||
* Wait for success or error pop-up message | ||
* | ||
* @param {Object} page - Methods to interact with a single tab or extension background page in Browser | ||
* @param {string} text - Text that should be in success message | ||
*/ | ||
async waitForPopUp({ page, text }: WaitForPopUp) { | ||
await Promise.race([ | ||
page.waitForSelector(`xpath=//div[contains(text(), "We're unable to process your request")]`), | ||
page.waitForSelector(`xpath=//div[contains(text(), '${text}')]`), | ||
]); | ||
const alertPopUp = await page.$$(`xpath=//div[contains(text(), "We're unable to process your request")]`); | ||
if (alertPopUp.length !== 0) { | ||
throw new Error('Service action failed'); | ||
} | ||
} | ||
} | ||
async getOneTimeToken({ | ||
workspaceUrl, | ||
builderDomain, | ||
csrfToken, | ||
sessionId, | ||
ctxsAuthId, | ||
authDomain, | ||
}: GetOneTimeToken) { | ||
const response = await axios({ | ||
url: `${workspaceUrl}/Citrix/StoreWeb/Sso/Proxy`, | ||
method: "POST", | ||
headers: { | ||
"Citrix-WSP-Proxy-URL": `${builderDomain}/app/api/auth/dsauth`, | ||
"Csrf-Token": `${csrfToken}`, | ||
Cookie: `CsrfToken=${csrfToken}; ASP.NET_SessionId=${sessionId}; CtxsAuthId=${ctxsAuthId}`, | ||
}, | ||
params: { | ||
async getOneTimeToken({ | ||
workspaceUrl, | ||
builderDomain, | ||
csrfToken, | ||
sessionId, | ||
ctxsAuthId, | ||
authDomain, | ||
}, | ||
}); | ||
return response.data.ott; | ||
} | ||
}: GetOneTimeToken) { | ||
const response = await axios({ | ||
url: `${workspaceUrl}/Citrix/StoreWeb/Sso/Proxy`, | ||
method: 'POST', | ||
headers: { | ||
'Citrix-WSP-Proxy-URL': `${builderDomain}/app/api/auth/dsauth`, | ||
'Csrf-Token': `${csrfToken}`, | ||
Cookie: `CsrfToken=${csrfToken}; ASP.NET_SessionId=${sessionId}; CtxsAuthId=${ctxsAuthId}`, | ||
}, | ||
params: { | ||
authDomain, | ||
}, | ||
}); | ||
return response.data.ott; | ||
} | ||
async getTokens({ builderDomain, authDomain, oneTimeToken }: GetTokens) { | ||
const response = await axios({ | ||
url: `${builderDomain}/app/api/auth/dsauth`, | ||
method: "GET", | ||
headers: { | ||
accept: "application/json", | ||
}, | ||
params: { | ||
authDomain, | ||
ott: oneTimeToken, | ||
}, | ||
}); | ||
async getTokens({ builderDomain, authDomain, oneTimeToken }: GetTokens) { | ||
const response = await axios({ | ||
url: `${builderDomain}/app/api/auth/dsauth`, | ||
method: 'GET', | ||
headers: { | ||
accept: 'application/json', | ||
}, | ||
params: { | ||
authDomain, | ||
ott: oneTimeToken, | ||
}, | ||
}); | ||
const citrixToken = response.data.csrf; | ||
const cookies = response.headers["set-cookie"]; | ||
const jSessionId = await getCookie({ | ||
cookies: cookies, | ||
cookieName: "JSESSIONID", | ||
}); | ||
return { citrixToken, jSessionId }; | ||
} | ||
const citrixToken = response.data.csrf; | ||
const cookies = response.headers['set-cookie']; | ||
const jSessionId = await getCookie({ | ||
cookies: cookies, | ||
cookieName: 'JSESSIONID', | ||
}); | ||
return { citrixToken, jSessionId }; | ||
} | ||
async getDsauthTokens({ | ||
page, | ||
context, | ||
workspaceUrl, | ||
workspaceUsername, | ||
workspacePassword, | ||
workspaceIdentityProvider, | ||
builderDomain, | ||
authDomain, | ||
}: GetDsauthTokens) { | ||
await this.login({ | ||
page, | ||
workspaceUrl, | ||
workspaceUsername, | ||
workspacePassword, | ||
workspaceIdentityProvider, | ||
}); | ||
const cookies = await context.cookies(); | ||
const csfrTokenCookie = cookies.find((e) => e.name === "CsrfToken"); | ||
const sessionIdCookie = cookies.find((e) => e.name === "ASP.NET_SessionId"); | ||
const ctxsAuthIdCookie = cookies.find((e) => e.name === "CtxsAuthId"); | ||
const csrfToken: any = csfrTokenCookie?.value; | ||
const sessionId: any = sessionIdCookie?.value; | ||
const ctxsAuthId: any = ctxsAuthIdCookie?.value; | ||
async getDsauthTokens({ | ||
page, | ||
context, | ||
workspaceUrl, | ||
workspaceUsername, | ||
workspacePassword, | ||
workspaceIdentityProvider, | ||
builderDomain, | ||
authDomain, | ||
}: GetDsauthTokens) { | ||
await this.login({ | ||
page, | ||
workspaceUrl, | ||
workspaceUsername, | ||
workspacePassword, | ||
workspaceIdentityProvider, | ||
}); | ||
const cookies = await context.cookies(); | ||
const csfrTokenCookie = cookies.find((e) => e.name === 'CsrfToken'); | ||
const sessionIdCookie = cookies.find((e) => e.name === 'ASP.NET_SessionId'); | ||
const ctxsAuthIdCookie = cookies.find((e) => e.name === 'CtxsAuthId'); | ||
const csrfToken: any = csfrTokenCookie?.value; | ||
const sessionId: any = sessionIdCookie?.value; | ||
const ctxsAuthId: any = ctxsAuthIdCookie?.value; | ||
const oneTimeToken = await this.getOneTimeToken({ | ||
workspaceUrl, | ||
builderDomain, | ||
csrfToken, | ||
sessionId, | ||
ctxsAuthId, | ||
authDomain, | ||
}); | ||
const { citrixToken, jSessionId } = await this.getTokens({ | ||
builderDomain, | ||
authDomain, | ||
oneTimeToken, | ||
}); | ||
const oneTimeToken = await this.getOneTimeToken({ | ||
workspaceUrl, | ||
builderDomain, | ||
csrfToken, | ||
sessionId, | ||
ctxsAuthId, | ||
authDomain, | ||
}); | ||
const { citrixToken, jSessionId } = await this.getTokens({ | ||
builderDomain, | ||
authDomain, | ||
oneTimeToken, | ||
}); | ||
return { citrixToken, jSessionId }; | ||
} | ||
return { citrixToken, jSessionId }; | ||
} | ||
async createDsAuthInstance({ | ||
citrixToken, | ||
jSessionId, | ||
}: CreateDsAuthInstance) { | ||
const dSauthInstance = axios.create({}); | ||
dSauthInstance.defaults.headers.common[ | ||
"citrix-csrf-token" | ||
] = `${citrixToken}`; | ||
dSauthInstance.defaults.headers.common[ | ||
"cookie" | ||
] = `JSESSIONID=${jSessionId}`; | ||
dSauthInstance.defaults.timeout = 90000; | ||
return dSauthInstance; | ||
} | ||
async createDsAuthInstance({ citrixToken, jSessionId }: CreateDsAuthInstance) { | ||
const dSauthInstance = axios.create({}); | ||
dSauthInstance.defaults.headers.common['citrix-csrf-token'] = `${citrixToken}`; | ||
dSauthInstance.defaults.headers.common['cookie'] = `JSESSIONID=${jSessionId}`; | ||
dSauthInstance.defaults.timeout = 90000; | ||
return dSauthInstance; | ||
} | ||
async getUserData({ | ||
dSauthInstance, | ||
microappsAdminUrl, | ||
appId, | ||
componentId, | ||
dataLimit, | ||
initiatorType, | ||
initiatorData, | ||
pageId, | ||
authDomain, | ||
}: GetUserData) { | ||
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, | ||
async getUserData({ | ||
dSauthInstance, | ||
microappsAdminUrl, | ||
appId, | ||
componentId, | ||
dataLimit, | ||
initiatorType, | ||
initiatorData, | ||
pageId, | ||
authDomain, | ||
}, | ||
}); | ||
return response.data.data; | ||
} | ||
}: GetUserData) { | ||
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; | ||
} | ||
} | ||
export type Login = { | ||
page: Page; | ||
workspaceUrl: string; | ||
workspaceUsername: string; | ||
workspacePassword: string; | ||
workspaceIdentityProvider: string; | ||
}; | ||
export type SkipTour = { | ||
page: Page; | ||
}; | ||
export type GoToActions = { | ||
page: Page; | ||
}; | ||
export type StartAction = { | ||
page: Page; | ||
actionName: string; | ||
integrationName: string; | ||
}; | ||
export type GetFeedNotifications = { | ||
page: Page; | ||
}; | ||
export type WaitForFeedCardId = { | ||
page: Page; | ||
repeatMax?: number; | ||
waitTime?: number; | ||
recordId: string; | ||
notificationId: string; | ||
}; | ||
export type GetFeedCardButton = { | ||
page: Page; | ||
feedCardId: string; | ||
buttonName: string; | ||
}; | ||
export type WaitForPopUp = { | ||
page: Page; | ||
text: string; | ||
}; | ||
export type GetOneTimeToken = { | ||
workspaceUrl: string; | ||
builderDomain: string; | ||
csrfToken: string; | ||
sessionId: string; | ||
ctxsAuthId: string; | ||
authDomain: string; | ||
}; | ||
export type GetTokens = { | ||
builderDomain: string; | ||
authDomain: string; | ||
oneTimeToken: string; | ||
}; | ||
export type GetDsauthTokens = { | ||
page: Page; | ||
workspaceUrl: string; | ||
workspaceUsername: string; | ||
workspacePassword: string; | ||
workspaceIdentityProvider: string; | ||
context: BrowserContext; | ||
builderDomain: string; | ||
authDomain: string; | ||
}; | ||
export type CreateDsAuthInstance = { | ||
citrixToken: string; | ||
jSessionId: string; | ||
}; | ||
export type GetUserData = { | ||
dSauthInstance: any; | ||
microappsAdminUrl: string; | ||
appId: string; | ||
componentId: string; | ||
dataLimit: string; | ||
initiatorType: string; | ||
initiatorData: string; | ||
pageId: string; | ||
authDomain: string; | ||
}; |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
283634
37
6594
1