appium 2.0.0-beta.4 → 2.0.0-beta.40

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 (151) hide show
  1. package/README.md +10 -11
  2. package/build/lib/appium.d.ts +204 -0
  3. package/build/lib/appium.d.ts.map +1 -0
  4. package/build/lib/appium.js +257 -131
  5. package/build/lib/cli/args.d.ts +20 -0
  6. package/build/lib/cli/args.d.ts.map +1 -0
  7. package/build/lib/cli/args.js +96 -282
  8. package/build/lib/cli/driver-command.d.ts +36 -0
  9. package/build/lib/cli/driver-command.d.ts.map +1 -0
  10. package/build/lib/cli/driver-command.js +25 -18
  11. package/build/lib/cli/extension-command.d.ts +372 -0
  12. package/build/lib/cli/extension-command.d.ts.map +1 -0
  13. package/build/lib/cli/extension-command.js +286 -156
  14. package/build/lib/cli/extension.d.ts +18 -0
  15. package/build/lib/cli/extension.d.ts.map +1 -0
  16. package/build/lib/cli/extension.js +30 -17
  17. package/build/lib/cli/parser.d.ts +80 -0
  18. package/build/lib/cli/parser.d.ts.map +1 -0
  19. package/build/lib/cli/parser.js +152 -95
  20. package/build/lib/cli/plugin-command.d.ts +33 -0
  21. package/build/lib/cli/plugin-command.d.ts.map +1 -0
  22. package/build/lib/cli/plugin-command.js +24 -19
  23. package/build/lib/cli/utils.d.ts +29 -0
  24. package/build/lib/cli/utils.d.ts.map +1 -0
  25. package/build/lib/cli/utils.js +27 -3
  26. package/build/lib/config-file.d.ts +100 -0
  27. package/build/lib/config-file.d.ts.map +1 -0
  28. package/build/lib/config-file.js +136 -0
  29. package/build/lib/config.d.ts +41 -0
  30. package/build/lib/config.d.ts.map +1 -0
  31. package/build/lib/config.js +92 -67
  32. package/build/lib/constants.d.ts +48 -0
  33. package/build/lib/constants.d.ts.map +1 -0
  34. package/build/lib/constants.js +60 -0
  35. package/build/lib/extension/driver-config.d.ts +81 -0
  36. package/build/lib/extension/driver-config.d.ts.map +1 -0
  37. package/build/lib/extension/driver-config.js +177 -0
  38. package/build/lib/extension/extension-config.d.ts +242 -0
  39. package/build/lib/extension/extension-config.d.ts.map +1 -0
  40. package/build/lib/extension/extension-config.js +436 -0
  41. package/build/lib/extension/index.d.ts +48 -0
  42. package/build/lib/extension/index.d.ts.map +1 -0
  43. package/build/lib/extension/index.js +74 -0
  44. package/build/lib/extension/manifest.d.ts +174 -0
  45. package/build/lib/extension/manifest.d.ts.map +1 -0
  46. package/build/lib/extension/manifest.js +256 -0
  47. package/build/lib/extension/package-changed.d.ts +11 -0
  48. package/build/lib/extension/package-changed.d.ts.map +1 -0
  49. package/build/lib/extension/package-changed.js +68 -0
  50. package/build/lib/extension/plugin-config.d.ts +57 -0
  51. package/build/lib/extension/plugin-config.d.ts.map +1 -0
  52. package/build/lib/extension/plugin-config.js +78 -0
  53. package/build/lib/grid-register.d.ts +10 -0
  54. package/build/lib/grid-register.d.ts.map +1 -0
  55. package/build/lib/grid-register.js +21 -25
  56. package/build/lib/logger.d.ts +3 -0
  57. package/build/lib/logger.d.ts.map +1 -0
  58. package/build/lib/logger.js +4 -6
  59. package/build/lib/logsink.d.ts +4 -0
  60. package/build/lib/logsink.d.ts.map +1 -0
  61. package/build/lib/logsink.js +14 -17
  62. package/build/lib/main.d.ts +55 -0
  63. package/build/lib/main.d.ts.map +1 -0
  64. package/build/lib/main.js +189 -90
  65. package/build/lib/schema/arg-spec.d.ts +143 -0
  66. package/build/lib/schema/arg-spec.d.ts.map +1 -0
  67. package/build/lib/schema/arg-spec.js +119 -0
  68. package/build/lib/schema/cli-args.d.ts +19 -0
  69. package/build/lib/schema/cli-args.d.ts.map +1 -0
  70. package/build/lib/schema/cli-args.js +180 -0
  71. package/build/lib/schema/cli-transformers.d.ts +5 -0
  72. package/build/lib/schema/cli-transformers.d.ts.map +1 -0
  73. package/build/lib/schema/cli-transformers.js +74 -0
  74. package/build/lib/schema/index.d.ts +3 -0
  75. package/build/lib/schema/index.d.ts.map +1 -0
  76. package/build/lib/schema/index.js +34 -0
  77. package/build/lib/schema/keywords.d.ts +24 -0
  78. package/build/lib/schema/keywords.d.ts.map +1 -0
  79. package/build/lib/schema/keywords.js +70 -0
  80. package/build/lib/schema/schema.d.ts +259 -0
  81. package/build/lib/schema/schema.d.ts.map +1 -0
  82. package/build/lib/schema/schema.js +452 -0
  83. package/build/lib/utils.d.ts +66 -0
  84. package/build/lib/utils.d.ts.map +1 -0
  85. package/build/lib/utils.js +35 -139
  86. package/build/tsconfig.tsbuildinfo +1 -0
  87. package/build/types/appium-manifest.d.ts +59 -0
  88. package/build/types/appium-manifest.d.ts.map +1 -0
  89. package/build/types/cli.d.ts +112 -0
  90. package/build/types/cli.d.ts.map +1 -0
  91. package/build/types/extension-manifest.d.ts +55 -0
  92. package/build/types/extension-manifest.d.ts.map +1 -0
  93. package/build/types/index.d.ts +16 -0
  94. package/build/types/index.d.ts.map +1 -0
  95. package/driver.d.ts +1 -0
  96. package/driver.js +14 -0
  97. package/index.js +11 -0
  98. package/lib/appium.js +517 -186
  99. package/lib/cli/args.js +269 -422
  100. package/lib/cli/driver-command.js +58 -23
  101. package/lib/cli/extension-command.js +612 -260
  102. package/lib/cli/extension.js +34 -16
  103. package/lib/cli/parser.js +241 -83
  104. package/lib/cli/plugin-command.js +48 -20
  105. package/lib/cli/utils.js +24 -10
  106. package/lib/config-file.js +219 -0
  107. package/lib/config.js +210 -91
  108. package/lib/constants.js +69 -0
  109. package/lib/extension/driver-config.js +249 -0
  110. package/lib/extension/extension-config.js +679 -0
  111. package/lib/extension/index.js +116 -0
  112. package/lib/extension/manifest.js +475 -0
  113. package/lib/extension/package-changed.js +64 -0
  114. package/lib/extension/plugin-config.js +113 -0
  115. package/lib/grid-register.js +49 -35
  116. package/lib/logger.js +1 -2
  117. package/lib/logsink.js +38 -33
  118. package/lib/main.js +303 -100
  119. package/lib/schema/arg-spec.js +229 -0
  120. package/lib/schema/cli-args.js +238 -0
  121. package/lib/schema/cli-transformers.js +115 -0
  122. package/lib/schema/index.js +2 -0
  123. package/lib/schema/keywords.js +136 -0
  124. package/lib/schema/schema.js +717 -0
  125. package/lib/utils.js +121 -140
  126. package/package.json +75 -85
  127. package/plugin.d.ts +1 -0
  128. package/plugin.js +13 -0
  129. package/scripts/autoinstall-extensions.js +177 -0
  130. package/support.d.ts +1 -0
  131. package/support.js +13 -0
  132. package/types/appium-manifest.ts +73 -0
  133. package/types/cli.ts +146 -0
  134. package/types/extension-manifest.ts +64 -0
  135. package/types/index.ts +21 -0
  136. package/CHANGELOG.md +0 -3515
  137. package/bin/ios-webkit-debug-proxy-launcher.js +0 -71
  138. package/build/lib/cli/npm.js +0 -206
  139. package/build/lib/cli/parser-helpers.js +0 -82
  140. package/build/lib/driver-config.js +0 -77
  141. package/build/lib/drivers.js +0 -96
  142. package/build/lib/extension-config.js +0 -253
  143. package/build/lib/plugin-config.js +0 -59
  144. package/build/lib/plugins.js +0 -14
  145. package/lib/cli/npm.js +0 -183
  146. package/lib/cli/parser-helpers.js +0 -79
  147. package/lib/driver-config.js +0 -46
  148. package/lib/drivers.js +0 -81
  149. package/lib/extension-config.js +0 -209
  150. package/lib/plugin-config.js +0 -34
  151. package/lib/plugins.js +0 -10
