@appium/types 0.4.0 → 0.5.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/action.d.ts +176 -0
- package/build/action.d.ts.map +1 -0
- package/build/action.js +84 -0
- package/build/appium-config.js +8 -0
- package/build/capabilities.d.ts +105 -26
- package/build/capabilities.d.ts.map +1 -1
- package/build/capabilities.js +2 -0
- package/build/config.js +3 -0
- package/build/constraints.d.ts +53 -0
- package/build/constraints.d.ts.map +1 -0
- package/build/constraints.js +54 -0
- package/build/driver.d.ts +46 -55
- package/build/driver.d.ts.map +1 -1
- package/build/driver.js +2 -0
- package/build/index.d.ts +5 -4
- package/build/index.d.ts.map +1 -1
- package/build/index.js +23 -0
- package/build/plugin.js +2 -0
- package/lib/action.ts +198 -0
- package/lib/capabilities.ts +164 -32
- package/lib/constraints.ts +53 -0
- package/lib/driver.ts +74 -66
- package/lib/index.ts +33 -24
- package/package.json +7 -5
package/lib/capabilities.ts
CHANGED
|
@@ -1,59 +1,191 @@
|
|
|
1
1
|
import type {Capabilities as WdioCaps} from '@wdio/types';
|
|
2
|
+
import {StringRecord, Constraint, Constraints} from '.';
|
|
3
|
+
import {BaseDriverCapConstraints} from './constraints';
|
|
4
|
+
|
|
5
|
+
export type StandardCapabilities = WdioCaps.Capabilities;
|
|
6
|
+
export type W3C_APPIUM_PREFIX = 'appium';
|
|
2
7
|
|
|
3
8
|
/**
|
|
4
|
-
*
|
|
9
|
+
* Base capabilities as derived from {@linkcode BaseDriverCapConstraints}.
|
|
5
10
|
*/
|
|
6
|
-
type
|
|
11
|
+
export type BaseCapabilities = ConstraintsToCaps<BaseDriverCapConstraints>;
|
|
7
12
|
|
|
8
13
|
/**
|
|
9
|
-
*
|
|
14
|
+
* Like {@linkcode BaseCapabilities}, except all Appium-specific keys are namespaced.
|
|
10
15
|
*/
|
|
11
|
-
type
|
|
16
|
+
export type BaseNSCapabilities = CapsToNSCaps<ConstraintsToCaps<BaseDriverCapConstraints>>;
|
|
12
17
|
|
|
13
18
|
/**
|
|
14
|
-
*
|
|
19
|
+
* These may (or should) be reused by drivers.
|
|
15
20
|
*/
|
|
16
|
-
type
|
|
21
|
+
export type AppiumAndroidCapabilities = WdioCaps.AppiumAndroidCapabilities;
|
|
22
|
+
export type AppiumIOSCapabilities = WdioCaps.AppiumIOSCapabilities;
|
|
23
|
+
export type AppiumXCUICommandTimeouts = WdioCaps.AppiumXCUICommandTimeouts;
|
|
24
|
+
export type AppiumXCUIProcessArguments = WdioCaps.AppiumXCUIProcessArguments;
|
|
25
|
+
export type AppiumXCUISafariGlobalPreferences = WdioCaps.AppiumXCUISafariGlobalPreferences;
|
|
26
|
+
export type AppiumXCUITestCapabilities = WdioCaps.AppiumXCUITestCapabilities;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Given a {@linkcode Constraint} `C` and a type `T`, see if `inclusion`/`inclusionCaseInsensitive` is present, and create a union of its allowed literals; otherwise just use `T`.
|
|
30
|
+
*/
|
|
31
|
+
type ConstraintChoice<
|
|
32
|
+
C extends Constraint,
|
|
33
|
+
T
|
|
34
|
+
> = C['inclusionCaseInsensitive'] extends ReadonlyArray<T>
|
|
35
|
+
? AnyCase<C['inclusionCaseInsensitive'][number]>
|
|
36
|
+
: C['inclusion'] extends ReadonlyArray<T>
|
|
37
|
+
? C['inclusion'][number]
|
|
38
|
+
: T;
|
|
17
39
|
|
|
18
40
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
41
|
+
* Given {@linkcode Constraint} `C`, determine the associated type of the capability.
|
|
42
|
+
*
|
|
43
|
+
* Notes:
|
|
44
|
+
*
|
|
45
|
+
* - Only `number` and `string` values can have "choices" (`inclusion`/`inclusionCaseInesnsitive`) associated with them.
|
|
46
|
+
* - If `isArray` is `true`, the type is always of type `string[]`. If this is incorrect, then it will be `any[]`.
|
|
47
|
+
* - There is no way to express the shape of an object if `ifObject` is `true`.
|
|
21
48
|
*/
|
|
22
|
-
type
|
|
23
|
-
|
|
24
|
-
|
|
49
|
+
type ConstraintToCapKind<C extends Constraint> = C['isString'] extends true
|
|
50
|
+
? ConstraintChoice<C, string>
|
|
51
|
+
: C['isNumber'] extends true
|
|
52
|
+
? ConstraintChoice<C, number>
|
|
53
|
+
: C['isBoolean'] extends true
|
|
54
|
+
? boolean
|
|
55
|
+
: C['isArray'] extends true
|
|
56
|
+
? string[]
|
|
57
|
+
: C['isObject'] extends true
|
|
58
|
+
? object
|
|
59
|
+
: any;
|
|
25
60
|
|
|
26
61
|
/**
|
|
27
|
-
*
|
|
62
|
+
* Given {@linkcode Constraint} `C`, determine if it is required or optional.
|
|
28
63
|
*
|
|
29
|
-
* In practice,
|
|
64
|
+
* In practice, _all_ capabilities are considered optional per types, but various errors might be thrown if some are not present.
|
|
30
65
|
*/
|
|
31
|
-
export type
|
|
32
|
-
|
|
33
|
-
|
|
66
|
+
export type ConstraintToCap<C extends Constraint> = C['presence'] extends
|
|
67
|
+
| true
|
|
68
|
+
| {allowEmpty: boolean}
|
|
69
|
+
? ConstraintToCapKind<C>
|
|
70
|
+
: ConstraintToCapKind<C> | undefined;
|
|
34
71
|
|
|
35
72
|
/**
|
|
36
|
-
*
|
|
73
|
+
* Given `string` `T`, this is a case-insensitive version of `T`.
|
|
37
74
|
*/
|
|
38
|
-
export type
|
|
39
|
-
|
|
40
|
-
|
|
75
|
+
export type AnyCase<T extends string> = string extends T
|
|
76
|
+
? string
|
|
77
|
+
: T extends `${infer F1}${infer F2}${infer R}`
|
|
78
|
+
? `${Uppercase<F1> | Lowercase<F1>}${Uppercase<F2> | Lowercase<F2>}${AnyCase<R>}`
|
|
79
|
+
: T extends `${infer F}${infer R}`
|
|
80
|
+
? `${Uppercase<F> | Lowercase<F>}${AnyCase<R>}`
|
|
81
|
+
: '';
|
|
41
82
|
|
|
42
83
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
84
|
+
* Given {@linkcode StringRecord} `T` and namespace string `NS`, a type with the key names prefixed by `${NS}:` _except_ for standard capabilities. `NS` defaults to `appium`.
|
|
85
|
+
*
|
|
86
|
+
* If `T` is already namespaced, well, it'll get _double_-namespaced.
|
|
45
87
|
*/
|
|
46
|
-
export type
|
|
47
|
-
|
|
48
|
-
|
|
88
|
+
export type CapsToNSCaps<T extends StringRecord, NS extends string = W3C_APPIUM_PREFIX> = {
|
|
89
|
+
[K in keyof T as K extends keyof StandardCapabilities
|
|
90
|
+
? K
|
|
91
|
+
: NamespacedString<K & string, NS>]: T[K];
|
|
49
92
|
};
|
|
50
93
|
|
|
94
|
+
export type NamespacedString<
|
|
95
|
+
S extends string,
|
|
96
|
+
NS extends string = W3C_APPIUM_PREFIX
|
|
97
|
+
> = `${NS}:${S}`;
|
|
98
|
+
|
|
51
99
|
/**
|
|
52
|
-
*
|
|
100
|
+
* Converts {@linkcode Constraint} `C` to a {@linkcode Capabilities} object.
|
|
53
101
|
*/
|
|
54
|
-
export type
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
102
|
+
export type ConstraintsToCaps<C extends Constraints> = {
|
|
103
|
+
-readonly [K in keyof C]: ConstraintToCap<C[K]>;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Given some constraints, return the entire set of supported capabilities it supports (including whatever is in its desired caps).
|
|
108
|
+
*
|
|
109
|
+
* Does not contain {@linkcode BaseCapabilities}; see {@linkcode DriverCaps}.
|
|
110
|
+
*/
|
|
111
|
+
export type Capabilities<
|
|
112
|
+
C extends Constraints = BaseDriverCapConstraints,
|
|
113
|
+
Extra extends StringRecord | void = void
|
|
114
|
+
> = Partial<ConstraintsToCaps<C> & Extra>;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Like {@linkcode Capabilities}, except W3C-style.
|
|
118
|
+
*
|
|
119
|
+
* Does not contain {@linkcode BaseCapabilities}; see {@linkcode W3CDriverCaps}.
|
|
120
|
+
*/
|
|
121
|
+
export type W3CCapabilities<
|
|
122
|
+
C extends Constraints = BaseDriverCapConstraints,
|
|
123
|
+
Extra extends StringRecord | void = void
|
|
124
|
+
> = {
|
|
125
|
+
alwaysMatch: NSCapabilities<C, Extra>;
|
|
126
|
+
firstMatch: NSCapabilities<C, Extra>[];
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Namespaced caps (where appropriate).
|
|
131
|
+
*
|
|
132
|
+
* Does not contain {@linkcode BaseCapabilities}; see {@linkcode NSDriverCaps}.
|
|
133
|
+
*/
|
|
134
|
+
export type NSCapabilities<
|
|
135
|
+
C extends Constraints = BaseDriverCapConstraints,
|
|
136
|
+
Extra extends StringRecord | void = void,
|
|
137
|
+
NS extends string = W3C_APPIUM_PREFIX
|
|
138
|
+
> = Partial<CapsToNSCaps<ConstraintsToCaps<C> & Extra, NS>>;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Capabilities for drivers extending `BaseDriver`.
|
|
142
|
+
*
|
|
143
|
+
* Includes {@linkcode BaseCapabilities}.
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```ts
|
|
147
|
+
* class MyDriver extends BaseDriver {
|
|
148
|
+
* async createSession (w3ccaps: W3CDriverCaps<MyDriverConstraints>, ...args: any[]) {
|
|
149
|
+
* const [
|
|
150
|
+
* sessionId: string,
|
|
151
|
+
* caps: DriverCaps<MyDriverConstraints>
|
|
152
|
+
* ] = await super.createSession(w3ccaps, ...args);
|
|
153
|
+
* // ...
|
|
154
|
+
* }
|
|
155
|
+
* }
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
|
|
159
|
+
export type DriverCaps<
|
|
160
|
+
C extends Constraints,
|
|
161
|
+
Extra extends StringRecord | void = void
|
|
162
|
+
> = Capabilities<BaseDriverCapConstraints & C, Extra>;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* W3C-style capabilities for drivers extending `BaseDriver`.
|
|
166
|
+
*
|
|
167
|
+
* Includes {@linkcode BaseCapabilities}.
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```ts
|
|
171
|
+
* class MyDriver extends BaseDriver {
|
|
172
|
+
* async createSession (w3ccaps: W3CDriverCaps<MyDriverConstraints>, ...args: any[]) {
|
|
173
|
+
* // ...
|
|
174
|
+
* }
|
|
175
|
+
* }
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
export type W3CDriverCaps<
|
|
179
|
+
C extends Constraints,
|
|
180
|
+
Extra extends StringRecord | void = void
|
|
181
|
+
> = W3CCapabilities<BaseDriverCapConstraints & C, Extra>;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Namespaced capabilities for drivers extending `BaseDriver`.
|
|
185
|
+
*
|
|
186
|
+
* Includes {@linkcode BaseCapabilities}.
|
|
187
|
+
*/
|
|
188
|
+
export type NSDriverCaps<
|
|
189
|
+
C extends Constraints,
|
|
190
|
+
Extra extends StringRecord | void = void
|
|
191
|
+
> = NSCapabilities<BaseDriverCapConstraints & C, Extra>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export const BASE_DESIRED_CAP_CONSTRAINTS = {
|
|
2
|
+
platformName: {
|
|
3
|
+
presence: true,
|
|
4
|
+
isString: true,
|
|
5
|
+
},
|
|
6
|
+
app: {
|
|
7
|
+
isString: true,
|
|
8
|
+
},
|
|
9
|
+
deviceName: {
|
|
10
|
+
isString: true,
|
|
11
|
+
},
|
|
12
|
+
platformVersion: {
|
|
13
|
+
isString: true,
|
|
14
|
+
},
|
|
15
|
+
newCommandTimeout: {
|
|
16
|
+
isNumber: true,
|
|
17
|
+
},
|
|
18
|
+
automationName: {
|
|
19
|
+
isString: true,
|
|
20
|
+
},
|
|
21
|
+
autoLaunch: {
|
|
22
|
+
isBoolean: true,
|
|
23
|
+
},
|
|
24
|
+
udid: {
|
|
25
|
+
isString: true,
|
|
26
|
+
},
|
|
27
|
+
orientation: {
|
|
28
|
+
inclusion: ['LANDSCAPE', 'PORTRAIT'],
|
|
29
|
+
},
|
|
30
|
+
autoWebview: {
|
|
31
|
+
isBoolean: true,
|
|
32
|
+
},
|
|
33
|
+
noReset: {
|
|
34
|
+
isBoolean: true,
|
|
35
|
+
},
|
|
36
|
+
fullReset: {
|
|
37
|
+
isBoolean: true,
|
|
38
|
+
},
|
|
39
|
+
language: {
|
|
40
|
+
isString: true,
|
|
41
|
+
},
|
|
42
|
+
locale: {
|
|
43
|
+
isString: true,
|
|
44
|
+
},
|
|
45
|
+
eventTimings: {
|
|
46
|
+
isBoolean: true,
|
|
47
|
+
},
|
|
48
|
+
printPageSourceOnFindFailure: {
|
|
49
|
+
isBoolean: true,
|
|
50
|
+
},
|
|
51
|
+
} as const;
|
|
52
|
+
|
|
53
|
+
export type BaseDriverCapConstraints = typeof BASE_DESIRED_CAP_CONSTRAINTS;
|
package/lib/driver.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import type {EventEmitter} from 'events';
|
|
2
|
+
import {Element, ActionSequence} from './action';
|
|
2
3
|
import {
|
|
3
4
|
HTTPMethod,
|
|
4
|
-
Capabilities,
|
|
5
5
|
AppiumServer,
|
|
6
6
|
UpdateServerCallback,
|
|
7
7
|
Class,
|
|
8
8
|
MethodMap,
|
|
9
9
|
AppiumLogger,
|
|
10
|
+
StringRecord,
|
|
11
|
+
ConstraintsToCaps,
|
|
12
|
+
BaseDriverCapConstraints,
|
|
13
|
+
W3CCapabilities,
|
|
14
|
+
Capabilities,
|
|
10
15
|
} from '.';
|
|
11
|
-
import {W3CCapabilities} from './capabilities';
|
|
12
16
|
import {ServerArgs} from './config';
|
|
13
17
|
|
|
14
18
|
export interface TimeoutCommands {
|
|
@@ -45,24 +49,30 @@ export interface SessionCommands {
|
|
|
45
49
|
}
|
|
46
50
|
|
|
47
51
|
export interface ExecuteCommands {
|
|
48
|
-
executeMethod(script: string, args: [
|
|
52
|
+
executeMethod(script: string, args: [StringRecord] | []): Promise<any>;
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
export interface ExecuteMethodDef {
|
|
52
|
-
command: string
|
|
56
|
+
command: string;
|
|
53
57
|
params?: {
|
|
54
|
-
required?: string[]
|
|
55
|
-
optional?: string[]
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
+
required?: string[];
|
|
59
|
+
optional?: string[];
|
|
60
|
+
};
|
|
61
|
+
}
|
|
58
62
|
export type ExecuteMethodMap = Record<string, ExecuteMethodDef>;
|
|
59
63
|
|
|
60
|
-
export interface MultiSessionData
|
|
64
|
+
export interface MultiSessionData<
|
|
65
|
+
C extends Constraints = BaseDriverCapConstraints,
|
|
66
|
+
Extra extends StringRecord | void = void
|
|
67
|
+
> {
|
|
61
68
|
id: string;
|
|
62
|
-
capabilities: Capabilities
|
|
69
|
+
capabilities: Capabilities<C, Extra>;
|
|
63
70
|
}
|
|
64
71
|
|
|
65
|
-
export type SingularSessionData
|
|
72
|
+
export type SingularSessionData<
|
|
73
|
+
C extends Constraints = BaseDriverCapConstraints,
|
|
74
|
+
Extra extends StringRecord | void = void
|
|
75
|
+
> = Capabilities<C, Extra> & {events?: EventHistory; error?: string};
|
|
66
76
|
|
|
67
77
|
export interface FindCommands {
|
|
68
78
|
findElement(strategy: string, selector: string): Promise<Element>;
|
|
@@ -105,15 +115,20 @@ export interface LogCommands {
|
|
|
105
115
|
}
|
|
106
116
|
|
|
107
117
|
export interface SettingsCommands {
|
|
108
|
-
updateSettings: (settings:
|
|
109
|
-
getSettings(): Promise<
|
|
118
|
+
updateSettings: (settings: StringRecord) => Promise<void>;
|
|
119
|
+
getSettings(): Promise<StringRecord>;
|
|
110
120
|
}
|
|
111
121
|
|
|
112
|
-
export interface SessionHandler<
|
|
122
|
+
export interface SessionHandler<
|
|
123
|
+
CreateResult,
|
|
124
|
+
DeleteResult,
|
|
125
|
+
C extends Constraints = BaseDriverCapConstraints,
|
|
126
|
+
Extra extends StringRecord | void = void
|
|
127
|
+
> {
|
|
113
128
|
createSession(
|
|
114
|
-
w3cCaps1: W3CCapabilities,
|
|
115
|
-
w3cCaps2?: W3CCapabilities,
|
|
116
|
-
w3cCaps?: W3CCapabilities,
|
|
129
|
+
w3cCaps1: W3CCapabilities<C, Extra>,
|
|
130
|
+
w3cCaps2?: W3CCapabilities<C, Extra>,
|
|
131
|
+
w3cCaps?: W3CCapabilities<C, Extra>,
|
|
117
132
|
driverData?: DriverData[]
|
|
118
133
|
): Promise<CreateResult>;
|
|
119
134
|
|
|
@@ -139,27 +154,24 @@ export type DriverData = Record<string, unknown>;
|
|
|
139
154
|
* }
|
|
140
155
|
*/
|
|
141
156
|
export interface Constraint {
|
|
142
|
-
presence?: boolean | {allowEmpty: boolean}
|
|
143
|
-
isString?: boolean;
|
|
144
|
-
isNumber?: boolean;
|
|
145
|
-
isBoolean?: boolean;
|
|
146
|
-
isObject?: boolean;
|
|
147
|
-
isArray?: boolean;
|
|
148
|
-
deprecated?: boolean;
|
|
149
|
-
inclusion?: any[]
|
|
157
|
+
readonly presence?: boolean | Readonly<{allowEmpty: boolean}>;
|
|
158
|
+
readonly isString?: boolean;
|
|
159
|
+
readonly isNumber?: boolean;
|
|
160
|
+
readonly isBoolean?: boolean;
|
|
161
|
+
readonly isObject?: boolean;
|
|
162
|
+
readonly isArray?: boolean;
|
|
163
|
+
readonly deprecated?: boolean;
|
|
164
|
+
readonly inclusion?: Readonly<[any, ...any[]]>;
|
|
165
|
+
readonly inclusionCaseInsensitive?: Readonly<[any, ...any[]]>;
|
|
150
166
|
}
|
|
151
|
-
export type Constraints = Record<string, Constraint
|
|
167
|
+
export type Constraints = Readonly<Record<string, Constraint>>;
|
|
152
168
|
|
|
153
|
-
export interface
|
|
154
|
-
'element-6066-11e4-a52e-4f735466cecf': string;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export interface DriverHelpers {
|
|
169
|
+
export interface DriverHelpers<C extends Constraints> {
|
|
158
170
|
configureApp: (app: string, supportedAppExtensions: string[]) => Promise<string>;
|
|
159
171
|
isPackageOrBundle: (app: string) => boolean;
|
|
160
172
|
duplicateKeys: <T>(input: T, firstKey: string, secondKey: string) => T;
|
|
161
173
|
parseCapsArray: (cap: string | string[]) => string[];
|
|
162
|
-
generateDriverLogPrefix: (obj: Core
|
|
174
|
+
generateDriverLogPrefix: (obj: Core<C>, sessionId?: string) => string;
|
|
163
175
|
}
|
|
164
176
|
|
|
165
177
|
export type SettingsUpdateListener<T extends Record<string, unknown> = Record<string, unknown>> = (
|
|
@@ -205,24 +217,6 @@ export interface Cookie {
|
|
|
205
217
|
sameSite?: 'Lax' | 'Strict';
|
|
206
218
|
}
|
|
207
219
|
|
|
208
|
-
export interface Actions {
|
|
209
|
-
type?: string;
|
|
210
|
-
actions: Action[];
|
|
211
|
-
parameters?: {
|
|
212
|
-
pointerType?: string;
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
export interface Action {
|
|
217
|
-
duration?: number;
|
|
218
|
-
type: string;
|
|
219
|
-
value?: string;
|
|
220
|
-
x?: number;
|
|
221
|
-
y?: number;
|
|
222
|
-
button?: number;
|
|
223
|
-
origin?: string;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
220
|
// Appium W3C WebDriver Extension
|
|
227
221
|
|
|
228
222
|
export interface ScreenRecordOptions {
|
|
@@ -287,15 +281,13 @@ export interface EventHistoryCommand {
|
|
|
287
281
|
*
|
|
288
282
|
* This should not be used directly by external code.
|
|
289
283
|
*/
|
|
290
|
-
export interface Core {
|
|
284
|
+
export interface Core<C extends Constraints = BaseDriverCapConstraints> {
|
|
291
285
|
shouldValidateCaps: boolean;
|
|
292
286
|
sessionId: string | null;
|
|
293
|
-
opts: DriverOpts
|
|
287
|
+
opts: DriverOpts<C>;
|
|
294
288
|
initialOpts: ServerArgs;
|
|
295
|
-
caps?: Capabilities;
|
|
296
|
-
originalCaps?: W3CCapabilities;
|
|
297
289
|
protocol?: string;
|
|
298
|
-
helpers: DriverHelpers
|
|
290
|
+
helpers: DriverHelpers<C>;
|
|
299
291
|
basePath: string;
|
|
300
292
|
relaxedSecurityEnabled: boolean;
|
|
301
293
|
allowInsecure: string[];
|
|
@@ -319,38 +311,43 @@ export interface Core {
|
|
|
319
311
|
assertFeatureEnabled(name: string): void;
|
|
320
312
|
validateLocatorStrategy(strategy: string, webContext?: boolean): void;
|
|
321
313
|
proxyActive(sessionId?: string): boolean;
|
|
322
|
-
getProxyAvoidList(sessionId?: string): [
|
|
314
|
+
getProxyAvoidList(sessionId?: string): RouteMatcher[];
|
|
323
315
|
canProxy(sessionId?: string): boolean;
|
|
324
316
|
proxyRouteIsAvoided(sessionId: string, method: string, url: string): boolean;
|
|
325
317
|
addManagedDriver(driver: Driver): void;
|
|
326
318
|
getManagedDrivers(): Driver[];
|
|
327
319
|
clearNewCommandTimeout(): Promise<void>;
|
|
328
320
|
logEvent(eventName: string): void;
|
|
329
|
-
driverForSession(sessionId: string): Core | null;
|
|
321
|
+
driverForSession(sessionId: string): Core<C> | null;
|
|
330
322
|
}
|
|
331
323
|
|
|
332
324
|
/**
|
|
333
325
|
* `BaseDriver` implements this. It contains default behavior;
|
|
334
326
|
* external drivers are expected to implement {@linkcode ExternalDriver} instead.
|
|
335
327
|
*/
|
|
336
|
-
export interface Driver
|
|
337
|
-
extends
|
|
328
|
+
export interface Driver<
|
|
329
|
+
C extends Constraints = BaseDriverCapConstraints,
|
|
330
|
+
A extends StringRecord = StringRecord
|
|
331
|
+
> extends SessionCommands,
|
|
338
332
|
LogCommands,
|
|
339
333
|
FindCommands,
|
|
340
334
|
SettingsCommands,
|
|
341
335
|
TimeoutCommands,
|
|
342
336
|
EventCommands,
|
|
343
|
-
SessionHandler<[string, any], void>,
|
|
337
|
+
SessionHandler<[string, any], void, C>,
|
|
338
|
+
ExecuteCommands,
|
|
344
339
|
Core {
|
|
345
|
-
cliArgs?:
|
|
340
|
+
cliArgs?: A;
|
|
346
341
|
// The following methods are implemented by `BaseDriver`.
|
|
347
342
|
executeCommand(cmd: string, ...args: any[]): Promise<any>;
|
|
348
343
|
startUnexpectedShutdown(err?: Error): Promise<void>;
|
|
349
344
|
startNewCommandTimeout(): Promise<void>;
|
|
350
345
|
reset(): Promise<void>;
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
346
|
+
caps?: Capabilities<C>;
|
|
347
|
+
originalCaps?: W3CCapabilities<C>;
|
|
348
|
+
desiredCapConstraints: C;
|
|
349
|
+
validateDesiredCaps(caps: Capabilities<C>): boolean;
|
|
350
|
+
logExtraCaps(caps: Capabilities<C>): void;
|
|
354
351
|
assignServer?(server: AppiumServer, host: string, port: number, path: string): void;
|
|
355
352
|
}
|
|
356
353
|
|
|
@@ -403,7 +400,7 @@ export interface ExternalDriver extends Driver {
|
|
|
403
400
|
setCookie?(cookie: Cookie): Promise<void>;
|
|
404
401
|
deleteCookie?(name: string): Promise<void>;
|
|
405
402
|
deleteCookies?(): Promise<void>;
|
|
406
|
-
performActions?(actions:
|
|
403
|
+
performActions?(actions: ActionSequence[]): Promise<void>;
|
|
407
404
|
releaseActions?(): Promise<void>;
|
|
408
405
|
postDismissAlert?(): Promise<void>;
|
|
409
406
|
postAcceptAlert?(): Promise<void>;
|
|
@@ -600,12 +597,18 @@ export type DriverClass<
|
|
|
600
597
|
S extends DriverStatic = DriverStatic
|
|
601
598
|
> = Class<D, S, [] | [Partial<ServerArgs>] | [Partial<ServerArgs>, boolean]>;
|
|
602
599
|
|
|
600
|
+
export interface ExtraDriverOpts {
|
|
601
|
+
fastReset?: boolean;
|
|
602
|
+
skipUninstall?: boolean;
|
|
603
|
+
}
|
|
603
604
|
/**
|
|
604
605
|
* Options as passed into a driver constructor, which is just a union of {@linkcode ServerArgs} and {@linkcode Capabilities}.
|
|
605
606
|
*
|
|
606
607
|
* The combination happens within Appium prior to calling the constructor.
|
|
607
608
|
*/
|
|
608
|
-
export type DriverOpts = ServerArgs &
|
|
609
|
+
export type DriverOpts<C extends Constraints = BaseDriverCapConstraints> = ServerArgs &
|
|
610
|
+
ExtraDriverOpts &
|
|
611
|
+
Partial<ConstraintsToCaps<C>>;
|
|
609
612
|
|
|
610
613
|
export type DriverCommand<TArgs = any, TReturn = unknown> = (...args: TArgs[]) => Promise<TReturn>;
|
|
611
614
|
|
|
@@ -613,3 +616,8 @@ export type DriverCommands<TArgs = any, TReturn = unknown> = Record<
|
|
|
613
616
|
string,
|
|
614
617
|
DriverCommand<TArgs, TReturn>
|
|
615
618
|
>;
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* Tuple of an HTTP method with a regex matching a request path
|
|
622
|
+
*/
|
|
623
|
+
export type RouteMatcher = [HTTPMethod, RegExp];
|
package/lib/index.ts
CHANGED
|
@@ -3,17 +3,19 @@ import type {Socket} from 'net';
|
|
|
3
3
|
import type {Server} from 'http';
|
|
4
4
|
import type {Class as _Class, ConditionalPick, MultidimensionalReadonlyArray} from 'type-fest';
|
|
5
5
|
import {ServerArgs} from './config';
|
|
6
|
-
import {Capabilities, W3CCapabilities} from './capabilities';
|
|
7
6
|
import type {Express} from 'express';
|
|
8
7
|
import {ExternalDriver} from './driver';
|
|
9
8
|
import type {Logger} from 'npmlog';
|
|
10
9
|
|
|
11
10
|
export * from './driver';
|
|
11
|
+
export * from './action';
|
|
12
12
|
export * from './plugin';
|
|
13
|
-
export
|
|
14
|
-
export
|
|
13
|
+
export * from './capabilities';
|
|
14
|
+
export * from './constraints';
|
|
15
|
+
export * from './config';
|
|
15
16
|
export * from './appium-config';
|
|
16
|
-
|
|
17
|
+
|
|
18
|
+
export type StringRecord = Record<string, any>;
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
21
|
* A log prefix for {@linkcode AppiumLogger}
|
|
@@ -62,15 +64,10 @@ export type AppiumServer = Omit<Server, 'close'> & AppiumServerExtension;
|
|
|
62
64
|
|
|
63
65
|
export interface AppiumServerExtension {
|
|
64
66
|
close(): Promise<void>;
|
|
65
|
-
addWebSocketHandler(
|
|
66
|
-
handlerPathname: string,
|
|
67
|
-
handlerServer: WSServer
|
|
68
|
-
): Promise<void>;
|
|
67
|
+
addWebSocketHandler(handlerPathname: string, handlerServer: WSServer): Promise<void>;
|
|
69
68
|
removeWebSocketHandler(handlerPathname: string): Promise<boolean>;
|
|
70
69
|
removeAllWebSocketHandlers(): Promise<boolean>;
|
|
71
|
-
getWebSocketHandlers(
|
|
72
|
-
keysFilter: string | null | undefined
|
|
73
|
-
): Promise<Record<string, WSServer>>;
|
|
70
|
+
getWebSocketHandlers(keysFilter: string | null | undefined): Promise<Record<string, WSServer>>;
|
|
74
71
|
webSocketsMapping: Record<string, WSServer>;
|
|
75
72
|
}
|
|
76
73
|
|
|
@@ -163,8 +160,11 @@ export type ExtensionType = DriverType | PluginType;
|
|
|
163
160
|
* @param httpServer - the node HTTP server that hosts the app
|
|
164
161
|
* @param cliArgs - Arguments from config files, CLI, etc.
|
|
165
162
|
*/
|
|
166
|
-
export type UpdateServerCallback = (
|
|
167
|
-
|
|
163
|
+
export type UpdateServerCallback = (
|
|
164
|
+
expressApp: Express,
|
|
165
|
+
httpServer: AppiumServer,
|
|
166
|
+
cliArgs: ServerArgs
|
|
167
|
+
) => Promise<void>;
|
|
168
168
|
|
|
169
169
|
/**
|
|
170
170
|
* Possible HTTP methods, as stolen from `axios`.
|
|
@@ -172,14 +172,23 @@ export type UpdateServerCallback = (expressApp: Express, httpServer: AppiumServe
|
|
|
172
172
|
* @see https://npm.im/axios
|
|
173
173
|
*/
|
|
174
174
|
export type HTTPMethod =
|
|
175
|
-
| 'get'
|
|
176
|
-
| '
|
|
177
|
-
| '
|
|
178
|
-
| '
|
|
179
|
-
| '
|
|
180
|
-
| '
|
|
181
|
-
| '
|
|
182
|
-
| '
|
|
183
|
-
| '
|
|
184
|
-
| '
|
|
185
|
-
|
|
175
|
+
| 'get'
|
|
176
|
+
| 'GET'
|
|
177
|
+
| 'delete'
|
|
178
|
+
| 'DELETE'
|
|
179
|
+
| 'head'
|
|
180
|
+
| 'HEAD'
|
|
181
|
+
| 'options'
|
|
182
|
+
| 'OPTIONS'
|
|
183
|
+
| 'post'
|
|
184
|
+
| 'POST'
|
|
185
|
+
| 'put'
|
|
186
|
+
| 'PUT'
|
|
187
|
+
| 'patch'
|
|
188
|
+
| 'PATCH'
|
|
189
|
+
| 'purge'
|
|
190
|
+
| 'PURGE'
|
|
191
|
+
| 'link'
|
|
192
|
+
| 'LINK'
|
|
193
|
+
| 'unlink'
|
|
194
|
+
| 'UNLINK';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appium/types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Various type declarations used across Appium",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"appium",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"build",
|
|
24
24
|
"lib"
|
|
25
25
|
],
|
|
26
|
+
"main": "./build/index.js",
|
|
26
27
|
"scripts": {
|
|
27
28
|
"build": "node ./scripts/generate-schema-types.js",
|
|
28
29
|
"dev": "npm run build -- --watch",
|
|
@@ -33,10 +34,11 @@
|
|
|
33
34
|
},
|
|
34
35
|
"dependencies": {
|
|
35
36
|
"@appium/schema": "^0.0.9",
|
|
36
|
-
"@types/express": "4.17.
|
|
37
|
+
"@types/express": "4.17.14",
|
|
37
38
|
"@types/npmlog": "4.1.4",
|
|
38
|
-
"@
|
|
39
|
-
"
|
|
39
|
+
"@types/ws": "8.5.3",
|
|
40
|
+
"@wdio/types": "7.25.1",
|
|
41
|
+
"type-fest": "3.1.0"
|
|
40
42
|
},
|
|
41
43
|
"engines": {
|
|
42
44
|
"node": ">=14",
|
|
@@ -45,5 +47,5 @@
|
|
|
45
47
|
"publishConfig": {
|
|
46
48
|
"access": "public"
|
|
47
49
|
},
|
|
48
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "f545a6cde58d83f3289072f8957468793947ba66"
|
|
49
51
|
}
|