@zipbul/gildash 0.14.0 → 0.15.1
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/dist/index.js +9 -9
- package/dist/migrations/0008_external_imports.sql +26 -0
- package/dist/migrations/meta/_journal.json +7 -0
- package/dist/src/common/path-utils.d.ts +8 -0
- package/dist/src/extractor/imports-extractor.d.ts +4 -2
- package/dist/src/extractor/relation-extractor.d.ts +2 -2
- package/dist/src/extractor/types.d.ts +6 -3
- package/dist/src/gildash/context.d.ts +1 -1
- package/dist/src/gildash/index.d.ts +492 -11
- package/dist/src/gildash/semantic-api.d.ts +2 -0
- package/dist/src/gildash/types.d.ts +15 -23
- package/dist/src/index.d.ts +10 -5
- package/dist/src/indexer/index-coordinator.d.ts +5 -4
- package/dist/src/indexer/relation-indexer.d.ts +6 -2
- package/dist/src/parser/ast-utils.d.ts +0 -4
- package/dist/src/parser/index.d.ts +1 -1
- package/dist/src/parser/types.d.ts +3 -1
- package/dist/src/search/annotation-search.d.ts +1 -1
- package/dist/src/search/relation-search.d.ts +9 -3
- package/dist/src/search/symbol-search.d.ts +47 -5
- package/dist/src/semantic/index.d.ts +7 -0
- package/dist/src/semantic/type-collector.d.ts +7 -0
- package/dist/src/semantic/types.d.ts +9 -0
- package/dist/src/store/repositories/annotation.repository.d.ts +1 -1
- package/dist/src/store/repositories/relation.repository.d.ts +8 -3
- package/dist/src/store/repositories/symbol.repository.d.ts +1 -1
- package/dist/src/store/schema.d.ts +38 -2
- package/package.json +3 -2
|
@@ -27,75 +27,367 @@ export type { GildashInternalOptions } from './lifecycle';
|
|
|
27
27
|
* watches for file changes, and provides search / dependency-graph queries.
|
|
28
28
|
*
|
|
29
29
|
* Every public method either returns a value directly or throws a
|
|
30
|
-
*
|
|
31
|
-
*
|
|
30
|
+
* {@link GildashError} on failure — including when called after {@link close}.
|
|
31
|
+
*
|
|
32
|
+
* File paths accepted by query methods are **relative to the project root**
|
|
33
|
+
* (e.g. `'src/utils.ts'`). The `project` parameter defaults to the primary
|
|
34
|
+
* project (first discovered boundary) when omitted.
|
|
32
35
|
*
|
|
33
36
|
* Create an instance with the static {@link Gildash.open} factory.
|
|
34
37
|
* Always call {@link Gildash.close} when done to release resources.
|
|
35
38
|
*/
|
|
36
39
|
export declare class Gildash {
|
|
37
|
-
/**
|
|
40
|
+
/** @internal Exposed for advanced testing only. */
|
|
38
41
|
readonly _ctx: GildashContext;
|
|
39
42
|
/** Absolute path to the indexed project root. */
|
|
40
43
|
get projectRoot(): string;
|
|
41
|
-
/** Current watcher role: `'owner'` (can reindex) or `'reader'` (read-only). */
|
|
44
|
+
/** Current watcher role: `'owner'` (can write/reindex) or `'reader'` (read-only). */
|
|
42
45
|
get role(): 'owner' | 'reader';
|
|
43
46
|
/** Discovered project boundaries within the project root. */
|
|
44
47
|
get projects(): ProjectBoundary[];
|
|
45
48
|
private constructor();
|
|
46
49
|
/**
|
|
47
50
|
* Create and initialise a new `Gildash` instance.
|
|
48
|
-
*
|
|
51
|
+
*
|
|
52
|
+
* @param options - Project root, extensions, watch mode, and optional DI overrides.
|
|
53
|
+
* @returns A fully initialised instance with the initial index complete.
|
|
54
|
+
* @throws {GildashError} With type `'validation'` if `projectRoot` is invalid,
|
|
55
|
+
* or type `'store'` if database initialisation fails.
|
|
56
|
+
*/
|
|
57
|
+
static open(options: GildashOptions & Partial<GildashInternalOptions>): Promise<Gildash>;
|
|
58
|
+
/**
|
|
59
|
+
* Shut down the instance and release all resources (watcher, database, caches).
|
|
60
|
+
*
|
|
61
|
+
* @param opts.cleanup - When `true`, deletes the `.gildash/` data directory.
|
|
62
|
+
* @throws {GildashError} With type `'closed'` if already closed.
|
|
49
63
|
*/
|
|
50
|
-
static open(options: GildashOptions & GildashInternalOptions): Promise<Gildash>;
|
|
51
|
-
/** Shut down the instance and release all resources. */
|
|
52
64
|
close(opts?: {
|
|
53
65
|
cleanup?: boolean;
|
|
54
66
|
}): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Parse a single source file into an AST. Result is LRU-cached by file path.
|
|
69
|
+
*
|
|
70
|
+
* @param filePath - Absolute path to the source file.
|
|
71
|
+
* @param sourceText - The file's source code.
|
|
72
|
+
* @param options - oxc-parser options (e.g. `sourceType`, `lang`).
|
|
73
|
+
* @returns The parsed AST with source text and comments.
|
|
74
|
+
* @throws {GildashError} With type `'parse'` if oxc-parser fails.
|
|
75
|
+
*/
|
|
55
76
|
parseSource(filePath: string, sourceText: string, options?: ParserOptions): ParsedFile;
|
|
77
|
+
/**
|
|
78
|
+
* Parse multiple files concurrently by reading them from disk.
|
|
79
|
+
*
|
|
80
|
+
* @param filePaths - Absolute paths to the source files.
|
|
81
|
+
* @param options - oxc-parser options applied to all files.
|
|
82
|
+
* @returns Parsed results keyed by path, plus an array of failures.
|
|
83
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed.
|
|
84
|
+
*/
|
|
56
85
|
batchParse(filePaths: string[], options?: ParserOptions): Promise<BatchParseResult>;
|
|
86
|
+
/**
|
|
87
|
+
* Retrieve a previously parsed AST from the LRU cache.
|
|
88
|
+
*
|
|
89
|
+
* @param filePath - Absolute path used as cache key.
|
|
90
|
+
* @returns The cached `ParsedFile`, or `undefined` if not in cache.
|
|
91
|
+
*/
|
|
57
92
|
getParsedAst(filePath: string): ParsedFile | undefined;
|
|
93
|
+
/**
|
|
94
|
+
* Extract symbol declarations from a parsed file.
|
|
95
|
+
*
|
|
96
|
+
* Extracts functions, classes, variables, types, interfaces, enums,
|
|
97
|
+
* and namespaces with their metadata (modifiers, decorators, heritage, etc.).
|
|
98
|
+
*
|
|
99
|
+
* @param parsed - A `ParsedFile` from {@link parseSource} or {@link batchParse}.
|
|
100
|
+
* @returns Array of extracted symbols. Empty array if no declarations found.
|
|
101
|
+
* @throws {GildashError} With type `'extract'` on extraction failure.
|
|
102
|
+
*/
|
|
58
103
|
extractSymbols(parsed: ParsedFile): ExtractedSymbol[];
|
|
104
|
+
/**
|
|
105
|
+
* Extract inter-file relations from a parsed file.
|
|
106
|
+
*
|
|
107
|
+
* Detects imports, re-exports, function calls, and heritage (extends/implements).
|
|
108
|
+
* Uses `module.staticImports`/`staticExports` when available, with AST fallback.
|
|
109
|
+
*
|
|
110
|
+
* @param parsed - A `ParsedFile` from {@link parseSource} or {@link batchParse}.
|
|
111
|
+
* @returns Array of relations. Empty array if no relations found.
|
|
112
|
+
* @throws {GildashError} With type `'extract'` on extraction failure.
|
|
113
|
+
*/
|
|
59
114
|
extractRelations(parsed: ParsedFile): CodeRelation[];
|
|
115
|
+
/**
|
|
116
|
+
* Return aggregate symbol and file counts for a project.
|
|
117
|
+
*
|
|
118
|
+
* @param project - Project name. Defaults to the primary project.
|
|
119
|
+
* @returns Counts of symbols by kind, total files, and total relations.
|
|
120
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed.
|
|
121
|
+
*/
|
|
60
122
|
getStats(project?: string): SymbolStats;
|
|
123
|
+
/**
|
|
124
|
+
* Search symbols by name, kind, file path, or export status.
|
|
125
|
+
*
|
|
126
|
+
* @param query - Search criteria. Set `query.text` for FTS prefix search,
|
|
127
|
+
* or `query.text` + `query.exact` for exact name match.
|
|
128
|
+
* Omit `query.limit` for unlimited results.
|
|
129
|
+
* @returns Matching symbols. Empty array if none found.
|
|
130
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed.
|
|
131
|
+
*/
|
|
61
132
|
searchSymbols(query: SymbolSearchQuery): SymbolSearchResult[];
|
|
133
|
+
/**
|
|
134
|
+
* Search relations by type, source/destination file, or symbol name.
|
|
135
|
+
*
|
|
136
|
+
* @param query - Search criteria (e.g. `{ type: 'imports', srcFilePath: 'src/app.ts' }`).
|
|
137
|
+
* Omit `query.limit` for unlimited results.
|
|
138
|
+
* @returns Matching relations. Empty array if none found.
|
|
139
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed.
|
|
140
|
+
*/
|
|
62
141
|
searchRelations(query: RelationSearchQuery): StoredCodeRelation[];
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
142
|
+
/**
|
|
143
|
+
* Search symbols across all discovered projects (ignores `query.project`).
|
|
144
|
+
*
|
|
145
|
+
* @param query - Same as {@link searchSymbols}.
|
|
146
|
+
* @returns Matching symbols from all projects.
|
|
147
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed.
|
|
148
|
+
*/
|
|
149
|
+
searchAllSymbols(query: SymbolSearchQuery): SymbolSearchResult[];
|
|
150
|
+
/**
|
|
151
|
+
* Search relations across all discovered projects.
|
|
152
|
+
*
|
|
153
|
+
* @param query - Same as {@link searchRelations}.
|
|
154
|
+
* @returns Matching relations from all projects.
|
|
155
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed.
|
|
156
|
+
*/
|
|
66
157
|
searchAllRelations(query: RelationSearchQuery): StoredCodeRelation[];
|
|
158
|
+
/**
|
|
159
|
+
* List all indexed file records for a project.
|
|
160
|
+
*
|
|
161
|
+
* @param project - Project name. Defaults to the primary project.
|
|
162
|
+
* @returns Array of file records with path, hash, and timestamps.
|
|
163
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed.
|
|
164
|
+
*/
|
|
67
165
|
listIndexedFiles(project?: string): FileRecord[];
|
|
166
|
+
/**
|
|
167
|
+
* Return relations where both source and destination are within the same file.
|
|
168
|
+
*
|
|
169
|
+
* @param filePath - Relative path to the file (e.g. `'src/app.ts'`).
|
|
170
|
+
* @param project - Project name. Defaults to the primary project.
|
|
171
|
+
* @returns Intra-file relations (calls, heritage within the same file).
|
|
172
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed.
|
|
173
|
+
*/
|
|
68
174
|
getInternalRelations(filePath: string, project?: string): StoredCodeRelation[];
|
|
175
|
+
/**
|
|
176
|
+
* Return a symbol with its full metadata, or `null` if not found.
|
|
177
|
+
*
|
|
178
|
+
* Includes heritage chain, class members, decorators, parameters,
|
|
179
|
+
* return type, and JSDoc.
|
|
180
|
+
*
|
|
181
|
+
* @param symbolName - Exact symbol name (e.g. `'MyClass'`).
|
|
182
|
+
* @param filePath - Relative path to the declaring file.
|
|
183
|
+
* @param project - Project name. Defaults to the primary project.
|
|
184
|
+
* @returns Full symbol data, or `null` if the symbol is not indexed.
|
|
185
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed.
|
|
186
|
+
*/
|
|
69
187
|
getFullSymbol(symbolName: string, filePath: string, project?: string): FullSymbol | null;
|
|
188
|
+
/**
|
|
189
|
+
* Return per-file statistics.
|
|
190
|
+
*
|
|
191
|
+
* @param filePath - Relative path to the file.
|
|
192
|
+
* @param project - Project name. Defaults to the primary project.
|
|
193
|
+
* @returns Symbol count, relation count, and fan-in/fan-out metrics.
|
|
194
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed.
|
|
195
|
+
*/
|
|
70
196
|
getFileStats(filePath: string, project?: string): FileStats;
|
|
197
|
+
/**
|
|
198
|
+
* Return the indexed file record, or `null` if the file is not indexed.
|
|
199
|
+
*
|
|
200
|
+
* @param filePath - Relative path to the file.
|
|
201
|
+
* @param project - Project name. Defaults to the primary project.
|
|
202
|
+
* @returns File record with hash, mtime, and size, or `null`.
|
|
203
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed.
|
|
204
|
+
*/
|
|
71
205
|
getFileInfo(filePath: string, project?: string): FileRecord | null;
|
|
206
|
+
/**
|
|
207
|
+
* Return all symbols declared in a specific file.
|
|
208
|
+
*
|
|
209
|
+
* @param filePath - Relative path to the file.
|
|
210
|
+
* @param project - Project name. Defaults to the primary project.
|
|
211
|
+
* @returns Array of symbols. Empty array if the file has no declarations.
|
|
212
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed.
|
|
213
|
+
*/
|
|
72
214
|
getSymbolsByFile(filePath: string, project?: string): SymbolSearchResult[];
|
|
215
|
+
/**
|
|
216
|
+
* Return the public module interface: exported symbols grouped by kind.
|
|
217
|
+
*
|
|
218
|
+
* @param filePath - Relative path to the file.
|
|
219
|
+
* @param project - Project name. Defaults to the primary project.
|
|
220
|
+
* @returns Module interface with `exports`, `reExports`, and `declarations`.
|
|
221
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed.
|
|
222
|
+
*/
|
|
73
223
|
getModuleInterface(filePath: string, project?: string): ModuleInterface;
|
|
224
|
+
/**
|
|
225
|
+
* Return direct import dependencies of a file (files this file imports from).
|
|
226
|
+
*
|
|
227
|
+
* @param filePath - Relative path to the file.
|
|
228
|
+
* @param project - Project name. Defaults to the primary project.
|
|
229
|
+
* @param limit - Maximum number of results. Defaults to 10,000.
|
|
230
|
+
* @returns Array of relative file paths.
|
|
231
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed.
|
|
232
|
+
*/
|
|
74
233
|
getDependencies(filePath: string, project?: string, limit?: number): string[];
|
|
234
|
+
/**
|
|
235
|
+
* Return files that directly import the given file (reverse dependencies).
|
|
236
|
+
*
|
|
237
|
+
* @param filePath - Relative path to the file.
|
|
238
|
+
* @param project - Project name. Defaults to the primary project.
|
|
239
|
+
* @param limit - Maximum number of results. Defaults to 10,000.
|
|
240
|
+
* @returns Array of relative file paths.
|
|
241
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed.
|
|
242
|
+
*/
|
|
75
243
|
getDependents(filePath: string, project?: string, limit?: number): string[];
|
|
244
|
+
/**
|
|
245
|
+
* Return all files transitively affected by changes to the given files.
|
|
246
|
+
*
|
|
247
|
+
* Walks the reverse dependency graph from each changed file.
|
|
248
|
+
*
|
|
249
|
+
* @param changedFiles - Relative paths to changed files.
|
|
250
|
+
* @param project - Project name. Defaults to the primary project.
|
|
251
|
+
* @returns Relative paths of all transitively affected files (excluding the input files).
|
|
252
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed.
|
|
253
|
+
*/
|
|
76
254
|
getAffected(changedFiles: string[], project?: string): Promise<string[]>;
|
|
255
|
+
/**
|
|
256
|
+
* Check whether the import graph contains any cycles.
|
|
257
|
+
*
|
|
258
|
+
* @param project - Project name. Defaults to the primary project.
|
|
259
|
+
* @returns `true` if at least one cycle exists.
|
|
260
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed.
|
|
261
|
+
*/
|
|
77
262
|
hasCycle(project?: string): Promise<boolean>;
|
|
263
|
+
/**
|
|
264
|
+
* Return the full import graph as an adjacency list.
|
|
265
|
+
*
|
|
266
|
+
* @param project - Project name. Defaults to the primary project.
|
|
267
|
+
* @returns Map where each key is a relative file path and the value is
|
|
268
|
+
* an array of files it directly imports.
|
|
269
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed.
|
|
270
|
+
*/
|
|
78
271
|
getImportGraph(project?: string): Promise<Map<string, string[]>>;
|
|
272
|
+
/**
|
|
273
|
+
* Return all files that the given file transitively depends on.
|
|
274
|
+
*
|
|
275
|
+
* @param filePath - Relative path to the file.
|
|
276
|
+
* @param project - Project name. Defaults to the primary project.
|
|
277
|
+
* @returns Relative paths of all transitive dependencies.
|
|
278
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed.
|
|
279
|
+
*/
|
|
79
280
|
getTransitiveDependencies(filePath: string, project?: string): Promise<string[]>;
|
|
281
|
+
/**
|
|
282
|
+
* Return all files that transitively depend on the given file.
|
|
283
|
+
*
|
|
284
|
+
* @param filePath - Relative path to the file.
|
|
285
|
+
* @param project - Project name. Defaults to the primary project.
|
|
286
|
+
* @returns Relative paths of all transitive dependents.
|
|
287
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed.
|
|
288
|
+
*/
|
|
80
289
|
getTransitiveDependents(filePath: string, project?: string): Promise<string[]>;
|
|
290
|
+
/**
|
|
291
|
+
* Return all cycle paths in the import graph.
|
|
292
|
+
*
|
|
293
|
+
* @param project - Project name. Defaults to the primary project.
|
|
294
|
+
* @param options.maxCycles - Stop after finding this many cycles.
|
|
295
|
+
* @returns Array of cycles, where each cycle is an array of relative file paths
|
|
296
|
+
* forming the loop (last file imports the first).
|
|
297
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed.
|
|
298
|
+
*/
|
|
81
299
|
getCyclePaths(project?: string, options?: {
|
|
82
300
|
maxCycles?: number;
|
|
83
301
|
}): Promise<string[][]>;
|
|
302
|
+
/**
|
|
303
|
+
* Return fan-in (dependents count) and fan-out (dependencies count) for a file.
|
|
304
|
+
*
|
|
305
|
+
* @param filePath - Relative path to the file.
|
|
306
|
+
* @param project - Project name. Defaults to the primary project.
|
|
307
|
+
* @returns `{ fanIn, fanOut }` counts.
|
|
308
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed.
|
|
309
|
+
*/
|
|
84
310
|
getFanMetrics(filePath: string, project?: string): Promise<FanMetrics>;
|
|
85
311
|
/**
|
|
86
|
-
*
|
|
312
|
+
* Return the resolved type tree for the given symbol.
|
|
87
313
|
*
|
|
88
314
|
* The returned tree is always a bounded, finite, acyclic structure.
|
|
89
315
|
* At the truncation boundary `members` and `typeArguments` will be
|
|
90
316
|
* `undefined`, but `text` always contains the full type string.
|
|
317
|
+
*
|
|
318
|
+
* @param symbolName - Exact symbol name.
|
|
319
|
+
* @param filePath - Relative path to the declaring file.
|
|
320
|
+
* @param project - Project name. Defaults to the primary project.
|
|
321
|
+
* @returns Resolved type tree, or `null` if the symbol cannot be found by tsc.
|
|
322
|
+
* @throws {GildashError} With type `'semantic'` if tsc initialisation fails.
|
|
91
323
|
*/
|
|
92
324
|
getResolvedType(symbolName: string, filePath: string, project?: string): ResolvedType | null;
|
|
325
|
+
/**
|
|
326
|
+
* Find all references to a symbol across the project using tsc.
|
|
327
|
+
*
|
|
328
|
+
* @param symbolName - Exact symbol name.
|
|
329
|
+
* @param filePath - Relative path to the declaring file.
|
|
330
|
+
* @param project - Project name. Defaults to the primary project.
|
|
331
|
+
* @returns Array of reference locations. Empty array if none found.
|
|
332
|
+
* @throws {GildashError} With type `'semantic'` if tsc initialisation fails.
|
|
333
|
+
*/
|
|
93
334
|
getSemanticReferences(symbolName: string, filePath: string, project?: string): SemanticReference[];
|
|
335
|
+
/**
|
|
336
|
+
* Find all implementations of an interface or abstract class member.
|
|
337
|
+
*
|
|
338
|
+
* @param symbolName - Exact symbol name.
|
|
339
|
+
* @param filePath - Relative path to the declaring file.
|
|
340
|
+
* @param project - Project name. Defaults to the primary project.
|
|
341
|
+
* @returns Array of implementation locations. Empty array if none found.
|
|
342
|
+
* @throws {GildashError} With type `'semantic'` if tsc initialisation fails.
|
|
343
|
+
*/
|
|
94
344
|
getImplementations(symbolName: string, filePath: string, project?: string): Implementation[];
|
|
345
|
+
/**
|
|
346
|
+
* Check if the source symbol's type is assignable to the target symbol's type.
|
|
347
|
+
*
|
|
348
|
+
* @param sourceSymbol - Name of the source symbol.
|
|
349
|
+
* @param sourceFilePath - Relative path to the source symbol's file.
|
|
350
|
+
* @param targetSymbol - Name of the target symbol.
|
|
351
|
+
* @param targetFilePath - Relative path to the target symbol's file.
|
|
352
|
+
* @param project - Project name. Defaults to the primary project.
|
|
353
|
+
* @returns `true` if assignable, `false` if not, `null` if either symbol cannot be resolved.
|
|
354
|
+
* @throws {GildashError} With type `'semantic'` if tsc initialisation fails.
|
|
355
|
+
*/
|
|
95
356
|
isTypeAssignableTo(sourceSymbol: string, sourceFilePath: string, targetSymbol: string, targetFilePath: string, project?: string): boolean | null;
|
|
357
|
+
/**
|
|
358
|
+
* Return the module's semantic interface: exports with resolved type information from tsc.
|
|
359
|
+
*
|
|
360
|
+
* @param filePath - Relative path to the file.
|
|
361
|
+
* @returns Semantic module interface with typed export entries.
|
|
362
|
+
* @throws {GildashError} With type `'semantic'` if tsc initialisation fails.
|
|
363
|
+
*/
|
|
96
364
|
getSemanticModuleInterface(filePath: string): SemanticModuleInterface;
|
|
365
|
+
/**
|
|
366
|
+
* Return resolved types for all declarations in a file, keyed by byte position.
|
|
367
|
+
*
|
|
368
|
+
* @param filePath - Relative path to the file.
|
|
369
|
+
* @returns Map from byte offset to resolved type tree.
|
|
370
|
+
* @throws {GildashError} With type `'semantic'` if tsc initialisation fails.
|
|
371
|
+
*/
|
|
97
372
|
getFileTypes(filePath: string): Map<number, ResolvedType>;
|
|
373
|
+
/**
|
|
374
|
+
* Return the resolved type at a specific line and column.
|
|
375
|
+
*
|
|
376
|
+
* @param filePath - Relative path to the file.
|
|
377
|
+
* @param line - 1-based line number.
|
|
378
|
+
* @param column - 0-based column number.
|
|
379
|
+
* @returns Resolved type tree, or `null` if no type is found at that position.
|
|
380
|
+
* @throws {GildashError} With type `'semantic'` if tsc initialisation fails.
|
|
381
|
+
*/
|
|
98
382
|
getResolvedTypeAt(filePath: string, line: number, column: number): ResolvedType | null;
|
|
383
|
+
/**
|
|
384
|
+
* Check if the type at the source position is assignable to the type at the target position.
|
|
385
|
+
*
|
|
386
|
+
* @param opts.source - Source location (file, line, column).
|
|
387
|
+
* @param opts.target - Target location (file, line, column).
|
|
388
|
+
* @returns `true` if assignable, `false` if not, `null` if either type cannot be resolved.
|
|
389
|
+
* @throws {GildashError} With type `'semantic'` if tsc initialisation fails.
|
|
390
|
+
*/
|
|
99
391
|
isTypeAssignableToAt(opts: {
|
|
100
392
|
source: {
|
|
101
393
|
filePath: string;
|
|
@@ -108,30 +400,219 @@ export declare class Gildash {
|
|
|
108
400
|
column: number;
|
|
109
401
|
};
|
|
110
402
|
}): boolean | null;
|
|
403
|
+
/**
|
|
404
|
+
* Return the resolved type at a specific byte position.
|
|
405
|
+
*
|
|
406
|
+
* @param filePath - Relative path to the file.
|
|
407
|
+
* @param position - 0-based byte offset in the file.
|
|
408
|
+
* @returns Resolved type tree, or `null` if no type is found at that position.
|
|
409
|
+
* @throws {GildashError} With type `'semantic'` if tsc initialisation fails.
|
|
410
|
+
*/
|
|
111
411
|
getResolvedTypeAtPosition(filePath: string, position: number): ResolvedType | null;
|
|
412
|
+
/**
|
|
413
|
+
* Find all semantic references to the symbol at a specific byte position.
|
|
414
|
+
*
|
|
415
|
+
* @param filePath - Relative path to the file.
|
|
416
|
+
* @param position - 0-based byte offset of the symbol.
|
|
417
|
+
* @returns Array of reference locations. Empty array if none found.
|
|
418
|
+
* @throws {GildashError} With type `'semantic'` if tsc initialisation fails.
|
|
419
|
+
*/
|
|
112
420
|
getSemanticReferencesAtPosition(filePath: string, position: number): SemanticReference[];
|
|
421
|
+
/**
|
|
422
|
+
* Find all implementations of the symbol at a specific byte position.
|
|
423
|
+
*
|
|
424
|
+
* @param filePath - Relative path to the file.
|
|
425
|
+
* @param position - 0-based byte offset of the symbol.
|
|
426
|
+
* @returns Array of implementation locations. Empty array if none found.
|
|
427
|
+
* @throws {GildashError} With type `'semantic'` if tsc initialisation fails.
|
|
428
|
+
*/
|
|
113
429
|
getImplementationsAtPosition(filePath: string, position: number): Implementation[];
|
|
430
|
+
/**
|
|
431
|
+
* Check type assignability between two byte positions.
|
|
432
|
+
*
|
|
433
|
+
* @param srcFilePath - Relative path to the source file.
|
|
434
|
+
* @param srcPosition - 0-based byte offset of the source type.
|
|
435
|
+
* @param dstFilePath - Relative path to the target file.
|
|
436
|
+
* @param dstPosition - 0-based byte offset of the target type.
|
|
437
|
+
* @returns `true` if assignable, `false` if not, `null` if either type cannot be resolved.
|
|
438
|
+
* @throws {GildashError} With type `'semantic'` if tsc initialisation fails.
|
|
439
|
+
*/
|
|
114
440
|
isTypeAssignableToAtPosition(srcFilePath: string, srcPosition: number, dstFilePath: string, dstPosition: number): boolean | null;
|
|
441
|
+
/**
|
|
442
|
+
* Check if the type at a position is assignable to a type expression string.
|
|
443
|
+
*
|
|
444
|
+
* @param filePath - Relative path to the file.
|
|
445
|
+
* @param position - 0-based byte offset of the source type.
|
|
446
|
+
* @param targetTypeExpression - A TypeScript type expression to check against (e.g. `'string | number'`).
|
|
447
|
+
* @param options.anyConstituent - When `true`, passes if any union constituent is assignable.
|
|
448
|
+
* @returns `true` if assignable, `false` if not, `null` if the source type cannot be resolved.
|
|
449
|
+
* @throws {GildashError} With type `'semantic'` if tsc initialisation fails.
|
|
450
|
+
*/
|
|
115
451
|
isTypeAssignableToType(filePath: string, position: number, targetTypeExpression: string, options?: {
|
|
116
452
|
anyConstituent?: boolean;
|
|
117
453
|
}): boolean | null;
|
|
454
|
+
/**
|
|
455
|
+
* Convert a line/column position to a byte offset.
|
|
456
|
+
*
|
|
457
|
+
* @param filePath - Relative path to the file.
|
|
458
|
+
* @param line - 1-based line number.
|
|
459
|
+
* @param column - 0-based column number.
|
|
460
|
+
* @returns 0-based byte offset, or `null` if the position is out of bounds.
|
|
461
|
+
* @throws {GildashError} With type `'semantic'` if tsc initialisation fails.
|
|
462
|
+
*/
|
|
118
463
|
lineColumnToPosition(filePath: string, line: number, column: number): number | null;
|
|
464
|
+
/**
|
|
465
|
+
* Find the byte position of a symbol name within a declaration.
|
|
466
|
+
*
|
|
467
|
+
* Useful for mapping an extracted symbol's span to its exact name position
|
|
468
|
+
* for use with position-based semantic APIs.
|
|
469
|
+
*
|
|
470
|
+
* @param filePath - Relative path to the file.
|
|
471
|
+
* @param declarationPos - Byte offset of the declaration start.
|
|
472
|
+
* @param name - The symbol name to locate within the declaration.
|
|
473
|
+
* @returns 0-based byte offset of the name, or `null` if not found.
|
|
474
|
+
* @throws {GildashError} With type `'semantic'` if tsc initialisation fails.
|
|
475
|
+
*/
|
|
119
476
|
findNamePosition(filePath: string, declarationPos: number, name: string): number | null;
|
|
477
|
+
/**
|
|
478
|
+
* Return the tsc symbol node at a specific byte position.
|
|
479
|
+
*
|
|
480
|
+
* Includes parent/member relationships and symbol flags.
|
|
481
|
+
*
|
|
482
|
+
* @param filePath - Relative path to the file.
|
|
483
|
+
* @param position - 0-based byte offset of the symbol.
|
|
484
|
+
* @returns Symbol node with parent, members, and exports, or `null` if no symbol found.
|
|
485
|
+
* @throws {GildashError} With type `'semantic'` if tsc initialisation fails.
|
|
486
|
+
*/
|
|
120
487
|
getSymbolNode(filePath: string, position: number): SymbolNode | null;
|
|
488
|
+
/**
|
|
489
|
+
* Return the base types (extends/implements targets) of the symbol at a byte position.
|
|
490
|
+
*
|
|
491
|
+
* @param filePath - Relative path to the file.
|
|
492
|
+
* @param position - 0-based byte offset of the class/interface symbol.
|
|
493
|
+
* @returns Array of resolved base types, or `null` if the symbol has no base types.
|
|
494
|
+
* @throws {GildashError} With type `'semantic'` if tsc initialisation fails.
|
|
495
|
+
*/
|
|
496
|
+
getBaseTypes(filePath: string, position: number): ResolvedType[] | null;
|
|
497
|
+
/**
|
|
498
|
+
* Return tsc semantic diagnostics for a file (type errors, unused variables, etc.).
|
|
499
|
+
*
|
|
500
|
+
* @param filePath - Relative path to the file.
|
|
501
|
+
* @param options - Filtering options (e.g. severity, category).
|
|
502
|
+
* @returns Array of diagnostics. Empty array if the file has no issues.
|
|
503
|
+
* @throws {GildashError} With type `'semantic'` if tsc initialisation fails.
|
|
504
|
+
*/
|
|
121
505
|
getSemanticDiagnostics(filePath: string, options?: GetDiagnosticsOptions): SemanticDiagnostic[];
|
|
506
|
+
/**
|
|
507
|
+
* Compute the diff between two symbol snapshots.
|
|
508
|
+
*
|
|
509
|
+
* @param before - Symbols from the previous snapshot.
|
|
510
|
+
* @param after - Symbols from the current snapshot.
|
|
511
|
+
* @returns `{ added, removed, modified }` arrays of symbols.
|
|
512
|
+
*/
|
|
122
513
|
diffSymbols(before: SymbolSearchResult[], after: SymbolSearchResult[]): SymbolDiff;
|
|
514
|
+
/**
|
|
515
|
+
* Register a callback invoked after each indexing run completes.
|
|
516
|
+
*
|
|
517
|
+
* @param callback - Receives the {@link IndexResult} with counts of indexed files and symbols.
|
|
518
|
+
* @returns An unsubscribe function. Call it to stop receiving notifications.
|
|
519
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed.
|
|
520
|
+
*/
|
|
123
521
|
onIndexed(callback: (result: IndexResult) => void): () => void;
|
|
522
|
+
/**
|
|
523
|
+
* Trigger a full re-index of all files.
|
|
524
|
+
*
|
|
525
|
+
* @returns Index result with counts of processed files, symbols, and relations.
|
|
526
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed,
|
|
527
|
+
* or type `'index'` if indexing fails.
|
|
528
|
+
*/
|
|
124
529
|
reindex(): Promise<IndexResult>;
|
|
530
|
+
/**
|
|
531
|
+
* Follow re-export chains to find the original declaration of a symbol.
|
|
532
|
+
*
|
|
533
|
+
* Traverses `re-exports` relations using `metaJson.specifiers` to map
|
|
534
|
+
* exported names back to their original source.
|
|
535
|
+
*
|
|
536
|
+
* @param symbolName - The exported symbol name to resolve.
|
|
537
|
+
* @param filePath - Relative path to the file exporting the symbol.
|
|
538
|
+
* @param project - Project name. Defaults to the primary project.
|
|
539
|
+
* @returns The original symbol name, file path, re-export chain, and whether a cycle was detected.
|
|
540
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed.
|
|
541
|
+
*/
|
|
125
542
|
resolveSymbol(symbolName: string, filePath: string, project?: string): ResolvedSymbol;
|
|
543
|
+
/**
|
|
544
|
+
* Search for structural AST patterns across indexed files using ast-grep.
|
|
545
|
+
*
|
|
546
|
+
* @param pattern - An ast-grep pattern string (e.g. `'console.log($$$)'`).
|
|
547
|
+
* @param opts.filePaths - Restrict search to specific absolute file paths.
|
|
548
|
+
* @param opts.project - Project name. Defaults to the primary project.
|
|
549
|
+
* @returns Array of pattern matches with file path, line, column, and matched text.
|
|
550
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed.
|
|
551
|
+
*/
|
|
126
552
|
findPattern(pattern: string, opts?: {
|
|
127
553
|
filePaths?: string[];
|
|
128
554
|
project?: string;
|
|
129
555
|
}): Promise<PatternMatch[]>;
|
|
556
|
+
/**
|
|
557
|
+
* Build the full inheritance chain (extends/implements tree) for a symbol.
|
|
558
|
+
*
|
|
559
|
+
* @param symbolName - Exact symbol name (e.g. `'MyClass'`).
|
|
560
|
+
* @param filePath - Relative path to the declaring file.
|
|
561
|
+
* @param project - Project name. Defaults to the primary project.
|
|
562
|
+
* @returns A tree node with `parents` (what this symbol extends/implements)
|
|
563
|
+
* and `children` (what extends/implements this symbol), recursively.
|
|
564
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed.
|
|
565
|
+
*/
|
|
130
566
|
getHeritageChain(symbolName: string, filePath: string, project?: string): Promise<HeritageNode>;
|
|
567
|
+
/**
|
|
568
|
+
* Register a callback invoked when a watched file is created, changed, or deleted.
|
|
569
|
+
*
|
|
570
|
+
* @param callback - Receives a {@link FileChangeEvent} with path and event type.
|
|
571
|
+
* @returns An unsubscribe function.
|
|
572
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed.
|
|
573
|
+
*/
|
|
131
574
|
onFileChanged(callback: (event: FileChangeEvent) => void): () => void;
|
|
575
|
+
/**
|
|
576
|
+
* Register a callback invoked on internal errors (e.g. healthcheck failures, watcher errors).
|
|
577
|
+
*
|
|
578
|
+
* @param callback - Receives the {@link GildashError}.
|
|
579
|
+
* @returns An unsubscribe function.
|
|
580
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed.
|
|
581
|
+
*/
|
|
132
582
|
onError(callback: (error: GildashError) => void): () => void;
|
|
583
|
+
/**
|
|
584
|
+
* Register a callback invoked when the watcher role changes.
|
|
585
|
+
*
|
|
586
|
+
* Role changes happen when the current owner goes stale and a reader self-promotes.
|
|
587
|
+
*
|
|
588
|
+
* @param callback - Receives the new role (`'owner'` or `'reader'`).
|
|
589
|
+
* @returns An unsubscribe function.
|
|
590
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed.
|
|
591
|
+
*/
|
|
133
592
|
onRoleChanged(callback: (newRole: 'owner' | 'reader') => void): () => void;
|
|
593
|
+
/**
|
|
594
|
+
* Search annotations (custom tags attached to symbols during indexing).
|
|
595
|
+
*
|
|
596
|
+
* @param query - Search criteria (e.g. `{ tag: 'todo', project: 'my-project' }`).
|
|
597
|
+
* @returns Matching annotations. Empty array if none found.
|
|
598
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed.
|
|
599
|
+
*/
|
|
134
600
|
searchAnnotations(query: AnnotationSearchQuery): AnnotationSearchResult[];
|
|
601
|
+
/**
|
|
602
|
+
* Query symbol changes recorded since a given date.
|
|
603
|
+
*
|
|
604
|
+
* @param since - ISO date string or `Date` object. Only changes after this timestamp are returned.
|
|
605
|
+
* @param options - Filtering options (symbol name, file path, change type, limit).
|
|
606
|
+
* @returns Array of symbol changes in chronological order.
|
|
607
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed.
|
|
608
|
+
*/
|
|
135
609
|
getSymbolChanges(since: Date | string, options?: SymbolChangeQueryOptions): SymbolChange[];
|
|
610
|
+
/**
|
|
611
|
+
* Delete changelog entries older than the given date.
|
|
612
|
+
*
|
|
613
|
+
* @param before - ISO date string or `Date` object. Entries before this timestamp are deleted.
|
|
614
|
+
* @returns The number of deleted changelog rows.
|
|
615
|
+
* @throws {GildashError} With type `'closed'` if the instance is closed.
|
|
616
|
+
*/
|
|
136
617
|
pruneChangelog(before: Date | string): number;
|
|
137
618
|
}
|
|
@@ -38,6 +38,8 @@ export declare function isTypeAssignableToAt(ctx: GildashContext, opts: {
|
|
|
38
38
|
}): boolean | null;
|
|
39
39
|
/** Retrieve the semantic module interface — exported symbols with resolved types. */
|
|
40
40
|
export declare function getSemanticModuleInterface(ctx: GildashContext, filePath: string): SemanticModuleInterface;
|
|
41
|
+
/** Retrieve the base types (supertypes) of a class/interface at a byte offset. */
|
|
42
|
+
export declare function getBaseTypes(ctx: GildashContext, filePath: string, position: number): ResolvedType[] | null;
|
|
41
43
|
/** Retrieve the resolved type at a byte offset without line/column conversion. */
|
|
42
44
|
export declare function getResolvedTypeAtPosition(ctx: GildashContext, filePath: string, position: number): ResolvedType | null;
|
|
43
45
|
/** Find all semantic references at a byte offset. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ParsedFile } from '../parser/types';
|
|
2
|
-
import type { SymbolSearchResult } from '../search/symbol-search';
|
|
3
|
-
import type { SymbolKind } from '../extractor/types';
|
|
2
|
+
import type { SymbolSearchResult, SymbolDetail } from '../search/symbol-search';
|
|
3
|
+
import type { SymbolKind, Decorator } from '../extractor/types';
|
|
4
4
|
import type { ResolvedType } from '../semantic/types';
|
|
5
5
|
/**
|
|
6
6
|
* Minimal logger interface accepted by {@link Gildash}.
|
|
@@ -52,32 +52,24 @@ export interface HeritageNode {
|
|
|
52
52
|
/**
|
|
53
53
|
* Full symbol detail including members, documentation, and type information.
|
|
54
54
|
* Returned by {@link Gildash.getFullSymbol}.
|
|
55
|
+
*
|
|
56
|
+
* Fields are lifted directly from {@link SymbolDetail} for convenient access.
|
|
55
57
|
*/
|
|
56
58
|
export interface FullSymbol extends SymbolSearchResult {
|
|
57
59
|
/** Class/interface members (methods, properties, constructors, accessors). */
|
|
58
|
-
members?:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
isReadonly?: boolean;
|
|
65
|
-
}>;
|
|
66
|
-
/** JSDoc comment attached to the symbol. */
|
|
67
|
-
jsDoc?: string;
|
|
68
|
-
/** Stringified parameter list (functions/methods). */
|
|
69
|
-
parameters?: string;
|
|
70
|
-
/** Stringified return type (functions/methods). */
|
|
60
|
+
members?: SymbolDetail['members'];
|
|
61
|
+
/** Parsed JSDoc comment attached to the symbol. */
|
|
62
|
+
jsDoc?: SymbolDetail['jsDoc'];
|
|
63
|
+
/** Function/method parameters. */
|
|
64
|
+
parameters?: SymbolDetail['parameters'];
|
|
65
|
+
/** Return type annotation as source text. */
|
|
71
66
|
returnType?: string;
|
|
72
|
-
/**
|
|
73
|
-
heritage?:
|
|
67
|
+
/** Heritage clauses (`extends` / `implements`). */
|
|
68
|
+
heritage?: SymbolDetail['heritage'];
|
|
74
69
|
/** Decorators applied to the symbol. */
|
|
75
|
-
decorators?:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}>;
|
|
79
|
-
/** Stringified type parameters (generic symbols). */
|
|
80
|
-
typeParameters?: string;
|
|
70
|
+
decorators?: Decorator[];
|
|
71
|
+
/** Generic type parameter names. */
|
|
72
|
+
typeParameters?: string[];
|
|
81
73
|
/** Resolved type from the Semantic Layer (available when `semantic: true`). */
|
|
82
74
|
resolvedType?: ResolvedType;
|
|
83
75
|
}
|