@appium/types 0.7.0 → 0.9.0
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/build/lib/appium-config.js +1 -1
- package/build/lib/capabilities.d.ts +2 -12
- package/build/lib/capabilities.d.ts.map +1 -1
- package/build/lib/driver.d.ts +1382 -28
- package/build/lib/driver.d.ts.map +1 -1
- package/build/lib/extension.d.ts +71 -0
- package/build/lib/extension.d.ts.map +1 -0
- package/build/lib/extension.js +3 -0
- package/build/lib/extension.js.map +1 -0
- package/build/lib/index.d.ts +13 -3
- package/build/lib/index.d.ts.map +1 -1
- package/build/lib/index.js.map +1 -1
- package/build/lib/logger.d.ts +39 -0
- package/build/lib/logger.d.ts.map +1 -0
- package/build/lib/logger.js +3 -0
- package/build/lib/logger.js.map +1 -0
- package/build/lib/plugin.d.ts +9 -6
- package/build/lib/plugin.d.ts.map +1 -1
- package/build/lib/server.d.ts +21 -0
- package/build/lib/server.d.ts.map +1 -0
- package/build/lib/server.js +3 -0
- package/build/lib/server.js.map +1 -0
- package/build/lib/standard-caps.d.ts +65 -0
- package/build/lib/standard-caps.d.ts.map +1 -0
- package/build/lib/standard-caps.js +3 -0
- package/build/lib/standard-caps.js.map +1 -0
- package/build/lib/util.d.ts +16 -0
- package/build/lib/util.d.ts.map +1 -0
- package/build/lib/util.js +3 -0
- package/build/lib/util.js.map +1 -0
- package/build/tsconfig.tsbuildinfo +1 -1
- package/lib/appium-config.ts +1 -1
- package/lib/capabilities.ts +3 -12
- package/lib/driver.ts +1590 -35
- package/lib/index.ts +22 -3
- package/lib/plugin.ts +13 -15
- package/lib/standard-caps.ts +65 -0
- package/package.json +8 -7
- package/tsconfig.json +13 -0
package/lib/index.ts
CHANGED
|
@@ -5,6 +5,8 @@ import type {Logger} from 'npmlog';
|
|
|
5
5
|
import type {Class as _Class, ConditionalPick, MultidimensionalReadonlyArray} from 'type-fest';
|
|
6
6
|
import type {Server as WSServer} from 'ws';
|
|
7
7
|
import {ServerArgs} from './config';
|
|
8
|
+
import {Driver} from './driver';
|
|
9
|
+
import {Plugin, PluginCommand} from './plugin';
|
|
8
10
|
|
|
9
11
|
export * from './action';
|
|
10
12
|
export * from './appium-config';
|
|
@@ -82,11 +84,14 @@ export interface AppiumServerSocket extends Socket {
|
|
|
82
84
|
* The definition of an extension method, which will be provided via Appium's API.
|
|
83
85
|
*
|
|
84
86
|
*/
|
|
85
|
-
export interface MethodDef<Ext> {
|
|
87
|
+
export interface MethodDef<Ext extends Plugin | Driver> {
|
|
86
88
|
/**
|
|
87
89
|
* Name of the command.
|
|
88
90
|
*/
|
|
89
|
-
readonly command?: keyof ConditionalPick<
|
|
91
|
+
readonly command?: keyof ConditionalPick<
|
|
92
|
+
Required<Ext>,
|
|
93
|
+
Ext extends Plugin ? PluginCommand : Ext extends Driver ? DriverCommand : never
|
|
94
|
+
>;
|
|
90
95
|
/**
|
|
91
96
|
* If true, this `Method` will never proxy.
|
|
92
97
|
*/
|
|
@@ -97,6 +102,20 @@ export interface MethodDef<Ext> {
|
|
|
97
102
|
readonly payloadParams?: PayloadParams;
|
|
98
103
|
}
|
|
99
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
|
+
|
|
100
119
|
/**
|
|
101
120
|
* An instance method of a driver class, whose name may be referenced by {@linkcode MethodDef.command}, and serves as an Appium command.
|
|
102
121
|
*
|
|
@@ -118,7 +137,7 @@ export interface PayloadParams {
|
|
|
118
137
|
/**
|
|
119
138
|
* A mapping of URL paths to HTTP methods to {@linkcode MethodDef}s.
|
|
120
139
|
*/
|
|
121
|
-
export type MethodMap<Ext
|
|
140
|
+
export type MethodMap<Ext extends Plugin | Driver> = Readonly<
|
|
122
141
|
Record<
|
|
123
142
|
string,
|
|
124
143
|
{
|
package/lib/plugin.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {AppiumLogger, Class, ExecuteMethodMap, MethodMap, UpdateServerCallback} from '.';
|
|
2
|
+
import {ExternalDriver} from './driver';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The interface describing the constructor and static properties of a Plugin.
|
|
@@ -21,6 +21,7 @@ export interface PluginStatic<P extends Plugin> {
|
|
|
21
21
|
* }
|
|
22
22
|
*/
|
|
23
23
|
newMethodMap?: MethodMap<P>;
|
|
24
|
+
executeMethodMap?: ExecuteMethodMap<P>;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
/**
|
|
@@ -44,17 +45,12 @@ export interface Plugin {
|
|
|
44
45
|
/**
|
|
45
46
|
* Listener for unexpected server shutdown, which allows a plugin to do cleanup or take custom actions.
|
|
46
47
|
*/
|
|
47
|
-
onUnexpectedShutdown?: (driver:
|
|
48
|
+
onUnexpectedShutdown?: (driver: ExternalDriver, cause: Error | string) => Promise<void>;
|
|
48
49
|
/**
|
|
49
50
|
* Handle an Appium command, optionally running and using or throwing away the value of the
|
|
50
51
|
* original Appium behavior (or the behavior of the next plugin in a plugin chain).
|
|
51
52
|
*/
|
|
52
|
-
handle?:
|
|
53
|
-
next: NextPluginCallback,
|
|
54
|
-
driver: Driver,
|
|
55
|
-
cmdName: string,
|
|
56
|
-
...args: any[]
|
|
57
|
-
) => Promise<void>;
|
|
53
|
+
handle?: PluginCommand<ExternalDriver, [cmdName: string, ...args: any[]], void>;
|
|
58
54
|
}
|
|
59
55
|
|
|
60
56
|
/**
|
|
@@ -70,19 +66,21 @@ export interface Plugin {
|
|
|
70
66
|
* for managing new command timeouts and command logging, for example:
|
|
71
67
|
* `driver.stopNewCommandTimeout()` -- before running plugin logic
|
|
72
68
|
* `driver.startNewCommandTimeout()` -- after running plugin logic
|
|
73
|
-
* `driver._eventHistory.commands.push({cmd: cmdName, startTime, endTime}) --
|
|
69
|
+
* `driver._eventHistory.commands.push({cmd: cmdName, startTime, endTime})` --
|
|
74
70
|
* after running plugin logic
|
|
75
71
|
*/
|
|
76
72
|
export type NextPluginCallback = () => Promise<void>;
|
|
77
73
|
|
|
78
74
|
/**
|
|
79
75
|
* Implementation of a command within a plugin
|
|
76
|
+
*
|
|
77
|
+
* At minimum, `D` must be `ExternalDriver`, but a plugin can be more narrow about which drivers it supports.
|
|
80
78
|
*/
|
|
81
|
-
export type PluginCommand<
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
) => Promise<
|
|
79
|
+
export type PluginCommand<
|
|
80
|
+
D extends ExternalDriver = ExternalDriver,
|
|
81
|
+
TArgs extends readonly any[] = any[],
|
|
82
|
+
TReturn = any
|
|
83
|
+
> = (next: NextPluginCallback, driver: D, ...args: TArgs) => Promise<TReturn>;
|
|
86
84
|
|
|
87
85
|
/**
|
|
88
86
|
* Mainly for internal use.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export type PageLoadingStrategy = 'none' | 'eager' | 'normal';
|
|
2
|
+
export type ProxyTypes = 'pac' | 'noproxy' | 'autodetect' | 'system' | 'manual';
|
|
3
|
+
export interface ProxyObject {
|
|
4
|
+
proxyType?: ProxyTypes;
|
|
5
|
+
proxyAutoconfigUrl?: string;
|
|
6
|
+
ftpProxy?: string;
|
|
7
|
+
ftpProxyPort?: number;
|
|
8
|
+
httpProxy?: string;
|
|
9
|
+
httpProxyPort?: number;
|
|
10
|
+
sslProxy?: string;
|
|
11
|
+
sslProxyPort?: number;
|
|
12
|
+
socksProxy?: string;
|
|
13
|
+
socksProxyPort?: number;
|
|
14
|
+
socksVersion?: string;
|
|
15
|
+
socksUsername?: string;
|
|
16
|
+
socksPassword?: string;
|
|
17
|
+
}
|
|
18
|
+
export type Timeouts = Record<'script' | 'pageLoad' | 'implicit', number>;
|
|
19
|
+
|
|
20
|
+
export interface StandardCapabilities {
|
|
21
|
+
/**
|
|
22
|
+
* Identifies the user agent.
|
|
23
|
+
*/
|
|
24
|
+
browserName?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Identifies the version of the user agent.
|
|
27
|
+
*/
|
|
28
|
+
browserVersion?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Identifies the operating system of the endpoint node.
|
|
31
|
+
*/
|
|
32
|
+
platformName?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Indicates whether untrusted and self-signed TLS certificates are implicitly trusted on navigation for the duration of the session.
|
|
35
|
+
*/
|
|
36
|
+
acceptInsecureCerts?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Defines the current session’s page load strategy.
|
|
39
|
+
*/
|
|
40
|
+
pageLoadStrategy?: PageLoadingStrategy;
|
|
41
|
+
/**
|
|
42
|
+
* Defines the current session’s proxy configuration.
|
|
43
|
+
*/
|
|
44
|
+
proxy?: ProxyObject;
|
|
45
|
+
/**
|
|
46
|
+
* Indicates whether the remote end supports all of the resizing and repositioning commands.
|
|
47
|
+
*/
|
|
48
|
+
setWindowRect?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Describes the timeouts imposed on certain session operations.
|
|
51
|
+
*/
|
|
52
|
+
timeouts?: Timeouts;
|
|
53
|
+
/**
|
|
54
|
+
* Defines the current session’s strict file interactability.
|
|
55
|
+
*/
|
|
56
|
+
strictFileInteractability?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Describes the current session’s user prompt handler. Defaults to the dismiss and notify state.
|
|
59
|
+
*/
|
|
60
|
+
unhandledPromptBehavior?: string;
|
|
61
|
+
/**
|
|
62
|
+
* WebDriver clients opt in to a bidirectional connection by requesting a capability with the name "webSocketUrl" and value true.
|
|
63
|
+
*/
|
|
64
|
+
webSocketUrl?: boolean;
|
|
65
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appium/types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Various type declarations used across Appium",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"automation",
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
"files": [
|
|
28
28
|
"build",
|
|
29
29
|
"lib",
|
|
30
|
-
"index.js"
|
|
30
|
+
"index.js",
|
|
31
|
+
"tsconfig.json"
|
|
31
32
|
],
|
|
32
33
|
"scripts": {
|
|
33
34
|
"build": "node ./scripts/generate-schema-types.js",
|
|
@@ -35,12 +36,12 @@
|
|
|
35
36
|
"test:smoke": "node ./index.js"
|
|
36
37
|
},
|
|
37
38
|
"dependencies": {
|
|
38
|
-
"@appium/schema": "^0.
|
|
39
|
+
"@appium/schema": "^0.2.3",
|
|
40
|
+
"@appium/tsconfig": "^0.2.3",
|
|
39
41
|
"@types/express": "4.17.15",
|
|
40
42
|
"@types/npmlog": "4.1.4",
|
|
41
|
-
"@types/ws": "8.5.
|
|
42
|
-
"
|
|
43
|
-
"type-fest": "3.4.0"
|
|
43
|
+
"@types/ws": "8.5.4",
|
|
44
|
+
"type-fest": "3.5.3"
|
|
44
45
|
},
|
|
45
46
|
"engines": {
|
|
46
47
|
"node": "^14.17.0 || ^16.13.0 || >=18.0.0",
|
|
@@ -49,7 +50,7 @@
|
|
|
49
50
|
"publishConfig": {
|
|
50
51
|
"access": "public"
|
|
51
52
|
},
|
|
52
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "f1e0a46712b76564cd44c37657882308a7bac706",
|
|
53
54
|
"typedoc": {
|
|
54
55
|
"entryPoint": "./lib/index.ts"
|
|
55
56
|
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@appium/tsconfig/tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "build",
|
|
5
|
+
"checkJs": true,
|
|
6
|
+
"strict": true,
|
|
7
|
+
"paths": {
|
|
8
|
+
"@appium/schema": ["../schema"]
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"include": ["lib"],
|
|
12
|
+
"references": [{"path": "../schema"}]
|
|
13
|
+
}
|