@machina.ai/openapi-contract-tester 2.1.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/.env.example +91 -0
- package/README.md +472 -0
- package/dist/ai-engine/assertion-generator.d.ts +48 -0
- package/dist/ai-engine/assertion-generator.d.ts.map +1 -0
- package/dist/ai-engine/assertion-generator.js +166 -0
- package/dist/ai-engine/assertion-generator.js.map +1 -0
- package/dist/ai-engine/context-data-generator.d.ts +38 -0
- package/dist/ai-engine/context-data-generator.d.ts.map +1 -0
- package/dist/ai-engine/context-data-generator.js +146 -0
- package/dist/ai-engine/context-data-generator.js.map +1 -0
- package/dist/ai-engine/dataflow-detector.d.ts +53 -0
- package/dist/ai-engine/dataflow-detector.d.ts.map +1 -0
- package/dist/ai-engine/dataflow-detector.js +217 -0
- package/dist/ai-engine/dataflow-detector.js.map +1 -0
- package/dist/ai-engine/dependency-detector.d.ts +52 -0
- package/dist/ai-engine/dependency-detector.d.ts.map +1 -0
- package/dist/ai-engine/dependency-detector.js +241 -0
- package/dist/ai-engine/dependency-detector.js.map +1 -0
- package/dist/ai-engine/edge-case-suggester.d.ts +63 -0
- package/dist/ai-engine/edge-case-suggester.d.ts.map +1 -0
- package/dist/ai-engine/edge-case-suggester.js +177 -0
- package/dist/ai-engine/edge-case-suggester.js.map +1 -0
- package/dist/ai-engine/index.d.ts +13 -0
- package/dist/ai-engine/index.d.ts.map +1 -0
- package/dist/ai-engine/index.js +13 -0
- package/dist/ai-engine/index.js.map +1 -0
- package/dist/analyzers/ai-failure-analyzer.d.ts +41 -0
- package/dist/analyzers/ai-failure-analyzer.d.ts.map +1 -0
- package/dist/analyzers/ai-failure-analyzer.js +220 -0
- package/dist/analyzers/ai-failure-analyzer.js.map +1 -0
- package/dist/analyzers/comparison-utils.d.ts +31 -0
- package/dist/analyzers/comparison-utils.d.ts.map +1 -0
- package/dist/analyzers/comparison-utils.js +85 -0
- package/dist/analyzers/comparison-utils.js.map +1 -0
- package/dist/analyzers/context-analyzer.d.ts +49 -0
- package/dist/analyzers/context-analyzer.d.ts.map +1 -0
- package/dist/analyzers/context-analyzer.js +292 -0
- package/dist/analyzers/context-analyzer.js.map +1 -0
- package/dist/analyzers/dependency-analyzer.d.ts +44 -0
- package/dist/analyzers/dependency-analyzer.d.ts.map +1 -0
- package/dist/analyzers/dependency-analyzer.js +313 -0
- package/dist/analyzers/dependency-analyzer.js.map +1 -0
- package/dist/analyzers/failure-analyzer.d.ts +122 -0
- package/dist/analyzers/failure-analyzer.d.ts.map +1 -0
- package/dist/analyzers/failure-analyzer.js +140 -0
- package/dist/analyzers/failure-analyzer.js.map +1 -0
- package/dist/analyzers/failure-detectors/index.d.ts +33 -0
- package/dist/analyzers/failure-detectors/index.d.ts.map +1 -0
- package/dist/analyzers/failure-detectors/index.js +164 -0
- package/dist/analyzers/failure-detectors/index.js.map +1 -0
- package/dist/analyzers/failure-discrepancy-correlator.d.ts +111 -0
- package/dist/analyzers/failure-discrepancy-correlator.d.ts.map +1 -0
- package/dist/analyzers/failure-discrepancy-correlator.js +202 -0
- package/dist/analyzers/failure-discrepancy-correlator.js.map +1 -0
- package/dist/analyzers/index.d.ts +10 -0
- package/dist/analyzers/index.d.ts.map +1 -0
- package/dist/analyzers/index.js +10 -0
- package/dist/analyzers/index.js.map +1 -0
- package/dist/analyzers/semantic-matcher.d.ts +123 -0
- package/dist/analyzers/semantic-matcher.d.ts.map +1 -0
- package/dist/analyzers/semantic-matcher.js +297 -0
- package/dist/analyzers/semantic-matcher.js.map +1 -0
- package/dist/analyzers/source-comparator.d.ts +177 -0
- package/dist/analyzers/source-comparator.d.ts.map +1 -0
- package/dist/analyzers/source-comparator.js +225 -0
- package/dist/analyzers/source-comparator.js.map +1 -0
- package/dist/business-rules/business-rules-analyzer.d.ts +44 -0
- package/dist/business-rules/business-rules-analyzer.d.ts.map +1 -0
- package/dist/business-rules/business-rules-analyzer.js +363 -0
- package/dist/business-rules/business-rules-analyzer.js.map +1 -0
- package/dist/business-rules/business-rules-generator.d.ts +78 -0
- package/dist/business-rules/business-rules-generator.d.ts.map +1 -0
- package/dist/business-rules/business-rules-generator.js +357 -0
- package/dist/business-rules/business-rules-generator.js.map +1 -0
- package/dist/business-rules/extractors/rule-extractors.d.ts +50 -0
- package/dist/business-rules/extractors/rule-extractors.d.ts.map +1 -0
- package/dist/business-rules/extractors/rule-extractors.js +189 -0
- package/dist/business-rules/extractors/rule-extractors.js.map +1 -0
- package/dist/business-rules/value-generators.d.ts +70 -0
- package/dist/business-rules/value-generators.d.ts.map +1 -0
- package/dist/business-rules/value-generators.js +142 -0
- package/dist/business-rules/value-generators.js.map +1 -0
- package/dist/executor/auth-providers/auth-header-builder.d.ts +16 -0
- package/dist/executor/auth-providers/auth-header-builder.d.ts.map +1 -0
- package/dist/executor/auth-providers/auth-header-builder.js +47 -0
- package/dist/executor/auth-providers/auth-header-builder.js.map +1 -0
- package/dist/executor/auth-providers/oauth2-provider.d.ts +19 -0
- package/dist/executor/auth-providers/oauth2-provider.d.ts.map +1 -0
- package/dist/executor/auth-providers/oauth2-provider.js +114 -0
- package/dist/executor/auth-providers/oauth2-provider.js.map +1 -0
- package/dist/executor/http-client.d.ts +133 -0
- package/dist/executor/http-client.d.ts.map +1 -0
- package/dist/executor/http-client.js +172 -0
- package/dist/executor/http-client.js.map +1 -0
- package/dist/executor/http-request-builder.d.ts +69 -0
- package/dist/executor/http-request-builder.d.ts.map +1 -0
- package/dist/executor/http-request-builder.js +140 -0
- package/dist/executor/http-request-builder.js.map +1 -0
- package/dist/executor/http-response-parser.d.ts +28 -0
- package/dist/executor/http-response-parser.d.ts.map +1 -0
- package/dist/executor/http-response-parser.js +74 -0
- package/dist/executor/http-response-parser.js.map +1 -0
- package/dist/executor/response-handler.d.ts +66 -0
- package/dist/executor/response-handler.d.ts.map +1 -0
- package/dist/executor/response-handler.js +135 -0
- package/dist/executor/response-handler.js.map +1 -0
- package/dist/executor/result-processor.d.ts +27 -0
- package/dist/executor/result-processor.d.ts.map +1 -0
- package/dist/executor/result-processor.js +140 -0
- package/dist/executor/result-processor.js.map +1 -0
- package/dist/executor/result-utils.d.ts +21 -0
- package/dist/executor/result-utils.d.ts.map +1 -0
- package/dist/executor/result-utils.js +29 -0
- package/dist/executor/result-utils.js.map +1 -0
- package/dist/executor/test-executor.d.ts +49 -0
- package/dist/executor/test-executor.d.ts.map +1 -0
- package/dist/executor/test-executor.js +226 -0
- package/dist/executor/test-executor.js.map +1 -0
- package/dist/executor/test-runner.d.ts +85 -0
- package/dist/executor/test-runner.d.ts.map +1 -0
- package/dist/executor/test-runner.js +177 -0
- package/dist/executor/test-runner.js.map +1 -0
- package/dist/executor/token-detector/index.d.ts +7 -0
- package/dist/executor/token-detector/index.d.ts.map +1 -0
- package/dist/executor/token-detector/index.js +7 -0
- package/dist/executor/token-detector/index.js.map +1 -0
- package/dist/executor/token-detector/token-detector.d.ts +64 -0
- package/dist/executor/token-detector/token-detector.d.ts.map +1 -0
- package/dist/executor/token-detector/token-detector.js +140 -0
- package/dist/executor/token-detector/token-detector.js.map +1 -0
- package/dist/generators/business-rule-from-stories-generator.d.ts +30 -0
- package/dist/generators/business-rule-from-stories-generator.d.ts.map +1 -0
- package/dist/generators/business-rule-from-stories-generator.js +227 -0
- package/dist/generators/business-rule-from-stories-generator.js.map +1 -0
- package/dist/generators/data/ai-data-generator.d.ts +23 -0
- package/dist/generators/data/ai-data-generator.d.ts.map +1 -0
- package/dist/generators/data/ai-data-generator.js +41 -0
- package/dist/generators/data/ai-data-generator.js.map +1 -0
- package/dist/generators/data/base-generator.d.ts +121 -0
- package/dist/generators/data/base-generator.d.ts.map +1 -0
- package/dist/generators/data/base-generator.js +200 -0
- package/dist/generators/data/base-generator.js.map +1 -0
- package/dist/generators/data/heuristic-data-generator.d.ts +28 -0
- package/dist/generators/data/heuristic-data-generator.d.ts.map +1 -0
- package/dist/generators/data/heuristic-data-generator.js +49 -0
- package/dist/generators/data/heuristic-data-generator.js.map +1 -0
- package/dist/generators/data/index.d.ts +48 -0
- package/dist/generators/data/index.d.ts.map +1 -0
- package/dist/generators/data/index.js +201 -0
- package/dist/generators/data/index.js.map +1 -0
- package/dist/generators/data/schema-walker.d.ts +45 -0
- package/dist/generators/data/schema-walker.d.ts.map +1 -0
- package/dist/generators/data/schema-walker.js +103 -0
- package/dist/generators/data/schema-walker.js.map +1 -0
- package/dist/generators/data/type-strategies.d.ts +79 -0
- package/dist/generators/data/type-strategies.d.ts.map +1 -0
- package/dist/generators/data/type-strategies.js +394 -0
- package/dist/generators/data/type-strategies.js.map +1 -0
- package/dist/generators/data-generator.d.ts +11 -0
- package/dist/generators/data-generator.d.ts.map +1 -0
- package/dist/generators/data-generator.js +11 -0
- package/dist/generators/data-generator.js.map +1 -0
- package/dist/generators/edge-case-generator.d.ts +55 -0
- package/dist/generators/edge-case-generator.d.ts.map +1 -0
- package/dist/generators/edge-case-generator.js +327 -0
- package/dist/generators/edge-case-generator.js.map +1 -0
- package/dist/generators/edge-cases/boundary-analyzer.d.ts +26 -0
- package/dist/generators/edge-cases/boundary-analyzer.d.ts.map +1 -0
- package/dist/generators/edge-cases/boundary-analyzer.js +95 -0
- package/dist/generators/edge-cases/boundary-analyzer.js.map +1 -0
- package/dist/generators/error-case-generator.d.ts +11 -0
- package/dist/generators/error-case-generator.d.ts.map +1 -0
- package/dist/generators/error-case-generator.js +11 -0
- package/dist/generators/error-case-generator.js.map +1 -0
- package/dist/generators/errors/auth-error-strategy.d.ts +36 -0
- package/dist/generators/errors/auth-error-strategy.d.ts.map +1 -0
- package/dist/generators/errors/auth-error-strategy.js +118 -0
- package/dist/generators/errors/auth-error-strategy.js.map +1 -0
- package/dist/generators/errors/business-error-strategy.d.ts +44 -0
- package/dist/generators/errors/business-error-strategy.d.ts.map +1 -0
- package/dist/generators/errors/business-error-strategy.js +152 -0
- package/dist/generators/errors/business-error-strategy.js.map +1 -0
- package/dist/generators/errors/error-strategy-factory.d.ts +27 -0
- package/dist/generators/errors/error-strategy-factory.d.ts.map +1 -0
- package/dist/generators/errors/error-strategy-factory.js +47 -0
- package/dist/generators/errors/error-strategy-factory.js.map +1 -0
- package/dist/generators/errors/error-strategy.d.ts +62 -0
- package/dist/generators/errors/error-strategy.d.ts.map +1 -0
- package/dist/generators/errors/error-strategy.js +69 -0
- package/dist/generators/errors/error-strategy.js.map +1 -0
- package/dist/generators/errors/index.d.ts +23 -0
- package/dist/generators/errors/index.d.ts.map +1 -0
- package/dist/generators/errors/index.js +73 -0
- package/dist/generators/errors/index.js.map +1 -0
- package/dist/generators/errors/validation-error-strategy.d.ts +25 -0
- package/dist/generators/errors/validation-error-strategy.d.ts.map +1 -0
- package/dist/generators/errors/validation-error-strategy.js +214 -0
- package/dist/generators/errors/validation-error-strategy.js.map +1 -0
- package/dist/generators/happy-path-generator.d.ts +93 -0
- package/dist/generators/happy-path-generator.d.ts.map +1 -0
- package/dist/generators/happy-path-generator.js +275 -0
- package/dist/generators/happy-path-generator.js.map +1 -0
- package/dist/generators/test-enricher.d.ts +44 -0
- package/dist/generators/test-enricher.d.ts.map +1 -0
- package/dist/generators/test-enricher.js +109 -0
- package/dist/generators/test-enricher.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/ai-cache.d.ts +123 -0
- package/dist/llm/ai-cache.d.ts.map +1 -0
- package/dist/llm/ai-cache.js +220 -0
- package/dist/llm/ai-cache.js.map +1 -0
- package/dist/llm/ai-client.d.ts +92 -0
- package/dist/llm/ai-client.d.ts.map +1 -0
- package/dist/llm/ai-client.js +386 -0
- package/dist/llm/ai-client.js.map +1 -0
- package/dist/llm/data-generator-ai.d.ts +84 -0
- package/dist/llm/data-generator-ai.d.ts.map +1 -0
- package/dist/llm/data-generator-ai.js +284 -0
- package/dist/llm/data-generator-ai.js.map +1 -0
- package/dist/llm/index.d.ts +7 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +7 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/mcp/handlers/base-handler.d.ts +72 -0
- package/dist/mcp/handlers/base-handler.d.ts.map +1 -0
- package/dist/mcp/handlers/base-handler.js +86 -0
- package/dist/mcp/handlers/base-handler.js.map +1 -0
- package/dist/mcp/handlers/compare-sources.d.ts +91 -0
- package/dist/mcp/handlers/compare-sources.d.ts.map +1 -0
- package/dist/mcp/handlers/compare-sources.js +182 -0
- package/dist/mcp/handlers/compare-sources.js.map +1 -0
- package/dist/mcp/handlers/export-results.d.ts +53 -0
- package/dist/mcp/handlers/export-results.d.ts.map +1 -0
- package/dist/mcp/handlers/export-results.js +132 -0
- package/dist/mcp/handlers/export-results.js.map +1 -0
- package/dist/mcp/handlers/export-to-postman.d.ts +65 -0
- package/dist/mcp/handlers/export-to-postman.d.ts.map +1 -0
- package/dist/mcp/handlers/export-to-postman.js +128 -0
- package/dist/mcp/handlers/export-to-postman.js.map +1 -0
- package/dist/mcp/handlers/generate-tests.d.ts +74 -0
- package/dist/mcp/handlers/generate-tests.d.ts.map +1 -0
- package/dist/mcp/handlers/generate-tests.js +519 -0
- package/dist/mcp/handlers/generate-tests.js.map +1 -0
- package/dist/mcp/handlers/index.d.ts +13 -0
- package/dist/mcp/handlers/index.d.ts.map +1 -0
- package/dist/mcp/handlers/index.js +12 -0
- package/dist/mcp/handlers/index.js.map +1 -0
- package/dist/mcp/handlers/run-tests.d.ts +89 -0
- package/dist/mcp/handlers/run-tests.d.ts.map +1 -0
- package/dist/mcp/handlers/run-tests.js +233 -0
- package/dist/mcp/handlers/run-tests.js.map +1 -0
- package/dist/mcp/handlers/types.d.ts +61 -0
- package/dist/mcp/handlers/types.d.ts.map +1 -0
- package/dist/mcp/handlers/types.js +9 -0
- package/dist/mcp/handlers/types.js.map +1 -0
- package/dist/mcp/server.d.ts +64 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +200 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/services/file-service.d.ts +66 -0
- package/dist/mcp/services/file-service.d.ts.map +1 -0
- package/dist/mcp/services/file-service.js +143 -0
- package/dist/mcp/services/file-service.js.map +1 -0
- package/dist/mcp/services/llm-service.d.ts +70 -0
- package/dist/mcp/services/llm-service.d.ts.map +1 -0
- package/dist/mcp/services/llm-service.js +189 -0
- package/dist/mcp/services/llm-service.js.map +1 -0
- package/dist/mcp/services/postman-service.d.ts +128 -0
- package/dist/mcp/services/postman-service.d.ts.map +1 -0
- package/dist/mcp/services/postman-service.js +266 -0
- package/dist/mcp/services/postman-service.js.map +1 -0
- package/dist/mcp/services/report-service.d.ts +81 -0
- package/dist/mcp/services/report-service.d.ts.map +1 -0
- package/dist/mcp/services/report-service.js +210 -0
- package/dist/mcp/services/report-service.js.map +1 -0
- package/dist/mcp/services/spec-service.d.ts +58 -0
- package/dist/mcp/services/spec-service.d.ts.map +1 -0
- package/dist/mcp/services/spec-service.js +140 -0
- package/dist/mcp/services/spec-service.js.map +1 -0
- package/dist/parsers/endpoint-extractor.d.ts +32 -0
- package/dist/parsers/endpoint-extractor.d.ts.map +1 -0
- package/dist/parsers/endpoint-extractor.js +160 -0
- package/dist/parsers/endpoint-extractor.js.map +1 -0
- package/dist/parsers/openapi-parser.d.ts +120 -0
- package/dist/parsers/openapi-parser.d.ts.map +1 -0
- package/dist/parsers/openapi-parser.js +257 -0
- package/dist/parsers/openapi-parser.js.map +1 -0
- package/dist/parsers/visitors/auth-visitor.d.ts +28 -0
- package/dist/parsers/visitors/auth-visitor.d.ts.map +1 -0
- package/dist/parsers/visitors/auth-visitor.js +116 -0
- package/dist/parsers/visitors/auth-visitor.js.map +1 -0
- package/dist/prd/index.d.ts +10 -0
- package/dist/prd/index.d.ts.map +1 -0
- package/dist/prd/index.js +10 -0
- package/dist/prd/index.js.map +1 -0
- package/dist/prd/prd-reader.d.ts +124 -0
- package/dist/prd/prd-reader.d.ts.map +1 -0
- package/dist/prd/prd-reader.js +308 -0
- package/dist/prd/prd-reader.js.map +1 -0
- package/dist/prd/prd-storage.d.ts +232 -0
- package/dist/prd/prd-storage.d.ts.map +1 -0
- package/dist/prd/prd-storage.js +129 -0
- package/dist/prd/prd-storage.js.map +1 -0
- package/dist/repairers/test-auto-repairer.d.ts +61 -0
- package/dist/repairers/test-auto-repairer.d.ts.map +1 -0
- package/dist/repairers/test-auto-repairer.js +213 -0
- package/dist/repairers/test-auto-repairer.js.map +1 -0
- package/dist/reporters/comparison-report-generator.d.ts +58 -0
- package/dist/reporters/comparison-report-generator.d.ts.map +1 -0
- package/dist/reporters/comparison-report-generator.js +369 -0
- package/dist/reporters/comparison-report-generator.js.map +1 -0
- package/dist/reporters/gherkin-formatter.d.ts +34 -0
- package/dist/reporters/gherkin-formatter.d.ts.map +1 -0
- package/dist/reporters/gherkin-formatter.js +231 -0
- package/dist/reporters/gherkin-formatter.js.map +1 -0
- package/dist/reporters/html-report-generator.d.ts +174 -0
- package/dist/reporters/html-report-generator.d.ts.map +1 -0
- package/dist/reporters/html-report-generator.js +194 -0
- package/dist/reporters/html-report-generator.js.map +1 -0
- package/dist/reporters/report-charts.d.ts +23 -0
- package/dist/reporters/report-charts.d.ts.map +1 -0
- package/dist/reporters/report-charts.js +182 -0
- package/dist/reporters/report-charts.js.map +1 -0
- package/dist/reporters/report-sections.d.ts +34 -0
- package/dist/reporters/report-sections.d.ts.map +1 -0
- package/dist/reporters/report-sections.js +481 -0
- package/dist/reporters/report-sections.js.map +1 -0
- package/dist/reporters/report-styles.d.ts +12 -0
- package/dist/reporters/report-styles.d.ts.map +1 -0
- package/dist/reporters/report-styles.js +412 -0
- package/dist/reporters/report-styles.js.map +1 -0
- package/dist/reporters/report-test-details.d.ts +56 -0
- package/dist/reporters/report-test-details.d.ts.map +1 -0
- package/dist/reporters/report-test-details.js +328 -0
- package/dist/reporters/report-test-details.js.map +1 -0
- package/dist/reporters/report-utils.d.ts +40 -0
- package/dist/reporters/report-utils.d.ts.map +1 -0
- package/dist/reporters/report-utils.js +163 -0
- package/dist/reporters/report-utils.js.map +1 -0
- package/dist/types/ai-config.d.ts +63 -0
- package/dist/types/ai-config.d.ts.map +1 -0
- package/dist/types/ai-config.js +79 -0
- package/dist/types/ai-config.js.map +1 -0
- package/dist/types/business-rules.d.ts +235 -0
- package/dist/types/business-rules.d.ts.map +1 -0
- package/dist/types/business-rules.js +6 -0
- package/dist/types/business-rules.js.map +1 -0
- package/dist/types/config.d.ts +106 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +6 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/core.d.ts +72 -0
- package/dist/types/core.d.ts.map +1 -0
- package/dist/types/core.js +6 -0
- package/dist/types/core.js.map +1 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +10 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/openapi.d.ts +139 -0
- package/dist/types/openapi.d.ts.map +1 -0
- package/dist/types/openapi.js +6 -0
- package/dist/types/openapi.js.map +1 -0
- package/dist/types/pact.d.ts +101 -0
- package/dist/types/pact.d.ts.map +1 -0
- package/dist/types/pact.js +6 -0
- package/dist/types/pact.js.map +1 -0
- package/dist/types/reporting.d.ts +93 -0
- package/dist/types/reporting.d.ts.map +1 -0
- package/dist/types/reporting.js +6 -0
- package/dist/types/reporting.js.map +1 -0
- package/dist/types/test-case.d.ts +233 -0
- package/dist/types/test-case.d.ts.map +1 -0
- package/dist/types/test-case.js +6 -0
- package/dist/types/test-case.js.map +1 -0
- package/dist/types/test-execution.d.ts +80 -0
- package/dist/types/test-execution.d.ts.map +1 -0
- package/dist/types/test-execution.js +6 -0
- package/dist/types/test-execution.js.map +1 -0
- package/dist/utils/auth-generator.d.ts +30 -0
- package/dist/utils/auth-generator.d.ts.map +1 -0
- package/dist/utils/auth-generator.js +68 -0
- package/dist/utils/auth-generator.js.map +1 -0
- package/dist/utils/config.d.ts +181 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +141 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/coverage-calculator.d.ts +81 -0
- package/dist/utils/coverage-calculator.d.ts.map +1 -0
- package/dist/utils/coverage-calculator.js +134 -0
- package/dist/utils/coverage-calculator.js.map +1 -0
- package/dist/utils/data-loader.d.ts +52 -0
- package/dist/utils/data-loader.d.ts.map +1 -0
- package/dist/utils/data-loader.js +192 -0
- package/dist/utils/data-loader.js.map +1 -0
- package/dist/utils/errors.d.ts +167 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +257 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/logger.d.ts +220 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +325 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/openapi-discovery.d.ts +31 -0
- package/dist/utils/openapi-discovery.d.ts.map +1 -0
- package/dist/utils/openapi-discovery.js +322 -0
- package/dist/utils/openapi-discovery.js.map +1 -0
- package/dist/utils/path-resolver.d.ts +101 -0
- package/dist/utils/path-resolver.d.ts.map +1 -0
- package/dist/utils/path-resolver.js +167 -0
- package/dist/utils/path-resolver.js.map +1 -0
- package/dist/utils/resilience.d.ts +181 -0
- package/dist/utils/resilience.d.ts.map +1 -0
- package/dist/utils/resilience.js +269 -0
- package/dist/utils/resilience.js.map +1 -0
- package/dist/validators/openapi-validator.d.ts +198 -0
- package/dist/validators/openapi-validator.d.ts.map +1 -0
- package/dist/validators/openapi-validator.js +349 -0
- package/dist/validators/openapi-validator.js.map +1 -0
- package/dist/validators/response-matcher.d.ts +84 -0
- package/dist/validators/response-matcher.d.ts.map +1 -0
- package/dist/validators/response-matcher.js +234 -0
- package/dist/validators/response-matcher.js.map +1 -0
- package/dist/validators/schema-validator.d.ts +174 -0
- package/dist/validators/schema-validator.d.ts.map +1 -0
- package/dist/validators/schema-validator.js +340 -0
- package/dist/validators/schema-validator.js.map +1 -0
- package/package.json +76 -0
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Happy Path Test Case Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates valid test cases for all endpoints in an OpenAPI specification.
|
|
5
|
+
* These tests represent the "happy path" - normal, successful scenarios with valid data.
|
|
6
|
+
*
|
|
7
|
+
* @module generators/happy-path-generator
|
|
8
|
+
*/
|
|
9
|
+
import { faker } from '@faker-js/faker';
|
|
10
|
+
import { generateDataFromSchema, aiLevelToMode } from './data-generator.js';
|
|
11
|
+
import { generateAuthHeaders } from '../utils/auth-generator.js';
|
|
12
|
+
/**
|
|
13
|
+
* Generates happy path test cases for all endpoints in an OpenAPI specification
|
|
14
|
+
*
|
|
15
|
+
* @param endpoints - Array of parsed endpoints from OpenAPI spec
|
|
16
|
+
* @param options - Generation options
|
|
17
|
+
* @returns Array of happy path test cases
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const spec = await parseOpenAPISpec('./api.yml');
|
|
22
|
+
* const endpoints = extractEndpoints(spec);
|
|
23
|
+
* const tests = generateHappyPathTests(endpoints);
|
|
24
|
+
* console.log(`Generated ${tests.length} happy path tests`);
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export async function generateHappyPathTests(endpoints, options = {}) {
|
|
28
|
+
const { seed } = options;
|
|
29
|
+
// Set seed for reproducibility if provided
|
|
30
|
+
if (seed !== undefined) {
|
|
31
|
+
faker.seed(seed);
|
|
32
|
+
}
|
|
33
|
+
const testCases = [];
|
|
34
|
+
for (const endpoint of endpoints) {
|
|
35
|
+
const testCase = await generateHappyPathTest(endpoint, options);
|
|
36
|
+
if (testCase) {
|
|
37
|
+
testCases.push(testCase);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return testCases;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Generates a single happy path test case for an endpoint
|
|
44
|
+
*
|
|
45
|
+
* @param endpoint - Parsed endpoint information
|
|
46
|
+
* @param options - Generation options (for real data)
|
|
47
|
+
* @returns Happy path test case, or undefined if cannot generate
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
async function generateHappyPathTest(endpoint, options = {}) {
|
|
51
|
+
const { method, path, pathParams, queryParams, requestBody, responses } = endpoint;
|
|
52
|
+
const { realData, useExamples = true, includeOptional = true, aiLevel, aiMode, apiContext } = options;
|
|
53
|
+
// Determine expected success status code
|
|
54
|
+
const expectedStatus = getSuccessStatusCode(method, responses);
|
|
55
|
+
if (!expectedStatus) {
|
|
56
|
+
// Cannot determine success status, skip this endpoint
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
// Generate path parameters
|
|
60
|
+
const pathParamsData = {};
|
|
61
|
+
for (const param of pathParams) {
|
|
62
|
+
pathParamsData[param.name] = generatePathParamValue(param);
|
|
63
|
+
}
|
|
64
|
+
// Generate query parameters (only required ones for happy path)
|
|
65
|
+
const queryParamsData = {};
|
|
66
|
+
for (const param of queryParams) {
|
|
67
|
+
if (param.required) {
|
|
68
|
+
queryParamsData[param.name] = generateQueryParamValue(param);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Determine effective AI mode based on aiLevel
|
|
72
|
+
const effectiveAiMode = aiLevelToMode(aiLevel, aiMode);
|
|
73
|
+
// Generate request body with REAL DATA for happy paths
|
|
74
|
+
const bodyData = requestBody
|
|
75
|
+
? await generateDataFromSchema(requestBody, {
|
|
76
|
+
includeOptional,
|
|
77
|
+
realData, // ← CRITICAL: Use real credentials/data
|
|
78
|
+
useExamples, // ← Use schema examples
|
|
79
|
+
aiMode: effectiveAiMode,
|
|
80
|
+
apiContext
|
|
81
|
+
})
|
|
82
|
+
: undefined;
|
|
83
|
+
// Generate authentication headers if endpoint requires auth
|
|
84
|
+
const authHeaders = generateAuthHeaders(endpoint.securitySchemes || []);
|
|
85
|
+
// Get expected response schema
|
|
86
|
+
const expectedSchema = responses[expectedStatus];
|
|
87
|
+
// Generate test case ID and name
|
|
88
|
+
const testId = `happy-${method.toLowerCase()}-${path.replace(/[^a-zA-Z0-9]/g, '-')}`;
|
|
89
|
+
const testName = `${method} ${path} - Happy Path`;
|
|
90
|
+
return {
|
|
91
|
+
id: testId,
|
|
92
|
+
name: testName,
|
|
93
|
+
description: `Valid request to ${method} ${path} with all required fields`,
|
|
94
|
+
category: 'happy-path',
|
|
95
|
+
method,
|
|
96
|
+
path,
|
|
97
|
+
pathParams: pathParamsData,
|
|
98
|
+
queryParams: queryParamsData,
|
|
99
|
+
headers: authHeaders, // ← NUEVO: Include auth headers
|
|
100
|
+
body: bodyData,
|
|
101
|
+
contentType: endpoint.requestContentType, // AGNOSTIC: From OpenAPI spec (json, form-urlencoded, etc.)
|
|
102
|
+
expectedStatus,
|
|
103
|
+
expectedSchema,
|
|
104
|
+
validateSchema: true,
|
|
105
|
+
requiresAuth: endpoint.requiresAuth, // AGNOSTIC: From OpenAPI spec
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Determines the expected success status code for an HTTP method
|
|
110
|
+
*
|
|
111
|
+
* @param method - HTTP method
|
|
112
|
+
* @param responses - Response schemas by status code
|
|
113
|
+
* @returns Success status code, or undefined if none found
|
|
114
|
+
* @internal
|
|
115
|
+
*/
|
|
116
|
+
function getSuccessStatusCode(method, responses) {
|
|
117
|
+
// Priority order for success codes based on method
|
|
118
|
+
const successCodesByMethod = {
|
|
119
|
+
GET: [200],
|
|
120
|
+
POST: [201, 200],
|
|
121
|
+
PUT: [200, 204],
|
|
122
|
+
PATCH: [200, 204],
|
|
123
|
+
DELETE: [204, 200],
|
|
124
|
+
HEAD: [200],
|
|
125
|
+
OPTIONS: [200],
|
|
126
|
+
};
|
|
127
|
+
const priorityCodes = successCodesByMethod[method] || [200];
|
|
128
|
+
// Try to find a success code in priority order
|
|
129
|
+
for (const code of priorityCodes) {
|
|
130
|
+
if (responses[code]) {
|
|
131
|
+
return code;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
// If no priority code found, look for any 2xx code
|
|
135
|
+
const availableCodes = Object.keys(responses).map(Number);
|
|
136
|
+
const successCode = availableCodes.find(code => code >= 200 && code < 300);
|
|
137
|
+
return successCode;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Generates a valid value for a path parameter
|
|
141
|
+
*
|
|
142
|
+
* @param param - Path parameter definition
|
|
143
|
+
* @returns Generated parameter value
|
|
144
|
+
* @internal
|
|
145
|
+
*/
|
|
146
|
+
function generatePathParamValue(param) {
|
|
147
|
+
if (!param.schema || '$ref' in param.schema) {
|
|
148
|
+
// Fallback: generate a reasonable default
|
|
149
|
+
return faker.string.uuid();
|
|
150
|
+
}
|
|
151
|
+
const schema = param.schema;
|
|
152
|
+
// Generate based on schema type and format
|
|
153
|
+
if (schema.type === 'integer') {
|
|
154
|
+
return schema.minimum ?? 1;
|
|
155
|
+
}
|
|
156
|
+
if (schema.type === 'number') {
|
|
157
|
+
return schema.minimum ?? 1.0;
|
|
158
|
+
}
|
|
159
|
+
if (schema.type === 'string') {
|
|
160
|
+
if (schema.format === 'uuid') {
|
|
161
|
+
return faker.string.uuid();
|
|
162
|
+
}
|
|
163
|
+
if (schema.enum && schema.enum.length > 0) {
|
|
164
|
+
return schema.enum[0];
|
|
165
|
+
}
|
|
166
|
+
if (schema.pattern) {
|
|
167
|
+
// For patterns, generate a simple valid value
|
|
168
|
+
return faker.string.alphanumeric(10);
|
|
169
|
+
}
|
|
170
|
+
// Default string
|
|
171
|
+
return faker.string.alphanumeric(10);
|
|
172
|
+
}
|
|
173
|
+
// Fallback
|
|
174
|
+
return faker.string.uuid();
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Generates a valid value for a query parameter
|
|
178
|
+
*
|
|
179
|
+
* @param param - Query parameter definition
|
|
180
|
+
* @returns Generated parameter value
|
|
181
|
+
* @internal
|
|
182
|
+
*/
|
|
183
|
+
function generateQueryParamValue(param) {
|
|
184
|
+
if (!param.schema || '$ref' in param.schema) {
|
|
185
|
+
// Fallback: generate a reasonable default
|
|
186
|
+
return 'value';
|
|
187
|
+
}
|
|
188
|
+
const schema = param.schema;
|
|
189
|
+
// Use default if available
|
|
190
|
+
if (schema.default !== undefined) {
|
|
191
|
+
return schema.default;
|
|
192
|
+
}
|
|
193
|
+
// Generate based on schema type
|
|
194
|
+
if (schema.type === 'boolean') {
|
|
195
|
+
return true;
|
|
196
|
+
}
|
|
197
|
+
if (schema.type === 'integer') {
|
|
198
|
+
const min = schema.minimum ?? 1;
|
|
199
|
+
const max = schema.maximum ?? 100;
|
|
200
|
+
return Math.floor((min + max) / 2);
|
|
201
|
+
}
|
|
202
|
+
if (schema.type === 'number') {
|
|
203
|
+
const min = schema.minimum ?? 1;
|
|
204
|
+
const max = schema.maximum ?? 100;
|
|
205
|
+
return (min + max) / 2;
|
|
206
|
+
}
|
|
207
|
+
if (schema.type === 'string') {
|
|
208
|
+
if (schema.enum && schema.enum.length > 0) {
|
|
209
|
+
return schema.enum[0];
|
|
210
|
+
}
|
|
211
|
+
return faker.lorem.word();
|
|
212
|
+
}
|
|
213
|
+
// Fallback
|
|
214
|
+
return 'value';
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Generates happy path test cases for a specific endpoint path
|
|
218
|
+
*
|
|
219
|
+
* Useful when you want to generate tests for only certain endpoints.
|
|
220
|
+
*
|
|
221
|
+
* @param endpoints - Array of parsed endpoints
|
|
222
|
+
* @param pathFilter - Path pattern to filter (e.g., '/users', '/users/{id}')
|
|
223
|
+
* @param options - Generation options
|
|
224
|
+
* @returns Array of happy path test cases for matching endpoints
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```typescript
|
|
228
|
+
* const spec = await parseOpenAPISpec('./api.yml');
|
|
229
|
+
* const endpoints = extractEndpoints(spec);
|
|
230
|
+
* const userTests = generateHappyPathTestsForPath(endpoints, '/users');
|
|
231
|
+
* ```
|
|
232
|
+
*/
|
|
233
|
+
export async function generateHappyPathTestsForPath(endpoints, pathFilter, options = {}) {
|
|
234
|
+
const filteredEndpoints = endpoints.filter(e => e.path === pathFilter);
|
|
235
|
+
return await generateHappyPathTests(filteredEndpoints, options);
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Generates happy path test cases for a specific HTTP method
|
|
239
|
+
*
|
|
240
|
+
* @param endpoints - Array of parsed endpoints
|
|
241
|
+
* @param methodFilter - HTTP method to filter (e.g., 'GET', 'POST')
|
|
242
|
+
* @param options - Generation options
|
|
243
|
+
* @returns Array of happy path test cases for matching method
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* ```typescript
|
|
247
|
+
* const spec = await parseOpenAPISpec('./api.yml');
|
|
248
|
+
* const endpoints = extractEndpoints(spec);
|
|
249
|
+
* const postTests = generateHappyPathTestsForMethod(endpoints, 'POST');
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
export async function generateHappyPathTestsForMethod(endpoints, methodFilter, options = {}) {
|
|
253
|
+
const filteredEndpoints = endpoints.filter(e => e.method === methodFilter);
|
|
254
|
+
return await generateHappyPathTests(filteredEndpoints, options);
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Generates happy path test cases for endpoints with a specific tag
|
|
258
|
+
*
|
|
259
|
+
* @param endpoints - Array of parsed endpoints
|
|
260
|
+
* @param tag - OpenAPI tag to filter by
|
|
261
|
+
* @param options - Generation options
|
|
262
|
+
* @returns Array of happy path test cases for matching tag
|
|
263
|
+
*
|
|
264
|
+
* @example
|
|
265
|
+
* ```typescript
|
|
266
|
+
* const spec = await parseOpenAPISpec('./api.yml');
|
|
267
|
+
* const endpoints = extractEndpoints(spec);
|
|
268
|
+
* const userTests = generateHappyPathTestsForTag(endpoints, 'users');
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
export async function generateHappyPathTestsForTag(endpoints, tag, options = {}) {
|
|
272
|
+
const filteredEndpoints = endpoints.filter(e => e.operation.tags?.includes(tag));
|
|
273
|
+
return await generateHappyPathTests(filteredEndpoints, options);
|
|
274
|
+
}
|
|
275
|
+
//# sourceMappingURL=happy-path-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"happy-path-generator.js","sourceRoot":"","sources":["../../src/generators/happy-path-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAGxC,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAyB,MAAM,qBAAqB,CAAC;AACnG,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,SAA2B,EAC3B,UAA4B,EAAE;IAE9B,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IAEzB,2CAA2C;IAC3C,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC;IAED,MAAM,SAAS,GAAe,EAAE,CAAC;IAEjC,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,MAAM,QAAQ,GAAG,MAAM,qBAAqB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAChE,IAAI,QAAQ,EAAE,CAAC;YACb,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAoBD;;;;;;;GAOG;AACH,KAAK,UAAU,qBAAqB,CAAC,QAAwB,EAAE,UAA4B,EAAE;IAC3F,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,QAAQ,CAAC;IACnF,MAAM,EAAE,QAAQ,EAAE,WAAW,GAAG,IAAI,EAAE,eAAe,GAAG,IAAI,EAAE,OAAO,EAAE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
|
|
|
1
|
+
/**
|
|
2
|
+
* Test Enricher - Post-processing for test metadata
|
|
3
|
+
*
|
|
4
|
+
* Enriches generated tests with technical metadata from OpenAPI endpoints.
|
|
5
|
+
* This is the SINGLE SOURCE OF TRUTH for headers, contentType, and auth requirements.
|
|
6
|
+
*
|
|
7
|
+
* @module generators/test-enricher
|
|
8
|
+
*/
|
|
9
|
+
import type { TestCase, ParsedEndpoint } from '../types/index.js';
|
|
10
|
+
import { generateAuthHeaders } from '../utils/auth-generator.js';
|
|
11
|
+
/**
|
|
12
|
+
* Enriches tests with metadata from their corresponding endpoints
|
|
13
|
+
*
|
|
14
|
+
* This function ensures ALL tests (heuristic or LLM-generated) have complete
|
|
15
|
+
* technical metadata inferred from the OpenAPI specification.
|
|
16
|
+
*
|
|
17
|
+
* @param tests - Array of tests to enrich
|
|
18
|
+
* @param endpoints - Array of parsed endpoints from OpenAPI spec
|
|
19
|
+
* @returns Enriched tests with complete metadata
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const tests = [...heuristicTests, ...llmTests];
|
|
24
|
+
* const enrichedTests = enrichTestsWithMetadata(tests, endpoints);
|
|
25
|
+
* // All tests now have headers, contentType, requiresAuth, etc.
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function enrichTestsWithMetadata(tests: TestCase[], endpoints: ParsedEndpoint[]): TestCase[];
|
|
29
|
+
export { generateAuthHeaders };
|
|
30
|
+
/**
|
|
31
|
+
* Validates that a test has all required metadata
|
|
32
|
+
*
|
|
33
|
+
* @param test - Test case to validate
|
|
34
|
+
* @returns True if test has all required metadata
|
|
35
|
+
*/
|
|
36
|
+
export declare function validateTestMetadata(test: TestCase): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Filters tests that have valid metadata
|
|
39
|
+
*
|
|
40
|
+
* @param tests - Array of tests to filter
|
|
41
|
+
* @returns Only tests with valid metadata
|
|
42
|
+
*/
|
|
43
|
+
export declare function filterValidTests(tests: TestCase[]): TestCase[];
|
|
44
|
+
//# sourceMappingURL=test-enricher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-enricher.d.ts","sourceRoot":"","sources":["../../src/generators/test-enricher.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAElE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAIjE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,QAAQ,EAAE,EACjB,SAAS,EAAE,cAAc,EAAE,GAC1B,QAAQ,EAAE,CAsDZ;AAGD,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAE/B;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAa5D;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,QAAQ,EAAE,CAY9D"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test Enricher - Post-processing for test metadata
|
|
3
|
+
*
|
|
4
|
+
* Enriches generated tests with technical metadata from OpenAPI endpoints.
|
|
5
|
+
* This is the SINGLE SOURCE OF TRUTH for headers, contentType, and auth requirements.
|
|
6
|
+
*
|
|
7
|
+
* @module generators/test-enricher
|
|
8
|
+
*/
|
|
9
|
+
import { createLogger } from '../utils/logger.js';
|
|
10
|
+
import { generateAuthHeaders } from '../utils/auth-generator.js';
|
|
11
|
+
const log = createLogger('test-enricher');
|
|
12
|
+
/**
|
|
13
|
+
* Enriches tests with metadata from their corresponding endpoints
|
|
14
|
+
*
|
|
15
|
+
* This function ensures ALL tests (heuristic or LLM-generated) have complete
|
|
16
|
+
* technical metadata inferred from the OpenAPI specification.
|
|
17
|
+
*
|
|
18
|
+
* @param tests - Array of tests to enrich
|
|
19
|
+
* @param endpoints - Array of parsed endpoints from OpenAPI spec
|
|
20
|
+
* @returns Enriched tests with complete metadata
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const tests = [...heuristicTests, ...llmTests];
|
|
25
|
+
* const enrichedTests = enrichTestsWithMetadata(tests, endpoints);
|
|
26
|
+
* // All tests now have headers, contentType, requiresAuth, etc.
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export function enrichTestsWithMetadata(tests, endpoints) {
|
|
30
|
+
log.info('Enriching tests with endpoint metadata', {
|
|
31
|
+
testCount: tests.length,
|
|
32
|
+
endpointCount: endpoints.length
|
|
33
|
+
});
|
|
34
|
+
const enriched = tests.map(test => {
|
|
35
|
+
// Find corresponding endpoint
|
|
36
|
+
const endpoint = endpoints.find(e => e.method === test.method && e.path === test.path);
|
|
37
|
+
if (!endpoint) {
|
|
38
|
+
log.warn('Endpoint not found for test', {
|
|
39
|
+
testId: test.id,
|
|
40
|
+
method: test.method,
|
|
41
|
+
path: test.path
|
|
42
|
+
});
|
|
43
|
+
return test; // Return as-is if endpoint not found
|
|
44
|
+
}
|
|
45
|
+
// Enrich with endpoint metadata
|
|
46
|
+
const enrichedTest = {
|
|
47
|
+
...test,
|
|
48
|
+
// Headers: use test's headers if present, otherwise infer from endpoint
|
|
49
|
+
headers: (test.headers && Object.keys(test.headers).length > 0)
|
|
50
|
+
? test.headers
|
|
51
|
+
: generateAuthHeaders(endpoint.securitySchemes || []),
|
|
52
|
+
// Content-Type: from endpoint if not specified
|
|
53
|
+
contentType: test.contentType || endpoint.requestContentType,
|
|
54
|
+
// Auth requirement: from endpoint
|
|
55
|
+
requiresAuth: endpoint.requiresAuth
|
|
56
|
+
};
|
|
57
|
+
log.debug('Test enriched', {
|
|
58
|
+
testId: test.id,
|
|
59
|
+
hadHeaders: !!(test.headers && Object.keys(test.headers).length > 0),
|
|
60
|
+
enrichedHeaders: Object.keys(enrichedTest.headers || {}).length,
|
|
61
|
+
contentType: enrichedTest.contentType,
|
|
62
|
+
requiresAuth: enrichedTest.requiresAuth
|
|
63
|
+
});
|
|
64
|
+
return enrichedTest;
|
|
65
|
+
});
|
|
66
|
+
log.info('Tests enrichment completed', {
|
|
67
|
+
enrichedCount: enriched.length,
|
|
68
|
+
withHeaders: enriched.filter(t => t.headers && Object.keys(t.headers).length > 0).length
|
|
69
|
+
});
|
|
70
|
+
return enriched;
|
|
71
|
+
}
|
|
72
|
+
// Re-export generateAuthHeaders for backward compatibility
|
|
73
|
+
export { generateAuthHeaders };
|
|
74
|
+
/**
|
|
75
|
+
* Validates that a test has all required metadata
|
|
76
|
+
*
|
|
77
|
+
* @param test - Test case to validate
|
|
78
|
+
* @returns True if test has all required metadata
|
|
79
|
+
*/
|
|
80
|
+
export function validateTestMetadata(test) {
|
|
81
|
+
// Check if test has basic required fields
|
|
82
|
+
if (!test.method || !test.path || !test.expectedStatus) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
// If endpoint requires auth, test should have headers
|
|
86
|
+
if (test.requiresAuth && (!test.headers || Object.keys(test.headers).length === 0)) {
|
|
87
|
+
log.warn('Test requires auth but has no headers', { testId: test.id });
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Filters tests that have valid metadata
|
|
94
|
+
*
|
|
95
|
+
* @param tests - Array of tests to filter
|
|
96
|
+
* @returns Only tests with valid metadata
|
|
97
|
+
*/
|
|
98
|
+
export function filterValidTests(tests) {
|
|
99
|
+
const valid = tests.filter(validateTestMetadata);
|
|
100
|
+
if (valid.length < tests.length) {
|
|
101
|
+
log.warn('Some tests filtered out due to invalid metadata', {
|
|
102
|
+
total: tests.length,
|
|
103
|
+
valid: valid.length,
|
|
104
|
+
filtered: tests.length - valid.length
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return valid;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=test-enricher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-enricher.js","sourceRoot":"","sources":["../../src/generators/test-enricher.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,MAAM,GAAG,GAAG,YAAY,CAAC,eAAe,CAAC,CAAC;AAE1C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,uBAAuB,CACrC,KAAiB,EACjB,SAA2B;IAE3B,GAAG,CAAC,IAAI,CAAC,wCAAwC,EAAE;QACjD,SAAS,EAAE,KAAK,CAAC,MAAM;QACvB,aAAa,EAAE,SAAS,CAAC,MAAM;KAChC,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QAChC,8BAA8B;QAC9B,MAAM,QAAQ,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAClC,CAAC,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CACjD,CAAC;QAEF,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,GAAG,CAAC,IAAI,CAAC,6BAA6B,EAAE;gBACtC,MAAM,EAAE,IAAI,CAAC,EAAE;gBACf,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,IAAI,EAAE,IAAI,CAAC,IAAI;aAChB,CAAC,CAAC;YACH,OAAO,IAAI,CAAC,CAAC,qCAAqC;QACpD,CAAC;QAED,gCAAgC;QAChC,MAAM,YAAY,GAAa;YAC7B,GAAG,IAAI;YAEP,wEAAwE;YACxE,OAAO,EAAE,CAAC,IAAI,CAAC,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MA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AAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;QACvD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,sDAAsD;IACtD,IAAI,IAAI,CAAC,YAAY,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC;QACnF,GAAG,CAAC,IAAI,CAAC,uCAAuC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;QACvE,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAiB;IAChD,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;IAEjD,IAAI,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QAChC,GAAG,CAAC,IAAI,CAAC,iDAAiD,EAAE;YAC1D,KAAK,EAAE,KAAK,CAAC,MAAM;YACnB,KAAK,EAAE,KAAK,CAAC,MAAM;YACnB,QAAQ,EAAE,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM;SACtC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;GAKG"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* OpenAPI Contract Tester MCP Server
|
|
4
|
+
* Entry point for the Model Context Protocol server
|
|
5
|
+
*
|
|
6
|
+
* @module index
|
|
7
|
+
*/
|
|
8
|
+
import { startMCPServer } from './mcp/server.js';
|
|
9
|
+
// Start the MCP server
|
|
10
|
+
startMCPServer().catch((error) => {
|
|
11
|
+
console.error('Fatal error starting MCP server:', error);
|
|
12
|
+
process.exit(1);
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,uBAAuB;AACvB,cAAc,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IAC/B,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;IACzD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Response Cache
|
|
3
|
+
*
|
|
4
|
+
* Caches LLM responses to reduce API calls, costs, and latency.
|
|
5
|
+
* Uses simple in-memory cache with TTL (time-to-live).
|
|
6
|
+
*
|
|
7
|
+
* @module llm/ai-cache
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Cache statistics
|
|
11
|
+
*/
|
|
12
|
+
interface CacheStats {
|
|
13
|
+
hits: number;
|
|
14
|
+
misses: number;
|
|
15
|
+
size: number;
|
|
16
|
+
hitRate: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* AI Response Cache
|
|
20
|
+
*
|
|
21
|
+
* Simple in-memory cache for LLM responses.
|
|
22
|
+
* Automatically expires entries after TTL.
|
|
23
|
+
*/
|
|
24
|
+
declare class AICache {
|
|
25
|
+
private cache;
|
|
26
|
+
private readonly TTL;
|
|
27
|
+
private hits;
|
|
28
|
+
private misses;
|
|
29
|
+
/**
|
|
30
|
+
* Creates a new AI cache
|
|
31
|
+
*
|
|
32
|
+
* @param ttl - Time-to-live in milliseconds (default: 1 hour)
|
|
33
|
+
*/
|
|
34
|
+
constructor(ttl?: number);
|
|
35
|
+
/**
|
|
36
|
+
* Generates a hash key for a prompt
|
|
37
|
+
*
|
|
38
|
+
* @param prompt - Prompt text
|
|
39
|
+
* @returns Hash key
|
|
40
|
+
*/
|
|
41
|
+
private getHash;
|
|
42
|
+
/**
|
|
43
|
+
* Gets cached response for a prompt
|
|
44
|
+
*
|
|
45
|
+
* @param prompt - Prompt text
|
|
46
|
+
* @returns Cached response or null if not found/expired
|
|
47
|
+
*/
|
|
48
|
+
get(prompt: string): string | null;
|
|
49
|
+
/**
|
|
50
|
+
* Stores a response in the cache
|
|
51
|
+
*
|
|
52
|
+
* @param prompt - Prompt text
|
|
53
|
+
* @param response - LLM response
|
|
54
|
+
*/
|
|
55
|
+
set(prompt: string, response: string): void;
|
|
56
|
+
/**
|
|
57
|
+
* Clears the entire cache
|
|
58
|
+
*/
|
|
59
|
+
clear(): void;
|
|
60
|
+
/**
|
|
61
|
+
* Removes expired entries from the cache
|
|
62
|
+
*/
|
|
63
|
+
private cleanup;
|
|
64
|
+
/**
|
|
65
|
+
* Gets cache statistics
|
|
66
|
+
*
|
|
67
|
+
* @returns Cache statistics
|
|
68
|
+
*/
|
|
69
|
+
getStats(): CacheStats;
|
|
70
|
+
/**
|
|
71
|
+
* Logs cache statistics
|
|
72
|
+
*/
|
|
73
|
+
logStats(): void;
|
|
74
|
+
/**
|
|
75
|
+
* Checks if cache contains a prompt
|
|
76
|
+
*
|
|
77
|
+
* @param prompt - Prompt text
|
|
78
|
+
* @returns true if cached and not expired
|
|
79
|
+
*/
|
|
80
|
+
has(prompt: string): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Gets the number of entries in the cache
|
|
83
|
+
*
|
|
84
|
+
* @returns Cache size
|
|
85
|
+
*/
|
|
86
|
+
size(): number;
|
|
87
|
+
/**
|
|
88
|
+
* Removes a specific entry from the cache
|
|
89
|
+
*
|
|
90
|
+
* @param prompt - Prompt text
|
|
91
|
+
* @returns true if entry was removed
|
|
92
|
+
*/
|
|
93
|
+
delete(prompt: string): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Gets all cached prompts (for debugging)
|
|
96
|
+
*
|
|
97
|
+
* @returns Array of cached prompt hashes and timestamps
|
|
98
|
+
*/
|
|
99
|
+
getCachedPrompts(): Array<{
|
|
100
|
+
hash: string;
|
|
101
|
+
age: number;
|
|
102
|
+
hits: number;
|
|
103
|
+
}>;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Global AI cache instance (1 hour TTL)
|
|
107
|
+
*/
|
|
108
|
+
export declare const aiCache: AICache;
|
|
109
|
+
/**
|
|
110
|
+
* Gets the global AI cache instance
|
|
111
|
+
*
|
|
112
|
+
* @returns AI cache instance
|
|
113
|
+
*/
|
|
114
|
+
export declare function getAICache(): AICache;
|
|
115
|
+
/**
|
|
116
|
+
* Creates a new AI cache with custom TTL
|
|
117
|
+
*
|
|
118
|
+
* @param ttl - Time-to-live in milliseconds
|
|
119
|
+
* @returns New AI cache instance
|
|
120
|
+
*/
|
|
121
|
+
export declare function createAICache(ttl: number): AICache;
|
|
122
|
+
export {};
|
|
123
|
+
//# sourceMappingURL=ai-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-cache.d.ts","sourceRoot":"","sources":["../../src/llm/ai-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAiBH;;GAEG;AACH,UAAU,UAAU;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,cAAM,OAAO;IACX,OAAO,CAAC,KAAK,CAAsC;IACnD,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,IAAI,CAAK;IACjB,OAAO,CAAC,MAAM,CAAK;IAEnB;;;;OAIG;gBACS,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