@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,48 @@
1
+ /**
2
+ * ConfigurationError: Erros relacionados à configuração do framework
3
+ */
4
+ import { BaseError } from './BaseError.js';
5
+ export class ConfigurationError extends BaseError {
6
+ constructor(code, message, userMessage, originalError, context) {
7
+ const details = {
8
+ code,
9
+ message,
10
+ userMessage,
11
+ category: 'configuration',
12
+ severity: 'medium',
13
+ recoverable: true,
14
+ suggestions: [
15
+ 'Verifique os arquivos de configuração',
16
+ 'Consulte a documentação de configuração',
17
+ 'Use os valores padrão se disponíveis',
18
+ ],
19
+ documentation: 'https://docs.autocore.rbqa/configuration',
20
+ };
21
+ super(details, originalError, context);
22
+ }
23
+ static missingConfigFile(filePath, context) {
24
+ return new ConfigurationError('CFG_MISSING_CONFIG_FILE', `Configuration file not found: ${filePath}`, `Arquivo de configuração não encontrado: ${filePath}`, undefined, { ...context, metadata: { filePath } });
25
+ }
26
+ static invalidConfigFormat(filePath, error, context) {
27
+ return new ConfigurationError('CFG_INVALID_CONFIG_FORMAT', `Invalid configuration format in ${filePath}: ${error.message}`, `Formato de configuração inválido em ${filePath}.`, error, { ...context, metadata: { filePath } });
28
+ }
29
+ static missingEnvironmentVariable(varName, context) {
30
+ return new ConfigurationError('CFG_MISSING_ENV_VAR', `Missing required environment variable: ${varName}`, `Variável de ambiente obrigatória não definida: ${varName}`, undefined, { ...context, metadata: { varName } });
31
+ }
32
+ static invalidEnvironmentValue(varName, expectedFormat, context) {
33
+ return new ConfigurationError('CFG_INVALID_ENV_VALUE', `Invalid value for environment variable ${varName}, expected: ${expectedFormat}`, `Valor inválido para variável de ambiente ${varName}. Esperado: ${expectedFormat}`, undefined, { ...context, metadata: { varName, expectedFormat } });
34
+ }
35
+ static conflictingConfiguration(config1, config2, context) {
36
+ return new ConfigurationError('CFG_CONFLICTING_CONFIG', `Conflicting configuration between ${config1} and ${config2}`, `Configurações conflitantes entre ${config1} e ${config2}.`, undefined, { ...context, metadata: { config1, config2 } });
37
+ }
38
+ static unsupportedBrowserConfig(browser, context) {
39
+ return new ConfigurationError('CFG_UNSUPPORTED_BROWSER', `Unsupported browser configuration: ${browser}`, `Configuração de navegador não suportada: ${browser}`, undefined, { ...context, metadata: { browser } });
40
+ }
41
+ static invalidTestConfiguration(configKey, reason, context) {
42
+ return new ConfigurationError('CFG_INVALID_TEST_CONFIG', `Invalid test configuration for ${configKey}: ${reason}`, `Configuração de teste inválida para ${configKey}: ${reason}`, undefined, { ...context, metadata: { configKey, reason } });
43
+ }
44
+ static missingDependency(dependency, context) {
45
+ return new ConfigurationError('CFG_MISSING_DEPENDENCY', `Missing required dependency: ${dependency}`, `Dependência obrigatória não encontrada: ${dependency}`, undefined, { ...context, metadata: { dependency } });
46
+ }
47
+ }
48
+ export default ConfigurationError;
@@ -0,0 +1,148 @@
1
+ /**
2
+ * Catálogo centralizado de erros do framework AutoCore.
3
+ *
4
+ * Cada erro tem um código único, uma mensagem template e um nível de severidade.
5
+ * Isso padroniza mensagens de erro em todo o codebase.
6
+ *
7
+ * @module errors/ErrorCatalog
8
+ */
9
+ export type ErrorSeverity = 'critical' | 'error' | 'warning' | 'info';
10
+ export interface ErrorEntry {
11
+ code: string;
12
+ message: string;
13
+ severity: ErrorSeverity;
14
+ hint?: string;
15
+ }
16
+ /**
17
+ * Códigos de erro do framework.
18
+ * Formato: `AC-{AREA}-{NUMERO}`
19
+ * - AREA: WEB, MOB, API, CFG, SEC, REC, INT
20
+ * - NUMERO: 3 dígitos
21
+ */
22
+ export declare const ErrorCatalog: {
23
+ readonly 'AC-WEB-001': {
24
+ readonly code: "AC-WEB-001";
25
+ readonly message: "Elemento não encontrado: {selector}";
26
+ readonly severity: ErrorSeverity;
27
+ readonly hint: "Verifique se o XPath/CSS está correto e se a página carregou completamente.";
28
+ };
29
+ readonly 'AC-WEB-002': {
30
+ readonly code: "AC-WEB-002";
31
+ readonly message: "Timeout ao aguardar elemento: {selector} ({timeout}ms)";
32
+ readonly severity: ErrorSeverity;
33
+ readonly hint: "Aumente o timeout ou verifique se o elemento é renderizado condicionalmente.";
34
+ };
35
+ readonly 'AC-WEB-003': {
36
+ readonly code: "AC-WEB-003";
37
+ readonly message: "Múltiplos elementos encontrados para: {selector}";
38
+ readonly severity: ErrorSeverity;
39
+ readonly hint: "Use um seletor mais específico ou índice para selecionar o elemento correto.";
40
+ };
41
+ readonly 'AC-WEB-004': {
42
+ readonly code: "AC-WEB-004";
43
+ readonly message: "Navegação falhou para URL: {url}";
44
+ readonly severity: ErrorSeverity;
45
+ readonly hint: "Verifique se a URL está acessível e se não há bloqueio de rede/firewall.";
46
+ };
47
+ readonly 'AC-WEB-005': {
48
+ readonly code: "AC-WEB-005";
49
+ readonly message: "Frame não encontrado: {selector}";
50
+ readonly severity: ErrorSeverity;
51
+ readonly hint: "Verifique se o iframe existe e se o seletor aponta para o frame correto.";
52
+ };
53
+ readonly 'AC-MOB-001': {
54
+ readonly code: "AC-MOB-001";
55
+ readonly message: "Falha na conexão com o dispositivo: {device}";
56
+ readonly severity: ErrorSeverity;
57
+ readonly hint: "Verifique se o Appium está rodando e o dispositivo/emulador está conectado.";
58
+ };
59
+ readonly 'AC-MOB-002': {
60
+ readonly code: "AC-MOB-002";
61
+ readonly message: "App não encontrado: {appPath}";
62
+ readonly severity: ErrorSeverity;
63
+ readonly hint: "Verifique o caminho do APK/IPA e se o arquivo existe.";
64
+ };
65
+ readonly 'AC-API-001': {
66
+ readonly code: "AC-API-001";
67
+ readonly message: "URL inválida para requisição: {url}";
68
+ readonly severity: ErrorSeverity;
69
+ readonly hint: "A URL deve começar com http:// ou https:// e ser bem formada.";
70
+ };
71
+ readonly 'AC-API-002': {
72
+ readonly code: "AC-API-002";
73
+ readonly message: "Timeout na requisição API: {url} ({timeout}ms)";
74
+ readonly severity: ErrorSeverity;
75
+ readonly hint: "Aumente o timeout ou verifique a saúde do serviço alvo.";
76
+ };
77
+ readonly 'AC-API-003': {
78
+ readonly code: "AC-API-003";
79
+ readonly message: "Resposta inesperada: HTTP {status} de {url}";
80
+ readonly severity: ErrorSeverity;
81
+ };
82
+ readonly 'AC-CFG-001': {
83
+ readonly code: "AC-CFG-001";
84
+ readonly message: "Variável de ambiente obrigatória ausente: {variable}";
85
+ readonly severity: ErrorSeverity;
86
+ readonly hint: "Defina a variável no .env ou nas configurações do sistema.";
87
+ };
88
+ readonly 'AC-CFG-002': {
89
+ readonly code: "AC-CFG-002";
90
+ readonly message: "Arquivo de configuração não encontrado: {path}";
91
+ readonly severity: ErrorSeverity;
92
+ };
93
+ readonly 'AC-SEC-001': {
94
+ readonly code: "AC-SEC-001";
95
+ readonly message: "Certificado SSL inválido ou expirado";
96
+ readonly severity: ErrorSeverity;
97
+ readonly hint: "Configure HUB_IGNORE_SSL=true para ambientes de teste ou atualize o certificado.";
98
+ };
99
+ readonly 'AC-SEC-002': {
100
+ readonly code: "AC-SEC-002";
101
+ readonly message: "Dados sensíveis detectados no output — mascarando automaticamente";
102
+ readonly severity: ErrorSeverity;
103
+ };
104
+ readonly 'AC-REC-001': {
105
+ readonly code: "AC-REC-001";
106
+ readonly message: "Recovery bem-sucedido: {selector} → {newSelector} (tentativa {attempt})";
107
+ readonly severity: ErrorSeverity;
108
+ };
109
+ readonly 'AC-REC-002': {
110
+ readonly code: "AC-REC-002";
111
+ readonly message: "Recovery falhou após {attempts} tentativas para: {selector}";
112
+ readonly severity: ErrorSeverity;
113
+ readonly hint: "O elemento pode ter sido removido ou a página mudou significativamente.";
114
+ };
115
+ readonly 'AC-REC-003': {
116
+ readonly code: "AC-REC-003";
117
+ readonly message: "Serviço de recovery indisponível: {reason}";
118
+ readonly severity: ErrorSeverity;
119
+ readonly hint: "Verifique a conectividade com o backend e HUB_BACKEND_URL.";
120
+ };
121
+ readonly 'AC-INT-001': {
122
+ readonly code: "AC-INT-001";
123
+ readonly message: "Falha na conexão com o backend: {url}";
124
+ readonly severity: ErrorSeverity;
125
+ readonly hint: "Verifique HUB_BACKEND_URL e conectividade de rede.";
126
+ };
127
+ readonly 'AC-INT-002': {
128
+ readonly code: "AC-INT-002";
129
+ readonly message: "Teams flush falhou: {reason}";
130
+ readonly severity: ErrorSeverity;
131
+ readonly hint: "Verifique webhook URL, SSL corporativo e HUB_TEAMS_FLUSH_IGNORE_SSL.";
132
+ };
133
+ };
134
+ export type ErrorCode = keyof typeof ErrorCatalog;
135
+ /**
136
+ * Formata uma mensagem de erro do catálogo com parâmetros.
137
+ *
138
+ * @example
139
+ * ```ts
140
+ * formatError('AC-WEB-001', { selector: '//button[@id="submit"]' })
141
+ * // → '[AC-WEB-001] Elemento não encontrado: //button[@id="submit"]'
142
+ * ```
143
+ */
144
+ export declare function formatError(code: ErrorCode, params?: Record<string, string | number>): string;
145
+ /**
146
+ * Retorna a hint associada a um código de erro (se existir).
147
+ */
148
+ export declare function getErrorHint(code: ErrorCode): string | undefined;
@@ -0,0 +1,157 @@
1
+ /**
2
+ * Catálogo centralizado de erros do framework AutoCore.
3
+ *
4
+ * Cada erro tem um código único, uma mensagem template e um nível de severidade.
5
+ * Isso padroniza mensagens de erro em todo o codebase.
6
+ *
7
+ * @module errors/ErrorCatalog
8
+ */
9
+ /**
10
+ * Códigos de erro do framework.
11
+ * Formato: `AC-{AREA}-{NUMERO}`
12
+ * - AREA: WEB, MOB, API, CFG, SEC, REC, INT
13
+ * - NUMERO: 3 dígitos
14
+ */
15
+ export const ErrorCatalog = {
16
+ // ── Web/Playwright ─────────────────────────────────────────
17
+ 'AC-WEB-001': {
18
+ code: 'AC-WEB-001',
19
+ message: 'Elemento não encontrado: {selector}',
20
+ severity: 'error',
21
+ hint: 'Verifique se o XPath/CSS está correto e se a página carregou completamente.',
22
+ },
23
+ 'AC-WEB-002': {
24
+ code: 'AC-WEB-002',
25
+ message: 'Timeout ao aguardar elemento: {selector} ({timeout}ms)',
26
+ severity: 'error',
27
+ hint: 'Aumente o timeout ou verifique se o elemento é renderizado condicionalmente.',
28
+ },
29
+ 'AC-WEB-003': {
30
+ code: 'AC-WEB-003',
31
+ message: 'Múltiplos elementos encontrados para: {selector}',
32
+ severity: 'warning',
33
+ hint: 'Use um seletor mais específico ou índice para selecionar o elemento correto.',
34
+ },
35
+ 'AC-WEB-004': {
36
+ code: 'AC-WEB-004',
37
+ message: 'Navegação falhou para URL: {url}',
38
+ severity: 'error',
39
+ hint: 'Verifique se a URL está acessível e se não há bloqueio de rede/firewall.',
40
+ },
41
+ 'AC-WEB-005': {
42
+ code: 'AC-WEB-005',
43
+ message: 'Frame não encontrado: {selector}',
44
+ severity: 'error',
45
+ hint: 'Verifique se o iframe existe e se o seletor aponta para o frame correto.',
46
+ },
47
+ // ── Mobile ─────────────────────────────────────────────────
48
+ 'AC-MOB-001': {
49
+ code: 'AC-MOB-001',
50
+ message: 'Falha na conexão com o dispositivo: {device}',
51
+ severity: 'critical',
52
+ hint: 'Verifique se o Appium está rodando e o dispositivo/emulador está conectado.',
53
+ },
54
+ 'AC-MOB-002': {
55
+ code: 'AC-MOB-002',
56
+ message: 'App não encontrado: {appPath}',
57
+ severity: 'error',
58
+ hint: 'Verifique o caminho do APK/IPA e se o arquivo existe.',
59
+ },
60
+ // ── API ────────────────────────────────────────────────────
61
+ 'AC-API-001': {
62
+ code: 'AC-API-001',
63
+ message: 'URL inválida para requisição: {url}',
64
+ severity: 'error',
65
+ hint: 'A URL deve começar com http:// ou https:// e ser bem formada.',
66
+ },
67
+ 'AC-API-002': {
68
+ code: 'AC-API-002',
69
+ message: 'Timeout na requisição API: {url} ({timeout}ms)',
70
+ severity: 'error',
71
+ hint: 'Aumente o timeout ou verifique a saúde do serviço alvo.',
72
+ },
73
+ 'AC-API-003': {
74
+ code: 'AC-API-003',
75
+ message: 'Resposta inesperada: HTTP {status} de {url}',
76
+ severity: 'warning',
77
+ },
78
+ // ── Configuração ────────────────────────────────────────────
79
+ 'AC-CFG-001': {
80
+ code: 'AC-CFG-001',
81
+ message: 'Variável de ambiente obrigatória ausente: {variable}',
82
+ severity: 'critical',
83
+ hint: 'Defina a variável no .env ou nas configurações do sistema.',
84
+ },
85
+ 'AC-CFG-002': {
86
+ code: 'AC-CFG-002',
87
+ message: 'Arquivo de configuração não encontrado: {path}',
88
+ severity: 'error',
89
+ },
90
+ // ── Segurança ───────────────────────────────────────────────
91
+ 'AC-SEC-001': {
92
+ code: 'AC-SEC-001',
93
+ message: 'Certificado SSL inválido ou expirado',
94
+ severity: 'warning',
95
+ hint: 'Configure HUB_IGNORE_SSL=true para ambientes de teste ou atualize o certificado.',
96
+ },
97
+ 'AC-SEC-002': {
98
+ code: 'AC-SEC-002',
99
+ message: 'Dados sensíveis detectados no output — mascarando automaticamente',
100
+ severity: 'warning',
101
+ },
102
+ // ── Recovery ────────────────────────────────────────────────
103
+ 'AC-REC-001': {
104
+ code: 'AC-REC-001',
105
+ message: 'Recovery bem-sucedido: {selector} → {newSelector} (tentativa {attempt})',
106
+ severity: 'info',
107
+ },
108
+ 'AC-REC-002': {
109
+ code: 'AC-REC-002',
110
+ message: 'Recovery falhou após {attempts} tentativas para: {selector}',
111
+ severity: 'error',
112
+ hint: 'O elemento pode ter sido removido ou a página mudou significativamente.',
113
+ },
114
+ 'AC-REC-003': {
115
+ code: 'AC-REC-003',
116
+ message: 'Serviço de recovery indisponível: {reason}',
117
+ severity: 'warning',
118
+ hint: 'Verifique a conectividade com o backend e HUB_BACKEND_URL.',
119
+ },
120
+ // ── Integração ──────────────────────────────────────────────
121
+ 'AC-INT-001': {
122
+ code: 'AC-INT-001',
123
+ message: 'Falha na conexão com o backend: {url}',
124
+ severity: 'warning',
125
+ hint: 'Verifique HUB_BACKEND_URL e conectividade de rede.',
126
+ },
127
+ 'AC-INT-002': {
128
+ code: 'AC-INT-002',
129
+ message: 'Teams flush falhou: {reason}',
130
+ severity: 'warning',
131
+ hint: 'Verifique webhook URL, SSL corporativo e HUB_TEAMS_FLUSH_IGNORE_SSL.',
132
+ },
133
+ };
134
+ /**
135
+ * Formata uma mensagem de erro do catálogo com parâmetros.
136
+ *
137
+ * @example
138
+ * ```ts
139
+ * formatError('AC-WEB-001', { selector: '//button[@id="submit"]' })
140
+ * // → '[AC-WEB-001] Elemento não encontrado: //button[@id="submit"]'
141
+ * ```
142
+ */
143
+ export function formatError(code, params = {}) {
144
+ const entry = ErrorCatalog[code];
145
+ let msg = entry.message;
146
+ for (const [key, value] of Object.entries(params)) {
147
+ msg = msg.replace(`{${key}}`, String(value));
148
+ }
149
+ return `[${code}] ${msg}`;
150
+ }
151
+ /**
152
+ * Retorna a hint associada a um código de erro (se existir).
153
+ */
154
+ export function getErrorHint(code) {
155
+ const entry = ErrorCatalog[code];
156
+ return 'hint' in entry ? entry.hint : undefined;
157
+ }
@@ -0,0 +1,101 @@
1
+ /**
2
+ * GlobalErrorHandler: Sistema global de captura e tratamento de erros
3
+ * Gerencia erros não capturados e fornece logging e observabilidade
4
+ */
5
+ import { BaseError } from './BaseError.js';
6
+ export interface ErrorHandlerConfig {
7
+ enableConsoleLogging: boolean;
8
+ enableFileLogging: boolean;
9
+ logFilePath?: string;
10
+ enableObservability: boolean;
11
+ observabilityEndpoint?: string;
12
+ maxErrorsInMemory: number;
13
+ enableStackTrace: boolean;
14
+ enableUserFriendlyMessages: boolean;
15
+ }
16
+ export interface ErrorMetrics {
17
+ totalErrors: number;
18
+ errorsByCategory: Record<string, number>;
19
+ errorsBySeverity: Record<string, number>;
20
+ recentErrors: BaseError[];
21
+ startTime: number;
22
+ }
23
+ export declare class GlobalErrorHandler {
24
+ private static instance;
25
+ private config;
26
+ private errors;
27
+ private metrics;
28
+ private originalConsoleError;
29
+ private originalProcessListeners;
30
+ private constructor();
31
+ /**
32
+ * Obtém instância singleton do GlobalErrorHandler
33
+ */
34
+ static getInstance(config?: Partial<ErrorHandlerConfig>): GlobalErrorHandler;
35
+ /**
36
+ * Configura handlers globais para captura de erros
37
+ */
38
+ private setupGlobalHandlers;
39
+ /**
40
+ * Manuseia erro principal do sistema
41
+ */
42
+ handleError(error: Error | BaseError, context?: Record<string, unknown>): void;
43
+ /**
44
+ * Manuseia erros não capturados
45
+ */
46
+ private handleUncaughtError;
47
+ /**
48
+ * Manuseia rejeições não tratadas
49
+ */
50
+ private handleUnhandledRejection;
51
+ /**
52
+ * Manuseia logs de erro do console
53
+ */
54
+ private handleConsoleError;
55
+ /**
56
+ * Converte erro genérico para BaseError
57
+ */
58
+ private convertToBaseError;
59
+ /**
60
+ * Registra erro nos logs
61
+ */
62
+ private logError;
63
+ /**
64
+ * Escreve erro em arquivo de log
65
+ */
66
+ private writeToLogFile;
67
+ /**
68
+ * Atualiza métricas de erro
69
+ */
70
+ private updateMetrics;
71
+ /**
72
+ * Armazena erro na memória
73
+ */
74
+ private storeError;
75
+ /**
76
+ * Envia erro para sistema de observabilidade
77
+ */
78
+ private sendToObservability;
79
+ /**
80
+ * Obtém métricas atuais
81
+ */
82
+ getMetrics(): ErrorMetrics;
83
+ /**
84
+ * Obtém erros recentes
85
+ */
86
+ getRecentErrors(limit?: number): BaseError[];
87
+ /**
88
+ * Gera relatório de status
89
+ */
90
+ generateStatusReport(): string;
91
+ /**
92
+ * Limpa erros armazenados
93
+ */
94
+ clearErrors(): void;
95
+ /**
96
+ * Desativa handlers globais
97
+ */
98
+ dispose(): void;
99
+ }
100
+ export declare const globalErrorHandler: GlobalErrorHandler;
101
+ export default GlobalErrorHandler;