@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,121 @@
1
+ /**
2
+ * DynamicConfigManager: Injeção automática de configurações do sistema selecionado
3
+ * URLs, credenciais, hosts são injetados automaticamente em ApiActions, playwright.config, SSHClient, BancoHelper
4
+ * Integrado com AutoCore Hub para buscar configurações centralizadas
5
+ */
6
+ /**
7
+ * Gerenciador de configuração dinâmica
8
+ */
9
+ export declare class DynamicConfigManager {
10
+ private static instance;
11
+ private systemsManager;
12
+ private hubClient;
13
+ private constructor();
14
+ /**
15
+ * Obtém instância singleton
16
+ */
17
+ static getInstance(): DynamicConfigManager;
18
+ /**
19
+ * 🔧 Obtém configuração injetável para API
20
+ * Usado por ApiActions para pegar base URL automaticamente
21
+ */
22
+ getApiConfig(): {
23
+ baseUrl: string;
24
+ headers?: Record<string, string>;
25
+ } | null;
26
+ /**
27
+ * 🔧 Obtém configuração injetável para Frontend/Playwright
28
+ * Usado para injetar baseURL no playwright.config.ts
29
+ */
30
+ getPlaywrightConfig(): {
31
+ baseURL: string;
32
+ } | null;
33
+ /**
34
+ * 🔧 Obtém configuração injetável para SSH
35
+ * Usado por SSHClient para pegar host, user, password
36
+ */
37
+ getSSHConfig(): {
38
+ host: string;
39
+ port: number;
40
+ username: string;
41
+ password?: string;
42
+ privateKey?: string;
43
+ } | null;
44
+ /**
45
+ * 🔧 Obtém configuração injetável para Banco de Dados
46
+ * Usado por BancoHelper para pegar host, service, user, password
47
+ */
48
+ getDatabaseConfig(): {
49
+ host: string;
50
+ port: number;
51
+ serviceName: string;
52
+ user: string;
53
+ password: string;
54
+ } | null;
55
+ /**
56
+ * 🔧 Injeta configurações em variáveis de ambiente (fallback)
57
+ * Usado quando o usuário já tem código que lê de process.env
58
+ *
59
+ * 🆕 IMPORTANTE: Agora injeta baseado no PROJECT_TYPE do projeto,
60
+ * não no tipo do ambiente (PROD, PREPROD, etc.)
61
+ *
62
+ * 📋 VARIÁVEIS INJETADAS:
63
+ *
64
+ * SEMPRE (qualquer tipo):
65
+ * - URL, USERNAME, PASSWORD → Para TestHubVars.get('URL'), etc.
66
+ * - BASE_URL, BASE_URL_API → Para ApiActions, Playwright
67
+ * - HUB_USERNAME, HUB_PASSWORD → Credenciais universais
68
+ *
69
+ * SSH (PROJECT_TYPE=SSH):
70
+ * - SSH_HOST → IP/hostname do servidor (vem do campo 'url' do Hub)
71
+ * - SSH_PORT → Porta SSH (default: 22)
72
+ * - SSH_USER → Usuário SSH
73
+ * - SSH_PASSWORD → Senha SSH
74
+ *
75
+ * BANCO (PROJECT_TYPE=BANCO):
76
+ * - DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, DB_SERVICE_NAME
77
+ */
78
+ injectIntoEnvironment(): void;
79
+ /**
80
+ * 🔧 Obtém credenciais para uso em testes de autenticação
81
+ * Usado quando usuário precisa fazer login manualmente
82
+ */
83
+ getCredentials(): {
84
+ username: string;
85
+ password: string;
86
+ } | null;
87
+ /**
88
+ * 🔧 Valida se configuração do sistema é suficiente
89
+ */
90
+ validateConfig(requiredFields: string[]): {
91
+ valid: boolean;
92
+ missing: string[];
93
+ };
94
+ /**
95
+ * 🔧 Gera URL completa a partir de path relativo
96
+ * Ex: getFullUrl('/api/users') -> 'https://sistema.com/api/users'
97
+ */
98
+ getFullUrl(relativePath: string): string | null;
99
+ /**
100
+ * 🔧 Atualiza playwright.config.ts com baseURL automaticamente (em tempo de execução)
101
+ */
102
+ injectPlaywrightBaseUrl(): void;
103
+ /**
104
+ * 🔌 Testa conectividade com AutoCore Hub
105
+ */
106
+ testHubConnection(): Promise<boolean>;
107
+ /**
108
+ * 🔄 Recarrega configurações do AutoCore Hub
109
+ */
110
+ reloadFromHub(): Promise<void>;
111
+ /**
112
+ * 📊 Obtém estatísticas do AutoCore Hub
113
+ */
114
+ getHubStats(): Promise<{
115
+ totalSystems: number;
116
+ systemsLoaded: boolean;
117
+ hubConnected: boolean;
118
+ selectedSystem: string | null;
119
+ }>;
120
+ }
121
+ export default DynamicConfigManager;
@@ -0,0 +1,320 @@
1
+ /**
2
+ * DynamicConfigManager: Injeção automática de configurações do sistema selecionado
3
+ * URLs, credenciais, hosts são injetados automaticamente em ApiActions, playwright.config, SSHClient, BancoHelper
4
+ * Integrado com AutoCore Hub para buscar configurações centralizadas
5
+ */
6
+ import * as fs from 'fs';
7
+ import { Logger } from '../utils/Logger.js';
8
+ import { SystemsManager } from './SystemsManager.js';
9
+ import { TestHubClient } from './TestHubClient.js';
10
+ /**
11
+ * Gerenciador de configuração dinâmica
12
+ */
13
+ export class DynamicConfigManager {
14
+ static instance;
15
+ systemsManager;
16
+ hubClient;
17
+ constructor() {
18
+ this.systemsManager = SystemsManager.getInstance();
19
+ this.hubClient = TestHubClient.getInstance();
20
+ }
21
+ /**
22
+ * Obtém instância singleton
23
+ */
24
+ static getInstance() {
25
+ if (!DynamicConfigManager.instance) {
26
+ DynamicConfigManager.instance = new DynamicConfigManager();
27
+ }
28
+ return DynamicConfigManager.instance;
29
+ }
30
+ /**
31
+ * 🔧 Obtém configuração injetável para API
32
+ * Usado por ApiActions para pegar base URL automaticamente
33
+ */
34
+ getApiConfig() {
35
+ const systemConfig = this.systemsManager.getSystemConfig();
36
+ if (!systemConfig) {
37
+ return null;
38
+ }
39
+ return {
40
+ baseUrl: systemConfig.baseUrl,
41
+ headers: {},
42
+ };
43
+ }
44
+ /**
45
+ * 🔧 Obtém configuração injetável para Frontend/Playwright
46
+ * Usado para injetar baseURL no playwright.config.ts
47
+ */
48
+ getPlaywrightConfig() {
49
+ const systemConfig = this.systemsManager.getSystemConfig();
50
+ if (!systemConfig) {
51
+ return null;
52
+ }
53
+ return {
54
+ baseURL: systemConfig.baseUrl,
55
+ };
56
+ }
57
+ /**
58
+ * 🔧 Obtém configuração injetável para SSH
59
+ * Usado por SSHClient para pegar host, user, password
60
+ */
61
+ getSSHConfig() {
62
+ const systemConfig = this.systemsManager.getSystemConfig();
63
+ if (!systemConfig) {
64
+ return null;
65
+ }
66
+ let privateKey;
67
+ if (systemConfig.privateKeyPath &&
68
+ fs.existsSync(systemConfig.privateKeyPath)) {
69
+ privateKey = fs.readFileSync(systemConfig.privateKeyPath, 'utf-8');
70
+ }
71
+ return {
72
+ host: systemConfig.host || '',
73
+ port: Number.parseInt(systemConfig.port || '22', 10),
74
+ username: systemConfig.username || '',
75
+ password: systemConfig.password,
76
+ privateKey,
77
+ };
78
+ }
79
+ /**
80
+ * 🔧 Obtém configuração injetável para Banco de Dados
81
+ * Usado por BancoHelper para pegar host, service, user, password
82
+ */
83
+ getDatabaseConfig() {
84
+ const systemConfig = this.systemsManager.getSystemConfig();
85
+ if (!systemConfig) {
86
+ return null;
87
+ }
88
+ return {
89
+ host: systemConfig.host || '',
90
+ port: Number.parseInt(systemConfig.port || '1521', 10),
91
+ serviceName: systemConfig.serviceName || '',
92
+ user: systemConfig.username || '',
93
+ password: systemConfig.password || '',
94
+ };
95
+ }
96
+ /**
97
+ * 🔧 Injeta configurações em variáveis de ambiente (fallback)
98
+ * Usado quando o usuário já tem código que lê de process.env
99
+ *
100
+ * 🆕 IMPORTANTE: Agora injeta baseado no PROJECT_TYPE do projeto,
101
+ * não no tipo do ambiente (PROD, PREPROD, etc.)
102
+ *
103
+ * 📋 VARIÁVEIS INJETADAS:
104
+ *
105
+ * SEMPRE (qualquer tipo):
106
+ * - URL, USERNAME, PASSWORD → Para TestHubVars.get('URL'), etc.
107
+ * - BASE_URL, BASE_URL_API → Para ApiActions, Playwright
108
+ * - HUB_USERNAME, HUB_PASSWORD → Credenciais universais
109
+ *
110
+ * SSH (PROJECT_TYPE=SSH):
111
+ * - SSH_HOST → IP/hostname do servidor (vem do campo 'url' do Hub)
112
+ * - SSH_PORT → Porta SSH (default: 22)
113
+ * - SSH_USER → Usuário SSH
114
+ * - SSH_PASSWORD → Senha SSH
115
+ *
116
+ * BANCO (PROJECT_TYPE=BANCO):
117
+ * - DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, DB_SERVICE_NAME
118
+ */
119
+ injectIntoEnvironment() {
120
+ const systemConfig = this.systemsManager.getSystemConfig();
121
+ if (!systemConfig) {
122
+ return;
123
+ }
124
+ const selectedSystem = this.systemsManager.getSelectedSystem();
125
+ if (!selectedSystem) {
126
+ return;
127
+ }
128
+ // 🆕 Obter tipo de projeto da variável de ambiente
129
+ const projectType = process.env.PROJECT_TYPE?.toUpperCase();
130
+ // ═══════════════════════════════════════════════════════════════════
131
+ // 🌐 VARIÁVEIS UNIVERSAIS - Sempre injetadas (para TestHubVars)
132
+ // ═══════════════════════════════════════════════════════════════════
133
+ // URL: Para Frontend/API é a URL HTTP, para SSH é o host
134
+ if (systemConfig.baseUrl) {
135
+ process.env.URL = systemConfig.baseUrl;
136
+ process.env.BASE_URL = systemConfig.baseUrl;
137
+ process.env.BASE_URL_API = systemConfig.baseUrl;
138
+ process.env.AUTOCORE_HUB_SYSTEM_URL = systemConfig.baseUrl;
139
+ }
140
+ // USERNAME e PASSWORD: Universais para qualquer tipo
141
+ if (systemConfig.username) {
142
+ process.env.USERNAME = systemConfig.username;
143
+ process.env.HUB_USERNAME = systemConfig.username;
144
+ }
145
+ if (systemConfig.password) {
146
+ process.env.PASSWORD = systemConfig.password;
147
+ process.env.HUB_PASSWORD = systemConfig.password;
148
+ }
149
+ // PORT: Porta do serviço
150
+ if (systemConfig.port) {
151
+ process.env.PORT = systemConfig.port;
152
+ }
153
+ // ═══════════════════════════════════════════════════════════════════
154
+ // 🔌 SSH: Variáveis específicas quando o sistema contém informações de SSH
155
+ // Injectar mesmo que PROJECT_TYPE não seja 'SSH' quando o sistema tiver campos SSH
156
+ // ═══════════════════════════════════════════════════════════════════
157
+ const systemHasSshInfo = !!(systemConfig.privateKeyPath ||
158
+ systemConfig.username ||
159
+ systemConfig.password ||
160
+ (systemConfig.baseUrl && !systemConfig.baseUrl.startsWith('http')) ||
161
+ systemConfig.host);
162
+ if (projectType === 'SSH' || systemHasSshInfo) {
163
+ // Para SSH, o campo 'url' do Hub pode conter o HOST (IP ou hostname)
164
+ const sshHost = systemConfig.baseUrl?.replace(/^https?:\/\//, '').split('/')[0] || systemConfig.host;
165
+ if (sshHost) {
166
+ process.env.SSH_HOST = sshHost;
167
+ }
168
+ if (systemConfig.port) {
169
+ process.env.SSH_PORT = systemConfig.port;
170
+ }
171
+ else {
172
+ process.env.SSH_PORT = '22'; // Default SSH port
173
+ }
174
+ if (systemConfig.username) {
175
+ process.env.SSH_USER = systemConfig.username;
176
+ }
177
+ if (systemConfig.password) {
178
+ process.env.SSH_PASSWORD = systemConfig.password;
179
+ }
180
+ // Se o sistema tiver caminho para chave privada, expor caminho absoluto em SSH_KEY_PATH
181
+ if (systemConfig.privateKeyPath) {
182
+ const possiblePath = systemConfig.privateKeyPath;
183
+ // Se for relativo, resolver a partir do cwd
184
+ const absoluteKeyPath = require('path').isAbsolute(possiblePath)
185
+ ? possiblePath
186
+ : require('path').resolve(process.cwd(), possiblePath);
187
+ if (require('fs').existsSync(absoluteKeyPath)) {
188
+ process.env.SSH_KEY_PATH = absoluteKeyPath;
189
+ Logger.info(`🔑 SSH key path detected and injected: ${process.env.SSH_KEY_PATH}`);
190
+ }
191
+ else {
192
+ Logger.warning(`⚠️ SSH key path configured in Hub not found on disk: ${absoluteKeyPath}`);
193
+ }
194
+ }
195
+ }
196
+ // ═══════════════════════════════════════════════════════════════════
197
+ // 🗄️ BANCO: Variáveis específicas quando PROJECT_TYPE=BANCO
198
+ // ═══════════════════════════════════════════════════════════════════
199
+ if (projectType === 'BANCO' || projectType === 'DATABASE') {
200
+ const dbHost = systemConfig.baseUrl?.replace(/^https?:\/\//, '').split('/')[0] || systemConfig.host;
201
+ if (dbHost) {
202
+ process.env.DB_HOST = dbHost;
203
+ }
204
+ if (systemConfig.port) {
205
+ process.env.DB_PORT = systemConfig.port;
206
+ }
207
+ else {
208
+ process.env.DB_PORT = '1521'; // Default Oracle port
209
+ }
210
+ if (systemConfig.serviceName) {
211
+ process.env.DB_SERVICE_NAME = systemConfig.serviceName;
212
+ }
213
+ if (systemConfig.username) {
214
+ process.env.DB_USER = systemConfig.username;
215
+ }
216
+ if (systemConfig.password) {
217
+ process.env.DB_PASSWORD = systemConfig.password;
218
+ }
219
+ Logger.info(`🗄️ [BANCO] Credenciais do Hub injetadas:`);
220
+ Logger.info(` Host: ${process.env.DB_HOST}:${process.env.DB_PORT}`);
221
+ Logger.info(` User: ${process.env.DB_USER}`);
222
+ }
223
+ // Configurações gerais do AutoCore Hub
224
+ process.env.AUTOCORE_HUB_SYSTEM_NAME = selectedSystem.name;
225
+ process.env.AUTOCORE_HUB_ENVIRONMENT = selectedSystem.environmentName;
226
+ }
227
+ /**
228
+ * 🔧 Obtém credenciais para uso em testes de autenticação
229
+ * Usado quando usuário precisa fazer login manualmente
230
+ */
231
+ getCredentials() {
232
+ const systemConfig = this.systemsManager.getSystemConfig();
233
+ if (!(systemConfig && systemConfig.username && systemConfig.password)) {
234
+ return null;
235
+ }
236
+ return {
237
+ username: systemConfig.username,
238
+ password: systemConfig.password,
239
+ };
240
+ }
241
+ /**
242
+ * 🔧 Valida se configuração do sistema é suficiente
243
+ */
244
+ validateConfig(requiredFields) {
245
+ const systemConfig = this.systemsManager.getSystemConfig();
246
+ if (!systemConfig) {
247
+ return {
248
+ valid: false,
249
+ missing: ['Sistema não selecionado'],
250
+ };
251
+ }
252
+ const missing = [];
253
+ const configMap = systemConfig;
254
+ for (const field of requiredFields) {
255
+ if (!configMap[field]) {
256
+ missing.push(field);
257
+ }
258
+ }
259
+ return {
260
+ valid: missing.length === 0,
261
+ missing,
262
+ };
263
+ }
264
+ /**
265
+ * 🔧 Gera URL completa a partir de path relativo
266
+ * Ex: getFullUrl('/api/users') -> 'https://sistema.com/api/users'
267
+ */
268
+ getFullUrl(relativePath) {
269
+ const systemConfig = this.systemsManager.getSystemConfig();
270
+ if (!systemConfig) {
271
+ return null;
272
+ }
273
+ const baseUrl = systemConfig.baseUrl.replace(/\/$/, ''); // Remove trailing slash
274
+ const path = relativePath.startsWith('/')
275
+ ? relativePath
276
+ : `/${relativePath}`;
277
+ return `${baseUrl}${path}`;
278
+ }
279
+ /**
280
+ * 🔧 Atualiza playwright.config.ts com baseURL automaticamente (em tempo de execução)
281
+ */
282
+ injectPlaywrightBaseUrl() {
283
+ const playwrightConfig = this.getPlaywrightConfig();
284
+ if (!playwrightConfig) {
285
+ return;
286
+ }
287
+ // Injetar em process.env para playwright.config.ts pegar
288
+ process.env.AUTOCORE_BASE_URL = playwrightConfig.baseURL;
289
+ Logger.info(`🔧 baseURL injetado no Playwright via AutoCore Hub: ${playwrightConfig.baseURL}`);
290
+ }
291
+ /**
292
+ * 🔌 Testa conectividade com AutoCore Hub
293
+ */
294
+ async testHubConnection() {
295
+ Logger.info('🔌 Testando conectividade com AutoCore Hub...');
296
+ return await this.hubClient.testConnection();
297
+ }
298
+ /**
299
+ * 🔄 Recarrega configurações do AutoCore Hub
300
+ */
301
+ async reloadFromHub() {
302
+ Logger.info('🔄 Recarregando configurações do AutoCore Hub...');
303
+ await this.systemsManager.reload();
304
+ }
305
+ /**
306
+ * 📊 Obtém estatísticas do AutoCore Hub
307
+ */
308
+ async getHubStats() {
309
+ const systems = await this.systemsManager.listSystems();
310
+ const selectedSystem = this.systemsManager.getSelectedSystem();
311
+ const hubConnected = await this.hubClient.testConnection();
312
+ return {
313
+ totalSystems: systems.length,
314
+ systemsLoaded: systems.length > 0,
315
+ hubConnected,
316
+ selectedSystem: selectedSystem?.name || null,
317
+ };
318
+ }
319
+ }
320
+ export default DynamicConfigManager;
@@ -0,0 +1,119 @@
1
+ /**
2
+ * SystemsManager: Gerenciador de sistemas com IntelliSense dinâmico
3
+ * Busca sistemas do backend e cria enum dinâmico para autocomplete
4
+ */
5
+ import { type TestHubEnvironment, type TestHubSystem } from './TestHubClient.js';
6
+ /**
7
+ * Sistema selecionado pelo usuário
8
+ */
9
+ export interface SelectedSystem {
10
+ name: string;
11
+ system: TestHubSystem;
12
+ environment: TestHubEnvironment;
13
+ environmentName: string;
14
+ }
15
+ /**
16
+ * Gerenciador de sistemas com suporte a IntelliSense
17
+ */
18
+ export declare class SystemsManager {
19
+ private static instance;
20
+ private client;
21
+ private selectedSystem;
22
+ private systemsLoaded;
23
+ private systems;
24
+ private constructor();
25
+ /**
26
+ * Obtém instância singleton
27
+ */
28
+ static getInstance(): SystemsManager;
29
+ /**
30
+ * 🚀 Inicializa o gerenciador e busca sistemas do backend
31
+ */
32
+ initialize(): Promise<void>;
33
+ /**
34
+ * 📝 Gera arquivo TypeScript com enum Systems para IntelliSense
35
+ *
36
+ * ESTRATÉGIA: Salva enum em .rbqa/SystemsEnum.ts no projeto consumidor
37
+ * para que possa ser importado sem modificar source files do framework
38
+ */
39
+ private generateSystemsEnum; /**
40
+ * Gera conteúdo do enum TypeScript
41
+ */
42
+ private generateEnumContent;
43
+ /**
44
+ * Sanitiza nome do sistema para usar como chave de enum
45
+ * IMPORTANTE: Preserva o formato original se já for válido (ex: AUTENTICA_IN_HML)
46
+ */
47
+ private sanitizeEnumKey;
48
+ /**
49
+ * 🎯 Seleciona um sistema para uso nos testes
50
+ * @param systemName Nome do sistema
51
+ * @param environmentName Nome do ambiente (ex: 'preprod', 'esteira1')
52
+ * @param projectType Tipo de projeto (API, Frontend, etc) para filtrar ambientes
53
+ */
54
+ selectSystem(systemName: string, environmentName?: string, projectType?: TestHubEnvironment['type']): Promise<SelectedSystem>;
55
+ /**
56
+ * Obtém sistema selecionado atual
57
+ */
58
+ getSelectedSystem(): SelectedSystem | null;
59
+ /**
60
+ * Verifica se um sistema foi selecionado
61
+ */
62
+ hasSystemSelected(): boolean;
63
+ /**
64
+ * Valida se sistema foi selecionado (lança erro se não)
65
+ */
66
+ validateSystemSelected(): void;
67
+ /**
68
+ * Lista todos os sistemas disponíveis
69
+ */
70
+ listSystems(): Promise<TestHubSystem[]>;
71
+ /**
72
+ * Lista sistemas por tipo
73
+ */
74
+ listSystemsByType(type: TestHubEnvironment['type']): Promise<TestHubSystem[]>;
75
+ /**
76
+ * Limpa seleção atual
77
+ */
78
+ clearSelection(): void;
79
+ /**
80
+ * Recarrega sistemas do backend (força atualização)
81
+ */
82
+ reload(): Promise<void>;
83
+ /**
84
+ * Obtém configuração do sistema selecionado (para injeção automática)
85
+ */
86
+ getSystemConfig(): {
87
+ baseUrl: string;
88
+ username?: string;
89
+ password?: string;
90
+ host?: string;
91
+ port?: string;
92
+ serviceName?: string;
93
+ privateKeyPath?: string;
94
+ } | null;
95
+ }
96
+ /**
97
+ * 🌐 Enum Systems com Lazy Loading
98
+ *
99
+ * Este enum é populado dinamicamente quando você usa TestAnnotations.setSystem()
100
+ * pela primeira vez. Ele carrega os sistemas do AutoCore Hub automaticamente.
101
+ *
102
+ * ✅ USO RECOMENDADO:
103
+ *
104
+ * import { TestAnnotations, Systems } from "@silasfmartins/testhub"
105
+ *
106
+ * test("Meu teste", async ({}, testInfo) => {
107
+ * TestAnnotations.Api.testInfo = testInfo
108
+ *
109
+ * // Opção 1: String direta (sempre funciona)
110
+ * await TestAnnotations.setSystem("AUTENTICA_IN_HML")
111
+ *
112
+ * // Opção 2: Enum (após primeira execução)
113
+ * await TestAnnotations.setSystem(Systems.AUTENTICA_IN_HML)
114
+ * })
115
+ *
116
+ * 💡 O enum Systems é populado automaticamente na primeira chamada de setSystem()
117
+ */
118
+ export declare const Systems: Record<string, string>;
119
+ export default SystemsManager;