@silasfmartins/testhub 1.0.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 (296) hide show
  1. package/.github/copilot-instructions.md +520 -0
  2. package/biome.json +37 -0
  3. package/dist/index.d.ts +45 -0
  4. package/dist/index.js +169 -0
  5. package/dist/scripts/consumer-postinstall.d.ts +15 -0
  6. package/dist/scripts/consumer-postinstall.js +785 -0
  7. package/dist/scripts/generate-docs.d.ts +16 -0
  8. package/dist/scripts/generate-docs.js +1363 -0
  9. package/dist/scripts/generate-index.d.ts +2 -0
  10. package/dist/scripts/generate-index.js +314 -0
  11. package/dist/scripts/init-api.d.ts +2 -0
  12. package/dist/scripts/init-api.js +525 -0
  13. package/dist/scripts/init-banco.d.ts +2 -0
  14. package/dist/scripts/init-banco.js +347 -0
  15. package/dist/scripts/init-frontend.d.ts +2 -0
  16. package/dist/scripts/init-frontend.js +627 -0
  17. package/dist/scripts/init-mobile.d.ts +2 -0
  18. package/dist/scripts/init-mobile.js +481 -0
  19. package/dist/scripts/init-scenarios.d.ts +2 -0
  20. package/dist/scripts/init-scenarios.js +846 -0
  21. package/dist/scripts/init-ssh.d.ts +2 -0
  22. package/dist/scripts/init-ssh.js +639 -0
  23. package/dist/scripts/package-versions.d.ts +57 -0
  24. package/dist/scripts/package-versions.js +768 -0
  25. package/dist/scripts/postinstall.d.ts +1 -0
  26. package/dist/scripts/postinstall.js +527 -0
  27. package/dist/scripts/robust-build.d.ts +7 -0
  28. package/dist/scripts/robust-build.js +88 -0
  29. package/dist/scripts/setup-local-packages.d.ts +31 -0
  30. package/dist/scripts/setup-local-packages.js +237 -0
  31. package/dist/scripts/smart-override.d.ts +2 -0
  32. package/dist/scripts/smart-override.js +1360 -0
  33. package/dist/scripts/sync-configs.d.ts +27 -0
  34. package/dist/scripts/sync-configs.js +248 -0
  35. package/dist/scripts/test-biome-parse.d.ts +5 -0
  36. package/dist/scripts/test-biome-parse.js +84 -0
  37. package/dist/scripts/ultracite-setup.d.ts +4 -0
  38. package/dist/scripts/ultracite-setup.js +310 -0
  39. package/dist/scripts/update-all-init-scripts.d.ts +2 -0
  40. package/dist/scripts/update-all-init-scripts.js +52 -0
  41. package/dist/scripts/update-biome-schema.d.ts +15 -0
  42. package/dist/scripts/update-biome-schema.js +124 -0
  43. package/dist/src/AutoCoreFacade.d.ts +145 -0
  44. package/dist/src/AutoCoreFacade.js +217 -0
  45. package/dist/src/api/ApiActions.d.ts +297 -0
  46. package/dist/src/api/ApiActions.js +1905 -0
  47. package/dist/src/api/Certificate.d.ts +60 -0
  48. package/dist/src/api/Certificate.js +79 -0
  49. package/dist/src/api/JsonResponse.d.ts +116 -0
  50. package/dist/src/api/JsonResponse.js +206 -0
  51. package/dist/src/appium/DeviceFarmViewer.d.ts +79 -0
  52. package/dist/src/appium/DeviceFarmViewer.js +1083 -0
  53. package/dist/src/appium/MobileActions.d.ts +347 -0
  54. package/dist/src/appium/MobileActions.js +1632 -0
  55. package/dist/src/appium/MobileConnection.d.ts +160 -0
  56. package/dist/src/appium/MobileConnection.js +772 -0
  57. package/dist/src/config/envLoader.d.ts +123 -0
  58. package/dist/src/config/envLoader.js +361 -0
  59. package/dist/src/config/jest-safe-setup.d.ts +19 -0
  60. package/dist/src/config/jest-safe-setup.js +369 -0
  61. package/dist/src/config/timeouts.d.ts +32 -0
  62. package/dist/src/config/timeouts.js +38 -0
  63. package/dist/src/desktop/DesktopActions.d.ts +46 -0
  64. package/dist/src/desktop/DesktopActions.js +398 -0
  65. package/dist/src/desktop/DesktopConnection.d.ts +32 -0
  66. package/dist/src/desktop/DesktopConnection.js +84 -0
  67. package/dist/src/domain/entities/TestExecution.d.ts +117 -0
  68. package/dist/src/domain/entities/TestExecution.js +150 -0
  69. package/dist/src/domain/entities/TestReport.d.ts +114 -0
  70. package/dist/src/domain/entities/TestReport.js +179 -0
  71. package/dist/src/domain/repositories/ITestRepository.d.ts +196 -0
  72. package/dist/src/domain/repositories/ITestRepository.js +14 -0
  73. package/dist/src/domain/schemas/ValidationSchemas.d.ts +159 -0
  74. package/dist/src/domain/schemas/ValidationSchemas.js +181 -0
  75. package/dist/src/functions/errors/BaseError.d.ts +78 -0
  76. package/dist/src/functions/errors/BaseError.js +245 -0
  77. package/dist/src/functions/errors/ConfigurationError.d.ts +16 -0
  78. package/dist/src/functions/errors/ConfigurationError.js +48 -0
  79. package/dist/src/functions/errors/ErrorCatalog.d.ts +148 -0
  80. package/dist/src/functions/errors/ErrorCatalog.js +157 -0
  81. package/dist/src/functions/errors/GlobalErrorHandler.d.ts +101 -0
  82. package/dist/src/functions/errors/GlobalErrorHandler.js +281 -0
  83. package/dist/src/functions/errors/IntegrationError.d.ts +17 -0
  84. package/dist/src/functions/errors/IntegrationError.js +51 -0
  85. package/dist/src/functions/errors/SecurityError.d.ts +14 -0
  86. package/dist/src/functions/errors/SecurityError.js +42 -0
  87. package/dist/src/functions/errors/SystemError.d.ts +12 -0
  88. package/dist/src/functions/errors/SystemError.js +36 -0
  89. package/dist/src/functions/errors/ValidationError.d.ts +14 -0
  90. package/dist/src/functions/errors/ValidationError.js +61 -0
  91. package/dist/src/functions/errors/index.d.ts +12 -0
  92. package/dist/src/functions/errors/index.js +13 -0
  93. package/dist/src/global-setup.d.ts +1 -0
  94. package/dist/src/global-setup.js +1037 -0
  95. package/dist/src/helpers/BancoActions.d.ts +188 -0
  96. package/dist/src/helpers/BancoActions.js +581 -0
  97. package/dist/src/helpers/EnviromentHelper.d.ts +17 -0
  98. package/dist/src/helpers/EnviromentHelper.js +66 -0
  99. package/dist/src/helpers/ParallelExecutionHelper.d.ts +183 -0
  100. package/dist/src/helpers/ParallelExecutionHelper.js +375 -0
  101. package/dist/src/helpers/SyncSignal.d.ts +15 -0
  102. package/dist/src/helpers/SyncSignal.js +44 -0
  103. package/dist/src/hubdocs/CategoryDetector.d.ts +83 -0
  104. package/dist/src/hubdocs/CategoryDetector.js +401 -0
  105. package/dist/src/hubdocs/DirectStatementInterceptor.d.ts +54 -0
  106. package/dist/src/hubdocs/DirectStatementInterceptor.js +243 -0
  107. package/dist/src/hubdocs/ExecutionTracker.d.ts +107 -0
  108. package/dist/src/hubdocs/ExecutionTracker.js +702 -0
  109. package/dist/src/hubdocs/HubDocs.d.ts +395 -0
  110. package/dist/src/hubdocs/HubDocs.js +3586 -0
  111. package/dist/src/hubdocs/StatementMethodFilter.d.ts +71 -0
  112. package/dist/src/hubdocs/StatementMethodFilter.js +618 -0
  113. package/dist/src/hubdocs/StatementTracker.d.ts +417 -0
  114. package/dist/src/hubdocs/StatementTracker.js +2419 -0
  115. package/dist/src/hubdocs/SwaggerGenerator.d.ts +59 -0
  116. package/dist/src/hubdocs/SwaggerGenerator.js +405 -0
  117. package/dist/src/hubdocs/index.d.ts +9 -0
  118. package/dist/src/hubdocs/index.js +9 -0
  119. package/dist/src/hubdocs/types.d.ts +114 -0
  120. package/dist/src/hubdocs/types.js +5 -0
  121. package/dist/src/infrastructure/DependencyContainer.d.ts +142 -0
  122. package/dist/src/infrastructure/DependencyContainer.js +250 -0
  123. package/dist/src/infrastructure/adapters/AppiumAdapter.d.ts +168 -0
  124. package/dist/src/infrastructure/adapters/AppiumAdapter.js +468 -0
  125. package/dist/src/infrastructure/adapters/OracleAdapter.d.ts +150 -0
  126. package/dist/src/infrastructure/adapters/OracleAdapter.js +388 -0
  127. package/dist/src/infrastructure/adapters/PlaywrightAdapter.d.ts +192 -0
  128. package/dist/src/infrastructure/adapters/PlaywrightAdapter.js +382 -0
  129. package/dist/src/infrastructure/adapters/SSHAdapter.d.ts +141 -0
  130. package/dist/src/infrastructure/adapters/SSHAdapter.js +428 -0
  131. package/dist/src/interfaces.d.ts +501 -0
  132. package/dist/src/interfaces.js +25 -0
  133. package/dist/src/internal/fakes/__fake-actions__.d.ts +17 -0
  134. package/dist/src/internal/fakes/__fake-actions__.js +21 -0
  135. package/dist/src/internal/fakes/__forbidden__.d.ts +10 -0
  136. package/dist/src/internal/fakes/__forbidden__.js +18 -0
  137. package/dist/src/internal/fakes/__honeypot__.d.ts +15 -0
  138. package/dist/src/internal/fakes/__honeypot__.js +24 -0
  139. package/dist/src/octane/OctaneReporter.d.ts +13 -0
  140. package/dist/src/octane/OctaneReporter.js +61 -0
  141. package/dist/src/playwright/CryptoActions.d.ts +20 -0
  142. package/dist/src/playwright/CryptoActions.js +75 -0
  143. package/dist/src/playwright/EnhancedWebActions.d.ts +7 -0
  144. package/dist/src/playwright/EnhancedWebActions.js +65 -0
  145. package/dist/src/playwright/WebActions.d.ts +1599 -0
  146. package/dist/src/playwright/WebActions.js +11788 -0
  147. package/dist/src/playwright/actions/ActionTimeline.d.ts +36 -0
  148. package/dist/src/playwright/actions/ActionTimeline.js +101 -0
  149. package/dist/src/playwright/actions/RecoveryQueue.d.ts +82 -0
  150. package/dist/src/playwright/actions/RecoveryQueue.js +130 -0
  151. package/dist/src/playwright/actions/SelectorCache.d.ts +53 -0
  152. package/dist/src/playwright/actions/SelectorCache.js +96 -0
  153. package/dist/src/playwright/actions/index.d.ts +13 -0
  154. package/dist/src/playwright/actions/index.js +14 -0
  155. package/dist/src/playwright/actions/types.d.ts +147 -0
  156. package/dist/src/playwright/actions/types.js +5 -0
  157. package/dist/src/playwright/fixtures.d.ts +112 -0
  158. package/dist/src/playwright/fixtures.js +718 -0
  159. package/dist/src/playwright/network-logs-reporter.d.ts +7 -0
  160. package/dist/src/playwright/network-logs-reporter.js +66 -0
  161. package/dist/src/playwright/registerRecoveryWrappers.d.ts +1 -0
  162. package/dist/src/playwright/registerRecoveryWrappers.js +54 -0
  163. package/dist/src/security/BuildSecurity.d.ts +12 -0
  164. package/dist/src/security/BuildSecurity.js +138 -0
  165. package/dist/src/security/EulaProtection.d.ts +70 -0
  166. package/dist/src/security/EulaProtection.js +155 -0
  167. package/dist/src/security/HoneypotManager.d.ts +46 -0
  168. package/dist/src/security/HoneypotManager.js +234 -0
  169. package/dist/src/security/KeysManager.d.ts +36 -0
  170. package/dist/src/security/KeysManager.js +158 -0
  171. package/dist/src/security/ProofOfWorkIntegration.d.ts +64 -0
  172. package/dist/src/security/ProofOfWorkIntegration.js +206 -0
  173. package/dist/src/security/SecurityValidation.d.ts +21 -0
  174. package/dist/src/security/SecurityValidation.js +163 -0
  175. package/dist/src/security/SourceMapProtection.d.ts +55 -0
  176. package/dist/src/security/SourceMapProtection.js +220 -0
  177. package/dist/src/security/protector.d.ts +1 -0
  178. package/dist/src/security/protector.js +97 -0
  179. package/dist/src/ssh/SSHActions.d.ts +262 -0
  180. package/dist/src/ssh/SSHActions.js +790 -0
  181. package/dist/src/ssh/SSHClient.d.ts +99 -0
  182. package/dist/src/ssh/SSHClient.js +409 -0
  183. package/dist/src/statements/BaseStatement.d.ts +38 -0
  184. package/dist/src/statements/BaseStatement.js +78 -0
  185. package/dist/src/testContext/AuthStateManager.d.ts +93 -0
  186. package/dist/src/testContext/AuthStateManager.js +256 -0
  187. package/dist/src/testContext/CoverageManager.d.ts +198 -0
  188. package/dist/src/testContext/CoverageManager.js +917 -0
  189. package/dist/src/testContext/TestAnnotations.d.ts +476 -0
  190. package/dist/src/testContext/TestAnnotations.js +2647 -0
  191. package/dist/src/testContext/TestContext.d.ts +138 -0
  192. package/dist/src/testContext/TestContext.js +369 -0
  193. package/dist/src/testContext/UnifiedHtmlGenerator.d.ts +7 -0
  194. package/dist/src/testContext/UnifiedHtmlGenerator.js +264 -0
  195. package/dist/src/testContext/UnifiedReportManager.d.ts +211 -0
  196. package/dist/src/testContext/UnifiedReportManager.js +1206 -0
  197. package/dist/src/testhub/DynamicConfigManager.d.ts +121 -0
  198. package/dist/src/testhub/DynamicConfigManager.js +320 -0
  199. package/dist/src/testhub/SystemsManager.d.ts +119 -0
  200. package/dist/src/testhub/SystemsManager.js +365 -0
  201. package/dist/src/testhub/TestHubClient.d.ts +335 -0
  202. package/dist/src/testhub/TestHubClient.js +1215 -0
  203. package/dist/src/testhub/TestHubReporter.d.ts +62 -0
  204. package/dist/src/testhub/TestHubReporter.js +576 -0
  205. package/dist/src/testhub/TestHubVars.d.ts +116 -0
  206. package/dist/src/testhub/TestHubVars.js +273 -0
  207. package/dist/src/utils/ActionInterceptor.d.ts +59 -0
  208. package/dist/src/utils/ActionInterceptor.js +741 -0
  209. package/dist/src/utils/ArtifactsCompressor.d.ts +43 -0
  210. package/dist/src/utils/ArtifactsCompressor.js +181 -0
  211. package/dist/src/utils/AutoLogsFinal.d.ts +47 -0
  212. package/dist/src/utils/AutoLogsFinal.js +148 -0
  213. package/dist/src/utils/CodeGenSession.d.ts +114 -0
  214. package/dist/src/utils/CodeGenSession.js +264 -0
  215. package/dist/src/utils/ConfigLogger.d.ts +133 -0
  216. package/dist/src/utils/ConfigLogger.js +611 -0
  217. package/dist/src/utils/CustomReporter.d.ts +22 -0
  218. package/dist/src/utils/CustomReporter.js +352 -0
  219. package/dist/src/utils/DataStore.d.ts +171 -0
  220. package/dist/src/utils/DataStore.js +484 -0
  221. package/dist/src/utils/DatabaseInterceptor.d.ts +19 -0
  222. package/dist/src/utils/DatabaseInterceptor.js +295 -0
  223. package/dist/src/utils/DateHelper.d.ts +16 -0
  224. package/dist/src/utils/DateHelper.js +120 -0
  225. package/dist/src/utils/DateValidator.d.ts +4 -0
  226. package/dist/src/utils/DateValidator.js +51 -0
  227. package/dist/src/utils/DocumentGenerator.d.ts +35 -0
  228. package/dist/src/utils/DocumentGenerator.js +129 -0
  229. package/dist/src/utils/EvidenceCapture.d.ts +90 -0
  230. package/dist/src/utils/EvidenceCapture.js +600 -0
  231. package/dist/src/utils/EvidenceReportGenerator.d.ts +70 -0
  232. package/dist/src/utils/EvidenceReportGenerator.js +799 -0
  233. package/dist/src/utils/FrameManagementUtil.d.ts +42 -0
  234. package/dist/src/utils/FrameManagementUtil.js +75 -0
  235. package/dist/src/utils/GlobalStatementsInterceptor.d.ts +1 -0
  236. package/dist/src/utils/GlobalStatementsInterceptor.js +1 -0
  237. package/dist/src/utils/HTMLTemplate.d.ts +1 -0
  238. package/dist/src/utils/HTMLTemplate.js +1034 -0
  239. package/dist/src/utils/InterceptacaoMagica.d.ts +23 -0
  240. package/dist/src/utils/InterceptacaoMagica.js +365 -0
  241. package/dist/src/utils/LogSanitizer.d.ts +35 -0
  242. package/dist/src/utils/LogSanitizer.js +110 -0
  243. package/dist/src/utils/Logger.d.ts +65 -0
  244. package/dist/src/utils/Logger.js +284 -0
  245. package/dist/src/utils/McpLocalClient.d.ts +141 -0
  246. package/dist/src/utils/McpLocalClient.js +871 -0
  247. package/dist/src/utils/PDFEvidenceGenerator.d.ts +20 -0
  248. package/dist/src/utils/PDFEvidenceGenerator.js +156 -0
  249. package/dist/src/utils/SpecFileAnalyzer.d.ts +35 -0
  250. package/dist/src/utils/SpecFileAnalyzer.js +209 -0
  251. package/dist/src/utils/StatementInterceptor.d.ts +18 -0
  252. package/dist/src/utils/StatementInterceptor.js +87 -0
  253. package/dist/src/utils/StatementLogger.d.ts +33 -0
  254. package/dist/src/utils/StatementLogger.js +113 -0
  255. package/dist/src/utils/StatementsInterceptor.d.ts +1 -0
  256. package/dist/src/utils/StatementsInterceptor.js +1 -0
  257. package/dist/src/utils/TeamsFlushHook.d.ts +17 -0
  258. package/dist/src/utils/TeamsFlushHook.js +168 -0
  259. package/dist/src/utils/TerminalLogCapture.d.ts +158 -0
  260. package/dist/src/utils/TerminalLogCapture.js +531 -0
  261. package/dist/src/utils/TestMethodLogger.d.ts +70 -0
  262. package/dist/src/utils/TestMethodLogger.js +95 -0
  263. package/dist/src/utils/UnifiedTeardown.d.ts +4 -0
  264. package/dist/src/utils/UnifiedTeardown.js +400 -0
  265. package/dist/src/utils/XPathCatalog.d.ts +152 -0
  266. package/dist/src/utils/XPathCatalog.js +350 -0
  267. package/dist/src/utils/generators.d.ts +90 -0
  268. package/dist/src/utils/generators.js +167 -0
  269. package/dist/src/utils/testRecovery/ResilientPlaywright.d.ts +152 -0
  270. package/dist/src/utils/testRecovery/ResilientPlaywright.js +715 -0
  271. package/dist/src/utils/testRecovery/TestRecoveryClient.d.ts +801 -0
  272. package/dist/src/utils/testRecovery/TestRecoveryClient.js +1415 -0
  273. package/dist/src/utils/testRecovery/autoFixCode.d.ts +65 -0
  274. package/dist/src/utils/testRecovery/autoFixCode.js +32 -0
  275. package/dist/vitest.config.d.ts +2 -0
  276. package/dist/vitest.config.js +59 -0
  277. package/dist/wdio.conf.d.ts +1 -0
  278. package/dist/wdio.conf.js +420 -0
  279. package/package.json +137 -0
  280. package/protect-loader.mjs +643 -0
  281. package/scripts/consumer-postinstall.ts +975 -0
  282. package/scripts/generate-index.ts +343 -0
  283. package/scripts/init-api.ts +613 -0
  284. package/scripts/init-banco.ts +437 -0
  285. package/scripts/init-frontend.ts +727 -0
  286. package/scripts/init-mobile.ts +558 -0
  287. package/scripts/init-scenarios.ts +925 -0
  288. package/scripts/init-ssh.ts +734 -0
  289. package/scripts/package-versions.ts +978 -0
  290. package/scripts/postinstall.ts +605 -0
  291. package/scripts/smart-override.ts +1675 -0
  292. package/scripts/sync-configs.ts +302 -0
  293. package/scripts/ultracite-setup.ts +370 -0
  294. package/src/types/globals.d.ts +48 -0
  295. package/tsconfig.json +29 -0
  296. package/types/autocore-sync-signal.d.ts +10 -0
