@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,303 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MRO phase — emit `METHOD_OVERRIDES` / `METHOD_IMPLEMENTS` edges by
|
|
3
|
+
* linearising each class's ancestor chain with its language-specific
|
|
4
|
+
* strategy.
|
|
5
|
+
*
|
|
6
|
+
* Strategy-per-language table:
|
|
7
|
+
* - `python` → `c3` (raises on ambiguity; caught + skipped per-class).
|
|
8
|
+
* - `typescript`, `tsx`, `javascript`, `rust` → `first-wins`.
|
|
9
|
+
* - `java`, `csharp` → `single-inheritance`; interfaces drive
|
|
10
|
+
* `METHOD_IMPLEMENTS` edges separately.
|
|
11
|
+
* - `go` → `none`; no class-based inheritance. Skipped entirely.
|
|
12
|
+
*
|
|
13
|
+
* Determinism: parents and methods are iterated in sorted-id order, so the
|
|
14
|
+
* edge set is byte-identical across runs.
|
|
15
|
+
*/
|
|
16
|
+
import { getProvider } from "../../providers/registry.js";
|
|
17
|
+
import { MroConflictError } from "../../providers/resolution/c3.js";
|
|
18
|
+
import { getMroStrategy } from "../../providers/resolution/mro.js";
|
|
19
|
+
import { CROSS_FILE_PHASE_NAME } from "./cross-file.js";
|
|
20
|
+
import { buildFilePathLookup, partitionPriorEdges, resolveIncrementalView, } from "./incremental-helper.js";
|
|
21
|
+
import { INCREMENTAL_SCOPE_PHASE_NAME } from "./incremental-scope.js";
|
|
22
|
+
import { STRUCTURE_PHASE_NAME } from "./structure.js";
|
|
23
|
+
export const MRO_PHASE_NAME = "mro";
|
|
24
|
+
/**
|
|
25
|
+
* Kinds that own methods and participate in the MRO walk.
|
|
26
|
+
*/
|
|
27
|
+
const OWNER_KINDS = new Set(["Class", "Interface", "Struct", "Trait"]);
|
|
28
|
+
export const mroPhase = {
|
|
29
|
+
name: MRO_PHASE_NAME,
|
|
30
|
+
deps: [CROSS_FILE_PHASE_NAME, STRUCTURE_PHASE_NAME, INCREMENTAL_SCOPE_PHASE_NAME],
|
|
31
|
+
async run(ctx) {
|
|
32
|
+
return runMro(ctx);
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
function runMro(ctx) {
|
|
36
|
+
// ---- : incremental carry-forward. -----------------------------
|
|
37
|
+
//
|
|
38
|
+
// When the incremental view is active we replay every prior-graph
|
|
39
|
+
// METHOD_OVERRIDES / METHOD_IMPLEMENTS edge whose both endpoints live
|
|
40
|
+
// outside the closure. The closure already pulled in a 1-hop heritage
|
|
41
|
+
// expansion (incremental-scope.ts lines 31-32), so any class whose
|
|
42
|
+
// ancestor moved is already in scope and will re-linearise below. Carry-
|
|
43
|
+
// forward for the rest keeps the graph hash byte-identical to a full
|
|
44
|
+
// run at the same commit (see `incremental-determinism.test.ts`).
|
|
45
|
+
const view = resolveIncrementalView(ctx);
|
|
46
|
+
if (view.active &&
|
|
47
|
+
view.previousGraph?.edges !== undefined &&
|
|
48
|
+
view.previousGraph.nodes !== undefined) {
|
|
49
|
+
const filePathByNodeId = buildFilePathLookup(view.previousGraph.nodes);
|
|
50
|
+
const carried = partitionPriorEdges(view.previousGraph.edges, filePathByNodeId, view.closure, new Set(["METHOD_OVERRIDES", "METHOD_IMPLEMENTS"]));
|
|
51
|
+
for (const e of carried) {
|
|
52
|
+
ctx.graph.addEdge({
|
|
53
|
+
from: e.from,
|
|
54
|
+
to: e.to,
|
|
55
|
+
type: e.type,
|
|
56
|
+
confidence: e.confidence,
|
|
57
|
+
...(e.reason !== undefined ? { reason: e.reason } : {}),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// ---- Collect owner nodes + their methods + their heritage. -------------
|
|
62
|
+
//
|
|
63
|
+
// We always collect metadata for EVERY owner in the graph — linearisation
|
|
64
|
+
// walks ancestor chains that may reach owners outside the closure, and
|
|
65
|
+
// those still need their methods + heritage loaded so the walk terminates
|
|
66
|
+
// correctly. The incremental gate applies at edge-emission time.
|
|
67
|
+
const ownerIds = [];
|
|
68
|
+
const ownerFilePath = new Map();
|
|
69
|
+
for (const n of ctx.graph.nodes()) {
|
|
70
|
+
if (OWNER_KINDS.has(n.kind)) {
|
|
71
|
+
ownerIds.push(n.id);
|
|
72
|
+
ownerFilePath.set(n.id, n.filePath);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
ownerIds.sort();
|
|
76
|
+
// Per-owner method map: name → method node id (one entry per name; if a
|
|
77
|
+
// class declares two overloads with the same name the last id wins for the
|
|
78
|
+
// MRO walk, which matches the `HAS_METHOD` edge set emitted at parse time).
|
|
79
|
+
const methodsByOwner = new Map();
|
|
80
|
+
const extendsByOwner = new Map();
|
|
81
|
+
const implementsByOwner = new Map();
|
|
82
|
+
for (const id of ownerIds) {
|
|
83
|
+
methodsByOwner.set(id, new Map());
|
|
84
|
+
extendsByOwner.set(id, []);
|
|
85
|
+
implementsByOwner.set(id, []);
|
|
86
|
+
}
|
|
87
|
+
const nodeKindById = new Map();
|
|
88
|
+
const nodeNameById = new Map();
|
|
89
|
+
for (const n of ctx.graph.nodes()) {
|
|
90
|
+
nodeKindById.set(n.id, n.kind);
|
|
91
|
+
nodeNameById.set(n.id, n.name);
|
|
92
|
+
}
|
|
93
|
+
for (const edge of ctx.graph.edges()) {
|
|
94
|
+
if (edge.type === "HAS_METHOD") {
|
|
95
|
+
const owner = edge.from;
|
|
96
|
+
const methodId = edge.to;
|
|
97
|
+
const name = nodeNameById.get(methodId);
|
|
98
|
+
if (name === undefined)
|
|
99
|
+
continue;
|
|
100
|
+
const map = methodsByOwner.get(owner);
|
|
101
|
+
if (map !== undefined)
|
|
102
|
+
map.set(name, methodId);
|
|
103
|
+
}
|
|
104
|
+
else if (edge.type === "EXTENDS") {
|
|
105
|
+
const list = extendsByOwner.get(edge.from);
|
|
106
|
+
if (list !== undefined)
|
|
107
|
+
list.push(edge.to);
|
|
108
|
+
}
|
|
109
|
+
else if (edge.type === "IMPLEMENTS") {
|
|
110
|
+
const list = implementsByOwner.get(edge.from);
|
|
111
|
+
if (list !== undefined)
|
|
112
|
+
list.push(edge.to);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
for (const list of extendsByOwner.values())
|
|
116
|
+
list.sort();
|
|
117
|
+
for (const list of implementsByOwner.values())
|
|
118
|
+
list.sort();
|
|
119
|
+
// ---- Linearize each owner using its provider's MRO strategy. -----------
|
|
120
|
+
const linearizationCache = new Map();
|
|
121
|
+
function linearizeFor(id) {
|
|
122
|
+
const cached = linearizationCache.get(id);
|
|
123
|
+
if (cached !== undefined)
|
|
124
|
+
return cached;
|
|
125
|
+
// Placeholder to break cycles — the strategies do not recurse into
|
|
126
|
+
// indirect ancestors through this lookup, but belt-and-suspenders.
|
|
127
|
+
linearizationCache.set(id, [id]);
|
|
128
|
+
const filePath = ownerFilePath.get(id) ?? "";
|
|
129
|
+
const lang = inferLanguageFromFile(filePath);
|
|
130
|
+
if (lang === undefined) {
|
|
131
|
+
linearizationCache.set(id, [id]);
|
|
132
|
+
return [id];
|
|
133
|
+
}
|
|
134
|
+
const provider = getProvider(lang);
|
|
135
|
+
const strategy = getMroStrategy(provider.mroStrategy);
|
|
136
|
+
if (provider.mroStrategy === "none") {
|
|
137
|
+
linearizationCache.set(id, [id]);
|
|
138
|
+
return [id];
|
|
139
|
+
}
|
|
140
|
+
const bases = extendsByOwner.get(id) ?? [];
|
|
141
|
+
try {
|
|
142
|
+
const linearization = strategy.linearize(id, bases, (baseId) => linearizeFor(baseId));
|
|
143
|
+
linearizationCache.set(id, linearization);
|
|
144
|
+
return linearization;
|
|
145
|
+
}
|
|
146
|
+
catch (err) {
|
|
147
|
+
if (err instanceof MroConflictError) {
|
|
148
|
+
ctx.onProgress?.({
|
|
149
|
+
phase: MRO_PHASE_NAME,
|
|
150
|
+
kind: "warn",
|
|
151
|
+
message: `mro: conflict linearising ${id}: ${err.message}`,
|
|
152
|
+
});
|
|
153
|
+
linearizationCache.set(id, [id]);
|
|
154
|
+
conflictCount += 1;
|
|
155
|
+
return [id];
|
|
156
|
+
}
|
|
157
|
+
throw err;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
let conflictCount = 0;
|
|
161
|
+
let overridesCount = 0;
|
|
162
|
+
let implementsCount = 0;
|
|
163
|
+
for (const id of ownerIds) {
|
|
164
|
+
const ownerPath = ownerFilePath.get(id) ?? "";
|
|
165
|
+
const lang = inferLanguageFromFile(ownerPath);
|
|
166
|
+
if (lang === undefined)
|
|
167
|
+
continue;
|
|
168
|
+
const provider = getProvider(lang);
|
|
169
|
+
if (provider.mroStrategy === "none")
|
|
170
|
+
continue;
|
|
171
|
+
const ownerMethods = methodsByOwner.get(id) ?? new Map();
|
|
172
|
+
if (ownerMethods.size === 0)
|
|
173
|
+
continue;
|
|
174
|
+
// Incremental gate: owners outside the closure keep their prior-graph
|
|
175
|
+
// MRO edges (carried forward above). Correctness for the in-closure
|
|
176
|
+
// case holds because incremental-scope already widened the closure by
|
|
177
|
+
// one heritage hop.
|
|
178
|
+
if (view.active && !view.closure.has(ownerPath))
|
|
179
|
+
continue;
|
|
180
|
+
// Sort method names for deterministic iteration.
|
|
181
|
+
const sortedNames = [...ownerMethods.keys()].sort();
|
|
182
|
+
// `METHOD_OVERRIDES`: walk the class's linearization; the first ancestor
|
|
183
|
+
// with a matching method wins. Skip the class itself (index 0).
|
|
184
|
+
const linearization = linearizeFor(id);
|
|
185
|
+
for (const name of sortedNames) {
|
|
186
|
+
const childMethodId = ownerMethods.get(name);
|
|
187
|
+
if (childMethodId === undefined)
|
|
188
|
+
continue;
|
|
189
|
+
for (let i = 1; i < linearization.length; i += 1) {
|
|
190
|
+
const ancestor = linearization[i];
|
|
191
|
+
if (ancestor === undefined)
|
|
192
|
+
continue;
|
|
193
|
+
// Skip interface/trait ancestors — they produce METHOD_IMPLEMENTS
|
|
194
|
+
// instead. We detect by kind.
|
|
195
|
+
const ancestorKind = nodeKindById.get(ancestor);
|
|
196
|
+
if (ancestorKind === "Interface" || ancestorKind === "Trait")
|
|
197
|
+
continue;
|
|
198
|
+
const ancestorMethods = methodsByOwner.get(ancestor);
|
|
199
|
+
if (ancestorMethods === undefined)
|
|
200
|
+
continue;
|
|
201
|
+
const parentMethodId = ancestorMethods.get(name);
|
|
202
|
+
if (parentMethodId === undefined)
|
|
203
|
+
continue;
|
|
204
|
+
ctx.graph.addEdge({
|
|
205
|
+
from: childMethodId,
|
|
206
|
+
to: parentMethodId,
|
|
207
|
+
type: "METHOD_OVERRIDES",
|
|
208
|
+
confidence: 0.9,
|
|
209
|
+
reason: "mro-linearization",
|
|
210
|
+
});
|
|
211
|
+
overridesCount += 1;
|
|
212
|
+
break; // first hit wins in the linearization.
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
// `METHOD_IMPLEMENTS`: direct `IMPLEMENTS` edges identify interfaces /
|
|
216
|
+
// traits whose contract the class claims. For each same-name method on
|
|
217
|
+
// those interfaces emit the edge.
|
|
218
|
+
const interfaces = implementsByOwner.get(id) ?? [];
|
|
219
|
+
for (const name of sortedNames) {
|
|
220
|
+
const childMethodId = ownerMethods.get(name);
|
|
221
|
+
if (childMethodId === undefined)
|
|
222
|
+
continue;
|
|
223
|
+
for (const ifaceId of interfaces) {
|
|
224
|
+
const ifaceMethods = methodsByOwner.get(ifaceId);
|
|
225
|
+
if (ifaceMethods === undefined)
|
|
226
|
+
continue;
|
|
227
|
+
const interfaceMethodId = ifaceMethods.get(name);
|
|
228
|
+
if (interfaceMethodId === undefined)
|
|
229
|
+
continue;
|
|
230
|
+
ctx.graph.addEdge({
|
|
231
|
+
from: childMethodId,
|
|
232
|
+
to: interfaceMethodId,
|
|
233
|
+
type: "METHOD_IMPLEMENTS",
|
|
234
|
+
confidence: 0.95,
|
|
235
|
+
reason: "interface-contract",
|
|
236
|
+
});
|
|
237
|
+
implementsCount += 1;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return { overridesCount, implementsCount, conflictCount };
|
|
242
|
+
}
|
|
243
|
+
function inferLanguageFromFile(filePath) {
|
|
244
|
+
const idx = filePath.lastIndexOf(".");
|
|
245
|
+
if (idx < 0)
|
|
246
|
+
return undefined;
|
|
247
|
+
const ext = filePath.slice(idx).toLowerCase();
|
|
248
|
+
switch (ext) {
|
|
249
|
+
case ".ts":
|
|
250
|
+
case ".mts":
|
|
251
|
+
case ".cts":
|
|
252
|
+
return "typescript";
|
|
253
|
+
case ".tsx":
|
|
254
|
+
return "tsx";
|
|
255
|
+
case ".js":
|
|
256
|
+
case ".mjs":
|
|
257
|
+
case ".cjs":
|
|
258
|
+
case ".jsx":
|
|
259
|
+
return "javascript";
|
|
260
|
+
case ".py":
|
|
261
|
+
case ".pyi":
|
|
262
|
+
return "python";
|
|
263
|
+
case ".go":
|
|
264
|
+
return "go";
|
|
265
|
+
case ".rs":
|
|
266
|
+
return "rust";
|
|
267
|
+
case ".java":
|
|
268
|
+
return "java";
|
|
269
|
+
case ".cs":
|
|
270
|
+
return "csharp";
|
|
271
|
+
case ".c":
|
|
272
|
+
case ".h":
|
|
273
|
+
// .h is ambiguous between C/C++; default to C. A dedicated C++ header
|
|
274
|
+
// detector can upgrade the classification later.
|
|
275
|
+
return "c";
|
|
276
|
+
case ".cpp":
|
|
277
|
+
case ".cc":
|
|
278
|
+
case ".cxx":
|
|
279
|
+
case ".hpp":
|
|
280
|
+
case ".hh":
|
|
281
|
+
case ".hxx":
|
|
282
|
+
return "cpp";
|
|
283
|
+
case ".rb":
|
|
284
|
+
return "ruby";
|
|
285
|
+
case ".kt":
|
|
286
|
+
case ".kts":
|
|
287
|
+
return "kotlin";
|
|
288
|
+
case ".swift":
|
|
289
|
+
return "swift";
|
|
290
|
+
case ".php":
|
|
291
|
+
case ".php3":
|
|
292
|
+
case ".php4":
|
|
293
|
+
case ".php5":
|
|
294
|
+
case ".php7":
|
|
295
|
+
case ".phtml":
|
|
296
|
+
return "php";
|
|
297
|
+
case ".dart":
|
|
298
|
+
return "dart";
|
|
299
|
+
default:
|
|
300
|
+
return undefined;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
//# sourceMappingURL=mro.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mro.js","sourceRoot":"","sources":["../../../src/pipeline/phases/mro.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAGnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC;AAQpC;;GAEG;AACH,MAAM,WAAW,GAAwB,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;AAE5F,MAAM,CAAC,MAAM,QAAQ,GAA6B;IAChD,I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Z,KAAK,KAAK,CAAC;QACX,KAAK,MAAM,CAAC;QACZ,KAAK,MAAM;YACT,OAAO,YAAY,CAAC;QACtB,KAAK,MAAM;YACT,OAAO,KAAK,CAAC;QACf,KAAK,KAAK,CAAC;QACX,KAAK,MAAM,CAAC;QACZ,KAAK,MAAM,CAAC;QACZ,KAAK,MAAM;YACT,OAAO,YAAY,CAAC;QACtB,KAAK,KAAK,CAAC;QACX,KAAK,MAAM;YACT,OAAO,QAAQ,CAAC;QAClB,KAAK,KAAK;YACR,OAAO,IAAI,CAAC;QACd,KAAK,KAAK;YACR,OAAO,MAAM,CAAC;QAChB,KAAK,OAAO;YACV,OAAO,MAAM,CAAC;QAChB,KAAK,KAAK;YACR,OAAO,QAAQ,CAAC;QAClB,KAAK,IAAI,CAAC;QACV,KAAK,IAAI;YACP,sEAAsE;YACtE,iDAAiD;YACjD,OAAO,GAAG,CAAC;QACb,KAAK,MAAM,CAAC;QACZ,KAAK,KAAK,CAAC;QACX,KAAK,MAAM,CAAC;QACZ,KAAK,MAAM,CAAC;QACZ,KAAK,KAAK,CAAC;QACX,KAAK,MAAM;YACT,OAAO,KAAK,CAAC;QACf,KAAK,KAAK;YACR,OAAO,MAAM,CAAC;QAChB,KAAK,KAAK,CAAC;QACX,KAAK,MAAM;YACT,OAAO,QAAQ,CAAC;QAClB,KAAK,QAAQ;YACX,OAAO,OAAO,CAAC;QACjB,KAAK,MAAM,CAAC;QACZ,KAAK,OAAO,CAAC;QACb,KAAK,OAAO,CAAC;QACb,KAAK,OAAO,CAAC;QACb,KAAK,OAAO,CAAC;QACb,KAAK,QAAQ;YACX,OAAO,KAAK,CAAC;QACf,KAAK,OAAO;YACV,OAAO,MAAM,CAAC;QAChB;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAPI phase — materialises HTTP operations described by OpenAPI /
|
|
3
|
+
* Swagger specs as `Operation` nodes and links them to existing `Route`
|
|
4
|
+
* nodes whose method + templated path match.
|
|
5
|
+
*
|
|
6
|
+
* Pipeline placement:
|
|
7
|
+
* - deps: [routes, profile]
|
|
8
|
+
* - If the ProjectProfile's `apiContracts` list does NOT include
|
|
9
|
+
* "openapi", the phase is a no-op (skips all spec discovery).
|
|
10
|
+
*
|
|
11
|
+
* What the phase does:
|
|
12
|
+
* 1. Walks scan output for every file whose basename matches
|
|
13
|
+
* `openapi.{yaml,json}` / `swagger.{yaml,json}`, sorted by relPath.
|
|
14
|
+
* 2. For each spec, invokes `SwaggerParser.dereference(absPath, { resolve: { external: false } })`
|
|
15
|
+
* which resolves internal `$ref`s inline while refusing any HTTP or
|
|
16
|
+
* external file lookups (hard offline posture).
|
|
17
|
+
* 3. For each (method, path) pair, emits one `Operation` node with id
|
|
18
|
+
* `Operation:<specRelPath>:<METHOD>:<path>` plus optional `summary`
|
|
19
|
+
* and `operationId` properties.
|
|
20
|
+
* 4. Looks up an existing `Route` node whose method + normalised path
|
|
21
|
+
* matches the operation. Matches exact strings first, then falls
|
|
22
|
+
* back to path-parameter normalisation:
|
|
23
|
+
* OpenAPI `{id}` → `:id`
|
|
24
|
+
* Next.js `[id]` → `:id`
|
|
25
|
+
* Express `:id` unchanged
|
|
26
|
+
* Both sides are normalised before comparison so any combination of
|
|
27
|
+
* the three notations produces a single canonical key.
|
|
28
|
+
* 5. On a match, emits a `HANDLES_ROUTE` edge Operation → Route with
|
|
29
|
+
* confidence 0.95 and reason `openapi-spec`. The direction encodes
|
|
30
|
+
* "this spec describes this route handler".
|
|
31
|
+
*
|
|
32
|
+
* Determinism:
|
|
33
|
+
* - Spec files are processed in scan-sorted order (same order scan emits).
|
|
34
|
+
* - Operations are materialised in `(METHOD, path)` lex order so edge
|
|
35
|
+
* insertion and graphHash byte-stability hold across runs.
|
|
36
|
+
*
|
|
37
|
+
* Error handling:
|
|
38
|
+
* - Any swagger-parser throw (malformed spec, unresolved $ref, circular
|
|
39
|
+
* references without handling) is caught and surfaced as a `warn`
|
|
40
|
+
* progress event. The offending spec is skipped; the phase continues.
|
|
41
|
+
* - No network calls: `resolve.external = false` disables the HTTP and
|
|
42
|
+
* file-based external resolvers.
|
|
43
|
+
*/
|
|
44
|
+
import type { PipelinePhase } from "../types.js";
|
|
45
|
+
export declare const OPENAPI_PHASE_NAME: "openapi";
|
|
46
|
+
export interface OpenApiOutput {
|
|
47
|
+
readonly operationsEmitted: number;
|
|
48
|
+
readonly routesLinked: number;
|
|
49
|
+
readonly specsProcessed: number;
|
|
50
|
+
}
|
|
51
|
+
export declare const openapiPhase: PipelinePhase<OpenApiOutput>;
|
|
52
|
+
//# sourceMappingURL=openapi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../../../src/pipeline/phases/openapi.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAUH,OAAO,KAAK,EAAmB,aAAa,EAAE,MAAM,aAAa,CAAC;AAKlE,eAAO,MAAM,kBAAkB,EAAG,SAAkB,CAAC;AAErD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAsCD,eAAO,MAAM,YAAY,EAAE,aAAa,CAAC,aAAa,CAUrD,CAAC"}
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAPI phase — materialises HTTP operations described by OpenAPI /
|
|
3
|
+
* Swagger specs as `Operation` nodes and links them to existing `Route`
|
|
4
|
+
* nodes whose method + templated path match.
|
|
5
|
+
*
|
|
6
|
+
* Pipeline placement:
|
|
7
|
+
* - deps: [routes, profile]
|
|
8
|
+
* - If the ProjectProfile's `apiContracts` list does NOT include
|
|
9
|
+
* "openapi", the phase is a no-op (skips all spec discovery).
|
|
10
|
+
*
|
|
11
|
+
* What the phase does:
|
|
12
|
+
* 1. Walks scan output for every file whose basename matches
|
|
13
|
+
* `openapi.{yaml,json}` / `swagger.{yaml,json}`, sorted by relPath.
|
|
14
|
+
* 2. For each spec, invokes `SwaggerParser.dereference(absPath, { resolve: { external: false } })`
|
|
15
|
+
* which resolves internal `$ref`s inline while refusing any HTTP or
|
|
16
|
+
* external file lookups (hard offline posture).
|
|
17
|
+
* 3. For each (method, path) pair, emits one `Operation` node with id
|
|
18
|
+
* `Operation:<specRelPath>:<METHOD>:<path>` plus optional `summary`
|
|
19
|
+
* and `operationId` properties.
|
|
20
|
+
* 4. Looks up an existing `Route` node whose method + normalised path
|
|
21
|
+
* matches the operation. Matches exact strings first, then falls
|
|
22
|
+
* back to path-parameter normalisation:
|
|
23
|
+
* OpenAPI `{id}` → `:id`
|
|
24
|
+
* Next.js `[id]` → `:id`
|
|
25
|
+
* Express `:id` unchanged
|
|
26
|
+
* Both sides are normalised before comparison so any combination of
|
|
27
|
+
* the three notations produces a single canonical key.
|
|
28
|
+
* 5. On a match, emits a `HANDLES_ROUTE` edge Operation → Route with
|
|
29
|
+
* confidence 0.95 and reason `openapi-spec`. The direction encodes
|
|
30
|
+
* "this spec describes this route handler".
|
|
31
|
+
*
|
|
32
|
+
* Determinism:
|
|
33
|
+
* - Spec files are processed in scan-sorted order (same order scan emits).
|
|
34
|
+
* - Operations are materialised in `(METHOD, path)` lex order so edge
|
|
35
|
+
* insertion and graphHash byte-stability hold across runs.
|
|
36
|
+
*
|
|
37
|
+
* Error handling:
|
|
38
|
+
* - Any swagger-parser throw (malformed spec, unresolved $ref, circular
|
|
39
|
+
* references without handling) is caught and surfaced as a `warn`
|
|
40
|
+
* progress event. The offending spec is skipped; the phase continues.
|
|
41
|
+
* - No network calls: `resolve.external = false` disables the HTTP and
|
|
42
|
+
* file-based external resolvers.
|
|
43
|
+
*/
|
|
44
|
+
import { makeNodeId } from "@opencodehub/core-types";
|
|
45
|
+
import { PROFILE_PHASE_NAME } from "./profile.js";
|
|
46
|
+
import { ROUTES_PHASE_NAME } from "./routes.js";
|
|
47
|
+
import { SCAN_PHASE_NAME } from "./scan.js";
|
|
48
|
+
export const OPENAPI_PHASE_NAME = "openapi";
|
|
49
|
+
/**
|
|
50
|
+
* HTTP verbs recognised by the OpenAPI spec, upper-cased for the Operation
|
|
51
|
+
* node `method` property. `trace` is in OpenAPI 3.x even though few runtime
|
|
52
|
+
* servers implement it — we surface it anyway so our operations mirror the
|
|
53
|
+
* authored spec.
|
|
54
|
+
*/
|
|
55
|
+
const HTTP_METHODS = ["get", "post", "put", "patch", "delete", "head", "options", "trace"];
|
|
56
|
+
/** Basenames that flag a file as an OpenAPI / Swagger spec unambiguously. */
|
|
57
|
+
const SPEC_BASENAME_RE = /^(openapi|swagger)\.(ya?ml|json)$/i;
|
|
58
|
+
export const openapiPhase = {
|
|
59
|
+
name: OPENAPI_PHASE_NAME,
|
|
60
|
+
deps: [ROUTES_PHASE_NAME, PROFILE_PHASE_NAME],
|
|
61
|
+
async run(ctx) {
|
|
62
|
+
const scan = ctx.phaseOutputs.get(SCAN_PHASE_NAME);
|
|
63
|
+
if (scan === undefined) {
|
|
64
|
+
throw new Error("openapi: scan output missing from phase outputs");
|
|
65
|
+
}
|
|
66
|
+
return runOpenApi(ctx, scan);
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
async function runOpenApi(ctx, scan) {
|
|
70
|
+
// Skip unless profile phase detected openapi.
|
|
71
|
+
const profile = findProjectProfile(ctx.graph);
|
|
72
|
+
if (!profile?.apiContracts.includes("openapi")) {
|
|
73
|
+
return { operationsEmitted: 0, routesLinked: 0, specsProcessed: 0 };
|
|
74
|
+
}
|
|
75
|
+
const specs = selectSpecFiles(scan.files);
|
|
76
|
+
if (specs.length === 0) {
|
|
77
|
+
return { operationsEmitted: 0, routesLinked: 0, specsProcessed: 0 };
|
|
78
|
+
}
|
|
79
|
+
// Build a method + normalised-path → Route node id lookup once, so per-
|
|
80
|
+
// operation matches stay O(1).
|
|
81
|
+
const routeIndex = indexRoutesByMethodAndPath(ctx.graph);
|
|
82
|
+
let operationsEmitted = 0;
|
|
83
|
+
let routesLinked = 0;
|
|
84
|
+
let specsProcessed = 0;
|
|
85
|
+
for (const spec of specs) {
|
|
86
|
+
const parsedOps = await dereferenceSpec(ctx, spec);
|
|
87
|
+
if (parsedOps === null) {
|
|
88
|
+
// Already warned in dereferenceSpec; skip spec, keep pipeline alive.
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
specsProcessed += 1;
|
|
92
|
+
// Sort operations deterministically before insertion.
|
|
93
|
+
const sorted = [...parsedOps].sort(compareParsedOperation);
|
|
94
|
+
for (const op of sorted) {
|
|
95
|
+
const opId = operationNodeId(spec.relPath, op.method, op.path);
|
|
96
|
+
const node = {
|
|
97
|
+
id: opId,
|
|
98
|
+
kind: "Operation",
|
|
99
|
+
name: `${op.method} ${op.path}`,
|
|
100
|
+
filePath: spec.relPath,
|
|
101
|
+
method: op.method,
|
|
102
|
+
path: op.path,
|
|
103
|
+
...(op.summary !== undefined ? { summary: op.summary } : {}),
|
|
104
|
+
...(op.operationId !== undefined ? { operationId: op.operationId } : {}),
|
|
105
|
+
};
|
|
106
|
+
ctx.graph.addNode(node);
|
|
107
|
+
operationsEmitted += 1;
|
|
108
|
+
const routeKey = routeLookupKey(op.method, op.path);
|
|
109
|
+
const routeId = routeIndex.get(routeKey);
|
|
110
|
+
if (routeId !== undefined) {
|
|
111
|
+
ctx.graph.addEdge({
|
|
112
|
+
from: opId,
|
|
113
|
+
to: routeId,
|
|
114
|
+
type: "HANDLES_ROUTE",
|
|
115
|
+
confidence: 0.95,
|
|
116
|
+
reason: "openapi-spec",
|
|
117
|
+
});
|
|
118
|
+
routesLinked += 1;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return { operationsEmitted, routesLinked, specsProcessed };
|
|
123
|
+
}
|
|
124
|
+
/** Look up the singleton ProjectProfile node in the graph, if any. */
|
|
125
|
+
function findProjectProfile(graph) {
|
|
126
|
+
for (const n of graph.nodes()) {
|
|
127
|
+
if (n.kind === "ProjectProfile")
|
|
128
|
+
return n;
|
|
129
|
+
}
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
function selectSpecFiles(files) {
|
|
133
|
+
const out = [];
|
|
134
|
+
for (const f of files) {
|
|
135
|
+
const basename = basenameOf(f.relPath);
|
|
136
|
+
if (SPEC_BASENAME_RE.test(basename))
|
|
137
|
+
out.push(f);
|
|
138
|
+
}
|
|
139
|
+
// scan output is already sorted by relPath, but sort defensively so
|
|
140
|
+
// tests that construct ScannedFile[] directly still get a stable order.
|
|
141
|
+
return out.slice().sort((a, b) => (a.relPath < b.relPath ? -1 : a.relPath > b.relPath ? 1 : 0));
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Invoke swagger-parser's `dereference` with external resolution disabled
|
|
145
|
+
* and walk the resulting paths object. Returns `null` on any parser throw
|
|
146
|
+
* (after emitting a warn event); otherwise returns the list of operations
|
|
147
|
+
* found on the spec.
|
|
148
|
+
*/
|
|
149
|
+
async function dereferenceSpec(ctx, spec) {
|
|
150
|
+
let SwaggerParser;
|
|
151
|
+
try {
|
|
152
|
+
const mod = (await import("@apidevtools/swagger-parser"));
|
|
153
|
+
SwaggerParser = mod.default;
|
|
154
|
+
}
|
|
155
|
+
catch (err) {
|
|
156
|
+
ctx.onProgress?.({
|
|
157
|
+
phase: OPENAPI_PHASE_NAME,
|
|
158
|
+
kind: "warn",
|
|
159
|
+
message: `openapi: @apidevtools/swagger-parser not available: ${errMessage(err)}`,
|
|
160
|
+
});
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
let api;
|
|
164
|
+
try {
|
|
165
|
+
api = await SwaggerParser.dereference(spec.absPath, {
|
|
166
|
+
resolve: { external: false },
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
catch (err) {
|
|
170
|
+
ctx.onProgress?.({
|
|
171
|
+
phase: OPENAPI_PHASE_NAME,
|
|
172
|
+
kind: "warn",
|
|
173
|
+
message: `openapi: failed to parse ${spec.relPath}: ${errMessage(err)}`,
|
|
174
|
+
});
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
const paths = extractPaths(api);
|
|
178
|
+
if (paths === undefined) {
|
|
179
|
+
ctx.onProgress?.({
|
|
180
|
+
phase: OPENAPI_PHASE_NAME,
|
|
181
|
+
kind: "warn",
|
|
182
|
+
message: `openapi: ${spec.relPath} has no paths object`,
|
|
183
|
+
});
|
|
184
|
+
return [];
|
|
185
|
+
}
|
|
186
|
+
const ops = [];
|
|
187
|
+
for (const [pathTemplate, pathItemRaw] of Object.entries(paths)) {
|
|
188
|
+
if (!isRecord(pathItemRaw))
|
|
189
|
+
continue;
|
|
190
|
+
const pathItem = pathItemRaw;
|
|
191
|
+
for (const method of HTTP_METHODS) {
|
|
192
|
+
const opRaw = pathItem[method];
|
|
193
|
+
if (!isRecord(opRaw))
|
|
194
|
+
continue;
|
|
195
|
+
const opRecord = opRaw;
|
|
196
|
+
const summary = stringOrUndefined(opRecord["summary"]);
|
|
197
|
+
const operationId = stringOrUndefined(opRecord["operationId"]);
|
|
198
|
+
ops.push({
|
|
199
|
+
method: method.toUpperCase(),
|
|
200
|
+
path: pathTemplate,
|
|
201
|
+
...(summary !== undefined ? { summary } : {}),
|
|
202
|
+
...(operationId !== undefined ? { operationId } : {}),
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return ops;
|
|
207
|
+
}
|
|
208
|
+
function extractPaths(api) {
|
|
209
|
+
if (!isRecord(api))
|
|
210
|
+
return undefined;
|
|
211
|
+
const paths = api["paths"];
|
|
212
|
+
if (!isRecord(paths))
|
|
213
|
+
return undefined;
|
|
214
|
+
return paths;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Walk the graph and build a method+normalisedPath → NodeId index of
|
|
218
|
+
* existing Route nodes. We snapshot the node set at call time; later
|
|
219
|
+
* Operation emissions don't invalidate the map because Route nodes are
|
|
220
|
+
* populated by the routes phase which strictly precedes this one.
|
|
221
|
+
*/
|
|
222
|
+
function indexRoutesByMethodAndPath(graph) {
|
|
223
|
+
const index = new Map();
|
|
224
|
+
for (const n of graph.nodes()) {
|
|
225
|
+
if (n.kind !== "Route")
|
|
226
|
+
continue;
|
|
227
|
+
const route = n;
|
|
228
|
+
// Routes without a method are rare (catch-all `app.use`) — they can't
|
|
229
|
+
// match a method-specific OpenAPI operation.
|
|
230
|
+
const method = route.method;
|
|
231
|
+
if (method === undefined)
|
|
232
|
+
continue;
|
|
233
|
+
const key = routeLookupKey(method.toUpperCase(), route.url);
|
|
234
|
+
// First-write wins; routes are emitted in a deterministic order so the
|
|
235
|
+
// winner is stable across runs.
|
|
236
|
+
if (!index.has(key)) {
|
|
237
|
+
index.set(key, route.id);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return index;
|
|
241
|
+
}
|
|
242
|
+
function routeLookupKey(method, path) {
|
|
243
|
+
return `${method.toUpperCase()}\u0000${normalisePath(path)}`;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Normalise route path templates so OpenAPI `/users/{id}`, Express
|
|
247
|
+
* `/users/:id`, and Next.js `/users/[id]` all collapse onto the same
|
|
248
|
+
* canonical form (`/users/:id`). The transformation is purely syntactic:
|
|
249
|
+
* we rewrite brace- and bracket-style parameters in place and otherwise
|
|
250
|
+
* leave the path untouched.
|
|
251
|
+
*/
|
|
252
|
+
function normalisePath(path) {
|
|
253
|
+
if (path.length === 0)
|
|
254
|
+
return path;
|
|
255
|
+
let out = path;
|
|
256
|
+
// `{param}` → `:param`
|
|
257
|
+
out = out.replace(/\{([^}]+)\}/g, ":$1");
|
|
258
|
+
// `[param]` → `:param`
|
|
259
|
+
out = out.replace(/\[([^\]]+)\]/g, ":$1");
|
|
260
|
+
return out;
|
|
261
|
+
}
|
|
262
|
+
function operationNodeId(specPath, method, pathTemplate) {
|
|
263
|
+
return makeNodeId("Operation", specPath, `${method}:${pathTemplate}`);
|
|
264
|
+
}
|
|
265
|
+
function compareParsedOperation(a, b) {
|
|
266
|
+
if (a.method !== b.method)
|
|
267
|
+
return a.method < b.method ? -1 : 1;
|
|
268
|
+
if (a.path !== b.path)
|
|
269
|
+
return a.path < b.path ? -1 : 1;
|
|
270
|
+
return 0;
|
|
271
|
+
}
|
|
272
|
+
function basenameOf(relPath) {
|
|
273
|
+
const idx = relPath.lastIndexOf("/");
|
|
274
|
+
return idx < 0 ? relPath : relPath.slice(idx + 1);
|
|
275
|
+
}
|
|
276
|
+
function isRecord(v) {
|
|
277
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
278
|
+
}
|
|
279
|
+
function stringOrUndefined(v) {
|
|
280
|
+
return typeof v === "string" && v.length > 0 ? v : undefined;
|
|
281
|
+
}
|
|
282
|
+
function errMessage(err) {
|
|
283
|
+
return err instanceof Error ? err.message : String(err);
|
|
284
|
+
}
|
|
285
|
+
//# sourceMappingURL=openapi.js.map
|