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