@appium/types 0.4.1 → 0.6.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.
Files changed (49) hide show
  1. package/build/{action.d.ts → lib/action.d.ts} +0 -0
  2. package/build/lib/action.d.ts.map +1 -0
  3. package/build/lib/action.js +85 -0
  4. package/build/lib/action.js.map +1 -0
  5. package/build/{appium-config.d.ts → lib/appium-config.d.ts} +39 -1
  6. package/build/lib/appium-config.d.ts.map +1 -0
  7. package/build/lib/appium-config.js +9 -0
  8. package/build/lib/appium-config.js.map +1 -0
  9. package/build/lib/capabilities.d.ts +126 -0
  10. package/build/lib/capabilities.d.ts.map +1 -0
  11. package/build/lib/capabilities.js +3 -0
  12. package/build/lib/capabilities.js.map +1 -0
  13. package/build/{config.d.ts → lib/config.d.ts} +0 -0
  14. package/build/lib/config.d.ts.map +1 -0
  15. package/build/lib/config.js +4 -0
  16. package/build/lib/config.js.map +1 -0
  17. package/build/lib/constraints.d.ts +65 -0
  18. package/build/lib/constraints.d.ts.map +1 -0
  19. package/build/lib/constraints.js +58 -0
  20. package/build/lib/constraints.js.map +1 -0
  21. package/build/{driver.d.ts → lib/driver.d.ts} +104 -71
  22. package/build/lib/driver.d.ts.map +1 -0
  23. package/build/lib/driver.js +3 -0
  24. package/build/lib/driver.js.map +1 -0
  25. package/build/{index.d.ts → lib/index.d.ts} +29 -24
  26. package/build/lib/index.d.ts.map +1 -0
  27. package/build/lib/index.js +26 -0
  28. package/build/lib/index.js.map +1 -0
  29. package/build/{plugin.d.ts → lib/plugin.d.ts} +6 -3
  30. package/build/lib/plugin.d.ts.map +1 -0
  31. package/build/lib/plugin.js +3 -0
  32. package/build/lib/plugin.js.map +1 -0
  33. package/build/tsconfig.tsbuildinfo +1 -0
  34. package/index.js +1 -0
  35. package/lib/appium-config.ts +39 -1
  36. package/lib/capabilities.ts +164 -32
  37. package/lib/constraints.js +55 -0
  38. package/lib/driver.ts +148 -88
  39. package/lib/index.ts +60 -45
  40. package/lib/plugin.ts +7 -3
  41. package/package.json +23 -17
  42. package/build/action.d.ts.map +0 -1
  43. package/build/appium-config.d.ts.map +0 -1
  44. package/build/capabilities.d.ts +0 -47
  45. package/build/capabilities.d.ts.map +0 -1
  46. package/build/config.d.ts.map +0 -1
  47. package/build/driver.d.ts.map +0 -1
  48. package/build/index.d.ts.map +0 -1
  49. package/build/plugin.d.ts.map +0 -1
package/lib/driver.ts CHANGED
@@ -2,17 +2,21 @@ 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';
17
+ import {AsyncReturnType, ConditionalPick} from 'type-fest';
14
18
 
