mnehmos.trace.mcp 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1662 -0
- package/dist/adapters/bootstrap.d.ts +29 -0
- package/dist/adapters/bootstrap.d.ts.map +1 -0
- package/dist/adapters/bootstrap.js +46 -0
- package/dist/adapters/bootstrap.js.map +1 -0
- package/dist/adapters/errors.d.ts +94 -0
- package/dist/adapters/errors.d.ts.map +1 -0
- package/dist/adapters/errors.js +107 -0
- package/dist/adapters/errors.js.map +1 -0
- package/dist/adapters/graphql/index.d.ts +9 -0
- package/dist/adapters/graphql/index.d.ts.map +1 -0
- package/dist/adapters/graphql/index.js +9 -0
- package/dist/adapters/graphql/index.js.map +1 -0
- package/dist/adapters/graphql/sdl-parser.d.ts +74 -0
- package/dist/adapters/graphql/sdl-parser.d.ts.map +1 -0
- package/dist/adapters/graphql/sdl-parser.js +559 -0
- package/dist/adapters/graphql/sdl-parser.js.map +1 -0
- package/dist/adapters/grpc/adapter.d.ts +76 -0
- package/dist/adapters/grpc/adapter.d.ts.map +1 -0
- package/dist/adapters/grpc/adapter.js +362 -0
- package/dist/adapters/grpc/adapter.js.map +1 -0
- package/dist/adapters/grpc/index.d.ts +10 -0
- package/dist/adapters/grpc/index.d.ts.map +1 -0
- package/dist/adapters/grpc/index.js +12 -0
- package/dist/adapters/grpc/index.js.map +1 -0
- package/dist/adapters/grpc/proto-parser.d.ts +76 -0
- package/dist/adapters/grpc/proto-parser.d.ts.map +1 -0
- package/dist/adapters/grpc/proto-parser.js +523 -0
- package/dist/adapters/grpc/proto-parser.js.map +1 -0
- package/dist/adapters/grpc/type-converter.d.ts +43 -0
- package/dist/adapters/grpc/type-converter.d.ts.map +1 -0
- package/dist/adapters/grpc/type-converter.js +270 -0
- package/dist/adapters/grpc/type-converter.js.map +1 -0
- package/dist/adapters/grpc/types.d.ts +85 -0
- package/dist/adapters/grpc/types.d.ts.map +1 -0
- package/dist/adapters/grpc/types.js +7 -0
- package/dist/adapters/grpc/types.js.map +1 -0
- package/dist/adapters/index.d.ts +39 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +50 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/mcp.d.ts +23 -0
- package/dist/adapters/mcp.d.ts.map +1 -0
- package/dist/adapters/mcp.js +293 -0
- package/dist/adapters/mcp.js.map +1 -0
- package/dist/adapters/openapi/adapter.d.ts +213 -0
- package/dist/adapters/openapi/adapter.d.ts.map +1 -0
- package/dist/adapters/openapi/adapter.js +557 -0
- package/dist/adapters/openapi/adapter.js.map +1 -0
- package/dist/adapters/openapi/convert.d.ts +120 -0
- package/dist/adapters/openapi/convert.d.ts.map +1 -0
- package/dist/adapters/openapi/convert.js +363 -0
- package/dist/adapters/openapi/convert.js.map +1 -0
- package/dist/adapters/openapi/index.d.ts +39 -0
- package/dist/adapters/openapi/index.d.ts.map +1 -0
- package/dist/adapters/openapi/index.js +48 -0
- package/dist/adapters/openapi/index.js.map +1 -0
- package/dist/adapters/openapi/parser.d.ts +95 -0
- package/dist/adapters/openapi/parser.d.ts.map +1 -0
- package/dist/adapters/openapi/parser.js +171 -0
- package/dist/adapters/openapi/parser.js.map +1 -0
- package/dist/adapters/registry.d.ts +116 -0
- package/dist/adapters/registry.d.ts.map +1 -0
- package/dist/adapters/registry.js +246 -0
- package/dist/adapters/registry.js.map +1 -0
- package/dist/adapters/trpc/adapter.d.ts +159 -0
- package/dist/adapters/trpc/adapter.d.ts.map +1 -0
- package/dist/adapters/trpc/adapter.js +223 -0
- package/dist/adapters/trpc/adapter.js.map +1 -0
- package/dist/adapters/trpc/extractor.d.ts +218 -0
- package/dist/adapters/trpc/extractor.d.ts.map +1 -0
- package/dist/adapters/trpc/extractor.js +708 -0
- package/dist/adapters/trpc/extractor.js.map +1 -0
- package/dist/adapters/trpc/index.d.ts +31 -0
- package/dist/adapters/trpc/index.d.ts.map +1 -0
- package/dist/adapters/trpc/index.js +40 -0
- package/dist/adapters/trpc/index.js.map +1 -0
- package/dist/adapters/trpc/parser.d.ts +119 -0
- package/dist/adapters/trpc/parser.d.ts.map +1 -0
- package/dist/adapters/trpc/parser.js +128 -0
- package/dist/adapters/trpc/parser.js.map +1 -0
- package/dist/compare/index.d.ts +33 -0
- package/dist/compare/index.d.ts.map +1 -0
- package/dist/compare/index.js +261 -0
- package/dist/compare/index.js.map +1 -0
- package/dist/core/types.d.ts +188 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +9 -0
- package/dist/core/types.js.map +1 -0
- package/dist/extract/index.d.ts +26 -0
- package/dist/extract/index.d.ts.map +1 -0
- package/dist/extract/index.js +44 -0
- package/dist/extract/index.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +674 -0
- package/dist/index.js.map +1 -0
- package/dist/languages/base.d.ts +57 -0
- package/dist/languages/base.d.ts.map +1 -0
- package/dist/languages/base.js +6 -0
- package/dist/languages/base.js.map +1 -0
- package/dist/languages/bootstrap.d.ts +10 -0
- package/dist/languages/bootstrap.d.ts.map +1 -0
- package/dist/languages/bootstrap.js +25 -0
- package/dist/languages/bootstrap.js.map +1 -0
- package/dist/languages/go/handlers/chi.d.ts +24 -0
- package/dist/languages/go/handlers/chi.d.ts.map +1 -0
- package/dist/languages/go/handlers/chi.js +205 -0
- package/dist/languages/go/handlers/chi.js.map +1 -0
- package/dist/languages/go/handlers/gin.d.ts +24 -0
- package/dist/languages/go/handlers/gin.d.ts.map +1 -0
- package/dist/languages/go/handlers/gin.js +156 -0
- package/dist/languages/go/handlers/gin.js.map +1 -0
- package/dist/languages/go/handlers/stdlib.d.ts +19 -0
- package/dist/languages/go/handlers/stdlib.d.ts.map +1 -0
- package/dist/languages/go/handlers/stdlib.js +112 -0
- package/dist/languages/go/handlers/stdlib.js.map +1 -0
- package/dist/languages/go/index.d.ts +18 -0
- package/dist/languages/go/index.d.ts.map +1 -0
- package/dist/languages/go/index.js +20 -0
- package/dist/languages/go/index.js.map +1 -0
- package/dist/languages/go/parser.d.ts +33 -0
- package/dist/languages/go/parser.d.ts.map +1 -0
- package/dist/languages/go/parser.js +95 -0
- package/dist/languages/go/parser.js.map +1 -0
- package/dist/languages/go/struct-extractor.d.ts +59 -0
- package/dist/languages/go/struct-extractor.d.ts.map +1 -0
- package/dist/languages/go/struct-extractor.js +483 -0
- package/dist/languages/go/struct-extractor.js.map +1 -0
- package/dist/languages/go/tag-parser.d.ts +62 -0
- package/dist/languages/go/tag-parser.d.ts.map +1 -0
- package/dist/languages/go/tag-parser.js +108 -0
- package/dist/languages/go/tag-parser.js.map +1 -0
- package/dist/languages/go/type-converter.d.ts +32 -0
- package/dist/languages/go/type-converter.d.ts.map +1 -0
- package/dist/languages/go/type-converter.js +226 -0
- package/dist/languages/go/type-converter.js.map +1 -0
- package/dist/languages/go/types.d.ts +153 -0
- package/dist/languages/go/types.d.ts.map +1 -0
- package/dist/languages/go/types.js +6 -0
- package/dist/languages/go/types.js.map +1 -0
- package/dist/languages/import-resolver.d.ts +645 -0
- package/dist/languages/import-resolver.d.ts.map +1 -0
- package/dist/languages/import-resolver.js +1278 -0
- package/dist/languages/import-resolver.js.map +1 -0
- package/dist/languages/index.d.ts +34 -0
- package/dist/languages/index.d.ts.map +1 -0
- package/dist/languages/index.js +93 -0
- package/dist/languages/index.js.map +1 -0
- package/dist/languages/json-schema.d.ts +40 -0
- package/dist/languages/json-schema.d.ts.map +1 -0
- package/dist/languages/json-schema.js +188 -0
- package/dist/languages/json-schema.js.map +1 -0
- package/dist/languages/python-ast/index.d.ts +8 -0
- package/dist/languages/python-ast/index.d.ts.map +1 -0
- package/dist/languages/python-ast/index.js +7 -0
- package/dist/languages/python-ast/index.js.map +1 -0
- package/dist/languages/python-ast/parser.d.ts +174 -0
- package/dist/languages/python-ast/parser.d.ts.map +1 -0
- package/dist/languages/python-ast/parser.js +1205 -0
- package/dist/languages/python-ast/parser.js.map +1 -0
- package/dist/languages/python-ast/type-resolver.d.ts +75 -0
- package/dist/languages/python-ast/type-resolver.d.ts.map +1 -0
- package/dist/languages/python-ast/type-resolver.js +421 -0
- package/dist/languages/python-ast/type-resolver.js.map +1 -0
- package/dist/languages/python-ast/types.d.ts +216 -0
- package/dist/languages/python-ast/types.d.ts.map +1 -0
- package/dist/languages/python-ast/types.js +6 -0
- package/dist/languages/python-ast/types.js.map +1 -0
- package/dist/languages/python.d.ts +55 -0
- package/dist/languages/python.d.ts.map +1 -0
- package/dist/languages/python.js +311 -0
- package/dist/languages/python.js.map +1 -0
- package/dist/languages/typescript.d.ts +272 -0
- package/dist/languages/typescript.d.ts.map +1 -0
- package/dist/languages/typescript.js +1381 -0
- package/dist/languages/typescript.js.map +1 -0
- package/dist/patterns/base.d.ts +146 -0
- package/dist/patterns/base.d.ts.map +1 -0
- package/dist/patterns/base.js +89 -0
- package/dist/patterns/base.js.map +1 -0
- package/dist/patterns/errors.d.ts +172 -0
- package/dist/patterns/errors.d.ts.map +1 -0
- package/dist/patterns/errors.js +185 -0
- package/dist/patterns/errors.js.map +1 -0
- package/dist/patterns/extractors.d.ts +170 -0
- package/dist/patterns/extractors.d.ts.map +1 -0
- package/dist/patterns/extractors.js +305 -0
- package/dist/patterns/extractors.js.map +1 -0
- package/dist/patterns/graphql/apollo-client.d.ts +80 -0
- package/dist/patterns/graphql/apollo-client.d.ts.map +1 -0
- package/dist/patterns/graphql/apollo-client.js +800 -0
- package/dist/patterns/graphql/apollo-client.js.map +1 -0
- package/dist/patterns/graphql/apollo-server.d.ts +55 -0
- package/dist/patterns/graphql/apollo-server.d.ts.map +1 -0
- package/dist/patterns/graphql/apollo-server.js +523 -0
- package/dist/patterns/graphql/apollo-server.js.map +1 -0
- package/dist/patterns/graphql/index.d.ts +11 -0
- package/dist/patterns/graphql/index.d.ts.map +1 -0
- package/dist/patterns/graphql/index.js +12 -0
- package/dist/patterns/graphql/index.js.map +1 -0
- package/dist/patterns/graphql/types.d.ts +213 -0
- package/dist/patterns/graphql/types.d.ts.map +1 -0
- package/dist/patterns/graphql/types.js +16 -0
- package/dist/patterns/graphql/types.js.map +1 -0
- package/dist/patterns/http-clients/axios.d.ts +148 -0
- package/dist/patterns/http-clients/axios.d.ts.map +1 -0
- package/dist/patterns/http-clients/axios.js +652 -0
- package/dist/patterns/http-clients/axios.js.map +1 -0
- package/dist/patterns/http-clients/fetch.d.ts +88 -0
- package/dist/patterns/http-clients/fetch.d.ts.map +1 -0
- package/dist/patterns/http-clients/fetch.js +364 -0
- package/dist/patterns/http-clients/fetch.js.map +1 -0
- package/dist/patterns/http-clients/index.d.ts +36 -0
- package/dist/patterns/http-clients/index.d.ts.map +1 -0
- package/dist/patterns/http-clients/index.js +50 -0
- package/dist/patterns/http-clients/index.js.map +1 -0
- package/dist/patterns/http-clients/property-access.d.ts +46 -0
- package/dist/patterns/http-clients/property-access.d.ts.map +1 -0
- package/dist/patterns/http-clients/property-access.js +818 -0
- package/dist/patterns/http-clients/property-access.js.map +1 -0
- package/dist/patterns/http-clients/type-inference.d.ts +48 -0
- package/dist/patterns/http-clients/type-inference.d.ts.map +1 -0
- package/dist/patterns/http-clients/type-inference.js +293 -0
- package/dist/patterns/http-clients/type-inference.js.map +1 -0
- package/dist/patterns/http-clients/types.d.ts +168 -0
- package/dist/patterns/http-clients/types.d.ts.map +1 -0
- package/dist/patterns/http-clients/types.js +10 -0
- package/dist/patterns/http-clients/types.js.map +1 -0
- package/dist/patterns/http-clients/url-extractor.d.ts +53 -0
- package/dist/patterns/http-clients/url-extractor.d.ts.map +1 -0
- package/dist/patterns/http-clients/url-extractor.js +338 -0
- package/dist/patterns/http-clients/url-extractor.js.map +1 -0
- package/dist/patterns/index.d.ts +44 -0
- package/dist/patterns/index.d.ts.map +1 -0
- package/dist/patterns/index.js +49 -0
- package/dist/patterns/index.js.map +1 -0
- package/dist/patterns/python/aiohttp.d.ts +21 -0
- package/dist/patterns/python/aiohttp.d.ts.map +1 -0
- package/dist/patterns/python/aiohttp.js +188 -0
- package/dist/patterns/python/aiohttp.js.map +1 -0
- package/dist/patterns/python/httpx.d.ts +20 -0
- package/dist/patterns/python/httpx.d.ts.map +1 -0
- package/dist/patterns/python/httpx.js +183 -0
- package/dist/patterns/python/httpx.js.map +1 -0
- package/dist/patterns/python/index.d.ts +32 -0
- package/dist/patterns/python/index.d.ts.map +1 -0
- package/dist/patterns/python/index.js +63 -0
- package/dist/patterns/python/index.js.map +1 -0
- package/dist/patterns/python/property-access.d.ts +27 -0
- package/dist/patterns/python/property-access.d.ts.map +1 -0
- package/dist/patterns/python/property-access.js +132 -0
- package/dist/patterns/python/property-access.js.map +1 -0
- package/dist/patterns/python/requests.d.ts +19 -0
- package/dist/patterns/python/requests.d.ts.map +1 -0
- package/dist/patterns/python/requests.js +239 -0
- package/dist/patterns/python/requests.js.map +1 -0
- package/dist/patterns/python/types.d.ts +95 -0
- package/dist/patterns/python/types.d.ts.map +1 -0
- package/dist/patterns/python/types.js +43 -0
- package/dist/patterns/python/types.js.map +1 -0
- package/dist/patterns/registry.d.ts +181 -0
- package/dist/patterns/registry.d.ts.map +1 -0
- package/dist/patterns/registry.js +304 -0
- package/dist/patterns/registry.js.map +1 -0
- package/dist/patterns/rest/express.d.ts +78 -0
- package/dist/patterns/rest/express.d.ts.map +1 -0
- package/dist/patterns/rest/express.js +289 -0
- package/dist/patterns/rest/express.js.map +1 -0
- package/dist/patterns/rest/fastify.d.ts +93 -0
- package/dist/patterns/rest/fastify.d.ts.map +1 -0
- package/dist/patterns/rest/fastify.js +420 -0
- package/dist/patterns/rest/fastify.js.map +1 -0
- package/dist/patterns/rest/index.d.ts +31 -0
- package/dist/patterns/rest/index.d.ts.map +1 -0
- package/dist/patterns/rest/index.js +45 -0
- package/dist/patterns/rest/index.js.map +1 -0
- package/dist/patterns/rest/middleware.d.ts +25 -0
- package/dist/patterns/rest/middleware.d.ts.map +1 -0
- package/dist/patterns/rest/middleware.js +219 -0
- package/dist/patterns/rest/middleware.js.map +1 -0
- package/dist/patterns/rest/path-parser.d.ts +50 -0
- package/dist/patterns/rest/path-parser.d.ts.map +1 -0
- package/dist/patterns/rest/path-parser.js +137 -0
- package/dist/patterns/rest/path-parser.js.map +1 -0
- package/dist/patterns/rest/response-inference.d.ts +44 -0
- package/dist/patterns/rest/response-inference.d.ts.map +1 -0
- package/dist/patterns/rest/response-inference.js +218 -0
- package/dist/patterns/rest/response-inference.js.map +1 -0
- package/dist/patterns/rest/types.d.ts +102 -0
- package/dist/patterns/rest/types.d.ts.map +1 -0
- package/dist/patterns/rest/types.js +10 -0
- package/dist/patterns/rest/types.js.map +1 -0
- package/dist/patterns/types.d.ts +105 -0
- package/dist/patterns/types.d.ts.map +1 -0
- package/dist/patterns/types.js +11 -0
- package/dist/patterns/types.js.map +1 -0
- package/dist/report/index.d.ts +11 -0
- package/dist/report/index.d.ts.map +1 -0
- package/dist/report/index.js +55 -0
- package/dist/report/index.js.map +1 -0
- package/dist/tools/contract-comments.d.ts +48 -0
- package/dist/tools/contract-comments.d.ts.map +1 -0
- package/dist/tools/contract-comments.js +130 -0
- package/dist/tools/contract-comments.js.map +1 -0
- package/dist/tools/index.d.ts +6 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +6 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/scaffold.d.ts +38 -0
- package/dist/tools/scaffold.d.ts.map +1 -0
- package/dist/tools/scaffold.js +373 -0
- package/dist/tools/scaffold.js.map +1 -0
- package/dist/trace/index.d.ts +28 -0
- package/dist/trace/index.d.ts.map +1 -0
- package/dist/trace/index.js +45 -0
- package/dist/trace/index.js.map +1 -0
- package/dist/types.d.ts +135 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +22 -0
- package/dist/types.js.map +1 -0
- package/dist/watch/cache.d.ts +41 -0
- package/dist/watch/cache.d.ts.map +1 -0
- package/dist/watch/cache.js +230 -0
- package/dist/watch/cache.js.map +1 -0
- package/dist/watch/index.d.ts +9 -0
- package/dist/watch/index.d.ts.map +1 -0
- package/dist/watch/index.js +7 -0
- package/dist/watch/index.js.map +1 -0
- package/dist/watch/project.d.ts +128 -0
- package/dist/watch/project.d.ts.map +1 -0
- package/dist/watch/project.js +152 -0
- package/dist/watch/project.js.map +1 -0
- package/dist/watch/watcher.d.ts +76 -0
- package/dist/watch/watcher.d.ts.map +1 -0
- package/dist/watch/watcher.js +235 -0
- package/dist/watch/watcher.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,645 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 🔗 Cross-File Import Resolution for TypeScript Projects
|
|
3
|
+
*
|
|
4
|
+
* This module provides comprehensive import resolution capabilities for TypeScript
|
|
5
|
+
* projects, including:
|
|
6
|
+
* - Relative import resolution (./foo, ../bar)
|
|
7
|
+
* - tsconfig.json path alias resolution (@/utils, models)
|
|
8
|
+
* - Re-export chain following (export * from, export { X } from)
|
|
9
|
+
* - Circular reference detection
|
|
10
|
+
* - Import graph building for visualization
|
|
11
|
+
*
|
|
12
|
+
* @module import-resolver
|
|
13
|
+
* @see ADR Reference: .context/ADR-P2-5-IMPORT-RESOLUTION.md
|
|
14
|
+
*
|
|
15
|
+
* @example Basic Usage
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { ImportResolverImpl } from './import-resolver.js';
|
|
18
|
+
*
|
|
19
|
+
* const resolver = new ImportResolverImpl({
|
|
20
|
+
* tsConfigPath: './tsconfig.json',
|
|
21
|
+
* maxReexportDepth: 10,
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* // Resolve an import
|
|
25
|
+
* const result = resolver.resolve('./types', '/project/src/index.ts');
|
|
26
|
+
*
|
|
27
|
+
* // Get all exported types from a file
|
|
28
|
+
* const types = resolver.getExportedTypes('/project/src/types/index.ts');
|
|
29
|
+
*
|
|
30
|
+
* // Resolve a specific type reference
|
|
31
|
+
* const typeRef = resolver.resolveTypeRef('User', '/project/src/handlers/user.ts');
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
import { SourceFile } from 'ts-morph';
|
|
35
|
+
import type { NormalizedType } from '../core/types.js';
|
|
36
|
+
/**
|
|
37
|
+
* Result of resolving an import specifier to a file path.
|
|
38
|
+
*
|
|
39
|
+
* This interface represents the complete result of import resolution,
|
|
40
|
+
* including the resolved file path, export information, and the parsed
|
|
41
|
+
* source file for further analysis.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* const result: ResolvedImport = {
|
|
46
|
+
* filePath: '/project/src/types/user.ts',
|
|
47
|
+
* exportName: 'User',
|
|
48
|
+
* isDefault: false,
|
|
49
|
+
* isNamespace: false,
|
|
50
|
+
* isTypeOnly: true,
|
|
51
|
+
* originalSpecifier: './types/user',
|
|
52
|
+
* };
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export interface ResolvedImport {
|
|
56
|
+
/** Absolute path to the resolved file */
|
|
57
|
+
filePath: string;
|
|
58
|
+
/** The export name (or 'default' for default exports, '*' for namespace) */
|
|
59
|
+
exportName: string;
|
|
60
|
+
/** Whether this is a default import (`import X from '...'`) */
|
|
61
|
+
isDefault: boolean;
|
|
62
|
+
/** Whether this is a namespace import (`import * as X from '...'`) */
|
|
63
|
+
isNamespace: boolean;
|
|
64
|
+
/** Whether this is a type-only import (`import type { X } from '...'`) */
|
|
65
|
+
isTypeOnly: boolean;
|
|
66
|
+
/** The source file containing the export (if successfully parsed) */
|
|
67
|
+
sourceFile?: SourceFile;
|
|
68
|
+
/** Original import specifier for debugging and error messages */
|
|
69
|
+
originalSpecifier: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Result of resolving a type reference across files.
|
|
73
|
+
*
|
|
74
|
+
* When resolving a type like `User` from a handler file, this interface
|
|
75
|
+
* provides the fully resolved type definition, the file where it's defined,
|
|
76
|
+
* and the chain of re-exports that were followed to find it.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* const result: ResolvedTypeRef = {
|
|
81
|
+
* type: { kind: 'object', schema: { name: 'User', properties: {...} } },
|
|
82
|
+
* definitionFile: '/project/src/types/user.ts',
|
|
83
|
+
* definitionLine: 5,
|
|
84
|
+
* reexportChain: ['/project/src/types/index.ts'],
|
|
85
|
+
* complete: true,
|
|
86
|
+
* };
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export interface ResolvedTypeRef {
|
|
90
|
+
/** The fully resolved type in NormalizedType format */
|
|
91
|
+
type: NormalizedType;
|
|
92
|
+
/** Absolute path to the file where the type is defined */
|
|
93
|
+
definitionFile: string;
|
|
94
|
+
/** Line number of the type definition (1-indexed) */
|
|
95
|
+
definitionLine: number;
|
|
96
|
+
/** Chain of re-export files traversed to reach the definition */
|
|
97
|
+
reexportChain: string[];
|
|
98
|
+
/** Whether resolution was complete or partial */
|
|
99
|
+
complete: boolean;
|
|
100
|
+
/** Reason if resolution was incomplete (e.g., circular reference, max depth) */
|
|
101
|
+
incompleteReason?: string;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Configuration options for the import resolver.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```typescript
|
|
108
|
+
* const config: ImportResolverConfig = {
|
|
109
|
+
* tsConfigPath: './tsconfig.json',
|
|
110
|
+
* maxReexportDepth: 15,
|
|
111
|
+
* maxCacheSize: 1000,
|
|
112
|
+
* includeNodeModules: false,
|
|
113
|
+
* };
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
export interface ImportResolverConfig {
|
|
117
|
+
/**
|
|
118
|
+
* Path to tsconfig.json file.
|
|
119
|
+
* Enables path alias resolution using `compilerOptions.paths` and `baseUrl`.
|
|
120
|
+
*/
|
|
121
|
+
tsConfigPath?: string;
|
|
122
|
+
/**
|
|
123
|
+
* Maximum depth for re-export chain resolution.
|
|
124
|
+
* Prevents infinite loops in complex re-export scenarios.
|
|
125
|
+
* @default 10
|
|
126
|
+
*/
|
|
127
|
+
maxReexportDepth?: number;
|
|
128
|
+
/**
|
|
129
|
+
* Maximum number of entries in the file cache (LRU eviction).
|
|
130
|
+
* Higher values use more memory but improve performance.
|
|
131
|
+
* @default 500
|
|
132
|
+
*/
|
|
133
|
+
maxCacheSize?: number;
|
|
134
|
+
/**
|
|
135
|
+
* Whether to resolve imports from node_modules.
|
|
136
|
+
* When false, third-party package imports return null.
|
|
137
|
+
* @default false
|
|
138
|
+
*/
|
|
139
|
+
includeNodeModules?: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Custom module resolution path mappings.
|
|
142
|
+
* Alternative to tsconfig.json paths for dynamic configuration.
|
|
143
|
+
*/
|
|
144
|
+
pathMappings?: Record<string, string[]>;
|
|
145
|
+
/**
|
|
146
|
+
* Base directory for relative path resolution.
|
|
147
|
+
* Defaults to the directory containing the source file.
|
|
148
|
+
*/
|
|
149
|
+
baseDir?: string;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Node in an import dependency graph.
|
|
153
|
+
*
|
|
154
|
+
* Represents a file and its import/export relationships for visualization
|
|
155
|
+
* and dependency analysis.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* const node: ImportGraphNode = {
|
|
160
|
+
* filePath: '/project/src/handlers/user.ts',
|
|
161
|
+
* imports: [
|
|
162
|
+
* { specifier: '../types', resolved: '/project/src/types/index.ts', names: ['User'] },
|
|
163
|
+
* ],
|
|
164
|
+
* exports: ['getUserHandler', 'createUserHandler'],
|
|
165
|
+
* children: [...], // Recursive nodes for imported files
|
|
166
|
+
* };
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
export interface ImportGraphNode {
|
|
170
|
+
/** Absolute path to this file */
|
|
171
|
+
filePath: string;
|
|
172
|
+
/** List of imports in this file */
|
|
173
|
+
imports: Array<{
|
|
174
|
+
/** Original import specifier (e.g., '../types', '@/utils') */
|
|
175
|
+
specifier: string;
|
|
176
|
+
/** Resolved absolute path, or null if unresolvable */
|
|
177
|
+
resolved: string | null;
|
|
178
|
+
/** Names imported from this specifier */
|
|
179
|
+
names: string[];
|
|
180
|
+
}>;
|
|
181
|
+
/** List of exported type/value names from this file */
|
|
182
|
+
exports: string[];
|
|
183
|
+
/** Child nodes for imported files (when depth > 0) */
|
|
184
|
+
children?: ImportGraphNode[];
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Statistics about the file cache performance.
|
|
188
|
+
*
|
|
189
|
+
* Use this to monitor cache effectiveness and tune `maxCacheSize`.
|
|
190
|
+
*/
|
|
191
|
+
export interface CacheStats {
|
|
192
|
+
/** Current number of cached entries */
|
|
193
|
+
size: number;
|
|
194
|
+
/** Maximum cache capacity */
|
|
195
|
+
maxSize: number;
|
|
196
|
+
/** Number of cache hits (successful lookups) */
|
|
197
|
+
hits: number;
|
|
198
|
+
/** Number of cache misses (new file parses required) */
|
|
199
|
+
misses: number;
|
|
200
|
+
/** Cache hit rate as a decimal (0.0 to 1.0) */
|
|
201
|
+
hitRate: number;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Import resolution engine interface.
|
|
205
|
+
*
|
|
206
|
+
* Provides methods for resolving TypeScript imports, extracting exported types,
|
|
207
|
+
* and building import dependency graphs.
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```typescript
|
|
211
|
+
* const resolver: ImportResolver = new ImportResolverImpl({
|
|
212
|
+
* tsConfigPath: './tsconfig.json',
|
|
213
|
+
* });
|
|
214
|
+
*
|
|
215
|
+
* // Resolve a relative import
|
|
216
|
+
* const resolved = resolver.resolve('./types', '/project/src/index.ts');
|
|
217
|
+
*
|
|
218
|
+
* // Get exported types
|
|
219
|
+
* const types = resolver.getExportedTypes('/project/src/types/index.ts');
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
export interface ImportResolver {
|
|
223
|
+
/**
|
|
224
|
+
* Resolves an import specifier from a source file.
|
|
225
|
+
*
|
|
226
|
+
* @param importPath - The import specifier (e.g., './types', '@/utils', 'lodash')
|
|
227
|
+
* @param fromFile - Absolute path to the file containing the import
|
|
228
|
+
* @returns Resolved import info, or null if unresolvable
|
|
229
|
+
*
|
|
230
|
+
* @example
|
|
231
|
+
* ```typescript
|
|
232
|
+
* const result = resolver.resolve('./types/user', '/project/src/handlers/index.ts');
|
|
233
|
+
* // result.filePath === '/project/src/types/user.ts'
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
resolve(importPath: string, fromFile: string): ResolvedImport | null;
|
|
237
|
+
/**
|
|
238
|
+
* Gets all exported types from a file.
|
|
239
|
+
*
|
|
240
|
+
* Includes both direct exports and re-exports from other modules.
|
|
241
|
+
*
|
|
242
|
+
* @param filePath - Absolute path to the file
|
|
243
|
+
* @returns Map of export name to NormalizedType
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* ```typescript
|
|
247
|
+
* const types = resolver.getExportedTypes('/project/src/types/index.ts');
|
|
248
|
+
* // types.get('User') => { kind: 'object', schema: {...} }
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
getExportedTypes(filePath: string): Map<string, NormalizedType>;
|
|
252
|
+
/**
|
|
253
|
+
* Resolves a type reference following imports and re-exports.
|
|
254
|
+
*
|
|
255
|
+
* Starting from a source file, follows the import chain to find
|
|
256
|
+
* where a type is actually defined.
|
|
257
|
+
*
|
|
258
|
+
* @param typeName - Name of the type to resolve
|
|
259
|
+
* @param fromFile - Absolute path to the file using the type
|
|
260
|
+
* @returns Resolved type reference, or null if not found
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
* ```typescript
|
|
264
|
+
* const ref = resolver.resolveTypeRef('User', '/project/src/handlers/user.ts');
|
|
265
|
+
* // ref.definitionFile === '/project/src/types/user.ts'
|
|
266
|
+
* // ref.reexportChain === ['/project/src/types/index.ts']
|
|
267
|
+
* ```
|
|
268
|
+
*/
|
|
269
|
+
resolveTypeRef(typeName: string, fromFile: string): ResolvedTypeRef | null;
|
|
270
|
+
/**
|
|
271
|
+
* Gets the import graph for a file.
|
|
272
|
+
*
|
|
273
|
+
* Builds a tree of import dependencies for visualization or analysis.
|
|
274
|
+
*
|
|
275
|
+
* @param filePath - Absolute path to the root file
|
|
276
|
+
* @param depth - How deep to traverse (default: 1)
|
|
277
|
+
* @returns Import graph node with children
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* ```typescript
|
|
281
|
+
* const graph = resolver.getImportGraph('/project/src/index.ts', 2);
|
|
282
|
+
* // graph.imports => [{ specifier: './handlers', resolved: '...', names: [...] }]
|
|
283
|
+
* // graph.children => [{ filePath: '...', imports: [...], ... }]
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
286
|
+
getImportGraph(filePath: string, depth?: number): ImportGraphNode;
|
|
287
|
+
/**
|
|
288
|
+
* Clears all cached data.
|
|
289
|
+
*
|
|
290
|
+
* Use after making changes to source files to ensure fresh parsing.
|
|
291
|
+
*/
|
|
292
|
+
clearCache(): void;
|
|
293
|
+
/**
|
|
294
|
+
* Gets cache performance statistics.
|
|
295
|
+
*
|
|
296
|
+
* @returns Current cache statistics
|
|
297
|
+
*
|
|
298
|
+
* @example
|
|
299
|
+
* ```typescript
|
|
300
|
+
* const stats = resolver.getCacheStats();
|
|
301
|
+
* console.log(`Cache hit rate: ${(stats.hitRate * 100).toFixed(1)}%`);
|
|
302
|
+
* ```
|
|
303
|
+
*/
|
|
304
|
+
getCacheStats(): CacheStats;
|
|
305
|
+
/**
|
|
306
|
+
* Warms the cache by pre-loading files matching patterns.
|
|
307
|
+
*
|
|
308
|
+
* Use before batch operations to improve performance.
|
|
309
|
+
*
|
|
310
|
+
* @param patterns - Glob patterns for files to pre-load
|
|
311
|
+
*
|
|
312
|
+
* @example
|
|
313
|
+
* ```typescript
|
|
314
|
+
* await resolver.warmCache(['src/**\/*.ts', 'lib/**\/*.ts']);
|
|
315
|
+
* ```
|
|
316
|
+
*/
|
|
317
|
+
warmCache(patterns: string[]): Promise<void>;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Cached data for a parsed TypeScript file.
|
|
321
|
+
* @internal
|
|
322
|
+
*/
|
|
323
|
+
interface CacheEntry {
|
|
324
|
+
/** Parsed ts-morph source file */
|
|
325
|
+
sourceFile: SourceFile;
|
|
326
|
+
/** Exported types (lazily computed on first access) */
|
|
327
|
+
exportedTypes?: Map<string, NormalizedType>;
|
|
328
|
+
/** File modification time for cache invalidation */
|
|
329
|
+
mtime: number;
|
|
330
|
+
/** Timestamp when this entry was created */
|
|
331
|
+
cachedAt: number;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* LRU (Least Recently Used) Cache for parsed TypeScript files.
|
|
335
|
+
*
|
|
336
|
+
* Provides efficient caching with automatic eviction of least-recently-used
|
|
337
|
+
* entries when the cache reaches capacity.
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* ```typescript
|
|
341
|
+
* const cache = new FileCache(100);
|
|
342
|
+
* cache.set('/path/to/file.ts', { sourceFile, mtime: Date.now(), cachedAt: Date.now() });
|
|
343
|
+
* const entry = cache.get('/path/to/file.ts');
|
|
344
|
+
* ```
|
|
345
|
+
*/
|
|
346
|
+
export declare class FileCache {
|
|
347
|
+
private cache;
|
|
348
|
+
private accessOrder;
|
|
349
|
+
private readonly maxSize;
|
|
350
|
+
private hits;
|
|
351
|
+
private misses;
|
|
352
|
+
/**
|
|
353
|
+
* Creates a new FileCache instance.
|
|
354
|
+
*
|
|
355
|
+
* @param maxSize - Maximum number of entries before LRU eviction (default: 500)
|
|
356
|
+
*/
|
|
357
|
+
constructor(maxSize?: number);
|
|
358
|
+
/**
|
|
359
|
+
* Gets a cached entry, updating its access order.
|
|
360
|
+
*
|
|
361
|
+
* @param filePath - Absolute path to the file
|
|
362
|
+
* @returns Cached entry, or undefined if not cached
|
|
363
|
+
*/
|
|
364
|
+
get(filePath: string): CacheEntry | undefined;
|
|
365
|
+
/**
|
|
366
|
+
* Sets a cache entry, evicting LRU entries if at capacity.
|
|
367
|
+
*
|
|
368
|
+
* @param filePath - Absolute path to the file
|
|
369
|
+
* @param entry - Cache entry to store
|
|
370
|
+
*/
|
|
371
|
+
set(filePath: string, entry: CacheEntry): void;
|
|
372
|
+
/**
|
|
373
|
+
* Invalidates a cache entry for a modified file.
|
|
374
|
+
*
|
|
375
|
+
* @param filePath - Absolute path to the file to invalidate
|
|
376
|
+
*/
|
|
377
|
+
invalidate(filePath: string): void;
|
|
378
|
+
/**
|
|
379
|
+
* Clears all cached data and resets statistics.
|
|
380
|
+
*/
|
|
381
|
+
clear(): void;
|
|
382
|
+
/**
|
|
383
|
+
* Gets cache performance statistics.
|
|
384
|
+
*
|
|
385
|
+
* @returns Cache statistics including hit rate
|
|
386
|
+
*/
|
|
387
|
+
getStats(): CacheStats;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Implementation of the ImportResolver interface.
|
|
391
|
+
*
|
|
392
|
+
* Provides comprehensive import resolution for TypeScript projects including:
|
|
393
|
+
* - Relative import resolution with extension probing
|
|
394
|
+
* - tsconfig.json path alias resolution
|
|
395
|
+
* - Re-export chain following
|
|
396
|
+
* - Circular reference detection
|
|
397
|
+
* - LRU caching for performance
|
|
398
|
+
*
|
|
399
|
+
* @example
|
|
400
|
+
* ```typescript
|
|
401
|
+
* const resolver = new ImportResolverImpl({
|
|
402
|
+
* tsConfigPath: './tsconfig.json',
|
|
403
|
+
* maxReexportDepth: 15,
|
|
404
|
+
* maxCacheSize: 1000,
|
|
405
|
+
* });
|
|
406
|
+
*
|
|
407
|
+
* // Resolve an import
|
|
408
|
+
* const result = resolver.resolve('./types', '/project/src/index.ts');
|
|
409
|
+
* if (result) {
|
|
410
|
+
* console.log(`Resolved to: ${result.filePath}`);
|
|
411
|
+
* }
|
|
412
|
+
*
|
|
413
|
+
* // Get all exported types
|
|
414
|
+
* const types = resolver.getExportedTypes('/project/src/types/index.ts');
|
|
415
|
+
* for (const [name, type] of types) {
|
|
416
|
+
* console.log(`Export: ${name} (${type.kind})`);
|
|
417
|
+
* }
|
|
418
|
+
* ```
|
|
419
|
+
*/
|
|
420
|
+
export declare class ImportResolverImpl implements ImportResolver {
|
|
421
|
+
private config;
|
|
422
|
+
private cache;
|
|
423
|
+
private project;
|
|
424
|
+
private tsConfigPaths;
|
|
425
|
+
private tsConfigDir;
|
|
426
|
+
/**
|
|
427
|
+
* Creates a new ImportResolverImpl instance.
|
|
428
|
+
*
|
|
429
|
+
* @param config - Configuration options for the resolver
|
|
430
|
+
*
|
|
431
|
+
* @example
|
|
432
|
+
* ```typescript
|
|
433
|
+
* const resolver = new ImportResolverImpl({
|
|
434
|
+
* tsConfigPath: './tsconfig.json',
|
|
435
|
+
* maxCacheSize: 1000,
|
|
436
|
+
* });
|
|
437
|
+
* ```
|
|
438
|
+
*/
|
|
439
|
+
constructor(config?: ImportResolverConfig);
|
|
440
|
+
/**
|
|
441
|
+
* Resolves an import specifier from a source file.
|
|
442
|
+
*
|
|
443
|
+
* Handles relative imports, path aliases, and baseUrl resolution.
|
|
444
|
+
* Returns null for node_modules imports unless `includeNodeModules` is true.
|
|
445
|
+
*
|
|
446
|
+
* @param importPath - The import specifier (e.g., './types', '@/utils')
|
|
447
|
+
* @param fromFile - Absolute path to the file containing the import
|
|
448
|
+
* @returns Resolved import info, or null if unresolvable
|
|
449
|
+
*/
|
|
450
|
+
resolve(importPath: string, fromFile: string): ResolvedImport | null;
|
|
451
|
+
/**
|
|
452
|
+
* Gets all exported types from a file.
|
|
453
|
+
*
|
|
454
|
+
* Collects direct exports (interfaces, type aliases, enums) and follows
|
|
455
|
+
* re-export chains to gather all publicly available types.
|
|
456
|
+
*
|
|
457
|
+
* @param filePath - Absolute path to the file
|
|
458
|
+
* @returns Map of export name to NormalizedType
|
|
459
|
+
*/
|
|
460
|
+
getExportedTypes(filePath: string): Map<string, NormalizedType>;
|
|
461
|
+
/**
|
|
462
|
+
* Resolves a type reference following imports and re-exports.
|
|
463
|
+
*
|
|
464
|
+
* Starting from a source file, traces the import chain to find where
|
|
465
|
+
* a type is actually defined, handling re-exports and aliases.
|
|
466
|
+
*
|
|
467
|
+
* @param typeName - Name of the type to resolve
|
|
468
|
+
* @param fromFile - Absolute path to the file using the type
|
|
469
|
+
* @returns Resolved type reference, or null if not found
|
|
470
|
+
*/
|
|
471
|
+
resolveTypeRef(typeName: string, fromFile: string): ResolvedTypeRef | null;
|
|
472
|
+
/**
|
|
473
|
+
* Gets the import graph for a file.
|
|
474
|
+
*
|
|
475
|
+
* Builds a tree structure showing all import dependencies, useful for
|
|
476
|
+
* visualization and dependency analysis.
|
|
477
|
+
*
|
|
478
|
+
* @param filePath - Absolute path to the root file
|
|
479
|
+
* @param depth - How deep to traverse (default: 1)
|
|
480
|
+
* @returns Import graph node with children
|
|
481
|
+
*/
|
|
482
|
+
getImportGraph(filePath: string, depth?: number): ImportGraphNode;
|
|
483
|
+
/**
|
|
484
|
+
* Clears all cached data.
|
|
485
|
+
*
|
|
486
|
+
* Use after making changes to source files to ensure fresh parsing.
|
|
487
|
+
*/
|
|
488
|
+
clearCache(): void;
|
|
489
|
+
/**
|
|
490
|
+
* Gets cache performance statistics.
|
|
491
|
+
*
|
|
492
|
+
* @returns Current cache statistics
|
|
493
|
+
*/
|
|
494
|
+
getCacheStats(): CacheStats;
|
|
495
|
+
/**
|
|
496
|
+
* Warms the cache by pre-loading files matching patterns.
|
|
497
|
+
*
|
|
498
|
+
* @param patterns - Glob patterns for files to pre-load
|
|
499
|
+
*/
|
|
500
|
+
warmCache(patterns: string[]): Promise<void>;
|
|
501
|
+
/**
|
|
502
|
+
* Resolves a relative import path (./foo or ../bar).
|
|
503
|
+
*
|
|
504
|
+
* @param importPath - The relative import specifier
|
|
505
|
+
* @param fromFile - Absolute path to the file containing the import
|
|
506
|
+
* @returns Resolved absolute path, or null if not found
|
|
507
|
+
* @internal
|
|
508
|
+
*/
|
|
509
|
+
private resolveRelativeImport;
|
|
510
|
+
/**
|
|
511
|
+
* Resolves a path alias from tsconfig.json paths configuration.
|
|
512
|
+
*
|
|
513
|
+
* @param importPath - The import specifier (e.g., '@/utils', 'models')
|
|
514
|
+
* @param fromFile - Absolute path to the file containing the import
|
|
515
|
+
* @returns Resolved absolute path, or null if not a matching alias
|
|
516
|
+
* @internal
|
|
517
|
+
*/
|
|
518
|
+
private resolvePathAlias;
|
|
519
|
+
/**
|
|
520
|
+
* Resolves an import using baseUrl from tsconfig.json.
|
|
521
|
+
*
|
|
522
|
+
* @param importPath - The import specifier
|
|
523
|
+
* @param fromFile - Absolute path to the file containing the import
|
|
524
|
+
* @returns Resolved absolute path, or null if not found
|
|
525
|
+
* @internal
|
|
526
|
+
*/
|
|
527
|
+
private resolveFromBaseUrl;
|
|
528
|
+
/**
|
|
529
|
+
* Probes for a file with various extensions and index files.
|
|
530
|
+
*
|
|
531
|
+
* @param targetBase - Base path to probe
|
|
532
|
+
* @returns Resolved path if found, or null
|
|
533
|
+
* @internal
|
|
534
|
+
*/
|
|
535
|
+
private probeFile;
|
|
536
|
+
/**
|
|
537
|
+
* Creates a ResolvedImport object from a resolved file path.
|
|
538
|
+
*
|
|
539
|
+
* @param filePath - Resolved absolute file path
|
|
540
|
+
* @param originalSpecifier - Original import specifier
|
|
541
|
+
* @returns ResolvedImport object
|
|
542
|
+
* @internal
|
|
543
|
+
*/
|
|
544
|
+
private createResolvedImport;
|
|
545
|
+
/**
|
|
546
|
+
* Gets or parses a source file, using cache when available.
|
|
547
|
+
*
|
|
548
|
+
* @param filePath - Absolute path to the file
|
|
549
|
+
* @returns Parsed SourceFile, or null if parsing fails
|
|
550
|
+
* @internal
|
|
551
|
+
*/
|
|
552
|
+
private getOrParseFile;
|
|
553
|
+
/**
|
|
554
|
+
* Collects directly exported types from a source file.
|
|
555
|
+
*
|
|
556
|
+
* @param sourceFile - The source file to analyze
|
|
557
|
+
* @param result - Map to populate with exported types
|
|
558
|
+
* @internal
|
|
559
|
+
*/
|
|
560
|
+
private collectDirectExports;
|
|
561
|
+
/**
|
|
562
|
+
* Collects re-exported types from a source file.
|
|
563
|
+
*
|
|
564
|
+
* Follows `export * from '...'` and `export { X } from '...'` declarations.
|
|
565
|
+
*
|
|
566
|
+
* @param sourceFile - The source file to analyze
|
|
567
|
+
* @param result - Map to populate with re-exported types
|
|
568
|
+
* @param visited - Set of visited file paths for cycle detection
|
|
569
|
+
* @param depth - Current recursion depth
|
|
570
|
+
* @internal
|
|
571
|
+
*/
|
|
572
|
+
private collectReExports;
|
|
573
|
+
/**
|
|
574
|
+
* Converts a TypeScript interface to NormalizedType format.
|
|
575
|
+
*
|
|
576
|
+
* @param iface - The interface node to convert
|
|
577
|
+
* @returns NormalizedType representation
|
|
578
|
+
* @internal
|
|
579
|
+
*/
|
|
580
|
+
private convertInterfaceToNormalizedType;
|
|
581
|
+
/**
|
|
582
|
+
* Converts a TypeScript type alias to NormalizedType format.
|
|
583
|
+
*
|
|
584
|
+
* @param typeAlias - The type alias node to convert
|
|
585
|
+
* @returns NormalizedType representation
|
|
586
|
+
* @internal
|
|
587
|
+
*/
|
|
588
|
+
private convertTypeAliasToNormalizedType;
|
|
589
|
+
/**
|
|
590
|
+
* Converts a ts-morph Type to NormalizedType format.
|
|
591
|
+
*
|
|
592
|
+
* Handles primitives, literals, arrays, unions, intersections, and objects.
|
|
593
|
+
*
|
|
594
|
+
* @param type - The ts-morph Type to convert
|
|
595
|
+
* @param visitingTypes - Set of type names being visited (for cycle detection)
|
|
596
|
+
* @returns NormalizedType representation
|
|
597
|
+
* @internal
|
|
598
|
+
*/
|
|
599
|
+
private convertTsTypeToNormalized;
|
|
600
|
+
/**
|
|
601
|
+
* Internal type reference resolution with cycle detection.
|
|
602
|
+
*
|
|
603
|
+
* @param typeName - Name of the type to resolve
|
|
604
|
+
* @param sourceFile - Current source file being analyzed
|
|
605
|
+
* @param visited - Set of visited file:type combinations
|
|
606
|
+
* @param reexportChain - Chain of re-export files traversed
|
|
607
|
+
* @param depth - Current recursion depth
|
|
608
|
+
* @returns Resolved type reference, or null if not found
|
|
609
|
+
* @internal
|
|
610
|
+
*/
|
|
611
|
+
private resolveTypeRefInternal;
|
|
612
|
+
/**
|
|
613
|
+
* Finds a direct type definition in a source file.
|
|
614
|
+
*
|
|
615
|
+
* @param typeName - Name of the type to find
|
|
616
|
+
* @param sourceFile - Source file to search
|
|
617
|
+
* @returns Type and line number if found, or null
|
|
618
|
+
* @internal
|
|
619
|
+
*/
|
|
620
|
+
private findDirectDefinition;
|
|
621
|
+
/**
|
|
622
|
+
* Finds a type in the imports of a source file.
|
|
623
|
+
*
|
|
624
|
+
* @param typeName - Name of the type to find
|
|
625
|
+
* @param sourceFile - Source file containing imports
|
|
626
|
+
* @param visited - Set of visited file:type combinations
|
|
627
|
+
* @param reexportChain - Chain of re-export files traversed
|
|
628
|
+
* @param depth - Current recursion depth
|
|
629
|
+
* @returns Resolved type reference, or null if not found in imports
|
|
630
|
+
* @internal
|
|
631
|
+
*/
|
|
632
|
+
private findInImports;
|
|
633
|
+
/**
|
|
634
|
+
* Builds an import graph recursively from a source file.
|
|
635
|
+
*
|
|
636
|
+
* @param sourceFile - Root source file
|
|
637
|
+
* @param depth - Remaining depth to traverse
|
|
638
|
+
* @param visited - Set of visited file paths
|
|
639
|
+
* @returns Import graph node
|
|
640
|
+
* @internal
|
|
641
|
+
*/
|
|
642
|
+
private buildImportGraph;
|
|
643
|
+
}
|
|
644
|
+
export {};
|
|
645
|
+
//# sourceMappingURL=import-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-resolver.d.ts","sourceRoot":"","sources":["../../src/languages/import-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAW,UAAU,EAAkD,MAAM,UAAU,CAAC;AAC/F,OAAO,KAAK,EAAE,cAAc,EAA4C,MAAM,kBAAkB,CAAC;AAqGjG;;;;;;;;;;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