@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,116 @@
1
+ /**
2
+ * TestHubVars: Acesso simplificado às variáveis de ambiente do TestHub
3
+ *
4
+ * Permite acessar variáveis cadastradas no AutoCore Hub de forma similar ao padrão Java:
5
+ * - Java: SFAConstants.URLSALESFORCE.getItem()
6
+ * - TypeScript: await TestHubVars.get('URLSALESFORCE')
7
+ *
8
+ * O sistema e ambiente são detectados automaticamente a partir de:
9
+ * - TestAnnotations.setSystem() - define o sistema atual
10
+ * - process.env.NODE_ENV ou process.env.ENV - define o ambiente
11
+ */
12
+ /**
13
+ * Classe para acesso simplificado às variáveis do TestHub
14
+ *
15
+ * @example
16
+ * // No .spec.ts
17
+ * await TestAnnotations.setSystem('SALESFORCE')
18
+ *
19
+ * // Na Page/Statement
20
+ * const url = await TestHubVars.get('URLSALESFORCE')
21
+ * await WebActions.navegarPara(url, 'Navegando para Salesforce', false)
22
+ *
23
+ * // Ou de forma mais direta
24
+ * await WebActions.navegarPara(
25
+ * await TestHubVars.get('URLSALESFORCE'),
26
+ * 'Navegando para Salesforce',
27
+ * false
28
+ * )
29
+ */
30
+ export declare class TestHubVars {
31
+ private static cache;
32
+ private static cacheDuration;
33
+ private static loadedEnvKeys;
34
+ /**
35
+ * 🔑 Obtém o valor de uma variável de ambiente do sistema atual
36
+ *
37
+ * @param variableKey Nome da variável (ex: 'URLSALESFORCE', 'API_TOKEN')
38
+ * @param defaultValue Valor padrão se a variável não existir
39
+ * @returns Valor da variável ou defaultValue
40
+ *
41
+ * @example
42
+ * // Uso básico
43
+ * const url = await TestHubVars.get('URLSALESFORCE')
44
+ *
45
+ * // Com valor padrão
46
+ * const timeout = await TestHubVars.get('TIMEOUT', '30000')
47
+ *
48
+ * // Em navegação - usar assim:
49
+ * const baseUrl = await TestHubVars.get('BASE_URL')
50
+ * await WebActions.navegarPara(baseUrl, 'Navegando', false)
51
+ */
52
+ static get(variableKey: string, defaultValue?: string): Promise<string>;
53
+ /**
54
+ * 🔑 Obtém múltiplas variáveis de uma vez
55
+ *
56
+ * @param variableKeys Array de nomes de variáveis
57
+ * @returns Objeto com chave-valor das variáveis
58
+ *
59
+ * @example
60
+ * const vars = await TestHubVars.getMany(['BASE_URL', 'API_TOKEN', 'TIMEOUT'])
61
+ * Logger.info(vars.BASE_URL)
62
+ */
63
+ static getMany(variableKeys: string[]): Promise<Record<string, string>>;
64
+ /**
65
+ * 🌍 Carrega todas as variáveis em process.env
66
+ *
67
+ * @param prefix Prefixo opcional (ex: 'TESTHUB_')
68
+ * @returns Número de variáveis carregadas
69
+ *
70
+ * @example
71
+ * await TestHubVars.loadToEnv()
72
+ * Logger.info(process.env.BASE_URL)
73
+ *
74
+ * await TestHubVars.loadToEnv('TESTHUB_')
75
+ * Logger.info(process.env.TESTHUB_BASE_URL)
76
+ */
77
+ static loadToEnv(prefix?: string): Promise<number>;
78
+ /**
79
+ * 🧹 Limpa o cache de variáveis
80
+ */
81
+ static clearCache(): void;
82
+ /**
83
+ * 🔄 Força recarregamento das variáveis
84
+ */
85
+ static refresh(): Promise<void>;
86
+ /**
87
+ * Obtém informações do sistema atual configurado
88
+ */
89
+ private static getCurrentSystemInfo;
90
+ /**
91
+ * Detecta o ambiente atual baseado em variáveis de ambiente
92
+ */
93
+ private static detectEnvironment;
94
+ /**
95
+ * Verifica se o cache é válido
96
+ */
97
+ private static isCacheValid;
98
+ /**
99
+ * Carrega variáveis do TestHub para o cache
100
+ */
101
+ private static loadVariables;
102
+ }
103
+ /**
104
+ * Alias curto para TestHubVars.get()
105
+ *
106
+ * @example
107
+ * import { getVar } from '@silasfmartins/testhub'
108
+ *
109
+ * const url = await getVar('URLSALESFORCE')
110
+ */
111
+ export declare const getVar: typeof TestHubVars.get;
112
+ /**
113
+ * Alias curto para TestHubVars
114
+ */
115
+ export declare const Vars: typeof TestHubVars;
116
+ export default TestHubVars;
@@ -0,0 +1,273 @@
1
+ /**
2
+ * TestHubVars: Acesso simplificado às variáveis de ambiente do TestHub
3
+ *
4
+ * Permite acessar variáveis cadastradas no AutoCore Hub de forma similar ao padrão Java:
5
+ * - Java: SFAConstants.URLSALESFORCE.getItem()
6
+ * - TypeScript: await TestHubVars.get('URLSALESFORCE')
7
+ *
8
+ * O sistema e ambiente são detectados automaticamente a partir de:
9
+ * - TestAnnotations.setSystem() - define o sistema atual
10
+ * - process.env.NODE_ENV ou process.env.ENV - define o ambiente
11
+ */
12
+ import { TestHubClient } from './TestHubClient.js';
13
+ import SystemsManager from './SystemsManager.js';
14
+ import { Logger } from '../utils/Logger.js';
15
+ /**
16
+ * Classe para acesso simplificado às variáveis do TestHub
17
+ *
18
+ * @example
19
+ * // No .spec.ts
20
+ * await TestAnnotations.setSystem('SALESFORCE')
21
+ *
22
+ * // Na Page/Statement
23
+ * const url = await TestHubVars.get('URLSALESFORCE')
24
+ * await WebActions.navegarPara(url, 'Navegando para Salesforce', false)
25
+ *
26
+ * // Ou de forma mais direta
27
+ * await WebActions.navegarPara(
28
+ * await TestHubVars.get('URLSALESFORCE'),
29
+ * 'Navegando para Salesforce',
30
+ * false
31
+ * )
32
+ */
33
+ export class TestHubVars {
34
+ static cache = null;
35
+ static cacheDuration = 5 * 60 * 1000; // 5 minutos
36
+ // keys that were loaded into process.env by TestHubVars.loadToEnv (full key names, including prefix if used)
37
+ static loadedEnvKeys = new Set();
38
+ /**
39
+ * 🔑 Obtém o valor de uma variável de ambiente do sistema atual
40
+ *
41
+ * @param variableKey Nome da variável (ex: 'URLSALESFORCE', 'API_TOKEN')
42
+ * @param defaultValue Valor padrão se a variável não existir
43
+ * @returns Valor da variável ou defaultValue
44
+ *
45
+ * @example
46
+ * // Uso básico
47
+ * const url = await TestHubVars.get('URLSALESFORCE')
48
+ *
49
+ * // Com valor padrão
50
+ * const timeout = await TestHubVars.get('TIMEOUT', '30000')
51
+ *
52
+ * // Em navegação - usar assim:
53
+ * const baseUrl = await TestHubVars.get('BASE_URL')
54
+ * await WebActions.navegarPara(baseUrl, 'Navegando', false)
55
+ */
56
+ static async get(variableKey, defaultValue) {
57
+ try {
58
+ // Prioridade 1: apenas considerar valores em process.env se foram carregados pelo TestHubVars.loadToEnv()
59
+ // Isso evita pegar variáveis locais do usuário (ex: USERNAME) quando não vieram do Hub.
60
+ const upKey = variableKey.toUpperCase();
61
+ if (this.loadedEnvKeys.has(variableKey) || this.loadedEnvKeys.has(upKey)) {
62
+ const envValue = process.env[variableKey] || process.env[upKey];
63
+ if (envValue) {
64
+ Logger.info(`🔎 TestHubVars: variável ${variableKey} encontrada em process.env (carregada do Hub)`);
65
+ return envValue;
66
+ }
67
+ }
68
+ // Obter sistema e ambiente atuais
69
+ const { systemName, environmentName } = this.getCurrentSystemInfo();
70
+ if (!systemName || !environmentName) {
71
+ // 🆕 Se não tem sistema, ainda tenta process.env
72
+ Logger.error(`⚠️ Sistema não configurado. Use TestAnnotations.setSystem() primeiro.`);
73
+ return defaultValue || '';
74
+ }
75
+ // Verificar cache
76
+ if (this.isCacheValid(systemName, environmentName)) {
77
+ const cachedValue = this.cache.variables.get(variableKey.toUpperCase());
78
+ if (cachedValue !== undefined) {
79
+ return cachedValue;
80
+ }
81
+ }
82
+ // Buscar variáveis do TestHub
83
+ await this.loadVariables(systemName, environmentName);
84
+ // Retornar valor
85
+ const value = this.cache?.variables.get(variableKey.toUpperCase());
86
+ if (value !== undefined) {
87
+ Logger.info(`🔎 TestHubVars: variável ${variableKey} obtida do Portal Hub (${systemName}/${environmentName})`);
88
+ return value;
89
+ }
90
+ // Se não encontrou, tentar busca case-insensitive
91
+ for (const [key, val] of this.cache?.variables || []) {
92
+ if (key.toLowerCase() === variableKey.toLowerCase()) {
93
+ return val;
94
+ }
95
+ }
96
+ Logger.error(`⚠️ Variável "${variableKey}" não encontrada em ${systemName}/${environmentName}`);
97
+ return defaultValue || '';
98
+ }
99
+ catch (error) {
100
+ Logger.error(`❌ Erro ao obter variável "${variableKey}":`, error);
101
+ return defaultValue || '';
102
+ }
103
+ }
104
+ /**
105
+ * 🔑 Obtém múltiplas variáveis de uma vez
106
+ *
107
+ * @param variableKeys Array de nomes de variáveis
108
+ * @returns Objeto com chave-valor das variáveis
109
+ *
110
+ * @example
111
+ * const vars = await TestHubVars.getMany(['BASE_URL', 'API_TOKEN', 'TIMEOUT'])
112
+ * Logger.info(vars.BASE_URL)
113
+ */
114
+ static async getMany(variableKeys) {
115
+ const result = {};
116
+ for (const key of variableKeys) {
117
+ result[key] = await this.get(key);
118
+ }
119
+ return result;
120
+ }
121
+ /**
122
+ * 🌍 Carrega todas as variáveis em process.env
123
+ *
124
+ * @param prefix Prefixo opcional (ex: 'TESTHUB_')
125
+ * @returns Número de variáveis carregadas
126
+ *
127
+ * @example
128
+ * await TestHubVars.loadToEnv()
129
+ * Logger.info(process.env.BASE_URL)
130
+ *
131
+ * await TestHubVars.loadToEnv('TESTHUB_')
132
+ * Logger.info(process.env.TESTHUB_BASE_URL)
133
+ */
134
+ static async loadToEnv(prefix = '') {
135
+ const { systemName, environmentName } = this.getCurrentSystemInfo();
136
+ if (!systemName || !environmentName) {
137
+ Logger.error('⚠️ Sistema não configurado');
138
+ return 0;
139
+ }
140
+ const client = TestHubClient.getInstance();
141
+ const variables = await client.getEnvironmentVariables(systemName, environmentName);
142
+ let loaded = 0;
143
+ for (const variable of variables) {
144
+ const envKey = prefix ? `${prefix}${variable.key}` : variable.key;
145
+ process.env[envKey] = variable.value;
146
+ this.loadedEnvKeys.add(envKey);
147
+ this.loadedEnvKeys.add(envKey.toUpperCase());
148
+ loaded++;
149
+ Logger.info(` ✅ ${envKey} carregada`);
150
+ }
151
+ Logger.info(`📦 ${loaded} variável(is) carregada(s) em process.env`);
152
+ return loaded;
153
+ }
154
+ /**
155
+ * 🧹 Limpa o cache de variáveis
156
+ */
157
+ static clearCache() {
158
+ this.cache = null;
159
+ Logger.info('🧹 Cache de variáveis limpo');
160
+ }
161
+ /**
162
+ * 🔄 Força recarregamento das variáveis
163
+ */
164
+ static async refresh() {
165
+ this.clearCache();
166
+ const { systemName, environmentName } = this.getCurrentSystemInfo();
167
+ if (systemName && environmentName) {
168
+ await this.loadVariables(systemName, environmentName);
169
+ Logger.info('🔄 Variáveis recarregadas');
170
+ }
171
+ }
172
+ // ============================================
173
+ // Métodos privados
174
+ // ============================================
175
+ /**
176
+ * Obtém informações do sistema atual configurado
177
+ */
178
+ static getCurrentSystemInfo() {
179
+ try {
180
+ const systemsManager = SystemsManager.getInstance();
181
+ const selectedSystem = systemsManager.getSelectedSystem();
182
+ if (selectedSystem) {
183
+ return {
184
+ systemName: selectedSystem.name,
185
+ environmentName: selectedSystem.environmentName,
186
+ };
187
+ }
188
+ // Do NOT fallback to process.env here. The env.ts module is responsible for local env variables.
189
+ // Require explicit selection via SystemsManager (e.g. TestAnnotations.setSystem()).
190
+ return { systemName: '', environmentName: '' };
191
+ }
192
+ catch {
193
+ return { systemName: '', environmentName: '' };
194
+ }
195
+ }
196
+ /**
197
+ * Detecta o ambiente atual baseado em variáveis de ambiente
198
+ */
199
+ static detectEnvironment() {
200
+ // Ordem de precedência
201
+ const env = process.env.AUTOCORE_ENVIRONMENT ||
202
+ process.env.ENV ||
203
+ process.env.NODE_ENV ||
204
+ 'preprod';
205
+ // Mapear nomes comuns para nomes do TestHub
206
+ const envMap = {
207
+ 'production': 'Prod',
208
+ 'prod': 'Prod',
209
+ 'staging': 'Homolog',
210
+ 'homolog': 'Homolog',
211
+ 'hml': 'Homolog',
212
+ 'development': 'Dev',
213
+ 'dev': 'Dev',
214
+ 'preprod': 'Preprod',
215
+ 'uat': 'UAT',
216
+ 'esteira1': 'Esteira1',
217
+ 'esteira2': 'Esteira2',
218
+ };
219
+ return envMap[env.toLowerCase()] || env;
220
+ }
221
+ /**
222
+ * Verifica se o cache é válido
223
+ */
224
+ static isCacheValid(systemName, environmentName) {
225
+ if (!this.cache)
226
+ return false;
227
+ const isSameSystem = this.cache.systemName === systemName &&
228
+ this.cache.environmentName === environmentName;
229
+ const isNotExpired = Date.now() - this.cache.timestamp < this.cacheDuration;
230
+ return isSameSystem && isNotExpired;
231
+ }
232
+ /**
233
+ * Carrega variáveis do TestHub para o cache
234
+ */
235
+ static async loadVariables(systemName, environmentName) {
236
+ if (this.isCacheValid(systemName, environmentName)) {
237
+ return;
238
+ }
239
+ Logger.info(`📥 Carregando variáveis de ${systemName}/${environmentName}...`);
240
+ const client = TestHubClient.getInstance();
241
+ const variables = await client.getEnvironmentVariables(systemName, environmentName);
242
+ // Criar novo cache
243
+ this.cache = {
244
+ systemName,
245
+ environmentName,
246
+ variables: new Map(),
247
+ timestamp: Date.now(),
248
+ };
249
+ // Popular cache
250
+ for (const variable of variables) {
251
+ this.cache.variables.set(variable.key.toUpperCase(), variable.value);
252
+ }
253
+ Logger.info(`✅ ${variables.length} variável(is) carregada(s) no cache`);
254
+ Logger.info(`ℹ️ TestHubVars: variáveis carregadas do Portal Hub para ${systemName}/${environmentName}`);
255
+ }
256
+ }
257
+ // ============================================
258
+ // Alias para uso mais simples
259
+ // ============================================
260
+ /**
261
+ * Alias curto para TestHubVars.get()
262
+ *
263
+ * @example
264
+ * import { getVar } from '@silasfmartins/testhub'
265
+ *
266
+ * const url = await getVar('URLSALESFORCE')
267
+ */
268
+ export const getVar = TestHubVars.get.bind(TestHubVars);
269
+ /**
270
+ * Alias curto para TestHubVars
271
+ */
272
+ export const Vars = TestHubVars;
273
+ export default TestHubVars;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * 🔧 Sistema de Interceptação para Captura Automática de Evidências
3
+ * @description Intercepta ações do WebActions, MobileActions e ApiActions para capturar evidências
4
+ * @author TestHUB Team
5
+ * @version 1.0.0
6
+ */
7
+ export declare class ActionInterceptor {
8
+ private static isInitialized;
9
+ private static interceptedMethods;
10
+ /**
11
+ * ✅ Inicializa os interceptadores
12
+ */
13
+ static initialize(): void;
14
+ /**
15
+ * ✅ Intercepta WebActions
16
+ */
17
+ private static interceptWebActions;
18
+ /**
19
+ * ✅ Intercepta DesktopActions
20
+ */
21
+ private static interceptDesktopActions;
22
+ /**
23
+ * ✅ Intercepta MobileActions
24
+ */
25
+ private static interceptMobileActions;
26
+ /**
27
+ * 🚫 Intercepta ApiActions - DESABILITADO
28
+ * Métodos do ApiActions são internos e não devem ser capturados como CTs
29
+ */
30
+ private static interceptApiActions;
31
+ /**
32
+ * ✅ Intercepta um método específico
33
+ */
34
+ private static interceptMethod;
35
+ /**
36
+ * ✅ Gera descrição amigável da ação
37
+ */
38
+ private static generateActionDescription;
39
+ /**
40
+ * ✅ Gera descrição para ações Web
41
+ */
42
+ private static generateWebDescription;
43
+ /**
44
+ * ✅ Gera descrição para ações Mobile
45
+ */
46
+ private static generateMobileDescription;
47
+ /**
48
+ * ✅ Gera descrição para ações API
49
+ */
50
+ private static generateApiDescription;
51
+ /**
52
+ * ✅ Extrai seletor de diferentes tipos
53
+ */
54
+ private static extractSelector;
55
+ /**
56
+ * ✅ Força o refresh da página
57
+ */
58
+ private static forceRefresh;
59
+ }