api-tests-coverage 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/README.md +703 -0
- package/config.yaml.example +227 -0
- package/dist/action/src/index.d.ts +2 -0
- package/dist/action/src/index.d.ts.map +1 -0
- package/dist/action/src/index.js +349 -0
- package/dist/action/src/prComment.d.ts +34 -0
- package/dist/action/src/prComment.d.ts.map +1 -0
- package/dist/action/src/prComment.js +146 -0
- package/dist/src/ast/astAnalysisOrchestrator.d.ts +36 -0
- package/dist/src/ast/astAnalysisOrchestrator.d.ts.map +1 -0
- package/dist/src/ast/astAnalysisOrchestrator.js +123 -0
- package/dist/src/ast/astTypes.d.ts +105 -0
- package/dist/src/ast/astTypes.d.ts.map +1 -0
- package/dist/src/ast/astTypes.js +9 -0
- package/dist/src/ast/languageAnalyzer.d.ts +46 -0
- package/dist/src/ast/languageAnalyzer.d.ts.map +1 -0
- package/dist/src/ast/languageAnalyzer.js +9 -0
- package/dist/src/ast/languageCapabilities.d.ts +24 -0
- package/dist/src/ast/languageCapabilities.d.ts.map +1 -0
- package/dist/src/ast/languageCapabilities.js +92 -0
- package/dist/src/ast/parseFile.d.ts +16 -0
- package/dist/src/ast/parseFile.d.ts.map +1 -0
- package/dist/src/ast/parseFile.js +65 -0
- package/dist/src/ast/parserRegistry.d.ts +39 -0
- package/dist/src/ast/parserRegistry.d.ts.map +1 -0
- package/dist/src/ast/parserRegistry.js +66 -0
- package/dist/src/buildSummary.d.ts +26 -0
- package/dist/src/buildSummary.d.ts.map +1 -0
- package/dist/src/buildSummary.js +193 -0
- package/dist/src/businessCoverage.d.ts +68 -0
- package/dist/src/businessCoverage.d.ts.map +1 -0
- package/dist/src/businessCoverage.js +290 -0
- package/dist/src/compatibilityCoverage.d.ts +83 -0
- package/dist/src/compatibilityCoverage.d.ts.map +1 -0
- package/dist/src/compatibilityCoverage.js +501 -0
- package/dist/src/config/defaultConfig.d.ts +9 -0
- package/dist/src/config/defaultConfig.d.ts.map +1 -0
- package/dist/src/config/defaultConfig.js +97 -0
- package/dist/src/config/index.d.ts +12 -0
- package/dist/src/config/index.d.ts.map +1 -0
- package/dist/src/config/index.js +37 -0
- package/dist/src/config/loadConfig.d.ts +29 -0
- package/dist/src/config/loadConfig.d.ts.map +1 -0
- package/dist/src/config/loadConfig.js +135 -0
- package/dist/src/config/mergeConfig.d.ts +15 -0
- package/dist/src/config/mergeConfig.d.ts.map +1 -0
- package/dist/src/config/mergeConfig.js +57 -0
- package/dist/src/config/schema.d.ts +15 -0
- package/dist/src/config/schema.d.ts.map +1 -0
- package/dist/src/config/schema.js +30 -0
- package/dist/src/config/types.d.ts +175 -0
- package/dist/src/config/types.d.ts.map +1 -0
- package/dist/src/config/types.js +9 -0
- package/dist/src/config/validateConfig.d.ts +22 -0
- package/dist/src/config/validateConfig.d.ts.map +1 -0
- package/dist/src/config/validateConfig.js +171 -0
- package/dist/src/config.d.ts +168 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +204 -0
- package/dist/src/coverage/deep-analysis/callGraph.d.ts +67 -0
- package/dist/src/coverage/deep-analysis/callGraph.d.ts.map +1 -0
- package/dist/src/coverage/deep-analysis/callGraph.js +275 -0
- package/dist/src/coverage/deep-analysis/deepEndpointResolver.d.ts +23 -0
- package/dist/src/coverage/deep-analysis/deepEndpointResolver.d.ts.map +1 -0
- package/dist/src/coverage/deep-analysis/deepEndpointResolver.js +394 -0
- package/dist/src/coverage/deep-analysis/index.d.ts +17 -0
- package/dist/src/coverage/deep-analysis/index.d.ts.map +1 -0
- package/dist/src/coverage/deep-analysis/index.js +63 -0
- package/dist/src/coverage/deep-analysis/resolveAssertions.d.ts +60 -0
- package/dist/src/coverage/deep-analysis/resolveAssertions.d.ts.map +1 -0
- package/dist/src/coverage/deep-analysis/resolveAssertions.js +121 -0
- package/dist/src/coverage/deep-analysis/resolveConstants.d.ts +36 -0
- package/dist/src/coverage/deep-analysis/resolveConstants.d.ts.map +1 -0
- package/dist/src/coverage/deep-analysis/resolveConstants.js +92 -0
- package/dist/src/coverage/deep-analysis/resolveEnums.d.ts +55 -0
- package/dist/src/coverage/deep-analysis/resolveEnums.d.ts.map +1 -0
- package/dist/src/coverage/deep-analysis/resolveEnums.js +152 -0
- package/dist/src/coverage/deep-analysis/resolveMethodChains.d.ts +70 -0
- package/dist/src/coverage/deep-analysis/resolveMethodChains.d.ts.map +1 -0
- package/dist/src/coverage/deep-analysis/resolveMethodChains.js +152 -0
- package/dist/src/coverage/deep-analysis/resolvePaths.d.ts +80 -0
- package/dist/src/coverage/deep-analysis/resolvePaths.d.ts.map +1 -0
- package/dist/src/coverage/deep-analysis/resolvePaths.js +216 -0
- package/dist/src/coverage/deep-analysis/resolveRequestWrappers.d.ts +71 -0
- package/dist/src/coverage/deep-analysis/resolveRequestWrappers.d.ts.map +1 -0
- package/dist/src/coverage/deep-analysis/resolveRequestWrappers.js +226 -0
- package/dist/src/coverage/deep-analysis/symbolTable.d.ts +58 -0
- package/dist/src/coverage/deep-analysis/symbolTable.d.ts.map +1 -0
- package/dist/src/coverage/deep-analysis/symbolTable.js +230 -0
- package/dist/src/coverage/deep-analysis/types.d.ts +122 -0
- package/dist/src/coverage/deep-analysis/types.d.ts.map +1 -0
- package/dist/src/coverage/deep-analysis/types.js +21 -0
- package/dist/src/discovery/fileClassifier.d.ts +50 -0
- package/dist/src/discovery/fileClassifier.d.ts.map +1 -0
- package/dist/src/discovery/fileClassifier.js +238 -0
- package/dist/src/discovery/projectDiscovery.d.ts +66 -0
- package/dist/src/discovery/projectDiscovery.d.ts.map +1 -0
- package/dist/src/discovery/projectDiscovery.js +287 -0
- package/dist/src/endpointCoverage.d.ts +70 -0
- package/dist/src/endpointCoverage.d.ts.map +1 -0
- package/dist/src/endpointCoverage.js +381 -0
- package/dist/src/errorCoverage.d.ts +93 -0
- package/dist/src/errorCoverage.d.ts.map +1 -0
- package/dist/src/errorCoverage.js +698 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +1441 -0
- package/dist/src/inference/businessRuleInference.d.ts +63 -0
- package/dist/src/inference/businessRuleInference.d.ts.map +1 -0
- package/dist/src/inference/businessRuleInference.js +268 -0
- package/dist/src/inference/integrationFlowInference.d.ts +56 -0
- package/dist/src/inference/integrationFlowInference.d.ts.map +1 -0
- package/dist/src/inference/integrationFlowInference.js +266 -0
- package/dist/src/integrationCoverage.d.ts +72 -0
- package/dist/src/integrationCoverage.d.ts.map +1 -0
- package/dist/src/integrationCoverage.js +317 -0
- package/dist/src/intelligence/index.d.ts +20 -0
- package/dist/src/intelligence/index.d.ts.map +1 -0
- package/dist/src/intelligence/index.js +105 -0
- package/dist/src/intelligence/linkageEngine.d.ts +20 -0
- package/dist/src/intelligence/linkageEngine.d.ts.map +1 -0
- package/dist/src/intelligence/linkageEngine.js +522 -0
- package/dist/src/intelligence/markdownReporter.d.ts +12 -0
- package/dist/src/intelligence/markdownReporter.d.ts.map +1 -0
- package/dist/src/intelligence/markdownReporter.js +265 -0
- package/dist/src/intelligence/riskScoring.d.ts +53 -0
- package/dist/src/intelligence/riskScoring.d.ts.map +1 -0
- package/dist/src/intelligence/riskScoring.js +181 -0
- package/dist/src/intelligence/types.d.ts +121 -0
- package/dist/src/intelligence/types.d.ts.map +1 -0
- package/dist/src/intelligence/types.js +8 -0
- package/dist/src/languageDetection.d.ts +100 -0
- package/dist/src/languageDetection.d.ts.map +1 -0
- package/dist/src/languageDetection.js +349 -0
- package/dist/src/languages/java/index.d.ts +16 -0
- package/dist/src/languages/java/index.d.ts.map +1 -0
- package/dist/src/languages/java/index.js +103 -0
- package/dist/src/languages/java/parser.d.ts +7 -0
- package/dist/src/languages/java/parser.d.ts.map +1 -0
- package/dist/src/languages/java/parser.js +50 -0
- package/dist/src/languages/java/semanticBuilder.d.ts +21 -0
- package/dist/src/languages/java/semanticBuilder.d.ts.map +1 -0
- package/dist/src/languages/java/semanticBuilder.js +358 -0
- package/dist/src/languages/javascript/annotationExtractor.d.ts +20 -0
- package/dist/src/languages/javascript/annotationExtractor.d.ts.map +1 -0
- package/dist/src/languages/javascript/annotationExtractor.js +94 -0
- package/dist/src/languages/javascript/assertionResolver.d.ts +18 -0
- package/dist/src/languages/javascript/assertionResolver.d.ts.map +1 -0
- package/dist/src/languages/javascript/assertionResolver.js +150 -0
- package/dist/src/languages/javascript/callResolver.d.ts +23 -0
- package/dist/src/languages/javascript/callResolver.d.ts.map +1 -0
- package/dist/src/languages/javascript/callResolver.js +236 -0
- package/dist/src/languages/javascript/httpInteractionExtractor.d.ts +23 -0
- package/dist/src/languages/javascript/httpInteractionExtractor.d.ts.map +1 -0
- package/dist/src/languages/javascript/httpInteractionExtractor.js +205 -0
- package/dist/src/languages/javascript/index.d.ts +20 -0
- package/dist/src/languages/javascript/index.d.ts.map +1 -0
- package/dist/src/languages/javascript/index.js +136 -0
- package/dist/src/languages/javascript/parser.d.ts +14 -0
- package/dist/src/languages/javascript/parser.d.ts.map +1 -0
- package/dist/src/languages/javascript/parser.js +38 -0
- package/dist/src/languages/javascript/symbolResolver.d.ts +31 -0
- package/dist/src/languages/javascript/symbolResolver.d.ts.map +1 -0
- package/dist/src/languages/javascript/symbolResolver.js +183 -0
- package/dist/src/languages/kotlin/index.d.ts +16 -0
- package/dist/src/languages/kotlin/index.d.ts.map +1 -0
- package/dist/src/languages/kotlin/index.js +151 -0
- package/dist/src/languages/kotlin/parser.d.ts +11 -0
- package/dist/src/languages/kotlin/parser.d.ts.map +1 -0
- package/dist/src/languages/kotlin/parser.js +74 -0
- package/dist/src/languages/python/index.d.ts +15 -0
- package/dist/src/languages/python/index.d.ts.map +1 -0
- package/dist/src/languages/python/index.js +293 -0
- package/dist/src/languages/ruby/index.d.ts +15 -0
- package/dist/src/languages/ruby/index.d.ts.map +1 -0
- package/dist/src/languages/ruby/index.js +274 -0
- package/dist/src/languages/shared/treeSitterUtils.d.ts +43 -0
- package/dist/src/languages/shared/treeSitterUtils.d.ts.map +1 -0
- package/dist/src/languages/shared/treeSitterUtils.js +100 -0
- package/dist/src/languages/typescript/index.d.ts +14 -0
- package/dist/src/languages/typescript/index.d.ts.map +1 -0
- package/dist/src/languages/typescript/index.js +25 -0
- package/dist/src/lib/index.d.ts +228 -0
- package/dist/src/lib/index.d.ts.map +1 -0
- package/dist/src/lib/index.js +486 -0
- package/dist/src/mcp/client/index.d.ts +37 -0
- package/dist/src/mcp/client/index.d.ts.map +1 -0
- package/dist/src/mcp/client/index.js +235 -0
- package/dist/src/mcp/config.d.ts +50 -0
- package/dist/src/mcp/config.d.ts.map +1 -0
- package/dist/src/mcp/config.js +125 -0
- package/dist/src/mcp/events.d.ts +24 -0
- package/dist/src/mcp/events.d.ts.map +1 -0
- package/dist/src/mcp/events.js +48 -0
- package/dist/src/mcp/fallback/index.d.ts +50 -0
- package/dist/src/mcp/fallback/index.d.ts.map +1 -0
- package/dist/src/mcp/fallback/index.js +216 -0
- package/dist/src/mcp/index.d.ts +67 -0
- package/dist/src/mcp/index.d.ts.map +1 -0
- package/dist/src/mcp/index.js +212 -0
- package/dist/src/mcp/normalizer.d.ts +21 -0
- package/dist/src/mcp/normalizer.d.ts.map +1 -0
- package/dist/src/mcp/normalizer.js +99 -0
- package/dist/src/mcp/prompts/index.d.ts +86 -0
- package/dist/src/mcp/prompts/index.d.ts.map +1 -0
- package/dist/src/mcp/prompts/index.js +304 -0
- package/dist/src/mcp/templates/index.d.ts +35 -0
- package/dist/src/mcp/templates/index.d.ts.map +1 -0
- package/dist/src/mcp/templates/index.js +143 -0
- package/dist/src/mcp/testing/mock-server/index.d.ts +47 -0
- package/dist/src/mcp/testing/mock-server/index.d.ts.map +1 -0
- package/dist/src/mcp/testing/mock-server/index.js +157 -0
- package/dist/src/mcp/types.d.ts +127 -0
- package/dist/src/mcp/types.d.ts.map +1 -0
- package/dist/src/mcp/types.js +8 -0
- package/dist/src/observability.d.ts +138 -0
- package/dist/src/observability.d.ts.map +1 -0
- package/dist/src/observability.js +519 -0
- package/dist/src/parameterCoverage.d.ts +75 -0
- package/dist/src/parameterCoverage.d.ts.map +1 -0
- package/dist/src/parameterCoverage.js +629 -0
- package/dist/src/perfResilienceCoverage.d.ts +155 -0
- package/dist/src/perfResilienceCoverage.d.ts.map +1 -0
- package/dist/src/perfResilienceCoverage.js +670 -0
- package/dist/src/pluginLoader.d.ts +51 -0
- package/dist/src/pluginLoader.d.ts.map +1 -0
- package/dist/src/pluginLoader.js +72 -0
- package/dist/src/publishing.d.ts +63 -0
- package/dist/src/publishing.d.ts.map +1 -0
- package/dist/src/publishing.js +379 -0
- package/dist/src/qualityGate.d.ts +58 -0
- package/dist/src/qualityGate.d.ts.map +1 -0
- package/dist/src/qualityGate.js +118 -0
- package/dist/src/reporting.d.ts +41 -0
- package/dist/src/reporting.d.ts.map +1 -0
- package/dist/src/reporting.js +278 -0
- package/dist/src/screenshots.d.ts +71 -0
- package/dist/src/screenshots.d.ts.map +1 -0
- package/dist/src/screenshots.js +141 -0
- package/dist/src/security/gate/index.d.ts +11 -0
- package/dist/src/security/gate/index.d.ts.map +1 -0
- package/dist/src/security/gate/index.js +65 -0
- package/dist/src/security/index.d.ts +30 -0
- package/dist/src/security/index.d.ts.map +1 -0
- package/dist/src/security/index.js +342 -0
- package/dist/src/security/normalizers/semgrep.d.ts +10 -0
- package/dist/src/security/normalizers/semgrep.d.ts.map +1 -0
- package/dist/src/security/normalizers/semgrep.js +104 -0
- package/dist/src/security/normalizers/trivy.d.ts +10 -0
- package/dist/src/security/normalizers/trivy.d.ts.map +1 -0
- package/dist/src/security/normalizers/trivy.js +78 -0
- package/dist/src/security/normalizers/zap.d.ts +10 -0
- package/dist/src/security/normalizers/zap.d.ts.map +1 -0
- package/dist/src/security/normalizers/zap.js +104 -0
- package/dist/src/security/scanners/semgrep.d.ts +6 -0
- package/dist/src/security/scanners/semgrep.d.ts.map +1 -0
- package/dist/src/security/scanners/semgrep.js +125 -0
- package/dist/src/security/scanners/trivy.d.ts +6 -0
- package/dist/src/security/scanners/trivy.d.ts.map +1 -0
- package/dist/src/security/scanners/trivy.js +115 -0
- package/dist/src/security/scanners/zap.d.ts +6 -0
- package/dist/src/security/scanners/zap.d.ts.map +1 -0
- package/dist/src/security/scanners/zap.js +135 -0
- package/dist/src/security/types.d.ts +146 -0
- package/dist/src/security/types.d.ts.map +1 -0
- package/dist/src/security/types.js +6 -0
- package/dist/src/securityCoverage.d.ts +116 -0
- package/dist/src/securityCoverage.d.ts.map +1 -0
- package/dist/src/securityCoverage.js +725 -0
- package/dist/src/summary/buildSummary.d.ts +28 -0
- package/dist/src/summary/buildSummary.d.ts.map +1 -0
- package/dist/src/summary/buildSummary.js +257 -0
- package/dist/src/summary/evaluateMetrics.d.ts +31 -0
- package/dist/src/summary/evaluateMetrics.d.ts.map +1 -0
- package/dist/src/summary/evaluateMetrics.js +118 -0
- package/dist/src/summary/index.d.ts +10 -0
- package/dist/src/summary/index.d.ts.map +1 -0
- package/dist/src/summary/index.js +22 -0
- package/dist/src/summary/markdownRenderer.d.ts +139 -0
- package/dist/src/summary/markdownRenderer.d.ts.map +1 -0
- package/dist/src/summary/markdownRenderer.js +459 -0
- package/dist/src/summary/prSummary.d.ts +24 -0
- package/dist/src/summary/prSummary.d.ts.map +1 -0
- package/dist/src/summary/prSummary.js +233 -0
- package/dist/src/summary/summaryTypes.d.ts +35 -0
- package/dist/src/summary/summaryTypes.d.ts.map +1 -0
- package/dist/src/summary/summaryTypes.js +27 -0
- package/package.json +84 -0
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Deep Code Analysis — Call Graph Construction
|
|
4
|
+
*
|
|
5
|
+
* Builds a lightweight per-file call graph that maps function/method names to
|
|
6
|
+
* their bodies and the other local functions they call.
|
|
7
|
+
*
|
|
8
|
+
* This call graph is used by wrapper-method and helper-method resolution to
|
|
9
|
+
* follow call chains up to a configurable depth.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.extractJsFunctions = extractJsFunctions;
|
|
13
|
+
exports.extractJavaKotlinFunctions = extractJavaKotlinFunctions;
|
|
14
|
+
exports.extractPythonFunctions = extractPythonFunctions;
|
|
15
|
+
exports.buildJsCallGraph = buildJsCallGraph;
|
|
16
|
+
exports.buildJavaCallGraph = buildJavaCallGraph;
|
|
17
|
+
exports.buildPythonCallGraph = buildPythonCallGraph;
|
|
18
|
+
exports.extractBalancedBraces = extractBalancedBraces;
|
|
19
|
+
// ─── Function body extraction ─────────────────────────────────────────────────
|
|
20
|
+
/**
|
|
21
|
+
* Extract top-level function definitions and their bodies from
|
|
22
|
+
* TypeScript/JavaScript source.
|
|
23
|
+
*
|
|
24
|
+
* Handles:
|
|
25
|
+
* function foo() { ... }
|
|
26
|
+
* const foo = () => { ... }
|
|
27
|
+
* const foo = (params) => { ... }
|
|
28
|
+
* const foo = function() { ... }
|
|
29
|
+
*/
|
|
30
|
+
function extractJsFunctions(content) {
|
|
31
|
+
const functions = [];
|
|
32
|
+
// Named function declarations: function foo(...) { body }
|
|
33
|
+
extractBracedFunctions(content, /\bfunction\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*\([^)]*\)\s*\{/, functions);
|
|
34
|
+
// Arrow functions: const foo = (...) => { body }
|
|
35
|
+
extractBracedFunctions(content, /\b(?:const|let|var)\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*=\s*(?:\([^)]*\)|[A-Za-z_$][A-Za-z0-9_$]*)\s*=>\s*\{/, functions);
|
|
36
|
+
// Function expressions: const foo = function(...) { body }
|
|
37
|
+
extractBracedFunctions(content, /\b(?:const|let|var)\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*=\s*function\s*\([^)]*\)\s*\{/, functions);
|
|
38
|
+
return functions;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Extract method definitions from Java / Kotlin source.
|
|
42
|
+
*
|
|
43
|
+
* Handles:
|
|
44
|
+
* [modifiers] returnType methodName([params]) { body }
|
|
45
|
+
* fun methodName([params]): ReturnType { body }
|
|
46
|
+
*/
|
|
47
|
+
function extractJavaKotlinFunctions(content) {
|
|
48
|
+
const functions = [];
|
|
49
|
+
// Java-style: ... MethodName(...) { body }
|
|
50
|
+
extractBracedFunctions(content, /\b([a-z_][A-Za-z0-9_]*)\s*\([^)]*\)\s*(?:throws\s+\w+(?:\s*,\s*\w+)*)?\s*\{/, functions);
|
|
51
|
+
// Kotlin fun: fun methodName(...) { body }
|
|
52
|
+
extractBracedFunctions(content, /\bfun\s+([A-Za-z_][A-Za-z0-9_]*)\s*\([^)]*\)/s, functions);
|
|
53
|
+
return functions;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Extract Python function definitions.
|
|
57
|
+
*
|
|
58
|
+
* Handles:
|
|
59
|
+
* def function_name(params):
|
|
60
|
+
* body (indented block)
|
|
61
|
+
*/
|
|
62
|
+
function extractPythonFunctions(content) {
|
|
63
|
+
var _a, _b;
|
|
64
|
+
const functions = [];
|
|
65
|
+
const defPattern = /^( *)def\s+([A-Za-z_][A-Za-z0-9_]*)\s*\([^)]*\)\s*:/gm;
|
|
66
|
+
let m;
|
|
67
|
+
while ((m = defPattern.exec(content)) !== null) {
|
|
68
|
+
const indent = m[1];
|
|
69
|
+
const name = m[2];
|
|
70
|
+
const startIdx = m.index + m[0].length;
|
|
71
|
+
// Find the end of the function body by looking for a line at the same or
|
|
72
|
+
// lesser indentation after the definition
|
|
73
|
+
const bodyLines = [];
|
|
74
|
+
const remaining = content.slice(startIdx);
|
|
75
|
+
const lines = remaining.split('\n');
|
|
76
|
+
// Determine body indentation (first non-empty line after def)
|
|
77
|
+
let bodyIndent = '';
|
|
78
|
+
for (const line of lines) {
|
|
79
|
+
if (line.trim() === '')
|
|
80
|
+
continue;
|
|
81
|
+
const lineIndentMatch = line.match(/^(\s+)/);
|
|
82
|
+
bodyIndent = lineIndentMatch ? lineIndentMatch[1] : '';
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
if (!bodyIndent || bodyIndent.length <= indent.length) {
|
|
86
|
+
// No body or inline expression — skip
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
for (const line of lines) {
|
|
90
|
+
if (line.trim() === '') {
|
|
91
|
+
bodyLines.push(line);
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
const li = (_b = (_a = line.match(/^(\s*)/)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : '';
|
|
95
|
+
if (li.length < bodyIndent.length && line.trim() !== '')
|
|
96
|
+
break;
|
|
97
|
+
bodyLines.push(line);
|
|
98
|
+
}
|
|
99
|
+
functions.push({ name, body: bodyLines.join('\n') });
|
|
100
|
+
}
|
|
101
|
+
return functions;
|
|
102
|
+
}
|
|
103
|
+
// ─── Call graph construction ──────────────────────────────────────────────────
|
|
104
|
+
/**
|
|
105
|
+
* Build a call graph from JavaScript/TypeScript source.
|
|
106
|
+
*/
|
|
107
|
+
function buildJsCallGraph(content) {
|
|
108
|
+
const graph = new Map();
|
|
109
|
+
const funcs = extractJsFunctions(content);
|
|
110
|
+
for (const { name, body } of funcs) {
|
|
111
|
+
const node = {
|
|
112
|
+
name,
|
|
113
|
+
body,
|
|
114
|
+
calls: extractLocalCallsFromBody(body, funcs.map((f) => f.name)),
|
|
115
|
+
directHttpCalls: extractDirectHttpCallsFromBody(body),
|
|
116
|
+
returnValue: extractReturnStringLiteral(body),
|
|
117
|
+
};
|
|
118
|
+
graph.set(name, node);
|
|
119
|
+
}
|
|
120
|
+
return graph;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Build a call graph from Java/Kotlin source.
|
|
124
|
+
*/
|
|
125
|
+
function buildJavaCallGraph(content) {
|
|
126
|
+
const graph = new Map();
|
|
127
|
+
const funcs = extractJavaKotlinFunctions(content);
|
|
128
|
+
for (const { name, body } of funcs) {
|
|
129
|
+
const node = {
|
|
130
|
+
name,
|
|
131
|
+
body,
|
|
132
|
+
calls: extractLocalCallsFromBody(body, funcs.map((f) => f.name)),
|
|
133
|
+
directHttpCalls: extractDirectHttpCallsFromBody(body),
|
|
134
|
+
returnValue: extractReturnStringLiteralJava(body),
|
|
135
|
+
};
|
|
136
|
+
graph.set(name, node);
|
|
137
|
+
}
|
|
138
|
+
return graph;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Build a call graph from Python source.
|
|
142
|
+
*/
|
|
143
|
+
function buildPythonCallGraph(content) {
|
|
144
|
+
const graph = new Map();
|
|
145
|
+
const funcs = extractPythonFunctions(content);
|
|
146
|
+
for (const { name, body } of funcs) {
|
|
147
|
+
const node = {
|
|
148
|
+
name,
|
|
149
|
+
body,
|
|
150
|
+
calls: extractLocalCallsFromBody(body, funcs.map((f) => f.name)),
|
|
151
|
+
directHttpCalls: extractDirectHttpCallsFromBody(body),
|
|
152
|
+
returnValue: extractReturnStringLiteralPython(body),
|
|
153
|
+
};
|
|
154
|
+
graph.set(name, node);
|
|
155
|
+
}
|
|
156
|
+
return graph;
|
|
157
|
+
}
|
|
158
|
+
// ─── HTTP call extraction from body ──────────────────────────────────────────
|
|
159
|
+
/**
|
|
160
|
+
* Find simple direct HTTP calls in a function body.
|
|
161
|
+
* Returns method+path pairs for string-literal calls only.
|
|
162
|
+
*/
|
|
163
|
+
function extractDirectHttpCallsFromBody(body) {
|
|
164
|
+
const calls = [];
|
|
165
|
+
// client.get('/path'), api.post('/path'), etc.
|
|
166
|
+
const httpPattern = /\.(get|post|put|patch|delete|head|options)\s*\(\s*['"`]([^'"`]+)['"`]\s*[),]/gi;
|
|
167
|
+
let m;
|
|
168
|
+
while ((m = httpPattern.exec(body)) !== null) {
|
|
169
|
+
calls.push({ method: m[1].toUpperCase(), path: m[2] });
|
|
170
|
+
}
|
|
171
|
+
// return client.get('/path')
|
|
172
|
+
const returnHttpPattern = /return\s+\w+\.(get|post|put|patch|delete|head|options)\s*\(\s*['"`]([^'"`]+)['"`]/gi;
|
|
173
|
+
while ((m = returnHttpPattern.exec(body)) !== null) {
|
|
174
|
+
calls.push({ method: m[1].toUpperCase(), path: m[2] });
|
|
175
|
+
}
|
|
176
|
+
return calls;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Find calls to other local functions in a body.
|
|
180
|
+
*/
|
|
181
|
+
function extractLocalCallsFromBody(body, localFunctionNames) {
|
|
182
|
+
const called = [];
|
|
183
|
+
for (const name of localFunctionNames) {
|
|
184
|
+
// name(...) appears in the body
|
|
185
|
+
const pattern = new RegExp(`\\b${escapeRegex(name)}\\s*\\(`, 'g');
|
|
186
|
+
if (pattern.test(body)) {
|
|
187
|
+
called.push(name);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return called;
|
|
191
|
+
}
|
|
192
|
+
// ─── Return value extraction ──────────────────────────────────────────────────
|
|
193
|
+
/** Extract the string literal returned by a JS/TS function body, if any. */
|
|
194
|
+
function extractReturnStringLiteral(body) {
|
|
195
|
+
const m = /\breturn\s+['"`]([^'"`\n]+)['"`]/.exec(body);
|
|
196
|
+
return m ? m[1] : undefined;
|
|
197
|
+
}
|
|
198
|
+
/** Extract the string literal returned by a Java/Kotlin method body. */
|
|
199
|
+
function extractReturnStringLiteralJava(body) {
|
|
200
|
+
const m = /\breturn\s+"([^"\n]+)"/.exec(body);
|
|
201
|
+
return m ? m[1] : undefined;
|
|
202
|
+
}
|
|
203
|
+
/** Extract the string literal returned by a Python function body. */
|
|
204
|
+
function extractReturnStringLiteralPython(body) {
|
|
205
|
+
const m = /\breturn\s+['"]([^'"\n]+)['"]/.exec(body);
|
|
206
|
+
return m ? m[1] : undefined;
|
|
207
|
+
}
|
|
208
|
+
// ─── Brace-balanced function body extraction ─────────────────────────────────
|
|
209
|
+
/**
|
|
210
|
+
* Find all functions matching a pattern that starts a brace-delimited body
|
|
211
|
+
* and extract the body text (balanced braces).
|
|
212
|
+
*/
|
|
213
|
+
function extractBracedFunctions(content, headerPattern, results) {
|
|
214
|
+
const gPattern = new RegExp(headerPattern.source, 'g');
|
|
215
|
+
let m;
|
|
216
|
+
while ((m = gPattern.exec(content)) !== null) {
|
|
217
|
+
const name = m[1];
|
|
218
|
+
if (!name)
|
|
219
|
+
continue;
|
|
220
|
+
// Find the opening brace
|
|
221
|
+
const openBrace = content.indexOf('{', m.index + m[0].length - 1);
|
|
222
|
+
if (openBrace === -1)
|
|
223
|
+
continue;
|
|
224
|
+
// Extract balanced brace body
|
|
225
|
+
const body = extractBalancedBraces(content, openBrace);
|
|
226
|
+
if (body !== undefined) {
|
|
227
|
+
results.push({ name, body });
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Extract the content of a brace-delimited block starting at `startIndex`
|
|
233
|
+
* (which must point at the opening `{`). Returns the inner body without
|
|
234
|
+
* the surrounding braces.
|
|
235
|
+
*
|
|
236
|
+
* Returns undefined if braces are not balanced.
|
|
237
|
+
*/
|
|
238
|
+
function extractBalancedBraces(content, startIndex) {
|
|
239
|
+
if (content[startIndex] !== '{')
|
|
240
|
+
return undefined;
|
|
241
|
+
let depth = 0;
|
|
242
|
+
let inString = null;
|
|
243
|
+
let i = startIndex;
|
|
244
|
+
while (i < content.length) {
|
|
245
|
+
const ch = content[i];
|
|
246
|
+
if (inString) {
|
|
247
|
+
if (ch === '\\') {
|
|
248
|
+
i += 2;
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
if (ch === inString)
|
|
252
|
+
inString = null;
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
if (ch === '"' || ch === "'" || ch === '`') {
|
|
256
|
+
inString = ch;
|
|
257
|
+
}
|
|
258
|
+
else if (ch === '{') {
|
|
259
|
+
depth++;
|
|
260
|
+
}
|
|
261
|
+
else if (ch === '}') {
|
|
262
|
+
depth--;
|
|
263
|
+
if (depth === 0) {
|
|
264
|
+
return content.slice(startIndex + 1, i);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
i++;
|
|
269
|
+
}
|
|
270
|
+
return undefined;
|
|
271
|
+
}
|
|
272
|
+
// ─── Utility ──────────────────────────────────────────────────────────────────
|
|
273
|
+
function escapeRegex(s) {
|
|
274
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
275
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep Code Analysis — Deep Endpoint Resolver
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates all deep-analysis sub-modules to extract HTTP calls from a
|
|
5
|
+
* single source file, resolving constants, enums, string templates, wrapper
|
|
6
|
+
* methods, request builders, and assertion linkage.
|
|
7
|
+
*
|
|
8
|
+
* The main entry point is `deepResolveFile()`.
|
|
9
|
+
*/
|
|
10
|
+
import type { DeepAnalysisConfig, ResolvedHttpCall } from './types';
|
|
11
|
+
import { extractResponseVariables } from './resolveAssertions';
|
|
12
|
+
/**
|
|
13
|
+
* Run deep endpoint analysis on a single source file.
|
|
14
|
+
*
|
|
15
|
+
* @param content Raw file content
|
|
16
|
+
* @param filePath Absolute path (used in output metadata)
|
|
17
|
+
* @param language Detected language
|
|
18
|
+
* @param config Deep analysis feature configuration
|
|
19
|
+
* @returns Array of resolved HTTP calls with resolution metadata
|
|
20
|
+
*/
|
|
21
|
+
export declare function deepResolveFile(content: string, filePath: string, language: 'typescript' | 'javascript' | 'java' | 'kotlin' | 'python' | 'ruby' | 'cucumber' | 'auto', config?: DeepAnalysisConfig): ResolvedHttpCall[];
|
|
22
|
+
export { extractResponseVariables };
|
|
23
|
+
//# sourceMappingURL=deepEndpointResolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deepEndpointResolver.d.ts","sourceRoot":"","sources":["../../../../src/coverage/deep-analysis/deepEndpointResolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAgC,MAAM,SAAS,CAAC;AAyBlG,OAAO,EAAqB,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAIlF;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,YAAY,GAAG,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,EACnG,MAAM,GAAE,kBAAiD,GACxD,gBAAgB,EAAE,CA8MpB;AA0ND,OAAO,EAAE,wBAAwB,EAAE,CAAC"}
|