@appium/base-driver 9.3.1 → 9.3.3

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.
Files changed (81) hide show
  1. package/LICENSE +1 -1
  2. package/build/lib/basedriver/capabilities.d.ts +10 -0
  3. package/build/lib/basedriver/capabilities.d.ts.map +1 -1
  4. package/build/lib/basedriver/capabilities.js +57 -44
  5. package/build/lib/basedriver/capabilities.js.map +1 -1
  6. package/build/lib/basedriver/commands/event.d.ts +5 -9
  7. package/build/lib/basedriver/commands/event.d.ts.map +1 -1
  8. package/build/lib/basedriver/commands/event.js +28 -49
  9. package/build/lib/basedriver/commands/event.js.map +1 -1
  10. package/build/lib/basedriver/commands/execute.d.ts +5 -11
  11. package/build/lib/basedriver/commands/execute.d.ts.map +1 -1
  12. package/build/lib/basedriver/commands/execute.js +15 -39
  13. package/build/lib/basedriver/commands/execute.js.map +1 -1
  14. package/build/lib/basedriver/commands/find.d.ts +5 -12
  15. package/build/lib/basedriver/commands/find.d.ts.map +1 -1
  16. package/build/lib/basedriver/commands/find.js +38 -98
  17. package/build/lib/basedriver/commands/find.js.map +1 -1
  18. package/build/lib/basedriver/commands/index.d.ts +7 -3
  19. package/build/lib/basedriver/commands/index.d.ts.map +1 -1
  20. package/build/lib/basedriver/commands/index.js +20 -27
  21. package/build/lib/basedriver/commands/index.js.map +1 -1
  22. package/build/lib/basedriver/commands/log.d.ts +5 -10
  23. package/build/lib/basedriver/commands/log.d.ts.map +1 -1
  24. package/build/lib/basedriver/commands/log.js +17 -50
  25. package/build/lib/basedriver/commands/log.js.map +1 -1
  26. package/build/lib/basedriver/commands/mixin.d.ts +12 -0
  27. package/build/lib/basedriver/commands/mixin.d.ts.map +1 -0
  28. package/build/lib/basedriver/commands/mixin.js +17 -0
  29. package/build/lib/basedriver/commands/mixin.js.map +1 -0
  30. package/build/lib/basedriver/commands/session.d.ts +5 -11
  31. package/build/lib/basedriver/commands/session.d.ts.map +1 -1
  32. package/build/lib/basedriver/commands/session.js +20 -45
  33. package/build/lib/basedriver/commands/session.js.map +1 -1
  34. package/build/lib/basedriver/commands/settings.d.ts +5 -9
  35. package/build/lib/basedriver/commands/settings.d.ts.map +1 -1
  36. package/build/lib/basedriver/commands/settings.js +14 -34
  37. package/build/lib/basedriver/commands/settings.js.map +1 -1
  38. package/build/lib/basedriver/commands/timeout.d.ts +5 -9
  39. package/build/lib/basedriver/commands/timeout.d.ts.map +1 -1
  40. package/build/lib/basedriver/commands/timeout.js +107 -126
  41. package/build/lib/basedriver/commands/timeout.js.map +1 -1
  42. package/build/lib/basedriver/core.d.ts +12 -5
  43. package/build/lib/basedriver/core.d.ts.map +1 -1
  44. package/build/lib/basedriver/core.js +10 -45
  45. package/build/lib/basedriver/core.js.map +1 -1
  46. package/build/lib/basedriver/driver.d.ts +12 -12
  47. package/build/lib/basedriver/driver.d.ts.map +1 -1
  48. package/build/lib/basedriver/driver.js +22 -14
  49. package/build/lib/basedriver/driver.js.map +1 -1
  50. package/build/lib/basedriver/helpers.d.ts.map +1 -1
  51. package/build/lib/basedriver/helpers.js +9 -3
  52. package/build/lib/basedriver/helpers.js.map +1 -1
  53. package/build/lib/express/server.d.ts +3 -15
  54. package/build/lib/express/server.d.ts.map +1 -1
  55. package/build/lib/index.d.ts +1 -1
  56. package/build/lib/index.d.ts.map +1 -1
  57. package/build/lib/index.js +2 -1
  58. package/build/lib/index.js.map +1 -1
  59. package/lib/basedriver/capabilities.js +68 -54
  60. package/lib/basedriver/commands/event.ts +48 -0
  61. package/lib/basedriver/commands/execute.ts +39 -0
  62. package/lib/basedriver/commands/find.ts +79 -0
  63. package/lib/basedriver/commands/index.ts +7 -0
  64. package/lib/basedriver/commands/log.ts +36 -0
  65. package/lib/basedriver/commands/mixin.ts +14 -0
  66. package/lib/basedriver/commands/session.ts +34 -0
  67. package/lib/basedriver/commands/settings.ts +25 -0
  68. package/lib/basedriver/commands/timeout.ts +155 -0
  69. package/lib/basedriver/core.js +41 -20
  70. package/lib/basedriver/driver.js +9 -12
  71. package/lib/basedriver/helpers.js +9 -3
  72. package/lib/index.js +1 -0
  73. package/package.json +8 -8
  74. package/lib/basedriver/commands/event.js +0 -63
  75. package/lib/basedriver/commands/execute.js +0 -45
  76. package/lib/basedriver/commands/find.js +0 -108
  77. package/lib/basedriver/commands/index.js +0 -35
  78. package/lib/basedriver/commands/log.js +0 -64
  79. package/lib/basedriver/commands/session.js +0 -57
  80. package/lib/basedriver/commands/settings.js +0 -38
  81. package/lib/basedriver/commands/timeout.js +0 -168
