@appium/types 0.9.1 → 0.10.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/LICENSE +1 -1
- package/build/lib/action.d.ts +21 -17
- package/build/lib/action.d.ts.map +1 -1
- package/build/lib/action.js +1 -1
- package/build/lib/action.js.map +1 -1
- package/build/lib/appium-config.d.ts +27 -27
- package/build/lib/appium-config.d.ts.map +1 -1
- package/build/lib/capabilities.d.ts +16 -16
- package/build/lib/capabilities.d.ts.map +1 -1
- package/build/lib/command.d.ts +98 -0
- package/build/lib/command.d.ts.map +1 -0
- package/build/lib/{logger.js → command.js} +1 -1
- package/build/lib/command.js.map +1 -0
- package/build/lib/config.d.ts +10 -10
- package/build/lib/config.d.ts.map +1 -1
- package/build/lib/constraints.d.ts +20 -20
- package/build/lib/constraints.js +1 -1
- package/build/lib/constraints.js.map +1 -1
- package/build/lib/driver.d.ts +39 -32
- package/build/lib/driver.d.ts.map +1 -1
- package/build/lib/index.d.ts +12 -64
- package/build/lib/index.d.ts.map +1 -1
- package/build/lib/index.js +1 -0
- package/build/lib/index.js.map +1 -1
- package/build/lib/plugin.d.ts +5 -4
- package/build/lib/plugin.d.ts.map +1 -1
- package/build/lib/standard-caps.d.ts +3 -3
- package/build/lib/standard-caps.d.ts.map +1 -1
- package/lib/action.ts +10 -13
- package/lib/command.ts +119 -0
- package/lib/constraints.js +1 -1
- package/lib/driver.ts +33 -35
- package/lib/index.ts +3 -73
- package/lib/plugin.ts +2 -1
- package/package.json +4 -4
- package/build/lib/extension.d.ts +0 -71
- package/build/lib/extension.d.ts.map +0 -1
- package/build/lib/extension.js +0 -3
- package/build/lib/extension.js.map +0 -1
- package/build/lib/logger.d.ts +0 -39
- package/build/lib/logger.d.ts.map +0 -1
- package/build/lib/logger.js.map +0 -1
- package/build/lib/server.d.ts +0 -21
- package/build/lib/server.d.ts.map +0 -1
- package/build/lib/server.js +0 -3
- package/build/lib/server.js.map +0 -1
- package/build/lib/util.d.ts +0 -16
- package/build/lib/util.d.ts.map +0 -1
- package/build/lib/util.js +0 -3
- package/build/lib/util.js.map +0 -1
package/build/lib/plugin.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { AppiumLogger, Class,
|
|
1
|
+
import { AppiumLogger, Class, UpdateServerCallback } from '.';
|
|
2
|
+
import { ExecuteMethodMap, MethodMap } from './command';
|
|
2
3
|
import { ExternalDriver } from './driver';
|
|
3
4
|
/**
|
|
4
5
|
* The interface describing the constructor and static properties of a Plugin.
|
|
@@ -66,19 +67,19 @@ export interface Plugin {
|
|
|
66
67
|
* `driver._eventHistory.commands.push({cmd: cmdName, startTime, endTime})` --
|
|
67
68
|
* after running plugin logic
|
|
68
69
|
*/
|
|
69
|
-
export
|
|
70
|
+
export type NextPluginCallback = () => Promise<void>;
|
|
70
71
|
/**
|
|
71
72
|
* Implementation of a command within a plugin
|
|
72
73
|
*
|
|
73
74
|
* At minimum, `D` must be `ExternalDriver`, but a plugin can be more narrow about which drivers it supports.
|
|
74
75
|
*/
|
|
75
|
-
export
|
|
76
|
+
export type PluginCommand<D extends ExternalDriver = ExternalDriver, TArgs extends readonly any[] = any[], TReturn = any> = (next: NextPluginCallback, driver: D, ...args: TArgs) => Promise<TReturn>;
|
|
76
77
|
/**
|
|
77
78
|
* Mainly for internal use.
|
|
78
79
|
*
|
|
79
80
|
* The third parameter is the possible constructor signatures for the plugin class.
|
|
80
81
|
*/
|
|
81
|
-
export
|
|
82
|
+
export type PluginClass<P extends Plugin = Plugin> = Class<P, PluginStatic<P>, [
|
|
82
83
|
pluginName: string,
|
|
83
84
|
cliArgs: Record<string, unknown>
|
|
84
85
|
]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../lib/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,KAAK,EAAE,gBAAgB,EAAE,SAAS,
|
|
1
|
+
{"version":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AAG,IACX,CAAC,IAAI,EAAE,kBAAkB,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAE9E;;;;GAIG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,KAAK,CACxD,CAAC,EACD,YAAY,CAAC,CAAC,CAAC,EACf;IAAC,UAAU,EAAE,MAAM;IAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAAC,CACvD,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export type PageLoadingStrategy = 'none' | 'eager' | 'normal';
|
|
2
|
+
export type ProxyTypes = 'pac' | 'noproxy' | 'autodetect' | 'system' | 'manual';
|
|
3
3
|
export interface ProxyObject {
|
|
4
4
|
proxyType?: ProxyTypes;
|
|
5
5
|
proxyAutoconfigUrl?: string;
|
|
@@ -15,7 +15,7 @@ export interface ProxyObject {
|
|
|
15
15
|
socksUsername?: string;
|
|
16
16
|
socksPassword?: string;
|
|
17
17
|
}
|
|
18
|
-
export
|
|
18
|
+
export type Timeouts = Record<'script' | 'pageLoad' | 'implicit', number>;
|
|
19
19
|
export interface StandardCapabilities {
|
|
20
20
|
/**
|
|
21
21
|
* Identifies the user agent.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standard-caps.d.ts","sourceRoot":"","sources":["../../lib/standard-caps.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"standard-caps.d.ts","sourceRoot":"","sources":["../../lib/standard-caps.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAC9D,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,SAAS,GAAG,YAAY,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAChF,MAAM,WAAW,W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2
|
-
* @module
|
|
3
2
|
* Portions Copyright (c) 2017 Igor Muchychka
|
|
4
3
|
* @see https://github.com/w3c-webdriver/w3c-webdriver
|
|
4
|
+
* @module
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* A W3C or JSONWP element.
|
|
9
|
+
*/
|
|
10
|
+
export interface Element<Id extends string = string> {
|
|
11
|
+
ELEMENT?: Id;
|
|
12
|
+
'element-6066-11e4-a52e-4f735466cecf': Id;
|
|
9
13
|
}
|
|
10
14
|
|
|
11
15
|
/**
|
|
@@ -72,11 +76,7 @@ export type KeyAction = PauseAction | KeyDownAction | KeyUpAction;
|
|
|
72
76
|
/**
|
|
73
77
|
* @group Actions
|
|
74
78
|
*/
|
|
75
|
-
export type PointerAction =
|
|
76
|
-
| PauseAction
|
|
77
|
-
| PointerMoveAction
|
|
78
|
-
| PointerUpAction
|
|
79
|
-
| PointerDownAction;
|
|
79
|
+
export type PointerAction = PauseAction | PointerMoveAction | PointerUpAction | PointerDownAction;
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
82
|
* @group Actions
|
|
@@ -116,10 +116,7 @@ export type PointerActionSequence = {
|
|
|
116
116
|
/**
|
|
117
117
|
* @group Actions
|
|
118
118
|
*/
|
|
119
|
-
export type ActionSequence =
|
|
120
|
-
| NullActionSequence
|
|
121
|
-
| KeyActionSequence
|
|
122
|
-
| PointerActionSequence;
|
|
119
|
+
export type ActionSequence = NullActionSequence | KeyActionSequence | PointerActionSequence;
|
|
123
120
|
|
|
124
121
|
/**
|
|
125
122
|
* @group Actions
|
|
@@ -194,5 +191,5 @@ export enum Key {
|
|
|
194
191
|
R_ARROWRIGHT = '\uE05A',
|
|
195
192
|
R_ARROWDOWN = '\uE05B',
|
|
196
193
|
R_INSERT = '\uE05C',
|
|
197
|
-
R_DELETE = '\uE05D'
|
|
194
|
+
R_DELETE = '\uE05D',
|
|
198
195
|
}
|
package/lib/command.ts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import {ConditionalPick, MultidimensionalReadonlyArray} from 'type-fest';
|
|
2
|
+
import {Driver, DriverCommand} from './driver';
|
|
3
|
+
import {Plugin, PluginCommand} from './plugin';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Defines the shape of a payload for a {@linkcode MethodDef}.
|
|
7
|
+
*/
|
|
8
|
+
export interface PayloadParams {
|
|
9
|
+
wrap?: string;
|
|
10
|
+
unwrap?: string;
|
|
11
|
+
required?: ReadonlyArray<string> | MultidimensionalReadonlyArray<string, 2>;
|
|
12
|
+
optional?: ReadonlyArray<string> | MultidimensionalReadonlyArray<string, 2>;
|
|
13
|
+
validate?: (obj: any, protocol: string) => boolean | string | undefined;
|
|
14
|
+
makeArgs?: (obj: any) => any;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A mapping of URL paths to HTTP methods to either a {@linkcode DriverMethodDef} or {@linkcode PluginMethodDef}.
|
|
18
|
+
*/
|
|
19
|
+
export type MethodMap<T extends Plugin | Driver> = T extends Plugin
|
|
20
|
+
? Readonly<PluginMethodMap<T>>
|
|
21
|
+
: T extends Driver
|
|
22
|
+
? Readonly<DriverMethodMap<T>>
|
|
23
|
+
: never;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A {@linkcode MethodMap} for a {@linkcode Driver}.
|
|
27
|
+
*/
|
|
28
|
+
export interface DriverMethodMap<T extends Driver> {
|
|
29
|
+
[key: string]: {
|
|
30
|
+
GET?: DriverMethodDef<T>;
|
|
31
|
+
POST?: DriverMethodDef<T>;
|
|
32
|
+
DELETE?: DriverMethodDef<T>;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Both {@linkcode DriverMethodDef} and {@linkcode PluginMethodDef} share these properties.
|
|
38
|
+
*/
|
|
39
|
+
export interface BaseMethodDef {
|
|
40
|
+
/**
|
|
41
|
+
* If true, this `Method` will never proxy.
|
|
42
|
+
*/
|
|
43
|
+
readonly neverProxy?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Specifies shape of payload
|
|
46
|
+
*/
|
|
47
|
+
readonly payloadParams?: PayloadParams;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* A definition of an exposed API command in a {@linkcode Driver}.
|
|
52
|
+
*/
|
|
53
|
+
export interface DriverMethodDef<T extends Driver> extends BaseMethodDef {
|
|
54
|
+
/**
|
|
55
|
+
* Name of the command.
|
|
56
|
+
*/
|
|
57
|
+
readonly command?: keyof ConditionalPick<Required<T>, DriverCommand>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* A definition of an exposed API command in a {@linkcode Plugin}.
|
|
62
|
+
*/
|
|
63
|
+
export interface PluginMethodDef<T extends Plugin> extends BaseMethodDef {
|
|
64
|
+
/**
|
|
65
|
+
* Name of the command.
|
|
66
|
+
*/
|
|
67
|
+
readonly command?: keyof ConditionalPick<Required<T>, DriverCommand>;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* A mapping of URL paths to HTTP methods to {@linkcode PluginMethodDef}.
|
|
72
|
+
*/
|
|
73
|
+
export interface PluginMethodMap<T extends Plugin> {
|
|
74
|
+
[key: string]: {
|
|
75
|
+
GET?: PluginMethodDef<T>;
|
|
76
|
+
POST?: PluginMethodDef<T>;
|
|
77
|
+
DELETE?: PluginMethodDef<T>;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface ExecuteMethodDef<Ext extends Plugin | Driver> {
|
|
82
|
+
command: keyof ConditionalPick<
|
|
83
|
+
Required<Ext>,
|
|
84
|
+
Ext extends Plugin ? PluginCommand : Ext extends Driver ? DriverCommand : never
|
|
85
|
+
>;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Properties shared by execute method definitions in both plugins and drivers
|
|
90
|
+
*/
|
|
91
|
+
export interface BaseExecuteMethodDef {
|
|
92
|
+
params?: {
|
|
93
|
+
required?: ReadonlyArray<string>;
|
|
94
|
+
optional?: ReadonlyArray<string>;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* A definition of an execute method in a {@linkcode Driver}.
|
|
100
|
+
*/
|
|
101
|
+
export interface DriverExecuteMethodDef<T extends Driver> extends BaseExecuteMethodDef {
|
|
102
|
+
command: keyof ConditionalPick<T, DriverCommand>;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* A definition of an execute method in a {@linkcode Plugin}.
|
|
107
|
+
*/
|
|
108
|
+
export interface PluginExecuteMethodDef<T extends Plugin> extends BaseExecuteMethodDef {
|
|
109
|
+
command: keyof ConditionalPick<T, PluginCommand>;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Definition of an execute method (which overloads the behavior of the `execute` command) in a {@linkcode Driver} or {@linkcode Plugin}.
|
|
114
|
+
*/
|
|
115
|
+
export type ExecuteMethodMap<T extends Plugin | Driver> = T extends Plugin
|
|
116
|
+
? Readonly<Record<string, PluginExecuteMethodDef<T>>>
|
|
117
|
+
: T extends Driver
|
|
118
|
+
? Readonly<Record<string, DriverExecuteMethodDef<T>>>
|
|
119
|
+
: never;
|
package/lib/constraints.js
CHANGED
package/lib/driver.ts
CHANGED
|
@@ -5,17 +5,16 @@ import {
|
|
|
5
5
|
AppiumServer,
|
|
6
6
|
UpdateServerCallback,
|
|
7
7
|
Class,
|
|
8
|
-
MethodMap,
|
|
9
8
|
AppiumLogger,
|
|
10
9
|
StringRecord,
|
|
11
10
|
ConstraintsToCaps,
|
|
12
11
|
BaseDriverCapConstraints,
|
|
13
12
|
W3CCapabilities,
|
|
14
13
|
Capabilities,
|
|
15
|
-
ExecuteMethodMap,
|
|
16
14
|
} from '.';
|
|
17
15
|
import {ServerArgs} from './config';
|
|
18
16
|
import {AsyncReturnType, Entries} from 'type-fest';
|
|
17
|
+
import {MethodMap, ExecuteMethodMap} from './command';
|
|
19
18
|
|
|
20
19
|
export interface ITimeoutCommands {
|
|
21
20
|
/**
|
|
@@ -66,7 +65,7 @@ export interface ITimeoutCommands {
|
|
|
66
65
|
*
|
|
67
66
|
* @returns The return value of the condition
|
|
68
67
|
*/
|
|
69
|
-
implicitWaitForCondition(condition: () => Promise<any>): Promise<unknown>;
|
|
68
|
+
implicitWaitForCondition(condition: (...args: any[]) => Promise<any>): Promise<unknown>;
|
|
70
69
|
|
|
71
70
|
/**
|
|
72
71
|
* Get the current timeouts
|
|
@@ -183,7 +182,7 @@ export interface IExecuteCommands {
|
|
|
183
182
|
*
|
|
184
183
|
* @returns The result of calling the Execute Method
|
|
185
184
|
*/
|
|
186
|
-
executeMethod(script: string, args: [StringRecord] | []): Promise<
|
|
185
|
+
executeMethod<TReturn = any>(script: string, args: [StringRecord] | any[]): Promise<TReturn>;
|
|
187
186
|
}
|
|
188
187
|
|
|
189
188
|
export interface MultiSessionData<
|
|
@@ -199,7 +198,7 @@ export type SingularSessionData<
|
|
|
199
198
|
Extra extends StringRecord | void = void
|
|
200
199
|
> = Capabilities<C, Extra> & {events?: EventHistory; error?: string};
|
|
201
200
|
|
|
202
|
-
export interface IFindCommands
|
|
201
|
+
export interface IFindCommands {
|
|
203
202
|
/**
|
|
204
203
|
* Find a UI element given a locator strategy and a selector, erroring if it can't be found
|
|
205
204
|
* @see {@link https://w3c.github.io/webdriver/#find-element}
|
|
@@ -294,7 +293,7 @@ export interface IFindCommands<Ctx = any> {
|
|
|
294
293
|
*
|
|
295
294
|
* @returns A single element or list of elements
|
|
296
295
|
*/
|
|
297
|
-
findElOrEls<Mult extends boolean>(
|
|
296
|
+
findElOrEls<Mult extends boolean, Ctx = any>(
|
|
298
297
|
strategy: string,
|
|
299
298
|
selector: string,
|
|
300
299
|
mult: Mult,
|
|
@@ -312,7 +311,7 @@ export interface IFindCommands<Ctx = any> {
|
|
|
312
311
|
*
|
|
313
312
|
* @returns A single element or list of elements
|
|
314
313
|
*/
|
|
315
|
-
findElOrElsWithProcessing<Mult extends boolean>(
|
|
314
|
+
findElOrElsWithProcessing<Mult extends boolean, Ctx = any>(
|
|
316
315
|
strategy: string,
|
|
317
316
|
selector: string,
|
|
318
317
|
mult: Mult,
|
|
@@ -328,41 +327,35 @@ export interface IFindCommands<Ctx = any> {
|
|
|
328
327
|
getPageSource(): Promise<string>;
|
|
329
328
|
}
|
|
330
329
|
|
|
331
|
-
export interface ILogCommands
|
|
330
|
+
export interface ILogCommands {
|
|
332
331
|
/**
|
|
333
332
|
* Definition of the available log types
|
|
334
333
|
*/
|
|
335
|
-
supportedLogTypes: Readonly<LogDefRecord
|
|
334
|
+
supportedLogTypes: Readonly<LogDefRecord>;
|
|
336
335
|
|
|
337
336
|
/**
|
|
338
337
|
* Get available log types as a list of strings
|
|
339
338
|
*/
|
|
340
|
-
getLogTypes(): Promise<
|
|
339
|
+
getLogTypes(): Promise<string[]>;
|
|
341
340
|
|
|
342
341
|
/**
|
|
343
342
|
* Get the log for a given log type.
|
|
344
343
|
*
|
|
345
344
|
* @param logType - Name/key of log type as defined in {@linkcode ILogCommands.supportedLogTypes}.
|
|
346
345
|
*/
|
|
347
|
-
getLog(
|
|
348
|
-
logType: keyof ILogCommands<C>['supportedLogTypes']
|
|
349
|
-
): Promise<
|
|
350
|
-
AsyncReturnType<
|
|
351
|
-
ILogCommands<C>['supportedLogTypes'][keyof ILogCommands<C>['supportedLogTypes']]['getter']
|
|
352
|
-
>
|
|
353
|
-
>;
|
|
346
|
+
getLog(logType: string): Promise<any[]>;
|
|
354
347
|
}
|
|
355
348
|
|
|
356
349
|
/**
|
|
357
350
|
* A record of {@linkcode LogDef} objects, keyed by the log type name.
|
|
358
351
|
* Used in {@linkcode ILogCommands.supportedLogTypes}
|
|
359
352
|
*/
|
|
360
|
-
export type LogDefRecord
|
|
353
|
+
export type LogDefRecord = Record<string, LogDef>;
|
|
361
354
|
|
|
362
355
|
/**
|
|
363
356
|
* A definition of a log type
|
|
364
357
|
*/
|
|
365
|
-
export interface LogDef
|
|
358
|
+
export interface LogDef {
|
|
366
359
|
/**
|
|
367
360
|
* Description of the log type.
|
|
368
361
|
*
|
|
@@ -375,7 +368,7 @@ export interface LogDef<C extends Constraints, T = unknown> {
|
|
|
375
368
|
*
|
|
376
369
|
* This implementation *should* drain, truncate or otherwise reset the log buffer.
|
|
377
370
|
*/
|
|
378
|
-
getter: (driver: Driver<C>) => Promise<T[]>;
|
|
371
|
+
getter: <C extends Constraints, T = any>(driver: Driver<C>) => Promise<T[]>;
|
|
379
372
|
}
|
|
380
373
|
|
|
381
374
|
export interface ISettingsCommands {
|
|
@@ -570,6 +563,8 @@ export interface Credential {
|
|
|
570
563
|
largeBlob?: string;
|
|
571
564
|
}
|
|
572
565
|
|
|
566
|
+
export type Orientation = 'LANDSCAPE' | 'PORTRAIT';
|
|
567
|
+
|
|
573
568
|
export interface EventHistory {
|
|
574
569
|
commands: EventHistoryCommand[];
|
|
575
570
|
[key: string]: any;
|
|
@@ -651,7 +646,7 @@ export interface Core<C extends Constraints = BaseDriverCapConstraints> {
|
|
|
651
646
|
canProxy(sessionId?: string): boolean;
|
|
652
647
|
proxyRouteIsAvoided(sessionId: string, method: string, url: string): boolean;
|
|
653
648
|
addManagedDriver(driver: Driver): void;
|
|
654
|
-
getManagedDrivers(): Driver[];
|
|
649
|
+
getManagedDrivers(): Driver<Constraints>[];
|
|
655
650
|
clearNewCommandTimeout(): Promise<void>;
|
|
656
651
|
logEvent(eventName: string): void;
|
|
657
652
|
driverForSession(sessionId: string): Core<C> | null;
|
|
@@ -666,12 +661,11 @@ export interface Core<C extends Constraints = BaseDriverCapConstraints> {
|
|
|
666
661
|
* `Ctx` would be the type of the element context (e.g., string, dictionary of some sort, etc.)
|
|
667
662
|
*/
|
|
668
663
|
export interface Driver<
|
|
669
|
-
C extends Constraints =
|
|
670
|
-
CArgs extends StringRecord = StringRecord
|
|
671
|
-
Ctx = any
|
|
664
|
+
C extends Constraints = Constraints,
|
|
665
|
+
CArgs extends StringRecord = StringRecord
|
|
672
666
|
> extends ISessionCommands,
|
|
673
|
-
ILogCommands
|
|
674
|
-
IFindCommands
|
|
667
|
+
ILogCommands,
|
|
668
|
+
IFindCommands,
|
|
675
669
|
ISettingsCommands,
|
|
676
670
|
ITimeoutCommands,
|
|
677
671
|
IEventCommands,
|
|
@@ -767,8 +761,7 @@ export interface Driver<
|
|
|
767
761
|
* External drivers must subclass `BaseDriver`, and can implement any of these methods.
|
|
768
762
|
* None of these are implemented within Appium itself.
|
|
769
763
|
*/
|
|
770
|
-
export interface ExternalDriver<C extends Constraints =
|
|
771
|
-
extends Driver<C> {
|
|
764
|
+
export interface ExternalDriver<C extends Constraints = Constraints> extends Driver<C> {
|
|
772
765
|
// The following properties are assigned by appium */
|
|
773
766
|
server?: AppiumServer;
|
|
774
767
|
serverHost?: string;
|
|
@@ -2205,11 +2198,11 @@ export interface ExternalDriver<C extends Constraints = BaseDriverCapConstraints
|
|
|
2205
2198
|
*
|
|
2206
2199
|
* This is likely unusable by external consumers, but YMMV!
|
|
2207
2200
|
*/
|
|
2208
|
-
export interface DriverStatic<
|
|
2201
|
+
export interface DriverStatic<T extends Driver> {
|
|
2209
2202
|
baseVersion: string;
|
|
2210
2203
|
updateServer?: UpdateServerCallback;
|
|
2211
|
-
newMethodMap?: MethodMap<
|
|
2212
|
-
executeMethodMap?: ExecuteMethodMap<
|
|
2204
|
+
newMethodMap?: MethodMap<T>;
|
|
2205
|
+
executeMethodMap?: ExecuteMethodMap<T>;
|
|
2213
2206
|
}
|
|
2214
2207
|
|
|
2215
2208
|
/**
|
|
@@ -2217,9 +2210,9 @@ export interface DriverStatic<D extends Driver> {
|
|
|
2217
2210
|
*
|
|
2218
2211
|
* This is likely unusable by external consumers, but YMMV!
|
|
2219
2212
|
*/
|
|
2220
|
-
export type DriverClass<
|
|
2221
|
-
|
|
2222
|
-
DriverStatic<
|
|
2213
|
+
export type DriverClass<T extends Driver = Driver> = Class<
|
|
2214
|
+
T,
|
|
2215
|
+
DriverStatic<T>,
|
|
2223
2216
|
[] | [Partial<ServerArgs>] | [Partial<ServerArgs>, boolean]
|
|
2224
2217
|
>;
|
|
2225
2218
|
|
|
@@ -2236,7 +2229,12 @@ export type DriverOpts<C extends Constraints = BaseDriverCapConstraints> = Serve
|
|
|
2236
2229
|
ExtraDriverOpts &
|
|
2237
2230
|
Partial<ConstraintsToCaps<C>>;
|
|
2238
2231
|
|
|
2239
|
-
|
|
2232
|
+
/**
|
|
2233
|
+
* An instance method of a driver class, whose name may be referenced by {@linkcode MethodDef.command}, and serves as an Appium command.
|
|
2234
|
+
*
|
|
2235
|
+
* Note that this signature differs from a `PluginCommand`.
|
|
2236
|
+
*/
|
|
2237
|
+
export type DriverCommand<TArgs = any, TRetval = unknown> = (...args: TArgs[]) => Promise<TRetval>;
|
|
2240
2238
|
|
|
2241
2239
|
export type DriverCommands<TArgs = any, TReturn = unknown> = Record<
|
|
2242
2240
|
string,
|
package/lib/index.ts
CHANGED
|
@@ -2,12 +2,10 @@ import type {Express} from 'express';
|
|
|
2
2
|
import type {Server} from 'http';
|
|
3
3
|
import type {Socket} from 'net';
|
|
4
4
|
import type {Logger} from 'npmlog';
|
|
5
|
-
import type {Class as _Class
|
|
5
|
+
import type {Class as _Class} from 'type-fest';
|
|
6
6
|
import type {Server as WSServer} from 'ws';
|
|
7
7
|
import {ServerArgs} from './config';
|
|
8
|
-
|
|
9
|
-
import {Plugin, PluginCommand} from './plugin';
|
|
10
|
-
|
|
8
|
+
export * from './command';
|
|
11
9
|
export * from './action';
|
|
12
10
|
export * from './appium-config';
|
|
13
11
|
export * from './capabilities';
|
|
@@ -80,80 +78,12 @@ export interface AppiumServerSocket extends Socket {
|
|
|
80
78
|
_openReqCount: number;
|
|
81
79
|
}
|
|
82
80
|
|
|
83
|
-
/**
|
|
84
|
-
* The definition of an extension method, which will be provided via Appium's API.
|
|
85
|
-
*
|
|
86
|
-
*/
|
|
87
|
-
export interface MethodDef<Ext extends Plugin | Driver> {
|
|
88
|
-
/**
|
|
89
|
-
* Name of the command.
|
|
90
|
-
*/
|
|
91
|
-
readonly command?: keyof ConditionalPick<
|
|
92
|
-
Required<Ext>,
|
|
93
|
-
Ext extends Plugin ? PluginCommand : Ext extends Driver ? DriverCommand : never
|
|
94
|
-
>;
|
|
95
|
-
/**
|
|
96
|
-
* If true, this `Method` will never proxy.
|
|
97
|
-
*/
|
|
98
|
-
readonly neverProxy?: boolean;
|
|
99
|
-
/**
|
|
100
|
-
* Specifies shape of payload
|
|
101
|
-
*/
|
|
102
|
-
readonly payloadParams?: PayloadParams;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export interface ExecuteMethodDef<Ext extends Driver | Plugin> {
|
|
106
|
-
command: keyof ConditionalPick<
|
|
107
|
-
Required<Ext>,
|
|
108
|
-
Ext extends Plugin ? PluginCommand : Ext extends Driver ? DriverCommand : never
|
|
109
|
-
>;
|
|
110
|
-
params?: {
|
|
111
|
-
required?: ReadonlyArray<string>;
|
|
112
|
-
optional?: ReadonlyArray<string>;
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
export type ExecuteMethodMap<Ext extends Driver | Plugin> = Readonly<
|
|
116
|
-
Record<string, Readonly<ExecuteMethodDef<Ext>>>
|
|
117
|
-
>;
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* An instance method of a driver class, whose name may be referenced by {@linkcode MethodDef.command}, and serves as an Appium command.
|
|
121
|
-
*
|
|
122
|
-
* Note that this signature differs from a `PluginCommand`.
|
|
123
|
-
*/
|
|
124
|
-
export type DriverCommand<TArgs = any, TRetval = unknown> = (...args: TArgs[]) => Promise<TRetval>;
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Defines the shape of a payload for a {@linkcode MethodDef}.
|
|
128
|
-
*/
|
|
129
|
-
export interface PayloadParams {
|
|
130
|
-
wrap?: string;
|
|
131
|
-
unwrap?: string;
|
|
132
|
-
required?: ReadonlyArray<string> | MultidimensionalReadonlyArray<string, 2>;
|
|
133
|
-
optional?: ReadonlyArray<string> | MultidimensionalReadonlyArray<string, 2>;
|
|
134
|
-
validate?: (obj: any, protocol: string) => boolean | string | undefined;
|
|
135
|
-
makeArgs?: (obj: any) => any;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* A mapping of URL paths to HTTP methods to {@linkcode MethodDef}s.
|
|
139
|
-
*/
|
|
140
|
-
export type MethodMap<Ext extends Plugin | Driver> = Readonly<
|
|
141
|
-
Record<
|
|
142
|
-
string,
|
|
143
|
-
{
|
|
144
|
-
GET?: MethodDef<Ext>;
|
|
145
|
-
POST?: MethodDef<Ext>;
|
|
146
|
-
DELETE?: MethodDef<Ext>;
|
|
147
|
-
}
|
|
148
|
-
>
|
|
149
|
-
>;
|
|
150
|
-
|
|
151
81
|
/**
|
|
152
82
|
* Wraps {@linkcode _Class `type-fest`'s `Class`} to include static members.
|
|
153
83
|
*/
|
|
154
84
|
export type Class<
|
|
155
85
|
Proto,
|
|
156
|
-
StaticMembers extends object =
|
|
86
|
+
StaticMembers extends object = object,
|
|
157
87
|
Args extends unknown[] = any[]
|
|
158
88
|
> = _Class<Proto, Args> & StaticMembers;
|
|
159
89
|
|
package/lib/plugin.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appium/types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "Various type declarations used across Appium",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"automation",
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"test:smoke": "node ./index.js"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@appium/schema": "^0.2.
|
|
40
|
+
"@appium/schema": "^0.2.6",
|
|
41
41
|
"@appium/tsconfig": "^0.2.4",
|
|
42
42
|
"@types/express": "4.17.17",
|
|
43
43
|
"@types/npmlog": "4.1.4",
|
|
44
44
|
"@types/ws": "8.5.4",
|
|
45
|
-
"type-fest": "3.
|
|
45
|
+
"type-fest": "3.6.1"
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|
|
48
48
|
"node": "^14.17.0 || ^16.13.0 || >=18.0.0",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "872b924a97c13142bdb8bf4218a4db324f309ce4",
|
|
55
55
|
"typedoc": {
|
|
56
56
|
"entryPoint": "./lib/index.ts"
|
|
57
57
|
}
|
package/build/lib/extension.d.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import type { Express } from 'express';
|
|
2
|
-
import { ConditionalPick, MultidimensionalReadonlyArray } from 'type-fest';
|
|
3
|
-
import { ServerArgs } from './config';
|
|
4
|
-
import { DriverCommand } from './driver';
|
|
5
|
-
import { PluginCommand } from './plugin';
|
|
6
|
-
import { AppiumServer } from './server';
|
|
7
|
-
/**
|
|
8
|
-
* The definition of an extension method, which will be provided via Appium's API.
|
|
9
|
-
*
|
|
10
|
-
*/
|
|
11
|
-
export interface MethodDef<Ext> {
|
|
12
|
-
/**
|
|
13
|
-
* Name of the command.
|
|
14
|
-
*/
|
|
15
|
-
readonly command?: keyof ConditionalPick<Required<Ext>, DriverCommand | PluginCommand>;
|
|
16
|
-
/**
|
|
17
|
-
* If true, this `Method` will never proxy.
|
|
18
|
-
*/
|
|
19
|
-
readonly neverProxy?: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Specifies shape of payload
|
|
22
|
-
*/
|
|
23
|
-
readonly payloadParams?: PayloadParams;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Defines the shape of a payload for a {@linkcode MethodDef}.
|
|
27
|
-
*/
|
|
28
|
-
export interface PayloadParams {
|
|
29
|
-
wrap?: string;
|
|
30
|
-
unwrap?: string;
|
|
31
|
-
required?: ReadonlyArray<string> | MultidimensionalReadonlyArray<string, 2>;
|
|
32
|
-
optional?: ReadonlyArray<string> | MultidimensionalReadonlyArray<string, 2>;
|
|
33
|
-
validate?: (obj: any, protocol: string) => boolean | string | undefined;
|
|
34
|
-
makeArgs?: (obj: any) => any;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* A mapping of URL paths to HTTP methods to {@linkcode MethodDef}s.
|
|
38
|
-
*/
|
|
39
|
-
export declare type MethodMap<Ext = any> = Readonly<Record<string, {
|
|
40
|
-
GET?: MethodDef<Ext>;
|
|
41
|
-
POST?: MethodDef<Ext>;
|
|
42
|
-
DELETE?: MethodDef<Ext>;
|
|
43
|
-
}>>;
|
|
44
|
-
/**
|
|
45
|
-
* The string referring to a "driver"-type extension
|
|
46
|
-
*/
|
|
47
|
-
export declare type DriverType = 'driver';
|
|
48
|
-
/**
|
|
49
|
-
* The string referring to a "plugin"-type extension
|
|
50
|
-
*
|
|
51
|
-
*/
|
|
52
|
-
export declare type PluginType = 'plugin';
|
|
53
|
-
/**
|
|
54
|
-
* The strings referring to all extension types.
|
|
55
|
-
*/
|
|
56
|
-
export declare type ExtensionType = DriverType | PluginType;
|
|
57
|
-
/**
|
|
58
|
-
* Optionally updates an Appium express app and http server, by calling
|
|
59
|
-
* methods that may mutate those objects. For example, you could call:
|
|
60
|
-
*
|
|
61
|
-
* `expressApp.get('/foo', handler)`
|
|
62
|
-
*
|
|
63
|
-
* In order to add a new route to Appium with this plugin. Or, you could add
|
|
64
|
-
* new listeners to the httpServer object.
|
|
65
|
-
*
|
|
66
|
-
* @param expressApp - the Express 'app' object used by Appium for route handling
|
|
67
|
-
* @param httpServer - the node HTTP server that hosts the app
|
|
68
|
-
* @param cliArgs - Arguments from config files, CLI, etc.
|
|
69
|
-
*/
|
|
70
|
-
export declare type UpdateServerCallback = (expressApp: Express, httpServer: AppiumServer, cliArgs: Partial<ServerArgs>) => Promise<void>;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