@appium/types 0.2.3 → 0.2.4
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/capabilities.d.ts.map +1 -1
- package/build/config.d.ts.map +1 -1
- package/build/driver.d.ts +440 -0
- package/build/driver.d.ts.map +1 -0
- package/build/index.d.ts +100 -399
- package/build/index.d.ts.map +1 -1
- package/build/plugin.d.ts +79 -0
- package/build/plugin.d.ts.map +1 -0
- package/lib/capabilities.ts +11 -12
- package/lib/config.ts +20 -23
- package/lib/driver.ts +601 -0
- package/lib/index.ts +117 -600
- package/lib/plugin.ts +92 -0
- package/package.json +9 -8
package/lib/plugin.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import {MethodMap, UpdateServerCallback, Class, AppiumLogger} from '.';
|
|
2
|
+
import {Driver, ExternalDriver} from './driver';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The interface describing the constructor and static properties of a Plugin.
|
|
6
|
+
*/
|
|
7
|
+
export interface PluginStatic<T extends Plugin = Plugin> {
|
|
8
|
+
/**
|
|
9
|
+
* Allows a plugin to modify the Appium server instance.
|
|
10
|
+
*/
|
|
11
|
+
updateServer?: UpdateServerCallback;
|
|
12
|
+
/**
|
|
13
|
+
* Plugins can define new methods for the Appium server to map to command names, of the same
|
|
14
|
+
* format as used in Appium's `routes.js`, for example, this would be a valid `newMethodMap`:
|
|
15
|
+
* @example
|
|
16
|
+
* {
|
|
17
|
+
* '/session/:sessionId/new_method': {
|
|
18
|
+
* GET: {command: 'getNewThing'},
|
|
19
|
+
* POST: {command: 'setNewThing', payloadParams: {required: ['someParam']}}
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
*/
|
|
23
|
+
newMethodMap?: MethodMap<T>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* An instance of a "plugin" extension.
|
|
28
|
+
*
|
|
29
|
+
* Likewise, the `prototype` of a {@link PluginClass `Plugin` class}.
|
|
30
|
+
*/
|
|
31
|
+
export interface Plugin {
|
|
32
|
+
/**
|
|
33
|
+
* Name of the plugin. Derived from the metadata.
|
|
34
|
+
*/
|
|
35
|
+
name: string;
|
|
36
|
+
/**
|
|
37
|
+
* A logger with prefix identifying the plugin
|
|
38
|
+
*/
|
|
39
|
+
logger: AppiumLogger;
|
|
40
|
+
/**
|
|
41
|
+
* CLI args for this plugin (if any are accepted and provided).
|
|
42
|
+
*/
|
|
43
|
+
cliArgs: Record<string, any>;
|
|
44
|
+
/**
|
|
45
|
+
* Listener for unexpected server shutdown, which allows a plugin to do cleanup or take custom actions.
|
|
46
|
+
*/
|
|
47
|
+
onUnexpectedShutdown?: (driver: Driver, cause: Error | string) => Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Handle an Appium command, optionally running and using or throwing away the value of the
|
|
50
|
+
* original Appium behavior (or the behavior of the next plugin in a plugin chain).
|
|
51
|
+
*/
|
|
52
|
+
handle?: (
|
|
53
|
+
next: NextPluginCallback,
|
|
54
|
+
driver: Driver,
|
|
55
|
+
cmdName: string,
|
|
56
|
+
...args: any[]
|
|
57
|
+
) => Promise<void>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* A reference to an async function which encapsulates what would normally
|
|
62
|
+
* happen if this plugin were not handling a command. Used by {@link PluginInterface.handle}.
|
|
63
|
+
*
|
|
64
|
+
* Given `next()` is a `NextPluginCallback`: if this is the only plugin
|
|
65
|
+
* handling the command, `await next()` would therefore trigger the normal
|
|
66
|
+
* handling logic in the driver which is in use. If another plugin is
|
|
67
|
+
* registered, it would run *that* plugin's `handle` method and return the
|
|
68
|
+
* result for use here. Note that if this plugin does *not* call `await next()`,
|
|
69
|
+
* then the normal command logic will not be run, and this plugin is responsible
|
|
70
|
+
* for managing new command timeouts and command logging, for example:
|
|
71
|
+
* `driver.stopNewCommandTimeout()` -- before running plugin logic
|
|
72
|
+
* `driver.startNewCommandTimeout()` -- after running plugin logic
|
|
73
|
+
* `driver._eventHistory.commands.push({cmd: cmdName, startTime, endTime}) --
|
|
74
|
+
* after running plugin logic
|
|
75
|
+
*/
|
|
76
|
+
export type NextPluginCallback = () => Promise<void>;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Implementation of a command within a plugin
|
|
80
|
+
*/
|
|
81
|
+
export type PluginCommand<TArgs = any> = (
|
|
82
|
+
next: NextPluginCallback,
|
|
83
|
+
driver: ExternalDriver,
|
|
84
|
+
...args: TArgs[]
|
|
85
|
+
) => Promise<void>;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Mainly for internal use.
|
|
89
|
+
*
|
|
90
|
+
* The third parameter is the possible constructor signatures for the plugin class.
|
|
91
|
+
*/
|
|
92
|
+
export type PluginClass = Class<Plugin, PluginStatic, [string, Record<string, unknown>]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appium/types",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Various type declarations used across Appium",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"appium",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "Apache-2.0",
|
|
20
20
|
"author": "https://github.com/appium",
|
|
21
|
+
"types": "./build/index.d.ts",
|
|
21
22
|
"files": [
|
|
22
23
|
"build",
|
|
23
24
|
"lib"
|
|
@@ -26,18 +27,18 @@
|
|
|
26
27
|
"build": "node ./scripts/generate-schema-types.js",
|
|
27
28
|
"dev": "npm run build -- --watch",
|
|
28
29
|
"fix": "npm run lint -- --fix",
|
|
29
|
-
"lint": "eslint -c ../../.eslintrc --ignore-path ../../.eslintignore ."
|
|
30
|
+
"lint": "eslint -c ../../.eslintrc --ignore-path ../../.eslintignore .",
|
|
31
|
+
"prepare": "npm run build"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@appium/schema": "^0.0.6"
|
|
30
35
|
},
|
|
31
36
|
"engines": {
|
|
32
|
-
"node": ">=
|
|
37
|
+
"node": ">=14",
|
|
33
38
|
"npm": ">=6"
|
|
34
39
|
},
|
|
35
|
-
"types": "./build/index.d.ts",
|
|
36
40
|
"publishConfig": {
|
|
37
41
|
"access": "public"
|
|
38
42
|
},
|
|
39
|
-
"gitHead": "
|
|
40
|
-
"dependencies": {
|
|
41
|
-
"@appium/schema": "^0.0.5"
|
|
42
|
-
}
|
|
43
|
+
"gitHead": "5c7af8ee73078018e4ec52fccf19fe3f77249d72"
|
|
43
44
|
}
|