appium 2.0.0-beta.26 → 2.0.0-beta.29

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 (118) hide show
  1. package/build/lib/appium.d.ts +215 -0
  2. package/build/lib/appium.d.ts.map +1 -0
  3. package/build/lib/appium.js +62 -54
  4. package/build/lib/cli/args.d.ts +20 -0
  5. package/build/lib/cli/args.d.ts.map +1 -0
  6. package/build/lib/cli/args.js +1 -1
  7. package/build/lib/cli/driver-command.d.ts +36 -0
  8. package/build/lib/cli/driver-command.d.ts.map +1 -0
  9. package/build/lib/cli/driver-command.js +8 -7
  10. package/build/lib/cli/extension-command.d.ts +345 -0
  11. package/build/lib/cli/extension-command.d.ts.map +1 -0
  12. package/build/lib/cli/extension-command.js +52 -38
  13. package/build/lib/cli/extension.d.ts +14 -0
  14. package/build/lib/cli/extension.d.ts.map +1 -0
  15. package/build/lib/cli/extension.js +7 -2
  16. package/build/lib/cli/parser.d.ts +79 -0
  17. package/build/lib/cli/parser.d.ts.map +1 -0
  18. package/build/lib/cli/parser.js +1 -1
  19. package/build/lib/cli/plugin-command.d.ts +39 -0
  20. package/build/lib/cli/plugin-command.d.ts.map +1 -0
  21. package/build/lib/cli/plugin-command.js +6 -7
  22. package/build/lib/cli/utils.d.ts +29 -0
  23. package/build/lib/cli/utils.d.ts.map +1 -0
  24. package/build/lib/cli/utils.js +1 -1
  25. package/build/lib/config-file.d.ts +100 -0
  26. package/build/lib/config-file.d.ts.map +1 -0
  27. package/build/lib/config-file.js +1 -1
  28. package/build/lib/config.d.ts +40 -0
  29. package/build/lib/config.d.ts.map +1 -0
  30. package/build/lib/config.js +2 -2
  31. package/build/lib/constants.d.ts +48 -0
  32. package/build/lib/constants.d.ts.map +1 -0
  33. package/build/lib/constants.js +1 -1
  34. package/build/lib/extension/driver-config.d.ts +84 -0
  35. package/build/lib/extension/driver-config.d.ts.map +1 -0
  36. package/build/lib/extension/driver-config.js +1 -1
  37. package/build/lib/extension/extension-config.d.ts +170 -0
  38. package/build/lib/extension/extension-config.d.ts.map +1 -0
  39. package/build/lib/extension/extension-config.js +2 -2
  40. package/build/lib/extension/index.d.ts +39 -0
  41. package/build/lib/extension/index.d.ts.map +1 -0
  42. package/build/lib/extension/index.js +1 -1
  43. package/build/lib/extension/manifest.d.ts +174 -0
  44. package/build/lib/extension/manifest.d.ts.map +1 -0
  45. package/build/lib/extension/manifest.js +1 -1
  46. package/build/lib/extension/package-changed.d.ts +11 -0
  47. package/build/lib/extension/package-changed.d.ts.map +1 -0
  48. package/build/lib/extension/package-changed.js +1 -1
  49. package/build/lib/extension/plugin-config.d.ts +62 -0
  50. package/build/lib/extension/plugin-config.d.ts.map +1 -0
  51. package/build/lib/extension/plugin-config.js +1 -1
  52. package/build/lib/grid-register.d.ts +10 -0
  53. package/build/lib/grid-register.d.ts.map +1 -0
  54. package/build/lib/logger.d.ts +3 -0
  55. package/build/lib/logger.d.ts.map +1 -0
  56. package/build/lib/logsink.d.ts +4 -0
  57. package/build/lib/logsink.d.ts.map +1 -0
  58. package/build/lib/logsink.js +1 -1
  59. package/build/lib/main.d.ts +51 -0
  60. package/build/lib/main.d.ts.map +1 -0
  61. package/build/lib/main.js +1 -1
  62. package/build/lib/schema/arg-spec.d.ts +143 -0
  63. package/build/lib/schema/arg-spec.d.ts.map +1 -0
  64. package/build/lib/schema/arg-spec.js +1 -1
  65. package/build/lib/schema/cli-args.d.ts +19 -0
  66. package/build/lib/schema/cli-args.d.ts.map +1 -0
  67. package/build/lib/schema/cli-args.js +1 -1
  68. package/build/lib/schema/cli-transformers.d.ts +5 -0
  69. package/build/lib/schema/cli-transformers.d.ts.map +1 -0
  70. package/build/lib/schema/cli-transformers.js +1 -1
  71. package/build/lib/schema/index.d.ts +3 -0
  72. package/build/lib/schema/index.d.ts.map +1 -0
  73. package/build/lib/schema/keywords.d.ts +24 -0
  74. package/build/lib/schema/keywords.d.ts.map +1 -0
  75. package/build/lib/schema/keywords.js +1 -1
  76. package/build/lib/schema/schema.d.ts +259 -0
  77. package/build/lib/schema/schema.d.ts.map +1 -0
  78. package/build/lib/schema/schema.js +3 -3
  79. package/build/lib/utils.d.ts +66 -0
  80. package/build/lib/utils.d.ts.map +1 -0
  81. package/build/lib/utils.js +6 -4
  82. package/build/tsconfig.tsbuildinfo +1 -0
  83. package/lib/appium.js +163 -81
  84. package/lib/cli/args.js +1 -2
  85. package/lib/cli/driver-command.js +11 -8
  86. package/lib/cli/extension-command.js +129 -80
  87. package/lib/cli/extension.js +13 -3
  88. package/lib/cli/parser.js +1 -2
  89. package/lib/cli/plugin-command.js +16 -6
  90. package/lib/cli/utils.js +1 -1
  91. package/lib/config-file.js +3 -4
  92. package/lib/config.js +12 -8
  93. package/lib/constants.js +0 -1
  94. package/lib/extension/driver-config.js +31 -12
  95. package/lib/extension/extension-config.js +21 -22
  96. package/lib/extension/index.js +1 -2
  97. package/lib/extension/manifest.js +23 -127
  98. package/lib/extension/package-changed.js +0 -1
  99. package/lib/extension/plugin-config.js +9 -7
  100. package/lib/logsink.js +4 -0
  101. package/lib/main.js +9 -10
  102. package/lib/schema/arg-spec.js +10 -6
  103. package/lib/schema/cli-args.js +0 -1
  104. package/lib/schema/cli-transformers.js +0 -1
  105. package/lib/schema/keywords.js +0 -1
  106. package/lib/schema/schema.js +2 -3
  107. package/lib/utils.js +49 -16
  108. package/package.json +12 -14
  109. package/types/appium-manifest.d.ts +61 -0
  110. package/types/cli.d.ts +134 -0
  111. package/types/extension.d.ts +56 -0
  112. package/types/external-manifest.d.ts +58 -0
  113. package/types/index.d.ts +7 -0
  114. package/build/lib/appium-config.schema.json +0 -278
  115. package/build/lib/schema/appium-config-schema.js +0 -251
  116. package/lib/schema/appium-config-schema.js +0 -287
  117. package/types/appium-config.d.ts +0 -197
  118. package/types/types.d.ts +0 -245
