@applitools/execution-grid-client
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -80,3 +80,3 @@ "use strict"; | ||
async function handleNewSession({ request, response, logger, }) { | ||
var _a, _b, _c, _d, _e, _f, _g; | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u; | ||
const session = {}; | ||
@@ -87,8 +87,22 @@ const requestBody = await (0, raw_body_1.default)(request, 'utf-8').then(body => (body ? JSON.parse(body) : undefined)); | ||
logger.log(`Request was intercepted with body:`, requestBody); | ||
const capabilities = (_b = (_a = requestBody.capabilities) === null || _a === void 0 ? void 0 : _a.alwaysMatch) !== null && _b !== void 0 ? _b : requestBody.desiredCapabilities; | ||
session.serverUrl = capabilities['applitools:eyesServerUrl'] = (_c = capabilities['applitools:eyesServerUrl']) !== null && _c !== void 0 ? _c : serverUrl; | ||
session.apiKey = capabilities['applitools:apiKey'] = (_d = capabilities['applitools:apiKey']) !== null && _d !== void 0 ? _d : apiKey; | ||
if (capabilities['applitools:tunnel']) { | ||
session.tunnelId = capabilities['applitools:x-tunnel-id-0'] = await createTunnel(session); | ||
session.serverUrl = | ||
(_e = (_c = (_b = (_a = requestBody.capabilities) === null || _a === void 0 ? void 0 : _a.alwaysMatch) === null || _b === void 0 ? void 0 : _b['applitools:eyesServerUrl']) !== null && _c !== void 0 ? _c : (_d = requestBody.desiredCapabilities) === null || _d === void 0 ? void 0 : _d['applitools:eyesServerUrl']) !== null && _e !== void 0 ? _e : serverUrl; | ||
session.apiKey = | ||
(_k = (_h = (_g = (_f = requestBody.capabilities) === null || _f === void 0 ? void 0 : _f.alwaysMatch) === null || _g === void 0 ? void 0 : _g['applitools:apiKey']) !== null && _h !== void 0 ? _h : (_j = requestBody.desiredCapabilities) === null || _j === void 0 ? void 0 : _j['applitools:apiKey']) !== null && _k !== void 0 ? _k : apiKey; | ||
session.tunnelId = | ||
((_m = (_l = requestBody.capabilities) === null || _l === void 0 ? void 0 : _l.alwaysMatch) === null || _m === void 0 ? void 0 : _m['applitools:tunnel']) || | ||
((_o = requestBody.desiredCapabilities) === null || _o === void 0 ? void 0 : _o['applitools:tunnel']) | ||
? await createTunnel(session) | ||
: undefined; | ||
const applitoolsCapabilities = { | ||
'applitools:eyesServerUrl': session.serverUrl, | ||
'applitools:apiKey': session.apiKey, | ||
'applitools:x-tunnel-id-0': session.tunnelId, | ||
}; | ||
if (((_p = requestBody.capabilities) === null || _p === void 0 ? void 0 : _p.alwaysMatch) || ((_q = requestBody.capabilities) === null || _q === void 0 ? void 0 : _q.firstMatch)) { | ||
requestBody.capabilities.alwaysMatch = Object.assign(Object.assign({}, (_r = requestBody.capabilities) === null || _r === void 0 ? void 0 : _r.alwaysMatch), applitoolsCapabilities); | ||
} | ||
if (requestBody.desiredCapabilities) { | ||
requestBody.desiredCapabilities = Object.assign(Object.assign({}, requestBody.desiredCapabilities), applitoolsCapabilities); | ||
} | ||
logger.log('Request body has modified:', requestBody); | ||
@@ -104,4 +118,4 @@ let attempt = 0; | ||
logger.log(`Response was intercepted with body:`, responseBody); | ||
if (!RETRY_ERROR_CODES.includes((_f = (_e = responseBody.value) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.appliErrorCode)) { | ||
if ((_g = responseBody.value) === null || _g === void 0 ? void 0 : _g.sessionId) | ||
if (!RETRY_ERROR_CODES.includes((_t = (_s = responseBody.value) === null || _s === void 0 ? void 0 : _s.data) === null || _t === void 0 ? void 0 : _t.appliErrorCode)) { | ||
if ((_u = responseBody.value) === null || _u === void 0 ? void 0 : _u.sessionId) | ||
sessions.set(responseBody.value.sessionId, session); | ||
@@ -108,0 +122,0 @@ response.writeHead(proxyResponse.statusCode, proxyResponse.headers).end(JSON.stringify(responseBody)); |
{ | ||
"name": "@applitools/execution-grid-client", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "license": "SEE LICENSE IN LICENSE", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34062
351