@applitools/ec-client 1.5.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,57 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.6.1](https://github.com/applitools/eyes.sdk.javascript1/compare/js/ec-client@1.6.0...js/ec-client@1.6.1) (2023-07-05)
4
+
5
+
6
+ ### Dependencies
7
+
8
+ * @applitools/tunnel-client bumped from 1.0.0 to 1.0.1
9
+ #### Bug Fixes
10
+
11
+ * re-release ([438a9aa](https://github.com/applitools/eyes.sdk.javascript1/commit/438a9aa6331ba76d6bdc7d94e8f27d7ae45730da))
12
+
13
+ ## [1.6.0](https://github.com/applitools/eyes.sdk.javascript1/compare/js/ec-client@1.5.0...js/ec-client@1.6.0) (2023-07-05)
14
+
15
+
16
+ ### Features
17
+
18
+ * added support of regional execution cloud servers ([#1711](https://github.com/applitools/eyes.sdk.javascript1/issues/1711)) ([2e26c69](https://github.com/applitools/eyes.sdk.javascript1/commit/2e26c6944bb15f6121fb37c1dba95aba162c1f6a))
19
+ * support dns caching ([#1680](https://github.com/applitools/eyes.sdk.javascript1/issues/1680)) ([9bbff34](https://github.com/applitools/eyes.sdk.javascript1/commit/9bbff34f50c9d18758b55a6bcb45571ca1148180))
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * fixed auto tunnel cleanup after unexpected end of the process ([3c1ad08](https://github.com/applitools/eyes.sdk.javascript1/commit/3c1ad0837d2d3560becc6d89370aa878becb3270))
25
+
26
+
27
+ ### Dependencies
28
+
29
+ * @applitools/core-base bumped from 1.2.1 to 1.3.0
30
+ #### Features
31
+
32
+ * support dns caching ([#1680](https://github.com/applitools/eyes.sdk.javascript1/issues/1680)) ([9bbff34](https://github.com/applitools/eyes.sdk.javascript1/commit/9bbff34f50c9d18758b55a6bcb45571ca1148180))
33
+
34
+
35
+
36
+ * @applitools/req bumped from 1.3.3 to 1.4.0
37
+ #### Features
38
+
39
+ * support dns caching ([#1680](https://github.com/applitools/eyes.sdk.javascript1/issues/1680)) ([9bbff34](https://github.com/applitools/eyes.sdk.javascript1/commit/9bbff34f50c9d18758b55a6bcb45571ca1148180))
40
+ * @applitools/driver bumped from 1.12.4 to 1.13.0
41
+ #### Features
42
+
43
+ * added auto applitools lib detection ([#1707](https://github.com/applitools/eyes.sdk.javascript1/issues/1707)) ([7d439b5](https://github.com/applitools/eyes.sdk.javascript1/commit/7d439b52af55f3b0596c9d35d6ba85c717448023))
44
+ * @applitools/tunnel-client bumped from 0.1.1 to 1.0.0
45
+ #### Features
46
+
47
+ * added binaries and made them available in jfrog ([92033fe](https://github.com/applitools/eyes.sdk.javascript1/commit/92033fed7edc58bbc4a4e37269068418fe3afc3d))
48
+ * release as 1.0.0 ([93bf312](https://github.com/applitools/eyes.sdk.javascript1/commit/93bf31205b07d19bc2cb4f50b974c7bad0f49cea))
49
+
50
+
51
+
52
+ * @applitools/spec-driver-webdriver bumped from 1.0.36 to 1.0.37
53
+
54
+
3
55
  ## [1.5.0](https://github.com/applitools/eyes.sdk.javascript1/compare/js/ec-client@1.4.0...js/ec-client@1.5.0) (2023-06-28)
4
56
 
5
57
 
package/dist/client.js CHANGED
@@ -28,33 +28,35 @@ const logger_1 = require("@applitools/logger");
28
28
  const server_1 = require("./server");
29
29
  const utils = __importStar(require("@applitools/utils"));
30
30
  async function makeECClient({ settings, logger: defaultLogger, } = {}) {
31
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6;
32
- var _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25;
31
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9;
32
+ var _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29;
33
33
  const logger = (0, logger_1.makeLogger)({ logger: defaultLogger, format: { label: 'ec-client' } });
34
34
  settings !== null && settings !== void 0 ? settings : (settings = {});
35
- (_a = settings.serverUrl) !== null && _a !== void 0 ? _a : (settings.serverUrl = (_b = utils.general.getEnvValue('EG_SERVER_URL')) !== null && _b !== void 0 ? _b : 'https://exec-wus.applitools.com');
36
- (_c = settings.proxy) !== null && _c !== void 0 ? _c : (settings.proxy = utils.general.getEnvValue('PROXY_URL') ? { url: utils.general.getEnvValue('PROXY_URL') } : undefined);
37
- (_d = settings.tunnel) !== null && _d !== void 0 ? _d : (settings.tunnel = {});
38
- (_e = (_7 = settings.tunnel).serviceUrl) !== null && _e !== void 0 ? _e : (_7.serviceUrl = utils.general.getEnvValue('EG_TUNNEL_URL'));
39
- (_f = (_8 = settings.tunnel).groupSize) !== null && _f !== void 0 ? _f : (_8.groupSize = (_g = utils.general.getEnvValue('TUNNEL_GROUP_SIZE', 'number')) !== null && _g !== void 0 ? _g : 2);
40
- (_h = (_9 = settings.tunnel).pool) !== null && _h !== void 0 ? _h : (_9.pool = {});
41
- (_j = (_10 = settings.tunnel.pool).maxInuse) !== null && _j !== void 0 ? _j : (_10.maxInuse = (_k = utils.general.getEnvValue('TUNNEL_POOL_MAX_INUSE', 'number')) !== null && _k !== void 0 ? _k : 4);
42
- (_l = (_11 = settings.tunnel.pool).timeout) !== null && _l !== void 0 ? _l : (_11.timeout = {});
43
- (_m = (_12 = settings.tunnel.pool.timeout).idle) !== null && _m !== void 0 ? _m : (_12.idle = (_o = utils.general.getEnvValue('TUNNEL_POOL_TIMEOUT_IDLE', 'number')) !== null && _o !== void 0 ? _o : 20 * 60000);
44
- (_p = (_13 = settings.tunnel.pool.timeout).expiration) !== null && _p !== void 0 ? _p : (_13.expiration = (_q = utils.general.getEnvValue('TUNNEL_POOL_TIMEOUT_EXPIRATION', 'number')) !== null && _q !== void 0 ? _q : 30000);
45
- (_r = settings.options) !== null && _r !== void 0 ? _r : (settings.options = {});
46
- (_s = (_14 = settings.options).eyesServerUrl) !== null && _s !== void 0 ? _s : (_14.eyesServerUrl = (_u = (_t = utils.general.getEnvValue('EYES_SERVER_URL')) !== null && _t !== void 0 ? _t : utils.general.getEnvValue('SERVER_URL')) !== null && _u !== void 0 ? _u : 'https://eyesapi.applitools.com');
47
- (_v = (_15 = settings.options).apiKey) !== null && _v !== void 0 ? _v : (_15.apiKey = utils.general.getEnvValue('API_KEY'));
48
- (_w = (_16 = settings.options).batch) !== null && _w !== void 0 ? _w : (_16.batch = {});
49
- (_x = (_17 = settings.options.batch).id) !== null && _x !== void 0 ? _x : (_17.id = (_y = utils.general.getEnvValue('BATCH_ID')) !== null && _y !== void 0 ? _y : `generated-${utils.general.guid()}`);
50
- (_z = (_18 = settings.options.batch).name) !== null && _z !== void 0 ? _z : (_18.name = utils.general.getEnvValue('BATCH_NAME'));
51
- (_0 = (_19 = settings.options.batch).sequenceName) !== null && _0 !== void 0 ? _0 : (_19.sequenceName = utils.general.getEnvValue('BATCH_SEQUENCE'));
52
- (_1 = (_20 = settings.options.batch).notifyOnCompletion) !== null && _1 !== void 0 ? _1 : (_20.notifyOnCompletion = utils.general.getEnvValue('BATCH_NOTIFY', 'boolean'));
53
- (_2 = (_21 = settings.options).tunnel) !== null && _2 !== void 0 ? _2 : (_21.tunnel = utils.general.getEnvValue('TUNNEL', 'boolean'));
54
- (_3 = (_22 = settings.options).useSelfHealing) !== null && _3 !== void 0 ? _3 : (_22.useSelfHealing = utils.general.getEnvValue('USE_SELF_HEALING', 'boolean'));
55
- (_4 = (_23 = settings.options).sessionName) !== null && _4 !== void 0 ? _4 : (_23.sessionName = utils.general.getEnvValue('SESSION_NAME'));
56
- (_5 = (_24 = settings.options).timeout) !== null && _5 !== void 0 ? _5 : (_24.timeout = utils.general.getEnvValue('EG_TIMEOUT', 'number'));
57
- (_6 = (_25 = settings.options).inactivityTimeout) !== null && _6 !== void 0 ? _6 : (_25.inactivityTimeout = utils.general.getEnvValue('EG_INACTIVITY_TIMEOUT', 'number'));
35
+ (_a = settings.serverUrl) !== null && _a !== void 0 ? _a : (settings.serverUrl = (_c = (_b = utils.general.getEnvValue('EXECUTION_CLOUD_URL')) !== null && _b !== void 0 ? _b : utils.general.getEnvValue('EG_SERVER_URL')) !== null && _c !== void 0 ? _c : 'https://exec-wus.applitools.com');
36
+ (_d = settings.proxy) !== null && _d !== void 0 ? _d : (settings.proxy = utils.general.getEnvValue('PROXY_URL') ? { url: utils.general.getEnvValue('PROXY_URL') } : undefined);
37
+ (_e = settings.useDnsCache) !== null && _e !== void 0 ? _e : (settings.useDnsCache = utils.general.getEnvValue('USE_DNS_CACHE', 'boolean'));
38
+ (_f = settings.tunnel) !== null && _f !== void 0 ? _f : (settings.tunnel = {});
39
+ (_g = (_10 = settings.tunnel).serviceUrl) !== null && _g !== void 0 ? _g : (_10.serviceUrl = utils.general.getEnvValue('EG_TUNNEL_URL'));
40
+ (_h = (_11 = settings.tunnel).groupSize) !== null && _h !== void 0 ? _h : (_11.groupSize = (_j = utils.general.getEnvValue('TUNNEL_GROUP_SIZE', 'number')) !== null && _j !== void 0 ? _j : 2);
41
+ (_k = (_12 = settings.tunnel).pool) !== null && _k !== void 0 ? _k : (_12.pool = {});
42
+ (_l = (_13 = settings.tunnel.pool).maxInuse) !== null && _l !== void 0 ? _l : (_13.maxInuse = (_m = utils.general.getEnvValue('TUNNEL_POOL_MAX_INUSE', 'number')) !== null && _m !== void 0 ? _m : 4);
43
+ (_o = (_14 = settings.tunnel.pool).timeout) !== null && _o !== void 0 ? _o : (_14.timeout = {});
44
+ (_p = (_15 = settings.tunnel.pool.timeout).idle) !== null && _p !== void 0 ? _p : (_15.idle = (_q = utils.general.getEnvValue('TUNNEL_POOL_TIMEOUT_IDLE', 'number')) !== null && _q !== void 0 ? _q : 20 * 60000);
45
+ (_r = (_16 = settings.tunnel.pool.timeout).expiration) !== null && _r !== void 0 ? _r : (_16.expiration = (_s = utils.general.getEnvValue('TUNNEL_POOL_TIMEOUT_EXPIRATION', 'number')) !== null && _s !== void 0 ? _s : 30000);
46
+ (_t = settings.options) !== null && _t !== void 0 ? _t : (settings.options = {});
47
+ (_u = (_17 = settings.options).eyesServerUrl) !== null && _u !== void 0 ? _u : (_17.eyesServerUrl = (_w = (_v = utils.general.getEnvValue('EYES_SERVER_URL')) !== null && _v !== void 0 ? _v : utils.general.getEnvValue('SERVER_URL')) !== null && _w !== void 0 ? _w : 'https://eyesapi.applitools.com');
48
+ (_x = (_18 = settings.options).apiKey) !== null && _x !== void 0 ? _x : (_18.apiKey = utils.general.getEnvValue('API_KEY'));
49
+ (_y = (_19 = settings.options).region) !== null && _y !== void 0 ? _y : (_19.region = utils.general.getEnvValue('EXECUTION_CLOUD_REGION'));
50
+ (_z = (_20 = settings.options).batch) !== null && _z !== void 0 ? _z : (_20.batch = {});
51
+ (_0 = (_21 = settings.options.batch).id) !== null && _0 !== void 0 ? _0 : (_21.id = (_1 = utils.general.getEnvValue('BATCH_ID')) !== null && _1 !== void 0 ? _1 : `generated-${utils.general.guid()}`);
52
+ (_2 = (_22 = settings.options.batch).name) !== null && _2 !== void 0 ? _2 : (_22.name = utils.general.getEnvValue('BATCH_NAME'));
53
+ (_3 = (_23 = settings.options.batch).sequenceName) !== null && _3 !== void 0 ? _3 : (_23.sequenceName = utils.general.getEnvValue('BATCH_SEQUENCE'));
54
+ (_4 = (_24 = settings.options.batch).notifyOnCompletion) !== null && _4 !== void 0 ? _4 : (_24.notifyOnCompletion = utils.general.getEnvValue('BATCH_NOTIFY', 'boolean'));
55
+ (_5 = (_25 = settings.options).tunnel) !== null && _5 !== void 0 ? _5 : (_25.tunnel = utils.general.getEnvValue('TUNNEL', 'boolean'));
56
+ (_6 = (_26 = settings.options).useSelfHealing) !== null && _6 !== void 0 ? _6 : (_26.useSelfHealing = utils.general.getEnvValue('USE_SELF_HEALING', 'boolean'));
57
+ (_7 = (_27 = settings.options).sessionName) !== null && _7 !== void 0 ? _7 : (_27.sessionName = utils.general.getEnvValue('SESSION_NAME'));
58
+ (_8 = (_28 = settings.options).timeout) !== null && _8 !== void 0 ? _8 : (_28.timeout = utils.general.getEnvValue('EG_TIMEOUT', 'number'));
59
+ (_9 = (_29 = settings.options).inactivityTimeout) !== null && _9 !== void 0 ? _9 : (_29.inactivityTimeout = utils.general.getEnvValue('EG_INACTIVITY_TIMEOUT', 'number'));
58
60
  const server = await (0, server_1.makeServer)({ settings: settings, logger });
59
61
  return server;
60
62
  }
@@ -6,7 +6,7 @@ function makeEndSession({ req, tunnels }) {
6
6
  var _a, _b;
7
7
  var _c;
8
8
  logger.log(`Request was intercepted with sessionId:`, session.sessionId);
9
- await req(request.url, { io: { request, response }, logger });
9
+ await req(request.url, { baseUrl: session.serverUrl, io: { request, response }, logger });
10
10
  if ((_a = session.tests) === null || _a === void 0 ? void 0 : _a.current) {
11
11
  await session.tests.current.abort({ settings: { testMetadata: session.metadata }, logger });
12
12
  (_b = (_c = session.tests).ended) !== null && _b !== void 0 ? _b : (_c.ended = []);
@@ -107,7 +107,7 @@ function makeExecuteScript({ req, core }) {
107
107
  return;
108
108
  }
109
109
  }
110
- await req(request.url, { body: requestBody, io: { request, response }, logger });
110
+ await req(request.url, { baseUrl: session.serverUrl, body: requestBody, io: { request, response }, logger });
111
111
  };
112
112
  }
113
113
  exports.makeExecuteScript = makeExecuteScript;
@@ -5,7 +5,11 @@ function makeFindElement({ req }) {
5
5
  return async function findElement({ session, request, response, logger, }) {
6
6
  var _a, _b, _c;
7
7
  logger.log('Inspecting element lookup request to collect self-healing metadata');
8
- const proxyResponse = await req(request.url, { io: { request, response, handle: false }, logger });
8
+ const proxyResponse = await req(request.url, {
9
+ baseUrl: session.serverUrl,
10
+ io: { request, response, handle: false },
11
+ logger,
12
+ });
9
13
  const responseBody = Buffer.from(await proxyResponse.arrayBuffer());
10
14
  const parsed = JSON.parse(responseBody.toString('utf8'));
11
15
  if ((_b = (_a = parsed === null || parsed === void 0 ? void 0 : parsed.appliCustomData) === null || _a === void 0 ? void 0 : _a.selfHealing) === null || _b === void 0 ? void 0 : _b.successfulSelector) {
@@ -28,6 +28,10 @@ exports.makeStartSession = void 0;
28
28
  const execution_grid_tunnel_1 = require("@applitools/execution-grid-tunnel");
29
29
  const abort_controller_1 = require("abort-controller");
30
30
  const utils = __importStar(require("@applitools/utils"));
31
+ const SERVER_URLS = {
32
+ 'us-west': 'https://exec-wus.applitools.com',
33
+ australia: 'https://exec-au.applitools.com',
34
+ };
31
35
  const RETRY_BACKOFF = [
32
36
  ...Array(5).fill(2000),
33
37
  ...Array(4).fill(5000),
@@ -36,7 +40,7 @@ const RETRY_BACKOFF = [
36
40
  function makeStartSession({ settings, req, tunnels }) {
37
41
  const queues = new Map();
38
42
  return async function createSession({ request, response, logger, }) {
39
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
43
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
40
44
  const requestBody = await utils.streams.toJSON(request);
41
45
  logger.log(`Request was intercepted with body:`, requestBody);
42
46
  let capabilities = {};
@@ -56,25 +60,33 @@ function makeStartSession({ settings, req, tunnels }) {
56
60
  Object.fromEntries(Object.entries(capabilities).map(([key, value]) => [key.replace(/^applitools:/, ''), value]))),
57
61
  };
58
62
  const session = {
63
+ serverUrl: settings.serverUrl,
64
+ proxy: settings.proxy,
59
65
  credentials: { eyesServerUrl: options.eyesServerUrl, apiKey: options.apiKey },
60
66
  options,
61
67
  };
68
+ if (options.region) {
69
+ if (SERVER_URLS[options.region])
70
+ session.serverUrl = SERVER_URLS[options.region];
71
+ else
72
+ throw new Error(`Failed to create session in unknown region ${options.region}`);
73
+ }
62
74
  if (options.tunnel && tunnels) {
63
75
  // TODO should be removed once tunnel spawning issue is solved
64
76
  await (0, execution_grid_tunnel_1.prepareEnvironment)();
65
77
  session.tunnels = await tunnels.acquire(session.credentials);
66
- session.tunnels.forEach((tunnel, index) => {
67
- options[`x-tunnel-id-${index}`] = tunnel.tunnelId;
68
- });
69
78
  }
70
- const applitoolsCapabilities = Object.fromEntries(Object.entries(options).map(([key, value]) => [`applitools:${key}`, value]));
79
+ const applitoolsCapabilities = Object.fromEntries([
80
+ ...Object.entries(options).map(([key, value]) => [`applitools:${key}`, value]),
81
+ ...((_g = (_f = session.tunnels) === null || _f === void 0 ? void 0 : _f.map((tunnel, index) => [`applitools:x-tunnel-id-${index}`, tunnel.tunnelId])) !== null && _g !== void 0 ? _g : []),
82
+ ]);
71
83
  if (!utils.types.isEmpty(requestBody.desiredCapabilities)) {
72
84
  requestBody.desiredCapabilities = { ...requestBody.desiredCapabilities, ...applitoolsCapabilities };
73
85
  }
74
- else if (!utils.types.isEmpty((_f = requestBody.capabilities) === null || _f === void 0 ? void 0 : _f.alwaysMatch)) {
75
- requestBody.capabilities.alwaysMatch = { ...(_g = requestBody.capabilities) === null || _g === void 0 ? void 0 : _g.alwaysMatch, ...applitoolsCapabilities };
86
+ else if (!utils.types.isEmpty((_h = requestBody.capabilities) === null || _h === void 0 ? void 0 : _h.alwaysMatch)) {
87
+ requestBody.capabilities.alwaysMatch = { ...(_j = requestBody.capabilities) === null || _j === void 0 ? void 0 : _j.alwaysMatch, ...applitoolsCapabilities };
76
88
  }
77
- else if (!utils.types.isEmpty((_j = (_h = requestBody.capabilities) === null || _h === void 0 ? void 0 : _h.firstMatch) === null || _j === void 0 ? void 0 : _j[0])) {
89
+ else if (!utils.types.isEmpty((_l = (_k = requestBody.capabilities) === null || _k === void 0 ? void 0 : _k.firstMatch) === null || _l === void 0 ? void 0 : _l[0])) {
78
90
  requestBody.capabilities.firstMatch = [{ ...requestBody.capabilities.firstMatch[0], ...applitoolsCapabilities }];
79
91
  }
80
92
  else {
@@ -98,6 +110,7 @@ function makeStartSession({ settings, req, tunnels }) {
98
110
  if (signal.aborted)
99
111
  return queue.pause;
100
112
  const proxyResponse = await req(request.url, {
113
+ baseUrl: session.serverUrl,
101
114
  body: requestBody,
102
115
  io: { request, response, handle: false },
103
116
  // TODO uncomment when we can throw different abort reasons for task cancelation and timeout abortion
@@ -123,9 +136,7 @@ function makeStartSession({ settings, req, tunnels }) {
123
136
  if (proxyResponse.headers.has('content-length')) {
124
137
  proxyResponse.headers.set('content-length', Buffer.byteLength(JSON.stringify(responseBody)).toString());
125
138
  }
126
- session.serverUrl = settings.serverUrl;
127
139
  session.sessionId = responseBody.value.sessionId;
128
- session.proxy = settings.proxy;
129
140
  session.capabilities = responseBody.value.capabilities;
130
141
  }
131
142
  response
package/dist/req-proxy.js CHANGED
@@ -30,6 +30,7 @@ function makeReqProxy(config) {
30
30
  return (0, req_1.makeReq)({
31
31
  baseUrl: config.targetUrl,
32
32
  proxy: config.proxy,
33
+ useDnsCache: config.useDnsCache,
33
34
  retry: config.retry,
34
35
  hooks: {
35
36
  afterOptionsMerged({ options }) {
package/dist/server.js CHANGED
@@ -39,7 +39,6 @@ async function makeServer({ settings, logger: mainLogger, }) {
39
39
  var _a, _b;
40
40
  const serverLogger = mainLogger.extend();
41
41
  const req = (0, req_proxy_1.makeReqProxy)({
42
- targetUrl: settings.serverUrl,
43
42
  proxy: settings.proxy,
44
43
  retry: {
45
44
  validate: async ({ response, error }) => {
@@ -52,6 +51,7 @@ async function makeServer({ settings, logger: mainLogger, }) {
52
51
  limit: 10,
53
52
  timeout: 5000,
54
53
  },
54
+ useDnsCache: settings.useDnsCache,
55
55
  });
56
56
  const core = (0, core_base_1.makeCore)({ agentId: `js/ec-client/${require('../package.json').version}` });
57
57
  const tunnels = ((_a = settings.tunnel) === null || _a === void 0 ? void 0 : _a.serviceUrl)
@@ -84,9 +84,13 @@ async function makeServer({ settings, logger: mainLogger, }) {
84
84
  await commands.endSession({ session, request, response, logger: requestLogger });
85
85
  sessions.delete(session.sessionId);
86
86
  });
87
- router.any(async () => {
87
+ router.any(/^\/session\/(?<sessionId>[^\/]+).*$/, async ({ match }) => {
88
88
  requestLogger.log('Passthrough request');
89
- await req(request.url, { io: { request, response }, logger: requestLogger });
89
+ const session = sessions.get(match.groups.sessionId);
90
+ await req(request.url, { baseUrl: session.serverUrl, io: { request, response }, logger: requestLogger });
91
+ });
92
+ router.fallback(async () => {
93
+ throw new Error('Unknown request');
90
94
  });
91
95
  router.catch(async ({ error }) => {
92
96
  requestLogger.error(`Error during processing request`, error);
@@ -63,26 +63,26 @@ async function makeTunnelManagerServer({ settings, path, idleTimeout = 600000, /
63
63
  });
64
64
  const sockets = new Set();
65
65
  server.on('connection', client => {
66
- const store = new Map();
66
+ const store = [];
67
67
  if (idle)
68
68
  idle = clearTimeout(idle);
69
69
  const socket = (0, socket_1.makeSocket)(client, { transport: 'ipc', logger });
70
70
  sockets.add(socket);
71
71
  socket.on('close', async () => {
72
- logger.log('Connection is closed, remaining tunnels are going to be released');
73
- sockets.delete(socket);
74
- await Promise.all(Array.from(store.values(), manager.release)).catch(logger.error);
72
+ logger.log('Connection is closed, remaining tunnels are going to be released', store);
73
+ await Promise.all(store.map(manager.release)).catch(logger.error);
75
74
  if (sockets.size === 0 && !serverClosed)
76
75
  idle = setTimeout(close, idleTimeout);
77
76
  });
78
77
  socket.command('Tunnel.acquire', async (credentials) => {
79
78
  const tunnels = await manager.acquire(credentials);
80
- store.set(JSON.stringify(tunnels), tunnels);
79
+ store.push(tunnels);
81
80
  return tunnels;
82
81
  });
83
82
  socket.command('Tunnel.release', async (tunnels) => {
84
83
  await manager.release(tunnels);
85
- store.delete(JSON.stringify(tunnels));
84
+ const storeIndex = store.findIndex(storedTunnels => tunnels.every((tunnel, index) => tunnel.tunnelId === storedTunnels[index].tunnelId));
85
+ tunnels.splice(storeIndex, 1);
86
86
  });
87
87
  });
88
88
  return { close };
@@ -12,14 +12,15 @@ function makeCallback(handler) {
12
12
  post: (pattern, callback) => routes.push({ method: 'POST', pattern, callback }),
13
13
  put: (pattern, callback) => routes.push({ method: 'PUT', pattern, callback }),
14
14
  delete: (pattern, callback) => routes.push({ method: 'DELETE', pattern, callback }),
15
- any: callback => fallbacks.push({ callback }),
15
+ any: (pattern, callback) => routes.push({ pattern, callback }),
16
+ fallback: callback => fallbacks.push({ callback }),
16
17
  catch: callback => catches.push({ callback }),
17
18
  finally: callback => finals.push({ callback }),
18
19
  };
19
20
  handler({ router, request, response });
20
21
  try {
21
22
  for (const { method, pattern, callback } of routes) {
22
- if (request.method === method && request.url) {
23
+ if ((!method || request.method === method) && request.url) {
23
24
  const regexp = pattern instanceof RegExp
24
25
  ? pattern
25
26
  : new RegExp(`^${pattern.replace(/:([^\/]+)/g, (_, name) => `(?<${name}>[^/]+)`)}/?$`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/ec-client",
3
- "version": "1.5.0",
3
+ "version": "1.6.1",
4
4
  "homepage": "https://applitools.com",
5
5
  "bugs": {
6
6
  "url": "https://github.com/applitools/eyes.sdk.javascript1/issues"
@@ -52,14 +52,14 @@
52
52
  "test:it": "MOCHA_GROUP=it run --top-level mocha './test/it/*.spec.ts'"
53
53
  },
54
54
  "dependencies": {
55
- "@applitools/core-base": "1.2.1",
56
- "@applitools/driver": "1.12.4",
55
+ "@applitools/core-base": "1.3.0",
56
+ "@applitools/driver": "1.13.0",
57
57
  "@applitools/execution-grid-tunnel": "2.1.6",
58
58
  "@applitools/logger": "2.0.5",
59
- "@applitools/req": "1.3.3",
59
+ "@applitools/req": "1.4.0",
60
60
  "@applitools/socket": "1.1.5",
61
- "@applitools/spec-driver-webdriver": "1.0.36",
62
- "@applitools/tunnel-client": "0.1.1",
61
+ "@applitools/spec-driver-webdriver": "1.0.37",
62
+ "@applitools/tunnel-client": "1.0.1",
63
63
  "@applitools/utils": "1.5.0",
64
64
  "abort-controller": "3.0.0",
65
65
  "webdriver": "7",
@@ -3,10 +3,11 @@ import { type IncomingMessage, type ServerResponse } from 'http';
3
3
  import { type Logger } from '@applitools/logger';
4
4
  import { type Req, type Proxy, type Retry, type Options } from '@applitools/req';
5
5
  export type ReqProxyConfig = {
6
- targetUrl: string;
6
+ targetUrl?: string;
7
7
  proxy?: Proxy;
8
8
  retry?: Retry | Retry[];
9
9
  logger?: Logger;
10
+ useDnsCache?: boolean;
10
11
  };
11
12
  export type ReqProxyOptions = Options & {
12
13
  io: {
package/types/types.d.ts CHANGED
@@ -10,6 +10,7 @@ export interface ECClient {
10
10
  export interface ECClientSettings {
11
11
  serverUrl: string;
12
12
  proxy?: Proxy;
13
+ useDnsCache?: boolean;
13
14
  options?: ECCapabilitiesOptions;
14
15
  port?: number;
15
16
  /** @internal */
@@ -18,6 +19,7 @@ export interface ECClientSettings {
18
19
  export interface ECCapabilitiesOptions {
19
20
  eyesServerUrl?: string;
20
21
  apiKey?: string;
22
+ region?: 'us-west' | 'australia';
21
23
  sessionName?: string;
22
24
  appName?: string;
23
25
  testName?: string;
@@ -31,8 +33,8 @@ export interface ECCapabilitiesOptions {
31
33
  }
32
34
  export interface ECSession {
33
35
  serverUrl: string;
34
- sessionId: string;
35
36
  proxy?: Proxy;
37
+ sessionId: string;
36
38
  credentials: {
37
39
  eyesServerUrl: string;
38
40
  apiKey: string;
@@ -1,24 +1,27 @@
1
1
  /// <reference types="node" />
2
2
  import { type IncomingMessage, type ServerResponse } from 'http';
3
- type Router = {
4
- get: (pattern: string | RegExp, callback: (options: {
3
+ interface Router {
4
+ get(pattern: string | RegExp, callback: (options: {
5
5
  match: RegExpMatchArray;
6
- }) => Promise<void> | void) => void;
7
- post: (pattern: string | RegExp, callback: (options: {
6
+ }) => Promise<void> | void): void;
7
+ post(pattern: string | RegExp, callback: (options: {
8
8
  match: RegExpMatchArray;
9
- }) => Promise<void> | void) => void;
10
- put: (pattern: string | RegExp, callback: (options: {
9
+ }) => Promise<void> | void): void;
10
+ put(pattern: string | RegExp, callback: (options: {
11
11
  match: RegExpMatchArray;
12
- }) => Promise<void> | void) => void;
13
- delete: (pattern: string | RegExp, callback: (options: {
12
+ }) => Promise<void> | void): void;
13
+ delete(pattern: string | RegExp, callback: (options: {
14
14
  match: RegExpMatchArray;
15
- }) => Promise<void> | void) => void;
16
- any: (callback: () => Promise<void> | void) => void;
17
- catch: (callback: (options: {
15
+ }) => Promise<void> | void): void;
16
+ any(pattern: string | RegExp, callback: (options: {
17
+ match: RegExpMatchArray;
18
+ }) => Promise<void> | void): void;
19
+ fallback(callback: () => Promise<void> | void): void;
20
+ catch(callback: (options: {
18
21
  error: any;
19
- }) => Promise<void> | void) => void;
20
- finally: (callback: () => Promise<void> | void) => void;
21
- };
22
+ }) => Promise<void> | void): void;
23
+ finally(callback: () => Promise<void> | void): void;
24
+ }
22
25
  export declare function makeCallback(handler: (options: {
23
26
  router: Router;
24
27
  request: IncomingMessage;