@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.
- package/.github/copilot-instructions.md +520 -0
- package/biome.json +37 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +169 -0
- package/dist/scripts/consumer-postinstall.d.ts +15 -0
- package/dist/scripts/consumer-postinstall.js +785 -0
- package/dist/scripts/generate-docs.d.ts +16 -0
- package/dist/scripts/generate-docs.js +1363 -0
- package/dist/scripts/generate-index.d.ts +2 -0
- package/dist/scripts/generate-index.js +314 -0
- package/dist/scripts/init-api.d.ts +2 -0
- package/dist/scripts/init-api.js +525 -0
- package/dist/scripts/init-banco.d.ts +2 -0
- package/dist/scripts/init-banco.js +347 -0
- package/dist/scripts/init-frontend.d.ts +2 -0
- package/dist/scripts/init-frontend.js +627 -0
- package/dist/scripts/init-mobile.d.ts +2 -0
- package/dist/scripts/init-mobile.js +481 -0
- package/dist/scripts/init-scenarios.d.ts +2 -0
- package/dist/scripts/init-scenarios.js +846 -0
- package/dist/scripts/init-ssh.d.ts +2 -0
- package/dist/scripts/init-ssh.js +639 -0
- package/dist/scripts/package-versions.d.ts +57 -0
- package/dist/scripts/package-versions.js +768 -0
- package/dist/scripts/postinstall.d.ts +1 -0
- package/dist/scripts/postinstall.js +527 -0
- package/dist/scripts/robust-build.d.ts +7 -0
- package/dist/scripts/robust-build.js +88 -0
- package/dist/scripts/setup-local-packages.d.ts +31 -0
- package/dist/scripts/setup-local-packages.js +237 -0
- package/dist/scripts/smart-override.d.ts +2 -0
- package/dist/scripts/smart-override.js +1360 -0
- package/dist/scripts/sync-configs.d.ts +27 -0
- package/dist/scripts/sync-configs.js +248 -0
- package/dist/scripts/test-biome-parse.d.ts +5 -0
- package/dist/scripts/test-biome-parse.js +84 -0
- package/dist/scripts/ultracite-setup.d.ts +4 -0
- package/dist/scripts/ultracite-setup.js +310 -0
- package/dist/scripts/update-all-init-scripts.d.ts +2 -0
- package/dist/scripts/update-all-init-scripts.js +52 -0
- package/dist/scripts/update-biome-schema.d.ts +15 -0
- package/dist/scripts/update-biome-schema.js +124 -0
- package/dist/src/AutoCoreFacade.d.ts +145 -0
- package/dist/src/AutoCoreFacade.js +217 -0
- package/dist/src/api/ApiActions.d.ts +297 -0
- package/dist/src/api/ApiActions.js +1905 -0
- package/dist/src/api/Certificate.d.ts +60 -0
- package/dist/src/api/Certificate.js +79 -0
- package/dist/src/api/JsonResponse.d.ts +116 -0
- package/dist/src/api/JsonResponse.js +206 -0
- package/dist/src/appium/DeviceFarmViewer.d.ts +79 -0
- package/dist/src/appium/DeviceFarmViewer.js +1083 -0
- package/dist/src/appium/MobileActions.d.ts +347 -0
- package/dist/src/appium/MobileActions.js +1632 -0
- package/dist/src/appium/MobileConnection.d.ts +160 -0
- package/dist/src/appium/MobileConnection.js +772 -0
- package/dist/src/config/envLoader.d.ts +123 -0
- package/dist/src/config/envLoader.js +361 -0
- package/dist/src/config/jest-safe-setup.d.ts +19 -0
- package/dist/src/config/jest-safe-setup.js +369 -0
- package/dist/src/config/timeouts.d.ts +32 -0
- package/dist/src/config/timeouts.js +38 -0
- package/dist/src/desktop/DesktopActions.d.ts +46 -0
- package/dist/src/desktop/DesktopActions.js +398 -0
- package/dist/src/desktop/DesktopConnection.d.ts +32 -0
- package/dist/src/desktop/DesktopConnection.js +84 -0
- package/dist/src/domain/entities/TestExecution.d.ts +117 -0
- package/dist/src/domain/entities/TestExecution.js +150 -0
- package/dist/src/domain/entities/TestReport.d.ts +114 -0
- package/dist/src/domain/entities/TestReport.js +179 -0
- package/dist/src/domain/repositories/ITestRepository.d.ts +196 -0
- package/dist/src/domain/repositories/ITestRepository.js +14 -0
- package/dist/src/domain/schemas/ValidationSchemas.d.ts +159 -0
- package/dist/src/domain/schemas/ValidationSchemas.js +181 -0
- package/dist/src/functions/errors/BaseError.d.ts +78 -0
- package/dist/src/functions/errors/BaseError.js +245 -0
- package/dist/src/functions/errors/ConfigurationError.d.ts +16 -0
- package/dist/src/functions/errors/ConfigurationError.js +48 -0
- package/dist/src/functions/errors/ErrorCatalog.d.ts +148 -0
- package/dist/src/functions/errors/ErrorCatalog.js +157 -0
- package/dist/src/functions/errors/GlobalErrorHandler.d.ts +101 -0
- package/dist/src/functions/errors/GlobalErrorHandler.js +281 -0
- package/dist/src/functions/errors/IntegrationError.d.ts +17 -0
- package/dist/src/functions/errors/IntegrationError.js +51 -0
- package/dist/src/functions/errors/SecurityError.d.ts +14 -0
- package/dist/src/functions/errors/SecurityError.js +42 -0
- package/dist/src/functions/errors/SystemError.d.ts +12 -0
- package/dist/src/functions/errors/SystemError.js +36 -0
- package/dist/src/functions/errors/ValidationError.d.ts +14 -0
- package/dist/src/functions/errors/ValidationError.js +61 -0
- package/dist/src/functions/errors/index.d.ts +12 -0
- package/dist/src/functions/errors/index.js +13 -0
- package/dist/src/global-setup.d.ts +1 -0
- package/dist/src/global-setup.js +1037 -0
- package/dist/src/helpers/BancoActions.d.ts +188 -0
- package/dist/src/helpers/BancoActions.js +581 -0
- package/dist/src/helpers/EnviromentHelper.d.ts +17 -0
- package/dist/src/helpers/EnviromentHelper.js +66 -0
- package/dist/src/helpers/ParallelExecutionHelper.d.ts +183 -0
- package/dist/src/helpers/ParallelExecutionHelper.js +375 -0
- package/dist/src/helpers/SyncSignal.d.ts +15 -0
- package/dist/src/helpers/SyncSignal.js +44 -0
- package/dist/src/hubdocs/CategoryDetector.d.ts +83 -0
- package/dist/src/hubdocs/CategoryDetector.js +401 -0
- package/dist/src/hubdocs/DirectStatementInterceptor.d.ts +54 -0
- package/dist/src/hubdocs/DirectStatementInterceptor.js +243 -0
- package/dist/src/hubdocs/ExecutionTracker.d.ts +107 -0
- package/dist/src/hubdocs/ExecutionTracker.js +702 -0
- package/dist/src/hubdocs/HubDocs.d.ts +395 -0
- package/dist/src/hubdocs/HubDocs.js +3586 -0
- package/dist/src/hubdocs/StatementMethodFilter.d.ts +71 -0
- package/dist/src/hubdocs/StatementMethodFilter.js +618 -0
- package/dist/src/hubdocs/StatementTracker.d.ts +417 -0
- package/dist/src/hubdocs/StatementTracker.js +2419 -0
- package/dist/src/hubdocs/SwaggerGenerator.d.ts +59 -0
- package/dist/src/hubdocs/SwaggerGenerator.js +405 -0
- package/dist/src/hubdocs/index.d.ts +9 -0
- package/dist/src/hubdocs/index.js +9 -0
- package/dist/src/hubdocs/types.d.ts +114 -0
- package/dist/src/hubdocs/types.js +5 -0
- package/dist/src/infrastructure/DependencyContainer.d.ts +142 -0
- package/dist/src/infrastructure/DependencyContainer.js +250 -0
- package/dist/src/infrastructure/adapters/AppiumAdapter.d.ts +168 -0
- package/dist/src/infrastructure/adapters/AppiumAdapter.js +468 -0
- package/dist/src/infrastructure/adapters/OracleAdapter.d.ts +150 -0
- package/dist/src/infrastructure/adapters/OracleAdapter.js +388 -0
- package/dist/src/infrastructure/adapters/PlaywrightAdapter.d.ts +192 -0
- package/dist/src/infrastructure/adapters/PlaywrightAdapter.js +382 -0
- package/dist/src/infrastructure/adapters/SSHAdapter.d.ts +141 -0
- package/dist/src/infrastructure/adapters/SSHAdapter.js +428 -0
- package/dist/src/interfaces.d.ts +501 -0
- package/dist/src/interfaces.js +25 -0
- package/dist/src/internal/fakes/__fake-actions__.d.ts +17 -0
- package/dist/src/internal/fakes/__fake-actions__.js +21 -0
- package/dist/src/internal/fakes/__forbidden__.d.ts +10 -0
- package/dist/src/internal/fakes/__forbidden__.js +18 -0
- package/dist/src/internal/fakes/__honeypot__.d.ts +15 -0
- package/dist/src/internal/fakes/__honeypot__.js +24 -0
- package/dist/src/octane/OctaneReporter.d.ts +13 -0
- package/dist/src/octane/OctaneReporter.js +61 -0
- package/dist/src/playwright/CryptoActions.d.ts +20 -0
- package/dist/src/playwright/CryptoActions.js +75 -0
- package/dist/src/playwright/EnhancedWebActions.d.ts +7 -0
- package/dist/src/playwright/EnhancedWebActions.js +65 -0
- package/dist/src/playwright/WebActions.d.ts +1599 -0
- package/dist/src/playwright/WebActions.js +11788 -0
- package/dist/src/playwright/actions/ActionTimeline.d.ts +36 -0
- package/dist/src/playwright/actions/ActionTimeline.js +101 -0
- package/dist/src/playwright/actions/RecoveryQueue.d.ts +82 -0
- package/dist/src/playwright/actions/RecoveryQueue.js +130 -0
- package/dist/src/playwright/actions/SelectorCache.d.ts +53 -0
- package/dist/src/playwright/actions/SelectorCache.js +96 -0
- package/dist/src/playwright/actions/index.d.ts +13 -0
- package/dist/src/playwright/actions/index.js +14 -0
- package/dist/src/playwright/actions/types.d.ts +147 -0
- package/dist/src/playwright/actions/types.js +5 -0
- package/dist/src/playwright/fixtures.d.ts +112 -0
- package/dist/src/playwright/fixtures.js +718 -0
- package/dist/src/playwright/network-logs-reporter.d.ts +7 -0
- package/dist/src/playwright/network-logs-reporter.js +66 -0
- package/dist/src/playwright/registerRecoveryWrappers.d.ts +1 -0
- package/dist/src/playwright/registerRecoveryWrappers.js +54 -0
- package/dist/src/security/BuildSecurity.d.ts +12 -0
- package/dist/src/security/BuildSecurity.js +138 -0
- package/dist/src/security/EulaProtection.d.ts +70 -0
- package/dist/src/security/EulaProtection.js +155 -0
- package/dist/src/security/HoneypotManager.d.ts +46 -0
- package/dist/src/security/HoneypotManager.js +234 -0
- package/dist/src/security/KeysManager.d.ts +36 -0
- package/dist/src/security/KeysManager.js +158 -0
- package/dist/src/security/ProofOfWorkIntegration.d.ts +64 -0
- package/dist/src/security/ProofOfWorkIntegration.js +206 -0
- package/dist/src/security/SecurityValidation.d.ts +21 -0
- package/dist/src/security/SecurityValidation.js +163 -0
- package/dist/src/security/SourceMapProtection.d.ts +55 -0
- package/dist/src/security/SourceMapProtection.js +220 -0
- package/dist/src/security/protector.d.ts +1 -0
- package/dist/src/security/protector.js +97 -0
- package/dist/src/ssh/SSHActions.d.ts +262 -0
- package/dist/src/ssh/SSHActions.js +790 -0
- package/dist/src/ssh/SSHClient.d.ts +99 -0
- package/dist/src/ssh/SSHClient.js +409 -0
- package/dist/src/statements/BaseStatement.d.ts +38 -0
- package/dist/src/statements/BaseStatement.js +78 -0
- package/dist/src/testContext/AuthStateManager.d.ts +93 -0
- package/dist/src/testContext/AuthStateManager.js +256 -0
- package/dist/src/testContext/CoverageManager.d.ts +198 -0
- package/dist/src/testContext/CoverageManager.js +917 -0
- package/dist/src/testContext/TestAnnotations.d.ts +476 -0
- package/dist/src/testContext/TestAnnotations.js +2647 -0
- package/dist/src/testContext/TestContext.d.ts +138 -0
- package/dist/src/testContext/TestContext.js +369 -0
- package/dist/src/testContext/UnifiedHtmlGenerator.d.ts +7 -0
- package/dist/src/testContext/UnifiedHtmlGenerator.js +264 -0
- package/dist/src/testContext/UnifiedReportManager.d.ts +211 -0
- package/dist/src/testContext/UnifiedReportManager.js +1206 -0
- package/dist/src/testhub/DynamicConfigManager.d.ts +121 -0
- package/dist/src/testhub/DynamicConfigManager.js +320 -0
- package/dist/src/testhub/SystemsManager.d.ts +119 -0
- package/dist/src/testhub/SystemsManager.js +365 -0
- package/dist/src/testhub/TestHubClient.d.ts +335 -0
- package/dist/src/testhub/TestHubClient.js +1215 -0
- package/dist/src/testhub/TestHubReporter.d.ts +62 -0
- package/dist/src/testhub/TestHubReporter.js +576 -0
- package/dist/src/testhub/TestHubVars.d.ts +116 -0
- package/dist/src/testhub/TestHubVars.js +273 -0
- package/dist/src/utils/ActionInterceptor.d.ts +59 -0
- package/dist/src/utils/ActionInterceptor.js +741 -0
- package/dist/src/utils/ArtifactsCompressor.d.ts +43 -0
- package/dist/src/utils/ArtifactsCompressor.js +181 -0
- package/dist/src/utils/AutoLogsFinal.d.ts +47 -0
- package/dist/src/utils/AutoLogsFinal.js +148 -0
- package/dist/src/utils/CodeGenSession.d.ts +114 -0
- package/dist/src/utils/CodeGenSession.js +264 -0
- package/dist/src/utils/ConfigLogger.d.ts +133 -0
- package/dist/src/utils/ConfigLogger.js +611 -0
- package/dist/src/utils/CustomReporter.d.ts +22 -0
- package/dist/src/utils/CustomReporter.js +352 -0
- package/dist/src/utils/DataStore.d.ts +171 -0
- package/dist/src/utils/DataStore.js +484 -0
- package/dist/src/utils/DatabaseInterceptor.d.ts +19 -0
- package/dist/src/utils/DatabaseInterceptor.js +295 -0
- package/dist/src/utils/DateHelper.d.ts +16 -0
- package/dist/src/utils/DateHelper.js +120 -0
- package/dist/src/utils/DateValidator.d.ts +4 -0
- package/dist/src/utils/DateValidator.js +51 -0
- package/dist/src/utils/DocumentGenerator.d.ts +35 -0
- package/dist/src/utils/DocumentGenerator.js +129 -0
- package/dist/src/utils/EvidenceCapture.d.ts +90 -0
- package/dist/src/utils/EvidenceCapture.js +600 -0
- package/dist/src/utils/EvidenceReportGenerator.d.ts +70 -0
- package/dist/src/utils/EvidenceReportGenerator.js +799 -0
- package/dist/src/utils/FrameManagementUtil.d.ts +42 -0
- package/dist/src/utils/FrameManagementUtil.js +75 -0
- package/dist/src/utils/GlobalStatementsInterceptor.d.ts +1 -0
- package/dist/src/utils/GlobalStatementsInterceptor.js +1 -0
- package/dist/src/utils/HTMLTemplate.d.ts +1 -0
- package/dist/src/utils/HTMLTemplate.js +1034 -0
- package/dist/src/utils/InterceptacaoMagica.d.ts +23 -0
- package/dist/src/utils/InterceptacaoMagica.js +365 -0
- package/dist/src/utils/LogSanitizer.d.ts +35 -0
- package/dist/src/utils/LogSanitizer.js +110 -0
- package/dist/src/utils/Logger.d.ts +65 -0
- package/dist/src/utils/Logger.js +284 -0
- package/dist/src/utils/McpLocalClient.d.ts +141 -0
- package/dist/src/utils/McpLocalClient.js +871 -0
- package/dist/src/utils/PDFEvidenceGenerator.d.ts +20 -0
- package/dist/src/utils/PDFEvidenceGenerator.js +156 -0
- package/dist/src/utils/SpecFileAnalyzer.d.ts +35 -0
- package/dist/src/utils/SpecFileAnalyzer.js +209 -0
- package/dist/src/utils/StatementInterceptor.d.ts +18 -0
- package/dist/src/utils/StatementInterceptor.js +87 -0
- package/dist/src/utils/StatementLogger.d.ts +33 -0
- package/dist/src/utils/StatementLogger.js +113 -0
- package/dist/src/utils/StatementsInterceptor.d.ts +1 -0
- package/dist/src/utils/StatementsInterceptor.js +1 -0
- package/dist/src/utils/TeamsFlushHook.d.ts +17 -0
- package/dist/src/utils/TeamsFlushHook.js +168 -0
- package/dist/src/utils/TerminalLogCapture.d.ts +158 -0
- package/dist/src/utils/TerminalLogCapture.js +531 -0
- package/dist/src/utils/TestMethodLogger.d.ts +70 -0
- package/dist/src/utils/TestMethodLogger.js +95 -0
- package/dist/src/utils/UnifiedTeardown.d.ts +4 -0
- package/dist/src/utils/UnifiedTeardown.js +400 -0
- package/dist/src/utils/XPathCatalog.d.ts +152 -0
- package/dist/src/utils/XPathCatalog.js +350 -0
- package/dist/src/utils/generators.d.ts +90 -0
- package/dist/src/utils/generators.js +167 -0
- package/dist/src/utils/testRecovery/ResilientPlaywright.d.ts +152 -0
- package/dist/src/utils/testRecovery/ResilientPlaywright.js +715 -0
- package/dist/src/utils/testRecovery/TestRecoveryClient.d.ts +801 -0
- package/dist/src/utils/testRecovery/TestRecoveryClient.js +1415 -0
- package/dist/src/utils/testRecovery/autoFixCode.d.ts +65 -0
- package/dist/src/utils/testRecovery/autoFixCode.js +32 -0
- package/dist/vitest.config.d.ts +2 -0
- package/dist/vitest.config.js +59 -0
- package/dist/wdio.conf.d.ts +1 -0
- package/dist/wdio.conf.js +420 -0
- package/package.json +137 -0
- package/protect-loader.mjs +643 -0
- package/scripts/consumer-postinstall.ts +975 -0
- package/scripts/generate-index.ts +343 -0
- package/scripts/init-api.ts +613 -0
- package/scripts/init-banco.ts +437 -0
- package/scripts/init-frontend.ts +727 -0
- package/scripts/init-mobile.ts +558 -0
- package/scripts/init-scenarios.ts +925 -0
- package/scripts/init-ssh.ts +734 -0
- package/scripts/package-versions.ts +978 -0
- package/scripts/postinstall.ts +605 -0
- package/scripts/smart-override.ts +1675 -0
- package/scripts/sync-configs.ts +302 -0
- package/scripts/ultracite-setup.ts +370 -0
- package/src/types/globals.d.ts +48 -0
- package/tsconfig.json +29 -0
- package/types/autocore-sync-signal.d.ts +10 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Schemas de validação usando Zod para os componentes do AutoCore
|
|
3
|
+
* @module Domain/Schemas
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
/**
|
|
7
|
+
* Schema para validação de URLs
|
|
8
|
+
*/
|
|
9
|
+
export declare const UrlSchema: z.ZodString;
|
|
10
|
+
/**
|
|
11
|
+
* Schema para validação de seletores CSS/XPath
|
|
12
|
+
*/
|
|
13
|
+
export declare const SelectorSchema: z.ZodString;
|
|
14
|
+
/**
|
|
15
|
+
* Schema para validação de tempo limite
|
|
16
|
+
*/
|
|
17
|
+
export declare const TimeoutSchema: z.ZodNumber;
|
|
18
|
+
/**
|
|
19
|
+
* Schema para validação de credenciais SSH
|
|
20
|
+
*/
|
|
21
|
+
export declare const SSHCredentialsSchema: z.ZodObject<{
|
|
22
|
+
host: z.ZodString;
|
|
23
|
+
port: z.ZodDefault<z.ZodNumber>;
|
|
24
|
+
username: z.ZodString;
|
|
25
|
+
password: z.ZodOptional<z.ZodString>;
|
|
26
|
+
privateKey: z.ZodOptional<z.ZodString>;
|
|
27
|
+
passphrase: z.ZodOptional<z.ZodString>;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
/**
|
|
30
|
+
* Schema para validação de comandos SSH
|
|
31
|
+
*/
|
|
32
|
+
export declare const SSHCommandSchema: z.ZodString;
|
|
33
|
+
/**
|
|
34
|
+
* Schema para validação de configuração de banco
|
|
35
|
+
*/
|
|
36
|
+
export declare const DatabaseConfigSchema: z.ZodObject<{
|
|
37
|
+
host: z.ZodString;
|
|
38
|
+
port: z.ZodNumber;
|
|
39
|
+
database: z.ZodString;
|
|
40
|
+
username: z.ZodString;
|
|
41
|
+
password: z.ZodString;
|
|
42
|
+
connectionTimeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
43
|
+
queryTimeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
44
|
+
}, z.core.$strip>;
|
|
45
|
+
/**
|
|
46
|
+
* Schema para validação de queries SQL
|
|
47
|
+
*/
|
|
48
|
+
export declare const SQLQuerySchema: z.ZodString;
|
|
49
|
+
/**
|
|
50
|
+
* Schema para validação de dados de API Request
|
|
51
|
+
*/
|
|
52
|
+
export declare const ApiRequestSchema: z.ZodObject<{
|
|
53
|
+
url: z.ZodString;
|
|
54
|
+
method: z.ZodEnum<{
|
|
55
|
+
POST: "POST";
|
|
56
|
+
GET: "GET";
|
|
57
|
+
DELETE: "DELETE";
|
|
58
|
+
PUT: "PUT";
|
|
59
|
+
PATCH: "PATCH";
|
|
60
|
+
}>;
|
|
61
|
+
headers: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
62
|
+
body: z.ZodOptional<z.ZodUnknown>;
|
|
63
|
+
timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
64
|
+
retries: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
65
|
+
}, z.core.$strip>;
|
|
66
|
+
/**
|
|
67
|
+
* Schema para validação de configuração de device mobile
|
|
68
|
+
*/
|
|
69
|
+
export declare const MobileDeviceSchema: z.ZodObject<{
|
|
70
|
+
platformName: z.ZodEnum<{
|
|
71
|
+
Android: "Android";
|
|
72
|
+
iOS: "iOS";
|
|
73
|
+
}>;
|
|
74
|
+
deviceName: z.ZodString;
|
|
75
|
+
platformVersion: z.ZodString;
|
|
76
|
+
app: z.ZodOptional<z.ZodString>;
|
|
77
|
+
appPackage: z.ZodOptional<z.ZodString>;
|
|
78
|
+
appActivity: z.ZodOptional<z.ZodString>;
|
|
79
|
+
udid: z.ZodOptional<z.ZodString>;
|
|
80
|
+
orientation: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
81
|
+
PORTRAIT: "PORTRAIT";
|
|
82
|
+
LANDSCAPE: "LANDSCAPE";
|
|
83
|
+
}>>>;
|
|
84
|
+
}, z.core.$strip>;
|
|
85
|
+
/**
|
|
86
|
+
* Schema para validação de coordenadas mobile
|
|
87
|
+
*/
|
|
88
|
+
export declare const MobileCoordinatesSchema: z.ZodObject<{
|
|
89
|
+
x: z.ZodNumber;
|
|
90
|
+
y: z.ZodNumber;
|
|
91
|
+
}, z.core.$strip>;
|
|
92
|
+
/**
|
|
93
|
+
* Schema para validação de configuração de teste
|
|
94
|
+
*/
|
|
95
|
+
export declare const TestConfigurationSchema: z.ZodObject<{
|
|
96
|
+
name: z.ZodString;
|
|
97
|
+
description: z.ZodOptional<z.ZodString>;
|
|
98
|
+
timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
99
|
+
retries: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
100
|
+
tags: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
101
|
+
environment: z.ZodOptional<z.ZodString>;
|
|
102
|
+
parallel: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
103
|
+
}, z.core.$strip>;
|
|
104
|
+
/**
|
|
105
|
+
* Schema para validação de evidências/screenshots
|
|
106
|
+
*/
|
|
107
|
+
export declare const EvidenceConfigSchema: z.ZodObject<{
|
|
108
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
109
|
+
onFailure: z.ZodDefault<z.ZodBoolean>;
|
|
110
|
+
onSuccess: z.ZodDefault<z.ZodBoolean>;
|
|
111
|
+
quality: z.ZodDefault<z.ZodNumber>;
|
|
112
|
+
fullPage: z.ZodDefault<z.ZodBoolean>;
|
|
113
|
+
path: z.ZodOptional<z.ZodString>;
|
|
114
|
+
}, z.core.$strip>;
|
|
115
|
+
/**
|
|
116
|
+
* Schema para validação de paths de arquivos
|
|
117
|
+
*/
|
|
118
|
+
export declare const FilePathSchema: z.ZodString;
|
|
119
|
+
/**
|
|
120
|
+
* Schema para validação de viewport/dimensões de tela
|
|
121
|
+
*/
|
|
122
|
+
export declare const ViewportSchema: z.ZodObject<{
|
|
123
|
+
width: z.ZodNumber;
|
|
124
|
+
height: z.ZodNumber;
|
|
125
|
+
}, z.core.$strip>;
|
|
126
|
+
/**
|
|
127
|
+
* Utility functions para validação
|
|
128
|
+
*/
|
|
129
|
+
export declare class SchemaValidator {
|
|
130
|
+
/**
|
|
131
|
+
* Valida dados usando schema e retorna resultado tipado
|
|
132
|
+
*/
|
|
133
|
+
static validate<T>(schema: z.ZodSchema<T>, data: unknown): T;
|
|
134
|
+
/**
|
|
135
|
+
* Valida dados de forma assíncrona
|
|
136
|
+
*/
|
|
137
|
+
static validateAsync<T>(schema: z.ZodSchema<T>, data: unknown): Promise<T>;
|
|
138
|
+
/**
|
|
139
|
+
* Cria um schema opcional com valor padrão
|
|
140
|
+
*/
|
|
141
|
+
static optional<T>(schema: z.ZodSchema<T>, defaultValue: T): z.ZodDefault<z.ZodOptional<z.ZodType<T, unknown, z.core.$ZodTypeInternals<T, unknown>>>>;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Tipos TypeScript derivados dos schemas
|
|
145
|
+
*/
|
|
146
|
+
export type UrlType = z.infer<typeof UrlSchema>;
|
|
147
|
+
export type SelectorType = z.infer<typeof SelectorSchema>;
|
|
148
|
+
export type TimeoutType = z.infer<typeof TimeoutSchema>;
|
|
149
|
+
export type SSHCredentialsType = z.infer<typeof SSHCredentialsSchema>;
|
|
150
|
+
export type SSHCommandType = z.infer<typeof SSHCommandSchema>;
|
|
151
|
+
export type DatabaseConfigType = z.infer<typeof DatabaseConfigSchema>;
|
|
152
|
+
export type SQLQueryType = z.infer<typeof SQLQuerySchema>;
|
|
153
|
+
export type ApiRequestType = z.infer<typeof ApiRequestSchema>;
|
|
154
|
+
export type MobileDeviceType = z.infer<typeof MobileDeviceSchema>;
|
|
155
|
+
export type MobileCoordinatesType = z.infer<typeof MobileCoordinatesSchema>;
|
|
156
|
+
export type TestConfigurationType = z.infer<typeof TestConfigurationSchema>;
|
|
157
|
+
export type EvidenceConfigType = z.infer<typeof EvidenceConfigSchema>;
|
|
158
|
+
export type FilePathType = z.infer<typeof FilePathSchema>;
|
|
159
|
+
export type ViewportType = z.infer<typeof ViewportSchema>;
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Schemas de validação usando Zod para os componentes do AutoCore
|
|
3
|
+
* @module Domain/Schemas
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
/**
|
|
7
|
+
* Schema para validação de URLs
|
|
8
|
+
*/
|
|
9
|
+
export const UrlSchema = z
|
|
10
|
+
.string()
|
|
11
|
+
.url('URL deve ser válida e incluir protocolo (http:// ou https://)');
|
|
12
|
+
/**
|
|
13
|
+
* Schema para validação de seletores CSS/XPath
|
|
14
|
+
*/
|
|
15
|
+
export const SelectorSchema = z
|
|
16
|
+
.string()
|
|
17
|
+
.min(1, 'Seletor não pode estar vazio')
|
|
18
|
+
.refine((selector) => {
|
|
19
|
+
// Validação básica de seletores CSS e XPath
|
|
20
|
+
const cssPattern = /^[a-zA-Z0-9\-_#.[\]():*+~>\s,"'=^$|]+$/;
|
|
21
|
+
const xpathPattern = /^\/\/|^\/|\.|@|\[|\]/;
|
|
22
|
+
return cssPattern.test(selector) || xpathPattern.test(selector);
|
|
23
|
+
}, 'Seletor deve ser um CSS selector ou XPath válido');
|
|
24
|
+
/**
|
|
25
|
+
* Schema para validação de tempo limite
|
|
26
|
+
*/
|
|
27
|
+
export const TimeoutSchema = z
|
|
28
|
+
.number()
|
|
29
|
+
.min(100, 'Timeout deve ser pelo menos 100ms')
|
|
30
|
+
.max(300_000, 'Timeout não pode exceder 5 minutos');
|
|
31
|
+
/**
|
|
32
|
+
* Schema para validação de credenciais SSH
|
|
33
|
+
*/
|
|
34
|
+
export const SSHCredentialsSchema = z
|
|
35
|
+
.object({
|
|
36
|
+
host: z.string().min(1, 'Host é obrigatório'),
|
|
37
|
+
port: z.number().min(1).max(65_535).default(22),
|
|
38
|
+
username: z.string().min(1, 'Username é obrigatório'),
|
|
39
|
+
password: z.string().optional(),
|
|
40
|
+
privateKey: z.string().optional(),
|
|
41
|
+
passphrase: z.string().optional(),
|
|
42
|
+
})
|
|
43
|
+
.refine((data) => data.password || data.privateKey, 'Deve fornecer password ou privateKey');
|
|
44
|
+
/**
|
|
45
|
+
* Schema para validação de comandos SSH
|
|
46
|
+
*/
|
|
47
|
+
export const SSHCommandSchema = z
|
|
48
|
+
.string()
|
|
49
|
+
.min(1, 'Comando não pode estar vazio')
|
|
50
|
+
.max(8192, 'Comando muito longo (máximo 8KB)');
|
|
51
|
+
/**
|
|
52
|
+
* Schema para validação de configuração de banco
|
|
53
|
+
*/
|
|
54
|
+
export const DatabaseConfigSchema = z.object({
|
|
55
|
+
host: z.string().min(1, 'Host é obrigatório'),
|
|
56
|
+
port: z.number().min(1).max(65_535),
|
|
57
|
+
database: z.string().min(1, 'Nome do banco é obrigatório'),
|
|
58
|
+
username: z.string().min(1, 'Username é obrigatório'),
|
|
59
|
+
password: z.string().min(1, 'Password é obrigatório'),
|
|
60
|
+
connectionTimeout: TimeoutSchema.optional().default(30_000),
|
|
61
|
+
queryTimeout: TimeoutSchema.optional().default(60_000),
|
|
62
|
+
});
|
|
63
|
+
/**
|
|
64
|
+
* Schema para validação de queries SQL
|
|
65
|
+
*/
|
|
66
|
+
export const SQLQuerySchema = z
|
|
67
|
+
.string()
|
|
68
|
+
.min(1, 'Query SQL não pode estar vazia')
|
|
69
|
+
.max(100_000, 'Query SQL muito longa (máximo 100KB)')
|
|
70
|
+
.refine((query) => {
|
|
71
|
+
const trimmed = query.trim().toLowerCase();
|
|
72
|
+
// Validações básicas de segurança SQL
|
|
73
|
+
const dangerousPatterns = [
|
|
74
|
+
/;\s*drop\s+/i,
|
|
75
|
+
/;\s*delete\s+.*\s+where\s+1\s*=\s*1/i,
|
|
76
|
+
/;\s*truncate\s+/i,
|
|
77
|
+
/;\s*alter\s+/i,
|
|
78
|
+
];
|
|
79
|
+
return !dangerousPatterns.some((pattern) => pattern.test(query));
|
|
80
|
+
}, 'Query contém padrões potencialmente perigosos');
|
|
81
|
+
/**
|
|
82
|
+
* Schema para validação de dados de API Request
|
|
83
|
+
*/
|
|
84
|
+
export const ApiRequestSchema = z.object({
|
|
85
|
+
url: UrlSchema,
|
|
86
|
+
method: z.enum(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']),
|
|
87
|
+
headers: z.record(z.string(), z.string()).optional().default({}),
|
|
88
|
+
body: z.unknown().optional(),
|
|
89
|
+
timeout: TimeoutSchema.optional().default(30_000),
|
|
90
|
+
retries: z.number().min(0).max(10).optional().default(0),
|
|
91
|
+
});
|
|
92
|
+
/**
|
|
93
|
+
* Schema para validação de configuração de device mobile
|
|
94
|
+
*/
|
|
95
|
+
export const MobileDeviceSchema = z.object({
|
|
96
|
+
platformName: z.enum(['iOS', 'Android']),
|
|
97
|
+
deviceName: z.string().min(1, 'Nome do device é obrigatório'),
|
|
98
|
+
platformVersion: z.string().min(1, 'Versão da plataforma é obrigatória'),
|
|
99
|
+
app: z.string().optional(),
|
|
100
|
+
appPackage: z.string().optional(),
|
|
101
|
+
appActivity: z.string().optional(),
|
|
102
|
+
udid: z.string().optional(),
|
|
103
|
+
orientation: z.enum(['PORTRAIT', 'LANDSCAPE']).optional().default('PORTRAIT'),
|
|
104
|
+
});
|
|
105
|
+
/**
|
|
106
|
+
* Schema para validação de coordenadas mobile
|
|
107
|
+
*/
|
|
108
|
+
export const MobileCoordinatesSchema = z.object({
|
|
109
|
+
x: z.number().min(0, 'Coordenada X deve ser positiva'),
|
|
110
|
+
y: z.number().min(0, 'Coordenada Y deve ser positiva'),
|
|
111
|
+
});
|
|
112
|
+
/**
|
|
113
|
+
* Schema para validação de configuração de teste
|
|
114
|
+
*/
|
|
115
|
+
export const TestConfigurationSchema = z.object({
|
|
116
|
+
name: z.string().min(1, 'Nome do teste é obrigatório'),
|
|
117
|
+
description: z.string().optional(),
|
|
118
|
+
timeout: TimeoutSchema.optional().default(60_000),
|
|
119
|
+
retries: z.number().min(0).max(10).optional().default(0),
|
|
120
|
+
tags: z.array(z.string()).optional().default([]),
|
|
121
|
+
environment: z.string().optional(),
|
|
122
|
+
parallel: z.boolean().optional().default(false),
|
|
123
|
+
});
|
|
124
|
+
/**
|
|
125
|
+
* Schema para validação de evidências/screenshots
|
|
126
|
+
*/
|
|
127
|
+
export const EvidenceConfigSchema = z.object({
|
|
128
|
+
enabled: z.boolean().default(true),
|
|
129
|
+
onFailure: z.boolean().default(true),
|
|
130
|
+
onSuccess: z.boolean().default(false),
|
|
131
|
+
quality: z.number().min(10).max(100).default(90),
|
|
132
|
+
fullPage: z.boolean().default(true),
|
|
133
|
+
path: z.string().optional(),
|
|
134
|
+
});
|
|
135
|
+
/**
|
|
136
|
+
* Schema para validação de paths de arquivos
|
|
137
|
+
*/
|
|
138
|
+
export const FilePathSchema = z
|
|
139
|
+
.string()
|
|
140
|
+
.min(1, 'Caminho do arquivo não pode estar vazio')
|
|
141
|
+
.refine((path) => {
|
|
142
|
+
// Validação básica de path - evitar path traversal
|
|
143
|
+
return !(path.includes('../') || path.includes('..\\'));
|
|
144
|
+
}, 'Caminho de arquivo contém caracteres perigosos');
|
|
145
|
+
/**
|
|
146
|
+
* Schema para validação de viewport/dimensões de tela
|
|
147
|
+
*/
|
|
148
|
+
export const ViewportSchema = z.object({
|
|
149
|
+
width: z.number().min(100).max(4000),
|
|
150
|
+
height: z.number().min(100).max(4000),
|
|
151
|
+
});
|
|
152
|
+
/**
|
|
153
|
+
* Utility functions para validação
|
|
154
|
+
*/
|
|
155
|
+
export class SchemaValidator {
|
|
156
|
+
/**
|
|
157
|
+
* Valida dados usando schema e retorna resultado tipado
|
|
158
|
+
*/
|
|
159
|
+
static validate(schema, data) {
|
|
160
|
+
const result = schema.safeParse(data);
|
|
161
|
+
if (!result.success) {
|
|
162
|
+
const errors = result.error.issues
|
|
163
|
+
.map((err) => `${err.path.join('.')}: ${err.message}`)
|
|
164
|
+
.join('; ');
|
|
165
|
+
throw new Error(`Validação falhou: ${errors}`);
|
|
166
|
+
}
|
|
167
|
+
return result.data;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Valida dados de forma assíncrona
|
|
171
|
+
*/
|
|
172
|
+
static async validateAsync(schema, data) {
|
|
173
|
+
return SchemaValidator.validate(schema, data);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Cria um schema opcional com valor padrão
|
|
177
|
+
*/
|
|
178
|
+
static optional(schema, defaultValue) {
|
|
179
|
+
return schema.optional().default(defaultValue);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BaseError: Classe base para todos os erros do AutoCore
|
|
3
|
+
* Fornece funcionalidades comuns como logging, categorização e context
|
|
4
|
+
*/
|
|
5
|
+
export interface ErrorContext {
|
|
6
|
+
userId?: string;
|
|
7
|
+
sessionId?: string;
|
|
8
|
+
timestamp: number;
|
|
9
|
+
environment: 'development' | 'testing' | 'production' | 'unknown';
|
|
10
|
+
framework: string;
|
|
11
|
+
version: string;
|
|
12
|
+
metadata?: Record<string, unknown>;
|
|
13
|
+
ctErro?: string;
|
|
14
|
+
cnErro?: string;
|
|
15
|
+
linhaErro?: number;
|
|
16
|
+
nomeCenarioCt?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface ErrorDetails {
|
|
19
|
+
code: string;
|
|
20
|
+
message: string;
|
|
21
|
+
userMessage: string;
|
|
22
|
+
category: 'security' | 'validation' | 'integration' | 'configuration' | 'network' | 'system';
|
|
23
|
+
severity: 'low' | 'medium' | 'high' | 'critical';
|
|
24
|
+
recoverable: boolean;
|
|
25
|
+
suggestions?: string[];
|
|
26
|
+
documentation?: string;
|
|
27
|
+
}
|
|
28
|
+
export declare class BaseError extends Error {
|
|
29
|
+
readonly id: string;
|
|
30
|
+
readonly code: string;
|
|
31
|
+
readonly userMessage: string;
|
|
32
|
+
readonly category: ErrorDetails['category'];
|
|
33
|
+
readonly severity: ErrorDetails['severity'];
|
|
34
|
+
readonly recoverable: boolean;
|
|
35
|
+
readonly suggestions: string[];
|
|
36
|
+
readonly documentation?: string;
|
|
37
|
+
readonly context: ErrorContext;
|
|
38
|
+
readonly timestamp: number;
|
|
39
|
+
readonly originalError?: Error;
|
|
40
|
+
constructor(detailsOrMessage: ErrorDetails | string, originalError?: Error, context?: Partial<ErrorContext>);
|
|
41
|
+
/**
|
|
42
|
+
* Converte erro para formato JSON serializável
|
|
43
|
+
*/
|
|
44
|
+
toJSON(): Record<string, unknown>;
|
|
45
|
+
/**
|
|
46
|
+
* Gera mensagem formatada para o usuário
|
|
47
|
+
*/
|
|
48
|
+
getUserFriendlyMessage(): string;
|
|
49
|
+
/**
|
|
50
|
+
* Gera relatório técnico completo
|
|
51
|
+
*/
|
|
52
|
+
getTechnicalReport(): string;
|
|
53
|
+
/**
|
|
54
|
+
* Detecta ambiente de execução
|
|
55
|
+
*/
|
|
56
|
+
private detectEnvironment;
|
|
57
|
+
/**
|
|
58
|
+
* Obtém versão do framework
|
|
59
|
+
*/
|
|
60
|
+
private getFrameworkVersion;
|
|
61
|
+
/**
|
|
62
|
+
* Melhora stack trace com informações úteis
|
|
63
|
+
*/
|
|
64
|
+
private enhanceStackTrace;
|
|
65
|
+
/**
|
|
66
|
+
* 🆕 Extrai informações de CT/CN automaticamente do stack trace
|
|
67
|
+
*/
|
|
68
|
+
private extractTestInfoFromStack;
|
|
69
|
+
/**
|
|
70
|
+
* 🆕 Define manualmente informações de CT/CN (sobrescreve auto-extração)
|
|
71
|
+
*/
|
|
72
|
+
setTestInfo(ctErro?: string, cnErro?: string, nomeCenarioCt?: string): void;
|
|
73
|
+
/**
|
|
74
|
+
* 🆕 Define linha de erro manualmente
|
|
75
|
+
*/
|
|
76
|
+
setLineNumber(line: number): void;
|
|
77
|
+
}
|
|
78
|
+
export default BaseError;
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BaseError: Classe base para todos os erros do AutoCore
|
|
3
|
+
* Fornece funcionalidades comuns como logging, categorização e context
|
|
4
|
+
*/
|
|
5
|
+
import { randomUUID } from 'node:crypto';
|
|
6
|
+
export class BaseError extends Error {
|
|
7
|
+
id;
|
|
8
|
+
code;
|
|
9
|
+
userMessage;
|
|
10
|
+
category;
|
|
11
|
+
severity;
|
|
12
|
+
recoverable;
|
|
13
|
+
suggestions;
|
|
14
|
+
documentation;
|
|
15
|
+
context;
|
|
16
|
+
timestamp;
|
|
17
|
+
originalError;
|
|
18
|
+
constructor(detailsOrMessage, originalError, context) {
|
|
19
|
+
const details = typeof detailsOrMessage === 'string'
|
|
20
|
+
? {
|
|
21
|
+
code: 'GENERIC_ERROR',
|
|
22
|
+
message: detailsOrMessage,
|
|
23
|
+
userMessage: detailsOrMessage,
|
|
24
|
+
category: 'system',
|
|
25
|
+
severity: 'medium',
|
|
26
|
+
recoverable: false,
|
|
27
|
+
}
|
|
28
|
+
: detailsOrMessage;
|
|
29
|
+
super(details.message);
|
|
30
|
+
this.id = randomUUID();
|
|
31
|
+
this.code = details.code;
|
|
32
|
+
this.userMessage = details.userMessage;
|
|
33
|
+
this.category = details.category;
|
|
34
|
+
this.severity = details.severity;
|
|
35
|
+
this.recoverable = details.recoverable;
|
|
36
|
+
this.suggestions = details.suggestions || [];
|
|
37
|
+
this.documentation = details.documentation;
|
|
38
|
+
this.originalError = originalError;
|
|
39
|
+
this.timestamp = Date.now();
|
|
40
|
+
// 🆕 Auto-extrair informações de CT/CN do stack trace
|
|
41
|
+
const autoExtractedInfo = this.extractTestInfoFromStack();
|
|
42
|
+
this.context = {
|
|
43
|
+
timestamp: this.timestamp,
|
|
44
|
+
environment: this.detectEnvironment(),
|
|
45
|
+
framework: 'AutoCore',
|
|
46
|
+
version: this.getFrameworkVersion(),
|
|
47
|
+
...autoExtractedInfo,
|
|
48
|
+
...context,
|
|
49
|
+
};
|
|
50
|
+
// Manter stack trace original se disponível
|
|
51
|
+
if (originalError?.stack) {
|
|
52
|
+
this.stack = this.enhanceStackTrace(originalError.stack);
|
|
53
|
+
}
|
|
54
|
+
Error.captureStackTrace(this, this.constructor);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Converte erro para formato JSON serializável
|
|
58
|
+
*/
|
|
59
|
+
toJSON() {
|
|
60
|
+
return {
|
|
61
|
+
id: this.id,
|
|
62
|
+
code: this.code,
|
|
63
|
+
message: this.message,
|
|
64
|
+
userMessage: this.userMessage,
|
|
65
|
+
category: this.category,
|
|
66
|
+
severity: this.severity,
|
|
67
|
+
recoverable: this.recoverable,
|
|
68
|
+
suggestions: this.suggestions,
|
|
69
|
+
documentation: this.documentation,
|
|
70
|
+
context: this.context,
|
|
71
|
+
timestamp: this.timestamp,
|
|
72
|
+
stack: this.stack,
|
|
73
|
+
originalError: this.originalError
|
|
74
|
+
? {
|
|
75
|
+
message: this.originalError.message,
|
|
76
|
+
stack: this.originalError.stack,
|
|
77
|
+
}
|
|
78
|
+
: undefined,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Gera mensagem formatada para o usuário
|
|
83
|
+
*/
|
|
84
|
+
getUserFriendlyMessage() {
|
|
85
|
+
let message = `❌ ${this.userMessage}\n`;
|
|
86
|
+
if (this.suggestions.length > 0) {
|
|
87
|
+
message += '\n💡 Sugestões:\n';
|
|
88
|
+
this.suggestions.forEach((suggestion, index) => {
|
|
89
|
+
message += ` ${index + 1}. ${suggestion}\n`;
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
if (this.documentation) {
|
|
93
|
+
message += `\n📚 Documentação: ${this.documentation}\n`;
|
|
94
|
+
}
|
|
95
|
+
message += `\n🔍 Código do erro: ${this.code}`;
|
|
96
|
+
message += `\n🆔 ID do erro: ${this.id}`;
|
|
97
|
+
return message;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Gera relatório técnico completo
|
|
101
|
+
*/
|
|
102
|
+
getTechnicalReport() {
|
|
103
|
+
const report = [
|
|
104
|
+
'=== RELATÓRIO DE ERRO AUTOCORE ===',
|
|
105
|
+
`ID: ${this.id}`,
|
|
106
|
+
`Código: ${this.code}`,
|
|
107
|
+
`Categoria: ${this.category}`,
|
|
108
|
+
`Severidade: ${this.severity}`,
|
|
109
|
+
`Recuperável: ${this.recoverable ? 'Sim' : 'Não'}`,
|
|
110
|
+
`Timestamp: ${new Date(this.timestamp).toISOString()}`,
|
|
111
|
+
'',
|
|
112
|
+
'Contexto:',
|
|
113
|
+
`- Ambiente: ${this.context.environment}`,
|
|
114
|
+
`- Framework: ${this.context.framework} v${this.context.version}`,
|
|
115
|
+
`- Session ID: ${this.context.sessionId || 'N/A'}`,
|
|
116
|
+
'',
|
|
117
|
+
'Mensagem Técnica:',
|
|
118
|
+
this.message,
|
|
119
|
+
'',
|
|
120
|
+
'Mensagem do Usuário:',
|
|
121
|
+
this.userMessage,
|
|
122
|
+
'',
|
|
123
|
+
];
|
|
124
|
+
if (this.suggestions.length > 0) {
|
|
125
|
+
report.push('Sugestões:');
|
|
126
|
+
this.suggestions.forEach((suggestion, index) => {
|
|
127
|
+
report.push(`${index + 1}. ${suggestion}`);
|
|
128
|
+
});
|
|
129
|
+
report.push('');
|
|
130
|
+
}
|
|
131
|
+
if (this.stack) {
|
|
132
|
+
report.push('Stack Trace:');
|
|
133
|
+
report.push(this.stack);
|
|
134
|
+
report.push('');
|
|
135
|
+
}
|
|
136
|
+
if (this.originalError) {
|
|
137
|
+
report.push('Erro Original:');
|
|
138
|
+
report.push(`Mensagem: ${this.originalError.message}`);
|
|
139
|
+
if (this.originalError.stack) {
|
|
140
|
+
report.push(`Stack: ${this.originalError.stack}`);
|
|
141
|
+
}
|
|
142
|
+
report.push('');
|
|
143
|
+
}
|
|
144
|
+
if (this.context.metadata) {
|
|
145
|
+
report.push('Metadados:');
|
|
146
|
+
report.push(JSON.stringify(this.context.metadata, null, 2));
|
|
147
|
+
}
|
|
148
|
+
return report.join('\n');
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Detecta ambiente de execução
|
|
152
|
+
*/
|
|
153
|
+
detectEnvironment() {
|
|
154
|
+
if (process.env.NODE_ENV === 'test' || process.env.VITEST) {
|
|
155
|
+
return 'testing';
|
|
156
|
+
}
|
|
157
|
+
if (process.env.NODE_ENV === 'production') {
|
|
158
|
+
return 'production';
|
|
159
|
+
}
|
|
160
|
+
if (process.env.NODE_ENV === 'development') {
|
|
161
|
+
return 'development';
|
|
162
|
+
}
|
|
163
|
+
return 'unknown';
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Obtém versão do framework
|
|
167
|
+
*/
|
|
168
|
+
getFrameworkVersion() {
|
|
169
|
+
try {
|
|
170
|
+
const pkg = require('../../../package.json');
|
|
171
|
+
return pkg.version || 'unknown';
|
|
172
|
+
}
|
|
173
|
+
catch {
|
|
174
|
+
return 'unknown';
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Melhora stack trace com informações úteis
|
|
179
|
+
*/
|
|
180
|
+
enhanceStackTrace(originalStack) {
|
|
181
|
+
const lines = originalStack.split('\n');
|
|
182
|
+
const enhanced = [
|
|
183
|
+
`AutoCore Error [${this.code}]: ${this.message}`,
|
|
184
|
+
` at ${this.constructor.name} (autocore:${this.category}:${this.severity})`,
|
|
185
|
+
...lines.slice(1),
|
|
186
|
+
];
|
|
187
|
+
return enhanced.join('\n');
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* 🆕 Extrai informações de CT/CN automaticamente do stack trace
|
|
191
|
+
*/
|
|
192
|
+
extractTestInfoFromStack() {
|
|
193
|
+
const extractedInfo = {};
|
|
194
|
+
try {
|
|
195
|
+
// Capturar stack trace atual
|
|
196
|
+
const stack = new Error().stack || '';
|
|
197
|
+
// Extrair linha de erro (primeira linha após o construtor)
|
|
198
|
+
const lineMatch = stack.match(/:(\d+):\d+/);
|
|
199
|
+
if (lineMatch) {
|
|
200
|
+
extractedInfo.linhaErro = Number.parseInt(lineMatch[1], 10);
|
|
201
|
+
}
|
|
202
|
+
// Tentar extrair CT e CN do stack trace
|
|
203
|
+
// Procurar por padrões como "CT001", "CN001" nos nomes de arquivo
|
|
204
|
+
const ctMatch = stack.match(/[/\\](CT\d+[^/\\\s.]*)/i);
|
|
205
|
+
if (ctMatch) {
|
|
206
|
+
extractedInfo.ctErro = ctMatch[1];
|
|
207
|
+
}
|
|
208
|
+
const cnMatch = stack.match(/[/\\](CN\d+[^/\\\s.]*)/i);
|
|
209
|
+
if (cnMatch) {
|
|
210
|
+
extractedInfo.cnErro = cnMatch[1];
|
|
211
|
+
}
|
|
212
|
+
// Se encontrou CT ou CN, criar nome completo do cenário
|
|
213
|
+
if (extractedInfo.cnErro || extractedInfo.ctErro) {
|
|
214
|
+
extractedInfo.nomeCenarioCt = [
|
|
215
|
+
extractedInfo.cnErro,
|
|
216
|
+
extractedInfo.ctErro,
|
|
217
|
+
]
|
|
218
|
+
.filter(Boolean)
|
|
219
|
+
.join(' / ');
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
catch {
|
|
223
|
+
// Ignorar erros na extração
|
|
224
|
+
}
|
|
225
|
+
return extractedInfo;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* 🆕 Define manualmente informações de CT/CN (sobrescreve auto-extração)
|
|
229
|
+
*/
|
|
230
|
+
setTestInfo(ctErro, cnErro, nomeCenarioCt) {
|
|
231
|
+
if (ctErro)
|
|
232
|
+
this.context.ctErro = ctErro;
|
|
233
|
+
if (cnErro)
|
|
234
|
+
this.context.cnErro = cnErro;
|
|
235
|
+
if (nomeCenarioCt)
|
|
236
|
+
this.context.nomeCenarioCt = nomeCenarioCt;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* 🆕 Define linha de erro manualmente
|
|
240
|
+
*/
|
|
241
|
+
setLineNumber(line) {
|
|
242
|
+
this.context.linhaErro = line;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
export default BaseError;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ConfigurationError: Erros relacionados à configuração do framework
|
|
3
|
+
*/
|
|
4
|
+
import { BaseError, type ErrorContext } from './BaseError.js';
|
|
5
|
+
export declare class ConfigurationError extends BaseError {
|
|
6
|
+
constructor(code: string, message: string, userMessage: string, originalError?: Error, context?: Partial<ErrorContext>);
|
|
7
|
+
static missingConfigFile(filePath: string, context?: Partial<ErrorContext>): ConfigurationError;
|
|
8
|
+
static invalidConfigFormat(filePath: string, error: Error, context?: Partial<ErrorContext>): ConfigurationError;
|
|
9
|
+
static missingEnvironmentVariable(varName: string, context?: Partial<ErrorContext>): ConfigurationError;
|
|
10
|
+
static invalidEnvironmentValue(varName: string, expectedFormat: string, context?: Partial<ErrorContext>): ConfigurationError;
|
|
11
|
+
static conflictingConfiguration(config1: string, config2: string, context?: Partial<ErrorContext>): ConfigurationError;
|
|
12
|
+
static unsupportedBrowserConfig(browser: string, context?: Partial<ErrorContext>): ConfigurationError;
|
|
13
|
+
static invalidTestConfiguration(configKey: string, reason: string, context?: Partial<ErrorContext>): ConfigurationError;
|
|
14
|
+
static missingDependency(dependency: string, context?: Partial<ErrorContext>): ConfigurationError;
|
|
15
|
+
}
|
|
16
|
+
export default ConfigurationError;
|