@@ -0,0 +1,79 @@
1
+ import {Constraints, IFindCommands} from '@appium/types';
2
+ import {errors} from '../../protocol';
3
+ import {BaseDriver} from '../driver';
4
+ import {mixin} from './mixin';
5
+
6
+ declare module '../driver' {
7
+ interface BaseDriver<C extends Constraints> extends IFindCommands {}
8
+ }
9
+
10
+ const FindCommands: IFindCommands = {
11
+ async findElement<C extends Constraints>(this: BaseDriver<C>, strategy, selector) {
12
+ return await this.findElOrElsWithProcessing(strategy, selector, false);
13
+ },
14
+
15
+ async findElements<C extends Constraints>(this: BaseDriver<C>, strategy, selector) {
16
+ return await this.findElOrElsWithProcessing(strategy, selector, true);
17
+ },
18
+
19
+ async findElementFromElement<C extends Constraints>(
20
+ this: BaseDriver<C>,
21
+ strategy: string,
22
+ selector: string,
23
+ elementId: string
24
+ ) {
25
+ return await this.findElOrElsWithProcessing(strategy, selector, false, elementId);
26
+ },
27
+
28
+ async findElementsFromElement<C extends Constraints>(
29
+ this: BaseDriver<C>,
30
+ strategy: string,
31
+ selector: string,
32
+ elementId: string
33
+ ) {
34
+ return await this.findElOrElsWithProcessing(strategy, selector, true, elementId);
35
+ },
36
+
37
+ /**
38
+ * Returns an object which adheres to the way the JSON Wire Protocol represents elements:
39
+ *
40
+ * Override this for your own driver!
41
+ */
42
+ async findElOrEls<C extends Constraints, Mult extends boolean, Ctx = any>(
43
+ this: BaseDriver<C>,
44
+ strategy: string,
45
+ selector: string,
46
+ mult: Mult,
47
+ context: Ctx
48
+ ) {
49
+ throw new errors.NotImplementedError('Not implemented yet for find.');
50
+ },
51
+
52
+ async getPageSource<C extends Constraints>(this: BaseDriver<C>) {
53
+ throw new errors.NotImplementedError('Not implemented yet for find.');
54
+ },
55
+
56
+ async findElOrElsWithProcessing<C extends Constraints, Mult extends boolean, Ctx = any>(
57
+ this: BaseDriver<C>,
58
+ strategy: string,
59
+ selector: string,
60
+ mult: Mult,
61
+ context?: Ctx
62
+ ) {
63
+ this.validateLocatorStrategy(strategy);
64
+ try {
65
+ return await this.findElOrEls(strategy, selector, mult, context);
66
+ } catch (err) {
67
+ if (this.opts.printPageSourceOnFindFailure) {
68
+ const src = await this.getPageSource();
69
+ this.log.debug(`Error finding element${mult ? 's' : ''}: ${err.message}`);
70
+ this.log.debug(`Page source requested through 'printPageSourceOnFindFailure':`);
71
+ this.log.debug(src);
72
+ }
73
+ // still want the error to occur
74
+ throw err;
75
+ }
76
+ },
77
+ };
78
+
79
+ mixin(FindCommands);
@@ -0,0 +1,7 @@
1
+ export * from './event';
2
+ export * from './find';
3
+ export * from './log';
4
+ export * from './session';
5
+ export * from './settings';
6
+ export * from './timeout';
7
+ export * from './execute';
@@ -0,0 +1,36 @@
1
+ import {Constraints, Driver, ILogCommands, LogDefRecord} from '@appium/types';
2
+ import _ from 'lodash';
3
+ import {BaseDriver} from '../driver';
4
+ import {mixin} from './mixin';
5
+
6
+ declare module '../driver' {
7
+ interface BaseDriver<C extends Constraints> extends ILogCommands {}
8
+ }
9
+
10
+ const LogCommands: ILogCommands = {
11
+ supportedLogTypes: <LogDefRecord>{},
12
+
13
+ async getLogTypes<C extends Constraints>(this: BaseDriver<C>) {
14
+ this.log.debug('Retrieving supported log types');
15
+ return Object.keys(this.supportedLogTypes);
16
+ },
17
+
18
+ async getLog<C extends Constraints>(
19
+ this: Driver<C>,
20
+ logType: keyof ILogCommands['supportedLogTypes']
21
+ ) {
22
+ this.log.debug(`Retrieving '${String(logType)}' logs`);
23
+
24
+ if (!(logType in this.supportedLogTypes)) {
25
+ const logsTypesWithDescriptions = _.mapValues(this.supportedLogTypes, 'description');
26
+ throw new Error(
27
+ `Unsupported log type '${String(logType)}'. ` +
28
+ `Supported types: ${JSON.stringify(logsTypesWithDescriptions)}`
29
+ );
30
+ }
31
+
32
+ return await this.supportedLogTypes[logType].getter(this);
33
+ },
34
+ };
35
+
36
+ mixin(LogCommands);
@@ -0,0 +1,14 @@
1
+ import {Constraints} from '@appium/types';
2
+ import {BaseDriver} from '../driver';
3
+
4
+ /**
5
+ * This function assigns a mixin `T` to the `FakeDriver` class' prototype.
6
+ * While each mixin has its own interface which is (in isolation) unrelated to `FakeDriver`, the constraint
7
+ * on this generic type `T` is that it must be a partial of `FakeDriver`'s interface. This enforces
8
+ * that it does not conflict with the existing interface of `FakeDriver`. In that way, you can
9
+ * think of it as a type guard.
10
+ * @param mixin Mixin implementation
11
+ */
12
+ export function mixin<C extends Constraints, T extends Partial<BaseDriver<C>>>(mixin: T): void {
13
+ Object.assign(BaseDriver.prototype, mixin);
14
+ }
@@ -0,0 +1,34 @@
1
+ import {Constraints, ISessionCommands, MultiSessionData} from '@appium/types';
2
+ import {BaseDriver} from '../driver';
3
+ import {mixin} from './mixin';
4
+
5
+ declare module '../driver' {
6
+ interface BaseDriver<C extends Constraints> extends ISessionCommands {}
7
+ }
8
+
9
+ const SessionCommands: ISessionCommands = {
10
+ async getSessions<C extends Constraints>(this: BaseDriver<C>) {
11
+ const ret: MultiSessionData[] = [];
12
+
13
+ if (this.sessionId) {
14
+ ret.push({
15
+ id: this.sessionId,
16
+ capabilities: this.caps,
17
+ });
18
+ }
19
+
20
+ return ret;
21
+ },
22
+
23
+ /**
24
+ * Returns capabilities for the session and event history (if applicable)
25
+ */
26
+ async getSession<C extends Constraints>(this: BaseDriver<C>) {
27
+ if (this.caps.eventTimings) {
28
+ return {...this.caps, events: this.eventHistory};
29
+ }
30
+ return this.caps;
31
+ },
32
+ };
33
+
34
+ mixin(SessionCommands);
@@ -0,0 +1,25 @@
1
+ import {BaseDriver} from '../driver';
2
+ import {Constraints, ISettingsCommands, StringRecord} from '@appium/types';
3
+ import {mixin} from './mixin';
4
+
5
+ declare module '../driver' {
6
+ interface BaseDriver<C extends Constraints> extends ISettingsCommands {}
7
+ }
8
+
9
+ const SettingsCommands: ISettingsCommands = {
10
+ async updateSettings<C extends Constraints>(this: BaseDriver<C>, newSettings: StringRecord) {
11
+ if (!this.settings) {
12
+ this.log.errorAndThrow('Cannot update settings; settings object not found');
13
+ }
14
+ return await this.settings.update(newSettings);
15
+ },
16
+
17
+ async getSettings<C extends Constraints>(this: BaseDriver<C>) {
18
+ if (!this.settings) {
19
+ this.log.errorAndThrow('Cannot get settings; settings object not found');
20
+ }
21
+ return this.settings.getSettings();
22
+ },
23
+ };
24
+
25
+ mixin(SettingsCommands);
@@ -0,0 +1,155 @@
1
+ // @ts-check
2
+
3
+ /* eslint-disable no-unused-vars */
4
+ /* eslint-disable require-await */
5
+ import {waitForCondition} from 'asyncbox';
6
+ import _ from 'lodash';
7
+ import {util} from '@appium/support';
8
+ import {errors} from '../../protocol';
9
+ import {BaseDriver} from '../driver';
10
+ import {Constraints, ITimeoutCommands} from '@appium/types';
11
+ import {mixin} from './mixin';
12
+
13
+ declare module '../driver' {
14
+ interface BaseDriver<C extends Constraints> extends ITimeoutCommands {}
15
+ }
16
+
17
+ const MIN_TIMEOUT = 0;
18
+
19
+ const TimeoutCommands: ITimeoutCommands = {
20
+ async timeouts(type, ms, script, pageLoad, implicit) {
21
+ if (util.hasValue(type) && util.hasValue(ms)) {
22
+ this.log.debug(`MJSONWP timeout arguments: ${JSON.stringify({type, ms})}}`);
23
+
24
+ switch (type) {
25
+ case 'command':
26
+ await this.newCommandTimeout(ms);
27
+ return;
28
+ case 'implicit':
29
+ await this.implicitWaitMJSONWP(ms);
30
+ return;
31
+ case 'page load':
32
+ await this.pageLoadTimeoutMJSONWP(ms);
33
+ return;
34
+ case 'script':
35
+ await this.scriptTimeoutMJSONWP(ms);
36
+ return;
37
+ default:
38
+ throw new Error(`'${type}' type is not supported for MJSONWP timeout`);
39
+ }
40
+ }
41
+
42
+ // Otherwise assume it is W3C protocol
43
+ this.log.debug(
44
+ `W3C timeout argument: ${JSON.stringify({
45
+ script,
46
+ pageLoad,
47
+ implicit,
48
+ })}}`
49
+ );
50
+ if (util.hasValue(script)) {
51
+ await this.scriptTimeoutW3C(script);
52
+ }
53
+ if (util.hasValue(pageLoad)) {
54
+ await this.pageLoadTimeoutW3C(pageLoad);
55
+ }
56
+ if (util.hasValue(implicit)) {
57
+ await this.implicitWaitW3C(implicit);
58
+ }
59
+ },
60
+
61
+ async getTimeouts() {
62
+ return {
63
+ command: this.newCommandTimeoutMs,
64
+ implicit: this.implicitWaitMs,
65
+ };
66
+ },
67
+
68
+ // implicit
69
+ async implicitWaitW3C(ms) {
70
+ await this.implicitWait(ms);
71
+ },
72
+
73
+ async implicitWaitMJSONWP(ms) {
74
+ await this.implicitWait(ms);
75
+ },
76
+
77
+ async implicitWait(ms) {
78
+ await this.setImplicitWait(this.parseTimeoutArgument(ms));
79
+ },
80
+
81
+ // pageLoad
82
+ async pageLoadTimeoutW3C(ms) {
83
+ throw new errors.NotImplementedError('Not implemented yet for pageLoad.');
84
+ },
85
+
86
+ async pageLoadTimeoutMJSONWP(ms) {
87
+ throw new errors.NotImplementedError('Not implemented yet for pageLoad.');
88
+ },
89
+
90
+ // script
91
+ async scriptTimeoutW3C(ms) {
92
+ throw new errors.NotImplementedError('Not implemented yet for script.');
93
+ },
94
+
95
+ async scriptTimeoutMJSONWP(ms) {
96
+ throw new errors.NotImplementedError('Not implemented yet for script.');
97
+ },
98
+
99
+ // command
100
+ async newCommandTimeout(ms) {
101
+ this.setNewCommandTimeout(this.parseTimeoutArgument(ms));
102
+ },
103
+
104
+ setImplicitWait(ms) {
105
+ // eslint-disable-line require-await
106
+ this.implicitWaitMs = ms;
107
+ this.log.debug(`Set implicit wait to ${ms}ms`);
108
+ if (this.managedDrivers && this.managedDrivers.length) {
109
+ this.log.debug('Setting implicit wait on managed drivers');
110
+ for (const driver of this.managedDrivers) {
111
+ if (_.isFunction(driver.setImplicitWait)) {
112
+ driver.setImplicitWait(ms);
113
+ }
114
+ }
115
+ }
116
+ },
117
+
118
+ setNewCommandTimeout(ms) {
119
+ this.newCommandTimeoutMs = ms;
120
+ this.log.debug(`Set new command timeout to ${ms}ms`);
121
+ if (this.managedDrivers && this.managedDrivers.length) {
122
+ this.log.debug('Setting new command timeout on managed drivers');
123
+ for (const driver of this.managedDrivers) {
124
+ if (_.isFunction(driver.setNewCommandTimeout)) {
125
+ driver.setNewCommandTimeout(ms);
126
+ }
127
+ }
128
+ }
129
+ },
130
+
131
+ async implicitWaitForCondition(condFn) {
132
+ this.log.debug(`Waiting up to ${this.implicitWaitMs} ms for condition`);
133
+ const wrappedCondFn = async (...args: any[]) => {
134
+ // reset command timeout
135
+ await this.clearNewCommandTimeout();
136
+
137
+ return await condFn(...args);
138
+ };
139
+ return await waitForCondition(wrappedCondFn, {
140
+ waitMs: this.implicitWaitMs,
141
+ intervalMs: 500,
142
+ logger: this.log,
143
+ });
144
+ },
145
+
146
+ parseTimeoutArgument<C extends Constraints>(this: BaseDriver<C>, ms: number | string) {
147
+ const duration = parseInt(String(ms), 10);
148
+ if (_.isNaN(duration) || duration < MIN_TIMEOUT) {
149
+ throw new errors.UnknownError(`Invalid timeout value '${ms}'`);
150
+ }
151
+ return duration;
152
+ },
153
+ };
154
+
155
+ mixin(TimeoutCommands);
@@ -29,13 +29,10 @@ class DriverCore {
29
29
  */
30
30
  static baseVersion = BASEDRIVER_VER;
31
31
 
32
- /** @type {import('@appium/types').ExecuteMethodMap<DriverCore>} */
33
- static executeMethodMap = {};
34
-
35
32
  /**
36
33
  * @type {string?}
37
34
  */
38
- sessionId = null;
35
+ sessionId;
39
36
 
40
37
  /**
41
38
  * @type {import('@appium/types').DriverOpts<C>}
@@ -47,7 +44,8 @@ class DriverCore {
47
44
  */
48
45
  initialOpts;
49
46
 
50
- helpers = helpers;
47
+ /** @type {typeof helpers} */
48
+ helpers;
51
49
 
52
50
  /**
53
51
  * basePath is used for several purposes, for example in setting up
@@ -56,39 +54,43 @@ class DriverCore {
56
54
  * initially but it is automatically updated during any actual program
57
55
  * execution by the routeConfiguringFunction, which is necessarily run as
58
56
  * the entrypoint for any Appium server
57
+ * @type {string}
59
58
  */
60
- basePath = DEFAULT_BASE_PATH;
59
+ basePath;
61
60
 
62
- relaxedSecurityEnabled = false;
61
+ /** @type {boolean} */
62
+ relaxedSecurityEnabled;
63
63
 
64
64
  /** @type {string[]} */
65
- allowInsecure = [];
65
+ allowInsecure;
66
66
 
67
67
  /** @type {string[]} */
68
- denyInsecure = [];
68
+ denyInsecure;
69
69
 
70
- newCommandTimeoutMs = NEW_COMMAND_TIMEOUT_MS;
70
+ /** @type {number} */
71
+ newCommandTimeoutMs;
71
72
 
72
- implicitWaitMs = 0;
73
+ /** @type {number} */
74
+ implicitWaitMs;
73
75
 
74
76
  /** @type {string[]} */
75
- locatorStrategies = [];
77
+ locatorStrategies;
76
78
 
77
79
  /** @type {string[]} */
78
- webLocatorStrategies = [];
80
+ webLocatorStrategies;
79
81
 
80
82
  /** @type {Driver[]} */
81
- managedDrivers = [];
83
+ managedDrivers;
82
84
 
83
85
  /** @type {NodeJS.Timeout?} */
84
- noCommandTimer = null;
86
+ noCommandTimer;
85
87
 
86
88
  /** @type {EventHistory} */
87
- _eventHistory = {commands: []};
89
+ _eventHistory;
88
90
 
89
91
  // used to handle driver events
90
92
  /** @type {NodeJS.EventEmitter} */
91
- eventEmitter = new EventEmitter();
93
+ eventEmitter;
92
94
 
93
95
  /**
94
96
  * @type {AppiumLogger}
@@ -97,8 +99,9 @@ class DriverCore {
97
99
 
98
100
  /**
99
101
  * @protected
102
+ * @type {boolean}
100
103
  */
101
- shutdownUnexpectedly = false;
104
+ shutdownUnexpectedly;
102
105
 
103
106
  /**
104
107
  * @type {boolean}
@@ -107,16 +110,18 @@ class DriverCore {
107
110
 
108
111
  /**
109
112
  * @protected
113
+ * @type {AsyncLock}
110
114
  */
111
- commandsQueueGuard = new AsyncLock();
115
+ commandsQueueGuard;
112
116
 
113
117
  /**
114
118
  * settings should be instantiated by drivers which extend BaseDriver, but
115
119
  * we set it to an empty DeviceSettings instance here to make sure that the
116
120
  * default settings are applied even if an extending driver doesn't utilize
117
121
  * the settings functionality itself
122
+ * @type {DeviceSettings}
118
123
  */
119
- settings = new DeviceSettings();
124
+ settings;
120
125
 
121
126
  /**
122
127
  * @param {DriverOpts<C>} opts
@@ -139,6 +144,22 @@ class DriverCore {
139
144
  this.initialOpts = _.cloneDeep(opts);
140
145
 
141
146
  this.sessionId = null;
147
+ this.helpers = helpers;
148
+ this.basePath = DEFAULT_BASE_PATH;
149
+ this.relaxedSecurityEnabled = false;
150
+ this.allowInsecure = [];
151
+ this.denyInsecure = [];
152
+ this.newCommandTimeoutMs = NEW_COMMAND_TIMEOUT_MS;
153
+ this.implicitWaitMs = 0;
154
+ this.locatorStrategies = [];
155
+ this.webLocatorStrategies = [];
156
+ this.managedDrivers = [];
157
+ this.noCommandTimer = null;
158
+ this._eventHistory = {commands: []};
159
+ this.eventEmitter = new EventEmitter();
160
+ this.shutdownUnexpectedly = false;
161
+ this.commandsQueueGuard = new AsyncLock();
162
+ this.settings = new DeviceSettings();
142
163
  }
143
164
 
144
165
  get log() {
@@ -1,14 +1,13 @@
1
1
  /* eslint-disable require-await */
2
2
  /* eslint-disable no-unused-vars */
3
3
 
4
- import {validateCaps, PREFIXED_APPIUM_OPTS_CAP, processCapabilities} from './capabilities';
4
+ import {validateCaps, processCapabilities} from './capabilities';
5
5
  import {DriverCore} from './core';
6
6
  import {util} from '@appium/support';
7
7
  import B from 'bluebird';
8
8
  import _ from 'lodash';
9
9
  import {fixCaps, isW3cCaps} from '../helpers/capabilities';
10
10
  import {DELETE_SESSION_COMMAND, determineProtocol, errors} from '../protocol';
11
- import {createBaseDriverClass} from './commands';
12
11
  import helpers from './helpers';
13
12
  import {BASE_DESIRED_CAP_CONSTRAINTS} from '@appium/types';
14
13
 
@@ -22,9 +21,10 @@ const ON_UNEXPECTED_SHUTDOWN_EVENT = 'onUnexpectedShutdown';
22
21
  * @implements {SessionHandler<C>}
23
22
  * @template {Constraints} C
24
23
  * @template {StringRecord} [CArgs=StringRecord]
24
+ * @implements {Driver<C, CArgs>}
25
25
  * @extends {DriverCore<C>}
26
26
  */
27
- export class BaseDriverCore extends DriverCore {
27
+ export class BaseDriver extends DriverCore {
28
28
  /**
29
29
  * @type {CArgs & ServerArgs}
30
30
  */
@@ -59,7 +59,7 @@ export class BaseDriverCore extends DriverCore {
59
59
  super(opts, shouldValidateCaps);
60
60
 
61
61
  /**
62
- * This must be assigned here because the declaration of {@linkcode BaseDriverCore.opts} above
62
+ * This must be assigned here because the declaration of {@linkcode BaseDriver.opts} above
63
63
  * blows away {@linkcode DriverCore.opts}.
64
64
  */
65
65
  this.opts = opts;
@@ -407,12 +407,9 @@ export class BaseDriverCore extends DriverCore {
407
407
  }
408
408
  }
409
409
 
410
- /**
411
- * This ensures that all of the mixins correctly implement the interface described in {@linkcode Driver}.
412
- * @template {Constraints} [C={}]
413
- * @implements {Driver<C>}
414
- */
415
- export class BaseDriver extends createBaseDriverClass(BaseDriverCore) {}
410
+ // eslint-disable-next-line import/no-unresolved
411
+ export * from './commands';
412
+
416
413
  export default BaseDriver;
417
414
 
418
415
  /**
@@ -433,11 +430,11 @@ export default BaseDriver;
433
430
  */
434
431
 
435
432
  /**
436
- * This is used to extend {@linkcode BaseDriverCore} by the mixins and also external drivers.
433
+ * This is used to extend {@linkcode BaseDriver} by the mixins and also external drivers.
437
434
  * @template {Constraints} C
438
435
  * @template [Proto={}]
439
436
  * @template [Static={}]
440
- * @typedef {import('@appium/types').Class<BaseDriverCore<C> & Proto,import('@appium/types').DriverStatic & Static>} BaseDriverBase
437
+ * @typedef {import('@appium/types').Class<BaseDriver<C> & Proto,import('@appium/types').DriverStatic & Static>} BaseDriverBase
441
438
  */
442
439
 
443
440
  /**
@@ -52,17 +52,22 @@ process.on('exit', () => {
52
52
  }
53
53
  });
54
54
 
55
- async function retrieveHeaders(link) {
55
+ /**
56
+ *
57
+ * @param {string} url
58
+ * @returns {Promise<import('axios').AxiosResponse['headers']>}
59
+ */
60
+ async function retrieveHeaders(url) {
56
61
  try {
57
62
  return (
58
63
  await axios({
59
- url: link,
64
+ url,
60
65
  method: 'HEAD',
61
66
  timeout: 5000,
62
67
  })
63
68
  ).headers;
64
69
  } catch (e) {
65
- logger.info(`Cannot send HEAD request to '${link}'. Original error: ${e.message}`);
70
+ logger.info(`Cannot send HEAD request to '${url}'. Original error: ${e.message}`);
66
71
  }
67
72
  return {};
68
73
  }
@@ -228,6 +233,7 @@ async function configureApp(app, options = /** @type {ConfigureAppOptions} */ ({
228
233
  let newApp = app;
229
234
  let shouldUnzipApp = false;
230
235
  let packageHash = null;
236
+ /** @type {import('axios').AxiosResponse['headers']?} */
231
237
  let headers = null;
232
238
  /** @type {RemoteAppProps} */
233
239
  const remoteAppProps = {
package/lib/index.js CHANGED
@@ -35,6 +35,7 @@ export {
35
35
  isStandardCap,
36
36
  validateCaps,
37
37
  promoteAppiumOptions,
38
+ promoteAppiumOptionsForObject,
38
39
  } from './basedriver/capabilities';
39
40
 
40
41
  // Web socket helpers
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appium/base-driver",
3
- "version": "9.3.1",
3
+ "version": "9.3.3",
4
4
  "description": "Base driver class for Appium drivers",
5
5
  "keywords": [
6
6
  "automation",
@@ -43,8 +43,8 @@
43
43
  "test:unit": "mocha \"./test/unit/**/*.spec.js\""
44
44
  },
45
45
  "dependencies": {
46
- "@appium/support": "^3.1.5",
47
- "@appium/types": "^0.9.1",
46
+ "@appium/support": "^3.1.7",
47
+ "@appium/types": "^0.10.1",
48
48
  "@colors/colors": "1.5.0",
49
49
  "@types/async-lock": "1.4.0",
50
50
  "@types/bluebird": "3.5.38",
@@ -53,19 +53,19 @@
53
53
  "@types/serve-favicon": "2.5.3",
54
54
  "async-lock": "1.4.0",
55
55
  "asyncbox": "2.9.4",
56
- "axios": "1.2.3",
56
+ "axios": "1.3.4",
57
57
  "bluebird": "3.7.2",
58
- "body-parser": "1.20.1",
58
+ "body-parser": "1.20.2",
59
59
  "es6-error": "4.1.1",
60
60
  "express": "4.18.2",
61
61
  "http-status-codes": "2.2.0",
62
62
  "lodash": "4.17.21",
63
- "lru-cache": "7.14.1",
63
+ "lru-cache": "7.18.3",
64
64
  "method-override": "3.0.0",
65
65
  "morgan": "1.10.0",
66
66
  "serve-favicon": "2.5.0",
67
67
  "source-map-support": "0.5.21",
68
- "type-fest": "3.5.6",
68
+ "type-fest": "3.6.1",
69
69
  "validate.js": "0.13.1"
70
70
  },
71
71
  "engines": {
@@ -75,7 +75,7 @@
75
75
  "publishConfig": {
76
76
  "access": "public"
77
77
  },
78
- "gitHead": "322363b8876a7ea7b630d538e22965f7bab0ea06",
78
+ "gitHead": "872b924a97c13142bdb8bf4218a4db324f309ce4",
79
79
  "typedoc": {
80
80
  "entryPoint": "./lib/index.js"
81
81
  }