@appium/types 0.4.1 → 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.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 +39 -35
- package/build/driver.d.ts.map +1 -1
- package/build/driver.js +2 -0
- package/build/index.d.ts +4 -4
- package/build/index.d.ts.map +1 -1
- package/build/index.js +23 -0
- package/build/plugin.js +2 -0
- package/lib/capabilities.ts +164 -32
- package/lib/constraints.ts +53 -0
- package/lib/driver.ts +65 -43
- package/lib/index.ts +32 -24
- package/package.json +6 -5
package/lib/driver.ts
CHANGED
|
@@ -2,14 +2,17 @@ import type {EventEmitter} from 'events';
|
|
|
2
2
|
import {Element, ActionSequence} from './action';
|
|
3
3
|
import {
|
|
4
4
|
HTTPMethod,
|
|
5
|
-
Capabilities,
|
|
6
5
|
AppiumServer,
|
|
7
6
|
UpdateServerCallback,
|
|
8
7
|
Class,
|
|
9
8
|
MethodMap,
|
|
10
9
|
AppiumLogger,
|
|
10
|
+
StringRecord,
|
|
11
|
+
ConstraintsToCaps,
|
|
12
|
+
BaseDriverCapConstraints,
|
|
13
|
+
W3CCapabilities,
|
|
14
|
+
Capabilities,
|
|
11
15
|
} from '.';
|
|
12
|
-
import {W3CCapabilities} from './capabilities';
|
|
13
16
|
import {ServerArgs} from './config';
|
|
14
17
|
|
|
15
18
|
export interface TimeoutCommands {
|
|
@@ -46,24 +49,30 @@ export interface SessionCommands {
|
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
export interface ExecuteCommands {
|
|
49
|
-
executeMethod(script: string, args: [
|
|
52
|
+
executeMethod(script: string, args: [StringRecord] | []): Promise<any>;
|
|
50
53
|
}
|
|
51
54
|
|
|
52
55
|
export interface ExecuteMethodDef {
|
|
53
|
-
command: string
|
|
56
|
+
command: string;
|
|
54
57
|
params?: {
|
|
55
|
-
required?: string[]
|
|
56
|
-
optional?: string[]
|
|
57
|
-
}
|
|
58
|
-
}
|
|
58
|
+
required?: string[];
|
|
59
|
+
optional?: string[];
|
|
60
|
+
};
|
|
61
|
+
}
|
|
59
62
|
export type ExecuteMethodMap = Record<string, ExecuteMethodDef>;
|
|
60
63
|
|
|
61
|
-
export interface MultiSessionData
|
|
64
|
+
export interface MultiSessionData<
|
|
65
|
+
C extends Constraints = BaseDriverCapConstraints,
|
|
66
|
+
Extra extends StringRecord | void = void
|
|
67
|
+
> {
|
|
62
68
|
id: string;
|
|
63
|
-
capabilities: Capabilities
|
|
69
|
+
capabilities: Capabilities<C, Extra>;
|
|
64
70
|
}
|
|
65
71
|
|
|
66
|
-
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};
|
|
67
76
|
|
|
68
77
|
export interface FindCommands {
|
|
69
78
|
findElement(strategy: string, selector: string): Promise<Element>;
|
|
@@ -106,15 +115,20 @@ export interface LogCommands {
|
|
|
106
115
|
}
|
|
107
116
|
|
|
108
117
|
export interface SettingsCommands {
|
|
109
|
-
updateSettings: (settings:
|
|
110
|
-
getSettings(): Promise<
|
|
118
|
+
updateSettings: (settings: StringRecord) => Promise<void>;
|
|
119
|
+
getSettings(): Promise<StringRecord>;
|
|
111
120
|
}
|
|
112
121
|
|
|
113
|
-
export interface SessionHandler<
|
|
122
|
+
export interface SessionHandler<
|
|
123
|
+
CreateResult,
|
|
124
|
+
DeleteResult,
|
|
125
|
+
C extends Constraints = BaseDriverCapConstraints,
|
|
126
|
+
Extra extends StringRecord | void = void
|
|
127
|
+
> {
|
|
114
128
|
createSession(
|
|
115
|
-
w3cCaps1: W3CCapabilities,
|
|
116
|
-
w3cCaps2?: W3CCapabilities,
|
|
117
|
-
w3cCaps?: W3CCapabilities,
|
|
129
|
+
w3cCaps1: W3CCapabilities<C, Extra>,
|
|
130
|
+
w3cCaps2?: W3CCapabilities<C, Extra>,
|
|
131
|
+
w3cCaps?: W3CCapabilities<C, Extra>,
|
|
118
132
|
driverData?: DriverData[]
|
|
119
133
|
): Promise<CreateResult>;
|
|
120
134
|
|
|
@@ -140,24 +154,24 @@ export type DriverData = Record<string, unknown>;
|
|
|
140
154
|
* }
|
|
141
155
|
*/
|
|
142
156
|
export interface Constraint {
|
|
143
|
-
presence?: boolean | {allowEmpty: boolean}
|
|
144
|
-
isString?: boolean;
|
|
145
|
-
isNumber?: boolean;
|
|
146
|
-
isBoolean?: boolean;
|
|
147
|
-
isObject?: boolean;
|
|
148
|
-
isArray?: boolean;
|
|
149
|
-
deprecated?: boolean;
|
|
150
|
-
inclusion?: any[]
|
|
151
|
-
inclusionCaseInsensitive?: 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[]]>;
|
|
152
166
|
}
|
|
153
|
-
export type Constraints = Record<string, Constraint
|
|
167
|
+
export type Constraints = Readonly<Record<string, Constraint>>;
|
|
154
168
|
|
|
155
|
-
export interface DriverHelpers {
|
|
169
|
+
export interface DriverHelpers<C extends Constraints> {
|
|
156
170
|
configureApp: (app: string, supportedAppExtensions: string[]) => Promise<string>;
|
|
157
171
|
isPackageOrBundle: (app: string) => boolean;
|
|
158
172
|
duplicateKeys: <T>(input: T, firstKey: string, secondKey: string) => T;
|
|
159
173
|
parseCapsArray: (cap: string | string[]) => string[];
|
|
160
|
-
generateDriverLogPrefix: (obj: Core
|
|
174
|
+
generateDriverLogPrefix: (obj: Core<C>, sessionId?: string) => string;
|
|
161
175
|
}
|
|
162
176
|
|
|
163
177
|
export type SettingsUpdateListener<T extends Record<string, unknown> = Record<string, unknown>> = (
|
|
@@ -267,15 +281,13 @@ export interface EventHistoryCommand {
|
|
|
267
281
|
*
|
|
268
282
|
* This should not be used directly by external code.
|
|
269
283
|
*/
|
|
270
|
-
export interface Core {
|
|
284
|
+
export interface Core<C extends Constraints = BaseDriverCapConstraints> {
|
|
271
285
|
shouldValidateCaps: boolean;
|
|
272
286
|
sessionId: string | null;
|
|
273
|
-
opts: DriverOpts
|
|
287
|
+
opts: DriverOpts<C>;
|
|
274
288
|
initialOpts: ServerArgs;
|
|
275
|
-
caps?: Capabilities;
|
|
276
|
-
originalCaps?: W3CCapabilities;
|
|
277
289
|
protocol?: string;
|
|
278
|
-
helpers: DriverHelpers
|
|
290
|
+
helpers: DriverHelpers<C>;
|
|
279
291
|
basePath: string;
|
|
280
292
|
relaxedSecurityEnabled: boolean;
|
|
281
293
|
allowInsecure: string[];
|
|
@@ -306,32 +318,36 @@ export interface Core {
|
|
|
306
318
|
getManagedDrivers(): Driver[];
|
|
307
319
|
clearNewCommandTimeout(): Promise<void>;
|
|
308
320
|
logEvent(eventName: string): void;
|
|
309
|
-
driverForSession(sessionId: string): Core | null;
|
|
321
|
+
driverForSession(sessionId: string): Core<C> | null;
|
|
310
322
|
}
|
|
311
323
|
|
|
312
324
|
/**
|
|
313
325
|
* `BaseDriver` implements this. It contains default behavior;
|
|
314
326
|
* external drivers are expected to implement {@linkcode ExternalDriver} instead.
|
|
315
327
|
*/
|
|
316
|
-
export interface Driver
|
|
317
|
-
extends
|
|
328
|
+
export interface Driver<
|
|
329
|
+
C extends Constraints = BaseDriverCapConstraints,
|
|
330
|
+
A extends StringRecord = StringRecord
|
|
331
|
+
> extends SessionCommands,
|
|
318
332
|
LogCommands,
|
|
319
333
|
FindCommands,
|
|
320
334
|
SettingsCommands,
|
|
321
335
|
TimeoutCommands,
|
|
322
336
|
EventCommands,
|
|
323
|
-
SessionHandler<[string, any], void>,
|
|
337
|
+
SessionHandler<[string, any], void, C>,
|
|
324
338
|
ExecuteCommands,
|
|
325
339
|
Core {
|
|
326
|
-
cliArgs?:
|
|
340
|
+
cliArgs?: A;
|
|
327
341
|
// The following methods are implemented by `BaseDriver`.
|
|
328
342
|
executeCommand(cmd: string, ...args: any[]): Promise<any>;
|
|
329
343
|
startUnexpectedShutdown(err?: Error): Promise<void>;
|
|
330
344
|
startNewCommandTimeout(): Promise<void>;
|
|
331
345
|
reset(): Promise<void>;
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
346
|
+
caps?: Capabilities<C>;
|
|
347
|
+
originalCaps?: W3CCapabilities<C>;
|
|
348
|
+
desiredCapConstraints: C;
|
|
349
|
+
validateDesiredCaps(caps: Capabilities<C>): boolean;
|
|
350
|
+
logExtraCaps(caps: Capabilities<C>): void;
|
|
335
351
|
assignServer?(server: AppiumServer, host: string, port: number, path: string): void;
|
|
336
352
|
}
|
|
337
353
|
|
|
@@ -581,12 +597,18 @@ export type DriverClass<
|
|
|
581
597
|
S extends DriverStatic = DriverStatic
|
|
582
598
|
> = Class<D, S, [] | [Partial<ServerArgs>] | [Partial<ServerArgs>, boolean]>;
|
|
583
599
|
|
|
600
|
+
export interface ExtraDriverOpts {
|
|
601
|
+
fastReset?: boolean;
|
|
602
|
+
skipUninstall?: boolean;
|
|
603
|
+
}
|
|
584
604
|
/**
|
|
585
605
|
* Options as passed into a driver constructor, which is just a union of {@linkcode ServerArgs} and {@linkcode Capabilities}.
|
|
586
606
|
*
|
|
587
607
|
* The combination happens within Appium prior to calling the constructor.
|
|
588
608
|
*/
|
|
589
|
-
export type DriverOpts = ServerArgs &
|
|
609
|
+
export type DriverOpts<C extends Constraints = BaseDriverCapConstraints> = ServerArgs &
|
|
610
|
+
ExtraDriverOpts &
|
|
611
|
+
Partial<ConstraintsToCaps<C>>;
|
|
590
612
|
|
|
591
613
|
export type DriverCommand<TArgs = any, TReturn = unknown> = (...args: TArgs[]) => Promise<TReturn>;
|
|
592
614
|
|
package/lib/index.ts
CHANGED
|
@@ -3,7 +3,6 @@ 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';
|
|
@@ -11,10 +10,12 @@ import type {Logger} from 'npmlog';
|
|
|
11
10
|
export * from './driver';
|
|
12
11
|
export * from './action';
|
|
13
12
|
export * from './plugin';
|
|
14
|
-
export
|
|
15
|
-
export
|
|
13
|
+
export * from './capabilities';
|
|
14
|
+
export * from './constraints';
|
|
15
|
+
export * from './config';
|
|
16
16
|
export * from './appium-config';
|
|
17
|
-
|
|
17
|
+
|
|
18
|
+
export type StringRecord = Record<string, any>;
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* A log prefix for {@linkcode AppiumLogger}
|
|
@@ -63,15 +64,10 @@ export type AppiumServer = Omit<Server, 'close'> & AppiumServerExtension;
|
|
|
63
64
|
|
|
64
65
|
export interface AppiumServerExtension {
|
|
65
66
|
close(): Promise<void>;
|
|
66
|
-
addWebSocketHandler(
|
|
67
|
-
handlerPathname: string,
|
|
68
|
-
handlerServer: WSServer
|
|
69
|
-
): Promise<void>;
|
|
67
|
+
addWebSocketHandler(handlerPathname: string, handlerServer: WSServer): Promise<void>;
|
|
70
68
|
removeWebSocketHandler(handlerPathname: string): Promise<boolean>;
|
|
71
69
|
removeAllWebSocketHandlers(): Promise<boolean>;
|
|
72
|
-
getWebSocketHandlers(
|
|
73
|
-
keysFilter: string | null | undefined
|
|
74
|
-
): Promise<Record<string, WSServer>>;
|
|
70
|
+
getWebSocketHandlers(keysFilter: string | null | undefined): Promise<Record<string, WSServer>>;
|
|
75
71
|
webSocketsMapping: Record<string, WSServer>;
|
|
76
72
|
}
|
|
77
73
|
|
|
@@ -164,8 +160,11 @@ export type ExtensionType = DriverType | PluginType;
|
|
|
164
160
|
* @param httpServer - the node HTTP server that hosts the app
|
|
165
161
|
* @param cliArgs - Arguments from config files, CLI, etc.
|
|
166
162
|
*/
|
|
167
|
-
export type UpdateServerCallback = (
|
|
168
|
-
|
|
163
|
+
export type UpdateServerCallback = (
|
|
164
|
+
expressApp: Express,
|
|
165
|
+
httpServer: AppiumServer,
|
|
166
|
+
cliArgs: ServerArgs
|
|
167
|
+
) => Promise<void>;
|
|
169
168
|
|
|
170
169
|
/**
|
|
171
170
|
* Possible HTTP methods, as stolen from `axios`.
|
|
@@ -173,14 +172,23 @@ export type UpdateServerCallback = (expressApp: Express, httpServer: AppiumServe
|
|
|
173
172
|
* @see https://npm.im/axios
|
|
174
173
|
*/
|
|
175
174
|
export type HTTPMethod =
|
|
176
|
-
| 'get'
|
|
177
|
-
| '
|
|
178
|
-
| '
|
|
179
|
-
| '
|
|
180
|
-
| '
|
|
181
|
-
| '
|
|
182
|
-
| '
|
|
183
|
-
| '
|
|
184
|
-
| '
|
|
185
|
-
| '
|
|
186
|
-
|
|
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,11 +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
|
"@types/ws": "8.5.3",
|
|
39
|
-
"@wdio/types": "7.
|
|
40
|
-
"type-fest": "
|
|
40
|
+
"@wdio/types": "7.25.1",
|
|
41
|
+
"type-fest": "3.1.0"
|
|
41
42
|
},
|
|
42
43
|
"engines": {
|
|
43
44
|
"node": ">=14",
|
|
@@ -46,5 +47,5 @@
|
|
|
46
47
|
"publishConfig": {
|
|
47
48
|
"access": "public"
|
|
48
49
|
},
|
|
49
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "f545a6cde58d83f3289072f8957468793947ba66"
|
|
50
51
|
}
|