@zipbul/gildash 0.0.2 → 0.2.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.
@@ -1,5 +1,12 @@
1
+ /**
2
+ * A discovered sub-project within the indexed project root.
3
+ *
4
+ * Returned by {@link Gildash.projects}.
5
+ */
1
6
  export interface ProjectBoundary {
7
+ /** Relative directory path from the project root. */
2
8
  dir: string;
9
+ /** Unique project name (typically the `name` field from `package.json`). */
3
10
  project: string;
4
11
  }
5
12
  export declare function discoverProjects(projectRoot: string): Promise<ProjectBoundary[]>;
@@ -1,42 +1,22 @@
1
1
  /**
2
- * Base error class for all Gildash errors.
3
- * Every error thrown by this library is an instance of `GildashError`.
4
- *
5
- * @example
6
- * ```ts
7
- * try {
8
- * await Gildash.open({ projectRoot: '/path' });
9
- * } catch (err) {
10
- * if (err instanceof GildashError) {
11
- * console.error('Gildash error:', err.message);
12
- * }
13
- * }
14
- * ```
2
+ * Discriminated union type representing all possible error categories in Gildash.
15
3
  */
16
- export declare class GildashError extends Error {
17
- constructor(message: string, options?: ErrorOptions);
18
- }
19
- /** Thrown when the file watcher fails to start or stop. */
20
- export declare class WatcherError extends GildashError {
21
- constructor(message: string, options?: ErrorOptions);
22
- }
23
- /** Thrown when AST parsing of a TypeScript file fails. */
24
- export declare class ParseError extends GildashError {
25
- constructor(message: string, options?: ErrorOptions);
26
- }
27
- /** Thrown when symbol or relation extraction from a parsed AST fails. */
28
- export declare class ExtractError extends GildashError {
29
- constructor(message: string, options?: ErrorOptions);
30
- }
31
- /** Thrown when the indexing pipeline encounters an unrecoverable error. */
32
- export declare class IndexError extends GildashError {
33
- constructor(message: string, options?: ErrorOptions);
34
- }
35
- /** Thrown when a database (SQLite) operation fails. */
36
- export declare class StoreError extends GildashError {
37
- constructor(message: string, options?: ErrorOptions);
38
- }
39
- /** Thrown when a search query (symbol search, relation search) fails. */
40
- export declare class SearchError extends GildashError {
41
- constructor(message: string, options?: ErrorOptions);
4
+ export type GildashErrorType = 'watcher' | 'parse' | 'extract' | 'index' | 'store' | 'search' | 'closed' | 'validation' | 'close';
5
+ /**
6
+ * Plain-object error value used throughout Gildash's Result-based error handling.
7
+ * Produced by {@link gildashError} and carried as the `data` field of an `Err<GildashError>`.
8
+ */
9
+ export interface GildashError {
10
+ type: GildashErrorType;
11
+ message: string;
12
+ cause?: unknown;
42
13
  }
14
+ /**
15
+ * Factory function that creates a {@link GildashError} value.
16
+ *
17
+ * @param type - One of the {@link GildashErrorType} variants.
18
+ * @param message - Human-readable description of the error.
19
+ * @param cause - Optional root cause (any value). When `undefined`, the `cause`
20
+ * property is omitted from the returned object entirely.
21
+ */
22
+ export declare function gildashError(type: GildashErrorType, message: string, cause?: unknown): GildashError;
@@ -1,3 +1,4 @@
1
+ import { type Result } from '@zipbul/result';
1
2
  import type { ParsedFile } from './parser/types';
2
3
  import { parseSource as defaultParseSource } from './parser/parse-source';
3
4
  import { ParseCache } from './parser/parse-cache';
@@ -24,6 +25,7 @@ import type { SymbolSearchQuery, SymbolSearchResult } from './search/symbol-sear
24
25
  import { relationSearch as defaultRelationSearch } from './search/relation-search';
25
26
  import type { RelationSearchQuery } from './search/relation-search';
26
27
  import type { SymbolStats } from './store/repositories/symbol.repository';
28
+ import { type GildashError } from './errors';
27
29
  /**
28
30
  * Minimal logger interface accepted by {@link Gildash}.
29
31
  *
@@ -38,11 +40,18 @@ export interface Logger {
38
40
  *
39
41
  * @example
40
42
  * ```ts
41
- * const ledger = await Gildash.open({
43
+ * import { isErr } from '@zipbul/result';
44
+ *
45
+ * const result = await Gildash.open({
42
46
  * projectRoot: '/absolute/path/to/project',
43
47
  * extensions: ['.ts', '.tsx'],
44
48
  * ignorePatterns: ['vendor'],
45
49
  * });
50
+ * if (isErr(result)) {
51
+ * console.error(result.data.message);
52
+ * process.exit(1);
53
+ * }
54
+ * const ledger = result;
46
55
  * ```
47
56
  */
48
57
  export interface GildashOptions {
@@ -88,15 +97,30 @@ interface GildashInternalOptions {
88
97
  * `Gildash` indexes TypeScript source code into a local SQLite database,
89
98
  * watches for file changes, and provides search / dependency-graph queries.
90
99
  *
100
+ * Every public method returns a `Result<T, GildashError>` — either the
101
+ * success value `T` directly, or an `Err<GildashError>` that can be checked
102
+ * with `isErr()` from `@zipbul/result`.
103
+ *
91
104
  * Create an instance with the static {@link Gildash.open} factory.
92
105
  * Always call {@link Gildash.close} when done to release resources.
93
106
  *
94
107
  * @example
95
108
  * ```ts
96
109
  * import { Gildash } from '@zipbul/gildash';
110
+ * import { isErr } from '@zipbul/result';
111
+ *
112
+ * const result = await Gildash.open({ projectRoot: '/my/project' });
113
+ * if (isErr(result)) {
114
+ * console.error(result.data.message);
115
+ * process.exit(1);
116
+ * }
117
+ * const ledger = result;
97
118
  *
98
- * const ledger = await Gildash.open({ projectRoot: '/my/project' });
99
119
  * const symbols = ledger.searchSymbols({ text: 'handle', kind: 'function' });
120
+ * if (!isErr(symbols)) {
121
+ * symbols.forEach(s => console.log(s.name));
122
+ * }
123
+ *
100
124
  * await ledger.close();
101
125
  * ```
102
126
  */
@@ -117,7 +141,8 @@ export declare class Gildash {
117
141
  private readonly relationSearchFn;
118
142
  private readonly logger;
119
143
  private readonly defaultProject;
120
- private readonly role;
144
+ /** Current watcher role: `'owner'` (can reindex) or `'reader'` (read-only). */
145
+ readonly role: 'owner' | 'reader';
121
146
  private timer;
122
147
  private signalHandlers;
123
148
  private closed;
@@ -133,18 +158,19 @@ export declare class Gildash {
133
158
  * and begins watching for file changes.
134
159
  *
135
160
  * @param options - Configuration for the instance.
136
- * @returns A fully-initialised `Gildash` ready for queries.
137
- * @throws {Error} If `projectRoot` is not absolute or does not exist.
161
+ * @returns A fully-initialised `Gildash` ready for queries, or an `Err<GildashError>` on failure.
138
162
  *
139
163
  * @example
140
164
  * ```ts
141
- * const ledger = await Gildash.open({
165
+ * const result = await Gildash.open({
142
166
  * projectRoot: '/home/user/my-app',
143
167
  * extensions: ['.ts', '.tsx'],
144
168
  * });
169
+ * if (isErr(result)) { console.error(result.data.message); process.exit(1); }
170
+ * const ledger = result;
145
171
  * ```
146
172
  */
147
- static open(options: GildashOptions & GildashInternalOptions): Promise<Gildash>;
173
+ static open(options: GildashOptions & GildashInternalOptions): Promise<Result<Gildash, GildashError>>;
148
174
  /**
149
175
  * Shut down the instance and release all resources.
150
176
  *
@@ -152,9 +178,20 @@ export declare class Gildash {
152
178
  * releases the watcher ownership role, and closes the database.
153
179
  * Calling `close()` more than once is safe (subsequent calls are no-ops).
154
180
  *
155
- * @throws {AggregateError} If one or more sub-systems fail during shutdown.
181
+ * @returns `void` on success, or `Err<GildashError>` with `type='close'` if one or more
182
+ * sub-systems failed during shutdown. The `cause` field contains an array of
183
+ * individual errors from each failed sub-system.
184
+ *
185
+ * @example
186
+ * ```ts
187
+ * const closeResult = await ledger.close();
188
+ * if (isErr(closeResult)) {
189
+ * console.error('Close failed:', closeResult.data.message);
190
+ * // closeResult.data.cause is unknown[] of per-subsystem errors
191
+ * }
192
+ * ```
156
193
  */
157
- close(): Promise<void>;
194
+ close(): Promise<Result<void, GildashError>>;
158
195
  /**
159
196
  * Register a callback that fires after each indexing run completes.
160
197
  *
@@ -174,38 +211,86 @@ export declare class Gildash {
174
211
  /**
175
212
  * Parse a TypeScript source string into an AST and cache the result.
176
213
  *
214
+ * On success the result is automatically stored in the internal LRU parse cache
215
+ * so that subsequent calls to extraction methods can reuse it.
216
+ *
177
217
  * @param filePath - File path used as the cache key and for diagnostics.
178
218
  * @param sourceText - Raw TypeScript source code.
179
- * @returns The parsed file representation.
180
- * @throws {Error} If the instance is closed.
219
+ * @returns A {@link ParsedFile}, or `Err<GildashError>` with `type='closed'` if the instance
220
+ * is closed, or `type='parse'` if the parser fails.
221
+ *
222
+ * @example
223
+ * ```ts
224
+ * const parsed = ledger.parseSource('/project/src/app.ts', sourceCode);
225
+ * if (isErr(parsed)) {
226
+ * console.error(parsed.data.message); // e.g. "Failed to parse file: ..."
227
+ * return;
228
+ * }
229
+ * // parsed is now a ParsedFile
230
+ * const symbols = ledger.extractSymbols(parsed);
231
+ * ```
181
232
  */
182
- parseSource(filePath: string, sourceText: string): ParsedFile;
233
+ parseSource(filePath: string, sourceText: string): Result<ParsedFile, GildashError>;
183
234
  /**
184
235
  * Extract all symbol declarations from a previously parsed file.
185
236
  *
237
+ * Returns function, class, variable, type-alias, interface, and enum declarations
238
+ * found in the AST.
239
+ *
186
240
  * @param parsed - A {@link ParsedFile} obtained from {@link parseSource}.
187
- * @returns An array of {@link ExtractedSymbol} entries.
188
- * @throws {Error} If the instance is closed.
241
+ * @returns An array of {@link ExtractedSymbol} entries, or `Err<GildashError>` with
242
+ * `type='closed'` if the instance is closed.
243
+ *
244
+ * @example
245
+ * ```ts
246
+ * const symbols = ledger.extractSymbols(parsed);
247
+ * if (isErr(symbols)) return;
248
+ * for (const sym of symbols) {
249
+ * console.log(`${sym.kind}: ${sym.name}`);
250
+ * }
251
+ * ```
189
252
  */
190
- extractSymbols(parsed: ParsedFile): ExtractedSymbol[];
253
+ extractSymbols(parsed: ParsedFile): Result<ExtractedSymbol[], GildashError>;
191
254
  /**
192
255
  * Extract inter-file relationships (imports, calls, extends, implements)
193
256
  * from a previously parsed file.
194
257
  *
258
+ * If tsconfig path aliases were discovered during {@link Gildash.open},
259
+ * they are automatically applied when resolving import targets.
260
+ *
195
261
  * @param parsed - A {@link ParsedFile} obtained from {@link parseSource}.
196
- * @returns An array of {@link CodeRelation} entries.
197
- * @throws {Error} If the instance is closed.
262
+ * @returns An array of {@link CodeRelation} entries, or `Err<GildashError>` with
263
+ * `type='closed'` if the instance is closed.
264
+ *
265
+ * @example
266
+ * ```ts
267
+ * const relations = ledger.extractRelations(parsed);
268
+ * if (isErr(relations)) return;
269
+ * const imports = relations.filter(r => r.type === 'imports');
270
+ * ```
198
271
  */
199
- extractRelations(parsed: ParsedFile): CodeRelation[];
272
+ extractRelations(parsed: ParsedFile): Result<CodeRelation[], GildashError>;
200
273
  /**
201
274
  * Trigger a full re-index of all tracked files.
202
275
  *
203
276
  * Only available to the instance that holds the *owner* role.
277
+ * Reader instances receive `Err<GildashError>` with `type='closed'`.
204
278
  *
205
- * @returns The indexing result summary.
206
- * @throws {Error} If the instance is closed or is a reader.
279
+ * @returns An {@link IndexResult} summary on success, or `Err<GildashError>` with
280
+ * `type='closed'` if the instance is closed / reader,
281
+ * `type='index'` if the indexing pipeline fails.
282
+ *
283
+ * @example
284
+ * ```ts
285
+ * const result = await ledger.reindex();
286
+ * if (isErr(result)) {
287
+ * console.error(result.data.message);
288
+ * return;
289
+ * }
290
+ * console.log(`Indexed ${result.indexedFiles} files in ${result.durationMs}ms`);
291
+ * ```
207
292
  */
208
- reindex(): Promise<IndexResult>;
293
+ reindex(): Promise<Result<IndexResult, GildashError>>;
209
294
  /**
210
295
  * Discovered project boundaries within the project root.
211
296
  *
@@ -216,69 +301,124 @@ export declare class Gildash {
216
301
  * Return aggregate symbol statistics for the given project.
217
302
  *
218
303
  * @param project - Project name. Defaults to the auto-discovered primary project.
219
- * @returns Counts grouped by symbol kind.
220
- * @throws {Error} If the instance is closed.
304
+ * @returns A {@link SymbolStats} object with counts grouped by symbol kind,
305
+ * or `Err<GildashError>` with `type='closed'` if the instance is closed,
306
+ * `type='store'` if the database query fails.
307
+ *
308
+ * @example
309
+ * ```ts
310
+ * const stats = ledger.getStats();
311
+ * if (isErr(stats)) return;
312
+ * console.log(`Files: ${stats.fileCount}, Symbols: ${stats.symbolCount}`);
313
+ * ```
221
314
  */
222
- getStats(project?: string): SymbolStats;
315
+ getStats(project?: string): Result<SymbolStats, GildashError>;
223
316
  /**
224
317
  * Search indexed symbols by name, kind, file path, or export status.
225
318
  *
226
- * @param query - Search filters. All fields are optional; omitted fields match everything.
227
- * @returns Matching {@link SymbolSearchResult} entries.
228
- * @throws {Error} If the instance is closed.
319
+ * @param query - Search filters (see {@link SymbolSearchQuery}). All fields are optional;
320
+ * omitted fields match everything.
321
+ * @returns An array of {@link SymbolSearchResult} entries, or `Err<GildashError>` with
322
+ * `type='closed'` if the instance is closed,
323
+ * `type='search'` if the query fails.
229
324
  *
230
325
  * @example
231
326
  * ```ts
232
327
  * const fns = ledger.searchSymbols({ kind: 'function', isExported: true });
328
+ * if (isErr(fns)) return;
329
+ * fns.forEach(fn => console.log(fn.name, fn.filePath));
233
330
  * ```
234
331
  */
235
- searchSymbols(query: SymbolSearchQuery): SymbolSearchResult[];
332
+ searchSymbols(query: SymbolSearchQuery): Result<SymbolSearchResult[], GildashError>;
236
333
  /**
237
334
  * Search indexed code relationships (imports, calls, extends, implements).
238
335
  *
239
- * @param query - Search filters. All fields are optional.
240
- * @returns Matching {@link CodeRelation} entries.
241
- * @throws {Error} If the instance is closed.
336
+ * @param query - Search filters (see {@link RelationSearchQuery}). All fields are optional.
337
+ * @returns An array of {@link CodeRelation} entries, or `Err<GildashError>` with
338
+ * `type='closed'` if the instance is closed,
339
+ * `type='search'` if the query fails.
340
+ *
341
+ * @example
342
+ * ```ts
343
+ * const rels = ledger.searchRelations({ srcFilePath: 'src/app.ts', type: 'imports' });
344
+ * if (isErr(rels)) return;
345
+ * rels.forEach(r => console.log(`${r.srcFilePath} -> ${r.dstFilePath}`));
346
+ * ```
242
347
  */
243
- searchRelations(query: RelationSearchQuery): CodeRelation[];
348
+ searchRelations(query: RelationSearchQuery): Result<CodeRelation[], GildashError>;
244
349
  /**
245
350
  * List the files that a given file directly imports.
246
351
  *
247
352
  * @param filePath - Absolute path of the source file.
248
353
  * @param project - Project name. Defaults to the primary project.
249
354
  * @param limit - Maximum results. Defaults to `10_000`.
250
- * @returns Absolute paths of imported files.
251
- * @throws {Error} If the instance is closed.
355
+ * @returns An array of absolute paths that `filePath` imports,
356
+ * or `Err<GildashError>` with `type='closed'` / `type='search'`.
357
+ *
358
+ * @example
359
+ * ```ts
360
+ * const deps = ledger.getDependencies('/project/src/app.ts');
361
+ * if (isErr(deps)) return;
362
+ * console.log('Imports:', deps.join(', '));
363
+ * ```
252
364
  */
253
- getDependencies(filePath: string, project?: string, limit?: number): string[];
365
+ getDependencies(filePath: string, project?: string, limit?: number): Result<string[], GildashError>;
254
366
  /**
255
367
  * List the files that directly import a given file.
256
368
  *
257
369
  * @param filePath - Absolute path of the target file.
258
370
  * @param project - Project name. Defaults to the primary project.
259
371
  * @param limit - Maximum results. Defaults to `10_000`.
260
- * @returns Absolute paths of files that import the target.
261
- * @throws {Error} If the instance is closed.
372
+ * @returns An array of absolute paths of files that import `filePath`,
373
+ * or `Err<GildashError>` with `type='closed'` / `type='search'`.
374
+ *
375
+ * @example
376
+ * ```ts
377
+ * const dependents = ledger.getDependents('/project/src/utils.ts');
378
+ * if (isErr(dependents)) return;
379
+ * console.log('Imported by:', dependents.join(', '));
380
+ * ```
262
381
  */
263
- getDependents(filePath: string, project?: string, limit?: number): string[];
382
+ getDependents(filePath: string, project?: string, limit?: number): Result<string[], GildashError>;
264
383
  /**
265
384
  * Compute the full set of files transitively affected by changes.
266
385
  *
267
- * Builds a dependency graph and walks all reverse edges from each changed file.
386
+ * Internally builds a full {@link DependencyGraph} and walks all reverse
387
+ * edges from each changed file to find every transitive dependent.
268
388
  *
269
389
  * @param changedFiles - Absolute paths of files that changed.
270
390
  * @param project - Project name. Defaults to the primary project.
271
- * @returns Paths of all transitively-dependent files (excludes the changed files themselves).
272
- * @throws {Error} If the instance is closed.
391
+ * @returns De-duplicated absolute paths of all transitively-dependent files
392
+ * (excluding the changed files themselves), or `Err<GildashError>` with
393
+ * `type='closed'` / `type='search'`.
394
+ *
395
+ * @example
396
+ * ```ts
397
+ * const affected = await ledger.getAffected(['/project/src/utils.ts']);
398
+ * if (isErr(affected)) return;
399
+ * console.log('Affected files:', affected.length);
400
+ * ```
273
401
  */
274
- getAffected(changedFiles: string[], project?: string): Promise<string[]>;
402
+ getAffected(changedFiles: string[], project?: string): Promise<Result<string[], GildashError>>;
275
403
  /**
276
404
  * Check whether the import graph contains a circular dependency.
277
405
  *
406
+ * Internally builds a full {@link DependencyGraph} and runs iterative DFS
407
+ * cycle detection.
408
+ *
278
409
  * @param project - Project name. Defaults to the primary project.
279
- * @returns `true` if at least one cycle exists.
280
- * @throws {Error} If the instance is closed.
410
+ * @returns `true` if at least one cycle exists, `false` otherwise,
411
+ * or `Err<GildashError>` with `type='closed'` / `type='search'`.
412
+ *
413
+ * @example
414
+ * ```ts
415
+ * const cycleResult = await ledger.hasCycle();
416
+ * if (isErr(cycleResult)) return;
417
+ * if (cycleResult) {
418
+ * console.warn('Circular dependency detected!');
419
+ * }
420
+ * ```
281
421
  */
282
- hasCycle(project?: string): Promise<boolean>;
422
+ hasCycle(project?: string): Promise<Result<boolean, GildashError>>;
283
423
  }
284
424
  export {};
@@ -1,8 +1,14 @@
1
1
  export { Gildash } from "./gildash";
2
2
  export type { GildashOptions, Logger } from "./gildash";
3
- export { GildashError, WatcherError, ParseError, ExtractError, IndexError, StoreError, SearchError, } from "./errors";
3
+ export { gildashError } from "./errors";
4
+ export type { GildashError, GildashErrorType } from "./errors";
4
5
  export { symbolSearch } from "./search/symbol-search";
5
6
  export type { SymbolSearchQuery, SymbolSearchResult } from "./search/symbol-search";
6
7
  export { relationSearch } from "./search/relation-search";
7
8
  export type { RelationSearchQuery } from "./search/relation-search";
8
9
  export { DependencyGraph } from "./search/dependency-graph";
10
+ export type { IndexResult } from "./indexer/index-coordinator";
11
+ export type { ProjectBoundary } from "./common/project-discovery";
12
+ export type { CodeRelation, SymbolKind } from "./extractor/types";
13
+ export type { SymbolStats } from "./store/repositories/symbol.repository";
14
+ export type { WatcherRole } from "./watcher/types";
@@ -9,14 +9,27 @@ import type { SymbolRecord } from '../store/repositories/symbol.repository';
9
9
  import type { RelationRecord } from '../store/repositories/relation.repository';
10
10
  import type { Logger } from '../gildash';
11
11
  export declare const WATCHER_DEBOUNCE_MS = 100;
12
+ /**
13
+ * Summary returned after an indexing run completes.
14
+ *
15
+ * Received via {@link Gildash.reindex} and the {@link Gildash.onIndexed} callback.
16
+ */
12
17
  export interface IndexResult {
18
+ /** Number of files that were (re-)indexed. */
13
19
  indexedFiles: number;
20
+ /** Number of files removed from the index. */
14
21
  removedFiles: number;
22
+ /** Total symbol count after indexing. */
15
23
  totalSymbols: number;
24
+ /** Total relation count after indexing. */
16
25
  totalRelations: number;
26
+ /** Wall-clock duration of the indexing run in milliseconds. */
17
27
  durationMs: number;
28
+ /** Absolute paths of files that changed and were re-indexed. */
18
29
  changedFiles: string[];
30
+ /** Absolute paths of files that were deleted from the index. */
19
31
  deletedFiles: string[];
32
+ /** Absolute paths of files that failed to index. */
20
33
  failedFiles: string[];
21
34
  }
22
35
  export interface IndexCoordinatorOptions {
@@ -1,2 +1,4 @@
1
+ import { type Result } from '@zipbul/result';
1
2
  import type { JsDocBlock } from '../extractor/types';
2
- export declare function parseJsDoc(commentText: string): JsDocBlock;
3
+ import { type GildashError } from '../errors';
4
+ export declare function parseJsDoc(commentText: string): Result<JsDocBlock, GildashError>;
@@ -1,3 +1,5 @@
1
+ import { type Result } from '@zipbul/result';
1
2
  import { parseSync as defaultParseSync } from 'oxc-parser';
2
3
  import type { ParsedFile } from './types';
3
- export declare function parseSource(filePath: string, sourceText: string, parseSyncFn?: typeof defaultParseSync): ParsedFile;
4
+ import { type GildashError } from '../errors';
5
+ export declare function parseSource(filePath: string, sourceText: string, parseSyncFn?: typeof defaultParseSync): Result<ParsedFile, GildashError>;
@@ -1,4 +1,6 @@
1
+ import { type Result } from '@zipbul/result';
1
2
  import { type BunSQLiteDatabase } from 'drizzle-orm/bun-sqlite';
3
+ import { type GildashError } from '../errors';
2
4
  import * as schema from './schema';
3
5
  export interface DbConnectionOptions {
4
6
  projectRoot: string;
@@ -10,7 +12,7 @@ export declare class DbConnection {
10
12
  private txDepth;
11
13
  constructor(opts: DbConnectionOptions);
12
14
  get drizzleDb(): BunSQLiteDatabase<typeof schema>;
13
- open(): void;
15
+ open(): Result<void, GildashError>;
14
16
  close(): void;
15
17
  transaction<T>(fn: (tx: DbConnection) => T): T;
16
18
  immediateTransaction<T>(fn: () => T): T;
@@ -19,8 +19,15 @@ export interface SearchOptions {
19
19
  kind?: string;
20
20
  limit?: number;
21
21
  }
22
+ /**
23
+ * Aggregate symbol statistics for a project.
24
+ *
25
+ * Returned by {@link Gildash.getStats}.
26
+ */
22
27
  export interface SymbolStats {
28
+ /** Total number of indexed symbols. */
23
29
  symbolCount: number;
30
+ /** Total number of indexed source files. */
24
31
  fileCount: number;
25
32
  }
26
33
  export declare class SymbolRepository {
@@ -1,13 +1,15 @@
1
+ import { type Result } from '@zipbul/result';
1
2
  import type { AsyncSubscription, SubscribeCallback } from "@parcel/watcher";
2
3
  import { subscribe as parcelSubscribe } from "@parcel/watcher";
3
4
  type SubscribeOptions = NonNullable<Parameters<typeof parcelSubscribe>[2]>;
5
+ import { type GildashError } from "../errors";
4
6
  import type { FileChangeEvent, WatcherOptions } from "./types";
5
7
  import type { Logger } from "../gildash";
6
8
  type SubscribeFn = (directoryPath: string, callback: SubscribeCallback, options?: SubscribeOptions) => Promise<AsyncSubscription>;
7
9
  export declare class ProjectWatcher {
8
10
  #private;
9
11
  constructor(options: WatcherOptions, subscribeFn?: SubscribeFn, logger?: Logger);
10
- start(onChange: (event: FileChangeEvent) => void): Promise<void>;
11
- close(): Promise<void>;
12
+ start(onChange: (event: FileChangeEvent) => void): Promise<Result<void, GildashError>>;
13
+ close(): Promise<Result<void, GildashError>>;
12
14
  }
13
15
  export {};
@@ -8,4 +8,10 @@ export interface WatcherOptions {
8
8
  ignorePatterns?: string[];
9
9
  extensions?: string[];
10
10
  }
11
+ /**
12
+ * The role acquired by a {@link Gildash} instance.
13
+ *
14
+ * - `'owner'` — the instance owns the file watcher and can trigger re-indexing.
15
+ * - `'reader'` — the instance shares the database but cannot trigger re-indexing.
16
+ */
11
17
  export type WatcherRole = "owner" | "reader";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zipbul/gildash",
3
- "version": "0.0.2",
3
+ "version": "0.2.0",
4
4
  "description": "TypeScript code indexing and dependency graph engine for Bun",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -35,7 +35,7 @@
35
35
  "build": "bun build index.ts --outdir dist --target bun --format esm --packages external --sourcemap=linked --production && tsc -p tsconfig.build.json && cp -r src/store/migrations dist/migrations",
36
36
  "typecheck": "tsc --noEmit",
37
37
  "test": "bun test",
38
- "coverage": "bun test --coverage",
38
+ "test:coverage": "bun test --coverage",
39
39
  "changeset": "changeset",
40
40
  "version-packages": "changeset version",
41
41
  "release": "changeset publish"
@@ -54,5 +54,8 @@
54
54
  "@types/bun": "latest",
55
55
  "drizzle-kit": "^0.31.9",
56
56
  "husky": "^9.1.7"
57
+ },
58
+ "peerDependencies": {
59
+ "@zipbul/result": "^0.0.3"
57
60
  }
58
- }
61
+ }