@opensip-cli/graph-typescript 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/NOTICE +8 -0
- package/README.md +31 -0
- package/dist/__tests__/_pipeline.d.ts +40 -0
- package/dist/__tests__/_pipeline.d.ts.map +1 -0
- package/dist/__tests__/_pipeline.js +67 -0
- package/dist/__tests__/_pipeline.js.map +1 -0
- package/dist/__tests__/acceptance/_fixture-runner.d.ts +13 -0
- package/dist/__tests__/acceptance/_fixture-runner.d.ts.map +1 -0
- package/dist/__tests__/acceptance/_fixture-runner.js +55 -0
- package/dist/__tests__/acceptance/_fixture-runner.js.map +1 -0
- package/dist/__tests__/acceptance/alias-resolution.test.d.ts +8 -0
- package/dist/__tests__/acceptance/alias-resolution.test.d.ts.map +1 -0
- package/dist/__tests__/acceptance/alias-resolution.test.js +39 -0
- package/dist/__tests__/acceptance/alias-resolution.test.js.map +1 -0
- package/dist/__tests__/acceptance/arrow-callback-resolution.test.d.ts +8 -0
- package/dist/__tests__/acceptance/arrow-callback-resolution.test.d.ts.map +1 -0
- package/dist/__tests__/acceptance/arrow-callback-resolution.test.js +33 -0
- package/dist/__tests__/acceptance/arrow-callback-resolution.test.js.map +1 -0
- package/dist/__tests__/acceptance/constructor-calls.test.d.ts +7 -0
- package/dist/__tests__/acceptance/constructor-calls.test.d.ts.map +1 -0
- package/dist/__tests__/acceptance/constructor-calls.test.js +36 -0
- package/dist/__tests__/acceptance/constructor-calls.test.js.map +1 -0
- package/dist/__tests__/acceptance/interface-dispatch.test.d.ts +8 -0
- package/dist/__tests__/acceptance/interface-dispatch.test.d.ts.map +1 -0
- package/dist/__tests__/acceptance/interface-dispatch.test.js +44 -0
- package/dist/__tests__/acceptance/interface-dispatch.test.js.map +1 -0
- package/dist/__tests__/acceptance/inventory-completeness.test.d.ts +9 -0
- package/dist/__tests__/acceptance/inventory-completeness.test.d.ts.map +1 -0
- package/dist/__tests__/acceptance/inventory-completeness.test.js +72 -0
- package/dist/__tests__/acceptance/inventory-completeness.test.js.map +1 -0
- package/dist/__tests__/acceptance/jsx-resolution.test.d.ts +7 -0
- package/dist/__tests__/acceptance/jsx-resolution.test.d.ts.map +1 -0
- package/dist/__tests__/acceptance/jsx-resolution.test.js +46 -0
- package/dist/__tests__/acceptance/jsx-resolution.test.js.map +1 -0
- package/dist/__tests__/acceptance/module-init.test.d.ts +10 -0
- package/dist/__tests__/acceptance/module-init.test.d.ts.map +1 -0
- package/dist/__tests__/acceptance/module-init.test.js +40 -0
- package/dist/__tests__/acceptance/module-init.test.js.map +1 -0
- package/dist/__tests__/acceptance/projectdir-normalization.test.d.ts +7 -0
- package/dist/__tests__/acceptance/projectdir-normalization.test.d.ts.map +1 -0
- package/dist/__tests__/acceptance/projectdir-normalization.test.js +51 -0
- package/dist/__tests__/acceptance/projectdir-normalization.test.js.map +1 -0
- package/dist/__tests__/body-twin-edges.test.d.ts +12 -0
- package/dist/__tests__/body-twin-edges.test.d.ts.map +1 -0
- package/dist/__tests__/body-twin-edges.test.js +85 -0
- package/dist/__tests__/body-twin-edges.test.js.map +1 -0
- package/dist/__tests__/cache-key.test.d.ts +8 -0
- package/dist/__tests__/cache-key.test.d.ts.map +1 -0
- package/dist/__tests__/cache-key.test.js +86 -0
- package/dist/__tests__/cache-key.test.js.map +1 -0
- package/dist/__tests__/depends-on-emission.test.d.ts +19 -0
- package/dist/__tests__/depends-on-emission.test.d.ts.map +1 -0
- package/dist/__tests__/depends-on-emission.test.js +165 -0
- package/dist/__tests__/depends-on-emission.test.js.map +1 -0
- package/dist/__tests__/discover.test.d.ts +9 -0
- package/dist/__tests__/discover.test.d.ts.map +1 -0
- package/dist/__tests__/discover.test.js +72 -0
- package/dist/__tests__/discover.test.js.map +1 -0
- package/dist/__tests__/edge-helpers/method-target.test.d.ts +8 -0
- package/dist/__tests__/edge-helpers/method-target.test.d.ts.map +1 -0
- package/dist/__tests__/edge-helpers/method-target.test.js +96 -0
- package/dist/__tests__/edge-helpers/method-target.test.js.map +1 -0
- package/dist/__tests__/edge-helpers/resolve-decl.test.d.ts +13 -0
- package/dist/__tests__/edge-helpers/resolve-decl.test.d.ts.map +1 -0
- package/dist/__tests__/edge-helpers/resolve-decl.test.js +176 -0
- package/dist/__tests__/edge-helpers/resolve-decl.test.js.map +1 -0
- package/dist/__tests__/edge-resolvers/branches.test.d.ts +11 -0
- package/dist/__tests__/edge-resolvers/branches.test.d.ts.map +1 -0
- package/dist/__tests__/edge-resolvers/branches.test.js +305 -0
- package/dist/__tests__/edge-resolvers/branches.test.js.map +1 -0
- package/dist/__tests__/edge-resolvers/contract.test.d.ts +8 -0
- package/dist/__tests__/edge-resolvers/contract.test.d.ts.map +1 -0
- package/dist/__tests__/edge-resolvers/contract.test.js +30 -0
- package/dist/__tests__/edge-resolvers/contract.test.js.map +1 -0
- package/dist/__tests__/edge-resolvers/resolver-units.test.d.ts +17 -0
- package/dist/__tests__/edge-resolvers/resolver-units.test.d.ts.map +1 -0
- package/dist/__tests__/edge-resolvers/resolver-units.test.js +286 -0
- package/dist/__tests__/edge-resolvers/resolver-units.test.js.map +1 -0
- package/dist/__tests__/fast-vs-exact.test.d.ts +16 -0
- package/dist/__tests__/fast-vs-exact.test.d.ts.map +1 -0
- package/dist/__tests__/fast-vs-exact.test.js +116 -0
- package/dist/__tests__/fast-vs-exact.test.js.map +1 -0
- package/dist/__tests__/graph-cli.test.d.ts +9 -0
- package/dist/__tests__/graph-cli.test.d.ts.map +1 -0
- package/dist/__tests__/graph-cli.test.js +417 -0
- package/dist/__tests__/graph-cli.test.js.map +1 -0
- package/dist/__tests__/heap-preflight.test.d.ts +10 -0
- package/dist/__tests__/heap-preflight.test.d.ts.map +1 -0
- package/dist/__tests__/heap-preflight.test.js +166 -0
- package/dist/__tests__/heap-preflight.test.js.map +1 -0
- package/dist/__tests__/inventory-differential.test.d.ts +15 -0
- package/dist/__tests__/inventory-differential.test.d.ts.map +1 -0
- package/dist/__tests__/inventory-differential.test.js +319 -0
- package/dist/__tests__/inventory-differential.test.js.map +1 -0
- package/dist/__tests__/inventory-helpers/hash-body.test.d.ts +11 -0
- package/dist/__tests__/inventory-helpers/hash-body.test.d.ts.map +1 -0
- package/dist/__tests__/inventory-helpers/hash-body.test.js +34 -0
- package/dist/__tests__/inventory-helpers/hash-body.test.js.map +1 -0
- package/dist/__tests__/inventory-helpers/synthesize-name.test.d.ts +9 -0
- package/dist/__tests__/inventory-helpers/synthesize-name.test.d.ts.map +1 -0
- package/dist/__tests__/inventory-helpers/synthesize-name.test.js +30 -0
- package/dist/__tests__/inventory-helpers/synthesize-name.test.js.map +1 -0
- package/dist/__tests__/inventory-property-tests.test.d.ts +24 -0
- package/dist/__tests__/inventory-property-tests.test.d.ts.map +1 -0
- package/dist/__tests__/inventory-property-tests.test.js +521 -0
- package/dist/__tests__/inventory-property-tests.test.js.map +1 -0
- package/dist/__tests__/inventory-shape-coverage.test.d.ts +16 -0
- package/dist/__tests__/inventory-shape-coverage.test.d.ts.map +1 -0
- package/dist/__tests__/inventory-shape-coverage.test.js +586 -0
- package/dist/__tests__/inventory-shape-coverage.test.js.map +1 -0
- package/dist/__tests__/inventory-visitors/contract.test.d.ts +9 -0
- package/dist/__tests__/inventory-visitors/contract.test.d.ts.map +1 -0
- package/dist/__tests__/inventory-visitors/contract.test.js +33 -0
- package/dist/__tests__/inventory-visitors/contract.test.js.map +1 -0
- package/dist/__tests__/lang-adapter-contract.test.d.ts +19 -0
- package/dist/__tests__/lang-adapter-contract.test.d.ts.map +1 -0
- package/dist/__tests__/lang-adapter-contract.test.js +880 -0
- package/dist/__tests__/lang-adapter-contract.test.js.map +1 -0
- package/dist/__tests__/lang-adapter-registry.test.d.ts +10 -0
- package/dist/__tests__/lang-adapter-registry.test.d.ts.map +1 -0
- package/dist/__tests__/lang-adapter-registry.test.js +151 -0
- package/dist/__tests__/lang-adapter-registry.test.js.map +1 -0
- package/dist/__tests__/normalize-project-dir.test.d.ts +5 -0
- package/dist/__tests__/normalize-project-dir.test.d.ts.map +1 -0
- package/dist/__tests__/normalize-project-dir.test.js +47 -0
- package/dist/__tests__/normalize-project-dir.test.js.map +1 -0
- package/dist/__tests__/orchestrate.test.d.ts +8 -0
- package/dist/__tests__/orchestrate.test.d.ts.map +1 -0
- package/dist/__tests__/orchestrate.test.js +213 -0
- package/dist/__tests__/orchestrate.test.js.map +1 -0
- package/dist/__tests__/parse-fast.test.d.ts +9 -0
- package/dist/__tests__/parse-fast.test.d.ts.map +1 -0
- package/dist/__tests__/parse-fast.test.js +114 -0
- package/dist/__tests__/parse-fast.test.js.map +1 -0
- package/dist/__tests__/rules/_helpers.d.ts +18 -0
- package/dist/__tests__/rules/_helpers.d.ts.map +1 -0
- package/dist/__tests__/rules/_helpers.js +62 -0
- package/dist/__tests__/rules/_helpers.js.map +1 -0
- package/dist/__tests__/rules/duplicated-function-body.test.d.ts +5 -0
- package/dist/__tests__/rules/duplicated-function-body.test.d.ts.map +1 -0
- package/dist/__tests__/rules/duplicated-function-body.test.js +39 -0
- package/dist/__tests__/rules/duplicated-function-body.test.js.map +1 -0
- package/dist/__tests__/rules/orphan-subtree.test.d.ts +5 -0
- package/dist/__tests__/rules/orphan-subtree.test.d.ts.map +1 -0
- package/dist/__tests__/rules/orphan-subtree.test.js +75 -0
- package/dist/__tests__/rules/orphan-subtree.test.js.map +1 -0
- package/dist/__tests__/rules/rule-hints-integration.test.d.ts +20 -0
- package/dist/__tests__/rules/rule-hints-integration.test.d.ts.map +1 -0
- package/dist/__tests__/rules/rule-hints-integration.test.js +279 -0
- package/dist/__tests__/rules/rule-hints-integration.test.js.map +1 -0
- package/dist/__tests__/tool-register.test.d.ts +16 -0
- package/dist/__tests__/tool-register.test.d.ts.map +1 -0
- package/dist/__tests__/tool-register.test.js +210 -0
- package/dist/__tests__/tool-register.test.js.map +1 -0
- package/dist/__tests__/value-reference-unit.test.d.ts +13 -0
- package/dist/__tests__/value-reference-unit.test.d.ts.map +1 -0
- package/dist/__tests__/value-reference-unit.test.js +226 -0
- package/dist/__tests__/value-reference-unit.test.js.map +1 -0
- package/dist/__tests__/value-reference.test.d.ts +15 -0
- package/dist/__tests__/value-reference.test.d.ts.map +1 -0
- package/dist/__tests__/value-reference.test.js +115 -0
- package/dist/__tests__/value-reference.test.js.map +1 -0
- package/dist/__tests__/walk-fast.test.d.ts +8 -0
- package/dist/__tests__/walk-fast.test.d.ts.map +1 -0
- package/dist/__tests__/walk-fast.test.js +51 -0
- package/dist/__tests__/walk-fast.test.js.map +1 -0
- package/dist/__tests__/walk-reexports.test.d.ts +7 -0
- package/dist/__tests__/walk-reexports.test.d.ts.map +1 -0
- package/dist/__tests__/walk-reexports.test.js +79 -0
- package/dist/__tests__/walk-reexports.test.js.map +1 -0
- package/dist/cache-key.d.ts +41 -0
- package/dist/cache-key.d.ts.map +1 -0
- package/dist/cache-key.js +94 -0
- package/dist/cache-key.js.map +1 -0
- package/dist/discover.d.ts +25 -0
- package/dist/discover.d.ts.map +1 -0
- package/dist/discover.js +124 -0
- package/dist/discover.js.map +1 -0
- package/dist/edge-helpers/cross-package-context.d.ts +34 -0
- package/dist/edge-helpers/cross-package-context.d.ts.map +1 -0
- package/dist/edge-helpers/cross-package-context.js +97 -0
- package/dist/edge-helpers/cross-package-context.js.map +1 -0
- package/dist/edge-helpers/declaration-to-node.d.ts +58 -0
- package/dist/edge-helpers/declaration-to-node.d.ts.map +1 -0
- package/dist/edge-helpers/declaration-to-node.js +93 -0
- package/dist/edge-helpers/declaration-to-node.js.map +1 -0
- package/dist/edge-helpers/find-catalog-entry.d.ts +24 -0
- package/dist/edge-helpers/find-catalog-entry.d.ts.map +1 -0
- package/dist/edge-helpers/find-catalog-entry.js +45 -0
- package/dist/edge-helpers/find-catalog-entry.js.map +1 -0
- package/dist/edge-helpers/method-target.d.ts +22 -0
- package/dist/edge-helpers/method-target.d.ts.map +1 -0
- package/dist/edge-helpers/method-target.js +46 -0
- package/dist/edge-helpers/method-target.js.map +1 -0
- package/dist/edge-helpers/resolution-trace.d.ts +24 -0
- package/dist/edge-helpers/resolution-trace.d.ts.map +1 -0
- package/dist/edge-helpers/resolution-trace.js +38 -0
- package/dist/edge-helpers/resolution-trace.js.map +1 -0
- package/dist/edge-helpers/resolve-decl.d.ts +44 -0
- package/dist/edge-helpers/resolve-decl.d.ts.map +1 -0
- package/dist/edge-helpers/resolve-decl.js +170 -0
- package/dist/edge-helpers/resolve-decl.js.map +1 -0
- package/dist/edge-helpers/unalias-symbol.d.ts +10 -0
- package/dist/edge-helpers/unalias-symbol.d.ts.map +1 -0
- package/dist/edge-helpers/unalias-symbol.js +29 -0
- package/dist/edge-helpers/unalias-symbol.js.map +1 -0
- package/dist/edge-resolvers/__tests__/boundary.test.d.ts +15 -0
- package/dist/edge-resolvers/__tests__/boundary.test.d.ts.map +1 -0
- package/dist/edge-resolvers/__tests__/boundary.test.js +227 -0
- package/dist/edge-resolvers/__tests__/boundary.test.js.map +1 -0
- package/dist/edge-resolvers/__tests__/callee-anchor.test.d.ts +10 -0
- package/dist/edge-resolvers/__tests__/callee-anchor.test.d.ts.map +1 -0
- package/dist/edge-resolvers/__tests__/callee-anchor.test.js +63 -0
- package/dist/edge-resolvers/__tests__/callee-anchor.test.js.map +1 -0
- package/dist/edge-resolvers/__tests__/syntactic.test.d.ts +12 -0
- package/dist/edge-resolvers/__tests__/syntactic.test.d.ts.map +1 -0
- package/dist/edge-resolvers/__tests__/syntactic.test.js +215 -0
- package/dist/edge-resolvers/__tests__/syntactic.test.js.map +1 -0
- package/dist/edge-resolvers/boundary.d.ts +41 -0
- package/dist/edge-resolvers/boundary.d.ts.map +1 -0
- package/dist/edge-resolvers/boundary.js +130 -0
- package/dist/edge-resolvers/boundary.js.map +1 -0
- package/dist/edge-resolvers/catalog-fallback.d.ts +13 -0
- package/dist/edge-resolvers/catalog-fallback.d.ts.map +1 -0
- package/dist/edge-resolvers/catalog-fallback.js +30 -0
- package/dist/edge-resolvers/catalog-fallback.js.map +1 -0
- package/dist/edge-resolvers/direct-call.d.ts +10 -0
- package/dist/edge-resolvers/direct-call.d.ts.map +1 -0
- package/dist/edge-resolvers/direct-call.js +45 -0
- package/dist/edge-resolvers/direct-call.js.map +1 -0
- package/dist/edge-resolvers/jsx-element.d.ts +16 -0
- package/dist/edge-resolvers/jsx-element.d.ts.map +1 -0
- package/dist/edge-resolvers/jsx-element.js +67 -0
- package/dist/edge-resolvers/jsx-element.js.map +1 -0
- package/dist/edge-resolvers/new-expression.d.ts +11 -0
- package/dist/edge-resolvers/new-expression.d.ts.map +1 -0
- package/dist/edge-resolvers/new-expression.js +56 -0
- package/dist/edge-resolvers/new-expression.js.map +1 -0
- package/dist/edge-resolvers/polymorphic.d.ts +8 -0
- package/dist/edge-resolvers/polymorphic.d.ts.map +1 -0
- package/dist/edge-resolvers/polymorphic.js +57 -0
- package/dist/edge-resolvers/polymorphic.js.map +1 -0
- package/dist/edge-resolvers/property-access.d.ts +10 -0
- package/dist/edge-resolvers/property-access.d.ts.map +1 -0
- package/dist/edge-resolvers/property-access.js +56 -0
- package/dist/edge-resolvers/property-access.js.map +1 -0
- package/dist/edge-resolvers/syntactic.d.ts +105 -0
- package/dist/edge-resolvers/syntactic.d.ts.map +1 -0
- package/dist/edge-resolvers/syntactic.js +294 -0
- package/dist/edge-resolvers/syntactic.js.map +1 -0
- package/dist/edge-resolvers/types.d.ts +37 -0
- package/dist/edge-resolvers/types.d.ts.map +1 -0
- package/dist/edge-resolvers/types.js +10 -0
- package/dist/edge-resolvers/types.js.map +1 -0
- package/dist/edges-value-reference.d.ts +26 -0
- package/dist/edges-value-reference.d.ts.map +1 -0
- package/dist/edges-value-reference.js +138 -0
- package/dist/edges-value-reference.js.map +1 -0
- package/dist/edges.d.ts +65 -0
- package/dist/edges.d.ts.map +1 -0
- package/dist/edges.js +392 -0
- package/dist/edges.js.map +1 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +346 -0
- package/dist/index.js.map +1 -0
- package/dist/inventory-helpers/classify-visibility.d.ts +13 -0
- package/dist/inventory-helpers/classify-visibility.d.ts.map +1 -0
- package/dist/inventory-helpers/classify-visibility.js +56 -0
- package/dist/inventory-helpers/classify-visibility.js.map +1 -0
- package/dist/inventory-helpers/extract-decorators.d.ts +6 -0
- package/dist/inventory-helpers/extract-decorators.d.ts.map +1 -0
- package/dist/inventory-helpers/extract-decorators.js +33 -0
- package/dist/inventory-helpers/extract-decorators.js.map +1 -0
- package/dist/inventory-helpers/extract-params.d.ts +7 -0
- package/dist/inventory-helpers/extract-params.d.ts.map +1 -0
- package/dist/inventory-helpers/extract-params.js +28 -0
- package/dist/inventory-helpers/extract-params.js.map +1 -0
- package/dist/inventory-helpers/hash-body.d.ts +43 -0
- package/dist/inventory-helpers/hash-body.d.ts.map +1 -0
- package/dist/inventory-helpers/hash-body.js +52 -0
- package/dist/inventory-helpers/hash-body.js.map +1 -0
- package/dist/inventory-helpers/synthesize-name.d.ts +16 -0
- package/dist/inventory-helpers/synthesize-name.d.ts.map +1 -0
- package/dist/inventory-helpers/synthesize-name.js +17 -0
- package/dist/inventory-helpers/synthesize-name.js.map +1 -0
- package/dist/inventory-visitors/arrow-function.d.ts +8 -0
- package/dist/inventory-visitors/arrow-function.d.ts.map +1 -0
- package/dist/inventory-visitors/arrow-function.js +55 -0
- package/dist/inventory-visitors/arrow-function.js.map +1 -0
- package/dist/inventory-visitors/class-static-init.d.ts +17 -0
- package/dist/inventory-visitors/class-static-init.d.ts.map +1 -0
- package/dist/inventory-visitors/class-static-init.js +45 -0
- package/dist/inventory-visitors/class-static-init.js.map +1 -0
- package/dist/inventory-visitors/constructor-declaration.d.ts +7 -0
- package/dist/inventory-visitors/constructor-declaration.d.ts.map +1 -0
- package/dist/inventory-visitors/constructor-declaration.js +47 -0
- package/dist/inventory-visitors/constructor-declaration.js.map +1 -0
- package/dist/inventory-visitors/function-declaration.d.ts +7 -0
- package/dist/inventory-visitors/function-declaration.d.ts.map +1 -0
- package/dist/inventory-visitors/function-declaration.js +59 -0
- package/dist/inventory-visitors/function-declaration.js.map +1 -0
- package/dist/inventory-visitors/function-expression.d.ts +7 -0
- package/dist/inventory-visitors/function-expression.d.ts.map +1 -0
- package/dist/inventory-visitors/function-expression.js +56 -0
- package/dist/inventory-visitors/function-expression.js.map +1 -0
- package/dist/inventory-visitors/getter-setter.d.ts +7 -0
- package/dist/inventory-visitors/getter-setter.d.ts.map +1 -0
- package/dist/inventory-visitors/getter-setter.js +63 -0
- package/dist/inventory-visitors/getter-setter.js.map +1 -0
- package/dist/inventory-visitors/method-declaration.d.ts +7 -0
- package/dist/inventory-visitors/method-declaration.d.ts.map +1 -0
- package/dist/inventory-visitors/method-declaration.js +75 -0
- package/dist/inventory-visitors/method-declaration.js.map +1 -0
- package/dist/inventory-visitors/module-init.d.ts +15 -0
- package/dist/inventory-visitors/module-init.d.ts.map +1 -0
- package/dist/inventory-visitors/module-init.js +40 -0
- package/dist/inventory-visitors/module-init.js.map +1 -0
- package/dist/inventory-visitors/types.d.ts +26 -0
- package/dist/inventory-visitors/types.d.ts.map +1 -0
- package/dist/inventory-visitors/types.js +14 -0
- package/dist/inventory-visitors/types.js.map +1 -0
- package/dist/normalize-project-dir.d.ts +14 -0
- package/dist/normalize-project-dir.d.ts.map +1 -0
- package/dist/normalize-project-dir.js +36 -0
- package/dist/normalize-project-dir.js.map +1 -0
- package/dist/parse-fast.d.ts +41 -0
- package/dist/parse-fast.d.ts.map +1 -0
- package/dist/parse-fast.js +91 -0
- package/dist/parse-fast.js.map +1 -0
- package/dist/parse.d.ts +42 -0
- package/dist/parse.d.ts.map +1 -0
- package/dist/parse.js +75 -0
- package/dist/parse.js.map +1 -0
- package/dist/test-file.d.ts +7 -0
- package/dist/test-file.d.ts.map +1 -0
- package/dist/test-file.js +42 -0
- package/dist/test-file.js.map +1 -0
- package/dist/walk.d.ts +125 -0
- package/dist/walk.d.ts.map +1 -0
- package/dist/walk.js +393 -0
- package/dist/walk.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// @fitness-ignore-file unbounded-memory -- reads tsconfig.json (+ its extends chain); bounded by standard TS configuration shape
|
|
2
|
+
/**
|
|
3
|
+
* TypeScript cacheKey implementation.
|
|
4
|
+
*
|
|
5
|
+
* Produces `ts-${ts.version}-adapter-${adapterVersion}-${resolutionMode}-${resolvedTsconfigHash}`.
|
|
6
|
+
* Stored in Catalog.cacheKey (v3 shape introduced by the language-pluggability
|
|
7
|
+
* work). Replaces the v2 fields `tsCompilerVersion` and `tsConfigPath` that lived
|
|
8
|
+
* as separate top-level catalog properties.
|
|
9
|
+
*
|
|
10
|
+
* The resolution mode is part of the key so a fast catalog and an exact catalog
|
|
11
|
+
* for the same tsconfig occupy distinct `cache_key` rows in the datastore —
|
|
12
|
+
* switching `--resolution` is a clean cache miss against the other tier, never a
|
|
13
|
+
* wrong-tier reuse. No schema change is needed; the existing `cache_key` column
|
|
14
|
+
* carries the mode.
|
|
15
|
+
*
|
|
16
|
+
* F2 — RESOLVED tsconfig (extends-aware). Earlier this hashed only the NAMED
|
|
17
|
+
* tsconfig file's RAW content. But package tsconfigs `extends` a shared base
|
|
18
|
+
* (`tsconfig.base.json`), and editing the base's `paths`/`baseUrl`/
|
|
19
|
+
* `moduleResolution` changes module resolution → different edges — WITHOUT
|
|
20
|
+
* changing the named file's bytes. Every shard fragment would then cache-hit a
|
|
21
|
+
* stale fragment → a silently-wrong graph (`--no-cache` recovers, but only if you
|
|
22
|
+
* know to). We now hash the RESOLVED `compilerOptions` (TS walks the `extends`
|
|
23
|
+
* chain for us via `parseJsonConfigFileContent`), stable-stringified, so any
|
|
24
|
+
* extends-base edit that affects resolution invalidates the key.
|
|
25
|
+
*
|
|
26
|
+
* F5 — adapter package version. The engine version is folded in separately at
|
|
27
|
+
* the engine boundary (`stampEngineVersion`, ADR-0015), but a
|
|
28
|
+
* `@opensip-cli/graph-typescript` resolver fix shipped WITHOUT an engine
|
|
29
|
+
* version bump (possible under independent versioning, ADR-0012) would reuse
|
|
30
|
+
* stale fragments. Folding the adapter's OWN package version closes that:
|
|
31
|
+
* belt-and-suspenders while engine + adapters ship in lockstep (3.0.0 today),
|
|
32
|
+
* load-bearing the moment they diverge.
|
|
33
|
+
*
|
|
34
|
+
* Per contract invariant I-6 (cacheKey is stable for stable input): the function
|
|
35
|
+
* is purely a function of
|
|
36
|
+
* `(ts.version, adapterVersion, resolutionMode, resolvedTsconfigOptions)`. If the
|
|
37
|
+
* tsconfig file is missing/unreadable on disk we fall back to a literal marker so
|
|
38
|
+
* two calls without a (readable) tsconfig still match.
|
|
39
|
+
*/
|
|
40
|
+
import { createHash } from 'node:crypto';
|
|
41
|
+
import { existsSync } from 'node:fs';
|
|
42
|
+
import { dirname } from 'node:path';
|
|
43
|
+
import { readPackageVersion } from '@opensip-cli/core';
|
|
44
|
+
import ts from 'typescript';
|
|
45
|
+
/**
|
|
46
|
+
* This adapter package's own version (ADR-0012 independent versioning). Resolved
|
|
47
|
+
* once from the nearest package.json, memoized in core's `readPackageVersion`.
|
|
48
|
+
*/
|
|
49
|
+
const ADAPTER_VERSION = readPackageVersion(import.meta.url);
|
|
50
|
+
export function cacheKey(input) {
|
|
51
|
+
const tsconfigHash = hashResolvedTsconfig(input.configPathAbs);
|
|
52
|
+
return `ts-${ts.version}-adapter-${ADAPTER_VERSION}-${input.resolutionMode}-${tsconfigHash}`;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Hash the RESOLVED tsconfig — the effective `compilerOptions` after TS walks the
|
|
56
|
+
* `extends` chain — rather than the named file's raw bytes. So an edit to a
|
|
57
|
+
* shared `tsconfig.base.json`'s `paths`/`baseUrl`/`moduleResolution` that the
|
|
58
|
+
* named config `extends` changes the key (the fragments rebuild), not a stale hit.
|
|
59
|
+
*/
|
|
60
|
+
function hashResolvedTsconfig(configPathAbs) {
|
|
61
|
+
if (configPathAbs === undefined || configPathAbs.length === 0) {
|
|
62
|
+
return 'no-tsconfig';
|
|
63
|
+
}
|
|
64
|
+
if (!existsSync(configPathAbs)) {
|
|
65
|
+
return `missing:${configPathAbs}`;
|
|
66
|
+
}
|
|
67
|
+
const read = ts.readConfigFile(configPathAbs, (path) => ts.sys.readFile(path));
|
|
68
|
+
if (read.error !== undefined || read.config === undefined) {
|
|
69
|
+
/* v8 ignore next */
|
|
70
|
+
return `unreadable:${configPathAbs}`;
|
|
71
|
+
}
|
|
72
|
+
// parseJsonConfigFileContent follows `extends` and merges the effective
|
|
73
|
+
// compilerOptions. We hash ONLY the resolved compilerOptions (the
|
|
74
|
+
// resolution-affecting surface) — not the full parsed file list, which is a
|
|
75
|
+
// function of on-disk globs the per-file fingerprint already covers.
|
|
76
|
+
const parsed = ts.parseJsonConfigFileContent(read.config, ts.sys, dirname(configPathAbs), undefined, configPathAbs);
|
|
77
|
+
return createHash('sha256').update(stableStringify(parsed.options)).digest('hex').slice(0, 16);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Stable JSON of an object: keys sorted so the hash is independent of TS's
|
|
81
|
+
* internal property-insertion order. Values are TS's resolved compilerOptions
|
|
82
|
+
* primitives (strings/numbers/booleans/enums) — JSON-serializable; the
|
|
83
|
+
* `configFilePath`/`pathsBasePath` absolute-path fields are dropped so the key
|
|
84
|
+
* is location-independent (a checkout under a different absolute root still
|
|
85
|
+
* hits).
|
|
86
|
+
*/
|
|
87
|
+
function stableStringify(options) {
|
|
88
|
+
const LOCATION_KEYS = new Set(['configFilePath', 'pathsBasePath']);
|
|
89
|
+
const entries = Object.entries(options)
|
|
90
|
+
.filter(([k]) => !LOCATION_KEYS.has(k))
|
|
91
|
+
.sort(([a], [b]) => Number(a > b) - Number(a < b));
|
|
92
|
+
return JSON.stringify(entries);
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=cache-key.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-key.js","sourceRoot":"","sources":["../src/cache-key.ts"],"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;IAClE,4EAA4E;IAC5E,qEAAqE;IACrE,MAAM,MAAM,GAAG,EAAE,CAAC,0BAA0B,CAC1C,IAAI,CAAC,MAAM,EACX,EAAE,CAAC,GAAG,EACN,OAAO,CAAC,aAAa,CAAC,EACtB,SAAS,EACT,aAAa,CACd,CAAC;IACF,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACjG,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,eAAe,CAAC,OAA2B;IAClD,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,gBAAgB,EAAE,eAAe,CAAC,CAAC,CAAC;IACnE,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,OAAkC,CAAC;SAC/D,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SACtC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACrD,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stage 0 — Discover files.
|
|
3
|
+
*
|
|
4
|
+
* Resolves the project's tsconfig and produces an absolute, realpath'd
|
|
5
|
+
* list of source files for stage 1 to inventory.
|
|
6
|
+
*
|
|
7
|
+
* Stage 0 does not create a TypeScript Program — that's stage 1's job.
|
|
8
|
+
* It is purely about *what files exist*.
|
|
9
|
+
*/
|
|
10
|
+
import ts from 'typescript';
|
|
11
|
+
/** Input to {@link discoverFiles}: project directory and optional tsconfig override. */
|
|
12
|
+
export interface DiscoveryInput {
|
|
13
|
+
readonly projectDir: string;
|
|
14
|
+
readonly tsConfigPath?: string;
|
|
15
|
+
}
|
|
16
|
+
/** Result of {@link discoverFiles}: resolved paths, source files, and TS compiler options. */
|
|
17
|
+
export interface DiscoveryOutput {
|
|
18
|
+
readonly projectDirAbs: string;
|
|
19
|
+
readonly tsConfigPathAbs: string;
|
|
20
|
+
readonly files: readonly string[];
|
|
21
|
+
readonly compilerOptions: ts.CompilerOptions;
|
|
22
|
+
}
|
|
23
|
+
/** Resolves the tsconfig for a TS project and returns the in-program source-file set. */
|
|
24
|
+
export declare function discoverFiles(input: DiscoveryInput): DiscoveryOutput;
|
|
25
|
+
//# sourceMappingURL=discover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discover.d.ts","sourceRoot":"","sources":["../src/discover.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAMH,OAAO,EAAE,MAAM,YAAY,CAAC;AAI5B,wFAAwF;AACxF,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,8FAA8F;AAC9F,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,eAAe,EAAE,EAAE,CAAC,eAAe,CAAC;CAC9C;AAED,yFAAyF;AACzF,wBAAgB,aAAa,CAAC,KAAK,EAAE,cAAc,GAAG,eAAe,CA0BpE"}
|
package/dist/discover.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// @fitness-ignore-file error-handling-quality -- two intentional swallows: (1) the ParseConfigHost.readFile shim returns undefined when TS asks about a vanished referenced file (TS treats undefined as "skip"), and (2) realpathSync probe for symlink dedup falls through with the original path; both are marked v8-ignore as effectively unreachable on real input.
|
|
2
|
+
// @fitness-ignore-file unbounded-memory -- ParseConfigHost.readFile reads tsconfig.json files only; bounded by standard TS configuration shape
|
|
3
|
+
/**
|
|
4
|
+
* Stage 0 — Discover files.
|
|
5
|
+
*
|
|
6
|
+
* Resolves the project's tsconfig and produces an absolute, realpath'd
|
|
7
|
+
* list of source files for stage 1 to inventory.
|
|
8
|
+
*
|
|
9
|
+
* Stage 0 does not create a TypeScript Program — that's stage 1's job.
|
|
10
|
+
* It is purely about *what files exist*.
|
|
11
|
+
*/
|
|
12
|
+
import { existsSync, realpathSync, readFileSync } from 'node:fs';
|
|
13
|
+
import { dirname, isAbsolute, resolve, sep } from 'node:path';
|
|
14
|
+
import { ConfigurationError, logger } from '@opensip-cli/core';
|
|
15
|
+
import ts from 'typescript';
|
|
16
|
+
import { normalizeProjectDir } from './normalize-project-dir.js';
|
|
17
|
+
/** Resolves the tsconfig for a TS project and returns the in-program source-file set. */
|
|
18
|
+
export function discoverFiles(input) {
|
|
19
|
+
logger.info({
|
|
20
|
+
evt: 'graph.discover.start',
|
|
21
|
+
module: 'graph:discover',
|
|
22
|
+
projectDir: input.projectDir,
|
|
23
|
+
});
|
|
24
|
+
const projectDirAbs = normalizeProjectDir(input.projectDir);
|
|
25
|
+
const tsConfigPathAbs = resolveTsConfigPath(projectDirAbs, input.tsConfigPath);
|
|
26
|
+
const { options, fileNames } = loadTsConfig(tsConfigPathAbs);
|
|
27
|
+
const files = filterToSourceFiles(fileNames);
|
|
28
|
+
logger.info({
|
|
29
|
+
evt: 'graph.discover.complete',
|
|
30
|
+
module: 'graph:discover',
|
|
31
|
+
projectDir: projectDirAbs,
|
|
32
|
+
tsConfig: tsConfigPathAbs,
|
|
33
|
+
fileCount: files.length,
|
|
34
|
+
});
|
|
35
|
+
return {
|
|
36
|
+
projectDirAbs,
|
|
37
|
+
tsConfigPathAbs,
|
|
38
|
+
files,
|
|
39
|
+
compilerOptions: options,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function resolveTsConfigPath(projectDirAbs, override) {
|
|
43
|
+
let candidate;
|
|
44
|
+
if (override === undefined) {
|
|
45
|
+
candidate = resolve(projectDirAbs, 'tsconfig.json');
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
candidate = isAbsolute(override) ? override : resolve(projectDirAbs, override);
|
|
49
|
+
}
|
|
50
|
+
if (!existsSync(candidate)) {
|
|
51
|
+
throw new ConfigurationError(`tsconfig.json not found at ${candidate}`);
|
|
52
|
+
}
|
|
53
|
+
/* v8 ignore start */
|
|
54
|
+
try {
|
|
55
|
+
return realpathSync(candidate);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return candidate;
|
|
59
|
+
}
|
|
60
|
+
/* v8 ignore stop */
|
|
61
|
+
}
|
|
62
|
+
function loadTsConfig(tsConfigPathAbs) {
|
|
63
|
+
const raw = readFileSync(tsConfigPathAbs, 'utf8');
|
|
64
|
+
const parsed = ts.parseConfigFileTextToJson(tsConfigPathAbs, raw);
|
|
65
|
+
/* v8 ignore start */
|
|
66
|
+
if (parsed.error) {
|
|
67
|
+
throw new ConfigurationError(`Failed to parse ${tsConfigPathAbs}: ${ts.flattenDiagnosticMessageText(parsed.error.messageText, '\n')}`);
|
|
68
|
+
}
|
|
69
|
+
/* v8 ignore stop */
|
|
70
|
+
const readDirectoryBound = ts.sys.readDirectory.bind(ts.sys);
|
|
71
|
+
const host = {
|
|
72
|
+
fileExists: (p) => existsSync(p),
|
|
73
|
+
readDirectory: readDirectoryBound,
|
|
74
|
+
/* v8 ignore start */
|
|
75
|
+
readFile: (p) => {
|
|
76
|
+
try {
|
|
77
|
+
return readFileSync(p, 'utf8');
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
/* v8 ignore stop */
|
|
84
|
+
useCaseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames,
|
|
85
|
+
};
|
|
86
|
+
const result = ts.parseJsonConfigFileContent(parsed.config, host, dirname(tsConfigPathAbs), {}, tsConfigPathAbs);
|
|
87
|
+
/* v8 ignore start */
|
|
88
|
+
if (result.errors.length > 0) {
|
|
89
|
+
const fatal = result.errors.find((e) => e.category === ts.DiagnosticCategory.Error);
|
|
90
|
+
if (fatal) {
|
|
91
|
+
throw new ConfigurationError(`Failed to load ${tsConfigPathAbs}: ${ts.flattenDiagnosticMessageText(fatal.messageText, '\n')}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/* v8 ignore stop */
|
|
95
|
+
return { options: result.options, fileNames: result.fileNames };
|
|
96
|
+
}
|
|
97
|
+
function filterToSourceFiles(fileNames) {
|
|
98
|
+
const seen = new Set();
|
|
99
|
+
const out = [];
|
|
100
|
+
for (const f of fileNames) {
|
|
101
|
+
if (!f.endsWith('.ts') && !f.endsWith('.tsx'))
|
|
102
|
+
continue;
|
|
103
|
+
if (f.endsWith('.d.ts'))
|
|
104
|
+
continue;
|
|
105
|
+
let real = f;
|
|
106
|
+
/* v8 ignore start */
|
|
107
|
+
try {
|
|
108
|
+
real = realpathSync(f);
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
// Use the original path if realpath fails (file might be in a symlinked dir).
|
|
112
|
+
}
|
|
113
|
+
/* v8 ignore stop */
|
|
114
|
+
// Normalize separators on Windows so dedup works.
|
|
115
|
+
const key = real.split(sep).join('/');
|
|
116
|
+
if (seen.has(key))
|
|
117
|
+
continue;
|
|
118
|
+
seen.add(key);
|
|
119
|
+
out.push(real);
|
|
120
|
+
}
|
|
121
|
+
out.sort();
|
|
122
|
+
return out;
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=discover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discover.js","sourceRoot":"","sources":["../src/discover.ts"],"names":[],"mappings":"A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YAAE,SAAS;QAClC,IAAI,IAAI,GAAG,CAAC,CAAC;QACb,qBAAqB;QACrB,IAAI,CAAC;YACH,IAAI,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;QACzB,CAAC;QAAC,MAAM,CAAC;YACP,8EAA8E;QAChF,CAAC;QACD,oBAAoB;QACpB,kDAAkD;QAClD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACtC,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,SAAS;QAC5B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACd,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC;IACD,GAAG,CAAC,IAAI,EAAE,CAAC;IACX,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-package resolution context for the EXACT (single-program) engine.
|
|
3
|
+
*
|
|
4
|
+
* The sharded engine links a `@scope/pkg` call to its target by looking the
|
|
5
|
+
* (import specifier + callee name) up in the imported package's export symbol
|
|
6
|
+
* table ({@link buildExportIndex}) — never by following the type-checker alias
|
|
7
|
+
* into the package's built `dist/*.d.ts` (which is bodiless, so its hash never
|
|
8
|
+
* matches the SOURCE body in the catalog). The exact engine now resolves
|
|
9
|
+
* cross-package calls the SAME way, through {@link resolveCrossPackageCall}; this
|
|
10
|
+
* module assembles the two indexes that resolver needs from the data the exact
|
|
11
|
+
* resolve stage already has — the merged catalog + the project root.
|
|
12
|
+
*
|
|
13
|
+
* - {@link ExportIndex} — built directly from the catalog (one pass).
|
|
14
|
+
* - {@link PackageManifestIndex} — built by deriving each workspace package's
|
|
15
|
+
* root (the nearest ancestor dir of a cataloged file that has a
|
|
16
|
+
* `package.json`) and reading its manifest. Single-program builds have no
|
|
17
|
+
* `Shard[]` to hand to `buildPackageManifestIndex`, so we synthesize one
|
|
18
|
+
* shard per discovered package root; manifest reads that fail are skipped
|
|
19
|
+
* (the package simply won't be specifier-resolvable), identical to the
|
|
20
|
+
* sharded path's best-effort behavior.
|
|
21
|
+
*/
|
|
22
|
+
import { type Catalog, type ExportIndex, type PackageManifestIndex } from '@opensip-cli/graph';
|
|
23
|
+
/** The two indexes the shared {@link resolveCrossPackageCall} resolver links against. */
|
|
24
|
+
export interface CrossPackageContext {
|
|
25
|
+
readonly exportIndex: ExportIndex;
|
|
26
|
+
readonly manifestIndex: PackageManifestIndex;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Assemble the exact engine's cross-package resolution context from the catalog
|
|
30
|
+
* and the absolute project root. Built once per resolve stage and threaded onto
|
|
31
|
+
* every resolver's {@link ResolverContext}.
|
|
32
|
+
*/
|
|
33
|
+
export declare function buildCrossPackageContext(catalog: Catalog, projectDirAbs: string): CrossPackageContext;
|
|
34
|
+
//# sourceMappingURL=cross-package-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cross-package-context.d.ts","sourceRoot":"","sources":["../../src/edge-helpers/cross-package-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAKH,OAAO,EAGL,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,oBAAoB,EAC1B,MAAM,oBAAoB,CAAC;AAE5B,yFAAyF;AACzF,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,aAAa,EAAE,oBAAoB,CAAC;CAC9C;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,MAAM,GACpB,mBAAmB,CAWrB"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-package resolution context for the EXACT (single-program) engine.
|
|
3
|
+
*
|
|
4
|
+
* The sharded engine links a `@scope/pkg` call to its target by looking the
|
|
5
|
+
* (import specifier + callee name) up in the imported package's export symbol
|
|
6
|
+
* table ({@link buildExportIndex}) — never by following the type-checker alias
|
|
7
|
+
* into the package's built `dist/*.d.ts` (which is bodiless, so its hash never
|
|
8
|
+
* matches the SOURCE body in the catalog). The exact engine now resolves
|
|
9
|
+
* cross-package calls the SAME way, through {@link resolveCrossPackageCall}; this
|
|
10
|
+
* module assembles the two indexes that resolver needs from the data the exact
|
|
11
|
+
* resolve stage already has — the merged catalog + the project root.
|
|
12
|
+
*
|
|
13
|
+
* - {@link ExportIndex} — built directly from the catalog (one pass).
|
|
14
|
+
* - {@link PackageManifestIndex} — built by deriving each workspace package's
|
|
15
|
+
* root (the nearest ancestor dir of a cataloged file that has a
|
|
16
|
+
* `package.json`) and reading its manifest. Single-program builds have no
|
|
17
|
+
* `Shard[]` to hand to `buildPackageManifestIndex`, so we synthesize one
|
|
18
|
+
* shard per discovered package root; manifest reads that fail are skipped
|
|
19
|
+
* (the package simply won't be specifier-resolvable), identical to the
|
|
20
|
+
* sharded path's best-effort behavior.
|
|
21
|
+
*/
|
|
22
|
+
import { existsSync } from 'node:fs';
|
|
23
|
+
import { dirname, join, sep } from 'node:path';
|
|
24
|
+
import { buildExportIndex, buildPackageManifestIndexFromRoots, } from '@opensip-cli/graph';
|
|
25
|
+
/**
|
|
26
|
+
* Assemble the exact engine's cross-package resolution context from the catalog
|
|
27
|
+
* and the absolute project root. Built once per resolve stage and threaded onto
|
|
28
|
+
* every resolver's {@link ResolverContext}.
|
|
29
|
+
*/
|
|
30
|
+
export function buildCrossPackageContext(catalog, projectDirAbs) {
|
|
31
|
+
const manifestIndex = buildPackageManifestIndexFromRoots(derivePackageRoots(catalog, projectDirAbs), projectDirAbs);
|
|
32
|
+
return {
|
|
33
|
+
// Pass the manifest index so the export index can follow re-export chains
|
|
34
|
+
// (a name re-exported by package A from package B resolves under A).
|
|
35
|
+
exportIndex: buildExportIndex(catalog, manifestIndex),
|
|
36
|
+
manifestIndex,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Derive each workspace package ROOT (absolute) present in the catalog. A
|
|
41
|
+
* package root is the nearest ancestor directory of a cataloged file that
|
|
42
|
+
* contains a `package.json`. Probing walks UP from each file's directory and
|
|
43
|
+
* stops at the first `package.json` (or the project root) — so a monorepo with
|
|
44
|
+
* `packages/<ns>/<pkg>/package.json` resolves each leaf package, not the
|
|
45
|
+
* workspace root. Deduped by root dir.
|
|
46
|
+
*/
|
|
47
|
+
function derivePackageRoots(catalog, projectDirAbs) {
|
|
48
|
+
const rootDirs = new Set();
|
|
49
|
+
const projectRootAbs = normalizeDir(projectDirAbs);
|
|
50
|
+
for (const occs of Object.values(catalog.functions)) {
|
|
51
|
+
if (!occs)
|
|
52
|
+
continue;
|
|
53
|
+
for (const occ of occs) {
|
|
54
|
+
const fileDirAbs = dirname(join(projectDirAbs, occ.filePath));
|
|
55
|
+
const root = findPackageRoot(fileDirAbs, projectRootAbs);
|
|
56
|
+
if (root !== undefined)
|
|
57
|
+
rootDirs.add(root);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return [...rootDirs];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Walk up from `startDirAbs` to the first ancestor (inclusive, up to and
|
|
64
|
+
* including `projectRootAbs`) that contains a `package.json`. Returns
|
|
65
|
+
* `undefined` when no manifest is found up to the project root.
|
|
66
|
+
*/
|
|
67
|
+
function findPackageRoot(startDirAbs, projectRootAbs) {
|
|
68
|
+
let dir = normalizeDir(startDirAbs);
|
|
69
|
+
for (;;) {
|
|
70
|
+
if (hasManifest(dir))
|
|
71
|
+
return dir;
|
|
72
|
+
if (dir === projectRootAbs)
|
|
73
|
+
return undefined;
|
|
74
|
+
const parent = dirname(dir);
|
|
75
|
+
if (parent === dir)
|
|
76
|
+
return undefined; // filesystem root — give up
|
|
77
|
+
dir = parent;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const MANIFEST_DIRS = new Set();
|
|
81
|
+
const NON_MANIFEST_DIRS = new Set();
|
|
82
|
+
/** Memoized `<dir>/package.json` existence probe (process-lifetime cache —
|
|
83
|
+
* package.json presence is stable within a run). */
|
|
84
|
+
function hasManifest(dirAbs) {
|
|
85
|
+
if (MANIFEST_DIRS.has(dirAbs))
|
|
86
|
+
return true;
|
|
87
|
+
if (NON_MANIFEST_DIRS.has(dirAbs))
|
|
88
|
+
return false;
|
|
89
|
+
const present = existsSync(join(dirAbs, 'package.json'));
|
|
90
|
+
(present ? MANIFEST_DIRS : NON_MANIFEST_DIRS).add(dirAbs);
|
|
91
|
+
return present;
|
|
92
|
+
}
|
|
93
|
+
/** Strip a trailing path separator so dir comparisons are stable. */
|
|
94
|
+
function normalizeDir(dirAbs) {
|
|
95
|
+
return dirAbs.endsWith(sep) && dirAbs.length > 1 ? dirAbs.slice(0, -1) : dirAbs;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=cross-package-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cross-package-context.js","sourceRoot":"","sources":["../../src/edge-helpers/cross-package-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,EACL,gBAAgB,EAChB,kCAAkC,GAInC,MAAM,oBAAoB,CAAC;AAQ5B;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CACtC,OAAgB,EAChB,aAAqB;IAErB,MAAM,aAAa,GAAG,kCAAkC,CACtD,kBAAkB,CAAC,OAAO,EAAE,aAAa,CAAC,EAC1C,aAAa,CACd,CAAC;IACF,OAAO;QACL,0EAA0E;QAC1E,qEAAqE;QACrE,WAAW,EAAE,gBAAgB,CAAC,OAAO,EAAE,aAAa,CAAC;QACrD,aA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AAS,WAAW,CAAC,MAAc;IACjC,IAAI,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IAC3C,IAAI,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IAChD,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;IACzD,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1D,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,qEAAqE;AACrE,SAAS,YAAY,CAAC,MAAc;IAClC,OAAO,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AAClF,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map a TypeScript Declaration to the function-shaped node that owns
|
|
3
|
+
* its catalog entry.
|
|
4
|
+
*
|
|
5
|
+
* Four resolver files used to inline their own near-identical copy
|
|
6
|
+
* of this logic — each accepting a slightly different set of
|
|
7
|
+
* declaration shapes. The duplicated-function-body rule flagged the
|
|
8
|
+
* group; consolidating onto one helper with a `DeclShape` bitmask
|
|
9
|
+
* makes the per-resolver intent explicit.
|
|
10
|
+
*
|
|
11
|
+
* Declaration shapes are bit flags so callers can OR exactly the
|
|
12
|
+
* subset their resolver accepts. The mask is matched against the
|
|
13
|
+
* declaration type before unwrapping (Variable / Property
|
|
14
|
+
* declarations dereference their initializer to find the actual
|
|
15
|
+
* function-shape).
|
|
16
|
+
*/
|
|
17
|
+
import ts from 'typescript';
|
|
18
|
+
/**
|
|
19
|
+
* Bit-flag set of declaration shapes acceptable in a given resolver
|
|
20
|
+
* context. OR the shapes a resolver should accept and pass the result
|
|
21
|
+
* to {@link functionLikeFromDeclaration}.
|
|
22
|
+
*/
|
|
23
|
+
export declare const DeclShape: {
|
|
24
|
+
/** `function foo() {}` */
|
|
25
|
+
readonly FunctionDeclaration: 1;
|
|
26
|
+
/** `() => ...` */
|
|
27
|
+
readonly ArrowFunction: 2;
|
|
28
|
+
/** `function () {}` (the expression form). */
|
|
29
|
+
readonly FunctionExpression: 4;
|
|
30
|
+
/** Class method: `foo() {}` inside a class body. */
|
|
31
|
+
readonly MethodDeclaration: 8;
|
|
32
|
+
/** `constructor() {}`. */
|
|
33
|
+
readonly ConstructorDeclaration: 16;
|
|
34
|
+
/** `get foo() {}` / `set foo(v) {}`. */
|
|
35
|
+
readonly Accessor: 32;
|
|
36
|
+
/** Interface method declarations: `foo(): void;`. */
|
|
37
|
+
readonly MethodSignature: 64;
|
|
38
|
+
/** Class property declarations (used by polymorphic dispatch). */
|
|
39
|
+
readonly PropertyDeclaration: 128;
|
|
40
|
+
/** `const foo = () => ...` / `const foo = function () {}` — unwrap initializer. */
|
|
41
|
+
readonly VariableInitializer: 256;
|
|
42
|
+
/** `{ foo: () => ... }` / `{ foo: function () {} }` — unwrap initializer. */
|
|
43
|
+
readonly PropertyAssignmentInitializer: 512;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Return the function-shaped node that should be hashed against the
|
|
47
|
+
* catalog for declaration `d`, given the caller's `accept` mask.
|
|
48
|
+
* Returns null when `d` doesn't match any accepted shape.
|
|
49
|
+
*
|
|
50
|
+
* Variable / property assignments are unwrapped to their initializer
|
|
51
|
+
* function only when the corresponding `*Initializer` bit is set.
|
|
52
|
+
* Direct function-shapes are accepted only when their specific bit
|
|
53
|
+
* is set — passing `DeclShape.ArrowFunction` accepts a bare arrow
|
|
54
|
+
* declaration but NOT a `const foo = () => ...` (you'd need to OR
|
|
55
|
+
* `VariableInitializer` for that).
|
|
56
|
+
*/
|
|
57
|
+
export declare function functionLikeFromDeclaration(d: ts.Declaration, accept: number): ts.Node | null;
|
|
58
|
+
//# sourceMappingURL=declaration-to-node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declaration-to-node.d.ts","sourceRoot":"","sources":["../../src/edge-helpers/declaration-to-node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B;;;;GAIG;AACH,eAAO,MAAM,SAAS;IACpB,0BAA0B;;IAE1B,kBAAkB;;IAElB,8CAA8C;;IAE9C,oDAAoD;;IAEpD,0BAA0B;;IAE1B,wCAAwC;;IAExC,qDAAqD;;IAErD,kEAAkE;;IAElE,mFAAmF;;IAEnF,6EAA6E;;CAErE,CAAC;AAuBX;;;;;;;;;;;GAWG;AACH,wBAAgB,2BAA2B,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,EAAE,CAAC,IAAI,GAAG,IAAI,CAmB7F"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map a TypeScript Declaration to the function-shaped node that owns
|
|
3
|
+
* its catalog entry.
|
|
4
|
+
*
|
|
5
|
+
* Four resolver files used to inline their own near-identical copy
|
|
6
|
+
* of this logic — each accepting a slightly different set of
|
|
7
|
+
* declaration shapes. The duplicated-function-body rule flagged the
|
|
8
|
+
* group; consolidating onto one helper with a `DeclShape` bitmask
|
|
9
|
+
* makes the per-resolver intent explicit.
|
|
10
|
+
*
|
|
11
|
+
* Declaration shapes are bit flags so callers can OR exactly the
|
|
12
|
+
* subset their resolver accepts. The mask is matched against the
|
|
13
|
+
* declaration type before unwrapping (Variable / Property
|
|
14
|
+
* declarations dereference their initializer to find the actual
|
|
15
|
+
* function-shape).
|
|
16
|
+
*/
|
|
17
|
+
import ts from 'typescript';
|
|
18
|
+
/**
|
|
19
|
+
* Bit-flag set of declaration shapes acceptable in a given resolver
|
|
20
|
+
* context. OR the shapes a resolver should accept and pass the result
|
|
21
|
+
* to {@link functionLikeFromDeclaration}.
|
|
22
|
+
*/
|
|
23
|
+
export const DeclShape = {
|
|
24
|
+
/** `function foo() {}` */
|
|
25
|
+
FunctionDeclaration: 1,
|
|
26
|
+
/** `() => ...` */
|
|
27
|
+
ArrowFunction: 2,
|
|
28
|
+
/** `function () {}` (the expression form). */
|
|
29
|
+
FunctionExpression: 4,
|
|
30
|
+
/** Class method: `foo() {}` inside a class body. */
|
|
31
|
+
MethodDeclaration: 8,
|
|
32
|
+
/** `constructor() {}`. */
|
|
33
|
+
ConstructorDeclaration: 16,
|
|
34
|
+
/** `get foo() {}` / `set foo(v) {}`. */
|
|
35
|
+
Accessor: 32,
|
|
36
|
+
/** Interface method declarations: `foo(): void;`. */
|
|
37
|
+
MethodSignature: 64,
|
|
38
|
+
/** Class property declarations (used by polymorphic dispatch). */
|
|
39
|
+
PropertyDeclaration: 128,
|
|
40
|
+
/** `const foo = () => ...` / `const foo = function () {}` — unwrap initializer. */
|
|
41
|
+
VariableInitializer: 256,
|
|
42
|
+
/** `{ foo: () => ... }` / `{ foo: function () {} }` — unwrap initializer. */
|
|
43
|
+
PropertyAssignmentInitializer: 512,
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Direct (un-unwrapped) shape predicate table. Each entry pairs a
|
|
47
|
+
* declaration-shape bit with the matching `ts.is*` guard. The lookup
|
|
48
|
+
* loop in {@link functionLikeFromDeclaration} keeps the cyclomatic
|
|
49
|
+
* complexity low compared to the if-ladder it replaced.
|
|
50
|
+
*/
|
|
51
|
+
const DIRECT_SHAPE_TABLE = [
|
|
52
|
+
[DeclShape.FunctionDeclaration, ts.isFunctionDeclaration],
|
|
53
|
+
[DeclShape.ArrowFunction, ts.isArrowFunction],
|
|
54
|
+
[DeclShape.FunctionExpression, ts.isFunctionExpression],
|
|
55
|
+
[DeclShape.MethodDeclaration, ts.isMethodDeclaration],
|
|
56
|
+
[DeclShape.ConstructorDeclaration, ts.isConstructorDeclaration],
|
|
57
|
+
[DeclShape.Accessor, (d) => ts.isGetAccessor(d) || ts.isSetAccessor(d)],
|
|
58
|
+
[DeclShape.MethodSignature, ts.isMethodSignature],
|
|
59
|
+
[DeclShape.PropertyDeclaration, ts.isPropertyDeclaration],
|
|
60
|
+
];
|
|
61
|
+
function isFunctionInitializer(node) {
|
|
62
|
+
return node !== undefined && (ts.isArrowFunction(node) || ts.isFunctionExpression(node));
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Return the function-shaped node that should be hashed against the
|
|
66
|
+
* catalog for declaration `d`, given the caller's `accept` mask.
|
|
67
|
+
* Returns null when `d` doesn't match any accepted shape.
|
|
68
|
+
*
|
|
69
|
+
* Variable / property assignments are unwrapped to their initializer
|
|
70
|
+
* function only when the corresponding `*Initializer` bit is set.
|
|
71
|
+
* Direct function-shapes are accepted only when their specific bit
|
|
72
|
+
* is set — passing `DeclShape.ArrowFunction` accepts a bare arrow
|
|
73
|
+
* declaration but NOT a `const foo = () => ...` (you'd need to OR
|
|
74
|
+
* `VariableInitializer` for that).
|
|
75
|
+
*/
|
|
76
|
+
export function functionLikeFromDeclaration(d, accept) {
|
|
77
|
+
for (const [bit, predicate] of DIRECT_SHAPE_TABLE) {
|
|
78
|
+
if ((accept & bit) !== 0 && predicate(d))
|
|
79
|
+
return d;
|
|
80
|
+
}
|
|
81
|
+
if ((accept & DeclShape.VariableInitializer) !== 0 &&
|
|
82
|
+
ts.isVariableDeclaration(d) &&
|
|
83
|
+
isFunctionInitializer(d.initializer)) {
|
|
84
|
+
return d.initializer ?? null;
|
|
85
|
+
}
|
|
86
|
+
if ((accept & DeclShape.PropertyAssignmentInitializer) !== 0 &&
|
|
87
|
+
ts.isPropertyAssignment(d) &&
|
|
88
|
+
isFunctionInitializer(d.initializer)) {
|
|
89
|
+
return d.initializer;
|
|
90
|
+
}
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=declaration-to-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declaration-to-node.js","sourceRoot":"","sources":["../../src/edge-helpers/declaration-to-node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,0BAA0B;IAC1B,mBAAmB,EAAE,CAAC;IACtB,kBAAkB;IAClB,aAAa,EAAE,CAAC;IAChB,8CAA8C;IAC9C,kBAAkB,EAAE,CAAC;IACrB,oDAAoD;IACpD,iBAAiB,EAAE,CAAC;IACpB,0BAA0B;IAC1B,sBAAsB,EAAE,EAAE;IAC1B,wCAAwC;IACxC,QAAQ,EAAE,EAAE;IACZ,qDAAqD;IACrD,eAAe,EAAE,EAAE;IACnB,kEAAkE;IAClE,mBAAmB,EAAE,GAAG;IACxB,mFAAmF;IACnF,mBAAmB,EAAE,GAAG;IACxB,6EAA6E;IAC7E,6BAA6B,EAAE,GAAG;CAC1B,CAAC;AAEX;;;;;GAKG;AACH,MAAM,kBAAkB,GAAmE;IACzF,CAAC,SAAS,CAAC,mBAAmB,EAAE,EAAE,CAAC,qBAAqB,CAAC;IACzD,CAAC,SAAS,CAAC,aAAa,EAAE,EAAE,CAAC,eAAe,CAAC;IAC7C,CAAC,SAAS,CAAC,kBAAkB,EAAE,EAAE,CAAC,oBAAoB,CAAC;IACvD,CAAC,SAAS,CAAC,iBAAiB,EAAE,EAAE,CAAC,mBAAmB,CAAC;IACrD,CAAC,SAAS,CAAC,sBAAsB,EAAE,EAAE,CAAC,wBAAwB,CAAC;IAC/D,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IACvE,CAAC,SAAS,CAAC,eAAe,EAAE,EAAE,CAAC,iBAAiB,CAAC;IACjD,CAAC,SAAS,CAAC,mBAAmB,EAAE,EAAE,CAAC,qBAAqB,CAAC;CAC1D,CAAC;AAEF,SAAS,qBAAqB,CAAC,IAAyB;IACtD,OAAO,IAAI,KAAK,SAAS,IAAI,CAAC,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC;AAC3F,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,2BAA2B,CAAC,CAAiB,EAAE,MAAc;IAC3E,KAAK,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,IAAI,kBAAkB,EAAE,CAAC;QAClD,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC;YAAE,OAAO,CAAC,CAAC;IACrD,CAAC;IACD,IACE,CAAC,MAAM,GAAG,SAAS,CAAC,mBAAmB,CAAC,KAAK,CAAC;QAC9C,EAAE,CAAC,qBAAqB,CAAC,CAAC,CAAC;QAC3B,qBAAqB,CAAC,CAAC,CAAC,WAAW,CAAC,EACpC,CAAC;QACD,OAAO,CAAC,CAAC,WAAW,IAAI,IAAI,CAAC;IAC/B,CAAC;IACD,IACE,CAAC,MAAM,GAAG,SAAS,CAAC,6BAA6B,CAAC,KAAK,CAAC;QACxD,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAC;QAC1B,qBAAqB,CAAC,CAAC,CAAC,WAAW,CAAC,EACpC,CAAC;QACD,OAAO,CAAC,CAAC,WAAW,CAAC;IACvB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* findCatalogEntry — locate a catalog entry's bodyHash from a TS declaration.
|
|
3
|
+
*
|
|
4
|
+
* Uses hashFunctionBody (the same function stage 1 used to populate
|
|
5
|
+
* the catalog) so a successful lookup is guaranteed when the
|
|
6
|
+
* declaration is in the project.
|
|
7
|
+
*/
|
|
8
|
+
import type { Catalog } from '@opensip-cli/graph';
|
|
9
|
+
import type ts from 'typescript';
|
|
10
|
+
/**
|
|
11
|
+
* Returns the bodyHash if the declaration's hash is present in the
|
|
12
|
+
* catalog under one of `candidateNames`. Returns null otherwise.
|
|
13
|
+
*
|
|
14
|
+
* Matching is strictly (candidate simple name) × (body hash): the declaration's
|
|
15
|
+
* hashed source body must equal a cataloged occurrence's `bodyHash` UNDER THE
|
|
16
|
+
* NAME the call site addressed. The old whole-catalog hash scan (any name) was
|
|
17
|
+
* removed — for an in-project declaration the correct name bucket is always one
|
|
18
|
+
* of `candidateNames` (the callee/declaration name), so the scan only ever
|
|
19
|
+
* fired on a `.d.ts` (bodiless) hash that happened to collide, fabricating
|
|
20
|
+
* phantom edges. Cross-package (`.d.ts`) resolution now goes through
|
|
21
|
+
* `resolveDeclToHash`'s export-index path, never this hasher.
|
|
22
|
+
*/
|
|
23
|
+
export declare function findCatalogEntry(decl: ts.Node, sourceFile: ts.SourceFile, catalog: Catalog, candidateNames: readonly string[]): string | null;
|
|
24
|
+
//# sourceMappingURL=find-catalog-entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-catalog-entry.d.ts","sourceRoot":"","sources":["../../src/edge-helpers/find-catalog-entry.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAsB,MAAM,oBAAoB,CAAC;AACtE,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,UAAU,EAAE,EAAE,CAAC,UAAU,EACzB,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,SAAS,MAAM,EAAE,GAChC,MAAM,GAAG,IAAI,CASf"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// @fitness-ignore-file batch-operation-limits -- iterates bounded collection (catalog entries for a single declaration site)
|
|
2
|
+
/**
|
|
3
|
+
* findCatalogEntry — locate a catalog entry's bodyHash from a TS declaration.
|
|
4
|
+
*
|
|
5
|
+
* Uses hashFunctionBody (the same function stage 1 used to populate
|
|
6
|
+
* the catalog) so a successful lookup is guaranteed when the
|
|
7
|
+
* declaration is in the project.
|
|
8
|
+
*/
|
|
9
|
+
import { hashFunctionBody } from '../inventory-helpers/hash-body.js';
|
|
10
|
+
/**
|
|
11
|
+
* Returns the bodyHash if the declaration's hash is present in the
|
|
12
|
+
* catalog under one of `candidateNames`. Returns null otherwise.
|
|
13
|
+
*
|
|
14
|
+
* Matching is strictly (candidate simple name) × (body hash): the declaration's
|
|
15
|
+
* hashed source body must equal a cataloged occurrence's `bodyHash` UNDER THE
|
|
16
|
+
* NAME the call site addressed. The old whole-catalog hash scan (any name) was
|
|
17
|
+
* removed — for an in-project declaration the correct name bucket is always one
|
|
18
|
+
* of `candidateNames` (the callee/declaration name), so the scan only ever
|
|
19
|
+
* fired on a `.d.ts` (bodiless) hash that happened to collide, fabricating
|
|
20
|
+
* phantom edges. Cross-package (`.d.ts`) resolution now goes through
|
|
21
|
+
* `resolveDeclToHash`'s export-index path, never this hasher.
|
|
22
|
+
*/
|
|
23
|
+
export function findCatalogEntry(decl, sourceFile, catalog, candidateNames) {
|
|
24
|
+
const bodyHash = hashFunctionBody(decl, sourceFile);
|
|
25
|
+
for (const name of candidateNames) {
|
|
26
|
+
const candidates = lookup(catalog, name);
|
|
27
|
+
if (!candidates)
|
|
28
|
+
continue;
|
|
29
|
+
const hit = candidates.find((c) => c.bodyHash === bodyHash);
|
|
30
|
+
if (hit)
|
|
31
|
+
return hit.bodyHash;
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
function lookup(catalog, name) {
|
|
36
|
+
// Object.hasOwn keeps us safe from accidental access to prototype
|
|
37
|
+
// properties when the catalog is keyed by an arbitrary identifier
|
|
38
|
+
// (e.g. "constructor", "toString").
|
|
39
|
+
if (!Object.hasOwn(catalog.functions, name))
|
|
40
|
+
return null;
|
|
41
|
+
const value = catalog.functions[name];
|
|
42
|
+
/* v8 ignore next */
|
|
43
|
+
return value ?? null;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=find-catalog-entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-catalog-entry.js","sourceRoot":"","sources":["../../src/edge-helpers/find-catalog-entry.ts"],"names":[],"mappings":"AAAA,6HAA6H;AAC7H;;;;;;GAMG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAKrE;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAAa,EACb,UAAyB,EACzB,OAAgB,EAChB,cAAiC;IAEjC,MAAM,QAAQ,GAAG,gBAAgB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACpD,KAAK,MAAM,IAAI,IAAI,cAAc,EAAE,CAAC;QAClC,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,UAAU;YAAE,SAAS;QAC1B,MAAM,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC;QAC5D,IAAI,GAAG;YAAE,OAAO,GAAG,CAAC,QAAQ,CAAC;IAC/B,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,MAAM,CAAC,OAAgB,EAAE,IAAY;IAC5C,kEAAkE;IAClE,kEAAkE;IAClE,oCAAoC;IACpC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACzD,MAAM,KAAK,GAA8C,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACjF,oBAAoB;IACpB,OAAO,KAAK,IAAI,IAAI,CAAC;AACvB,CAAC"}
|