@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,388 @@
1
+ /**
2
+ * @fileoverview Adaptador Oracle para operações de banco de dados seguindo padrões DDD
3
+ * @module Infrastructure/Adapters
4
+ */
5
+ import { DatabaseConfigSchema, SchemaValidator, } 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 oracledb com a arquitetura do AutoCore
10
+ * Implementa a interface IDatabaseClient usando oracledb
11
+ */
12
+ export class OracleAdapter {
13
+ connection = null;
14
+ pool = null;
15
+ oracledb = null;
16
+ connected = false;
17
+ connectionConfig = null;
18
+ inTransaction = false;
19
+ constructor() {
20
+ // Lazy loading da biblioteca oracledb
21
+ }
22
+ /**
23
+ * Conecta ao banco Oracle
24
+ */
25
+ async connect(config) {
26
+ try {
27
+ // Validação usando Zod
28
+ const validConfig = SchemaValidator.validate(DatabaseConfigSchema, config);
29
+ // Lazy loading da biblioteca Oracle
30
+ if (!this.oracledb) {
31
+ try {
32
+ this.oracledb = await import('oracledb');
33
+ // Configurar oracledb
34
+ this.oracledb.outFormat = this.oracledb.OUT_FORMAT_OBJECT;
35
+ this.oracledb.autoCommit = false;
36
+ }
37
+ catch (error) {
38
+ // Fallback para implementação mock se oracledb não estiver disponível
39
+ this.oracledb = {
40
+ getConnection: async () => ({
41
+ execute: async () => ({ rows: [], rowsAffected: 0 }),
42
+ close: async () => { },
43
+ commit: async () => { },
44
+ rollback: async () => { },
45
+ }),
46
+ createPool: async () => ({
47
+ getConnection: async () => this.oracledb.getConnection(),
48
+ close: async () => { },
49
+ }),
50
+ OUT_FORMAT_OBJECT: 'object',
51
+ };
52
+ }
53
+ }
54
+ // Configurar conexão
55
+ const connectionConfig = {
56
+ user: validConfig.username,
57
+ password: validConfig.password,
58
+ connectString: `${validConfig.host}:${validConfig.port}/${validConfig.database}`,
59
+ connectTimeout: validConfig.connectionTimeout || 30,
60
+ poolMin: config.poolMin || 1,
61
+ poolMax: config.poolMax || 10,
62
+ };
63
+ // Criar pool de conexões
64
+ this.pool = await this.oracledb.createPool(connectionConfig);
65
+ // Testar conexão
66
+ this.connection = await this.pool.getConnection();
67
+ this.connected = true;
68
+ this.connectionConfig = validConfig;
69
+ }
70
+ catch (error) {
71
+ const err = error;
72
+ this.connected = false;
73
+ this.connectionConfig = null;
74
+ throw IntegrationError.databaseConnectionFailed(`${config.host}:${config.port}/${config.database}`, err);
75
+ }
76
+ }
77
+ /**
78
+ * Desconecta do banco
79
+ */
80
+ async disconnect() {
81
+ try {
82
+ if (this.connection) {
83
+ await this.connection.close().catch(() => { });
84
+ this.connection = null;
85
+ }
86
+ if (this.pool) {
87
+ await this.pool.close(0).catch(() => { });
88
+ this.pool = null;
89
+ }
90
+ }
91
+ finally {
92
+ this.connected = false;
93
+ this.connectionConfig = null;
94
+ this.inTransaction = false;
95
+ }
96
+ }
97
+ /**
98
+ * Verifica se está conectado
99
+ */
100
+ isConnected() {
101
+ return this.connected && !!this.connection;
102
+ }
103
+ /**
104
+ * Executa uma consulta SQL
105
+ */
106
+ async query(sql, parameters = []) {
107
+ if (!this.isConnected()) {
108
+ throw ValidationError.invalidConfiguration('database', 'Banco não está conectado');
109
+ }
110
+ if (!sql.trim()) {
111
+ throw ValidationError.missingRequiredParameter('sql');
112
+ }
113
+ const startTime = Date.now();
114
+ try {
115
+ const result = await this.connection.execute(sql, parameters);
116
+ const executionTime = Date.now() - startTime;
117
+ return {
118
+ rows: result.rows || [],
119
+ rowCount: result.rows ? result.rows.length : 0,
120
+ columns: result.metaData
121
+ ? result.metaData.map((col) => col.name)
122
+ : [],
123
+ executionTime,
124
+ query: sql,
125
+ parameters,
126
+ };
127
+ }
128
+ catch (error) {
129
+ const err = error;
130
+ throw IntegrationError.webOperationFailed('query', `Falha ao executar consulta: ${sql}`, err);
131
+ }
132
+ }
133
+ /**
134
+ * Executa consulta e retorna um registro
135
+ */
136
+ async queryOne(sql, parameters = []) {
137
+ const result = await this.query(sql, parameters);
138
+ return result.rows.length > 0 ? result.rows[0] : null;
139
+ }
140
+ /**
141
+ * Executa consulta e retorna múltiplos registros
142
+ */
143
+ async queryMany(sql, parameters = []) {
144
+ const result = await this.query(sql, parameters);
145
+ return result.rows;
146
+ }
147
+ /**
148
+ * Executa comando SQL (INSERT, UPDATE, DELETE)
149
+ */
150
+ async execute(sql, parameters = []) {
151
+ if (!this.isConnected()) {
152
+ throw ValidationError.invalidConfiguration('database', 'Banco não está conectado');
153
+ }
154
+ if (!sql.trim()) {
155
+ throw ValidationError.missingRequiredParameter('sql');
156
+ }
157
+ try {
158
+ const result = await this.connection.execute(sql, parameters);
159
+ if (!this.inTransaction) {
160
+ await this.connection.commit();
161
+ }
162
+ return {
163
+ affectedRows: result.rowsAffected || 0,
164
+ lastInsertId: result.lastRowid,
165
+ };
166
+ }
167
+ catch (error) {
168
+ if (!this.inTransaction) {
169
+ await this.connection.rollback();
170
+ }
171
+ const err = error;
172
+ throw IntegrationError.webOperationFailed('execute', `Falha ao executar comando: ${sql}`, err);
173
+ }
174
+ }
175
+ /**
176
+ * Executa múltiplos comandos em lote
177
+ */
178
+ async executeBatch(sql, parametersArray) {
179
+ if (!this.isConnected()) {
180
+ throw ValidationError.invalidConfiguration('database', 'Banco não está conectado');
181
+ }
182
+ if (!sql.trim()) {
183
+ throw ValidationError.missingRequiredParameter('sql');
184
+ }
185
+ if (!parametersArray || parametersArray.length === 0) {
186
+ throw ValidationError.missingRequiredParameter('parametersArray');
187
+ }
188
+ const affectedRows = [];
189
+ try {
190
+ const wasInTransaction = this.inTransaction;
191
+ if (!wasInTransaction) {
192
+ await this.beginTransaction();
193
+ }
194
+ for (const parameters of parametersArray) {
195
+ const result = await this.connection.execute(sql, parameters);
196
+ affectedRows.push(result.rowsAffected || 0);
197
+ }
198
+ if (!wasInTransaction) {
199
+ await this.commit();
200
+ }
201
+ return { affectedRows };
202
+ }
203
+ catch (error) {
204
+ if (!this.inTransaction) {
205
+ await this.rollback();
206
+ }
207
+ const err = error;
208
+ throw IntegrationError.webOperationFailed('executeBatch', `Falha ao executar lote: ${sql}`, err);
209
+ }
210
+ }
211
+ /**
212
+ * Inicia transação
213
+ */
214
+ async beginTransaction() {
215
+ if (!this.isConnected()) {
216
+ throw ValidationError.invalidConfiguration('database', 'Banco não está conectado');
217
+ }
218
+ if (this.inTransaction) {
219
+ throw ValidationError.invalidConfiguration('transaction', 'Transação já está ativa');
220
+ }
221
+ this.inTransaction = true;
222
+ }
223
+ /**
224
+ * Confirma transação
225
+ */
226
+ async commit() {
227
+ if (!this.isConnected()) {
228
+ throw ValidationError.invalidConfiguration('database', 'Banco não está conectado');
229
+ }
230
+ try {
231
+ await this.connection.commit();
232
+ this.inTransaction = false;
233
+ }
234
+ catch (error) {
235
+ const err = error;
236
+ throw IntegrationError.webOperationFailed('commit', 'Falha ao confirmar transação', err);
237
+ }
238
+ }
239
+ /**
240
+ * Desfaz transação
241
+ */
242
+ async rollback() {
243
+ if (!this.isConnected()) {
244
+ throw ValidationError.invalidConfiguration('database', 'Banco não está conectado');
245
+ }
246
+ try {
247
+ await this.connection.rollback();
248
+ this.inTransaction = false;
249
+ }
250
+ catch (error) {
251
+ const err = error;
252
+ throw IntegrationError.webOperationFailed('rollback', 'Falha ao desfazer transação', err);
253
+ }
254
+ }
255
+ /**
256
+ * Testa conexão com o banco
257
+ */
258
+ async testConnection() {
259
+ try {
260
+ if (!this.isConnected()) {
261
+ return false;
262
+ }
263
+ const result = await this.query('SELECT 1 FROM DUAL');
264
+ return result.rows.length > 0;
265
+ }
266
+ catch (error) {
267
+ return false;
268
+ }
269
+ }
270
+ /**
271
+ * Obtém informações da conexão
272
+ */
273
+ getConnectionInfo() {
274
+ return this.connectionConfig;
275
+ }
276
+ /**
277
+ * Executa script SQL de arquivo
278
+ */
279
+ async executeScript(scriptPath) {
280
+ if (!scriptPath.trim()) {
281
+ throw ValidationError.missingRequiredParameter('scriptPath');
282
+ }
283
+ try {
284
+ const fs = await import('fs/promises');
285
+ const scriptContent = await fs.readFile(scriptPath, 'utf8');
286
+ // Dividir script em comandos individuais
287
+ const commands = scriptContent
288
+ .split(/;\s*[\r\n]+/)
289
+ .map((cmd) => cmd.trim())
290
+ .filter((cmd) => cmd.length > 0 && !cmd.startsWith('--'));
291
+ await this.beginTransaction();
292
+ for (const command of commands) {
293
+ if (command.trim()) {
294
+ await this.execute(command);
295
+ }
296
+ }
297
+ await this.commit();
298
+ }
299
+ catch (error) {
300
+ await this.rollback();
301
+ const err = error;
302
+ throw IntegrationError.fileSystemError('executeScript', scriptPath, err);
303
+ }
304
+ }
305
+ /**
306
+ * Chama procedure armazenada
307
+ */
308
+ async callProcedure(procedureName, parameters = []) {
309
+ if (!procedureName.trim()) {
310
+ throw ValidationError.missingRequiredParameter('procedureName');
311
+ }
312
+ const placeholders = parameters
313
+ .map((_, index) => `:${index + 1}`)
314
+ .join(', ');
315
+ const sql = `BEGIN ${procedureName}(${placeholders}); END;`;
316
+ try {
317
+ const result = await this.execute(sql, parameters);
318
+ return result;
319
+ }
320
+ catch (error) {
321
+ const err = error;
322
+ throw IntegrationError.webOperationFailed('callProcedure', `Falha ao executar procedure: ${procedureName}`, err);
323
+ }
324
+ }
325
+ /**
326
+ * Chama função armazenada
327
+ */
328
+ async callFunction(functionName, parameters = []) {
329
+ if (!functionName.trim()) {
330
+ throw ValidationError.missingRequiredParameter('functionName');
331
+ }
332
+ const placeholders = parameters
333
+ .map((_, index) => `:${index + 2}`)
334
+ .join(', ');
335
+ const sql = `BEGIN :1 := ${functionName}(${placeholders}); END;`;
336
+ try {
337
+ // Adicionar parâmetro de saída no início
338
+ const allParameters = [
339
+ { dir: this.oracledb.BIND_OUT, type: this.oracledb.STRING },
340
+ ...parameters,
341
+ ];
342
+ const result = await this.connection.execute(sql, allParameters);
343
+ return result.outBinds ? result.outBinds[0] : null;
344
+ }
345
+ catch (error) {
346
+ const err = error;
347
+ throw IntegrationError.webOperationFailed('callFunction', `Falha ao executar função: ${functionName}`, err);
348
+ }
349
+ }
350
+ /**
351
+ * Obtém a instância da conexão Oracle
352
+ * Para casos onde é necessário acessar funcionalidades específicas
353
+ */
354
+ getConnection() {
355
+ return this.connection;
356
+ }
357
+ /**
358
+ * Obtém o pool de conexões
359
+ */
360
+ getPool() {
361
+ return this.pool;
362
+ }
363
+ /**
364
+ * Executa consulta com cursor (para grandes volumes)
365
+ */
366
+ async *queryWithCursor(sql, parameters = [], batchSize = 1000) {
367
+ if (!this.isConnected()) {
368
+ throw ValidationError.invalidConfiguration('database', 'Banco não está conectado');
369
+ }
370
+ const connection = this.connection;
371
+ const result = await connection.execute(sql, parameters, {
372
+ resultSet: true,
373
+ });
374
+ const resultSet = result.resultSet;
375
+ try {
376
+ let rows;
377
+ do {
378
+ rows = await resultSet.getRows(batchSize);
379
+ if (rows.length > 0) {
380
+ yield rows;
381
+ }
382
+ } while (rows.length === batchSize);
383
+ }
384
+ finally {
385
+ await resultSet.close();
386
+ }
387
+ }
388
+ }
@@ -0,0 +1,192 @@
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 type { BrowserContext, Page } from '@playwright/test';
41
+ /**
42
+ * Interface para drivers web
43
+ */
44
+ export interface IWebDriver {
45
+ navigate(url: string, options?: {
46
+ timeout?: number;
47
+ }): Promise<void>;
48
+ click(selector: string, options?: {
49
+ timeout?: number;
50
+ }): Promise<void>;
51
+ fill(selector: string, value: string, options?: {
52
+ timeout?: number;
53
+ }): Promise<void>;
54
+ getText(selector: string): Promise<string>;
55
+ getAttribute(selector: string, attribute: string): Promise<string | null>;
56
+ isVisible(selector: string): Promise<boolean>;
57
+ isEnabled(selector: string): Promise<boolean>;
58
+ waitForElement(selector: string, options?: {
59
+ timeout?: number;
60
+ state?: 'visible' | 'hidden' | 'attached' | 'detached';
61
+ }): Promise<void>;
62
+ selectOption(selector: string, value: string): Promise<void>;
63
+ hover(selector: string): Promise<void>;
64
+ doubleClick(selector: string): Promise<void>;
65
+ rightClick(selector: string): Promise<void>;
66
+ screenshot(options?: {
67
+ path?: string;
68
+ fullPage?: boolean;
69
+ }): Promise<Buffer>;
70
+ setViewport(width: number, height: number): Promise<void>;
71
+ evaluateScript<T>(script: string): Promise<T>;
72
+ goBack(): Promise<void>;
73
+ goForward(): Promise<void>;
74
+ reload(): Promise<void>;
75
+ getCurrentUrl(): Promise<string>;
76
+ getTitle(): Promise<string>;
77
+ close(): Promise<void>;
78
+ }
79
+ /**
80
+ * Adaptador que integra Playwright com a arquitetura do AutoCore
81
+ * Implementa a interface IWebDriver usando Playwright como infraestrutura
82
+ */
83
+ export declare class PlaywrightAdapter implements IWebDriver {
84
+ private page;
85
+ private context?;
86
+ constructor(page: Page, context?: BrowserContext | undefined);
87
+ /**
88
+ * Navega para uma URL
89
+ */
90
+ navigate(url: string, options?: {
91
+ timeout?: number;
92
+ }): Promise<void>;
93
+ /**
94
+ * Clica em um elemento
95
+ */
96
+ click(selector: string, options?: {
97
+ timeout?: number;
98
+ }): Promise<void>;
99
+ /**
100
+ * Preenche um campo
101
+ */
102
+ fill(selector: string, value: string, options?: {
103
+ timeout?: number;
104
+ }): Promise<void>;
105
+ /**
106
+ * Obtém texto de um elemento
107
+ */
108
+ getText(selector: string): Promise<string>;
109
+ /**
110
+ * Obtém atributo de um elemento
111
+ */
112
+ getAttribute(selector: string, attribute: string): Promise<string | null>;
113
+ /**
114
+ * Verifica se elemento está visível
115
+ */
116
+ isVisible(selector: string): Promise<boolean>;
117
+ /**
118
+ * Verifica se elemento está habilitado
119
+ */
120
+ isEnabled(selector: string): Promise<boolean>;
121
+ /**
122
+ * Aguarda elemento ficar em estado específico
123
+ */
124
+ waitForElement(selector: string, options?: {
125
+ timeout?: number;
126
+ state?: 'visible' | 'hidden' | 'attached' | 'detached';
127
+ }): Promise<void>;
128
+ /**
129
+ * Seleciona opção em dropdown
130
+ */
131
+ selectOption(selector: string, value: string): Promise<void>;
132
+ /**
133
+ * Hover sobre elemento
134
+ */
135
+ hover(selector: string): Promise<void>;
136
+ /**
137
+ * Duplo clique
138
+ */
139
+ doubleClick(selector: string): Promise<void>;
140
+ /**
141
+ * Clique com botão direito
142
+ */
143
+ rightClick(selector: string): Promise<void>;
144
+ /**
145
+ * Captura screenshot
146
+ */
147
+ screenshot(options?: {
148
+ path?: string;
149
+ fullPage?: boolean;
150
+ }): Promise<Buffer>;
151
+ /**
152
+ * Define tamanho do viewport
153
+ */
154
+ setViewport(width: number, height: number): Promise<void>;
155
+ /**
156
+ * Executa JavaScript na página
157
+ */
158
+ evaluateScript<T>(script: string): Promise<T>;
159
+ /**
160
+ * Voltar página
161
+ */
162
+ goBack(): Promise<void>;
163
+ /**
164
+ * Avançar página
165
+ */
166
+ goForward(): Promise<void>;
167
+ /**
168
+ * Recarregar página
169
+ */
170
+ reload(): Promise<void>;
171
+ /**
172
+ * Obtém URL atual
173
+ */
174
+ getCurrentUrl(): Promise<string>;
175
+ /**
176
+ * Obtém título da página
177
+ */
178
+ getTitle(): Promise<string>;
179
+ /**
180
+ * Fecha a página
181
+ */
182
+ close(): Promise<void>;
183
+ /**
184
+ * Obtém a instância do Page do Playwright
185
+ * Para casos onde é necessário acessar funcionalidades específicas
186
+ */
187
+ getPage(): Page;
188
+ /**
189
+ * Obtém o contexto do browser
190
+ */
191
+ getContext(): BrowserContext | undefined;
192
+ }