@@ -1,4 +1,3 @@
1
- // @ts-check
2
1
 
3
2
  import _ from 'lodash';
4
3
  import { DRIVER_TYPE } from '../constants';
@@ -80,7 +79,7 @@ export class DriverConfig extends ExtensionConfig {
80
79
  }
81
80
 
82
81
  /**
83
- * @param {ManifestDriverData} extData
82
+ * @param {ExtManifest<DriverType>} extData
84
83
  * @returns {import('./extension-config').Problem[]}
85
84
  */
86
85
  getConfigProblems (extData) {
@@ -126,7 +125,7 @@ export class DriverConfig extends ExtensionConfig {
126
125
 
127
126
  /**
128
127
  * @param {ExtName<DriverType>} driverName
129
- * @param {ManifestDriverData} extData
128
+ * @param {ExtManifest<DriverType>} extData
130
129
  * @returns {string}
131
130
  */
132
131
  extensionDesc (driverName, {version, automationName}) {
@@ -135,8 +134,8 @@ export class DriverConfig extends ExtensionConfig {
135
134
 
136
135
  /**
137
136
  * Given capabilities, find a matching driver within the config. Load its class and return it along with version and driver name.
138
- * @param { { automationName: string, platformName: string } } caps
139
- * @returns { { driver: import('./manifest').DriverClass, version: string, driverName: string } }
137
+ * @param {Capabilities} caps
138
+ * @returns {MatchedDriver}
140
139
  */
141
140
  findMatchingDriver ({automationName, platformName}) {
142
141
  if (!_.isString(platformName)) {
@@ -177,7 +176,7 @@ export class DriverConfig extends ExtensionConfig {
177
176
  * Given an automation name and platform name, find a suitable driver and return its extension data.
178
177
  * @param {string} matchAutomationName
179
178
  * @param {string} matchPlatformName
180
- * @returns {ManifestDriverData & { driverName: string } }
179
+ * @returns {ExtMetadata<DriverType> & import('../../types/appium-manifest').InternalMetadata & import('../../types/external-manifest').CommonMetadata}
181
180
  */
182
181
  _getDriverBySupport (matchAutomationName, matchPlatformName) {
183
182
  const drivers = this.installedExtensions;
@@ -211,20 +210,40 @@ export class DriverConfig extends ExtensionConfig {
211
210
  */
212
211
 
213
212
  /**
214
- * @typedef {import('./manifest').ExternalData<DriverType>} ExternalDriverData
215
- * @typedef {import('./manifest').ManifestDriverData} ManifestDriverData
216
- * @typedef {import('./manifest').ManifestData} ManifestData
217
- * @typedef {import('./manifest').DriverType} DriverType
213
+ * @template T
214
+ * @typedef {import('../../types').ExtMetadata<T>} ExtMetadata
215
+ */
216
+
217
+ /**
218
+ * @template T
219
+ * @typedef {import('../../types').ExtManifest<T>} ExtManifest
220
+ */
221
+
222
+ /**
223
+ * @typedef {import('../../types').ManifestData} ManifestData
224
+ * @typedef {import('../../types').DriverType} DriverType
218
225
  * @typedef {import('./manifest').Manifest} Manifest
219
226
  */
220
227
 
221
228
  /**
222
229
  * @template T
223
- * @typedef {import('./extension-config').ExtRecord<T>} ExtRecord
230
+ * @typedef {import('../../types').ExtRecord<T>} ExtRecord
224
231
  */
225
232
 
226
233
  /**
227
234
  * @template T
228
- * @typedef {import('./extension-config').ExtName<T>} ExtName
235
+ * @typedef {import('../../types').ExtName<T>} ExtName
229
236
  */
230
237
 
238
+
239
+ /**
240
+ * Return value of {@linkcode DriverConfig.findMatchingDriver}
241
+ * @typedef MatchedDriver
242
+ * @property {import('../../types/extension').DriverClass} driver
243
+ * @property {string} version
244
+ * @property {string} driverName
245
+ */
246
+
247
+ /**
248
+ * @typedef {import('@appium/types').Capabilities} Capabilities
249
+ */
@@ -1,4 +1,3 @@
1
- // @ts-check
2
1
 
3
2
  import _ from 'lodash';
4
3
  import path from 'path';
@@ -78,7 +77,7 @@ export class ExtensionConfig {
78
77
  for (const [
79
78
  extName,
80
79
  extData,
81
- ] of /** @type {[ExtName<ExtType>, ExtData<ExtType>][]} */ (
80
+ ] of /** @type {[ExtName<ExtType>, ExtManifest<ExtType>][]} */ (
82
81
  _.toPairs(exts)
83
82
  )) {
84
83
  foundProblems[extName] = [
@@ -121,7 +120,7 @@ export class ExtensionConfig {
121
120
  }
122
121
 
123
122
  /**
124
- * @param {ExtData<ExtType>} extData
123
+ * @param {ExtManifest<ExtType>} extData
125
124
  * @param {ExtName<ExtType>} extName
126
125
  * @returns {Problem[]}
127
126
  */
@@ -167,7 +166,7 @@ export class ExtensionConfig {
167
166
  }
168
167
 
169
168
  /**
170
- * @param {ExtData<ExtType>} extData
169
+ * @param {ExtManifest<ExtType>} extData
171
170
  * @param {ExtName<ExtType>} extName
172
171
  * @returns {Problem[]}
173
172
  */
@@ -214,7 +213,7 @@ export class ExtensionConfig {
214
213
 
215
214
  /**
216
215
  * @abstract
217
- * @param {ExtData<ExtType>} extData
216
+ * @param {ExtManifest<ExtType>} extData
218
217
  * @returns {Problem[]}
219
218
  */
220
219
  // eslint-disable-next-line no-unused-vars
@@ -225,12 +224,12 @@ export class ExtensionConfig {
225
224
 
226
225
  /**
227
226
  * @param {string} extName
228
- * @param {ExtData<ExtType>} extData
227
+ * @param {ExtManifest<ExtType>} extData
229
228
  * @param {ExtensionConfigMutationOpts} [opts]
230
229
  * @returns {Promise<void>}
231
230
  */
232
231
  async addExtension (extName, extData, {write = true} = {}) {
233
- await this.manifest.addExtension(this.extensionType, extName, extData);
232
+ this.manifest.addExtension(this.extensionType, extName, extData);
234
233
  if (write) {
235
234
  await this.manifest.write();
236
235
  }
@@ -238,7 +237,7 @@ export class ExtensionConfig {
238
237
 
239
238
  /**
240
239
  * @param {ExtName<ExtType>} extName
241
- * @param {ExtData<ExtType>} extData
240
+ * @param {ExtManifest<ExtType>|import('../cli/extension-command').ExtensionFields<ExtType>} extData
242
241
  * @param {ExtensionConfigMutationOpts} [opts]
243
242
  * @returns {Promise<void>}
244
243
  */
@@ -282,7 +281,7 @@ export class ExtensionConfig {
282
281
  for (const [
283
282
  extName,
284
283
  extData,
285
- ] of /** @type {[string, ExtData<ExtType>][]} */ (
284
+ ] of /** @type {[string, ExtManifest<ExtType>][]} */ (
286
285
  _.toPairs(this.installedExtensions)
287
286
  )) {
288
287
  log.info(` - ${this.extensionDesc(extName, extData)}`);
@@ -292,7 +291,7 @@ export class ExtensionConfig {
292
291
  /**
293
292
  * Returns a string describing the extension. Subclasses must implement.
294
293
  * @param {ExtName<ExtType>} extName - Extension name
295
- * @param {ExtData<ExtType>} extData - Extension data
294
+ * @param {ExtManifest<ExtType>} extData - Extension data
296
295
  * @returns {string}
297
296
  * @abstract
298
297
  */
@@ -342,7 +341,7 @@ export class ExtensionConfig {
342
341
  * @param {string} appiumHome
343
342
  * @param {ExtType} extType
344
343
  * @param {ExtName<ExtType>} extName - Extension name (unique to its type)
345
- * @param {ExtDataWithSchema<ExtType>} extData - Extension config
344
+ * @param {ExtManifestWithSchema<ExtType>} extData - Extension config
346
345
  * @returns {import('ajv').SchemaObject|undefined}
347
346
  */
348
347
  static _readExtensionSchema (appiumHome, extType, extName, extData) {
@@ -368,11 +367,11 @@ export class ExtensionConfig {
368
367
  }
369
368
 
370
369
  /**
371
- * Returns `true` if a specific {@link ExtData} object has a `schema` prop.
372
- * The {@link ExtData} object becomes a {@link ExtDataWithSchema} object.
370
+ * Returns `true` if a specific {@link ExtManifest} object has a `schema` prop.
371
+ * The {@link ExtManifest} object becomes a {@link ExtManifestWithSchema} object.
373
372
  * @template {ExtensionType} ExtType
374
- * @param {ExtData<ExtType>} extData
375
- * @returns {extData is ExtDataWithSchema<ExtType>}
373
+ * @param {ExtManifest<ExtType>} extData
374
+ * @returns {extData is ExtManifestWithSchema<ExtType>}
376
375
  */
377
376
  static extDataHasSchema (extData) {
378
377
  return _.isString(extData?.schema) || _.isObject(extData?.schema);
@@ -382,7 +381,7 @@ export class ExtensionConfig {
382
381
  * If an extension provides a schema, this will load the schema and attempt to
383
382
  * register it with the schema registrar.
384
383
  * @param {ExtName<ExtType>} extName - Name of extension
385
- * @param {ExtDataWithSchema<ExtType>} extData - Extension data
384
+ * @param {ExtManifestWithSchema<ExtType>} extData - Extension data
386
385
  * @returns {import('ajv').SchemaObject|undefined}
387
386
  */
388
387
  readExtensionSchema (extName, extData) {
@@ -418,33 +417,33 @@ export {
418
417
  */
419
418
 
420
419
  /**
421
- * @typedef {import('./manifest').ExtensionType} ExtensionType
420
+ * @typedef {import('../../types').ExtensionType} ExtensionType
422
421
  * @typedef {import('./manifest').Manifest} Manifest
423
422
  */
424
423
 
425
424
  /**
426
425
  * @template T
427
- * @typedef {import('./manifest').ExtData<T>} ExtData
426
+ * @typedef {import('../../types/appium-manifest').ExtManifest<T>} ExtManifest
428
427
  */
429
428
 
430
429
  /**
431
430
  * @template T
432
- * @typedef {import('./manifest').ExtDataWithSchema<T>} ExtDataWithSchema
431
+ * @typedef {import('../../types/appium-manifest').ExtManifestWithSchema<T>} ExtManifestWithSchema
433
432
  */
434
433
 
435
434
  /**
436
435
  * @template T
437
- * @typedef {import('./manifest').ExtName<T>} ExtName
436
+ * @typedef {import('../../types/appium-manifest').ExtName<T>} ExtName
438
437
  */
439
438
 
440
439
  /**
441
440
  * @template T
442
- * @typedef {import('./manifest').ExtClass<T>} ExtClass
441
+ * @typedef {import('../../types/extension').ExtClass<T>} ExtClass
443
442
  */
444
443
 
445
444
  /**
446
445
  * @template T
447
- * @typedef {import('./manifest').ExtRecord<T>} ExtRecord
446
+ * @typedef {import('../../types/appium-manifest').ExtRecord<T>} ExtRecord
448
447
  */
449
448
 
450
449
  /**
@@ -1,4 +1,3 @@
1
- // @ts-check
2
1
 
3
2
  import _ from 'lodash';
4
3
  import { USE_ALL_PLUGINS } from '../constants';
@@ -38,7 +37,7 @@ export async function loadExtensions (appiumHome) {
38
37
  *
39
38
  * @param {import('./plugin-config').PluginConfig} pluginConfig - a plugin extension config
40
39
  * @param {string[]} usePlugins
41
- * @returns {import('./manifest').PluginClass[]}
40
+ * @returns {import('../../types').PluginClass[]}
42
41
  */
43
42
  export function getActivePlugins (pluginConfig, usePlugins = []) {
44
43
  return _.compact(
@@ -1,4 +1,4 @@
1
- // @ts-check
1
+ /// <reference path="../../types/appium-manifest.d.ts" />
2
2
 
3
3
  /**
4
4
  * Module containing {@link Manifest} which handles reading & writing of extension config files.
@@ -61,7 +61,7 @@ const INITIAL_MANIFEST_DATA = Object.freeze({
61
61
  *
62
62
  * The `package.json` must have an `appium` property which is an object.
63
63
  * @param {any} value
64
- * @returns {value is ExtensionPackageJson<ExtensionType>}
64
+ * @returns {value is ExtPackageJson<ExtensionType>}
65
65
  */
66
66
  function isExtension (value) {
67
67
  return (
@@ -77,7 +77,7 @@ function isExtension (value) {
77
77
  * To be considered a driver, a `package.json` must have a fields
78
78
  * `appium.driverName`, `appium.automationName` and `appium.platformNames`.
79
79
  * @param {any} value - Value to test
80
- * @returns {value is ExtensionPackageJson<DriverType>}
80
+ * @returns {value is ExtPackageJson<DriverType>}
81
81
  */
82
82
  function isDriver (value) {
83
83
  return (
@@ -93,7 +93,7 @@ function isDriver (value) {
93
93
  *
94
94
  * To be considered a plugin, a `package.json` must have an `appium.pluginName` field.
95
95
  * @param {any} value - Value to test
96
- * @returns {value is ExtensionPackageJson<PluginType>}
96
+ * @returns {value is ExtPackageJson<PluginType>}
97
97
  */
98
98
  function isPlugin (value) {
99
99
  return isExtension(value) && _.isString(_.get(value, 'appium.pluginName'));
@@ -231,13 +231,13 @@ export class Manifest {
231
231
  *
232
232
  * Will _not_ overwrite existing entries.
233
233
  * @template {ExtensionType} ExtType
234
- * @param {ExtensionPackageJson<ExtType>} pkgJson
234
+ * @param {ExtPackageJson<ExtType>} pkgJson
235
235
  * @param {string} pkgPath
236
236
  * @returns {boolean} - `true` upon success, `false` if the extension is already registered.
237
237
  */
238
238
  addExtensionFromPackage (pkgJson, pkgPath) {
239
239
  /**
240
- * @type {InternalData}
240
+ * @type {InternalMetadata}
241
241
  */
242
242
  const internal = {
243
243
  pkgName: pkgJson.name,
@@ -281,7 +281,7 @@ export class Manifest {
281
281
  * @template {ExtensionType} ExtType
282
282
  * @param {ExtType} extType - `driver` or `plugin`
283
283
  * @param {string} extName - Name of extension
284
- * @param {ExtData<ExtType>} extData - Extension metadata
284
+ * @param {ExtManifest<ExtType>} extData - Extension metadata
285
285
  * @returns {void}
286
286
  */
287
287
  addExtension (extType, extName, extData) {
@@ -445,146 +445,42 @@ export class Manifest {
445
445
  }
446
446
 
447
447
  /**
448
- * Either `driver` or `plugin` rn
449
- * @typedef {typeof DRIVER_TYPE | typeof PLUGIN_TYPE} ExtensionType
450
- */
451
-
452
- /**
453
- * Represents an entire YAML manifest (`extensions.yaml`)
454
- * @typedef ManifestData
455
- * @property {ExtRecord<DriverType>} drivers - Record of drivers, keyed by name
456
- * @property {ExtRecord<PluginType>} plugins - Record of plugins, keyed by name
457
- * @property {number} [schemaRev] - The schema revision of the manifest
458
- */
459
-
460
- /**
461
- * Combination of external + internal extension data with `driverName`/`pluginName` removed (it becomes a key in an {@link ExtRecord} object).
462
- * @template {ExtensionType} ExtType
463
- * @typedef {(Omit<ExternalData<ExtType>, ExtType extends DriverType ? 'driverName' : 'pluginName'>) & InternalData & CommonData} ExtensionManifest
464
- */
465
-
466
- /**
467
- * Manifest extension data which is _not_ provided in `package.json`. It may be derived
468
- * (e.g., `installSpec`) or copied from elsewhere in a `package.json` (e.g.,
469
- * `version`).
470
- * @typedef InternalData
471
- * @property {string} pkgName - Name of package (e.g., `appium-xcuitest-driver`)
472
- * @property {string} version - Version of package
473
- * @property {import('./extension-config').InstallType} installType - Install type
474
- * @property {string} installSpec - Whatever the user typed as the extension to install. May be derived from `package.json`
475
- */
476
-
477
- /**
478
- * Convert external (`package.json`) extension data into manifest data
479
- * @typedef {ExtensionManifest<DriverType>} ManifestDriverData
480
- */
481
-
482
- /**
483
- * Convert external (`package.json`) extension data into manifest data
484
- * @typedef {ExtensionManifest<PluginType>} ManifestPluginData
485
- */
486
-
487
- /**
488
- * Data points shared by all Appium extensions
489
- * @typedef CommonData
490
- * @property {string} mainClass - Name of main class in the extension
491
- * @property {Record<string,string>} [scripts] - Collection of scripts which an extension may run
492
- * @property {string | (import('ajv').SchemaObject & {[key: number]: never})} [schema] - Argument schema object
493
- */
494
-
495
- /**
496
- * Driver-specific manifest data.
497
- * @typedef DriverData
498
- * @property {string} automationName - Automation engine to use
499
- * @property {string[]} platformNames - Platforms to run on
500
- * @property {string} driverName - Name of driver (_not_ the same as the package name, probably)
501
- */
502
-
503
- /**
504
- * Plugin-specific manifest data.
505
- * @typedef PluginData
506
- * @property {string} pluginName - Name of plugin (_not_ the same as the package name, probably)
507
- */
508
-
509
- /**
510
- * Generic type to refer to either {@link DriverData} or {@link PluginData}
511
- * @template {ExtensionType} ExtType
512
- * @typedef {CommonData & (ExtType extends DriverType ? DriverData : PluginData)} ExternalData
513
- */
514
-
515
- /**
516
- * Main class/constructor of third-party plugin
517
- *
518
- * Referenced by {@link CommonData.mainClass}
519
- * @typedef { {pluginName: string} & import('type-fest').Class<unknown> & ExtClassStaticMembers} PluginClass
520
- */
521
-
522
- /**
523
- * Main class/constructor of third-party driver
524
- *
525
- * Referenced by {@link CommonData.mainClass}
526
- * @typedef { {driverName: string} & import('type-fest').Class<unknown> & ExtClassStaticMembers } DriverClass
527
- */
528
-
529
- /**
530
- * @typedef ExtClassStaticMembers
531
- * @property {UpdateServerFn} [updateServer]
532
- * @property {import('@appium/base-driver').MethodMap} [newMethodMap]
533
- */
534
-
535
- /**
536
- * @callback UpdateServerFn
537
- * @param {import('express').Express} app - Express app
538
- * @param {import('http').Server} httpServer - HTTP server
539
- * @returns {import('type-fest').Promisable<void>}
540
- */
541
- /**
542
- * Generic type for an object keyed by extension name, with values of type {@link ExtData}
543
- * @template {ExtensionType} ExtType
544
- * @typedef {Record<string,ExtData<ExtType>>} ExtRecord
448
+ * Type of the string referring to a driver (typically as a key or type string)
449
+ * @typedef {import('../../types').DriverType} DriverType
545
450
  */
546
451
 
547
452
  /**
548
- * Generic type to refer to the data in an {@link ExtRecord}; this is the data for each extension in `extensions.yaml`.
549
- * @template {ExtensionType} ExtType
550
- * @typedef {ExtensionManifest<ExtType>} ExtData
453
+ * Type of the string referring to a plugin (typically as a key or type string)
454
+ * @typedef {import('../../types').PluginType} PluginType
551
455
  */
552
456
 
553
457
  /**
554
- * Like {@link ExtData} except it _for sure_ has a `schema` property.
555
- * @template {ExtensionType} ExtType
556
- * @typedef {(ExtensionManifest<ExtType>) & {schema: import('ajv').SchemaObject|string} } ExtDataWithSchema
458
+ * @typedef SyncWithInstalledExtensionsOpts
459
+ * @property {number} [depthLimit] - Maximum depth to recurse into subdirectories
557
460
  */
558
461
 
559
462
  /**
560
- * Generic type to refer to the main class constructor of an extension
561
- * @template {ExtensionType} ExtType
562
- * @typedef {ExtType extends DriverType ? DriverClass : PluginClass} ExtClass
463
+ * @typedef {import('../../types/appium-manifest').ManifestData} ManifestData
464
+ * @typedef {import('../../types/appium-manifest').InternalMetadata} InternalMetadata
563
465
  */
564
466
 
565
467
  /**
566
- * Generic type for the key of an {@link ExtRecord} which corresponds to an extension name.
567
- * @template {ExtensionType} ExtType
568
- * @typedef {keyof ExtRecord<ExtType>} ExtName
468
+ * @template T
469
+ * @typedef {import('../../types/external-manifest').ExtPackageJson<T>} ExtPackageJson
569
470
  */
570
471
 
571
472
  /**
572
- * Type of the string referring to a driver (typically as a key or type string)
573
- * @typedef {typeof import('../constants').DRIVER_TYPE} DriverType
473
+ * @template T
474
+ * @typedef {import('../../types/appium-manifest').ExtManifest<T>} ExtManifest
574
475
  */
575
476
 
576
477
  /**
577
- * Type of the string referring to a plugin (typically as a key or type string)
578
- * @typedef {typeof import('../constants').PLUGIN_TYPE} PluginType
478
+ * @template T
479
+ * @typedef {import('../../types/appium-manifest').ExtRecord<T>} ExtRecord
579
480
  */
580
481
 
581
482
  /**
582
- * A `package.json` containing extension data.
583
- * @template {ExtensionType} ExtType
584
- * @typedef {import('type-fest').SetRequired<import('type-fest').PackageJson, 'name' | 'version'> & {appium: ExternalData<ExtType>} } ExtensionPackageJson
483
+ * Either `driver` or `plugin` rn
484
+ * @typedef {import('../../types').ExtensionType} ExtensionType
585
485
  */
586
486
 
587
- /**
588
- * @typedef SyncWithInstalledExtensionsOpts
589
- * @property {number} [depthLimit] - Maximum depth to recurse into subdirectories
590
- */
@@ -1,4 +1,3 @@
1
- // @ts-check
2
1
 
3
2
  import { fs } from '@appium/support';
4
3
  import { isPackageChanged } from 'package-changed';
@@ -1,4 +1,3 @@
1
- // @ts-check
2
1
 
3
2
  import _ from 'lodash';
4
3
  import {ExtensionConfig} from './extension-config';
@@ -27,7 +26,7 @@ export class PluginConfig extends ExtensionConfig {
27
26
  *
28
27
  * Just calls the superclass' constructor with the correct extension type
29
28
  * @private
30
- * @param {import('./manifest').Manifest} manifest - IO object
29
+ * @param {Manifest} manifest - IO object
31
30
  * @param {PluginConfigOptions} [opts]
32
31
  */
33
32
  constructor (manifest, {extData, logFn} = {}) {
@@ -63,9 +62,10 @@ export class PluginConfig extends ExtensionConfig {
63
62
  static getInstance (manifest) {
64
63
  return PluginConfig._instances.get(manifest);
65
64
  }
65
+
66
66
  /**
67
67
  * @param {string} pluginName
68
- * @param {PluginData} pluginData
68
+ * @param {import('../../types/appium-manifest').ExtManifest<PluginType>} pluginData
69
69
  * @returns {string}
70
70
  */
71
71
  extensionDesc (pluginName, {version}) {
@@ -74,7 +74,7 @@ export class PluginConfig extends ExtensionConfig {
74
74
 
75
75
  /**
76
76
  *
77
- * @param {(keyof import('./manifest').ExtRecord<PluginType>)[]} activeNames
77
+ * @param {(keyof PluginRecord)[]} activeNames
78
78
  * @returns {void}
79
79
  */
80
80
  print (activeNames) {
@@ -101,11 +101,13 @@ export class PluginConfig extends ExtensionConfig {
101
101
  /**
102
102
  * @typedef PluginConfigOptions
103
103
  * @property {import('./extension-config').ExtensionLogFn} [logFn] - Optional logging function
104
- * @property {import('./manifest').ExtRecord<PluginType>} [extData] - Extension data
104
+ * @property {import('../../types/appium-manifest').PluginRecord} [extData] - Extension data
105
105
  */
106
106
 
107
+
107
108
  /**
108
- * @typedef {import('./manifest').PluginType} PluginType
109
- * @typedef {import('./manifest').ExtData<PluginType>} PluginData
109
+ * @typedef {import('../../types/appium-manifest').PluginRecord} PluginRecord
110
+ * @typedef {import('../../types').PluginType} PluginType
111
+ * @typedef {import('../../types/external-manifest').ExtMetadata<PluginType>} PluginMetadata
110
112
  * @typedef {import('./manifest').Manifest} Manifest
111
113
  */
package/lib/logsink.js CHANGED
@@ -66,6 +66,8 @@ const stripColorFormat = format(function stripColor (info) {
66
66
 
67
67
  function createConsoleTransport (args, logLvl) {
68
68
  return new (transports.Console)({
69
+ // `name` is unsupported per winston's type declarations
70
+ // @ts-expect-error
69
71
  name: 'console',
70
72
  handleExceptions: true,
71
73
  exitOnError: false,
@@ -92,6 +94,7 @@ function createConsoleTransport (args, logLvl) {
92
94
 
93
95
  function createFileTransport (args, logLvl) {
94
96
  return new (transports.File)({
97
+ // @ts-expect-error
95
98
  name: 'file',
96
99
  filename: args.logFile,
97
100
  maxFiles: 1,
@@ -120,6 +123,7 @@ function createHttpTransport (args, logLvl) {
120
123
  }
121
124
 
122
125
  return new (transports.Http)({
126
+ // @ts-expect-error
123
127
  name: 'http',
124
128
  host,
125
129
  port,
package/lib/main.js CHANGED
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- // transpile:main
4
- // @ts-check
5
3
 
6
4
  import { init as logsinkInit } from './logsink'; // this import needs to come first since it sets up global npmlog
7
5
  import logger from './logger'; // logger needs to remain second
@@ -110,7 +108,7 @@ function logServerPort (address, port) {
110
108
  * Gets a list of `updateServer` functions from all extensions
111
109
  * @param {DriverClass[]} driverClasses
112
110
  * @param {PluginClass[]} pluginClasses
113
- * @returns {import('./extension/manifest').UpdateServerFn[]}
111
+ * @returns {import('@appium/base-driver/lib/basedriver/driver').UpdateServerCallback[]}
114
112
  */
115
113
  function getServerUpdaters (driverClasses, pluginClasses) {
116
114
  return _.compact(_.map([...driverClasses, ...pluginClasses], 'updateServer'));
@@ -120,7 +118,7 @@ function getServerUpdaters (driverClasses, pluginClasses) {
120
118
  * Makes a big `MethodMap` from all the little `MethodMap`s in the extensions
121
119
  * @param {DriverClass[]} driverClasses
122
120
  * @param {PluginClass[]} pluginClasses
123
- * @returns {import('@appium/base-driver').MethodMap}
121
+ * @returns {import('@appium/types').MethodMap}
124
122
  */
125
123
  function getExtraMethodMap (driverClasses, pluginClasses) {
126
124
  return [...driverClasses, ...pluginClasses].reduce(
@@ -341,18 +339,19 @@ export { finalizeSchema, getSchema, validate } from './schema/schema';
341
339
  export { main, init, resolveAppiumHome };
342
340
 
343
341
  /**
344
- * @typedef {import('../types/types').ParsedArgs} ParsedArgs
342
+ * @typedef {import('../types/cli').ParsedArgs} ParsedArgs
345
343
  */
346
344
 
347
345
  /**
348
- * @typedef {import('../types/types').PartialArgs} PartialArgs
349
- * @typedef {import('./extension/manifest').DriverType} DriverType
350
- * @typedef {import('./extension/manifest').PluginType} PluginType
351
- * @typedef {import('./extension/manifest').DriverClass} DriverClass
352
- * @typedef {import('./extension/manifest').PluginClass} PluginClass
346
+ * @typedef {import('../types/cli').PartialArgs} PartialArgs
347
+ * @typedef {import('../types').DriverType} DriverType
348
+ * @typedef {import('../types').PluginType} PluginType
349
+ * @typedef {import('../types/extension').DriverClass} DriverClass
350
+ * @typedef {import('../types/extension').PluginClass} PluginClass
353
351
  */
354
352
 
355
353
  /**
354
+ * Literally an empty object
356
355
  * @typedef { {} } ExtCommandInitResult
357
356
  */
358
357
 
@@ -28,6 +28,7 @@ const PROPERTIES = 'properties';
28
28
  * option) used for cross-referencing.
29
29
  *
30
30
  * This class has no instance methods, and is basically just a read-only "struct".
31
+ * @template D
31
32
  */
32
33
  export class ArgSpec {
33
34
  /**
@@ -81,7 +82,7 @@ export class ArgSpec {
81
82
  /**
82
83
  * Whatever the default value of this argument is, as specified by the
83
84
  * `default` property of the schema.
84
- * @type {D}
85
+ * @type {D|undefined}
85
86
  */
86
87
  defaultValue;
87
88
 
@@ -92,7 +93,6 @@ export class ArgSpec {
92
93
  *
93
94
  * The _constructor_ is private. Use {@link ArgSpec.create} instead.
94
95
  * @private
95
- * @template D
96
96
  * @param {string} name
97
97
  * @param {ArgSpecOptions<D>} [opts]
98
98
  */
@@ -176,12 +176,15 @@ export class ArgSpec {
176
176
  /**
177
177
  * When given the root ID of a schema for an extension (`<extType>-<normalizedExtName>.json`) Returns an object containing the extension type and the _normalized_ extension name.
178
178
  * @param {string} schemaId - Root schema ID
179
- * @returns { {extType: ExtensionType|undefined, normalizedExtName: string|undefined} }
179
+ * @returns { {extType?: ExtensionType, normalizedExtName?: string} }
180
180
  */
181
181
  static extensionInfoFromRootSchemaId (schemaId) {
182
182
  const matches = schemaId.match(SCHEMA_ID_REGEXP);
183
183
  if (matches?.groups) {
184
- const {extType, normalizedExtName} = matches.groups;
184
+ const {extType, normalizedExtName} =
185
+ /** @type { {extType: ExtensionType, normalizedExtName: string} } */ (
186
+ matches.groups
187
+ );
185
188
  return {extType, normalizedExtName};
186
189
  }
187
190
  return {};
@@ -192,7 +195,8 @@ export class ArgSpec {
192
195
  *
193
196
  * @param {string} name - The canonical name of the argument. Corresponds to a key in a schema's
194
197
  * `properties` property.
195
- * @param {ArgSpecOptions} [opts] - Options
198
+ * @template D
199
+ * @param {ArgSpecOptions<D>} [opts] - Options
196
200
  * @returns {Readonly<ArgSpec>}
197
201
  */
198
202
  static create (name, opts) {
@@ -224,5 +228,5 @@ export class ArgSpec {
224
228
  */
225
229
 
226
230
  /**
227
- * @typedef {import('../manifest').ExtensionType} ExtensionType
231
+ * @typedef {import('../extension/manifest').ExtensionType} ExtensionType
228
232
  */
@@ -1,4 +1,3 @@
1
- // @ts-check
2
1
 
3
2
  import {ArgumentTypeError} from 'argparse';
4
3
  import _ from 'lodash';