@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,382 @@
1
+ /**
2
+ * @fileoverview Adaptador Playwright para automação web seguindo padrões DDD
3
+ * @module Infrastructure/Adapters
4
+ *
5
+ * 🎯 OBJETIVO: Abstrai Playwright com interface padronizada IWebDriver
6
+ * - ✅ Facilita futuras migrações de tecnologia web (Playwright → outras)
7
+ * - ✅ Padroniza métodos entre diferentes drivers web
8
+ * - ✅ Adiciona validação automática com Zod
9
+ * - ✅ Integra automaticamente com sistema de evidências
10
+ * - ✅ Compatível 100% com WebActions atuais
11
+ *
12
+ * 🔄 DIFERENÇA DO SELENIUM/WebDriver:
13
+ * - Selenium: Protocolo W3C WebDriver padrão, mais lento, sem recursos modernos
14
+ * - Playwright: API nativa moderna, mais rápido, recursos avançados (auto-wait, interceptação)
15
+ *
16
+ * 🏗️ ARQUITETURA DDD:
17
+ * - Domain Layer: Interface IWebDriver (contrato independente de tecnologia)
18
+ * - Infrastructure Layer: PlaywrightAdapter (implementação específica)
19
+ * - Application Layer: WebActions (mantém compatibilidade com código atual)
20
+ *
21
+ * 💡 BENEFÍCIOS DESTA ABSTRAÇÃO:
22
+ * - Possibilita trocar Playwright por Selenium/Puppeteer sem quebrar código
23
+ * - Adiciona validação que Playwright puro não tem
24
+ * - Integra automaticamente com coverage/evidências do AutoCore
25
+ * - Permite DI (Dependency Injection) para testes unitários
26
+ * - Facilita mocking e debugging
27
+ *
28
+ * EXEMPLO USO DIRETO (DDD):
29
+ * ```typescript
30
+ * const webDriver: IWebDriver = new PlaywrightAdapter(page)
31
+ * await webDriver.click('#submit') // Validação automática + evidências
32
+ * ```
33
+ *
34
+ * EXEMPLO USO ATUAL (continua funcionando):
35
+ * ```typescript
36
+ * import { WebActions } from '@silasfmartins/testhub'
37
+ * await WebActions.click('#submit') // Usa PlaywrightAdapter internamente
38
+ * ```
39
+ */
40
+ import { SchemaValidator, SelectorSchema, TimeoutSchema, UrlSchema, ViewportSchema, } from '../../domain/schemas/ValidationSchemas.js';
41
+ import { IntegrationError } from '../../functions/errors/IntegrationError.js';
42
+ import { ValidationError } from '../../functions/errors/ValidationError.js';
43
+ /**
44
+ * Adaptador que integra Playwright com a arquitetura do AutoCore
45
+ * Implementa a interface IWebDriver usando Playwright como infraestrutura
46
+ */
47
+ export class PlaywrightAdapter {
48
+ page;
49
+ context;
50
+ constructor(page, context) {
51
+ this.page = page;
52
+ this.context = context;
53
+ if (!page) {
54
+ throw ValidationError.missingRequiredParameter('page');
55
+ }
56
+ }
57
+ /**
58
+ * Navega para uma URL
59
+ */
60
+ async navigate(url, options = {}) {
61
+ try {
62
+ // Validação usando Zod
63
+ const validUrl = SchemaValidator.validate(UrlSchema, url);
64
+ const timeout = options.timeout
65
+ ? SchemaValidator.validate(TimeoutSchema, options.timeout)
66
+ : 30_000;
67
+ await this.page.goto(validUrl, {
68
+ timeout,
69
+ waitUntil: 'domcontentloaded',
70
+ });
71
+ }
72
+ catch (error) {
73
+ const err = error;
74
+ throw IntegrationError.networkError(url, err);
75
+ }
76
+ }
77
+ /**
78
+ * Clica em um elemento
79
+ */
80
+ async click(selector, options = {}) {
81
+ try {
82
+ const validSelector = SchemaValidator.validate(SelectorSchema, selector);
83
+ const timeout = options.timeout
84
+ ? SchemaValidator.validate(TimeoutSchema, options.timeout)
85
+ : 30_000;
86
+ const locator = this.page.locator(validSelector);
87
+ await locator.click({ timeout });
88
+ }
89
+ catch (error) {
90
+ const err = error;
91
+ throw IntegrationError.webOperationFailed('click', `Falha ao clicar no elemento ${selector}`, err);
92
+ }
93
+ }
94
+ /**
95
+ * Preenche um campo
96
+ */
97
+ async fill(selector, value, options = {}) {
98
+ try {
99
+ const validSelector = SchemaValidator.validate(SelectorSchema, selector);
100
+ const timeout = options.timeout
101
+ ? SchemaValidator.validate(TimeoutSchema, options.timeout)
102
+ : 30_000;
103
+ if (!value && value !== '') {
104
+ throw ValidationError.missingRequiredParameter('value');
105
+ }
106
+ const locator = this.page.locator(validSelector);
107
+ await locator.fill(value, { timeout });
108
+ }
109
+ catch (error) {
110
+ const err = error;
111
+ throw IntegrationError.webOperationFailed('fill', `Falha ao preencher campo ${selector}`, err);
112
+ }
113
+ }
114
+ /**
115
+ * Obtém texto de um elemento
116
+ */
117
+ async getText(selector) {
118
+ try {
119
+ const validSelector = SchemaValidator.validate(SelectorSchema, selector);
120
+ const locator = this.page.locator(validSelector);
121
+ const text = await locator.textContent();
122
+ return text || '';
123
+ }
124
+ catch (error) {
125
+ const err = error;
126
+ throw IntegrationError.webOperationFailed('getText', `Falha ao obter texto do elemento ${selector}`, err);
127
+ }
128
+ }
129
+ /**
130
+ * Obtém atributo de um elemento
131
+ */
132
+ async getAttribute(selector, attribute) {
133
+ try {
134
+ const validSelector = SchemaValidator.validate(SelectorSchema, selector);
135
+ if (!attribute.trim()) {
136
+ throw ValidationError.missingRequiredParameter('attribute');
137
+ }
138
+ const locator = this.page.locator(validSelector);
139
+ return await locator.getAttribute(attribute);
140
+ }
141
+ catch (error) {
142
+ const err = error;
143
+ throw IntegrationError.webOperationFailed('getAttribute', `Falha ao obter atributo ${attribute} do elemento ${selector}`, err);
144
+ }
145
+ }
146
+ /**
147
+ * Verifica se elemento está visível
148
+ */
149
+ async isVisible(selector) {
150
+ try {
151
+ const validSelector = SchemaValidator.validate(SelectorSchema, selector);
152
+ const locator = this.page.locator(validSelector);
153
+ return await locator.isVisible();
154
+ }
155
+ catch (error) {
156
+ return false; // Retorna false se elemento não existir
157
+ }
158
+ }
159
+ /**
160
+ * Verifica se elemento está habilitado
161
+ */
162
+ async isEnabled(selector) {
163
+ try {
164
+ const validSelector = SchemaValidator.validate(SelectorSchema, selector);
165
+ const locator = this.page.locator(validSelector);
166
+ return await locator.isEnabled();
167
+ }
168
+ catch (error) {
169
+ return false;
170
+ }
171
+ }
172
+ /**
173
+ * Aguarda elemento ficar em estado específico
174
+ */
175
+ async waitForElement(selector, options = {}) {
176
+ try {
177
+ const validSelector = SchemaValidator.validate(SelectorSchema, selector);
178
+ const timeout = options.timeout
179
+ ? SchemaValidator.validate(TimeoutSchema, options.timeout)
180
+ : 30_000;
181
+ const locator = this.page.locator(validSelector);
182
+ await locator.waitFor({
183
+ state: options.state || 'visible',
184
+ timeout,
185
+ });
186
+ }
187
+ catch (error) {
188
+ const err = error;
189
+ throw IntegrationError.timeoutError(`waitForElement ${selector}`, options.timeout || 30_000);
190
+ }
191
+ }
192
+ /**
193
+ * Seleciona opção em dropdown
194
+ */
195
+ async selectOption(selector, value) {
196
+ try {
197
+ const validSelector = SchemaValidator.validate(SelectorSchema, selector);
198
+ if (!value && value !== '') {
199
+ throw ValidationError.missingRequiredParameter('value');
200
+ }
201
+ const locator = this.page.locator(validSelector);
202
+ await locator.selectOption(value);
203
+ }
204
+ catch (error) {
205
+ const err = error;
206
+ throw IntegrationError.webOperationFailed('selectOption', `Falha ao selecionar opção ${value} em ${selector}`, err);
207
+ }
208
+ }
209
+ /**
210
+ * Hover sobre elemento
211
+ */
212
+ async hover(selector) {
213
+ try {
214
+ const validSelector = SchemaValidator.validate(SelectorSchema, selector);
215
+ const locator = this.page.locator(validSelector);
216
+ await locator.hover();
217
+ }
218
+ catch (error) {
219
+ const err = error;
220
+ throw IntegrationError.webOperationFailed('hover', `Falha ao fazer hover em ${selector}`, err);
221
+ }
222
+ }
223
+ /**
224
+ * Duplo clique
225
+ */
226
+ async doubleClick(selector) {
227
+ try {
228
+ const validSelector = SchemaValidator.validate(SelectorSchema, selector);
229
+ const locator = this.page.locator(validSelector);
230
+ await locator.dblclick();
231
+ }
232
+ catch (error) {
233
+ const err = error;
234
+ throw IntegrationError.webOperationFailed('doubleClick', `Falha ao fazer duplo clique em ${selector}`, err);
235
+ }
236
+ }
237
+ /**
238
+ * Clique com botão direito
239
+ */
240
+ async rightClick(selector) {
241
+ try {
242
+ const validSelector = SchemaValidator.validate(SelectorSchema, selector);
243
+ const locator = this.page.locator(validSelector);
244
+ await locator.click({ button: 'right' });
245
+ }
246
+ catch (error) {
247
+ const err = error;
248
+ throw IntegrationError.webOperationFailed('rightClick', `Falha ao fazer clique direito em ${selector}`, err);
249
+ }
250
+ }
251
+ /**
252
+ * Captura screenshot
253
+ */
254
+ async screenshot(options = {}) {
255
+ try {
256
+ return await this.page.screenshot({
257
+ path: options.path,
258
+ fullPage: options.fullPage !== false,
259
+ });
260
+ }
261
+ catch (error) {
262
+ const err = error;
263
+ throw IntegrationError.webOperationFailed('screenshot', 'Falha ao capturar screenshot', err);
264
+ }
265
+ }
266
+ /**
267
+ * Define tamanho do viewport
268
+ */
269
+ async setViewport(width, height) {
270
+ try {
271
+ const viewport = SchemaValidator.validate(ViewportSchema, {
272
+ width,
273
+ height,
274
+ });
275
+ await this.page.setViewportSize(viewport);
276
+ }
277
+ catch (error) {
278
+ const err = error;
279
+ throw IntegrationError.webOperationFailed('setViewport', `Falha ao definir viewport ${width}x${height}`, err);
280
+ }
281
+ }
282
+ /**
283
+ * Executa JavaScript na página
284
+ */
285
+ async evaluateScript(script) {
286
+ try {
287
+ if (!script.trim()) {
288
+ throw ValidationError.missingRequiredParameter('script');
289
+ }
290
+ return await this.page.evaluate(script);
291
+ }
292
+ catch (error) {
293
+ const err = error;
294
+ throw IntegrationError.webOperationFailed('evaluateScript', 'Falha ao executar JavaScript', err);
295
+ }
296
+ }
297
+ /**
298
+ * Voltar página
299
+ */
300
+ async goBack() {
301
+ try {
302
+ await this.page.goBack();
303
+ }
304
+ catch (error) {
305
+ const err = error;
306
+ throw IntegrationError.webOperationFailed('goBack', 'Falha ao voltar página', err);
307
+ }
308
+ }
309
+ /**
310
+ * Avançar página
311
+ */
312
+ async goForward() {
313
+ try {
314
+ await this.page.goForward();
315
+ }
316
+ catch (error) {
317
+ const err = error;
318
+ throw IntegrationError.webOperationFailed('goForward', 'Falha ao avançar página', err);
319
+ }
320
+ }
321
+ /**
322
+ * Recarregar página
323
+ */
324
+ async reload() {
325
+ try {
326
+ await this.page.reload();
327
+ }
328
+ catch (error) {
329
+ const err = error;
330
+ throw IntegrationError.webOperationFailed('reload', 'Falha ao recarregar página', err);
331
+ }
332
+ }
333
+ /**
334
+ * Obtém URL atual
335
+ */
336
+ async getCurrentUrl() {
337
+ try {
338
+ return this.page.url();
339
+ }
340
+ catch (error) {
341
+ const err = error;
342
+ throw IntegrationError.webOperationFailed('getCurrentUrl', 'Falha ao obter URL atual', err);
343
+ }
344
+ }
345
+ /**
346
+ * Obtém título da página
347
+ */
348
+ async getTitle() {
349
+ try {
350
+ return await this.page.title();
351
+ }
352
+ catch (error) {
353
+ const err = error;
354
+ throw IntegrationError.webOperationFailed('getTitle', 'Falha ao obter título da página', err);
355
+ }
356
+ }
357
+ /**
358
+ * Fecha a página
359
+ */
360
+ async close() {
361
+ try {
362
+ await this.page.close();
363
+ }
364
+ catch (error) {
365
+ const err = error;
366
+ throw IntegrationError.webOperationFailed('close', 'Falha ao fechar página', err);
367
+ }
368
+ }
369
+ /**
370
+ * Obtém a instância do Page do Playwright
371
+ * Para casos onde é necessário acessar funcionalidades específicas
372
+ */
373
+ getPage() {
374
+ return this.page;
375
+ }
376
+ /**
377
+ * Obtém o contexto do browser
378
+ */
379
+ getContext() {
380
+ return this.context;
381
+ }
382
+ }
@@ -0,0 +1,141 @@
1
+ /**
2
+ * @fileoverview Adaptador SSH para execução remota seguindo padrões DDD
3
+ * @module Infrastructure/Adapters
4
+ */
5
+ /**
6
+ * Credenciais SSH validadas pelo Zod
7
+ */
8
+ export interface SSHCredentials {
9
+ host: string;
10
+ port: number;
11
+ username: string;
12
+ password?: string;
13
+ privateKey?: string;
14
+ passphrase?: string;
15
+ }
16
+ /**
17
+ * Resultado de execução de comando SSH
18
+ */
19
+ export interface SSHResult {
20
+ success: boolean;
21
+ stdout: string;
22
+ stderr: string;
23
+ exitCode: number;
24
+ command: string;
25
+ timestamp: Date;
26
+ }
27
+ /**
28
+ * Interface para clientes SSH
29
+ */
30
+ export interface ISSHClient {
31
+ connect(credentials: SSHCredentials): Promise<void>;
32
+ disconnect(): Promise<void>;
33
+ isConnected(): boolean;
34
+ executeCommand(command: string, options?: {
35
+ timeout?: number;
36
+ cwd?: string;
37
+ }): Promise<SSHResult>;
38
+ uploadFile(localPath: string, remotePath: string): Promise<void>;
39
+ downloadFile(remotePath: string, localPath: string): Promise<void>;
40
+ createDirectory(remotePath: string, recursive?: boolean): Promise<void>;
41
+ removeFile(remotePath: string): Promise<void>;
42
+ removeDirectory(remotePath: string, recursive?: boolean): Promise<void>;
43
+ fileExists(remotePath: string): Promise<boolean>;
44
+ getFileInfo(remotePath: string): Promise<{
45
+ size: number;
46
+ modified: Date;
47
+ isDirectory: boolean;
48
+ }>;
49
+ listDirectory(remotePath: string): Promise<string[]>;
50
+ }
51
+ /**
52
+ * Adaptador que integra node-ssh com a arquitetura do AutoCore
53
+ * Implementa a interface ISSHClient usando node-ssh
54
+ */
55
+ export declare class SSHAdapter implements ISSHClient {
56
+ private ssh;
57
+ private connected;
58
+ private connectionInfo;
59
+ constructor();
60
+ /**
61
+ * Conecta ao servidor SSH
62
+ */
63
+ connect(credentials: SSHCredentials): Promise<void>;
64
+ /**
65
+ * Desconecta do servidor SSH
66
+ */
67
+ disconnect(): Promise<void>;
68
+ /**
69
+ * Verifica se está conectado
70
+ */
71
+ isConnected(): boolean;
72
+ /**
73
+ * Executa comando no servidor remoto
74
+ */
75
+ executeCommand(command: string, options?: {
76
+ timeout?: number;
77
+ cwd?: string;
78
+ }): Promise<SSHResult>;
79
+ /**
80
+ * Faz upload de arquivo para o servidor
81
+ */
82
+ uploadFile(localPath: string, remotePath: string): Promise<void>;
83
+ /**
84
+ * Faz download de arquivo do servidor
85
+ */
86
+ downloadFile(remotePath: string, localPath: string): Promise<void>;
87
+ /**
88
+ * Cria diretório no servidor
89
+ */
90
+ createDirectory(remotePath: string, recursive?: boolean): Promise<void>;
91
+ /**
92
+ * Remove arquivo do servidor
93
+ */
94
+ removeFile(remotePath: string): Promise<void>;
95
+ /**
96
+ * Remove diretório do servidor
97
+ */
98
+ removeDirectory(remotePath: string, recursive?: boolean): Promise<void>;
99
+ /**
100
+ * Verifica se arquivo existe no servidor
101
+ */
102
+ fileExists(remotePath: string): Promise<boolean>;
103
+ /**
104
+ * Obtém informações de arquivo/diretório
105
+ */
106
+ getFileInfo(remotePath: string): Promise<{
107
+ size: number;
108
+ modified: Date;
109
+ isDirectory: boolean;
110
+ }>;
111
+ /**
112
+ * Lista conteúdo de diretório
113
+ */
114
+ listDirectory(remotePath: string): Promise<string[]>;
115
+ /**
116
+ * Obtém informações da conexão atual
117
+ */
118
+ getConnectionInfo(): SSHCredentials | null;
119
+ /**
120
+ * Obtém a instância do NodeSSH
121
+ * Para casos onde é necessário acessar funcionalidades específicas
122
+ */
123
+ getSSHClient(): any;
124
+ /**
125
+ * Executa múltiplos comandos em sequência
126
+ */
127
+ executeCommandSequence(commands: string[], options?: {
128
+ stopOnError?: boolean;
129
+ timeout?: number;
130
+ cwd?: string;
131
+ }): Promise<SSHResult[]>;
132
+ /**
133
+ * Executa script local no servidor remoto
134
+ */
135
+ executeScript(scriptContent: string, options?: {
136
+ interpreter?: string;
137
+ args?: string[];
138
+ timeout?: number;
139
+ cwd?: string;
140
+ }): Promise<SSHResult>;
141
+ }