@@ -0,0 +1,259 @@
1
+ /**
2
+ * Key/value pairs go in... but they don't come out.
3
+ *
4
+ * @template K,V
5
+ * @extends {Map<K,V>}
6
+ */
7
+ export class RoachHotelMap<K, V> extends Map<K, V> {
8
+ constructor();
9
+ constructor(entries?: readonly (readonly [K, V])[] | null | undefined);
10
+ constructor();
11
+ constructor(iterable?: Iterable<readonly [K, V]> | null | undefined);
12
+ }
13
+ /**
14
+ * Extensions that an extension schema file can have.
15
+ */
16
+ export const ALLOWED_SCHEMA_EXTENSIONS: Set<string>;
17
+ /**
18
+ * Thrown when the {@link AppiumSchema} instance has not yet been finalized, but
19
+ * the method called requires it.
20
+ */
21
+ export class SchemaFinalizationError extends Error {
22
+ constructor();
23
+ /**
24
+ * @type {Readonly<string>}
25
+ */
26
+ code: Readonly<string>;
27
+ }
28
+ /**
29
+ * Thrown when a "unique" schema ID conflicts with an existing schema ID.
30
+ *
31
+ * This is likely going to be caused by attempting to register the same schema twice.
32
+ */
33
+ export class SchemaNameConflictError extends Error {
34
+ /**
35
+ * @param {ExtensionType} extType
36
+ * @param {string} extName
37
+ */
38
+ constructor(extType: ExtensionType, extName: string);
39
+ /**
40
+ * @type {Readonly<string>}
41
+ */
42
+ code: Readonly<string>;
43
+ /**
44
+ * @type {Readonly<{extType: ExtensionType, extName: string}>}
45
+ */
46
+ data: Readonly<{
47
+ extType: ExtensionType;
48
+ extName: string;
49
+ }>;
50
+ }
51
+ /**
52
+ * Thrown when a schema ID was expected, but it doesn't exist on the {@link Ajv} instance.
53
+ */
54
+ export class SchemaUnknownSchemaError extends ReferenceError {
55
+ /**
56
+ * @param {string} schemaId
57
+ */
58
+ constructor(schemaId: string);
59
+ /**
60
+ * @type {Readonly<string>}
61
+ */
62
+ code: Readonly<string>;
63
+ /**
64
+ * @type {Readonly<{schemaId: string}>}
65
+ */
66
+ data: Readonly<{
67
+ schemaId: string;
68
+ }>;
69
+ }
70
+ /**
71
+ * Thrown when a schema is provided, but it's of an unsupported type.
72
+ *
73
+ * "Valid" schemas which are unsupported include boolean schemas and async schemas
74
+ * (having a `true` `$async` property).
75
+ */
76
+ export class SchemaUnsupportedSchemaError extends TypeError {
77
+ /**
78
+ * @param {any} schema
79
+ * @param {ExtensionType} extType
80
+ * @param {string} extName
81
+ */
82
+ constructor(schema: any, extType: ExtensionType, extName: string);
83
+ /**
84
+ * @type {Readonly<string>}
85
+ */
86
+ code: Readonly<string>;
87
+ /**
88
+ * @type {Readonly<{schema: any, extType: ExtensionType, extName: string}>}
89
+ */
90
+ data: Readonly<{
91
+ schema: any;
92
+ extType: ExtensionType;
93
+ extName: string;
94
+ }>;
95
+ }
96
+ /**
97
+ * Registers a schema from an extension.
98
+ *
99
+ * This is "fail-fast" in that the schema will immediately be validated against JSON schema draft-07 _or_ whatever the value of the schema's `$schema` prop is.
100
+ *
101
+ * Does _not_ add the schema to the `ajv` instance (this is done by {@link AppiumSchema.finalize}).
102
+ * @param {ExtensionType} extType - Extension type
103
+ * @param {string} extName - Unique extension name for `type`
104
+ * @param {SchemaObject} schema - Schema object
105
+ * @throws {SchemaNameConflictError} If the schema is an invalid
106
+ * @returns {void}
107
+ */
108
+ export function registerSchema(extType: ExtensionType, extName: string, schema: SchemaObject): void;
109
+ export function getAllArgSpecs(): RoachHotelMap<string, ArgSpec<any>>;
110
+ /**
111
+ * Returns a {@link ArgSpec} for the given argument name.
112
+ * @param {string} name - CLI argument name
113
+ * @param {ExtensionType} [extType] - Extension type
114
+ * @param {string} [extName] - Extension name
115
+ * @returns {ArgSpec|undefined} ArgSpec or `undefined` if not found
116
+ */
117
+ export function getArgSpec(name: string, extType?: import("../../../types/build").ExtensionType | undefined, extName?: string | undefined): ArgSpec<any> | undefined;
118
+ /**
119
+ * Returns `true` if the instance knows about an argument by the given `name`.
120
+ * @param {string} name - CLI argument name
121
+ * @param {ExtensionType} [extType] - Extension type
122
+ * @param {string} [extName] - Extension name
123
+ * @returns {boolean} `true` if such an {@link ArgSpec} exists
124
+ */
125
+ export function hasArgSpec(name: string, extType?: import("../../../types/build").ExtensionType | undefined, extName?: string | undefined): boolean;
126
+ /**
127
+ * Return `true` if {@link AppiumSchema.finalize finalize} has been called
128
+ * successfully and {@link AppiumSchema.reset reset} has not been called since.
129
+ * @returns {boolean} If finalized
130
+ */
131
+ export function isFinalized(): boolean;
132
+ /**
133
+ * Call this when no more schemas will be registered.
134
+ *
135
+ * This does three things:
136
+ * 1. It combines all schemas from extensions into the Appium config schema,
137
+ * then adds the result to the `Ajv` instance.
138
+ * 2. It adds schemas for _each_ argument/property for validation purposes.
139
+ * The CLI uses these schemas to validate specific arguments.
140
+ * 3. The schemas are validated against JSON schema draft-07 (which is the
141
+ * only one supported at this time)
142
+ *
143
+ * Any method in this instance that needs to interact with the `Ajv` instance
144
+ * will throw if this method has not been called.
145
+ *
146
+ * If the instance has already been finalized, this is a no-op.
147
+ * @public
148
+ * @throws {Error} If the schema is not valid
149
+ * @returns {Readonly<Record<string,StrictSchemaObject>>} Record of schema IDs to full schema objects
150
+ */
151
+ export function finalizeSchema(): Readonly<Record<string, StrictSchemaObject>>;
152
+ /**
153
+ * Resets this instance to its original state.
154
+ *
155
+ * - Removes all added schemas from the `Ajv` instance
156
+ * - Resets the map of {@link ArgSpec ArgSpecs}
157
+ * - Resets the map of registered schemas
158
+ * - Sets the {@link AppiumSchema._finalized _finalized} flag to `false`
159
+ *
160
+ * If you need to call {@link AppiumSchema.finalize} again, you'll want to call this first.
161
+ * @returns {void}
162
+ */
163
+ export function resetSchema(): void;
164
+ /**
165
+ * Given an object, validates it against the Appium config schema.
166
+ * If errors occur, the returned array will be non-empty.
167
+ * @param {any} value - The value (hopefully an object) to validate against the schema
168
+ * @param {string} [ref] - Schema ID or ref.
169
+ * @public
170
+ * @returns {import('ajv').ErrorObject[]} Array of errors, if any.
171
+ */
172
+ export function validate(value: any, ref?: string | undefined): import('ajv').ErrorObject[];
173
+ /**
174
+ * Retrieves the schema itself
175
+ * @public
176
+ * @param {string} [ref] - Schema ID
177
+ * @throws If the schema has not yet been finalized
178
+ * @returns {SchemaObject}
179
+ */
180
+ export function getSchema(ref?: string | undefined): SchemaObject;
181
+ /**
182
+ * Flatten schema into an array of `SchemaObject`s and associated
183
+ * {@link ArgSpec ArgSpecs}.
184
+ *
185
+ * Converts nested extension schemas to keys based on the extension type and
186
+ * name. Used when translating to `argparse` options or getting the list of
187
+ * default values (see {@link AppiumSchema.getDefaults}) for CLI or otherwise.
188
+ *
189
+ * The return value is an intermediate reprsentation used by `cli-args`
190
+ * module's `toParserArgs`, which converts the finalized schema to parameters
191
+ * used by `argparse`.
192
+ * @throws If {@link AppiumSchema.finalize} has not been called yet.
193
+ * @returns {FlattenedSchema}
194
+ */
195
+ export function flattenSchema(): FlattenedSchema;
196
+ /**
197
+ * Returns a `Record` of argument "dest" strings to default values.
198
+ *
199
+ * The "dest" string is the property name in object returned by
200
+ * `argparse.ArgumentParser['parse_args']`.
201
+ * @template {boolean|undefined} Flattened
202
+ * @param {Flattened} [flatten=true] - If `true`, flattens the returned object
203
+ * using "keypath"-style keys of the format `<extType>.<extName>.<argName>`.
204
+ * Otherwise, returns a nested object using `extType` and `extName` as
205
+ * properties. Base arguments (server arguments) are always at the top level.
206
+ * @returns {DefaultValues<Flattened>}
207
+ */
208
+ export function getDefaultsForSchema<Flattened extends boolean | undefined>(flatten?: Flattened | undefined): DefaultValues<Flattened>;
209
+ /**
210
+ * Returns a flattened Record of defaults for a specific extension. Keys will
211
+ * be of format `<argName>`.
212
+ * @param {ExtensionType} extType - Extension type
213
+ * @param {string} extName - Extension name
214
+ * @returns {Record<string,ArgSpecDefaultValue>}
215
+ */
216
+ export function getDefaultsForExtension(extType: ExtensionType, extName: string): Record<string, ArgSpecDefaultValue>;
217
+ /**
218
+ * Returns `true` if `filename`'s file extension is allowed (in {@link ALLOWED_SCHEMA_EXTENSIONS}).
219
+ * @param {string} filename
220
+ * @returns {boolean}
221
+ */
222
+ export function isAllowedSchemaFileExtension(filename: string): boolean;
223
+ /**
224
+ * Appium only supports schemas that are plain objects; not arrays.
225
+ */
226
+ export type SchemaObject = import("ajv").SchemaObject & {
227
+ [key: number]: never;
228
+ };
229
+ export type ExtensionType = import('../extension/manifest').ExtensionType;
230
+ /**
231
+ * An object having property `additionalProperties: false`
232
+ */
233
+ export type StrictProp = {
234
+ additionalProperties: false;
235
+ };
236
+ /**
237
+ * A {@link SchemaObject } with `additionalProperties: false`
238
+ */
239
+ export type StrictSchemaObject = SchemaObject & StrictProp;
240
+ /**
241
+ * A list of schemas associated with properties and their corresponding {@link ArgSpec } objects.
242
+ *
243
+ * Intermediate data structure used when converting the entire schema down to CLI arguments.
244
+ */
245
+ export type FlattenedSchema = {
246
+ schema: SchemaObject;
247
+ argSpec: ArgSpec<any>;
248
+ }[];
249
+ export type ArgSpecDefaultValue = ArgSpec<any>['defaultValue'];
250
+ /**
251
+ * e.g. `{driver: {foo: 'bar'}}` where `foo` is the arg name and `bar` is the default value.
252
+ */
253
+ export type NestedArgSpecDefaultValue = Record<string, Record<string, ArgSpecDefaultValue>>;
254
+ /**
255
+ * Helper type for the return value of {@link AppiumSchema.getDefaults }
256
+ */
257
+ export type DefaultValues<Flattened extends boolean | undefined> = Record<string, Flattened extends true ? ArgSpecDefaultValue : ArgSpecDefaultValue | NestedArgSpecDefaultValue>;
258
+ import { ArgSpec } from "./arg-spec";
259
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../lib/schema/schema.js"],"names":[],"mappings":"AASA;;;;;GAKG;AACH;IAqCY,cAA2B;IAAA,uEAEV;IAsHL,cAA2B;IAAA,qEACP;CAvI3C;AAED;;GAEG;AACH,oDAA2E;AAuf3E;;;GAGG;AACH;IAME,cAEC;IAPD;;OAEG;IACH,MAFU,SAAS,MAAM,CAAC,CAEa;CAKxC;AAED;;;;GAIG;AACH;IAWE;;;OAGG;IACH,qBAHW,aAAa,WACb,MAAM,EAKhB;IAjBD;;OAEG;IACH,MAFU,SAAS,MAAM,CAAC,CAEc;IAExC;;OAEG;IACH,MAFU,SAAS;QAAC,OAAO,EAAE,aAAa,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAC,CAAC,CAExD;CAUN;AAED;;GAEG;AACH;IAWE;;OAEG;IACH,sBAFW,MAAM,EAKhB;IAhBD;;OAEG;IACH,MAFU,SAAS,MAAM,CAAC,CAEe;IAEzC;;OAEG;IACH,MAFU,SAAS;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAC,CAAC,CAEjC;CASN;AAED;;;;;GAKG;AACH;IAWE;;;;OAIG;IACH,oBAJW,GAAG,WACH,aAAa,WACb,MAAM,EAyBhB;IAtCD;;OAEG;IACH,MAFU,SAAS,MAAM,CAAC,CAEmB;IAE7C;;OAEG;IACH,MAFU,SAAS;QAAC,MAAM,EAAE,GAAG,CAAC;QAAC,OAAO,EAAE,aAAa,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAC,CAAC,CAErE;CA+BN;AAvWC;;;;;;;;;;;GAWG;AACH,wCANW,aAAa,WACb,MAAM,UACN,YAAY,GAEV,IAAI,CAmBhB;AAzKD,sEAEC;AAyKD;;;;;;GAMG;AACH,iCALW,MAAM,qGAGJ,eAAQ,SAAS,CAI7B;AAED;;;;;;GAMG;AACH,iCALW,MAAM,qGAGJ,OAAO,CAInB;AAxMD;;;;GAIG;AACH,+BAFa,OAAO,CAInB;AAMD;;;;;;;;;;;;;;;;;;GAkBG;AACH,kCAFa,SAAS,OAAO,MAAM,EAAC,kBAAkB,CAAC,CAAC,CAsEvD;AAuBD;;;;;;;;;;GAUG;AACH,+BAFa,IAAI,CAehB;AA2ND;;;;;;;GAOG;AACH,gCALW,GAAG,6BAGD,OAAO,KAAK,EAAE,WAAW,EAAE,CAKvC;AAxCD;;;;;;GAMG;AACH,qDAFa,YAAY,CAIxB;AA9ED;;;;;;;;;;;;;GAaG;AACH,iDAqDC;AArID;;;;;;;;;;;GAWG;AACH,uIA8BC;AAED;;;;;;GAMG;AACH,iDAJW,aAAa,WACb,MAAM,GACJ,OAAO,MAAM,EAAC,mBAAmB,CAAC,CAe9C;AAiHD;;;;GAIG;AACH,uDAHW,MAAM,GACJ,OAAO,CAInB;;;;;;;4BAoJU,OAAO,uBAAuB,EAAE,aAAa;;;;;0BAM5C,KAAK;;;;;iCAKN,YAAY,GAAG,UAAU;;;;;;8BAOxB;IAAC,MAAM,EAAE,YAAY,CAAC;IAAC,OAAO,eAAS;CAAC,EAAE;kCAI3C,aAAQ,cAAc,CAAC;;;;wCAKvB,OAAO,MAAM,EAAC,OAAO,MAAM,EAAC,mBAAmB,CAAC,CAAC;;;;mEAMjD,OAAO,MAAM,EAAC,SAAS,SAAS,IAAI,GAAG,mBAAmB,GAAG,mBAAmB,GAAG,yBAAyB,CAAC"}