@@ -0,0 +1,468 @@
1
+ /**
2
+ * @fileoverview Adaptador Appium para automação móvel seguindo padrões DDD
3
+ * @module Infrastructure/Adapters
4
+ */
5
+ import { MobileDeviceSchema, SchemaValidator, SelectorSchema, TimeoutSchema, } from '../../domain/schemas/ValidationSchemas.js';
6
+ import { IntegrationError } from '../../functions/errors/IntegrationError.js';
7
+ import { ValidationError } from '../../functions/errors/ValidationError.js';
8
+ /**
9
+ * Adaptador que integra Appium com a arquitetura do AutoCore
10
+ * Implementa a interface IMobileDriver usando WebDriverIO
11
+ */
12
+ export class AppiumAdapter {
13
+ driver;
14
+ deviceConfig;
15
+ constructor(driver, // WebDriverIO instance
16
+ deviceConfig) {
17
+ this.driver = driver;
18
+ this.deviceConfig = deviceConfig;
19
+ if (!driver) {
20
+ throw ValidationError.missingRequiredParameter('driver');
21
+ }
22
+ // Valida configuração do dispositivo
23
+ if (deviceConfig) {
24
+ SchemaValidator.validate(MobileDeviceSchema, deviceConfig);
25
+ }
26
+ }
27
+ /**
28
+ * Toca em um elemento
29
+ */
30
+ async tap(selector, options = {}) {
31
+ try {
32
+ const validSelector = SchemaValidator.validate(SelectorSchema, selector);
33
+ const timeout = options.timeout
34
+ ? SchemaValidator.validate(TimeoutSchema, options.timeout)
35
+ : 30_000;
36
+ const element = await this.driver.$(validSelector);
37
+ await element.waitForDisplayed({ timeout });
38
+ await element.click();
39
+ }
40
+ catch (error) {
41
+ const err = error;
42
+ throw IntegrationError.webOperationFailed('tap', `Falha ao tocar no elemento ${selector}`, err);
43
+ }
44
+ }
45
+ /**
46
+ * Duplo toque em um elemento
47
+ */
48
+ async doubleTap(selector) {
49
+ try {
50
+ const validSelector = SchemaValidator.validate(SelectorSchema, selector);
51
+ const element = await this.driver.$(validSelector);
52
+ await element.waitForDisplayed();
53
+ await element.doubleClick();
54
+ }
55
+ catch (error) {
56
+ const err = error;
57
+ throw IntegrationError.webOperationFailed('doubleTap', `Falha ao fazer duplo toque em ${selector}`, err);
58
+ }
59
+ }
60
+ /**
61
+ * Pressão longa em um elemento
62
+ */
63
+ async longPress(selector, duration = 1000) {
64
+ try {
65
+ const validSelector = SchemaValidator.validate(SelectorSchema, selector);
66
+ const element = await this.driver.$(validSelector);
67
+ await element.waitForDisplayed();
68
+ // WebDriverIO touch action
69
+ await this.driver.touchAction([
70
+ { action: 'press', element },
71
+ { action: 'wait', ms: duration },
72
+ { action: 'release' },
73
+ ]);
74
+ }
75
+ catch (error) {
76
+ const err = error;
77
+ throw IntegrationError.webOperationFailed('longPress', `Falha ao fazer pressão longa em ${selector}`, err);
78
+ }
79
+ }
80
+ /**
81
+ * Desliza de um elemento para outro
82
+ */
83
+ async swipe(startSelector, endSelector) {
84
+ try {
85
+ const validStartSelector = SchemaValidator.validate(SelectorSchema, startSelector);
86
+ const validEndSelector = SchemaValidator.validate(SelectorSchema, endSelector);
87
+ const startElement = await this.driver.$(validStartSelector);
88
+ const endElement = await this.driver.$(validEndSelector);
89
+ await startElement.waitForDisplayed();
90
+ await endElement.waitForDisplayed();
91
+ const startLocation = await startElement.getLocation();
92
+ const endLocation = await endElement.getLocation();
93
+ await this.swipeByCoordinates(startLocation.x, startLocation.y, endLocation.x, endLocation.y);
94
+ }
95
+ catch (error) {
96
+ const err = error;
97
+ throw IntegrationError.webOperationFailed('swipe', `Falha ao deslizar de ${startSelector} para ${endSelector}`, err);
98
+ }
99
+ }
100
+ /**
101
+ * Desliza por coordenadas
102
+ */
103
+ async swipeByCoordinates(startX, startY, endX, endY) {
104
+ try {
105
+ await this.driver.touchAction([
106
+ { action: 'press', x: startX, y: startY },
107
+ { action: 'wait', ms: 300 },
108
+ { action: 'moveTo', x: endX, y: endY },
109
+ { action: 'release' },
110
+ ]);
111
+ }
112
+ catch (error) {
113
+ const err = error;
114
+ throw IntegrationError.webOperationFailed('swipeByCoordinates', `Falha ao deslizar de (${startX},${startY}) para (${endX},${endY})`, err);
115
+ }
116
+ }
117
+ /**
118
+ * Rola a tela em uma direção
119
+ */
120
+ async scroll(direction, distance = 500) {
121
+ try {
122
+ const windowSize = await this.driver.getWindowSize();
123
+ const centerX = windowSize.width / 2;
124
+ const centerY = windowSize.height / 2;
125
+ let startX = centerX, startY = centerY, endX = centerX, endY = centerY;
126
+ switch (direction) {
127
+ case 'up':
128
+ startY = centerY + distance / 2;
129
+ endY = centerY - distance / 2;
130
+ break;
131
+ case 'down':
132
+ startY = centerY - distance / 2;
133
+ endY = centerY + distance / 2;
134
+ break;
135
+ case 'left':
136
+ startX = centerX + distance / 2;
137
+ endX = centerX - distance / 2;
138
+ break;
139
+ case 'right':
140
+ startX = centerX - distance / 2;
141
+ endX = centerX + distance / 2;
142
+ break;
143
+ }
144
+ await this.swipeByCoordinates(startX, startY, endX, endY);
145
+ }
146
+ catch (error) {
147
+ const err = error;
148
+ throw IntegrationError.webOperationFailed('scroll', `Falha ao rolar ${direction}`, err);
149
+ }
150
+ }
151
+ /**
152
+ * Envia texto para um elemento
153
+ */
154
+ async sendKeys(selector, text) {
155
+ try {
156
+ const validSelector = SchemaValidator.validate(SelectorSchema, selector);
157
+ if (!text && text !== '') {
158
+ throw ValidationError.missingRequiredParameter('text');
159
+ }
160
+ const element = await this.driver.$(validSelector);
161
+ await element.waitForDisplayed();
162
+ await element.setValue(text);
163
+ }
164
+ catch (error) {
165
+ const err = error;
166
+ throw IntegrationError.webOperationFailed('sendKeys', `Falha ao enviar texto para ${selector}`, err);
167
+ }
168
+ }
169
+ /**
170
+ * Limpa texto de um elemento
171
+ */
172
+ async clearText(selector) {
173
+ try {
174
+ const validSelector = SchemaValidator.validate(SelectorSchema, selector);
175
+ const element = await this.driver.$(validSelector);
176
+ await element.waitForDisplayed();
177
+ await element.clearValue();
178
+ }
179
+ catch (error) {
180
+ const err = error;
181
+ throw IntegrationError.webOperationFailed('clearText', `Falha ao limpar texto de ${selector}`, err);
182
+ }
183
+ }
184
+ /**
185
+ * Esconde o teclado
186
+ */
187
+ async hideKeyboard() {
188
+ try {
189
+ await this.driver.hideKeyboard();
190
+ }
191
+ catch (error) {
192
+ // Ignorar erro se teclado não estiver visível
193
+ // Isso é normal em muitos casos
194
+ }
195
+ }
196
+ /**
197
+ * Obtém texto de um elemento
198
+ */
199
+ async getText(selector) {
200
+ try {
201
+ const validSelector = SchemaValidator.validate(SelectorSchema, selector);
202
+ const element = await this.driver.$(validSelector);
203
+ await element.waitForDisplayed();
204
+ return await element.getText();
205
+ }
206
+ catch (error) {
207
+ const err = error;
208
+ throw IntegrationError.webOperationFailed('getText', `Falha ao obter texto de ${selector}`, err);
209
+ }
210
+ }
211
+ /**
212
+ * Obtém atributo de um elemento
213
+ */
214
+ async getAttribute(selector, attribute) {
215
+ try {
216
+ const validSelector = SchemaValidator.validate(SelectorSchema, selector);
217
+ if (!attribute.trim()) {
218
+ throw ValidationError.missingRequiredParameter('attribute');
219
+ }
220
+ const element = await this.driver.$(validSelector);
221
+ await element.waitForDisplayed();
222
+ return await element.getAttribute(attribute);
223
+ }
224
+ catch (error) {
225
+ const err = error;
226
+ throw IntegrationError.webOperationFailed('getAttribute', `Falha ao obter atributo ${attribute} de ${selector}`, err);
227
+ }
228
+ }
229
+ /**
230
+ * Verifica se elemento está visível
231
+ */
232
+ async isDisplayed(selector) {
233
+ try {
234
+ const validSelector = SchemaValidator.validate(SelectorSchema, selector);
235
+ const element = await this.driver.$(validSelector);
236
+ return await element.isDisplayed();
237
+ }
238
+ catch (error) {
239
+ return false;
240
+ }
241
+ }
242
+ /**
243
+ * Verifica se elemento está habilitado
244
+ */
245
+ async isEnabled(selector) {
246
+ try {
247
+ const validSelector = SchemaValidator.validate(SelectorSchema, selector);
248
+ const element = await this.driver.$(validSelector);
249
+ return await element.isEnabled();
250
+ }
251
+ catch (error) {
252
+ return false;
253
+ }
254
+ }
255
+ /**
256
+ * Aguarda elemento ficar em condição específica
257
+ */
258
+ async waitForElement(selector, options = {}) {
259
+ try {
260
+ const validSelector = SchemaValidator.validate(SelectorSchema, selector);
261
+ const timeout = options.timeout
262
+ ? SchemaValidator.validate(TimeoutSchema, options.timeout)
263
+ : 30_000;
264
+ const element = await this.driver.$(validSelector);
265
+ switch (options.condition || 'visible') {
266
+ case 'visible':
267
+ await element.waitForDisplayed({ timeout });
268
+ break;
269
+ case 'clickable':
270
+ await element.waitForClickable({ timeout });
271
+ break;
272
+ case 'exists':
273
+ await element.waitForExist({ timeout });
274
+ break;
275
+ }
276
+ }
277
+ catch (error) {
278
+ const err = error;
279
+ throw IntegrationError.timeoutError(`waitForElement ${selector}`, options.timeout || 30_000);
280
+ }
281
+ }
282
+ /**
283
+ * Gesto de pinça (reduzir)
284
+ */
285
+ async pinch(selector, scale) {
286
+ try {
287
+ const validSelector = SchemaValidator.validate(SelectorSchema, selector);
288
+ const element = await this.driver.$(validSelector);
289
+ await element.waitForDisplayed();
290
+ // WebDriverIO multi-touch para pinch
291
+ const location = await element.getLocation();
292
+ const size = await element.getSize();
293
+ const centerX = location.x + size.width / 2;
294
+ const centerY = location.y + size.height / 2;
295
+ const distance = Math.min(size.width, size.height) / 4;
296
+ await this.driver.multiTouchAction([
297
+ [
298
+ { action: 'press', x: centerX - distance, y: centerY },
299
+ { action: 'wait', ms: 300 },
300
+ { action: 'moveTo', x: centerX - distance * scale, y: centerY },
301
+ { action: 'release' },
302
+ ],
303
+ [
304
+ { action: 'press', x: centerX + distance, y: centerY },
305
+ { action: 'wait', ms: 300 },
306
+ { action: 'moveTo', x: centerX + distance * scale, y: centerY },
307
+ { action: 'release' },
308
+ ],
309
+ ]);
310
+ }
311
+ catch (error) {
312
+ const err = error;
313
+ throw IntegrationError.webOperationFailed('pinch', `Falha ao fazer pinch em ${selector}`, err);
314
+ }
315
+ }
316
+ /**
317
+ * Gesto de zoom (ampliar)
318
+ */
319
+ async zoom(selector, scale) {
320
+ // Zoom é o inverso do pinch
321
+ await this.pinch(selector, 1 / scale);
322
+ }
323
+ /**
324
+ * Rotaciona dispositivo
325
+ */
326
+ async rotate(orientation) {
327
+ try {
328
+ await this.driver.setOrientation(orientation.toUpperCase());
329
+ }
330
+ catch (error) {
331
+ const err = error;
332
+ throw IntegrationError.webOperationFailed('rotate', `Falha ao rotacionar para ${orientation}`, err);
333
+ }
334
+ }
335
+ /**
336
+ * Muda para contexto WebView
337
+ */
338
+ async switchToWebView() {
339
+ try {
340
+ const contexts = await this.driver.getContexts();
341
+ const webviewContext = contexts.find((context) => context.includes('WEBVIEW'));
342
+ if (webviewContext) {
343
+ await this.driver.switchContext(webviewContext);
344
+ }
345
+ else {
346
+ throw new Error('WebView context não encontrado');
347
+ }
348
+ }
349
+ catch (error) {
350
+ const err = error;
351
+ throw IntegrationError.webOperationFailed('switchToWebView', 'Falha ao mudar para WebView', err);
352
+ }
353
+ }
354
+ /**
355
+ * Muda para contexto nativo
356
+ */
357
+ async switchToNativeApp() {
358
+ try {
359
+ await this.driver.switchContext('NATIVE_APP');
360
+ }
361
+ catch (error) {
362
+ const err = error;
363
+ throw IntegrationError.webOperationFailed('switchToNativeApp', 'Falha ao mudar para contexto nativo', err);
364
+ }
365
+ }
366
+ /**
367
+ * Obtém activity atual (Android)
368
+ */
369
+ async getCurrentActivity() {
370
+ try {
371
+ return await this.driver.getCurrentActivity();
372
+ }
373
+ catch (error) {
374
+ const err = error;
375
+ throw IntegrationError.webOperationFailed('getCurrentActivity', 'Falha ao obter activity atual', err);
376
+ }
377
+ }
378
+ /**
379
+ * Abre a aplicação
380
+ */
381
+ async launchApp() {
382
+ try {
383
+ await this.driver.launchApp();
384
+ }
385
+ catch (error) {
386
+ const err = error;
387
+ throw IntegrationError.webOperationFailed('launchApp', 'Falha ao abrir aplicação', err);
388
+ }
389
+ }
390
+ /**
391
+ * Fecha a aplicação
392
+ */
393
+ async closeApp() {
394
+ try {
395
+ await this.driver.closeApp();
396
+ }
397
+ catch (error) {
398
+ const err = error;
399
+ throw IntegrationError.webOperationFailed('closeApp', 'Falha ao fechar aplicação', err);
400
+ }
401
+ }
402
+ /**
403
+ * Reseta a aplicação
404
+ */
405
+ async resetApp() {
406
+ try {
407
+ await this.driver.reset();
408
+ }
409
+ catch (error) {
410
+ const err = error;
411
+ throw IntegrationError.webOperationFailed('resetApp', 'Falha ao resetar aplicação', err);
412
+ }
413
+ }
414
+ /**
415
+ * Captura screenshot
416
+ */
417
+ async screenshot(path) {
418
+ try {
419
+ const screenshot = await this.driver.takeScreenshot();
420
+ const buffer = Buffer.from(screenshot, 'base64');
421
+ if (path) {
422
+ const fs = await import('fs/promises');
423
+ await fs.writeFile(path, buffer);
424
+ }
425
+ return buffer;
426
+ }
427
+ catch (error) {
428
+ const err = error;
429
+ throw IntegrationError.webOperationFailed('screenshot', 'Falha ao capturar screenshot', err);
430
+ }
431
+ }
432
+ /**
433
+ * Obtém código fonte da página
434
+ */
435
+ async getPageSource() {
436
+ try {
437
+ return await this.driver.getPageSource();
438
+ }
439
+ catch (error) {
440
+ const err = error;
441
+ throw IntegrationError.webOperationFailed('getPageSource', 'Falha ao obter código fonte', err);
442
+ }
443
+ }
444
+ /**
445
+ * Encerra o driver
446
+ */
447
+ async quit() {
448
+ try {
449
+ await this.driver.deleteSession();
450
+ }
451
+ catch {
452
+ // Best-effort: session may already be closed
453
+ }
454
+ }
455
+ /**
456
+ * Obtém a instância do WebDriverIO
457
+ * Para casos onde é necessário acessar funcionalidades específicas
458
+ */
459
+ getDriver() {
460
+ return this.driver;
461
+ }
462
+ /**
463
+ * Obtém configuração do dispositivo
464
+ */
465
+ getDeviceConfig() {
466
+ return this.deviceConfig;
467
+ }
468
+ }
@@ -0,0 +1,150 @@
1
+ /**
2
+ * @fileoverview Adaptador Oracle para operações de banco de dados seguindo padrões DDD
3
+ * @module Infrastructure/Adapters
4
+ */
5
+ /**
6
+ * Configuração de conexão com banco Oracle
7
+ */
8
+ export interface OracleConfig {
9
+ host: string;
10
+ port: number;
11
+ database: string;
12
+ username: string;
13
+ password: string;
14
+ connectionTimeout?: number;
15
+ queryTimeout?: number;
16
+ poolMin?: number;
17
+ poolMax?: number;
18
+ }
19
+ /**
20
+ * Resultado de consulta SQL
21
+ */
22
+ export interface QueryResult {
23
+ rows: any[];
24
+ rowCount: number;
25
+ columns: string[];
26
+ executionTime: number;
27
+ query: string;
28
+ parameters?: any[];
29
+ }
30
+ /**
31
+ * Interface para clientes de banco de dados
32
+ */
33
+ export interface IDatabaseClient {
34
+ connect(config: OracleConfig): Promise<void>;
35
+ disconnect(): Promise<void>;
36
+ isConnected(): boolean;
37
+ query(sql: string, parameters?: any[]): Promise<QueryResult>;
38
+ queryOne<T = any>(sql: string, parameters?: any[]): Promise<T | null>;
39
+ queryMany<T = any>(sql: string, parameters?: any[]): Promise<T[]>;
40
+ execute(sql: string, parameters?: any[]): Promise<{
41
+ affectedRows: number;
42
+ lastInsertId?: any;
43
+ }>;
44
+ executeBatch(sql: string, parametersArray: any[][]): Promise<{
45
+ affectedRows: number[];
46
+ }>;
47
+ beginTransaction(): Promise<void>;
48
+ commit(): Promise<void>;
49
+ rollback(): Promise<void>;
50
+ testConnection(): Promise<boolean>;
51
+ getConnectionInfo(): OracleConfig | null;
52
+ executeScript(scriptPath: string): Promise<void>;
53
+ callProcedure(procedureName: string, parameters?: any[]): Promise<any>;
54
+ callFunction(functionName: string, parameters?: any[]): Promise<any>;
55
+ }
56
+ /**
57
+ * Adaptador que integra oracledb com a arquitetura do AutoCore
58
+ * Implementa a interface IDatabaseClient usando oracledb
59
+ */
60
+ export declare class OracleAdapter implements IDatabaseClient {
61
+ private connection;
62
+ private pool;
63
+ private oracledb;
64
+ private connected;
65
+ private connectionConfig;
66
+ private inTransaction;
67
+ constructor();
68
+ /**
69
+ * Conecta ao banco Oracle
70
+ */
71
+ connect(config: OracleConfig): Promise<void>;
72
+ /**
73
+ * Desconecta do banco
74
+ */
75
+ disconnect(): Promise<void>;
76
+ /**
77
+ * Verifica se está conectado
78
+ */
79
+ isConnected(): boolean;
80
+ /**
81
+ * Executa uma consulta SQL
82
+ */
83
+ query(sql: string, parameters?: any[]): Promise<QueryResult>;
84
+ /**
85
+ * Executa consulta e retorna um registro
86
+ */
87
+ queryOne<T = any>(sql: string, parameters?: any[]): Promise<T | null>;
88
+ /**
89
+ * Executa consulta e retorna múltiplos registros
90
+ */
91
+ queryMany<T = any>(sql: string, parameters?: any[]): Promise<T[]>;
92
+ /**
93
+ * Executa comando SQL (INSERT, UPDATE, DELETE)
94
+ */
95
+ execute(sql: string, parameters?: any[]): Promise<{
96
+ affectedRows: number;
97
+ lastInsertId?: any;
98
+ }>;
99
+ /**
100
+ * Executa múltiplos comandos em lote
101
+ */
102
+ executeBatch(sql: string, parametersArray: any[][]): Promise<{
103
+ affectedRows: number[];
104
+ }>;
105
+ /**
106
+ * Inicia transação
107
+ */
108
+ beginTransaction(): Promise<void>;
109
+ /**
110
+ * Confirma transação
111
+ */
112
+ commit(): Promise<void>;
113
+ /**
114
+ * Desfaz transação
115
+ */
116
+ rollback(): Promise<void>;
117
+ /**
118
+ * Testa conexão com o banco
119
+ */
120
+ testConnection(): Promise<boolean>;
121
+ /**
122
+ * Obtém informações da conexão
123
+ */
124
+ getConnectionInfo(): OracleConfig | null;
125
+ /**
126
+ * Executa script SQL de arquivo
127
+ */
128
+ executeScript(scriptPath: string): Promise<void>;
129
+ /**
130
+ * Chama procedure armazenada
131
+ */
132
+ callProcedure(procedureName: string, parameters?: any[]): Promise<any>;
133
+ /**
134
+ * Chama função armazenada
135
+ */
136
+ callFunction(functionName: string, parameters?: any[]): Promise<any>;
137
+ /**
138
+ * Obtém a instância da conexão Oracle
139
+ * Para casos onde é necessário acessar funcionalidades específicas
140
+ */
141
+ getConnection(): any;
142
+ /**
143
+ * Obtém o pool de conexões
144
+ */
145
+ getPool(): any;
146
+ /**
147
+ * Executa consulta com cursor (para grandes volumes)
148
+ */
149
+ queryWithCursor<T = any>(sql: string, parameters?: any[], batchSize?: number): AsyncGenerator<T[], void, unknown>;
150
+ }