@appium/types 0.10.1 → 0.10.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.
- package/build/lib/action.d.ts +1 -7
- package/build/lib/action.d.ts.map +1 -1
- package/build/lib/action.js.map +1 -1
- package/build/lib/capabilities.d.ts +34 -23
- package/build/lib/capabilities.d.ts.map +1 -1
- package/build/lib/command.d.ts +24 -6
- package/build/lib/command.d.ts.map +1 -1
- package/build/lib/config.d.ts +2 -13
- package/build/lib/config.d.ts.map +1 -1
- package/build/lib/config.js.map +1 -1
- package/build/lib/constraints.d.ts +54 -67
- package/build/lib/constraints.d.ts.map +1 -1
- package/build/lib/constraints.js +2 -5
- package/build/lib/constraints.js.map +1 -1
- package/build/lib/driver.d.ts +206 -281
- package/build/lib/driver.d.ts.map +1 -1
- package/build/lib/http.d.ts +11 -0
- package/build/lib/http.d.ts.map +1 -0
- package/build/lib/http.js +3 -0
- package/build/lib/http.js.map +1 -0
- package/build/lib/index.d.ts +5 -104
- package/build/lib/index.d.ts.map +1 -1
- package/build/lib/index.js +5 -3
- 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 +29 -5
- package/build/lib/plugin.d.ts.map +1 -1
- package/build/lib/server.d.ts +60 -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/util.d.ts +67 -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/lib/action.ts +1 -7
- package/lib/capabilities.ts +40 -53
- package/lib/command.ts +30 -10
- package/lib/config.ts +2 -36
- package/lib/{constraints.js → constraints.ts} +5 -5
- package/lib/driver.ts +240 -345
- package/lib/http.ts +31 -0
- package/lib/index.ts +5 -143
- package/lib/logger.ts +41 -0
- package/lib/plugin.ts +37 -6
- package/lib/server.ts +73 -0
- package/lib/util.ts +91 -0
- package/package.json +5 -4
package/lib/http.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An object of HTTP headers.
|
|
3
|
+
*/
|
|
4
|
+
export type HTTPHeaders = Record<string, string | string[] | number | boolean | null>;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Possible HTTP methods, as stolen from `axios`.
|
|
8
|
+
*
|
|
9
|
+
* @see https://npm.im/axios
|
|
10
|
+
*/
|
|
11
|
+
export type HTTPMethod =
|
|
12
|
+
| 'get'
|
|
13
|
+
| 'GET'
|
|
14
|
+
| 'delete'
|
|
15
|
+
| 'DELETE'
|
|
16
|
+
| 'head'
|
|
17
|
+
| 'HEAD'
|
|
18
|
+
| 'options'
|
|
19
|
+
| 'OPTIONS'
|
|
20
|
+
| 'post'
|
|
21
|
+
| 'POST'
|
|
22
|
+
| 'put'
|
|
23
|
+
| 'PUT'
|
|
24
|
+
| 'patch'
|
|
25
|
+
| 'PATCH'
|
|
26
|
+
| 'purge'
|
|
27
|
+
| 'PURGE'
|
|
28
|
+
| 'link'
|
|
29
|
+
| 'LINK'
|
|
30
|
+
| 'unlink'
|
|
31
|
+
| 'UNLINK';
|
package/lib/index.ts
CHANGED
|
@@ -1,150 +1,12 @@
|
|
|
1
|
-
import type {Express} from 'express';
|
|
2
|
-
import type {Server} from 'http';
|
|
3
|
-
import type {Socket} from 'net';
|
|
4
|
-
import type {Logger} from 'npmlog';
|
|
5
|
-
import type {Class as _Class} from 'type-fest';
|
|
6
|
-
import type {Server as WSServer} from 'ws';
|
|
7
|
-
import {ServerArgs} from './config';
|
|
8
1
|
export * from './command';
|
|
9
2
|
export * from './action';
|
|
10
3
|
export * from './appium-config';
|
|
11
4
|
export * from './capabilities';
|
|
12
5
|
export * from './config';
|
|
13
|
-
export
|
|
14
|
-
export type {BaseDriverCapConstraints} from './constraints';
|
|
6
|
+
export * from './constraints';
|
|
15
7
|
export * from './driver';
|
|
16
8
|
export * from './plugin';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
*
|
|
20
|
-
|
|
21
|
-
export type StringRecord = Record<string, any>;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* A log prefix for {@linkcode AppiumLogger}
|
|
25
|
-
*
|
|
26
|
-
* If a function, the function will return the prefix. Log messages will be prefixed with this value.
|
|
27
|
-
*/
|
|
28
|
-
export type AppiumLoggerPrefix = string | (() => string);
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Possible "log levels" for {@linkcode AppiumLogger}.
|
|
32
|
-
*
|
|
33
|
-
* Extracted from `npmlog`.
|
|
34
|
-
*/
|
|
35
|
-
export type AppiumLoggerLevel = 'silly' | 'verbose' | 'debug' | 'info' | 'http' | 'warn' | 'error';
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Describes the `npmlog`-based internal logger.
|
|
39
|
-
*
|
|
40
|
-
* @see https://npm.im/npmlog
|
|
41
|
-
*/
|
|
42
|
-
export interface AppiumLogger {
|
|
43
|
-
/**
|
|
44
|
-
* Returns the underlying `npmlog` {@link Logger}.
|
|
45
|
-
*/
|
|
46
|
-
unwrap(): Logger;
|
|
47
|
-
level: AppiumLoggerLevel;
|
|
48
|
-
levels: AppiumLoggerLevel[];
|
|
49
|
-
/**
|
|
50
|
-
* Log prefix, if applicable.
|
|
51
|
-
*/
|
|
52
|
-
prefix?: AppiumLoggerPrefix;
|
|
53
|
-
debug(...args: any[]): void;
|
|
54
|
-
info(...args: any[]): void;
|
|
55
|
-
warn(...args: any[]): void;
|
|
56
|
-
error(...args: any[]): void;
|
|
57
|
-
verbose(...args: any[]): void;
|
|
58
|
-
silly(...args: any[]): void;
|
|
59
|
-
http(...args: any[]): void;
|
|
60
|
-
errorAndThrow(...args: any[]): never;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Appium's slightly-modified {@linkcode Server http.Server}.
|
|
65
|
-
*/
|
|
66
|
-
export type AppiumServer = Omit<Server, 'close'> & AppiumServerExtension;
|
|
67
|
-
|
|
68
|
-
export interface AppiumServerExtension {
|
|
69
|
-
close(): Promise<void>;
|
|
70
|
-
addWebSocketHandler(handlerPathname: string, handlerServer: WSServer): Promise<void>;
|
|
71
|
-
removeWebSocketHandler(handlerPathname: string): Promise<boolean>;
|
|
72
|
-
removeAllWebSocketHandlers(): Promise<boolean>;
|
|
73
|
-
getWebSocketHandlers(keysFilter: string | null | undefined): Promise<Record<string, WSServer>>;
|
|
74
|
-
webSocketsMapping: Record<string, WSServer>;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export interface AppiumServerSocket extends Socket {
|
|
78
|
-
_openReqCount: number;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Wraps {@linkcode _Class `type-fest`'s `Class`} to include static members.
|
|
83
|
-
*/
|
|
84
|
-
export type Class<
|
|
85
|
-
Proto,
|
|
86
|
-
StaticMembers extends object = object,
|
|
87
|
-
Args extends unknown[] = any[]
|
|
88
|
-
> = _Class<Proto, Args> & StaticMembers;
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* The string referring to a "driver"-type extension
|
|
92
|
-
*/
|
|
93
|
-
export type DriverType = 'driver';
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* The string referring to a "plugin"-type extension
|
|
97
|
-
*
|
|
98
|
-
*/
|
|
99
|
-
export type PluginType = 'plugin';
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* The strings referring to all extension types.
|
|
103
|
-
*/
|
|
104
|
-
export type ExtensionType = DriverType | PluginType;
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Optionally updates an Appium express app and http server, by calling
|
|
108
|
-
* methods that may mutate those objects. For example, you could call:
|
|
109
|
-
*
|
|
110
|
-
* `expressApp.get('/foo', handler)`
|
|
111
|
-
*
|
|
112
|
-
* In order to add a new route to Appium with this plugin. Or, you could add
|
|
113
|
-
* new listeners to the httpServer object.
|
|
114
|
-
*
|
|
115
|
-
* @param expressApp - the Express 'app' object used by Appium for route handling
|
|
116
|
-
* @param httpServer - the node HTTP server that hosts the app
|
|
117
|
-
* @param cliArgs - Arguments from config files, CLI, etc.
|
|
118
|
-
*/
|
|
119
|
-
export type UpdateServerCallback = (
|
|
120
|
-
expressApp: Express,
|
|
121
|
-
httpServer: AppiumServer,
|
|
122
|
-
cliArgs: Partial<ServerArgs>
|
|
123
|
-
) => Promise<void>;
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Possible HTTP methods, as stolen from `axios`.
|
|
127
|
-
*
|
|
128
|
-
* @see https://npm.im/axios
|
|
129
|
-
*/
|
|
130
|
-
export type HTTPMethod =
|
|
131
|
-
| 'get'
|
|
132
|
-
| 'GET'
|
|
133
|
-
| 'delete'
|
|
134
|
-
| 'DELETE'
|
|
135
|
-
| 'head'
|
|
136
|
-
| 'HEAD'
|
|
137
|
-
| 'options'
|
|
138
|
-
| 'OPTIONS'
|
|
139
|
-
| 'post'
|
|
140
|
-
| 'POST'
|
|
141
|
-
| 'put'
|
|
142
|
-
| 'PUT'
|
|
143
|
-
| 'patch'
|
|
144
|
-
| 'PATCH'
|
|
145
|
-
| 'purge'
|
|
146
|
-
| 'PURGE'
|
|
147
|
-
| 'link'
|
|
148
|
-
| 'LINK'
|
|
149
|
-
| 'unlink'
|
|
150
|
-
| 'UNLINK';
|
|
9
|
+
export * from './http';
|
|
10
|
+
export * from './util';
|
|
11
|
+
export * from './server';
|
|
12
|
+
export * from './logger';
|
package/lib/logger.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type {Logger} from 'npmlog';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A log prefix for {@linkcode AppiumLogger}
|
|
5
|
+
*
|
|
6
|
+
* If a function, the function will return the prefix. Log messages will be prefixed with this value.
|
|
7
|
+
*/
|
|
8
|
+
export type AppiumLoggerPrefix = string | (() => string);
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Possible "log levels" for {@linkcode AppiumLogger}.
|
|
12
|
+
*
|
|
13
|
+
* Extracted from `npmlog`.
|
|
14
|
+
*/
|
|
15
|
+
export type AppiumLoggerLevel = 'silly' | 'verbose' | 'debug' | 'info' | 'http' | 'warn' | 'error';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Describes the `npmlog`-based internal logger.
|
|
19
|
+
*
|
|
20
|
+
* @see https://npm.im/npmlog
|
|
21
|
+
*/
|
|
22
|
+
export interface AppiumLogger {
|
|
23
|
+
/**
|
|
24
|
+
* Returns the underlying `npmlog` {@link Logger}.
|
|
25
|
+
*/
|
|
26
|
+
unwrap(): Logger;
|
|
27
|
+
level: AppiumLoggerLevel;
|
|
28
|
+
levels: AppiumLoggerLevel[];
|
|
29
|
+
/**
|
|
30
|
+
* Log prefix, if applicable.
|
|
31
|
+
*/
|
|
32
|
+
prefix?: AppiumLoggerPrefix;
|
|
33
|
+
debug(...args: any[]): void;
|
|
34
|
+
info(...args: any[]): void;
|
|
35
|
+
warn(...args: any[]): void;
|
|
36
|
+
error(...args: any[]): void;
|
|
37
|
+
verbose(...args: any[]): void;
|
|
38
|
+
silly(...args: any[]): void;
|
|
39
|
+
http(...args: any[]): void;
|
|
40
|
+
errorAndThrow(...args: any[]): never;
|
|
41
|
+
}
|
package/lib/plugin.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {AsyncReturnType} from 'type-fest';
|
|
2
2
|
import {ExecuteMethodMap, MethodMap} from './command';
|
|
3
|
-
import {ExternalDriver} from './driver';
|
|
3
|
+
import {DriverCommand, ExternalDriver} from './driver';
|
|
4
|
+
import {AppiumLogger} from './logger';
|
|
5
|
+
import {UpdateServerCallback} from './server';
|
|
6
|
+
import {Class, StringRecord} from './util';
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
9
|
* The interface describing the constructor and static properties of a Plugin.
|
|
@@ -25,6 +28,33 @@ export interface PluginStatic<P extends Plugin> {
|
|
|
25
28
|
executeMethodMap?: ExecuteMethodMap<P>;
|
|
26
29
|
}
|
|
27
30
|
|
|
31
|
+
/**
|
|
32
|
+
* This utility type can presently be used by Plugin authors to mark a method in their plugin as one
|
|
33
|
+
* which overrides a method in a Driver.
|
|
34
|
+
* @privateRemarks This would work well as a decorator. May want to accept a type arg for `Driver`
|
|
35
|
+
* and use a string method name to lookup the method instead.
|
|
36
|
+
* @example
|
|
37
|
+
*
|
|
38
|
+
* class MyPlugin extends BasePlugin implements Plugin {
|
|
39
|
+
* public getPageSource: DriverCommandToPluginCommand<
|
|
40
|
+
* ExternalDriver['getPageSource'], // method to override
|
|
41
|
+
* [flag: boolean], // new arguments; defaults to the args of the method
|
|
42
|
+
* string|Buffer, // new return type; defaults to the async return type of the method
|
|
43
|
+
* string // async return type of `next()`
|
|
44
|
+
* > = async function (next, driver, flag = boolean) {
|
|
45
|
+
* const source = await next();
|
|
46
|
+
* return flag ? source : Buffer.from(source);
|
|
47
|
+
* }
|
|
48
|
+
* }
|
|
49
|
+
*
|
|
50
|
+
*/
|
|
51
|
+
export type DriverCommandToPluginCommand<
|
|
52
|
+
DC extends DriverCommand,
|
|
53
|
+
TArgs extends readonly any[] = Parameters<DC>,
|
|
54
|
+
TReturn = AsyncReturnType<DC>,
|
|
55
|
+
NextRetval = unknown
|
|
56
|
+
> = PluginCommand<ExternalDriver, TArgs, TReturn, NextRetval>;
|
|
57
|
+
|
|
28
58
|
/**
|
|
29
59
|
* An instance of a "plugin" extension.
|
|
30
60
|
*
|
|
@@ -70,7 +100,7 @@ export interface Plugin {
|
|
|
70
100
|
* `driver._eventHistory.commands.push({cmd: cmdName, startTime, endTime})` --
|
|
71
101
|
* after running plugin logic
|
|
72
102
|
*/
|
|
73
|
-
export type NextPluginCallback = () => Promise<
|
|
103
|
+
export type NextPluginCallback<T = unknown> = () => Promise<T>;
|
|
74
104
|
|
|
75
105
|
/**
|
|
76
106
|
* Implementation of a command within a plugin
|
|
@@ -80,8 +110,9 @@ export type NextPluginCallback = () => Promise<void>;
|
|
|
80
110
|
export type PluginCommand<
|
|
81
111
|
D extends ExternalDriver = ExternalDriver,
|
|
82
112
|
TArgs extends readonly any[] = any[],
|
|
83
|
-
TReturn =
|
|
84
|
-
|
|
113
|
+
TReturn = unknown,
|
|
114
|
+
NextReturn = unknown
|
|
115
|
+
> = (next: NextPluginCallback<NextReturn>, driver: D, ...args: TArgs) => Promise<TReturn>;
|
|
85
116
|
|
|
86
117
|
/**
|
|
87
118
|
* Mainly for internal use.
|
|
@@ -91,5 +122,5 @@ export type PluginCommand<
|
|
|
91
122
|
export type PluginClass<P extends Plugin = Plugin> = Class<
|
|
92
123
|
P,
|
|
93
124
|
PluginStatic<P>,
|
|
94
|
-
[pluginName: string, cliArgs:
|
|
125
|
+
[pluginName: string, cliArgs: StringRecord<unknown>]
|
|
95
126
|
>;
|
package/lib/server.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type {Express} from 'express';
|
|
2
|
+
import type {Server as WSServer} from 'ws';
|
|
3
|
+
import type {Server as HTTPServer} from 'node:http';
|
|
4
|
+
import type {Socket} from 'node:net';
|
|
5
|
+
import {ServerArgs} from './config';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Appium's slightly-modified {@linkcode HTTPServer http.Server}.
|
|
9
|
+
*/
|
|
10
|
+
export type AppiumServer = Omit<HTTPServer, 'close'> & AppiumServerExtension;
|
|
11
|
+
|
|
12
|
+
export interface AppiumServerExtension {
|
|
13
|
+
close(): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Adds websocket handler to an {@linkcode AppiumServer}.
|
|
16
|
+
* @param handlerPathname - Web socket endpoint path starting with a single slash character. It is recommended to always prepend `/ws` to all web socket pathnames.
|
|
17
|
+
* @param handlerServer - WebSocket server instance. See https://github.com/websockets/ws/pull/885 for more details on how to configure the handler properly.
|
|
18
|
+
*/
|
|
19
|
+
addWebSocketHandler(
|
|
20
|
+
this: AppiumServer,
|
|
21
|
+
handlerPathname: string,
|
|
22
|
+
handlerServer: WSServer
|
|
23
|
+
): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Removes existing WebSocket handler from the server instance.
|
|
26
|
+
*
|
|
27
|
+
* The call is ignored if the given `handlerPathname` handler is not present in the handlers list.
|
|
28
|
+
* @param handlerPathname - WebSocket endpoint path
|
|
29
|
+
* @returns `true` if the `handlerPathname` was found and deleted; `false` otherwise.
|
|
30
|
+
*/
|
|
31
|
+
removeWebSocketHandler(this: AppiumServer, handlerPathname: string): Promise<boolean>;
|
|
32
|
+
/**
|
|
33
|
+
* Removes all existing WebSocket handlers from the server instance.
|
|
34
|
+
* @returns `true` if at least one handler was deleted; `false` otherwise.
|
|
35
|
+
*/
|
|
36
|
+
removeAllWebSocketHandlers(this: AppiumServer): Promise<boolean>;
|
|
37
|
+
/**
|
|
38
|
+
* Returns web socket handlers registered for the given server
|
|
39
|
+
* instance.
|
|
40
|
+
* @param keysFilter - Only include pathnames with given value if set. All pairs will be included by default.
|
|
41
|
+
* @returns Pathnames to WS server instances mapping matching the search criteria, if any found.
|
|
42
|
+
*/
|
|
43
|
+
getWebSocketHandlers(
|
|
44
|
+
this: AppiumServer,
|
|
45
|
+
keysFilter?: string | null
|
|
46
|
+
): Promise<Record<string, WSServer>>;
|
|
47
|
+
webSocketsMapping: Record<string, WSServer>;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface AppiumServerSocket extends Socket {
|
|
51
|
+
_openReqCount: number;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export {WSServer};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Optionally updates an Appium express app and http server, by calling
|
|
58
|
+
* methods that may mutate those objects. For example, you could call:
|
|
59
|
+
*
|
|
60
|
+
* `expressApp.get('/foo', handler)`
|
|
61
|
+
*
|
|
62
|
+
* In order to add a new route to Appium with this plugin. Or, you could add
|
|
63
|
+
* new listeners to the httpServer object.
|
|
64
|
+
*
|
|
65
|
+
* @param expressApp - the Express 'app' object used by Appium for route handling
|
|
66
|
+
* @param httpServer - the node HTTP server that hosts the app
|
|
67
|
+
* @param cliArgs - Arguments from config files, CLI, etc.
|
|
68
|
+
*/
|
|
69
|
+
export type UpdateServerCallback = (
|
|
70
|
+
expressApp: Express,
|
|
71
|
+
httpServer: AppiumServer,
|
|
72
|
+
cliArgs: Partial<ServerArgs>
|
|
73
|
+
) => Promise<void>;
|
package/lib/util.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type {Class as _Class} from 'type-fest';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Utility type for a object with string-only props
|
|
5
|
+
*/
|
|
6
|
+
export type StringRecord<T = any> = Record<string, T>;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Wraps {@linkcode _Class `type-fest`'s `Class`} to include static members.
|
|
10
|
+
*/
|
|
11
|
+
export type Class<
|
|
12
|
+
Proto,
|
|
13
|
+
StaticMembers extends object = object,
|
|
14
|
+
Args extends unknown[] = any[]
|
|
15
|
+
> = _Class<Proto, Args> & StaticMembers;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The string referring to a "driver"-type extension
|
|
19
|
+
*/
|
|
20
|
+
export type DriverType = 'driver';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The string referring to a "plugin"-type extension
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
export type PluginType = 'plugin';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The strings referring to all extension types.
|
|
30
|
+
*/
|
|
31
|
+
export type ExtensionType = DriverType | PluginType;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Converts a kebab-cased string into a camel-cased string.
|
|
35
|
+
*/
|
|
36
|
+
export type KebabToCamel<S extends string> = S extends `${infer P1}-${infer P2}${infer P3}`
|
|
37
|
+
? `${Lowercase<P1>}${Uppercase<P2>}${KebabToCamel<P3>}`
|
|
38
|
+
: Lowercase<S>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Converts an object with kebab-cased keys into camel-cased keys.
|
|
42
|
+
*/
|
|
43
|
+
export type ObjectToCamel<T> = {
|
|
44
|
+
[K in keyof T as KebabToCamel<string & K>]: T[K] extends Record<string, any>
|
|
45
|
+
? KeysToCamelCase<T[K]>
|
|
46
|
+
: T[K];
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Converts an object or array to have camel-cased keys.
|
|
51
|
+
*/
|
|
52
|
+
export type KeysToCamelCase<T> = {
|
|
53
|
+
[K in keyof T as KebabToCamel<string & K>]: T[K] extends Array<any>
|
|
54
|
+
? KeysToCamelCase<T[K][number]>[]
|
|
55
|
+
: ObjectToCamel<T[K]>;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Object `B` has all the keys as object `A` (even if those keys in `A` are otherwise optional).
|
|
60
|
+
*/
|
|
61
|
+
export type Associated<A extends object, B extends {[key in keyof Required<A>]: unknown}> = {
|
|
62
|
+
[Prop in keyof Required<A>]: B[Prop];
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Given `string` `T`, this is a case-insensitive version of `T`.
|
|
67
|
+
*/
|
|
68
|
+
export type AnyCase<T extends string> = string extends T
|
|
69
|
+
? string
|
|
70
|
+
: T extends `${infer F1}${infer F2}${infer R}`
|
|
71
|
+
? `${Uppercase<F1> | Lowercase<F1>}${Uppercase<F2> | Lowercase<F2>}${AnyCase<R>}`
|
|
72
|
+
: T extends `${infer F}${infer R}`
|
|
73
|
+
? `${Uppercase<F> | Lowercase<F>}${AnyCase<R>}`
|
|
74
|
+
: '';
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* A W3C element.
|
|
78
|
+
* @see https://www.w3.org/TR/webdriver1/#elements
|
|
79
|
+
*/
|
|
80
|
+
export interface Element<Id extends string = string> {
|
|
81
|
+
/**
|
|
82
|
+
* For backwards compatibility with JSONWP only.
|
|
83
|
+
* @deprecated Use {@linkcode element-6066-11e4-a52e-4f735466cecf} instead.
|
|
84
|
+
*/
|
|
85
|
+
ELEMENT?: Id;
|
|
86
|
+
/**
|
|
87
|
+
* This property name is the string constant W3C element identifier used to identify an object as
|
|
88
|
+
* a W3C element.
|
|
89
|
+
*/
|
|
90
|
+
'element-6066-11e4-a52e-4f735466cecf': Id;
|
|
91
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appium/types",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.3",
|
|
4
4
|
"description": "Various type declarations used across Appium",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"automation",
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "node ./scripts/generate-schema-types.js",
|
|
36
36
|
"clean": "git checkout -- ./types/lib/appium-config.ts || true",
|
|
37
|
-
"test:smoke": "node ./index.js"
|
|
37
|
+
"test:smoke": "node ./index.js",
|
|
38
|
+
"test:types": "tsd"
|
|
38
39
|
},
|
|
39
40
|
"dependencies": {
|
|
40
41
|
"@appium/schema": "^0.2.6",
|
|
@@ -42,7 +43,7 @@
|
|
|
42
43
|
"@types/express": "4.17.17",
|
|
43
44
|
"@types/npmlog": "4.1.4",
|
|
44
45
|
"@types/ws": "8.5.4",
|
|
45
|
-
"type-fest": "3.
|
|
46
|
+
"type-fest": "3.7.2"
|
|
46
47
|
},
|
|
47
48
|
"engines": {
|
|
48
49
|
"node": "^14.17.0 || ^16.13.0 || >=18.0.0",
|
|
@@ -51,7 +52,7 @@
|
|
|
51
52
|
"publishConfig": {
|
|
52
53
|
"access": "public"
|
|
53
54
|
},
|
|
54
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "a11a6ede3320c0a58aad82fd7fc4c8b8ba75ae95",
|
|
55
56
|
"typedoc": {
|
|
56
57
|
"entryPoint": "./lib/index.ts"
|
|
57
58
|
}
|