@opencodehub/ingestion 0.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/LICENSE +202 -0
- package/README.md +69 -0
- package/dist/extract/index.d.ts +8 -0
- package/dist/extract/index.d.ts.map +1 -0
- package/dist/extract/index.js +6 -0
- package/dist/extract/index.js.map +1 -0
- package/dist/extract/orm-detector.d.ts +19 -0
- package/dist/extract/orm-detector.d.ts.map +1 -0
- package/dist/extract/orm-detector.js +209 -0
- package/dist/extract/orm-detector.js.map +1 -0
- package/dist/extract/property-access.d.ts +76 -0
- package/dist/extract/property-access.d.ts.map +1 -0
- package/dist/extract/property-access.js +260 -0
- package/dist/extract/property-access.js.map +1 -0
- package/dist/extract/receiver-resolver.d.ts +86 -0
- package/dist/extract/receiver-resolver.d.ts.map +1 -0
- package/dist/extract/receiver-resolver.js +77 -0
- package/dist/extract/receiver-resolver.js.map +1 -0
- package/dist/extract/route-detector-java.d.ts +29 -0
- package/dist/extract/route-detector-java.d.ts.map +1 -0
- package/dist/extract/route-detector-java.js +190 -0
- package/dist/extract/route-detector-java.js.map +1 -0
- package/dist/extract/route-detector-nestjs.d.ts +30 -0
- package/dist/extract/route-detector-nestjs.d.ts.map +1 -0
- package/dist/extract/route-detector-nestjs.js +134 -0
- package/dist/extract/route-detector-nestjs.js.map +1 -0
- package/dist/extract/route-detector-python.d.ts +28 -0
- package/dist/extract/route-detector-python.d.ts.map +1 -0
- package/dist/extract/route-detector-python.js +100 -0
- package/dist/extract/route-detector-python.js.map +1 -0
- package/dist/extract/route-detector-rails.d.ts +28 -0
- package/dist/extract/route-detector-rails.d.ts.map +1 -0
- package/dist/extract/route-detector-rails.js +162 -0
- package/dist/extract/route-detector-rails.js.map +1 -0
- package/dist/extract/route-detector.d.ts +45 -0
- package/dist/extract/route-detector.d.ts.map +1 -0
- package/dist/extract/route-detector.js +467 -0
- package/dist/extract/route-detector.js.map +1 -0
- package/dist/extract/tool-detector.d.ts +26 -0
- package/dist/extract/tool-detector.d.ts.map +1 -0
- package/dist/extract/tool-detector.js +364 -0
- package/dist/extract/tool-detector.js.map +1 -0
- package/dist/extract/types.d.ts +89 -0
- package/dist/extract/types.d.ts.map +1 -0
- package/dist/extract/types.js +11 -0
- package/dist/extract/types.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/parse/cobol-regex.d.ts +85 -0
- package/dist/parse/cobol-regex.d.ts.map +1 -0
- package/dist/parse/cobol-regex.js +355 -0
- package/dist/parse/cobol-regex.js.map +1 -0
- package/dist/parse/grammar-registry.d.ts +115 -0
- package/dist/parse/grammar-registry.d.ts.map +1 -0
- package/dist/parse/grammar-registry.js +278 -0
- package/dist/parse/grammar-registry.js.map +1 -0
- package/dist/parse/index.d.ts +14 -0
- package/dist/parse/index.d.ts.map +1 -0
- package/dist/parse/index.js +10 -0
- package/dist/parse/index.js.map +1 -0
- package/dist/parse/language-detector.d.ts +17 -0
- package/dist/parse/language-detector.d.ts.map +1 -0
- package/dist/parse/language-detector.js +104 -0
- package/dist/parse/language-detector.js.map +1 -0
- package/dist/parse/parse-worker.d.ts +24 -0
- package/dist/parse/parse-worker.d.ts.map +1 -0
- package/dist/parse/parse-worker.js +230 -0
- package/dist/parse/parse-worker.js.map +1 -0
- package/dist/parse/types.d.ts +49 -0
- package/dist/parse/types.d.ts.map +1 -0
- package/dist/parse/types.js +11 -0
- package/dist/parse/types.js.map +1 -0
- package/dist/parse/unified-queries.d.ts +37 -0
- package/dist/parse/unified-queries.d.ts.map +1 -0
- package/dist/parse/unified-queries.js +623 -0
- package/dist/parse/unified-queries.js.map +1 -0
- package/dist/parse/wasm-fallback.d.ts +88 -0
- package/dist/parse/wasm-fallback.d.ts.map +1 -0
- package/dist/parse/wasm-fallback.js +258 -0
- package/dist/parse/wasm-fallback.js.map +1 -0
- package/dist/parse/worker-pool.d.ts +48 -0
- package/dist/parse/worker-pool.d.ts.map +1 -0
- package/dist/parse/worker-pool.js +97 -0
- package/dist/parse/worker-pool.js.map +1 -0
- package/dist/pipeline/dep-parsers/go.d.ts +25 -0
- package/dist/pipeline/dep-parsers/go.d.ts.map +1 -0
- package/dist/pipeline/dep-parsers/go.js +146 -0
- package/dist/pipeline/dep-parsers/go.js.map +1 -0
- package/dist/pipeline/dep-parsers/index.d.ts +17 -0
- package/dist/pipeline/dep-parsers/index.d.ts.map +1 -0
- package/dist/pipeline/dep-parsers/index.js +16 -0
- package/dist/pipeline/dep-parsers/index.js.map +1 -0
- package/dist/pipeline/dep-parsers/maven.d.ts +24 -0
- package/dist/pipeline/dep-parsers/maven.d.ts.map +1 -0
- package/dist/pipeline/dep-parsers/maven.js +131 -0
- package/dist/pipeline/dep-parsers/maven.js.map +1 -0
- package/dist/pipeline/dep-parsers/npm.d.ts +30 -0
- package/dist/pipeline/dep-parsers/npm.d.ts.map +1 -0
- package/dist/pipeline/dep-parsers/npm.js +309 -0
- package/dist/pipeline/dep-parsers/npm.js.map +1 -0
- package/dist/pipeline/dep-parsers/nuget.d.ts +24 -0
- package/dist/pipeline/dep-parsers/nuget.d.ts.map +1 -0
- package/dist/pipeline/dep-parsers/nuget.js +178 -0
- package/dist/pipeline/dep-parsers/nuget.js.map +1 -0
- package/dist/pipeline/dep-parsers/python.d.ts +21 -0
- package/dist/pipeline/dep-parsers/python.d.ts.map +1 -0
- package/dist/pipeline/dep-parsers/python.js +369 -0
- package/dist/pipeline/dep-parsers/python.js.map +1 -0
- package/dist/pipeline/dep-parsers/rust.d.ts +18 -0
- package/dist/pipeline/dep-parsers/rust.d.ts.map +1 -0
- package/dist/pipeline/dep-parsers/rust.js +134 -0
- package/dist/pipeline/dep-parsers/rust.js.map +1 -0
- package/dist/pipeline/dep-parsers/spdx-normalize.d.ts +15 -0
- package/dist/pipeline/dep-parsers/spdx-normalize.d.ts.map +1 -0
- package/dist/pipeline/dep-parsers/spdx-normalize.js +31 -0
- package/dist/pipeline/dep-parsers/spdx-normalize.js.map +1 -0
- package/dist/pipeline/dep-parsers/types.d.ts +63 -0
- package/dist/pipeline/dep-parsers/types.d.ts.map +1 -0
- package/dist/pipeline/dep-parsers/types.js +56 -0
- package/dist/pipeline/dep-parsers/types.js.map +1 -0
- package/dist/pipeline/gitignore-stack.d.ts +44 -0
- package/dist/pipeline/gitignore-stack.d.ts.map +1 -0
- package/dist/pipeline/gitignore-stack.js +69 -0
- package/dist/pipeline/gitignore-stack.js.map +1 -0
- package/dist/pipeline/gitignore.d.ts +67 -0
- package/dist/pipeline/gitignore.d.ts.map +1 -0
- package/dist/pipeline/gitignore.js +210 -0
- package/dist/pipeline/gitignore.js.map +1 -0
- package/dist/pipeline/index.d.ts +53 -0
- package/dist/pipeline/index.d.ts.map +1 -0
- package/dist/pipeline/index.js +29 -0
- package/dist/pipeline/index.js.map +1 -0
- package/dist/pipeline/orchestrator.d.ts +105 -0
- package/dist/pipeline/orchestrator.d.ts.map +1 -0
- package/dist/pipeline/orchestrator.js +175 -0
- package/dist/pipeline/orchestrator.js.map +1 -0
- package/dist/pipeline/ownership-helpers/drift.d.ts +41 -0
- package/dist/pipeline/ownership-helpers/drift.d.ts.map +1 -0
- package/dist/pipeline/ownership-helpers/drift.js +122 -0
- package/dist/pipeline/ownership-helpers/drift.js.map +1 -0
- package/dist/pipeline/ownership-helpers/gini-community.d.ts +24 -0
- package/dist/pipeline/ownership-helpers/gini-community.d.ts.map +1 -0
- package/dist/pipeline/ownership-helpers/gini-community.js +32 -0
- package/dist/pipeline/ownership-helpers/gini-community.js.map +1 -0
- package/dist/pipeline/ownership-helpers/git-blame-batcher.d.ts +71 -0
- package/dist/pipeline/ownership-helpers/git-blame-batcher.d.ts.map +1 -0
- package/dist/pipeline/ownership-helpers/git-blame-batcher.js +178 -0
- package/dist/pipeline/ownership-helpers/git-blame-batcher.js.map +1 -0
- package/dist/pipeline/ownership-helpers/line-overlap.d.ts +35 -0
- package/dist/pipeline/ownership-helpers/line-overlap.d.ts.map +1 -0
- package/dist/pipeline/ownership-helpers/line-overlap.js +62 -0
- package/dist/pipeline/ownership-helpers/line-overlap.js.map +1 -0
- package/dist/pipeline/ownership-helpers/orphan.d.ts +73 -0
- package/dist/pipeline/ownership-helpers/orphan.d.ts.map +1 -0
- package/dist/pipeline/ownership-helpers/orphan.js +117 -0
- package/dist/pipeline/ownership-helpers/orphan.js.map +1 -0
- package/dist/pipeline/phases/accesses.d.ts +44 -0
- package/dist/pipeline/phases/accesses.d.ts.map +1 -0
- package/dist/pipeline/phases/accesses.js +194 -0
- package/dist/pipeline/phases/accesses.js.map +1 -0
- package/dist/pipeline/phases/annotate.d.ts +28 -0
- package/dist/pipeline/phases/annotate.d.ts.map +1 -0
- package/dist/pipeline/phases/annotate.js +60 -0
- package/dist/pipeline/phases/annotate.js.map +1 -0
- package/dist/pipeline/phases/cochange.d.ts +42 -0
- package/dist/pipeline/phases/cochange.d.ts.map +1 -0
- package/dist/pipeline/phases/cochange.js +0 -0
- package/dist/pipeline/phases/cochange.js.map +1 -0
- package/dist/pipeline/phases/communities.d.ts +34 -0
- package/dist/pipeline/phases/communities.d.ts.map +1 -0
- package/dist/pipeline/phases/communities.js +412 -0
- package/dist/pipeline/phases/communities.js.map +1 -0
- package/dist/pipeline/phases/complexity.d.ts +50 -0
- package/dist/pipeline/phases/complexity.d.ts.map +1 -0
- package/dist/pipeline/phases/complexity.js +794 -0
- package/dist/pipeline/phases/complexity.js.map +1 -0
- package/dist/pipeline/phases/confidence-demote.d.ts +23 -0
- package/dist/pipeline/phases/confidence-demote.d.ts.map +1 -0
- package/dist/pipeline/phases/confidence-demote.js +113 -0
- package/dist/pipeline/phases/confidence-demote.js.map +1 -0
- package/dist/pipeline/phases/content-cache.d.ts +166 -0
- package/dist/pipeline/phases/content-cache.d.ts.map +1 -0
- package/dist/pipeline/phases/content-cache.js +323 -0
- package/dist/pipeline/phases/content-cache.js.map +1 -0
- package/dist/pipeline/phases/coverage-parsers/cobertura.d.ts +25 -0
- package/dist/pipeline/phases/coverage-parsers/cobertura.d.ts.map +1 -0
- package/dist/pipeline/phases/coverage-parsers/cobertura.js +139 -0
- package/dist/pipeline/phases/coverage-parsers/cobertura.js.map +1 -0
- package/dist/pipeline/phases/coverage-parsers/coverage-py.d.ts +25 -0
- package/dist/pipeline/phases/coverage-parsers/coverage-py.d.ts.map +1 -0
- package/dist/pipeline/phases/coverage-parsers/coverage-py.js +51 -0
- package/dist/pipeline/phases/coverage-parsers/coverage-py.js.map +1 -0
- package/dist/pipeline/phases/coverage-parsers/jacoco.d.ts +32 -0
- package/dist/pipeline/phases/coverage-parsers/jacoco.d.ts.map +1 -0
- package/dist/pipeline/phases/coverage-parsers/jacoco.js +98 -0
- package/dist/pipeline/phases/coverage-parsers/jacoco.js.map +1 -0
- package/dist/pipeline/phases/coverage-parsers/lcov.d.ts +21 -0
- package/dist/pipeline/phases/coverage-parsers/lcov.d.ts.map +1 -0
- package/dist/pipeline/phases/coverage-parsers/lcov.js +104 -0
- package/dist/pipeline/phases/coverage-parsers/lcov.js.map +1 -0
- package/dist/pipeline/phases/coverage-parsers/types.d.ts +27 -0
- package/dist/pipeline/phases/coverage-parsers/types.d.ts.map +1 -0
- package/dist/pipeline/phases/coverage-parsers/types.js +39 -0
- package/dist/pipeline/phases/coverage-parsers/types.js.map +1 -0
- package/dist/pipeline/phases/coverage.d.ts +39 -0
- package/dist/pipeline/phases/coverage.d.ts.map +1 -0
- package/dist/pipeline/phases/coverage.js +154 -0
- package/dist/pipeline/phases/coverage.js.map +1 -0
- package/dist/pipeline/phases/cross-file.d.ts +40 -0
- package/dist/pipeline/phases/cross-file.d.ts.map +1 -0
- package/dist/pipeline/phases/cross-file.js +411 -0
- package/dist/pipeline/phases/cross-file.js.map +1 -0
- package/dist/pipeline/phases/dead-code.d.ts +28 -0
- package/dist/pipeline/phases/dead-code.d.ts.map +1 -0
- package/dist/pipeline/phases/dead-code.js +157 -0
- package/dist/pipeline/phases/dead-code.js.map +1 -0
- package/dist/pipeline/phases/default-set.d.ts +24 -0
- package/dist/pipeline/phases/default-set.d.ts.map +1 -0
- package/dist/pipeline/phases/default-set.js +133 -0
- package/dist/pipeline/phases/default-set.js.map +1 -0
- package/dist/pipeline/phases/dependencies.d.ts +59 -0
- package/dist/pipeline/phases/dependencies.d.ts.map +1 -0
- package/dist/pipeline/phases/dependencies.js +281 -0
- package/dist/pipeline/phases/dependencies.js.map +1 -0
- package/dist/pipeline/phases/embedder-pool.d.ts +31 -0
- package/dist/pipeline/phases/embedder-pool.d.ts.map +1 -0
- package/dist/pipeline/phases/embedder-pool.js +79 -0
- package/dist/pipeline/phases/embedder-pool.js.map +1 -0
- package/dist/pipeline/phases/embedder-worker.d.ts +28 -0
- package/dist/pipeline/phases/embedder-worker.d.ts.map +1 -0
- package/dist/pipeline/phases/embedder-worker.js +43 -0
- package/dist/pipeline/phases/embedder-worker.js.map +1 -0
- package/dist/pipeline/phases/embeddings.d.ts +117 -0
- package/dist/pipeline/phases/embeddings.d.ts.map +1 -0
- package/dist/pipeline/phases/embeddings.js +697 -0
- package/dist/pipeline/phases/embeddings.js.map +1 -0
- package/dist/pipeline/phases/fetches.d.ts +47 -0
- package/dist/pipeline/phases/fetches.d.ts.map +1 -0
- package/dist/pipeline/phases/fetches.js +207 -0
- package/dist/pipeline/phases/fetches.js.map +1 -0
- package/dist/pipeline/phases/incremental-helper.d.ts +96 -0
- package/dist/pipeline/phases/incremental-helper.d.ts.map +1 -0
- package/dist/pipeline/phases/incremental-helper.js +125 -0
- package/dist/pipeline/phases/incremental-helper.js.map +1 -0
- package/dist/pipeline/phases/incremental-scope.d.ts +67 -0
- package/dist/pipeline/phases/incremental-scope.d.ts.map +1 -0
- package/dist/pipeline/phases/incremental-scope.js +225 -0
- package/dist/pipeline/phases/incremental-scope.js.map +1 -0
- package/dist/pipeline/phases/markdown.d.ts +29 -0
- package/dist/pipeline/phases/markdown.d.ts.map +1 -0
- package/dist/pipeline/phases/markdown.js +298 -0
- package/dist/pipeline/phases/markdown.js.map +1 -0
- package/dist/pipeline/phases/mro.d.ts +24 -0
- package/dist/pipeline/phases/mro.d.ts.map +1 -0
- package/dist/pipeline/phases/mro.js +303 -0
- package/dist/pipeline/phases/mro.js.map +1 -0
- package/dist/pipeline/phases/openapi.d.ts +52 -0
- package/dist/pipeline/phases/openapi.d.ts.map +1 -0
- package/dist/pipeline/phases/openapi.js +285 -0
- package/dist/pipeline/phases/openapi.js.map +1 -0
- package/dist/pipeline/phases/orm.d.ts +26 -0
- package/dist/pipeline/phases/orm.d.ts.map +1 -0
- package/dist/pipeline/phases/orm.js +183 -0
- package/dist/pipeline/phases/orm.js.map +1 -0
- package/dist/pipeline/phases/ownership.d.ts +88 -0
- package/dist/pipeline/phases/ownership.d.ts.map +1 -0
- package/dist/pipeline/phases/ownership.js +479 -0
- package/dist/pipeline/phases/ownership.js.map +1 -0
- package/dist/pipeline/phases/parse.d.ts +63 -0
- package/dist/pipeline/phases/parse.d.ts.map +1 -0
- package/dist/pipeline/phases/parse.js +994 -0
- package/dist/pipeline/phases/parse.js.map +1 -0
- package/dist/pipeline/phases/processes.d.ts +47 -0
- package/dist/pipeline/phases/processes.d.ts.map +1 -0
- package/dist/pipeline/phases/processes.js +620 -0
- package/dist/pipeline/phases/processes.js.map +1 -0
- package/dist/pipeline/phases/profile.d.ts +33 -0
- package/dist/pipeline/phases/profile.d.ts.map +1 -0
- package/dist/pipeline/phases/profile.js +91 -0
- package/dist/pipeline/phases/profile.js.map +1 -0
- package/dist/pipeline/phases/repo-node.d.ts +112 -0
- package/dist/pipeline/phases/repo-node.d.ts.map +1 -0
- package/dist/pipeline/phases/repo-node.js +272 -0
- package/dist/pipeline/phases/repo-node.js.map +1 -0
- package/dist/pipeline/phases/risk-snapshot.d.ts +34 -0
- package/dist/pipeline/phases/risk-snapshot.d.ts.map +1 -0
- package/dist/pipeline/phases/risk-snapshot.js +63 -0
- package/dist/pipeline/phases/risk-snapshot.js.map +1 -0
- package/dist/pipeline/phases/routes.d.ts +31 -0
- package/dist/pipeline/phases/routes.d.ts.map +1 -0
- package/dist/pipeline/phases/routes.js +262 -0
- package/dist/pipeline/phases/routes.js.map +1 -0
- package/dist/pipeline/phases/sbom.d.ts +45 -0
- package/dist/pipeline/phases/sbom.d.ts.map +1 -0
- package/dist/pipeline/phases/sbom.js +289 -0
- package/dist/pipeline/phases/sbom.js.map +1 -0
- package/dist/pipeline/phases/scan.d.ts +54 -0
- package/dist/pipeline/phases/scan.d.ts.map +1 -0
- package/dist/pipeline/phases/scan.js +340 -0
- package/dist/pipeline/phases/scan.js.map +1 -0
- package/dist/pipeline/phases/scip-index.d.ts +54 -0
- package/dist/pipeline/phases/scip-index.d.ts.map +1 -0
- package/dist/pipeline/phases/scip-index.js +469 -0
- package/dist/pipeline/phases/scip-index.js.map +1 -0
- package/dist/pipeline/phases/structure.d.ts +21 -0
- package/dist/pipeline/phases/structure.d.ts.map +1 -0
- package/dist/pipeline/phases/structure.js +115 -0
- package/dist/pipeline/phases/structure.js.map +1 -0
- package/dist/pipeline/phases/summarize.d.ts +126 -0
- package/dist/pipeline/phases/summarize.d.ts.map +1 -0
- package/dist/pipeline/phases/summarize.js +401 -0
- package/dist/pipeline/phases/summarize.js.map +1 -0
- package/dist/pipeline/phases/temporal-helpers/branch-divergence.d.ts +42 -0
- package/dist/pipeline/phases/temporal-helpers/branch-divergence.d.ts.map +1 -0
- package/dist/pipeline/phases/temporal-helpers/branch-divergence.js +96 -0
- package/dist/pipeline/phases/temporal-helpers/branch-divergence.js.map +1 -0
- package/dist/pipeline/phases/temporal-helpers/churn-decay.d.ts +22 -0
- package/dist/pipeline/phases/temporal-helpers/churn-decay.d.ts.map +1 -0
- package/dist/pipeline/phases/temporal-helpers/churn-decay.js +32 -0
- package/dist/pipeline/phases/temporal-helpers/churn-decay.js.map +1 -0
- package/dist/pipeline/phases/temporal-helpers/conventional-commits.d.ts +21 -0
- package/dist/pipeline/phases/temporal-helpers/conventional-commits.d.ts.map +1 -0
- package/dist/pipeline/phases/temporal-helpers/conventional-commits.js +37 -0
- package/dist/pipeline/phases/temporal-helpers/conventional-commits.js.map +1 -0
- package/dist/pipeline/phases/temporal-helpers/gini.d.ts +32 -0
- package/dist/pipeline/phases/temporal-helpers/gini.d.ts.map +1 -0
- package/dist/pipeline/phases/temporal-helpers/gini.js +78 -0
- package/dist/pipeline/phases/temporal-helpers/gini.js.map +1 -0
- package/dist/pipeline/phases/temporal-helpers/revert-detect.d.ts +14 -0
- package/dist/pipeline/phases/temporal-helpers/revert-detect.d.ts.map +1 -0
- package/dist/pipeline/phases/temporal-helpers/revert-detect.js +25 -0
- package/dist/pipeline/phases/temporal-helpers/revert-detect.js.map +1 -0
- package/dist/pipeline/phases/temporal-helpers/test-pair.d.ts +18 -0
- package/dist/pipeline/phases/temporal-helpers/test-pair.d.ts.map +1 -0
- package/dist/pipeline/phases/temporal-helpers/test-pair.js +119 -0
- package/dist/pipeline/phases/temporal-helpers/test-pair.js.map +1 -0
- package/dist/pipeline/phases/temporal.d.ts +65 -0
- package/dist/pipeline/phases/temporal.d.ts.map +1 -0
- package/dist/pipeline/phases/temporal.js +621 -0
- package/dist/pipeline/phases/temporal.js.map +1 -0
- package/dist/pipeline/phases/tools.d.ts +21 -0
- package/dist/pipeline/phases/tools.d.ts.map +1 -0
- package/dist/pipeline/phases/tools.js +118 -0
- package/dist/pipeline/phases/tools.js.map +1 -0
- package/dist/pipeline/profile-detectors/api-contracts.d.ts +18 -0
- package/dist/pipeline/profile-detectors/api-contracts.d.ts.map +1 -0
- package/dist/pipeline/profile-detectors/api-contracts.js +78 -0
- package/dist/pipeline/profile-detectors/api-contracts.js.map +1 -0
- package/dist/pipeline/profile-detectors/framework-detector.d.ts +11 -0
- package/dist/pipeline/profile-detectors/framework-detector.d.ts.map +1 -0
- package/dist/pipeline/profile-detectors/framework-detector.js +11 -0
- package/dist/pipeline/profile-detectors/framework-detector.js.map +1 -0
- package/dist/pipeline/profile-detectors/frameworks-catalog.d.ts +7 -0
- package/dist/pipeline/profile-detectors/frameworks-catalog.d.ts.map +1 -0
- package/dist/pipeline/profile-detectors/frameworks-catalog.js +7 -0
- package/dist/pipeline/profile-detectors/frameworks-catalog.js.map +1 -0
- package/dist/pipeline/profile-detectors/frameworks.d.ts +7 -0
- package/dist/pipeline/profile-detectors/frameworks.d.ts.map +1 -0
- package/dist/pipeline/profile-detectors/frameworks.js +7 -0
- package/dist/pipeline/profile-detectors/frameworks.js.map +1 -0
- package/dist/pipeline/profile-detectors/iac.d.ts +22 -0
- package/dist/pipeline/profile-detectors/iac.d.ts.map +1 -0
- package/dist/pipeline/profile-detectors/iac.js +97 -0
- package/dist/pipeline/profile-detectors/iac.js.map +1 -0
- package/dist/pipeline/profile-detectors/languages.d.ts +18 -0
- package/dist/pipeline/profile-detectors/languages.d.ts.map +1 -0
- package/dist/pipeline/profile-detectors/languages.js +60 -0
- package/dist/pipeline/profile-detectors/languages.js.map +1 -0
- package/dist/pipeline/profile-detectors/manifests.d.ts +7 -0
- package/dist/pipeline/profile-detectors/manifests.d.ts.map +1 -0
- package/dist/pipeline/profile-detectors/manifests.js +7 -0
- package/dist/pipeline/profile-detectors/manifests.js.map +1 -0
- package/dist/pipeline/profile-detectors/src-dirs.d.ts +17 -0
- package/dist/pipeline/profile-detectors/src-dirs.d.ts.map +1 -0
- package/dist/pipeline/profile-detectors/src-dirs.js +89 -0
- package/dist/pipeline/profile-detectors/src-dirs.js.map +1 -0
- package/dist/pipeline/profile-detectors/variant-detectors.d.ts +7 -0
- package/dist/pipeline/profile-detectors/variant-detectors.d.ts.map +1 -0
- package/dist/pipeline/profile-detectors/variant-detectors.js +7 -0
- package/dist/pipeline/profile-detectors/variant-detectors.js.map +1 -0
- package/dist/pipeline/runner.d.ts +54 -0
- package/dist/pipeline/runner.d.ts.map +1 -0
- package/dist/pipeline/runner.js +247 -0
- package/dist/pipeline/runner.js.map +1 -0
- package/dist/pipeline/types.d.ts +235 -0
- package/dist/pipeline/types.d.ts.map +1 -0
- package/dist/pipeline/types.js +15 -0
- package/dist/pipeline/types.js.map +1 -0
- package/dist/providers/c.d.ts +3 -0
- package/dist/providers/c.d.ts.map +1 -0
- package/dist/providers/c.js +162 -0
- package/dist/providers/c.js.map +1 -0
- package/dist/providers/cobol.d.ts +19 -0
- package/dist/providers/cobol.d.ts.map +1 -0
- package/dist/providers/cobol.js +44 -0
- package/dist/providers/cobol.js.map +1 -0
- package/dist/providers/cpp.d.ts +3 -0
- package/dist/providers/cpp.d.ts.map +1 -0
- package/dist/providers/cpp.js +200 -0
- package/dist/providers/cpp.js.map +1 -0
- package/dist/providers/csharp.d.ts +3 -0
- package/dist/providers/csharp.d.ts.map +1 -0
- package/dist/providers/csharp.js +292 -0
- package/dist/providers/csharp.js.map +1 -0
- package/dist/providers/dart.d.ts +3 -0
- package/dist/providers/dart.d.ts.map +1 -0
- package/dist/providers/dart.js +214 -0
- package/dist/providers/dart.js.map +1 -0
- package/dist/providers/definition-ids.d.ts +18 -0
- package/dist/providers/definition-ids.d.ts.map +1 -0
- package/dist/providers/definition-ids.js +23 -0
- package/dist/providers/definition-ids.js.map +1 -0
- package/dist/providers/extract-helpers.d.ts +60 -0
- package/dist/providers/extract-helpers.d.ts.map +1 -0
- package/dist/providers/extract-helpers.js +296 -0
- package/dist/providers/extract-helpers.js.map +1 -0
- package/dist/providers/extraction-types.d.ts +85 -0
- package/dist/providers/extraction-types.d.ts.map +1 -0
- package/dist/providers/extraction-types.js +13 -0
- package/dist/providers/extraction-types.js.map +1 -0
- package/dist/providers/go.d.ts +3 -0
- package/dist/providers/go.d.ts.map +1 -0
- package/dist/providers/go.js +359 -0
- package/dist/providers/go.js.map +1 -0
- package/dist/providers/http-detect.d.ts +44 -0
- package/dist/providers/http-detect.d.ts.map +1 -0
- package/dist/providers/http-detect.js +307 -0
- package/dist/providers/http-detect.js.map +1 -0
- package/dist/providers/index.d.ts +38 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +33 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/java.d.ts +3 -0
- package/dist/providers/java.d.ts.map +1 -0
- package/dist/providers/java.js +259 -0
- package/dist/providers/java.js.map +1 -0
- package/dist/providers/javascript.d.ts +3 -0
- package/dist/providers/javascript.d.ts.map +1 -0
- package/dist/providers/javascript.js +139 -0
- package/dist/providers/javascript.js.map +1 -0
- package/dist/providers/kotlin.d.ts +3 -0
- package/dist/providers/kotlin.d.ts.map +1 -0
- package/dist/providers/kotlin.js +175 -0
- package/dist/providers/kotlin.js.map +1 -0
- package/dist/providers/php.d.ts +3 -0
- package/dist/providers/php.d.ts.map +1 -0
- package/dist/providers/php.js +218 -0
- package/dist/providers/php.js.map +1 -0
- package/dist/providers/python-accesses.d.ts +9 -0
- package/dist/providers/python-accesses.d.ts.map +1 -0
- package/dist/providers/python-accesses.js +22 -0
- package/dist/providers/python-accesses.js.map +1 -0
- package/dist/providers/python.d.ts +3 -0
- package/dist/providers/python.d.ts.map +1 -0
- package/dist/providers/python.js +323 -0
- package/dist/providers/python.js.map +1 -0
- package/dist/providers/registry.d.ts +4 -0
- package/dist/providers/registry.d.ts.map +1 -0
- package/dist/providers/registry.js +46 -0
- package/dist/providers/registry.js.map +1 -0
- package/dist/providers/resolution/c3.d.ts +6 -0
- package/dist/providers/resolution/c3.d.ts.map +1 -0
- package/dist/providers/resolution/c3.js +76 -0
- package/dist/providers/resolution/c3.js.map +1 -0
- package/dist/providers/resolution/context.d.ts +38 -0
- package/dist/providers/resolution/context.d.ts.map +1 -0
- package/dist/providers/resolution/context.js +45 -0
- package/dist/providers/resolution/context.js.map +1 -0
- package/dist/providers/resolution/first-wins.d.ts +3 -0
- package/dist/providers/resolution/first-wins.d.ts.map +1 -0
- package/dist/providers/resolution/first-wins.js +27 -0
- package/dist/providers/resolution/first-wins.js.map +1 -0
- package/dist/providers/resolution/mro.d.ts +16 -0
- package/dist/providers/resolution/mro.d.ts.map +1 -0
- package/dist/providers/resolution/mro.js +14 -0
- package/dist/providers/resolution/mro.js.map +1 -0
- package/dist/providers/resolution/none.d.ts +3 -0
- package/dist/providers/resolution/none.d.ts.map +1 -0
- package/dist/providers/resolution/none.js +11 -0
- package/dist/providers/resolution/none.js.map +1 -0
- package/dist/providers/resolution/python-all-filter.d.ts +25 -0
- package/dist/providers/resolution/python-all-filter.d.ts.map +1 -0
- package/dist/providers/resolution/python-all-filter.js +64 -0
- package/dist/providers/resolution/python-all-filter.js.map +1 -0
- package/dist/providers/resolution/resolver-strategy.d.ts +42 -0
- package/dist/providers/resolution/resolver-strategy.d.ts.map +1 -0
- package/dist/providers/resolution/resolver-strategy.js +50 -0
- package/dist/providers/resolution/resolver-strategy.js.map +1 -0
- package/dist/providers/resolution/single-inheritance.d.ts +3 -0
- package/dist/providers/resolution/single-inheritance.d.ts.map +1 -0
- package/dist/providers/resolution/single-inheritance.js +21 -0
- package/dist/providers/resolution/single-inheritance.js.map +1 -0
- package/dist/providers/resolution/stack-graphs/__fixtures__/mock-tree.d.ts +16 -0
- package/dist/providers/resolution/stack-graphs/__fixtures__/mock-tree.d.ts.map +1 -0
- package/dist/providers/resolution/stack-graphs/__fixtures__/mock-tree.js +50 -0
- package/dist/providers/resolution/stack-graphs/__fixtures__/mock-tree.js.map +1 -0
- package/dist/providers/resolution/stack-graphs/glue.d.ts +15 -0
- package/dist/providers/resolution/stack-graphs/glue.d.ts.map +1 -0
- package/dist/providers/resolution/stack-graphs/glue.js +44 -0
- package/dist/providers/resolution/stack-graphs/glue.js.map +1 -0
- package/dist/providers/resolution/stack-graphs/node-edge-builder.d.ts +30 -0
- package/dist/providers/resolution/stack-graphs/node-edge-builder.d.ts.map +1 -0
- package/dist/providers/resolution/stack-graphs/node-edge-builder.js +366 -0
- package/dist/providers/resolution/stack-graphs/node-edge-builder.js.map +1 -0
- package/dist/providers/resolution/stack-graphs/partial-path-engine.d.ts +9 -0
- package/dist/providers/resolution/stack-graphs/partial-path-engine.d.ts.map +1 -0
- package/dist/providers/resolution/stack-graphs/partial-path-engine.js +152 -0
- package/dist/providers/resolution/stack-graphs/partial-path-engine.js.map +1 -0
- package/dist/providers/resolution/stack-graphs/rule-parser.d.ts +11 -0
- package/dist/providers/resolution/stack-graphs/rule-parser.d.ts.map +1 -0
- package/dist/providers/resolution/stack-graphs/rule-parser.js +247 -0
- package/dist/providers/resolution/stack-graphs/rule-parser.js.map +1 -0
- package/dist/providers/resolution/stack-graphs/types.d.ts +93 -0
- package/dist/providers/resolution/stack-graphs/types.d.ts.map +1 -0
- package/dist/providers/resolution/stack-graphs/types.js +11 -0
- package/dist/providers/resolution/stack-graphs/types.js.map +1 -0
- package/dist/providers/resolution/stack-graphs-python.d.ts +27 -0
- package/dist/providers/resolution/stack-graphs-python.d.ts.map +1 -0
- package/dist/providers/resolution/stack-graphs-python.js +104 -0
- package/dist/providers/resolution/stack-graphs-python.js.map +1 -0
- package/dist/providers/resolution/stack-graphs-ts.d.ts +134 -0
- package/dist/providers/resolution/stack-graphs-ts.d.ts.map +1 -0
- package/dist/providers/resolution/stack-graphs-ts.js +372 -0
- package/dist/providers/resolution/stack-graphs-ts.js.map +1 -0
- package/dist/providers/ruby.d.ts +3 -0
- package/dist/providers/ruby.d.ts.map +1 -0
- package/dist/providers/ruby.js +259 -0
- package/dist/providers/ruby.js.map +1 -0
- package/dist/providers/rust.d.ts +3 -0
- package/dist/providers/rust.d.ts.map +1 -0
- package/dist/providers/rust.js +318 -0
- package/dist/providers/rust.js.map +1 -0
- package/dist/providers/swift.d.ts +3 -0
- package/dist/providers/swift.d.ts.map +1 -0
- package/dist/providers/swift.js +177 -0
- package/dist/providers/swift.js.map +1 -0
- package/dist/providers/test-helpers.d.ts +24 -0
- package/dist/providers/test-helpers.d.ts.map +1 -0
- package/dist/providers/test-helpers.js +33 -0
- package/dist/providers/test-helpers.js.map +1 -0
- package/dist/providers/ts-shared.d.ts +30 -0
- package/dist/providers/ts-shared.d.ts.map +1 -0
- package/dist/providers/ts-shared.js +328 -0
- package/dist/providers/ts-shared.js.map +1 -0
- package/dist/providers/tsx.d.ts +7 -0
- package/dist/providers/tsx.d.ts.map +1 -0
- package/dist/providers/tsx.js +79 -0
- package/dist/providers/tsx.js.map +1 -0
- package/dist/providers/types.d.ts +166 -0
- package/dist/providers/types.d.ts.map +1 -0
- package/dist/providers/types.js +7 -0
- package/dist/providers/types.js.map +1 -0
- package/dist/providers/typescript-family-accesses.d.ts +14 -0
- package/dist/providers/typescript-family-accesses.d.ts.map +1 -0
- package/dist/providers/typescript-family-accesses.js +27 -0
- package/dist/providers/typescript-family-accesses.js.map +1 -0
- package/dist/providers/typescript.d.ts +9 -0
- package/dist/providers/typescript.d.ts.map +1 -0
- package/dist/providers/typescript.js +84 -0
- package/dist/providers/typescript.js.map +1 -0
- package/package.json +108 -0
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Route detectors.
|
|
3
|
+
*
|
|
4
|
+
* This file carries Next.js App Router (filesystem routing) and Express
|
|
5
|
+
* (app/router verb calls). Sibling files supply the other detectors:
|
|
6
|
+
*
|
|
7
|
+
* - FastAPI / Starlette: route-detector-python.ts
|
|
8
|
+
* - Spring MVC + WebFlux: route-detector-java.ts
|
|
9
|
+
* - NestJS: route-detector-nestjs.ts
|
|
10
|
+
* - Rails (`config/routes.rb`): route-detector-rails.ts
|
|
11
|
+
*
|
|
12
|
+
* All patterns below were authored fresh from the public framework
|
|
13
|
+
* documentation:
|
|
14
|
+
* - Next.js App Router: https://nextjs.org/docs/app/building-your-application/routing
|
|
15
|
+
* - Express routing: https://expressjs.com/en/guide/routing.html
|
|
16
|
+
*/
|
|
17
|
+
import { resolveReceiver } from "./receiver-resolver.js";
|
|
18
|
+
/**
|
|
19
|
+
* Module specifier the Express detector verifies receivers against. We
|
|
20
|
+
* accept only the canonical `"express"` specifier; wrapping libraries
|
|
21
|
+
* (`express-promise-router`, etc.) that rename `app`/`router` locally will
|
|
22
|
+
* land via their own `localAlias` so this tight match is safe.
|
|
23
|
+
*/
|
|
24
|
+
const EXPRESS_MODULE = "express";
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
// Next.js (App Router)
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
/** Files that are not routable themselves, even though they sit under `app/`. */
|
|
29
|
+
const NEXTJS_SPECIAL_FILES = new Set([
|
|
30
|
+
"layout",
|
|
31
|
+
"error",
|
|
32
|
+
"loading",
|
|
33
|
+
"not-found",
|
|
34
|
+
"global-error",
|
|
35
|
+
"template",
|
|
36
|
+
"default",
|
|
37
|
+
]);
|
|
38
|
+
/** HTTP verbs that, when exported from a `route.ts`, become method handlers. */
|
|
39
|
+
const NEXTJS_ROUTE_VERBS = ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"];
|
|
40
|
+
/** Match `export async function GET`, `export function POST`, `export const DELETE =`, etc. */
|
|
41
|
+
const NEXTJS_VERB_EXPORT_RE = /export\s+(?:async\s+)?(?:function|const|let|var)\s+(GET|POST|PUT|DELETE|PATCH|HEAD|OPTIONS)\b/g;
|
|
42
|
+
/**
|
|
43
|
+
* Convert one App-Router path segment to URL form:
|
|
44
|
+
* - `(group)` -> dropped (route groups, docs: "Route Groups")
|
|
45
|
+
* - `[...slug]` -> `{+slug}` (catch-all)
|
|
46
|
+
* - `[[...slug]]` -> `{+slug}` (optional catch-all; same shape at this layer)
|
|
47
|
+
* - `[id]` -> `{id}` (dynamic segment)
|
|
48
|
+
* - anything else -> passed through unchanged
|
|
49
|
+
*/
|
|
50
|
+
function nextJsSegmentToUrl(segment) {
|
|
51
|
+
if (segment.length === 0)
|
|
52
|
+
return null;
|
|
53
|
+
// Route groups: (foo) — invisible in URL.
|
|
54
|
+
if (segment.startsWith("(") && segment.endsWith(")"))
|
|
55
|
+
return null;
|
|
56
|
+
// Optional catch-all: [[...name]]
|
|
57
|
+
const optionalCatch = segment.match(/^\[\[\.\.\.(.+)\]\]$/);
|
|
58
|
+
if (optionalCatch)
|
|
59
|
+
return `{+${optionalCatch[1]}}`;
|
|
60
|
+
// Catch-all: [...name]
|
|
61
|
+
const catchAll = segment.match(/^\[\.\.\.(.+)\]$/);
|
|
62
|
+
if (catchAll)
|
|
63
|
+
return `{+${catchAll[1]}}`;
|
|
64
|
+
// Dynamic: [name]
|
|
65
|
+
const dynamic = segment.match(/^\[(.+)\]$/);
|
|
66
|
+
if (dynamic)
|
|
67
|
+
return `{${dynamic[1]}}`;
|
|
68
|
+
return segment;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Given a repo-relative file path, return the canonical URL under App Router,
|
|
72
|
+
* or `null` if the file is not a route. The input `filePath` is expected to
|
|
73
|
+
* be POSIX-style (forward slashes); on Windows callers should normalise.
|
|
74
|
+
*/
|
|
75
|
+
function nextJsUrlFromFilePath(filePath, repoRoot) {
|
|
76
|
+
const normalized = normalizeRelative(filePath, repoRoot);
|
|
77
|
+
const parts = normalized.split("/");
|
|
78
|
+
const appIndex = parts.indexOf("app");
|
|
79
|
+
if (appIndex === -1)
|
|
80
|
+
return null;
|
|
81
|
+
const under = parts.slice(appIndex + 1);
|
|
82
|
+
if (under.length === 0)
|
|
83
|
+
return null;
|
|
84
|
+
const last = under[under.length - 1];
|
|
85
|
+
if (last === undefined)
|
|
86
|
+
return null;
|
|
87
|
+
const match = last.match(/^(.+)\.(tsx?|jsx?|mjs|mts|cjs|cts)$/);
|
|
88
|
+
if (!match)
|
|
89
|
+
return null;
|
|
90
|
+
const basename = match[1];
|
|
91
|
+
// Only `route` and `page` map to URLs; layouts/error/loading/etc. are skipped.
|
|
92
|
+
if (basename !== "route" && basename !== "page")
|
|
93
|
+
return null;
|
|
94
|
+
if (NEXTJS_SPECIAL_FILES.has(basename))
|
|
95
|
+
return null;
|
|
96
|
+
const urlSegments = [];
|
|
97
|
+
for (const seg of under.slice(0, -1)) {
|
|
98
|
+
const converted = nextJsSegmentToUrl(seg);
|
|
99
|
+
if (converted === null)
|
|
100
|
+
continue;
|
|
101
|
+
urlSegments.push(converted);
|
|
102
|
+
}
|
|
103
|
+
return urlSegments.length === 0 ? "/" : `/${urlSegments.join("/")}`;
|
|
104
|
+
}
|
|
105
|
+
function normalizeRelative(filePath, repoRoot) {
|
|
106
|
+
const p = filePath.replace(/\\/g, "/");
|
|
107
|
+
const r = repoRoot.replace(/\\/g, "/").replace(/\/+$/, "");
|
|
108
|
+
if (r.length > 0 && p.startsWith(`${r}/`))
|
|
109
|
+
return p.slice(r.length + 1);
|
|
110
|
+
if (p.startsWith("/"))
|
|
111
|
+
return p.slice(1);
|
|
112
|
+
return p;
|
|
113
|
+
}
|
|
114
|
+
function extractNextJsVerbs(content) {
|
|
115
|
+
const verbs = new Set();
|
|
116
|
+
NEXTJS_VERB_EXPORT_RE.lastIndex = 0;
|
|
117
|
+
let match = NEXTJS_VERB_EXPORT_RE.exec(content);
|
|
118
|
+
while (match !== null) {
|
|
119
|
+
const verb = match[1];
|
|
120
|
+
if (verb !== undefined)
|
|
121
|
+
verbs.add(verb);
|
|
122
|
+
match = NEXTJS_VERB_EXPORT_RE.exec(content);
|
|
123
|
+
}
|
|
124
|
+
// Preserve canonical ordering instead of insertion order for byte-stability.
|
|
125
|
+
return NEXTJS_ROUTE_VERBS.filter((v) => verbs.has(v));
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Walk the supplied files, filter to those under `app/**`, and emit one
|
|
129
|
+
* `ExtractedRoute` per route/method pair. `page.tsx` files emit a single
|
|
130
|
+
* route with no method (treated as an HTML GET page by consumers).
|
|
131
|
+
*/
|
|
132
|
+
export function detectNextJsRoutes(files, repoRoot) {
|
|
133
|
+
const out = [];
|
|
134
|
+
for (const file of files) {
|
|
135
|
+
const url = nextJsUrlFromFilePath(file.filePath, repoRoot);
|
|
136
|
+
if (url === null)
|
|
137
|
+
continue;
|
|
138
|
+
const rel = normalizeRelative(file.filePath, repoRoot);
|
|
139
|
+
const isRoute = /(^|\/)route\.(tsx?|jsx?|mjs|mts|cjs|cts)$/.test(rel);
|
|
140
|
+
if (isRoute) {
|
|
141
|
+
const verbs = extractNextJsVerbs(file.content);
|
|
142
|
+
if (verbs.length === 0) {
|
|
143
|
+
// A route.ts with no recognised verb export is still a route shell;
|
|
144
|
+
// surface it without a method so the pipeline can warn downstream.
|
|
145
|
+
out.push({ url, handlerFile: rel, framework: "nextjs" });
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
for (const method of verbs) {
|
|
149
|
+
out.push({ url, method, handlerFile: rel, framework: "nextjs" });
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
// `page.tsx` — a renderable route; no HTTP method attached.
|
|
155
|
+
out.push({ url, handlerFile: rel, framework: "nextjs" });
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return out;
|
|
159
|
+
}
|
|
160
|
+
// ---------------------------------------------------------------------------
|
|
161
|
+
// Express
|
|
162
|
+
// ---------------------------------------------------------------------------
|
|
163
|
+
/**
|
|
164
|
+
* Match `app.get('/x', h)` / `router.post("/x", m, h)` / `server.use(\`/x\`, h)`.
|
|
165
|
+
*
|
|
166
|
+
* Group 1: receiver identifier (e.g. `app`, `router`, `apiRouter`).
|
|
167
|
+
* Group 2: HTTP verb keyword.
|
|
168
|
+
* Group 3: path — single-quoted, double-quoted, or template-literal body.
|
|
169
|
+
*
|
|
170
|
+
* Template-literal bodies are captured verbatim; callers inspect for `${...}`
|
|
171
|
+
* to decide whether to log a warning about unresolved interpolation.
|
|
172
|
+
*/
|
|
173
|
+
const EXPRESS_ROUTE_RE = /\b([A-Za-z_$][\w$]*)\s*\.\s*(get|post|put|delete|patch|all|use)\s*\(\s*(?:'([^']*)'|"([^"]*)"|`([^`]*)`)/g;
|
|
174
|
+
const EXPRESS_VERBS = new Set([
|
|
175
|
+
"get",
|
|
176
|
+
"post",
|
|
177
|
+
"put",
|
|
178
|
+
"delete",
|
|
179
|
+
"patch",
|
|
180
|
+
"all",
|
|
181
|
+
"use",
|
|
182
|
+
]);
|
|
183
|
+
/**
|
|
184
|
+
* Regex-scan the file content for Express route registrations and emit one
|
|
185
|
+
* {@link ExtractedRoute} per (receiver, verb, path) triple whose receiver
|
|
186
|
+
* identifier resolves back to the `"express"` npm module. When no import
|
|
187
|
+
* map is supplied AND {@link ExtractInput.strictDetectors} is `false`, the
|
|
188
|
+
* detector falls back to the pre-P06 regex-only behavior so dogfood mode
|
|
189
|
+
* on legacy callers still produces edges.
|
|
190
|
+
*/
|
|
191
|
+
export function detectExpressRoutes(input) {
|
|
192
|
+
const { filePath, content, importsByFile, tsMorphProject, strictDetectors } = input;
|
|
193
|
+
const out = [];
|
|
194
|
+
EXPRESS_ROUTE_RE.lastIndex = 0;
|
|
195
|
+
let match = EXPRESS_ROUTE_RE.exec(content);
|
|
196
|
+
while (match !== null) {
|
|
197
|
+
const receiver = match[1] ?? "";
|
|
198
|
+
const verb = (match[2] ?? "").toLowerCase();
|
|
199
|
+
const pathSingle = match[3];
|
|
200
|
+
const pathDouble = match[4];
|
|
201
|
+
const pathTemplate = match[5];
|
|
202
|
+
const rawPath = pathSingle ?? pathDouble ?? pathTemplate;
|
|
203
|
+
const matchStart = match.index ?? 0;
|
|
204
|
+
const matchEnd = matchStart + match[0].length;
|
|
205
|
+
match = EXPRESS_ROUTE_RE.exec(content);
|
|
206
|
+
if (rawPath === undefined)
|
|
207
|
+
continue;
|
|
208
|
+
if (!EXPRESS_VERBS.has(verb))
|
|
209
|
+
continue;
|
|
210
|
+
if (pathTemplate !== undefined && /\$\{[^}]*\}/.test(pathTemplate)) {
|
|
211
|
+
// Template literal with interpolation; the URL cannot be resolved
|
|
212
|
+
// statically. Skip but leave a console warning so pipeline logs can
|
|
213
|
+
// surface it; consumers that want silent behaviour can wrap console.
|
|
214
|
+
// eslint-disable-next-line no-console
|
|
215
|
+
console.warn(`[extract/route-detector] express template literal with interpolation at ${filePath}: ${pathTemplate}`);
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
if (!confirmExpressReceiver(receiver, filePath, importsByFile, tsMorphProject, strictDetectors))
|
|
219
|
+
continue;
|
|
220
|
+
// Scrape the handler body for `res.json({...})` / `res.send({...})`
|
|
221
|
+
// object-literal shapes so downstream Route nodes can carry
|
|
222
|
+
// `responseKeys`. We scope the scan to the balanced-paren call that
|
|
223
|
+
// registered this route so neighbouring handlers don't bleed in.
|
|
224
|
+
const callBody = extractBalancedArgument(content, matchEnd);
|
|
225
|
+
const responseKeys = scrapeExpressResponseKeys(callBody);
|
|
226
|
+
out.push({
|
|
227
|
+
url: rawPath,
|
|
228
|
+
method: verb.toUpperCase(),
|
|
229
|
+
handlerFile: filePath,
|
|
230
|
+
framework: "express",
|
|
231
|
+
...(responseKeys !== undefined ? { responseKeys } : {}),
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
return out;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Confirm `receiver` resolves to an `express` import in `filePath`. Returns
|
|
238
|
+
* `true` when:
|
|
239
|
+
* - the import-graph or ts-morph path matches `"express"`, OR
|
|
240
|
+
* - an import map is present, the receiver itself wasn't resolved, but
|
|
241
|
+
* `"express"` is imported somewhere in the file (covers
|
|
242
|
+
* `const app = express()` where `app` is a local const, not an
|
|
243
|
+
* import) — unless strict mode is on, OR
|
|
244
|
+
* - no import map was plumbed AND strict mode is off (legacy fallback).
|
|
245
|
+
*
|
|
246
|
+
* Returns `false` when:
|
|
247
|
+
* - the receiver resolved to a DIFFERENT module (real false positive), OR
|
|
248
|
+
* - an import map was plumbed, strict mode is on, and the receiver
|
|
249
|
+
* isn't imported, OR
|
|
250
|
+
* - an import map was plumbed, express is not imported anywhere in the
|
|
251
|
+
* file, and the receiver itself isn't imported.
|
|
252
|
+
*/
|
|
253
|
+
function confirmExpressReceiver(receiver, filePath, importsByFile, tsMorphProject, strictDetectors) {
|
|
254
|
+
const origin = resolveReceiver(receiver, filePath, importsByFile, tsMorphProject);
|
|
255
|
+
if (origin !== null)
|
|
256
|
+
return origin.moduleName === EXPRESS_MODULE;
|
|
257
|
+
if (importsByFile !== undefined) {
|
|
258
|
+
if (strictDetectors)
|
|
259
|
+
return false;
|
|
260
|
+
const imports = importsByFile.get(filePath);
|
|
261
|
+
if (imports === undefined)
|
|
262
|
+
return false;
|
|
263
|
+
for (const imp of imports) {
|
|
264
|
+
if (imp.source === EXPRESS_MODULE)
|
|
265
|
+
return true;
|
|
266
|
+
}
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
return strictDetectors !== true;
|
|
270
|
+
}
|
|
271
|
+
// ---------------------------------------------------------------------------
|
|
272
|
+
// Response-key scraping
|
|
273
|
+
// ---------------------------------------------------------------------------
|
|
274
|
+
/**
|
|
275
|
+
* Read from `startIdx` onward until the first balanced `)` closes. Returns
|
|
276
|
+
* the substring between the opening `(` and the matching `)`. When the
|
|
277
|
+
* starting region contains no opening paren (defensive) we return an empty
|
|
278
|
+
* string.
|
|
279
|
+
*/
|
|
280
|
+
function extractBalancedArgument(content, startIdx) {
|
|
281
|
+
let i = startIdx;
|
|
282
|
+
let depth = 0;
|
|
283
|
+
let seenOpen = false;
|
|
284
|
+
let bodyStart = -1;
|
|
285
|
+
while (i < content.length) {
|
|
286
|
+
const ch = content[i];
|
|
287
|
+
if (ch === "(") {
|
|
288
|
+
if (!seenOpen) {
|
|
289
|
+
seenOpen = true;
|
|
290
|
+
bodyStart = i + 1;
|
|
291
|
+
}
|
|
292
|
+
depth += 1;
|
|
293
|
+
}
|
|
294
|
+
else if (ch === ")") {
|
|
295
|
+
depth -= 1;
|
|
296
|
+
if (depth === 0) {
|
|
297
|
+
if (bodyStart === -1)
|
|
298
|
+
return "";
|
|
299
|
+
return content.slice(bodyStart, i);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
else if (!seenOpen && ch === ",") {
|
|
303
|
+
// The regex match consumed the verb's opening paren + path literal;
|
|
304
|
+
// the `,` we hit here is the outer call's separator, so walk back
|
|
305
|
+
// to the original opening paren (already past startIdx).
|
|
306
|
+
if (bodyStart === -1)
|
|
307
|
+
bodyStart = startIdx;
|
|
308
|
+
seenOpen = true;
|
|
309
|
+
depth = 1;
|
|
310
|
+
}
|
|
311
|
+
i += 1;
|
|
312
|
+
}
|
|
313
|
+
return "";
|
|
314
|
+
}
|
|
315
|
+
/** Extract top-level object keys from the first `res.json({...})` match. */
|
|
316
|
+
function scrapeExpressResponseKeys(body) {
|
|
317
|
+
if (body.length === 0)
|
|
318
|
+
return undefined;
|
|
319
|
+
const callRe = /\b(?:res|response)\s*\.\s*(?:json|send)\s*\(\s*(\{[\s\S]*?\})\s*[,)]/;
|
|
320
|
+
const m = callRe.exec(body);
|
|
321
|
+
if (m === null)
|
|
322
|
+
return undefined;
|
|
323
|
+
const keys = parseTopLevelObjectKeys(m[1]);
|
|
324
|
+
return [...keys].sort();
|
|
325
|
+
}
|
|
326
|
+
/** Extract top-level keys from a `NextResponse.json({...})` / `Response.json({...})`. */
|
|
327
|
+
function scrapeNextResponseKeys(handlerBody) {
|
|
328
|
+
if (handlerBody.length === 0)
|
|
329
|
+
return undefined;
|
|
330
|
+
const callRe = /\b(?:NextResponse|Response)\s*\.\s*json\s*\(\s*(\{[\s\S]*?\})\s*[,)]/;
|
|
331
|
+
const m = callRe.exec(handlerBody);
|
|
332
|
+
if (m === null)
|
|
333
|
+
return undefined;
|
|
334
|
+
const keys = parseTopLevelObjectKeys(m[1]);
|
|
335
|
+
return [...keys].sort();
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Parse `{ key1: ..., key2: "x" }` and return the literal top-level keys.
|
|
339
|
+
* Strips nested object/array bodies so `{a:{b:1},c:2}` returns `[a,c]`.
|
|
340
|
+
* Computed keys (`[foo]: 1`) and spreads are dropped.
|
|
341
|
+
*/
|
|
342
|
+
function parseTopLevelObjectKeys(literal) {
|
|
343
|
+
const body = literal.slice(1, -1);
|
|
344
|
+
const keys = [];
|
|
345
|
+
let depth = 0;
|
|
346
|
+
let inString = null;
|
|
347
|
+
let tokenStart = 0;
|
|
348
|
+
let i = 0;
|
|
349
|
+
const boundary = () => {
|
|
350
|
+
const segment = body.slice(tokenStart, i).trim();
|
|
351
|
+
tokenStart = i + 1;
|
|
352
|
+
if (segment.length === 0)
|
|
353
|
+
return;
|
|
354
|
+
const colonIdx = segment.indexOf(":");
|
|
355
|
+
const keyPart = (colonIdx === -1 ? segment : segment.slice(0, colonIdx)).trim();
|
|
356
|
+
const m = /^['"]?([A-Za-z_$][\w$]*)['"]?$/.exec(keyPart);
|
|
357
|
+
if (m !== null)
|
|
358
|
+
keys.push(m[1]);
|
|
359
|
+
};
|
|
360
|
+
while (i < body.length) {
|
|
361
|
+
const ch = body[i];
|
|
362
|
+
if (inString !== null) {
|
|
363
|
+
if (ch === "\\") {
|
|
364
|
+
i += 2;
|
|
365
|
+
continue;
|
|
366
|
+
}
|
|
367
|
+
if (ch === inString)
|
|
368
|
+
inString = null;
|
|
369
|
+
i += 1;
|
|
370
|
+
continue;
|
|
371
|
+
}
|
|
372
|
+
if (ch === '"' || ch === "'" || ch === "`") {
|
|
373
|
+
inString = ch;
|
|
374
|
+
i += 1;
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
if (ch === "{" || ch === "[" || ch === "(")
|
|
378
|
+
depth += 1;
|
|
379
|
+
else if (ch === "}" || ch === "]" || ch === ")")
|
|
380
|
+
depth -= 1;
|
|
381
|
+
else if (ch === "," && depth === 0)
|
|
382
|
+
boundary();
|
|
383
|
+
i += 1;
|
|
384
|
+
}
|
|
385
|
+
boundary();
|
|
386
|
+
return keys;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Walk each Next.js verb handler's body for `NextResponse.json({...})` /
|
|
390
|
+
* `Response.json({...})` and attach the literal keys to the matching route.
|
|
391
|
+
* Returns a fresh array; callers must not mutate the originals.
|
|
392
|
+
*/
|
|
393
|
+
export function populateNextJsResponseKeys(routes, files) {
|
|
394
|
+
if (routes.length === 0)
|
|
395
|
+
return routes;
|
|
396
|
+
const contentByFile = new Map();
|
|
397
|
+
for (const f of files)
|
|
398
|
+
contentByFile.set(f.filePath, f.content);
|
|
399
|
+
return routes.map((r) => {
|
|
400
|
+
if (r.framework !== "nextjs")
|
|
401
|
+
return r;
|
|
402
|
+
if (r.method === undefined)
|
|
403
|
+
return r;
|
|
404
|
+
const content = findFileContent(contentByFile, r.handlerFile);
|
|
405
|
+
if (content === undefined)
|
|
406
|
+
return r;
|
|
407
|
+
const handlerBody = extractNextJsHandlerBody(content, r.method);
|
|
408
|
+
const keys = scrapeNextResponseKeys(handlerBody);
|
|
409
|
+
return keys !== undefined ? { ...r, responseKeys: keys } : r;
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
function findFileContent(contentByFile, handlerFile) {
|
|
413
|
+
const direct = contentByFile.get(handlerFile);
|
|
414
|
+
if (direct !== undefined)
|
|
415
|
+
return direct;
|
|
416
|
+
for (const [k, v] of contentByFile) {
|
|
417
|
+
if (k.endsWith(`/${handlerFile}`))
|
|
418
|
+
return v;
|
|
419
|
+
}
|
|
420
|
+
return undefined;
|
|
421
|
+
}
|
|
422
|
+
function extractNextJsHandlerBody(content, verb) {
|
|
423
|
+
const fnRe = new RegExp(`export\\s+(?:async\\s+)?function\\s+${verb}\\s*\\([^)]*\\)\\s*\\{`, "m");
|
|
424
|
+
const fnMatch = fnRe.exec(content);
|
|
425
|
+
if (fnMatch !== null) {
|
|
426
|
+
const start = fnMatch.index + fnMatch[0].length - 1;
|
|
427
|
+
return sliceBalancedBlock(content, start);
|
|
428
|
+
}
|
|
429
|
+
const constRe = new RegExp(`export\\s+const\\s+${verb}\\s*=\\s*(?:async\\s*)?\\([^)]*\\)\\s*=>\\s*\\{`, "m");
|
|
430
|
+
const constMatch = constRe.exec(content);
|
|
431
|
+
if (constMatch !== null) {
|
|
432
|
+
const start = constMatch.index + constMatch[0].length - 1;
|
|
433
|
+
return sliceBalancedBlock(content, start);
|
|
434
|
+
}
|
|
435
|
+
return "";
|
|
436
|
+
}
|
|
437
|
+
function sliceBalancedBlock(content, openBraceIdx) {
|
|
438
|
+
if (content[openBraceIdx] !== "{")
|
|
439
|
+
return "";
|
|
440
|
+
let depth = 0;
|
|
441
|
+
let inString = null;
|
|
442
|
+
for (let i = openBraceIdx; i < content.length; i += 1) {
|
|
443
|
+
const ch = content[i];
|
|
444
|
+
if (inString !== null) {
|
|
445
|
+
if (ch === "\\") {
|
|
446
|
+
i += 1;
|
|
447
|
+
continue;
|
|
448
|
+
}
|
|
449
|
+
if (ch === inString)
|
|
450
|
+
inString = null;
|
|
451
|
+
continue;
|
|
452
|
+
}
|
|
453
|
+
if (ch === '"' || ch === "'" || ch === "`") {
|
|
454
|
+
inString = ch;
|
|
455
|
+
continue;
|
|
456
|
+
}
|
|
457
|
+
if (ch === "{")
|
|
458
|
+
depth += 1;
|
|
459
|
+
else if (ch === "}") {
|
|
460
|
+
depth -= 1;
|
|
461
|
+
if (depth === 0)
|
|
462
|
+
return content.slice(openBraceIdx + 1, i);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
return "";
|
|
466
|
+
}
|
|
467
|
+
//# sourceMappingURL=route-detector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-detector.js","sourceRoot":"","sources":["../../src/extract/route-detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGzD;;;;;GAKG;AACH,MAAM,cAAc,GAAG,SAAS,CAAC;AAEjC,8EAA8E;AAC9E,uBAAuB;AACvB,8EAA8E;AAE9E,iFAAiF;AACjF,MAAM,oBAAoB,GAAwB,IAAI,GAAG,CAAC;IACxD,QAAQ;IACR,OAAO;IACP,SAAS;IACT,WAAW;IACX,cAAc;IACd,UAAU;IACV,SAAS;CACV,CAAC,CAAC;AAEH,gFAAgF;AAChF,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,MAAM,EAA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AE,OAAO,EAAE,CAAC;IAC7C,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,QAAQ,GAAkB,IAAI,CAAC;IACnC,KAAK,IAAI,CAAC,GAAG,YAAY,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACtD,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;YACtB,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC;gBAChB,CAAC,IAAI,CAAC,CAAC;gBACP,SAAS;YACX,CAAC;YACD,IAAI,EAAE,KAAK,QAAQ;gBAAE,QAAQ,GAAG,IAAI,CAAC;YACrC,SAAS;QACX,CAAC;QACD,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,KAAK,GAAG,EAAE,CAAC;YAC3C,QAAQ,GAAG,EAAE,CAAC;YACd,SAAS;QACX,CAAC;QACD,IAAI,EAAE,KAAK,GAAG;YAAE,KAAK,IAAI,CAAC,CAAC;aACtB,IAAI,EAAE,KAAK,GAAG,EAAE,CAAC;YACpB,KAAK,IAAI,CAAC,CAAC;YACX,IAAI,KAAK,KAAK,CAAC;gBAAE,OAAO,OAAO,CAAC,KAAK,CAAC,YAAY,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP / JSON-RPC tool detector.
|
|
3
|
+
*
|
|
4
|
+
* The heuristic is intentionally coarse: many agent frameworks (MCP, LangChain
|
|
5
|
+
* tools, OpenAI function schemas) converge on a `{ name, description, ... }`
|
|
6
|
+
* object literal for each tool. At MVP we only claim a match when the file
|
|
7
|
+
* path *also* signals "tool-ness", which eliminates the majority of false
|
|
8
|
+
* positives coming from generic config blocks.
|
|
9
|
+
*
|
|
10
|
+
* Pattern authored fresh — no external regex reused.
|
|
11
|
+
*/
|
|
12
|
+
import type { ExtractedTool, ExtractInput } from "./types.js";
|
|
13
|
+
/**
|
|
14
|
+
* Translate an object literal written in relaxed JS syntax (single quotes,
|
|
15
|
+
* unquoted keys, trailing commas) into strict canonical JSON sorted by key.
|
|
16
|
+
* Returns `undefined` when the literal is too exotic to normalize safely
|
|
17
|
+
* (template strings, bareword values, computed keys).
|
|
18
|
+
*/
|
|
19
|
+
export declare function canonicalizeObjectLiteral(literal: string): string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Emit one `ExtractedTool` per `{ name, description }` literal pair found in
|
|
22
|
+
* the same 5-line window. Duplicates (same `toolName` + `description`) are
|
|
23
|
+
* de-duplicated per file; cross-file de-duplication is a later phase concern.
|
|
24
|
+
*/
|
|
25
|
+
export declare function detectMcpTools(input: ExtractInput): readonly ExtractedTool[];
|
|
26
|
+
//# sourceMappingURL=tool-detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-detector.d.ts","sourceRoot":"","sources":["../../src/extract/tool-detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAgI9D;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAU7E;AA8JD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS,aAAa,EAAE,CAkD5E"}
|