@xenon-device-management/xenon 1.1.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 (228) hide show
  1. package/README.md +446 -0
  2. package/lib/package.json +207 -0
  3. package/lib/public/assets/Layouts-7IT8aFLI.js +11 -0
  4. package/lib/public/assets/Layouts-DPMls9vh.css +1 -0
  5. package/lib/public/assets/ai-settings-BbnfgdEx.js +11 -0
  6. package/lib/public/assets/apps-CRMrI4_p.js +16 -0
  7. package/lib/public/assets/apps-CcM77dgg.css +1 -0
  8. package/lib/public/assets/badge-B1nKs8zj.css +1 -0
  9. package/lib/public/assets/badge-CSvl5xIU.js +11 -0
  10. package/lib/public/assets/button-CJlKn4PZ.css +1 -0
  11. package/lib/public/assets/button-CvLaGFYj.js +26 -0
  12. package/lib/public/assets/calendar-6w-D6Oaw.js +6 -0
  13. package/lib/public/assets/clock-DcdeWBPr.js +6 -0
  14. package/lib/public/assets/cpu-DiSoXT9n.js +6 -0
  15. package/lib/public/assets/device-explorer-CajM63OJ.js +193 -0
  16. package/lib/public/assets/device-explorer-CxdUAoTL.css +1 -0
  17. package/lib/public/assets/index-ByQwMN5T.js +174 -0
  18. package/lib/public/assets/index-C1DBaoSh.js +1 -0
  19. package/lib/public/assets/index-qzCez_kk.css +1 -0
  20. package/lib/public/assets/lock-B23ibZmo.js +6 -0
  21. package/lib/public/assets/maintenance-settings-CirzA6yG.js +6 -0
  22. package/lib/public/assets/mouse-pointer-2-Cz76SHFb.js +6 -0
  23. package/lib/public/assets/plus-BBwlIevt.js +6 -0
  24. package/lib/public/assets/session-dashboard-C2k7FFv_.css +1 -0
  25. package/lib/public/assets/session-dashboard-HPDtwPOZ.js +62 -0
  26. package/lib/public/assets/settings-DrZsZwdc.js +1 -0
  27. package/lib/public/assets/trash-2-DQpvzJec.js +6 -0
  28. package/lib/public/assets/useSocket-Dxsqae2a.js +16 -0
  29. package/lib/public/assets/webhook-settings-CDPgsgkb.css +1 -0
  30. package/lib/public/assets/webhook-settings-Cp-B4Nrw.js +1 -0
  31. package/lib/public/assets/zap-DovP6iow.js +6 -0
  32. package/lib/public/favicon.ico +0 -0
  33. package/lib/public/favicon.png +0 -0
  34. package/lib/public/favicon.svg +9 -0
  35. package/lib/public/index.html +46 -0
  36. package/lib/public/logo.svg +17 -0
  37. package/lib/public/logo192.png +0 -0
  38. package/lib/public/logo512.png +0 -0
  39. package/lib/public/manifest.json +25 -0
  40. package/lib/public/robots.txt +3 -0
  41. package/lib/schema.json +348 -0
  42. package/lib/src/InternalHttpClient.js +212 -0
  43. package/lib/src/PluginContext.js +29 -0
  44. package/lib/src/XenonCapabilityManager.js +199 -0
  45. package/lib/src/app/index.js +167 -0
  46. package/lib/src/app/routers/apps.js +79 -0
  47. package/lib/src/app/routers/config.js +131 -0
  48. package/lib/src/app/routers/control.js +835 -0
  49. package/lib/src/app/routers/dashboard.js +301 -0
  50. package/lib/src/app/routers/grid.js +352 -0
  51. package/lib/src/app/routers/reservation.js +190 -0
  52. package/lib/src/app/routers/webhook.js +83 -0
  53. package/lib/src/app/swagger-docs.js +203 -0
  54. package/lib/src/app/swagger.js +366 -0
  55. package/lib/src/chromeUtils.js +148 -0
  56. package/lib/src/commands/handle.js +19 -0
  57. package/lib/src/commands/index.js +8 -0
  58. package/lib/src/config.js +73 -0
  59. package/lib/src/dashboard/asset-manager.js +84 -0
  60. package/lib/src/dashboard/commands.js +284 -0
  61. package/lib/src/dashboard/event-manager.js +699 -0
  62. package/lib/src/dashboard/services/app-service.js +134 -0
  63. package/lib/src/dashboard/services/failure-analysis-service.js +173 -0
  64. package/lib/src/dashboard/services/session-service.js +113 -0
  65. package/lib/src/data-service/CircuitBreaker.js +83 -0
  66. package/lib/src/data-service/config-service.js +155 -0
  67. package/lib/src/data-service/db.js +122 -0
  68. package/lib/src/data-service/device-service.js +320 -0
  69. package/lib/src/data-service/device-store.interface.js +2 -0
  70. package/lib/src/data-service/device-store.js +345 -0
  71. package/lib/src/data-service/pending-sessions-service.js +25 -0
  72. package/lib/src/data-service/pluginArgs.js +25 -0
  73. package/lib/src/data-service/prisma-service.js +31 -0
  74. package/lib/src/data-service/prisma-store.js +385 -0
  75. package/lib/src/data-service/queue-service.js +150 -0
  76. package/lib/src/data-service/web-config-service.js +130 -0
  77. package/lib/src/device-managers/AndroidDeviceManager.js +1155 -0
  78. package/lib/src/device-managers/ChromeDriverManager.js +68 -0
  79. package/lib/src/device-managers/HealthMonitorService.js +325 -0
  80. package/lib/src/device-managers/IOSDeviceManager.js +351 -0
  81. package/lib/src/device-managers/NodeDevices.js +82 -0
  82. package/lib/src/device-managers/android/AndroidStreamService.js +370 -0
  83. package/lib/src/device-managers/android/DeviceLockManager.js +45 -0
  84. package/lib/src/device-managers/cloud/CapabilityManager.js +26 -0
  85. package/lib/src/device-managers/cloud/Devices.js +86 -0
  86. package/lib/src/device-managers/iOSTracker.js +44 -0
  87. package/lib/src/device-managers/index.js +89 -0
  88. package/lib/src/device-managers/ios/IOSDiscoveryService.js +268 -0
  89. package/lib/src/device-managers/ios/IOSStreamService.js +893 -0
  90. package/lib/src/device-managers/ios/WDAClient.js +866 -0
  91. package/lib/src/device-utils.js +663 -0
  92. package/lib/src/enums/Capabilities.js +8 -0
  93. package/lib/src/enums/Cloud.js +11 -0
  94. package/lib/src/enums/Platform.js +9 -0
  95. package/lib/src/enums/SessionType.js +9 -0
  96. package/lib/src/enums/SocketEvents.js +15 -0
  97. package/lib/src/helpers/UniversalMjpegProxy.js +273 -0
  98. package/lib/src/helpers/index.js +229 -0
  99. package/lib/src/index.js +95 -0
  100. package/lib/src/interceptors/CommandInterceptor.js +524 -0
  101. package/lib/src/interfaces/ICloudManager.js +2 -0
  102. package/lib/src/interfaces/IDevice.js +2 -0
  103. package/lib/src/interfaces/IDeviceFilterOptions.js +2 -0
  104. package/lib/src/interfaces/IDeviceManager.js +2 -0
  105. package/lib/src/interfaces/IOptions.js +2 -0
  106. package/lib/src/interfaces/IPluginArgs.js +55 -0
  107. package/lib/src/interfaces/ISessionCapability.js +2 -0
  108. package/lib/src/logger.js +225 -0
  109. package/lib/src/plugin.js +244 -0
  110. package/lib/src/prisma.js +12 -0
  111. package/lib/src/profiling/AndroidAppProfiler.js +213 -0
  112. package/lib/src/proxy/wd-command-proxy.js +221 -0
  113. package/lib/src/scripts/generate-database-migration.js +59 -0
  114. package/lib/src/scripts/initialize-database.js +55 -0
  115. package/lib/src/scripts/install-go-ios.js +66 -0
  116. package/lib/src/scripts/prepare-prisma.js +89 -0
  117. package/lib/src/services/AICommandService.js +143 -0
  118. package/lib/src/services/AIService.js +466 -0
  119. package/lib/src/services/CleanupService.js +141 -0
  120. package/lib/src/services/EventBus.js +74 -0
  121. package/lib/src/services/InspectorService.js +395 -0
  122. package/lib/src/services/MetricsService.js +134 -0
  123. package/lib/src/services/NetworkConditioningService.js +173 -0
  124. package/lib/src/services/NotificationService.js +163 -0
  125. package/lib/src/services/RequestLogService.js +252 -0
  126. package/lib/src/services/ResourceIsolationService.js +122 -0
  127. package/lib/src/services/SecurityService.js +120 -0
  128. package/lib/src/services/ServerManager.js +284 -0
  129. package/lib/src/services/SessionHeartbeatService.js +158 -0
  130. package/lib/src/services/SessionLifecycleService.js +572 -0
  131. package/lib/src/services/SocketClient.js +71 -0
  132. package/lib/src/services/SocketServer.js +87 -0
  133. package/lib/src/services/TracingService.js +132 -0
  134. package/lib/src/services/VideoPipelineService.js +220 -0
  135. package/lib/src/services/healing/FuzzyXmlHealingProvider.js +333 -0
  136. package/lib/src/services/healing/HealEtalonService.js +98 -0
  137. package/lib/src/services/healing/HealedLocatorGenerator.js +132 -0
  138. package/lib/src/services/healing/HealingOrchestrator.js +165 -0
  139. package/lib/src/services/healing/LlmHealingProvider.js +77 -0
  140. package/lib/src/services/healing/OcrHealingProvider.js +119 -0
  141. package/lib/src/services/healing/ResilioTreeHealingProvider.js +100 -0
  142. package/lib/src/services/healing/VisualAiHealingProvider.js +90 -0
  143. package/lib/src/services/healing/types.js +12 -0
  144. package/lib/src/services/omni-vision/OmniVisionService.js +718 -0
  145. package/lib/src/services/omni-vision/VisionAssertionService.js +68 -0
  146. package/lib/src/sessions/CloudSession.js +42 -0
  147. package/lib/src/sessions/LocalSession.js +313 -0
  148. package/lib/src/sessions/RemoteSession.js +287 -0
  149. package/lib/src/sessions/SessionManager.js +238 -0
  150. package/lib/src/sessions/XenonSession.js +44 -0
  151. package/lib/src/types/CLIArgs.js +2 -0
  152. package/lib/src/types/CloudArgs.js +2 -0
  153. package/lib/src/types/CloudSchema.js +131 -0
  154. package/lib/src/types/DeviceType.js +2 -0
  155. package/lib/src/types/DeviceUpdate.js +2 -0
  156. package/lib/src/types/IOSDevice.js +2 -0
  157. package/lib/src/types/Platform.js +2 -0
  158. package/lib/src/types/SessionStatus.js +11 -0
  159. package/lib/src/validators/CapabilityValidator.js +93 -0
  160. package/lib/test/e2e/android/conf.spec.js +43 -0
  161. package/lib/test/e2e/android/conf2.spec.js +44 -0
  162. package/lib/test/e2e/android/conf3.spec.js +44 -0
  163. package/lib/test/e2e/e2ehelper.js +113 -0
  164. package/lib/test/e2e/hubnode/forward-request.spec.js +224 -0
  165. package/lib/test/e2e/hubnode/hubnode.spec.js +214 -0
  166. package/lib/test/e2e/ios/conf1.spec.js +39 -0
  167. package/lib/test/e2e/ios/conf2.spec.js +39 -0
  168. package/lib/test/e2e/plugin-harness.js +236 -0
  169. package/lib/test/e2e/plugin.spec.js +97 -0
  170. package/lib/test/e2e/telemetry_verification.spec.js +83 -0
  171. package/lib/test/e2e/video-recording-test.spec.js +63 -0
  172. package/lib/test/helpers/test-container.js +112 -0
  173. package/lib/test/integration/androidDevices.spec.js +137 -0
  174. package/lib/test/integration/cliArgs.js +73 -0
  175. package/lib/test/integration/ios/01iOSSimulator.spec.js +291 -0
  176. package/lib/test/integration/ios/02iOSDevices.spec.js +75 -0
  177. package/lib/test/integration/testHelpers.js +74 -0
  178. package/lib/test/unit/AndroidDeviceManager.spec.js +178 -0
  179. package/lib/test/unit/ChromeDriverManager.spec.js +26 -0
  180. package/lib/test/unit/CleanupService.spec.js +21 -0
  181. package/lib/test/unit/DeviceModel.spec.js +157 -0
  182. package/lib/test/unit/FuzzyXmlHealingProvider.test.js +294 -0
  183. package/lib/test/unit/GetAdbOriginal.js +42 -0
  184. package/lib/test/unit/HealingCascade.test.js +128 -0
  185. package/lib/test/unit/IOSDeviceManager.spec.js +261 -0
  186. package/lib/test/unit/RemoteIOs.spec.js +78 -0
  187. package/lib/test/unit/ResilioTreeHealingProvider.test.js +96 -0
  188. package/lib/test/unit/commands.spec.js +27 -0
  189. package/lib/test/unit/config.spec.js +27 -0
  190. package/lib/test/unit/device-service.spec.js +307 -0
  191. package/lib/test/unit/device-utils.spec.js +313 -0
  192. package/lib/test/unit/fixtures/device.config.js +4 -0
  193. package/lib/test/unit/fixtures/devices.js +89 -0
  194. package/lib/test/unit/helpers.spec.js +62 -0
  195. package/lib/test/unit/omni-vision.spec.js +100 -0
  196. package/lib/test/unit/plugin.spec.js +133 -0
  197. package/lib/tsconfig.tsbuildinfo +1 -0
  198. package/package.json +207 -0
  199. package/prisma/data.db +0 -0
  200. package/prisma/dev.db +0 -0
  201. package/prisma/dev.db-journal +0 -0
  202. package/prisma/migrations/20231011074725_initial_tables/migration.sql +47 -0
  203. package/prisma/migrations/20231226115334_update_session_log/migration.sql +2 -0
  204. package/prisma/migrations/20251204113710_add_video_recording_enabled/migration.sql +29 -0
  205. package/prisma/migrations/20251204132449_add_log_table/migration.sql +11 -0
  206. package/prisma/migrations/20251205050111_add_profiling_support/migration.sql +47 -0
  207. package/prisma/migrations/20251205050947_add_is_error_field/migration.sql +24 -0
  208. package/prisma/migrations/20260126201337_add_app_model/migration.sql +18 -0
  209. package/prisma/migrations/20260130115722_add_performance_trace_and_xenon_sync/migration.sql +2 -0
  210. package/prisma/migrations/20260130135114_add_device_models/migration.sql +57 -0
  211. package/prisma/migrations/20260130140655_make_systemport_optional/migration.sql +45 -0
  212. package/prisma/migrations/20260130140932_make_device_fields_optional/migration.sql +45 -0
  213. package/prisma/migrations/20260130141040_final_schema_fix/migration.sql +45 -0
  214. package/prisma/migrations/20260130143234_add_device_health_fields/migration.sql +4 -0
  215. package/prisma/migrations/20260130144921_add_failure_category/migration.sql +2 -0
  216. package/prisma/migrations/20260131151456_add_webhook_config/migration.sql +10 -0
  217. package/prisma/migrations/20260201094507_add_device_tags/migration.sql +11 -0
  218. package/prisma/migrations/20260201103410_add_managed_process/migration.sql +15 -0
  219. package/prisma/migrations/20260201140637_add_web_config/migration.sql +22 -0
  220. package/prisma/migrations/20260201162232_add_session_progress/migration.sql +2 -0
  221. package/prisma/migrations/20260201174231_add_total_healed_count/migration.sql +2 -0
  222. package/prisma/migrations/migration_lock.toml +3 -0
  223. package/prisma/schema.prisma +210 -0
  224. package/schema.json +348 -0
  225. package/scripts/build-xenon.sh +32 -0
  226. package/scripts/dev/debug-gemini.ts +44 -0
  227. package/scripts/generate-types-from-schema.js +86 -0
  228. package/scripts/install-compatible-driver.js +39 -0
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultSchema = exports.pCloudySchema = exports.sauceOrLambdaSchema = exports.browserStackSchema = void 0;
4
+ exports.browserStackSchema = {
5
+ $schema: 'http://json-schema.org/draft-07/schema',
6
+ title: 'browserstackConfig',
7
+ type: 'object',
8
+ required: ['cloudName', 'url', 'devices'],
9
+ properties: {
10
+ cloudName: {
11
+ type: 'string',
12
+ description: 'specify cloudName as browserstack',
13
+ },
14
+ url: {
15
+ type: 'string',
16
+ description: 'Url of cloud',
17
+ },
18
+ devices: {
19
+ type: 'array',
20
+ items: {
21
+ type: 'object',
22
+ properties: {
23
+ deviceName: {
24
+ type: 'string',
25
+ },
26
+ os_version: {
27
+ type: 'string',
28
+ },
29
+ platform: {
30
+ type: 'string',
31
+ },
32
+ },
33
+ required: ['deviceName', 'os_version', 'platform'],
34
+ },
35
+ },
36
+ },
37
+ };
38
+ exports.sauceOrLambdaSchema = {
39
+ $schema: 'http://json-schema.org/draft-07/schema',
40
+ title: 'sauceLabsOrLambdaConfig',
41
+ type: 'object',
42
+ required: ['cloudName', 'url', 'devices'],
43
+ properties: {
44
+ cloudName: {
45
+ type: 'string',
46
+ description: 'specify cloudName as sauce or lambdatest',
47
+ },
48
+ url: {
49
+ type: 'string',
50
+ description: 'Url of cloud',
51
+ },
52
+ devices: {
53
+ type: 'array',
54
+ items: {
55
+ type: 'object',
56
+ properties: {
57
+ deviceName: {
58
+ type: 'string',
59
+ },
60
+ platformVersion: {
61
+ type: 'string',
62
+ },
63
+ platform: {
64
+ type: 'string',
65
+ },
66
+ },
67
+ required: ['deviceName', 'platformVersion', 'platform'],
68
+ },
69
+ },
70
+ },
71
+ };
72
+ exports.pCloudySchema = {
73
+ $schema: 'http://json-schema.org/draft-07/schema',
74
+ title: 'pCloudyConfig',
75
+ type: 'object',
76
+ required: ['cloudName', 'url', 'devices'],
77
+ properties: {
78
+ cloudName: {
79
+ type: 'string',
80
+ description: 'specify cloudName as pCloudy',
81
+ },
82
+ url: {
83
+ type: 'string',
84
+ description: 'Url of cloud',
85
+ },
86
+ devices: {
87
+ type: 'array',
88
+ items: {
89
+ type: 'object',
90
+ properties: {
91
+ pCloudy_DeviceManufacturer: {
92
+ type: 'string',
93
+ },
94
+ pCloudy_DeviceVersion: {
95
+ type: 'string',
96
+ },
97
+ platform: {
98
+ type: 'string',
99
+ },
100
+ },
101
+ required: ['pCloudy_DeviceManufacturer', 'pCloudy_DeviceVersion', 'platform'],
102
+ },
103
+ },
104
+ },
105
+ };
106
+ exports.defaultSchema = {
107
+ $schema: 'http://json-schema.org/draft-07/schema',
108
+ title: 'defaultCloudConfig',
109
+ type: 'object',
110
+ required: ['cloudName', 'url', 'devices'],
111
+ properties: {
112
+ cloudName: {
113
+ type: 'string',
114
+ },
115
+ url: {
116
+ type: 'string',
117
+ },
118
+ devices: {
119
+ type: 'array',
120
+ items: {
121
+ type: 'object',
122
+ properties: {
123
+ platform: {
124
+ type: 'string',
125
+ },
126
+ },
127
+ required: ['platform'],
128
+ },
129
+ },
130
+ },
131
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SessionStatus = void 0;
4
+ var SessionStatus;
5
+ (function (SessionStatus) {
6
+ SessionStatus["RUNNING"] = "running";
7
+ SessionStatus["SUCCESS"] = "success";
8
+ SessionStatus["FAILED"] = "failed";
9
+ SessionStatus["UNMARKED"] = "unmarked";
10
+ SessionStatus["TIMEOUT"] = "timeout";
11
+ })(SessionStatus || (exports.SessionStatus = SessionStatus = {}));
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.CapabilityValidator = exports.CapabilitySchema = void 0;
10
+ const zod_1 = require("zod");
11
+ const typedi_1 = require("typedi");
12
+ const XenonCapabilityManager_1 = require("../XenonCapabilityManager");
13
+ /**
14
+ * Zod Schema for Appium Capabilities
15
+ * Focuses on critical fields required for session allocation and infrastructure management.
16
+ */
17
+ exports.CapabilitySchema = zod_1.z
18
+ .object({
19
+ platformName: zod_1.z
20
+ .string()
21
+ .toLowerCase()
22
+ .refine((val) => ['android', 'ios', 'tvos'].includes(val), {
23
+ message: 'platformName must be one of: android, ios, tvos',
24
+ }),
25
+ // Appium specific caps (with and without prefix)
26
+ 'appium:automationName': zod_1.z.string().optional(),
27
+ automationName: zod_1.z.string().optional(),
28
+ 'appium:udid': zod_1.z.string().optional(),
29
+ udid: zod_1.z.string().optional(),
30
+ 'appium:platformVersion': zod_1.z.string().optional(),
31
+ platformVersion: zod_1.z.string().optional(),
32
+ 'appium:deviceName': zod_1.z.string().optional(),
33
+ deviceName: zod_1.z.string().optional(),
34
+ 'appium:app': zod_1.z.string().optional(),
35
+ app: zod_1.z.string().optional(),
36
+ // Standard Appium Timeouts & Reset strategies
37
+ 'appium:newCommandTimeout': zod_1.z.number().int().min(0).max(1800).optional(),
38
+ newCommandTimeout: zod_1.z.number().int().min(0).max(1800).optional(),
39
+ 'appium:noReset': zod_1.z.boolean().optional(),
40
+ noReset: zod_1.z.boolean().optional(),
41
+ 'appium:fullReset': zod_1.z.boolean().optional(),
42
+ fullReset: zod_1.z.boolean().optional(),
43
+ // Xenon Specific Options (Enterprise Features)
44
+ [XenonCapabilityManager_1.XENON_CAPABILITIES.BUILD_NAME]: zod_1.z.string().optional(),
45
+ [XenonCapabilityManager_1.XENON_CAPABILITIES.SESSION_NAME]: zod_1.z.string().optional(),
46
+ // Xenon Network Conditioning (Roadmap Item 2)
47
+ 'xenon:networkProfile': zod_1.z.enum(['4G', '3G', 'Edge', 'Offline', 'Normal']).optional(),
48
+ // Predictive Failure Thresholds (Roadmap Item 1)
49
+ 'xenon:minBatteryLevel': zod_1.z.number().int().min(1).max(100).optional().default(10),
50
+ 'xenon:maxThermalStatus': zod_1.z.enum(['Normal', 'Hot', 'Critical']).optional().default('Hot'),
51
+ // Advanced Resource Isolation (Roadmap Item 3)
52
+ 'xenon:isolationProfile': zod_1.z
53
+ .enum(['Economy', 'Performance', 'Guaranteed'])
54
+ .optional()
55
+ .default('Performance'),
56
+ // Core capabilities using the enum defined in XenonCapabilityManager
57
+ [XenonCapabilityManager_1.XENON_CAPABILITIES.VIDEO_RECORDING]: zod_1.z.union([zod_1.z.boolean(), zod_1.z.string()]).optional(),
58
+ [XenonCapabilityManager_1.XENON_CAPABILITIES.RECORD_VIDEO]: zod_1.z.union([zod_1.z.boolean(), zod_1.z.string()]).optional(),
59
+ [XenonCapabilityManager_1.XENON_CAPABILITIES.SCREENSHOT_ON_FAILURE]: zod_1.z.union([zod_1.z.boolean(), zod_1.z.string()]).optional(),
60
+ [XenonCapabilityManager_1.XENON_CAPABILITIES.SCREENSHOT_ON_FAIL]: zod_1.z.union([zod_1.z.boolean(), zod_1.z.string()]).optional(),
61
+ [XenonCapabilityManager_1.XENON_CAPABILITIES.SCREENSHOT_ON_EVERY_COMMAND]: zod_1.z.union([zod_1.z.boolean(), zod_1.z.string()]).optional(),
62
+ [XenonCapabilityManager_1.XENON_CAPABILITIES.SCREENSHOT_EVERY_COMMAND]: zod_1.z.union([zod_1.z.boolean(), zod_1.z.string()]).optional(),
63
+ [XenonCapabilityManager_1.XENON_CAPABILITIES.SAVE_DEVICE_LOGS]: zod_1.z.union([zod_1.z.boolean(), zod_1.z.string()]).optional(),
64
+ [XenonCapabilityManager_1.XENON_CAPABILITIES.SAVE_LOGS]: zod_1.z.union([zod_1.z.boolean(), zod_1.z.string()]).optional(),
65
+ // Legacy/Additional snake_case/camelCase aliases not covered by the main enum
66
+ buildName: zod_1.z.string().optional(),
67
+ sessionName: zod_1.z.string().optional(),
68
+ })
69
+ .passthrough();
70
+ /**
71
+ * Principal Capability Validator
72
+ * Performs strict validation and "Fails Fast" before resource allocation.
73
+ */
74
+ let CapabilityValidator = class CapabilityValidator {
75
+ /**
76
+ * Validates the merged capabilities from alwaysMatch and firstMatch.
77
+ * @param caps The merged capability object
78
+ * @returns Validated object or throws error
79
+ */
80
+ validate(caps) {
81
+ const result = exports.CapabilitySchema.safeParse(caps);
82
+ if (!result.success) {
83
+ const error = result.error.issues[0];
84
+ const field = error.path.join('.');
85
+ throw new Error(`[Xenon] Invalid Capability: '${field}' - ${error.message}`);
86
+ }
87
+ return result.data;
88
+ }
89
+ };
90
+ exports.CapabilityValidator = CapabilityValidator;
91
+ exports.CapabilityValidator = CapabilityValidator = __decorate([
92
+ (0, typedi_1.Service)()
93
+ ], CapabilityValidator);
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const webdriverio_1 = require("webdriverio");
13
+ const APPIUM_HOST = '127.0.0.1';
14
+ const APPIUM_PORT = 31337;
15
+ const WDIO_PARAMS = {
16
+ connectionRetryCount: 0,
17
+ hostname: APPIUM_HOST,
18
+ port: APPIUM_PORT,
19
+ path: '/wd/hub/',
20
+ logLevel: 'info',
21
+ };
22
+ const capabilities = {
23
+ platformName: 'Android',
24
+ 'appium:uiautomator2ServerInstallTimeout': '50000',
25
+ 'appium:automationName': 'UIAutomator2',
26
+ 'appium:app': 'https://github.com/AppiumTestDistribution/appium-demo/blob/main/VodQA.apk?raw=true',
27
+ };
28
+ let driver;
29
+ describe('Plugin Test', () => {
30
+ beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
31
+ driver = yield (0, webdriverio_1.remote)(Object.assign(Object.assign({}, WDIO_PARAMS), { capabilities }));
32
+ }));
33
+ it('Vertical swipe test', () => __awaiter(void 0, void 0, void 0, function* () {
34
+ console.log(yield driver.capabilities.deviceUDID);
35
+ yield driver.$('~login').click();
36
+ }));
37
+ afterEach(() => __awaiter(void 0, void 0, void 0, function* () {
38
+ if (driver) {
39
+ yield driver.deleteSession();
40
+ driver = null;
41
+ }
42
+ }));
43
+ });
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const webdriverio_1 = require("webdriverio");
13
+ const APPIUM_HOST = '127.0.0.1';
14
+ const APPIUM_PORT = 31337;
15
+ const WDIO_PARAMS = {
16
+ connectionRetryCount: 0,
17
+ hostname: APPIUM_HOST,
18
+ port: APPIUM_PORT,
19
+ path: '/wd/hub/',
20
+ logLevel: 'info',
21
+ };
22
+ const capabilities = {
23
+ platformName: 'Android',
24
+ 'appium:uiautomator2ServerInstallTimeout': '50000',
25
+ 'appium:automationName': 'UIAutomator2',
26
+ 'appium:app': 'https://github.com/AppiumTestDistribution/appium-demo/blob/main/VodQA.apk?raw=true',
27
+ };
28
+ describe('Plugin1 Test', () => {
29
+ let driver;
30
+ beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
31
+ driver = yield (0, webdriverio_1.remote)(Object.assign(Object.assign({}, WDIO_PARAMS), { capabilities }));
32
+ }));
33
+ it('Slider test', () => __awaiter(void 0, void 0, void 0, function* () {
34
+ console.log(yield driver.capabilities.deviceUDID);
35
+ yield driver.$('~login').click();
36
+ yield driver.$('~slider1').click();
37
+ }));
38
+ afterEach(() => __awaiter(void 0, void 0, void 0, function* () {
39
+ if (driver) {
40
+ yield driver.deleteSession();
41
+ driver = null;
42
+ }
43
+ }));
44
+ });
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const webdriverio_1 = require("webdriverio");
13
+ const APPIUM_HOST = '127.0.0.1';
14
+ const APPIUM_PORT = 31337;
15
+ const WDIO_PARAMS = {
16
+ connectionRetryCount: 0,
17
+ hostname: APPIUM_HOST,
18
+ port: APPIUM_PORT,
19
+ path: '/wd/hub/',
20
+ logLevel: 'info',
21
+ };
22
+ const capabilities = {
23
+ platformName: 'Android',
24
+ 'appium:uiautomator2ServerInstallTimeout': '50000',
25
+ 'appium:automationName': 'UIAutomator2',
26
+ 'appium:app': 'https://github.com/AppiumTestDistribution/appium-demo/blob/main/VodQA.apk?raw=true',
27
+ };
28
+ describe('Plugin1 Test', () => {
29
+ let driver;
30
+ beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
31
+ driver = yield (0, webdriverio_1.remote)(Object.assign(Object.assign({}, WDIO_PARAMS), { capabilities }));
32
+ }));
33
+ it('Slider test', () => __awaiter(void 0, void 0, void 0, function* () {
34
+ console.log(yield driver.capabilities.deviceUDID);
35
+ yield driver.$('~login').click();
36
+ yield driver.$('~slider1').click();
37
+ }));
38
+ afterEach(() => __awaiter(void 0, void 0, void 0, function* () {
39
+ if (driver) {
40
+ yield driver.deleteSession();
41
+ driver = null;
42
+ }
43
+ }));
44
+ });
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.node_config = exports.hub_config = exports.PLUGIN_PATH = exports.NODE_APPIUM_PORT = exports.HUB_APPIUM_PORT = void 0;
7
+ exports.ensureTempDir = ensureTempDir;
8
+ exports.ensureAppiumHome = ensureAppiumHome;
9
+ exports.ensureHubConfig = ensureHubConfig;
10
+ exports.ensureNodeConfig = ensureNodeConfig;
11
+ const fs_1 = __importDefault(require("fs"));
12
+ const path_1 = __importDefault(require("path"));
13
+ const os_1 = __importDefault(require("os"));
14
+ const ip_1 = __importDefault(require("ip"));
15
+ const IPluginArgs_1 = require("../../src/interfaces/IPluginArgs");
16
+ const ifaces = os_1.default.networkInterfaces();
17
+ /**
18
+ {
19
+ lo0: [
20
+ {
21
+ address: '127.0.0.1',
22
+ netmask: '255.0.0.0',
23
+ family: 'IPv4',
24
+ mac: '00:00:00:00:00:00',
25
+ internal: true,
26
+ cidr: '127.0.0.1/8'
27
+ }
28
+ ]
29
+ }
30
+ */
31
+ const localIp = ip_1.default.address();
32
+ const ifaceNames = Object.keys(ifaces);
33
+ // find first ip address coming from device other than localIp
34
+ const availableIpAddresses = ifaceNames
35
+ .map((device) => {
36
+ var _a;
37
+ return (_a = (ifaces[device] || []).find((iface) => iface.family === 'IPv4')) === null || _a === void 0 ? void 0 : _a.address;
38
+ })
39
+ .filter((ip) => ip !== undefined);
40
+ // find first ip address coming from device other than localIp
41
+ let alternateIp = availableIpAddresses.find((ip) => ip !== localIp);
42
+ if (alternateIp === undefined)
43
+ alternateIp = localIp;
44
+ console.log(`Using localIp: ${localIp}`);
45
+ console.log(`Using alternateIp: ${alternateIp}`);
46
+ exports.HUB_APPIUM_PORT = 4723;
47
+ exports.NODE_APPIUM_PORT = 4724;
48
+ exports.PLUGIN_PATH = path_1.default.resolve(__dirname + '/../..');
49
+ exports.hub_config = Object.assign({}, IPluginArgs_1.DefaultPluginArgs, {
50
+ hub: undefined,
51
+ bindHostOrIp: localIp,
52
+ });
53
+ exports.node_config = Object.assign({}, IPluginArgs_1.DefaultPluginArgs, {
54
+ hub: `http://${exports.hub_config.bindHostOrIp}:${exports.HUB_APPIUM_PORT}`,
55
+ bindHostOrIp: alternateIp,
56
+ });
57
+ function ensureTempDir() {
58
+ const tempDir = path_1.default.resolve(__dirname + '/../../temp-appium');
59
+ if (!fs_1.default.existsSync(tempDir)) {
60
+ fs_1.default.mkdirSync(tempDir);
61
+ }
62
+ return tempDir;
63
+ }
64
+ function ensureAppiumHome(suffix = '', deleteExisting = true) {
65
+ const newHome = path_1.default.resolve(path_1.default.join(__dirname, '/../../temp-appium', suffix));
66
+ if (!fs_1.default.existsSync(newHome)) {
67
+ fs_1.default.mkdirSync(newHome);
68
+ }
69
+ // check if there's already extensions.yaml under node_modules/.cache/appium
70
+ const extensionsYaml = path_1.default.join(newHome, 'node_modules', '.cache', 'appium', 'extensions.yaml');
71
+ // log a warning as appium won't be able to install the plugin
72
+ if (fs_1.default.existsSync(extensionsYaml)) {
73
+ console.log(`WARNING: ${extensionsYaml} already exists. Appium won't be able to install the plugin`);
74
+ if (deleteExisting) {
75
+ console.log(`Deleting ${extensionsYaml}`);
76
+ fs_1.default.unlinkSync(extensionsYaml);
77
+ }
78
+ }
79
+ return newHome;
80
+ }
81
+ function ensureHubConfig(platform = 'android', iosDeviceType = 'both', androidDeviceType = 'both', moreConfig = {}) {
82
+ return ensureConfig('hub-config.json', {
83
+ server: {
84
+ port: exports.HUB_APPIUM_PORT,
85
+ plugin: {
86
+ xenon: Object.assign(exports.node_config, {
87
+ platform,
88
+ androidDeviceType,
89
+ iosDeviceType,
90
+ }, moreConfig),
91
+ },
92
+ },
93
+ });
94
+ }
95
+ function ensureNodeConfig(platform = 'android', iosDeviceType = 'both', androidDeviceType = 'both', moreConfig = {}) {
96
+ return ensureConfig('node-config.json', {
97
+ server: {
98
+ port: exports.NODE_APPIUM_PORT,
99
+ plugin: {
100
+ xenon: Object.assign(exports.node_config, {
101
+ platform,
102
+ androidDeviceType,
103
+ iosDeviceType,
104
+ }),
105
+ },
106
+ },
107
+ });
108
+ }
109
+ function ensureConfig(filename, config) {
110
+ const config_file = ensureTempDir() + '/' + filename;
111
+ fs_1.default.writeFileSync(config_file, JSON.stringify(config));
112
+ return config_file;
113
+ }