@appium/base-driver 10.0.0-beta.0 → 10.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -8
- package/build/lib/basedriver/capabilities.d.ts.map +1 -1
- package/build/lib/basedriver/capabilities.js +2 -4
- package/build/lib/basedriver/capabilities.js.map +1 -1
- package/build/lib/basedriver/commands/execute.js.map +1 -1
- package/build/lib/basedriver/commands/timeout.js +12 -31
- package/build/lib/basedriver/commands/timeout.js.map +1 -1
- package/build/lib/basedriver/core.d.ts +0 -8
- package/build/lib/basedriver/core.d.ts.map +1 -1
- package/build/lib/basedriver/core.js +8 -18
- package/build/lib/basedriver/core.js.map +1 -1
- package/build/lib/basedriver/driver.js +2 -2
- package/build/lib/basedriver/driver.js.map +1 -1
- package/build/lib/basedriver/helpers.d.ts +9 -1
- package/build/lib/basedriver/helpers.d.ts.map +1 -1
- package/build/lib/basedriver/helpers.js +56 -142
- package/build/lib/basedriver/helpers.js.map +1 -1
- package/build/lib/basedriver/validation.d.ts +7 -0
- package/build/lib/basedriver/validation.d.ts.map +1 -0
- package/build/lib/basedriver/validation.js +130 -0
- package/build/lib/basedriver/validation.js.map +1 -0
- package/build/lib/express/middleware.d.ts +0 -6
- package/build/lib/express/middleware.d.ts.map +1 -1
- package/build/lib/express/middleware.js +28 -60
- package/build/lib/express/middleware.js.map +1 -1
- package/build/lib/express/server.d.ts.map +1 -1
- package/build/lib/express/server.js +0 -1
- package/build/lib/express/server.js.map +1 -1
- package/build/lib/helpers/capabilities.d.ts +13 -6
- package/build/lib/helpers/capabilities.d.ts.map +1 -1
- package/build/lib/helpers/capabilities.js +7 -0
- package/build/lib/helpers/capabilities.js.map +1 -1
- package/build/lib/index.d.ts +1 -0
- package/build/lib/index.d.ts.map +1 -1
- package/build/lib/index.js +3 -1
- package/build/lib/index.js.map +1 -1
- package/build/lib/jsonwp-proxy/proxy.d.ts +0 -8
- package/build/lib/jsonwp-proxy/proxy.d.ts.map +1 -1
- package/build/lib/jsonwp-proxy/proxy.js +7 -38
- package/build/lib/jsonwp-proxy/proxy.js.map +1 -1
- package/build/lib/protocol/errors.d.ts +171 -277
- package/build/lib/protocol/errors.d.ts.map +1 -1
- package/build/lib/protocol/errors.js +201 -421
- package/build/lib/protocol/errors.js.map +1 -1
- package/build/lib/protocol/helpers.d.ts +6 -6
- package/build/lib/protocol/helpers.d.ts.map +1 -1
- package/build/lib/protocol/helpers.js +11 -7
- package/build/lib/protocol/helpers.js.map +1 -1
- package/build/lib/protocol/index.d.ts +2 -1
- package/build/lib/protocol/index.d.ts.map +1 -1
- package/build/lib/protocol/index.js +2 -1
- package/build/lib/protocol/index.js.map +1 -1
- package/build/lib/protocol/protocol.d.ts +16 -19
- package/build/lib/protocol/protocol.d.ts.map +1 -1
- package/build/lib/protocol/protocol.js +98 -119
- package/build/lib/protocol/protocol.js.map +1 -1
- package/build/lib/protocol/routes.d.ts +12 -714
- package/build/lib/protocol/routes.d.ts.map +1 -1
- package/build/lib/protocol/routes.js +24 -488
- package/build/lib/protocol/routes.js.map +1 -1
- package/build/lib/protocol/validators.d.ts +4 -7
- package/build/lib/protocol/validators.d.ts.map +1 -1
- package/build/lib/protocol/validators.js +4 -21
- package/build/lib/protocol/validators.js.map +1 -1
- package/lib/basedriver/capabilities.ts +2 -4
- package/lib/basedriver/commands/execute.ts +1 -1
- package/lib/basedriver/commands/timeout.ts +16 -43
- package/lib/basedriver/core.ts +10 -19
- package/lib/basedriver/driver.ts +3 -3
- package/lib/basedriver/helpers.js +61 -167
- package/lib/basedriver/validation.ts +145 -0
- package/lib/express/middleware.js +32 -70
- package/lib/express/server.js +0 -2
- package/lib/helpers/capabilities.js +9 -4
- package/lib/index.js +2 -0
- package/lib/jsonwp-proxy/proxy.js +8 -45
- package/lib/protocol/{errors.js → errors.ts} +322 -436
- package/lib/protocol/helpers.js +12 -8
- package/lib/protocol/index.js +8 -1
- package/lib/protocol/{protocol.js → protocol.ts} +147 -146
- package/lib/protocol/routes.js +26 -498
- package/lib/protocol/validators.ts +19 -0
- package/package.json +10 -11
- package/build/lib/basedriver/desired-caps.d.ts +0 -5
- package/build/lib/basedriver/desired-caps.d.ts.map +0 -1
- package/build/lib/basedriver/desired-caps.js +0 -92
- package/build/lib/basedriver/desired-caps.js.map +0 -1
- package/lib/basedriver/README.md +0 -36
- package/lib/basedriver/desired-caps.js +0 -103
- package/lib/express/README.md +0 -59
- package/lib/jsonwp-proxy/README.md +0 -52
- package/lib/jsonwp-status/README.md +0 -20
- package/lib/protocol/README.md +0 -100
- package/lib/protocol/validators.js +0 -38
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
import {isSessionCommand, routeToCommandName} from '../protocol';
|
|
12
12
|
import {MAX_LOG_BODY_LENGTH, DEFAULT_BASE_PATH, PROTOCOLS} from '../constants';
|
|
13
13
|
import ProtocolConverter from './protocol-converter';
|
|
14
|
-
import {formatResponseValue,
|
|
14
|
+
import {formatResponseValue, ensureW3cResponse} from '../protocol/helpers';
|
|
15
15
|
import http from 'http';
|
|
16
16
|
import https from 'https';
|
|
17
17
|
import { match as pathToRegexMatch } from 'path-to-regexp';
|
|
@@ -290,37 +290,6 @@ export class JWProxy {
|
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
292
|
|
|
293
|
-
/**
|
|
294
|
-
* @deprecated This method is not used anymore and will be removed
|
|
295
|
-
*
|
|
296
|
-
* @param {string} url
|
|
297
|
-
* @param {import('@appium/types').HTTPMethod} method
|
|
298
|
-
* @returns {string|undefined}
|
|
299
|
-
*/
|
|
300
|
-
requestToCommandName(url, method) {
|
|
301
|
-
/**
|
|
302
|
-
*
|
|
303
|
-
* @param {RegExp} pattern
|
|
304
|
-
* @returns {string|undefined}
|
|
305
|
-
*/
|
|
306
|
-
const extractCommandName = (pattern) => {
|
|
307
|
-
const pathMatch = pattern.exec(url);
|
|
308
|
-
if (pathMatch) {
|
|
309
|
-
return routeToCommandName(pathMatch[1], method, this.reqBasePath);
|
|
310
|
-
}
|
|
311
|
-
};
|
|
312
|
-
let commandName = routeToCommandName(url, method, this.reqBasePath);
|
|
313
|
-
if (!commandName && _.includes(url, `${this.reqBasePath}/session/`)) {
|
|
314
|
-
commandName = extractCommandName(
|
|
315
|
-
new RegExp(`${_.escapeRegExp(this.reqBasePath)}/session/[^/]+(.+)`)
|
|
316
|
-
);
|
|
317
|
-
}
|
|
318
|
-
if (!commandName && _.includes(url, this.reqBasePath)) {
|
|
319
|
-
commandName = extractCommandName(new RegExp(`${_.escapeRegExp(this.reqBasePath)}(/.+)`));
|
|
320
|
-
}
|
|
321
|
-
return commandName;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
293
|
/**
|
|
325
294
|
*
|
|
326
295
|
* @param {string} url
|
|
@@ -428,18 +397,13 @@ export class JWProxy {
|
|
|
428
397
|
/** @type {import('@appium/types').HTTPMethod} */ (req.method),
|
|
429
398
|
req.body
|
|
430
399
|
);
|
|
431
|
-
for (const [name, value] of _.toPairs(response.headers)) {
|
|
432
|
-
if (!_.isNil(value)) {
|
|
433
|
-
res.setHeader(name, _.isBoolean(value) ? String(value) : value);
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
400
|
statusCode = response.statusCode;
|
|
437
401
|
} catch (err) {
|
|
438
402
|
[statusCode, resBodyObj] = getResponseForW3CError(
|
|
439
403
|
isErrorType(err, errors.ProxyRequestError) ? err.getActualError() : err
|
|
440
404
|
);
|
|
441
405
|
}
|
|
442
|
-
res.
|
|
406
|
+
res.setHeader('content-type', 'application/json; charset=utf-8');
|
|
443
407
|
if (!_.isPlainObject(resBodyObj)) {
|
|
444
408
|
const error = new errors.UnknownError(
|
|
445
409
|
`The downstream server response with the status code ${statusCode} is not a valid JSON object: ` +
|
|
@@ -462,7 +426,7 @@ export class JWProxy {
|
|
|
462
426
|
}
|
|
463
427
|
}
|
|
464
428
|
resBodyObj.value = formatResponseValue(resBodyObj.value);
|
|
465
|
-
res.status(statusCode).
|
|
429
|
+
res.status(statusCode).json(ensureW3cResponse(resBodyObj));
|
|
466
430
|
}
|
|
467
431
|
|
|
468
432
|
/**
|
|
@@ -503,12 +467,11 @@ export class JWProxy {
|
|
|
503
467
|
pathname = pathname.replace('/wd/hub', '');
|
|
504
468
|
}
|
|
505
469
|
}
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
);
|
|
470
|
+
let result = pathname;
|
|
471
|
+
if (match) {
|
|
472
|
+
result = _.isArray(match.params?.command) ? `/${match.params.command.join('/')}` : '';
|
|
473
|
+
}
|
|
474
|
+
return _.trimEnd(result, '/');
|
|
512
475
|
}
|
|
513
476
|
}
|
|
514
477
|
|