@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,264 @@
1
+ /**
2
+ * CodeGen Session Manager (v2.7.44 - items 15 & 16)
3
+ *
4
+ * Mantém uma única sessão Playwright MCP por execução de CT para que o
5
+ * codegen capture todo o fluxo real em vez de "sempre o mesmo código".
6
+ *
7
+ * Item 15 – Fluxo contínuo na mesma sessão:
8
+ * 1. start() → inicia sessão única
9
+ * 2. execute() → navega/click/fill na mesma sessão
10
+ * 3. codegenPreview() / codegenExport() → gera artefato
11
+ * 4. close() → encerra sessão
12
+ *
13
+ * Item 16 – Modo recorder (interação manual):
14
+ * 1. startRecording() → habilita captura de eventos no browser
15
+ * 2. (usuário interage manualmente na página)
16
+ * 3. stopRecording() → coleta eventos e converte em capturedElements
17
+ * 4. codegenExport() → gera código a partir dos eventos gravados
18
+ */
19
+ import { Logger } from './Logger.js';
20
+ import { callMcpToolLocalFirst } from './McpLocalClient.js';
21
+ let _transport = null;
22
+ // ---------------------------------------------------------------------------
23
+ // CodeGenSession
24
+ // ---------------------------------------------------------------------------
25
+ export class CodeGenSession {
26
+ active = false;
27
+ recording = false;
28
+ recordedEvents = [];
29
+ options = {};
30
+ // ---------- Transport ----------
31
+ /** Injeta a função de transporte MCP (obrigatório antes de usar) */
32
+ static setTransport(fn) {
33
+ _transport = fn;
34
+ }
35
+ async call(action, params) {
36
+ if (!_transport) {
37
+ throw new Error('[CodeGenSession] Transporte MCP não configurado. Chame CodeGenSession.setTransport() antes de usar.');
38
+ }
39
+ const result = await _transport(action, params);
40
+ // (item 27.4) Reroute automático quando backend requer MCP local
41
+ if (!result.success &&
42
+ result.requiresLocalMcp === true) {
43
+ Logger.info(`[CodeGenSession] Backend requer MCP local para action='${action}', reencaminhando...`);
44
+ const localResult = await callMcpToolLocalFirst('codegen', { action, ...(params || {}) });
45
+ if (localResult?.result && typeof localResult.result === 'object') {
46
+ return localResult.result;
47
+ }
48
+ }
49
+ return result;
50
+ }
51
+ // ---------- Item 15 — Sessão contínua ----------
52
+ /**
53
+ * Inicia (ou reutiliza) uma sessão Playwright MCP.
54
+ * Não reinicia browser/context/page — preserva `capturedElements`.
55
+ * Reinicia apenas com `fromScratch=true` ou `resetSession=true` (item 15/27.5).
56
+ */
57
+ async start(opts) {
58
+ const shouldReset = opts?.fromScratch || opts?.resetSession;
59
+ if (this.active && !shouldReset) {
60
+ Logger.info('[CodeGenSession] Sessão já ativa, reutilizando (sessionReused=true).');
61
+ return { success: true };
62
+ }
63
+ // Se reset explícito, fechar sessão atual antes de iniciar nova
64
+ if (this.active && shouldReset) {
65
+ Logger.info('[CodeGenSession] Reset explícito solicitado, fechando sessão atual...');
66
+ await this.close();
67
+ }
68
+ this.options = opts ?? {};
69
+ const params = {};
70
+ if (this.options.headless != null)
71
+ params.headless = this.options.headless;
72
+ if (this.options.ignoreSSL)
73
+ params.ignoreSSL = true;
74
+ const res = await this.call('start', params);
75
+ this.active = true;
76
+ Logger.info('[CodeGenSession] Sessão Playwright MCP iniciada (sessionCreated=true).');
77
+ // Navegar automaticamente se URL inicial fornecida
78
+ if (this.options.startUrl) {
79
+ await this.execute('navigate', { url: this.options.startUrl });
80
+ }
81
+ return res;
82
+ }
83
+ /**
84
+ * Executa uma ação na sessão ativa (navigate/click/fill/select/…).
85
+ */
86
+ async execute(action, params) {
87
+ if (!this.active) {
88
+ await this.start(this.options);
89
+ }
90
+ return this.call(action, params);
91
+ }
92
+ /**
93
+ * Gera preview do código capturado (inspeção).
94
+ */
95
+ async codegenPreview() {
96
+ return this.call('codegen_preview');
97
+ }
98
+ /**
99
+ * Exporta código capturado (Playwright puro ou framework).
100
+ */
101
+ async codegenExport(target = 'both') {
102
+ return this.call('codegen_export', { codegenTarget: target });
103
+ }
104
+ /**
105
+ * Gera código com alvo específico (alias conveniente).
106
+ */
107
+ async codegen(target = 'both') {
108
+ return this.call('codegen', { codegenTarget: target });
109
+ }
110
+ /**
111
+ * Encerra a sessão. Chamar somente APÓS etapa de codegen.
112
+ */
113
+ async close() {
114
+ if (!this.active)
115
+ return;
116
+ try {
117
+ await this.call('close');
118
+ }
119
+ catch (err) {
120
+ Logger.warning(`[CodeGenSession] Erro ao fechar sessão: ${err}`);
121
+ }
122
+ finally {
123
+ this.active = false;
124
+ this.recording = false;
125
+ this.recordedEvents = [];
126
+ }
127
+ Logger.info('[CodeGenSession] Sessão encerrada.');
128
+ }
129
+ /** Verifica se a sessão está ativa */
130
+ isActive() {
131
+ return this.active;
132
+ }
133
+ // ---------- Item 16 — Modo recorder ----------
134
+ /**
135
+ * Inicia gravação de eventos de interação manual.
136
+ * Injeta um listener de eventos na página ativa que captura
137
+ * click/fill/select/check/uncheck/press.
138
+ */
139
+ async startRecording() {
140
+ if (!this.active)
141
+ await this.start(this.options);
142
+ if (this.recording)
143
+ return;
144
+ this.recordedEvents = [];
145
+ this.recording = true;
146
+ // Injetar script de captura na página via MCP
147
+ try {
148
+ await this.call('evaluate', {
149
+ expression: RECORDER_INJECT_SCRIPT,
150
+ });
151
+ }
152
+ catch {
153
+ // Se evaluate não for suportado, apenas marcar como recording
154
+ }
155
+ Logger.info('[CodeGenSession] Gravação de interações iniciada.');
156
+ }
157
+ /**
158
+ * Para a gravação e coleta os eventos capturados do browser.
159
+ * Faz flush para `capturedElements` internamente.
160
+ */
161
+ async stopRecording() {
162
+ if (!this.recording)
163
+ return [];
164
+ this.recording = false;
165
+ // Coletar eventos do browser
166
+ try {
167
+ const result = await this.call('evaluate', {
168
+ expression: '(() => { const e = window.__autocore_recorded || []; window.__autocore_recorded = []; return e; })()',
169
+ });
170
+ const events = Array.isArray(result.data) ? result.data : [];
171
+ for (const ev of events) {
172
+ if (ev && typeof ev === 'object' && 'action' in ev) {
173
+ this.recordedEvents.push({
174
+ action: ev.action,
175
+ selector: ev.selector,
176
+ xpath: ev.xpath,
177
+ value: ev.value,
178
+ pageUrl: ev.pageUrl,
179
+ pageTitle: ev.pageTitle,
180
+ timestamp: ev.timestamp || Date.now(),
181
+ });
182
+ }
183
+ }
184
+ }
185
+ catch {
186
+ // Coleta via MCP não disponível — usar eventos já registrados
187
+ }
188
+ Logger.info(`[CodeGenSession] Gravação parada. ${this.recordedEvents.length} evento(s) capturado(s).`);
189
+ return [...this.recordedEvents];
190
+ }
191
+ /** Registra manualmente um evento (para integração programática) */
192
+ addEvent(event) {
193
+ this.recordedEvents.push(event);
194
+ }
195
+ /** Retorna todos os eventos gravados */
196
+ getRecordedEvents() {
197
+ return [...this.recordedEvents];
198
+ }
199
+ /** Limpa eventos gravados */
200
+ clearEvents() {
201
+ this.recordedEvents = [];
202
+ }
203
+ }
204
+ // ---------------------------------------------------------------------------
205
+ // Script injetado na página para captura de interações (item 16)
206
+ // ---------------------------------------------------------------------------
207
+ const RECORDER_INJECT_SCRIPT = `
208
+ (() => {
209
+ if (window.__autocore_recorder_active) return;
210
+ window.__autocore_recorder_active = true;
211
+ window.__autocore_recorded = window.__autocore_recorded || [];
212
+
213
+ const getSelector = (el) => {
214
+ if (!el || !el.tagName) return '';
215
+ if (el.id) return '//*[@id="' + el.id + '"]';
216
+ if (el.getAttribute('data-testid')) return '//*[@data-testid="' + el.getAttribute('data-testid') + '"]';
217
+ if (el.getAttribute('name')) return '//' + el.tagName.toLowerCase() + '[@name="' + el.getAttribute('name') + '"]';
218
+ return '';
219
+ };
220
+
221
+ document.addEventListener('click', (e) => {
222
+ const el = e.target;
223
+ window.__autocore_recorded.push({
224
+ action: 'click',
225
+ selector: getSelector(el),
226
+ xpath: getSelector(el),
227
+ value: undefined,
228
+ pageUrl: location.href,
229
+ pageTitle: document.title,
230
+ timestamp: Date.now(),
231
+ });
232
+ }, true);
233
+
234
+ document.addEventListener('change', (e) => {
235
+ const el = e.target;
236
+ const tag = el.tagName && el.tagName.toLowerCase();
237
+ const action = tag === 'select' ? 'select'
238
+ : (el.type === 'checkbox' ? (el.checked ? 'check' : 'uncheck') : 'fill');
239
+ window.__autocore_recorded.push({
240
+ action,
241
+ selector: getSelector(el),
242
+ xpath: getSelector(el),
243
+ value: el.value || undefined,
244
+ pageUrl: location.href,
245
+ pageTitle: document.title,
246
+ timestamp: Date.now(),
247
+ });
248
+ }, true);
249
+
250
+ document.addEventListener('keydown', (e) => {
251
+ if (['Enter', 'Tab', 'Escape'].includes(e.key)) {
252
+ window.__autocore_recorded.push({
253
+ action: 'press',
254
+ selector: getSelector(e.target),
255
+ xpath: getSelector(e.target),
256
+ value: e.key,
257
+ pageUrl: location.href,
258
+ pageTitle: document.title,
259
+ timestamp: Date.now(),
260
+ });
261
+ }
262
+ }, true);
263
+ })()
264
+ `;
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Gerenciador de logs de configuração para Playwright
3
+ * Fornece informações detalhadas sobre configurações e ambiente
4
+ * ATUALIZADO: Integrado com a nova arquitetura unificada
5
+ */
6
+ export declare class ConfigLogger {
7
+ private static logFile;
8
+ private static projectName;
9
+ private static logToFile;
10
+ private static initialized;
11
+ private static startTime;
12
+ /**
13
+ * Inicializa o logger de configurações
14
+ * @param options Opções de inicialização
15
+ */
16
+ static init(options?: {
17
+ projectName?: string;
18
+ logToFile?: boolean;
19
+ logDir?: string;
20
+ }): void;
21
+ /**
22
+ * Obtém o nome do projeto do package.json
23
+ */
24
+ private static getProjectNameFromPackageJson;
25
+ /**
26
+ * Escreve no arquivo de log
27
+ */
28
+ private static appendToLogFile;
29
+ /**
30
+ * Registra log informativo
31
+ */
32
+ static info(message: string): void;
33
+ /**
34
+ * Registra log de sucesso
35
+ */
36
+ static success(message: string): void;
37
+ /**
38
+ * Registra log de aviso
39
+ */
40
+ static warning(message: string): void;
41
+ /**
42
+ * Registra log de erro
43
+ */
44
+ static error(message: string, error?: any): void;
45
+ /**
46
+ * Registra log crítico (erro grave que pode impedir a execução)
47
+ */
48
+ static critical(message: string, error?: any): void;
49
+ /**
50
+ * Registra resumo da configuração do ambiente
51
+ */
52
+ static logEnvironmentConfig(): void;
53
+ /**
54
+ * Registra variáveis de ambiente relevantes para o projeto
55
+ */
56
+ static logEnvironmentVariables(): void;
57
+ /**
58
+ * NOVO: Log específico para variáveis Mobile
59
+ */
60
+ private static logMobileVariables;
61
+ /**
62
+ * NOVO: Log específico para variáveis SSH
63
+ */
64
+ private static logSSHVariables;
65
+ /**
66
+ * NOVO: Log específico para variáveis de Banco
67
+ */
68
+ private static logDatabaseVariables;
69
+ /**
70
+ * Retorna o caminho do arquivo de lock usado para evitar inicialização múltipla
71
+ */
72
+ private static getLockFilePath;
73
+ /**
74
+ * Verifica se o ConfigLogger já foi executado antes (evita inicialização múltipla)
75
+ */
76
+ private static hasRunBefore;
77
+ /**
78
+ * Marca o ConfigLogger como já inicializado
79
+ */
80
+ private static markAsRun;
81
+ /**
82
+ * Limpa o estado e arquivos temporários do ConfigLogger
83
+ */
84
+ static cleanup(): void;
85
+ /**
86
+ * Registra informações sobre o Playwright (versão otimizada)
87
+ */
88
+ static logPlaywrightConfig(): void;
89
+ /**
90
+ * Lê e extrai informações do arquivo de configuração do Playwright
91
+ * sem executar comandos externos (apenas parsing de texto)
92
+ */
93
+ private static readPlaywrightConfigFile;
94
+ /**
95
+ * Extrai informações de configuração do conteúdo do arquivo usando regex
96
+ * (parsing simples sem executar código)
97
+ */
98
+ private static parseConfigContent;
99
+ /**
100
+ * NOVO: Gera relatório de configuração do projeto
101
+ */
102
+ static generateProjectReport(): {
103
+ projectName: string;
104
+ projectType?: string;
105
+ environment?: string;
106
+ configuredFeatures: string[];
107
+ missingFeatures: string[];
108
+ };
109
+ /**
110
+ * NOVO: Log do relatório de projeto
111
+ */
112
+ static logProjectReport(): void;
113
+ /**
114
+ * 🚀 Inicia execução de um método com separador visual
115
+ */
116
+ static methodStart(methodName: string, className?: string, params?: any[]): void;
117
+ /**
118
+ * ✅ Finaliza execução de um método
119
+ */
120
+ static methodEnd(methodName: string, className?: string, success?: boolean, duration?: number): void;
121
+ /**
122
+ * 📋 Log simples de método com separador pequeno
123
+ */
124
+ static methodLog(methodName: string, className?: string): void;
125
+ /**
126
+ * 🎯 Log de separação entre grupos de métodos
127
+ */
128
+ static sectionSeparator(sectionName: string): void;
129
+ /**
130
+ * 📖 Wrapper para executar método com logs automáticos
131
+ */
132
+ static executeWithLogs<T>(methodName: string, className: string, method: () => Promise<T> | T, params?: any[]): Promise<T>;
133
+ }