15
- export interface TimeoutCommands {
19
+ export interface ITimeoutCommands {
16
20
  timeouts(
17
21
  type: string,
18
22
  ms: number | string,
@@ -35,37 +39,42 @@ export interface TimeoutCommands {
35
39
  parseTimeoutArgument(ms: number | string): number;
36
40
  }
37
41
 
38
- export interface EventCommands {
42
+ export interface IEventCommands {
39
43
  logCustomEvent(vendor: string, event: string): Promise<void>;
40
44
  getLogEvents(type?: string | string[]): Promise<EventHistory | Record<string, number>>;
41
45
  }
42
46
 
43
- export interface SessionCommands {
47
+ export interface ISessionCommands {
44
48
  getSessions(): Promise<MultiSessionData[]>;
45
49
  getSession(): Promise<SingularSessionData>;
46
50
  }
47
51
 
48
- export interface ExecuteCommands {
49
- executeMethod(script: string, args: [Record<string, any>]|[]): Promise<any>;
52
+ export interface IExecuteCommands {
53
+ executeMethod(script: string, args: [StringRecord] | []): Promise<any>;
50
54
  }
51
55
 
52
- export interface ExecuteMethodDef {
53
- command: string,
56
+ export interface ExecuteMethodDef<D> {
57
+ command: keyof ConditionalPick<Required<D>, DriverCommand>;
54
58
  params?: {
55
- required?: string[],
56
- optional?: string[],
57
- }
58
- };
59
- export type ExecuteMethodMap = Record<string, ExecuteMethodDef>;
60
-
61
- export interface MultiSessionData {
59
+ required?: ReadonlyArray<string>;
60
+ optional?: ReadonlyArray<string>;
61
+ };
62
+ }
63
+ export type ExecuteMethodMap<D> = Readonly<Record<string, Readonly<ExecuteMethodDef<D>>>>;
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 = Capabilities & {events?: EventHistory};
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
- export interface FindCommands {
77
+ export interface IFindCommands<Ctx = any> {
69
78
  findElement(strategy: string, selector: string): Promise<Element>;
70
79
  findElements(strategy: string, selector: string): Promise<Element[]>;
71
80
  findElementFromElement(strategy: string, selector: string, elementId: string): Promise<Element>;
@@ -79,42 +88,84 @@ export interface FindCommands {
79
88
  strategy: string,
80
89
  selector: string,
81
90
  mult: Mult,
82
- context?: string
91
+ context?: Ctx
83
92
  ): Promise<Mult extends true ? Element[] : Element>;
84
93
 
85
94
  findElOrElsWithProcessing<Mult extends boolean>(
86
95
  strategy: string,
87
96
  selector: string,
88
97
  mult: Mult,
89
- context?: string
98
+ context?: Ctx
90
99
  ): Promise<Mult extends true ? Element[] : Element>;
91
100
 
92
101
  getPageSource(): Promise<string>;
93
102
  }
94
103
 
95
- export interface LogCommands {
96
- supportedLogTypes: Record<string, LogType<Driver>>;
97
- getLogTypes(): Promise<string[]>;
104
+ export interface ILogCommands<C extends Constraints> {
105
+ /**
106
+ * Definition of the available log types
107
+ */
108
+ supportedLogTypes: Readonly<LogDefRecord<C>>;
109
+
110
+ /**
111
+ * Get available log types as a list of strings
112
+ */
113
+ getLogTypes(): Promise<(keyof ILogCommands<C>['supportedLogTypes'])[]>;
114
+
98
115
  /**
99
- * Gets logs
116
+ * Get the log for a given log type.
100
117
  *
101
- * TODO: `logType` should be a key in `supportedLogTypes`, and the return value of this function
102
- * should be the associated `LogType` object's `LogEntry` parameterized type.
103
- * @param logType - Name/key of log type as defined in {@linkcode LogCommands.supportedLogTypes}.
118
+ * @param logType - Name/key of log type as defined in {@linkcode ILogCommands.supportedLogTypes}.
104
119
  */
105
- getLog(logType: string): Promise<any[]>;
120
+ getLog(
121
+ logType: keyof ILogCommands<C>['supportedLogTypes']
122
+ ): Promise<
123
+ AsyncReturnType<
124
+ ILogCommands<C>['supportedLogTypes'][keyof ILogCommands<C>['supportedLogTypes']]['getter']
125
+ >
126
+ >;
106
127
  }
107
128
 
108
- export interface SettingsCommands {
109
- updateSettings: (settings: Record<string, any>) => Promise<void>;
110
- getSettings(): Promise<Record<string, any>>;
129
+ /**
130
+ * A record of {@linkcode LogDef} objects, keyed by the log type name.
131
+ * Used in {@linkcode ILogCommands.supportedLogTypes}
132
+ */
133
+ export type LogDefRecord<C extends Constraints> = Record<string, LogDef<C>>;
134
+
135
+ /**
136
+ * A definition of a log type
137
+ */
138
+ export interface LogDef<C extends Constraints, T = unknown> {
139
+ /**
140
+ * Description of the log type.
141
+ *
142
+ * The only place this is used is in error messages if the client provides an invalid log type
143
+ * via {@linkcode ILogCommands.getLog}.
144
+ */
145
+ description: string;
146
+ /**
147
+ * Returns all the log data for the given type
148
+ *
149
+ * This implementation *should* drain, truncate or otherwise reset the log buffer.
150
+ */
151
+ getter: (driver: Driver<C>) => Promise<T[]>;
152
+ }
153
+
154
+ export interface ISettingsCommands {
155
+ updateSettings: (settings: StringRecord) => Promise<void>;
156
+ getSettings(): Promise<StringRecord>;
111
157
  }
112
158
 
113
- export interface SessionHandler<CreateResult, DeleteResult> {
159
+ export interface SessionHandler<
160
+ CreateResult,
161
+ DeleteResult,
162
+ C extends Constraints = BaseDriverCapConstraints,
163
+ Extra extends StringRecord | void = void
164
+ > {
114
165
  createSession(
115
- w3cCaps1: W3CCapabilities,
116
- w3cCaps2?: W3CCapabilities,
117
- w3cCaps?: W3CCapabilities,
166
+ w3cCaps1: W3CCapabilities<C, Extra>,
167
+ w3cCaps2?: W3CCapabilities<C, Extra>,
168
+ w3cCaps?: W3CCapabilities<C, Extra>,
118
169
  driverData?: DriverData[]
119
170
  ): Promise<CreateResult>;
120
171
 
@@ -140,24 +191,24 @@ export type DriverData = Record<string, unknown>;
140
191
  * }
141
192
  */
142
193
  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[];
194
+ readonly presence?: boolean | Readonly<{allowEmpty: boolean}>;
195
+ readonly isString?: boolean;
196
+ readonly isNumber?: boolean;
197
+ readonly isBoolean?: boolean;
198
+ readonly isObject?: boolean;
199
+ readonly isArray?: boolean;
200
+ readonly deprecated?: boolean;
201
+ readonly inclusion?: Readonly<[any, ...any[]]>;
202
+ readonly inclusionCaseInsensitive?: Readonly<[any, ...any[]]>;
152
203
  }
153
- export type Constraints = Record<string, Constraint>;
204
+ export type Constraints = Readonly<Record<string, Constraint>>;
154
205
 
155
- export interface DriverHelpers {
206
+ export interface DriverHelpers<C extends Constraints> {
156
207
  configureApp: (app: string, supportedAppExtensions: string[]) => Promise<string>;
157
208
  isPackageOrBundle: (app: string) => boolean;
158
209
  duplicateKeys: <T>(input: T, firstKey: string, secondKey: string) => T;
159
210
  parseCapsArray: (cap: string | string[]) => string[];
160
- generateDriverLogPrefix: (obj: Core, sessionId?: string) => string;
211
+ generateDriverLogPrefix: (obj: Core<C>, sessionId?: string) => string;
161
212
  }
162
213
 
163
214
  export type SettingsUpdateListener<T extends Record<string, unknown> = Record<string, unknown>> = (
@@ -171,11 +222,6 @@ export interface DeviceSettings<T = any> {
171
222
  getSettings(): Record<string, T>;
172
223
  }
173
224
 
174
- export interface LogType<TDriver, LogEntry = string> {
175
- description: string;
176
- getter: (driver: TDriver) => Promise<LogEntry[]>;
177
- }
178
-
179
225
  // WebDriver
180
226
 
181
227
  export interface Rect {
@@ -230,7 +276,7 @@ export type Position = Pick<Rect, 'x' | 'y'>;
230
276
  export interface Location {
231
277
  latitude: number;
232
278
  longitude: number;
233
- altitude: number;
279
+ altitude?: number;
234
280
  }
235
281
 
236
282
  export interface Rotation {
@@ -267,15 +313,13 @@ export interface EventHistoryCommand {
267
313
  *
268
314
  * This should not be used directly by external code.
269
315
  */
270
- export interface Core {
316
+ export interface Core<C extends Constraints = BaseDriverCapConstraints> {
271
317
  shouldValidateCaps: boolean;
272
318
  sessionId: string | null;
273
- opts: DriverOpts;
319
+ opts: DriverOpts<C>;
274
320
  initialOpts: ServerArgs;
275
- caps?: Capabilities;
276
- originalCaps?: W3CCapabilities;
277
321
  protocol?: string;
278
- helpers: DriverHelpers;
322
+ helpers: DriverHelpers<C>;
279
323
  basePath: string;
280
324
  relaxedSecurityEnabled: boolean;
281
325
  allowInsecure: string[];
@@ -306,32 +350,41 @@ export interface Core {
306
350
  getManagedDrivers(): Driver[];
307
351
  clearNewCommandTimeout(): Promise<void>;
308
352
  logEvent(eventName: string): void;
309
- driverForSession(sessionId: string): Core | null;
353
+ driverForSession(sessionId: string): Core<C> | null;
310
354
  }
311
355
 
312
356
  /**
313
357
  * `BaseDriver` implements this. It contains default behavior;
314
358
  * external drivers are expected to implement {@linkcode ExternalDriver} instead.
359
+ *
360
+ * `C` should be the constraints of the driver.
361
+ * `CArgs` would be the shape of `cliArgs`.
362
+ * `Ctx` would be the type of the element context (e.g., string, dictionary of some sort, etc.)
315
363
  */
316
- export interface Driver
317
- extends SessionCommands,
318
- LogCommands,
319
- FindCommands,
320
- SettingsCommands,
321
- TimeoutCommands,
322
- EventCommands,
323
- SessionHandler<[string, any], void>,
324
- ExecuteCommands,
364
+ export interface Driver<
365
+ C extends Constraints = BaseDriverCapConstraints,
366
+ CArgs extends StringRecord = StringRecord,
367
+ Ctx = any
368
+ > extends ISessionCommands,
369
+ ILogCommands<C>,
370
+ IFindCommands<Ctx>,
371
+ ISettingsCommands,
372
+ ITimeoutCommands,
373
+ IEventCommands,
374
+ IExecuteCommands,
375
+ SessionHandler<[string, any], void, C>,
325
376
  Core {
326
- cliArgs?: Record<string, any>;
377
+ cliArgs: CArgs;
327
378
  // The following methods are implemented by `BaseDriver`.
328
379
  executeCommand(cmd: string, ...args: any[]): Promise<any>;
329
380
  startUnexpectedShutdown(err?: Error): Promise<void>;
330
381
  startNewCommandTimeout(): Promise<void>;
331
382
  reset(): Promise<void>;
332
- desiredCapConstraints: Constraints;
333
- validateDesiredCaps(caps: Capabilities): boolean;
334
- logExtraCaps(caps: Capabilities): void;
383
+ caps?: Capabilities<C>;
384
+ originalCaps?: W3CCapabilities<C>;
385
+ desiredCapConstraints: C;
386
+ validateDesiredCaps(caps: Capabilities<C>): boolean;
387
+ logExtraCaps(caps: Capabilities<C>): void;
335
388
  assignServer?(server: AppiumServer, host: string, port: number, path: string): void;
336
389
  }
337
390
 
@@ -339,12 +392,13 @@ export interface Driver
339
392
  * External drivers must subclass `BaseDriver`, and can implement any of these methods.
340
393
  * None of these are implemented within Appium itself.
341
394
  */
342
- export interface ExternalDriver extends Driver {
395
+ export interface ExternalDriver<C extends Constraints = BaseDriverCapConstraints>
396
+ extends Driver<C> {
343
397
  // The following properties are assigned by appium */
344
- server: AppiumServer;
345
- serverHost: string;
346
- serverPort: number;
347
- serverPath: string;
398
+ server?: AppiumServer;
399
+ serverHost?: string;
400
+ serverPort?: number;
401
+ serverPath?: string;
348
402
 
349
403
  // WebDriver
350
404
  setUrl?(url: string): Promise<void>;
@@ -555,8 +609,7 @@ export interface ExternalDriver extends Driver {
555
609
  removeAllAuthCredentials?(): Promise<void>;
556
610
  removeAuthCredential?(): Promise<void>;
557
611
  setUserAuthVerified?(isUserVerified: boolean): Promise<void>;
558
-
559
- proxyCommand?(url: string, method: HTTPMethod, body?: string): Promise<unknown>;
612
+ proxyCommand?<T = any>(url: string, method: HTTPMethod, body?: string): Promise<T>;
560
613
  }
561
614
 
562
615
  /**
@@ -564,11 +617,11 @@ export interface ExternalDriver extends Driver {
564
617
  *
565
618
  * This is likely unusable by external consumers, but YMMV!
566
619
  */
567
- export interface DriverStatic {
620
+ export interface DriverStatic<D extends Driver> {
568
621
  baseVersion: string;
569
622
  updateServer?: UpdateServerCallback;
570
- newMethodMap?: MethodMap<ExternalDriver>;
571
- executeMethodMap: ExecuteMethodMap;
623
+ newMethodMap?: MethodMap<D>;
624
+ executeMethodMap?: ExecuteMethodMap<D>;
572
625
  }
573
626
 
574
627
  /**
@@ -576,17 +629,24 @@ export interface DriverStatic {
576
629
  *
577
630
  * This is likely unusable by external consumers, but YMMV!
578
631
  */
579
- export type DriverClass<
580
- D extends Driver = ExternalDriver,
581
- S extends DriverStatic = DriverStatic
582
- > = Class<D, S, [] | [Partial<ServerArgs>] | [Partial<ServerArgs>, boolean]>;
632
+ export type DriverClass<D extends Driver = ExternalDriver> = Class<
633
+ D,
634
+ DriverStatic<D>,
635
+ [] | [Partial<ServerArgs>] | [Partial<ServerArgs>, boolean]
636
+ >;
583
637
 
638
+ export interface ExtraDriverOpts {
639
+ fastReset?: boolean;
640
+ skipUninstall?: boolean;
641
+ }
584
642
  /**
585
643
  * Options as passed into a driver constructor, which is just a union of {@linkcode ServerArgs} and {@linkcode Capabilities}.
586
644
  *
587
645
  * The combination happens within Appium prior to calling the constructor.
588
646
  */
589
- export type DriverOpts = ServerArgs & Capabilities;
647
+ export type DriverOpts<C extends Constraints = BaseDriverCapConstraints> = ServerArgs &
648
+ ExtraDriverOpts &
649
+ Partial<ConstraintsToCaps<C>>;
590
650
 
591
651
  export type DriverCommand<TArgs = any, TReturn = unknown> = (...args: TArgs[]) => Promise<TReturn>;
592
652
 
package/lib/index.ts CHANGED
@@ -1,20 +1,24 @@
1
- import type {Server as WSServer} from 'ws';
2
- import type {Socket} from 'net';
1
+ import type {Express} from 'express';
3
2
  import type {Server} from 'http';
3
+ import type {Socket} from 'net';
4
+ import type {Logger} from 'npmlog';
4
5
  import type {Class as _Class, ConditionalPick, MultidimensionalReadonlyArray} from 'type-fest';
6
+ import type {Server as WSServer} from 'ws';
5
7
  import {ServerArgs} from './config';
6
- import {Capabilities, W3CCapabilities} from './capabilities';
7
- import type {Express} from 'express';
8
- import {ExternalDriver} from './driver';
9
- import type {Logger} from 'npmlog';
10
8
 
11
- export * from './driver';
12
9
  export * from './action';
13
- export * from './plugin';
14
- export {AppiumW3CCapabilities} from './capabilities';
15
- export {AppiumConfig, NormalizedAppiumConfig} from './config';
16
10
  export * from './appium-config';
17
- export {ServerArgs, Capabilities, W3CCapabilities};
11
+ export * from './capabilities';
12
+ export * from './config';
13
+ export {BASE_DESIRED_CAP_CONSTRAINTS} from './constraints';
14
+ export type {BaseDriverCapConstraints} from './constraints';
15
+ export * from './driver';
16
+ export * from './plugin';
17
+
18
+ /**
19
+ * Utility type for a object with string-only props
20
+ */
21
+ export type StringRecord = Record<string, any>;
18
22
 
19
23
  /**
20
24
  * A log prefix for {@linkcode AppiumLogger}
@@ -63,15 +67,10 @@ export type AppiumServer = Omit<Server, 'close'> & AppiumServerExtension;
63
67
 
64
68
  export interface AppiumServerExtension {
65
69
  close(): Promise<void>;
66
- addWebSocketHandler(
67
- handlerPathname: string,
68
- handlerServer: WSServer
69
- ): Promise<void>;
70
+ addWebSocketHandler(handlerPathname: string, handlerServer: WSServer): Promise<void>;
70
71
  removeWebSocketHandler(handlerPathname: string): Promise<boolean>;
71
72
  removeAllWebSocketHandlers(): Promise<boolean>;
72
- getWebSocketHandlers(
73
- keysFilter: string | null | undefined
74
- ): Promise<Record<string, WSServer>>;
73
+ getWebSocketHandlers(keysFilter: string | null | undefined): Promise<Record<string, WSServer>>;
75
74
  webSocketsMapping: Record<string, WSServer>;
76
75
  }
77
76
 
@@ -83,47 +82,51 @@ export interface AppiumServerSocket extends Socket {
83
82
  * The definition of an extension method, which will be provided via Appium's API.
84
83
  *
85
84
  */
86
- export interface Method<T> {
85
+ export interface MethodDef<Ext> {
87
86
  /**
88
87
  * Name of the command.
89
88
  */
90
- command?: keyof ConditionalPick<Required<T>, DriverCommand>;
89
+ readonly command?: keyof ConditionalPick<Required<Ext>, DriverCommand>;
91
90
  /**
92
91
  * If true, this `Method` will never proxy.
93
92
  */
94
- neverProxy?: boolean;
93
+ readonly neverProxy?: boolean;
95
94
  /**
96
95
  * Specifies shape of payload
97
96
  */
98
- payloadParams?: PayloadParams;
97
+ readonly payloadParams?: PayloadParams;
99
98
  }
100
99
 
101
100
  /**
102
- * An instance method of a driver class, whose name may be referenced by {@linkcode Method.command}, and serves as an Appium command.
101
+ * An instance method of a driver class, whose name may be referenced by {@linkcode MethodDef.command}, and serves as an Appium command.
103
102
  *
104
103
  * Note that this signature differs from a `PluginCommand`.
105
104
  */
106
105
  export type DriverCommand<TArgs = any, TRetval = unknown> = (...args: TArgs[]) => Promise<TRetval>;
107
106
 
108
107
  /**
109
- * Defines the shape of a payload for a {@linkcode Method}.
108
+ * Defines the shape of a payload for a {@linkcode MethodDef}.
110
109
  */
111
110
  export interface PayloadParams {
112
111
  wrap?: string;
113
112
  unwrap?: string;
114
- required?: Readonly<string[]> | MultidimensionalReadonlyArray<string, 2>;
115
- optional?: Readonly<string[]> | MultidimensionalReadonlyArray<string, 2>;
113
+ required?: ReadonlyArray<string> | MultidimensionalReadonlyArray<string, 2>;
114
+ optional?: ReadonlyArray<string> | MultidimensionalReadonlyArray<string, 2>;
116
115
  validate?: (obj: any, protocol: string) => boolean | string | undefined;
117
116
  makeArgs?: (obj: any) => any;
118
117
  }
119
118
  /**
120
- * A mapping of URL paths to HTTP methods to {@linkcode Method}s.
121
- *
122
- * @todo Should use {@linkcode HTTPMethod} here
119
+ * A mapping of URL paths to HTTP methods to {@linkcode MethodDef}s.
123
120
  */
124
- export type MethodMap<Extension = ExternalDriver> = Record<
125
- string,
126
- Record<string, Method<Extension & ExternalDriver>>
121
+ export type MethodMap<Ext = any> = Readonly<
122
+ Record<
123
+ string,
124
+ {
125
+ GET?: MethodDef<Ext>;
126
+ POST?: MethodDef<Ext>;
127
+ DELETE?: MethodDef<Ext>;
128
+ }
129
+ >
127
130
  >;
128
131
 
129
132
  /**
@@ -164,8 +167,11 @@ export type ExtensionType = DriverType | PluginType;
164
167
  * @param httpServer - the node HTTP server that hosts the app
165
168
  * @param cliArgs - Arguments from config files, CLI, etc.
166
169
  */
167
- export type UpdateServerCallback = (expressApp: Express, httpServer: AppiumServer, cliArgs: ServerArgs) => Promise<void>;
168
-
170
+ export type UpdateServerCallback = (
171
+ expressApp: Express,
172
+ httpServer: AppiumServer,
173
+ cliArgs: Partial<ServerArgs>
174
+ ) => Promise<void>;
169
175
 
170
176
  /**
171
177
  * Possible HTTP methods, as stolen from `axios`.
@@ -173,14 +179,23 @@ export type UpdateServerCallback = (expressApp: Express, httpServer: AppiumServe
173
179
  * @see https://npm.im/axios
174
180
  */
175
181
  export type HTTPMethod =
176
- | 'get' | 'GET'
177
- | 'delete' | 'DELETE'
178
- | 'head' | 'HEAD'
179
- | 'options' | 'OPTIONS'
180
- | 'post' | 'POST'
181
- | 'put' | 'PUT'
182
- | 'patch' | 'PATCH'
183
- | 'purge' | 'PURGE'
184
- | 'link' | 'LINK'
185
- | 'unlink' | 'UNLINK';
186
-
182
+ | 'get'
183
+ | 'GET'
184
+ | 'delete'
185
+ | 'DELETE'
186
+ | 'head'
187
+ | 'HEAD'
188
+ | 'options'
189
+ | 'OPTIONS'
190
+ | 'post'
191
+ | 'POST'
192
+ | 'put'
193
+ | 'PUT'
194
+ | 'patch'
195
+ | 'PATCH'
196
+ | 'purge'
197
+ | 'PURGE'
198
+ | 'link'
199
+ | 'LINK'
200
+ | 'unlink'
201
+ | 'UNLINK';
package/lib/plugin.ts CHANGED
@@ -4,7 +4,7 @@ import {Driver, ExternalDriver} from './driver';
4
4
  /**
5
5
  * The interface describing the constructor and static properties of a Plugin.
6
6
  */
7
- export interface PluginStatic<T extends Plugin = Plugin> {
7
+ export interface PluginStatic<P extends Plugin> {
8
8
  /**
9
9
  * Allows a plugin to modify the Appium server instance.
10
10
  */
@@ -20,7 +20,7 @@ export interface PluginStatic<T extends Plugin = Plugin> {
20
20
  * }
21
21
  * }
22
22
  */
23
- newMethodMap?: MethodMap<T>;
23
+ newMethodMap?: MethodMap<P>;
24
24
  }
25
25
 
26
26
  /**
@@ -89,4 +89,8 @@ export type PluginCommand<TArgs = any> = (
89
89
  *
90
90
  * The third parameter is the possible constructor signatures for the plugin class.
91
91
  */
92
- export type PluginClass = Class<Plugin, PluginStatic, [string, Record<string, unknown>]>;
92
+ export type PluginClass<P extends Plugin = Plugin> = Class<
93
+ P,
94
+ PluginStatic<P>,
95
+ [string, Record<string, unknown>]
96
+ >;
package/package.json CHANGED
@@ -1,11 +1,16 @@
1
1
  {
2
2
  "name": "@appium/types",
3
- "version": "0.4.1",
3
+ "version": "0.6.0",
4
4
  "description": "Various type declarations used across Appium",
5
5
  "keywords": [
6
- "appium",
7
- "typescript",
8
- "types"
6
+ "automation",
7
+ "javascript",
8
+ "selenium",
9
+ "webdriver",
10
+ "ios",
11
+ "android",
12
+ "firefoxos",
13
+ "testing"
9
14
  ],
10
15
  "homepage": "https://appium.io",
11
16
  "bugs": {
@@ -18,33 +23,34 @@
18
23
  },
19
24
  "license": "Apache-2.0",
20
25
  "author": "https://github.com/appium",
21
- "types": "./build/index.d.ts",
26
+ "types": "./build/lib/index.d.ts",
22
27
  "files": [
23
28
  "build",
24
- "lib"
29
+ "lib",
30
+ "index.js"
25
31
  ],
26
32
  "scripts": {
27
33
  "build": "node ./scripts/generate-schema-types.js",
28
- "dev": "npm run build -- --watch",
29
- "fix": "npm run lint -- --fix",
30
- "lint": "eslint -c ../../.eslintrc --ignore-path ../../.eslintignore .",
31
- "prepare": "npm run build",
32
- "test:smoke": "echo 'No smoke test for this package'"
34
+ "clean": "git checkout -- ./types/lib/appium-config.ts || true",
35
+ "test:smoke": "node ./index.js"
33
36
  },
34
37
  "dependencies": {
35
- "@appium/schema": "^0.0.9",
36
- "@types/express": "4.17.13",
38
+ "@appium/schema": "^0.1.0",
39
+ "@types/express": "4.17.14",
37
40
  "@types/npmlog": "4.1.4",
38
41
  "@types/ws": "8.5.3",
39
- "@wdio/types": "7.24.0",
40
- "type-fest": "2.19.0"
42
+ "@wdio/types": "7.26.0",
43
+ "type-fest": "3.3.0"
41
44
  },
42
45
  "engines": {
43
- "node": ">=14",
46
+ "node": "^14.17.0 || ^16.13.0 || >=18.0.0",
44
47
  "npm": ">=8"
45
48
  },
46
49
  "publishConfig": {
47
50
  "access": "public"
48
51
  },
49
- "gitHead": "c26af8f85230ac65cbc19f08f763942f74b0eb0c"
52
+ "gitHead": "0823f0b60e40395cd1dc3b72cfa3c0092bc81302",
53
+ "typedoc": {
54
+ "entryPoint": "./lib/index.ts"
55
+ }
50
56
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../lib/action.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,OAAO;IACtB,qCAAqC,EAAE,MAAM,CAAC;CAC/C;AAED;;GAEG;AACH,oBAAY,WAAW,GAAG;IACxB,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,oBAAY,aAAa,GAAG;IAC1B,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,GAAG,GAAG,MAAM,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,oBAAY,WAAW,GAAG;IACxB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,GAAG,GAAG,MAAM,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AAW;IACnB,UAAU,WAAW;IACrB,KAAK,WAAW;IAChB,MAAM,WAAW;IACjB,WAAW,WAAW;IACtB,SAAS,WAAW;IACpB,YAAY,WAAW;IACvB,WAAW,WAAW;IACtB,QAAQ,WAAW;IACnB,QAAQ,WAAW;CACpB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"appium-config.d.ts","sourceRoot":"","sources":["../lib/appium-config.ts"],"names":[],"mappings":"AACA;;;;GAIG;AAEH;;GAEG;AACH,oBAAY,aAAa,GAAG,MAAM,CAAC;AACnC;;GAEG;AACH,oBAAY,eAAe,GAAG,OAAO,CAAC;AACtC;;GAEG;AACH,oBAAY,mBAAmB,GAAG,MAAM,EAAE,CAAC;AAC3C;;GAEG;AACH,oBAAY,cAAc,GAAG,MAAM,CAAC;AACpC;;GAEG;AACH,oBAAY,qBAAqB,GAAG,MAAM,CAAC;AAC3C;;GAEG;AACH,oBAAY,kBAAkB,GAAG,MAAM,CAAC;AACxC;;GAEG;AACH,oBAAY,qBAAqB,GAAG,OAAO,CAAC;AAC5C;;GAEG;AACH,oBAAY,kBAAkB,GAAG,MAAM,EAAE,CAAC;AAC1C;;GAEG;AACH,oBAAY,sBAAsB,GAAG,MAAM,CAAC;AAC5C;;GAEG;AACH,oBAAY,mBAAmB,GAAG,OAAO,CAAC;AAC1C;;GAEG;AACH,oBAAY,SAAS,GAAG,MAAM,CAAC;AAC/B;;GAEG;AACH,oBAAY,gBAAgB,GAAG,MAAM,EAAE,CAAC;AACxC;;GAEG;AACH,oBAAY,cAAc,GACtB,MAAM,GACN,YAAY,GACZ,WAAW,GACX,WAAW,GACX,YAAY,GACZ,MAAM,GACN,YAAY,GACZ,WAAW,GACX,WAAW,GACX,YAAY,GACZ,OAAO,GACP,aAAa,GACb,YAAY,GACZ,YAAY,GACZ,aAAa,GACb,OAAO,GACP,aAAa,GACb,YAAY,GACZ,YAAY,GACZ,aAAa,CAAC;AAClB;;GAEG;AACH,oBAAY,iBAAiB,GAAG,OAAO,CA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