@zipbul/gildash 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ko.md +28 -6
- package/README.md +29 -5
- package/dist/index.js +7 -5
- package/dist/index.js.map +42 -28
- package/dist/migrations/0003_majestic_mongu.sql +1 -0
- package/dist/migrations/0004_cool_firestar.sql +23 -0
- package/dist/migrations/meta/0003_snapshot.json +422 -0
- package/dist/migrations/meta/0004_snapshot.json +429 -0
- package/dist/migrations/meta/_journal.json +14 -0
- package/dist/src/errors.d.ts +1 -1
- package/dist/src/extractor/relation-extractor.d.ts +2 -1
- package/dist/src/gildash/context.d.ts +91 -0
- package/dist/src/gildash/extract-api.d.ts +9 -0
- package/dist/src/gildash/graph-api.d.ts +30 -0
- package/dist/src/gildash/index.d.ts +92 -0
- package/dist/src/gildash/lifecycle.d.ts +62 -0
- package/dist/src/gildash/misc-api.d.ts +22 -0
- package/dist/src/gildash/parse-api.d.ts +11 -0
- package/dist/src/gildash/query-api.d.ts +35 -0
- package/dist/src/gildash/semantic-api.d.ts +22 -0
- package/dist/src/gildash/types.d.ts +160 -0
- package/dist/src/index.d.ts +2 -1
- package/dist/src/indexer/index-coordinator.d.ts +8 -2
- package/dist/src/indexer/relation-indexer.d.ts +6 -0
- package/dist/src/search/dependency-graph.d.ts +1 -0
- package/dist/src/search/relation-search.d.ts +11 -1
- package/dist/src/search/symbol-search.d.ts +6 -0
- package/dist/src/semantic/ast-node-utils.d.ts +9 -0
- package/dist/src/semantic/implementation-finder.d.ts +22 -0
- package/dist/src/semantic/index.d.ts +68 -0
- package/dist/src/semantic/reference-resolver.d.ts +19 -0
- package/dist/src/semantic/symbol-graph.d.ts +36 -0
- package/dist/src/semantic/tsc-program.d.ts +67 -0
- package/dist/src/semantic/type-collector.d.ts +27 -0
- package/dist/src/semantic/types.d.ts +103 -0
- package/dist/src/store/repositories/relation.repository.d.ts +14 -2
- package/dist/src/store/repositories/symbol.repository.d.ts +2 -0
- package/dist/src/store/schema.d.ts +38 -0
- package/package.json +3 -2
- package/dist/src/gildash.d.ts +0 -821
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "6",
|
|
3
|
+
"dialect": "sqlite",
|
|
4
|
+
"id": "4792483b-0af0-4775-a2df-c04b8066770e",
|
|
5
|
+
"prevId": "5b9c3951-b14d-4b77-b125-ca1e30793c73",
|
|
6
|
+
"tables": {
|
|
7
|
+
"files": {
|
|
8
|
+
"name": "files",
|
|
9
|
+
"columns": {
|
|
10
|
+
"project": {
|
|
11
|
+
"name": "project",
|
|
12
|
+
"type": "text",
|
|
13
|
+
"primaryKey": false,
|
|
14
|
+
"notNull": true,
|
|
15
|
+
"autoincrement": false
|
|
16
|
+
},
|
|
17
|
+
"file_path": {
|
|
18
|
+
"name": "file_path",
|
|
19
|
+
"type": "text",
|
|
20
|
+
"primaryKey": false,
|
|
21
|
+
"notNull": true,
|
|
22
|
+
"autoincrement": false
|
|
23
|
+
},
|
|
24
|
+
"mtime_ms": {
|
|
25
|
+
"name": "mtime_ms",
|
|
26
|
+
"type": "real",
|
|
27
|
+
"primaryKey": false,
|
|
28
|
+
"notNull": true,
|
|
29
|
+
"autoincrement": false
|
|
30
|
+
},
|
|
31
|
+
"size": {
|
|
32
|
+
"name": "size",
|
|
33
|
+
"type": "integer",
|
|
34
|
+
"primaryKey": false,
|
|
35
|
+
"notNull": true,
|
|
36
|
+
"autoincrement": false
|
|
37
|
+
},
|
|
38
|
+
"content_hash": {
|
|
39
|
+
"name": "content_hash",
|
|
40
|
+
"type": "text",
|
|
41
|
+
"primaryKey": false,
|
|
42
|
+
"notNull": true,
|
|
43
|
+
"autoincrement": false
|
|
44
|
+
},
|
|
45
|
+
"updated_at": {
|
|
46
|
+
"name": "updated_at",
|
|
47
|
+
"type": "text",
|
|
48
|
+
"primaryKey": false,
|
|
49
|
+
"notNull": true,
|
|
50
|
+
"autoincrement": false
|
|
51
|
+
},
|
|
52
|
+
"line_count": {
|
|
53
|
+
"name": "line_count",
|
|
54
|
+
"type": "integer",
|
|
55
|
+
"primaryKey": false,
|
|
56
|
+
"notNull": false,
|
|
57
|
+
"autoincrement": false
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"indexes": {},
|
|
61
|
+
"foreignKeys": {},
|
|
62
|
+
"compositePrimaryKeys": {
|
|
63
|
+
"files_project_file_path_pk": {
|
|
64
|
+
"columns": [
|
|
65
|
+
"project",
|
|
66
|
+
"file_path"
|
|
67
|
+
],
|
|
68
|
+
"name": "files_project_file_path_pk"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"uniqueConstraints": {},
|
|
72
|
+
"checkConstraints": {}
|
|
73
|
+
},
|
|
74
|
+
"relations": {
|
|
75
|
+
"name": "relations",
|
|
76
|
+
"columns": {
|
|
77
|
+
"id": {
|
|
78
|
+
"name": "id",
|
|
79
|
+
"type": "integer",
|
|
80
|
+
"primaryKey": true,
|
|
81
|
+
"notNull": true,
|
|
82
|
+
"autoincrement": true
|
|
83
|
+
},
|
|
84
|
+
"project": {
|
|
85
|
+
"name": "project",
|
|
86
|
+
"type": "text",
|
|
87
|
+
"primaryKey": false,
|
|
88
|
+
"notNull": true,
|
|
89
|
+
"autoincrement": false
|
|
90
|
+
},
|
|
91
|
+
"type": {
|
|
92
|
+
"name": "type",
|
|
93
|
+
"type": "text",
|
|
94
|
+
"primaryKey": false,
|
|
95
|
+
"notNull": true,
|
|
96
|
+
"autoincrement": false
|
|
97
|
+
},
|
|
98
|
+
"src_file_path": {
|
|
99
|
+
"name": "src_file_path",
|
|
100
|
+
"type": "text",
|
|
101
|
+
"primaryKey": false,
|
|
102
|
+
"notNull": true,
|
|
103
|
+
"autoincrement": false
|
|
104
|
+
},
|
|
105
|
+
"src_symbol_name": {
|
|
106
|
+
"name": "src_symbol_name",
|
|
107
|
+
"type": "text",
|
|
108
|
+
"primaryKey": false,
|
|
109
|
+
"notNull": false,
|
|
110
|
+
"autoincrement": false
|
|
111
|
+
},
|
|
112
|
+
"dst_project": {
|
|
113
|
+
"name": "dst_project",
|
|
114
|
+
"type": "text",
|
|
115
|
+
"primaryKey": false,
|
|
116
|
+
"notNull": true,
|
|
117
|
+
"autoincrement": false
|
|
118
|
+
},
|
|
119
|
+
"dst_file_path": {
|
|
120
|
+
"name": "dst_file_path",
|
|
121
|
+
"type": "text",
|
|
122
|
+
"primaryKey": false,
|
|
123
|
+
"notNull": true,
|
|
124
|
+
"autoincrement": false
|
|
125
|
+
},
|
|
126
|
+
"dst_symbol_name": {
|
|
127
|
+
"name": "dst_symbol_name",
|
|
128
|
+
"type": "text",
|
|
129
|
+
"primaryKey": false,
|
|
130
|
+
"notNull": false,
|
|
131
|
+
"autoincrement": false
|
|
132
|
+
},
|
|
133
|
+
"meta_json": {
|
|
134
|
+
"name": "meta_json",
|
|
135
|
+
"type": "text",
|
|
136
|
+
"primaryKey": false,
|
|
137
|
+
"notNull": false,
|
|
138
|
+
"autoincrement": false
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
"indexes": {
|
|
142
|
+
"idx_relations_src": {
|
|
143
|
+
"name": "idx_relations_src",
|
|
144
|
+
"columns": [
|
|
145
|
+
"project",
|
|
146
|
+
"src_file_path"
|
|
147
|
+
],
|
|
148
|
+
"isUnique": false
|
|
149
|
+
},
|
|
150
|
+
"idx_relations_dst": {
|
|
151
|
+
"name": "idx_relations_dst",
|
|
152
|
+
"columns": [
|
|
153
|
+
"dst_project",
|
|
154
|
+
"dst_file_path"
|
|
155
|
+
],
|
|
156
|
+
"isUnique": false
|
|
157
|
+
},
|
|
158
|
+
"idx_relations_type": {
|
|
159
|
+
"name": "idx_relations_type",
|
|
160
|
+
"columns": [
|
|
161
|
+
"project",
|
|
162
|
+
"type"
|
|
163
|
+
],
|
|
164
|
+
"isUnique": false
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
"foreignKeys": {
|
|
168
|
+
"relations_project_src_file_path_files_project_file_path_fk": {
|
|
169
|
+
"name": "relations_project_src_file_path_files_project_file_path_fk",
|
|
170
|
+
"tableFrom": "relations",
|
|
171
|
+
"tableTo": "files",
|
|
172
|
+
"columnsFrom": [
|
|
173
|
+
"project",
|
|
174
|
+
"src_file_path"
|
|
175
|
+
],
|
|
176
|
+
"columnsTo": [
|
|
177
|
+
"project",
|
|
178
|
+
"file_path"
|
|
179
|
+
],
|
|
180
|
+
"onDelete": "cascade",
|
|
181
|
+
"onUpdate": "no action"
|
|
182
|
+
},
|
|
183
|
+
"relations_dst_project_dst_file_path_files_project_file_path_fk": {
|
|
184
|
+
"name": "relations_dst_project_dst_file_path_files_project_file_path_fk",
|
|
185
|
+
"tableFrom": "relations",
|
|
186
|
+
"tableTo": "files",
|
|
187
|
+
"columnsFrom": [
|
|
188
|
+
"dst_project",
|
|
189
|
+
"dst_file_path"
|
|
190
|
+
],
|
|
191
|
+
"columnsTo": [
|
|
192
|
+
"project",
|
|
193
|
+
"file_path"
|
|
194
|
+
],
|
|
195
|
+
"onDelete": "cascade",
|
|
196
|
+
"onUpdate": "no action"
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
"compositePrimaryKeys": {},
|
|
200
|
+
"uniqueConstraints": {},
|
|
201
|
+
"checkConstraints": {}
|
|
202
|
+
},
|
|
203
|
+
"symbols": {
|
|
204
|
+
"name": "symbols",
|
|
205
|
+
"columns": {
|
|
206
|
+
"id": {
|
|
207
|
+
"name": "id",
|
|
208
|
+
"type": "integer",
|
|
209
|
+
"primaryKey": true,
|
|
210
|
+
"notNull": true,
|
|
211
|
+
"autoincrement": true
|
|
212
|
+
},
|
|
213
|
+
"project": {
|
|
214
|
+
"name": "project",
|
|
215
|
+
"type": "text",
|
|
216
|
+
"primaryKey": false,
|
|
217
|
+
"notNull": true,
|
|
218
|
+
"autoincrement": false
|
|
219
|
+
},
|
|
220
|
+
"file_path": {
|
|
221
|
+
"name": "file_path",
|
|
222
|
+
"type": "text",
|
|
223
|
+
"primaryKey": false,
|
|
224
|
+
"notNull": true,
|
|
225
|
+
"autoincrement": false
|
|
226
|
+
},
|
|
227
|
+
"kind": {
|
|
228
|
+
"name": "kind",
|
|
229
|
+
"type": "text",
|
|
230
|
+
"primaryKey": false,
|
|
231
|
+
"notNull": true,
|
|
232
|
+
"autoincrement": false
|
|
233
|
+
},
|
|
234
|
+
"name": {
|
|
235
|
+
"name": "name",
|
|
236
|
+
"type": "text",
|
|
237
|
+
"primaryKey": false,
|
|
238
|
+
"notNull": true,
|
|
239
|
+
"autoincrement": false
|
|
240
|
+
},
|
|
241
|
+
"start_line": {
|
|
242
|
+
"name": "start_line",
|
|
243
|
+
"type": "integer",
|
|
244
|
+
"primaryKey": false,
|
|
245
|
+
"notNull": true,
|
|
246
|
+
"autoincrement": false
|
|
247
|
+
},
|
|
248
|
+
"start_column": {
|
|
249
|
+
"name": "start_column",
|
|
250
|
+
"type": "integer",
|
|
251
|
+
"primaryKey": false,
|
|
252
|
+
"notNull": true,
|
|
253
|
+
"autoincrement": false
|
|
254
|
+
},
|
|
255
|
+
"end_line": {
|
|
256
|
+
"name": "end_line",
|
|
257
|
+
"type": "integer",
|
|
258
|
+
"primaryKey": false,
|
|
259
|
+
"notNull": true,
|
|
260
|
+
"autoincrement": false
|
|
261
|
+
},
|
|
262
|
+
"end_column": {
|
|
263
|
+
"name": "end_column",
|
|
264
|
+
"type": "integer",
|
|
265
|
+
"primaryKey": false,
|
|
266
|
+
"notNull": true,
|
|
267
|
+
"autoincrement": false
|
|
268
|
+
},
|
|
269
|
+
"is_exported": {
|
|
270
|
+
"name": "is_exported",
|
|
271
|
+
"type": "integer",
|
|
272
|
+
"primaryKey": false,
|
|
273
|
+
"notNull": true,
|
|
274
|
+
"autoincrement": false,
|
|
275
|
+
"default": 0
|
|
276
|
+
},
|
|
277
|
+
"signature": {
|
|
278
|
+
"name": "signature",
|
|
279
|
+
"type": "text",
|
|
280
|
+
"primaryKey": false,
|
|
281
|
+
"notNull": false,
|
|
282
|
+
"autoincrement": false
|
|
283
|
+
},
|
|
284
|
+
"fingerprint": {
|
|
285
|
+
"name": "fingerprint",
|
|
286
|
+
"type": "text",
|
|
287
|
+
"primaryKey": false,
|
|
288
|
+
"notNull": false,
|
|
289
|
+
"autoincrement": false
|
|
290
|
+
},
|
|
291
|
+
"detail_json": {
|
|
292
|
+
"name": "detail_json",
|
|
293
|
+
"type": "text",
|
|
294
|
+
"primaryKey": false,
|
|
295
|
+
"notNull": false,
|
|
296
|
+
"autoincrement": false
|
|
297
|
+
},
|
|
298
|
+
"content_hash": {
|
|
299
|
+
"name": "content_hash",
|
|
300
|
+
"type": "text",
|
|
301
|
+
"primaryKey": false,
|
|
302
|
+
"notNull": true,
|
|
303
|
+
"autoincrement": false
|
|
304
|
+
},
|
|
305
|
+
"indexed_at": {
|
|
306
|
+
"name": "indexed_at",
|
|
307
|
+
"type": "text",
|
|
308
|
+
"primaryKey": false,
|
|
309
|
+
"notNull": true,
|
|
310
|
+
"autoincrement": false
|
|
311
|
+
},
|
|
312
|
+
"resolved_type": {
|
|
313
|
+
"name": "resolved_type",
|
|
314
|
+
"type": "text",
|
|
315
|
+
"primaryKey": false,
|
|
316
|
+
"notNull": false,
|
|
317
|
+
"autoincrement": false
|
|
318
|
+
}
|
|
319
|
+
},
|
|
320
|
+
"indexes": {
|
|
321
|
+
"idx_symbols_project_file": {
|
|
322
|
+
"name": "idx_symbols_project_file",
|
|
323
|
+
"columns": [
|
|
324
|
+
"project",
|
|
325
|
+
"file_path"
|
|
326
|
+
],
|
|
327
|
+
"isUnique": false
|
|
328
|
+
},
|
|
329
|
+
"idx_symbols_project_kind": {
|
|
330
|
+
"name": "idx_symbols_project_kind",
|
|
331
|
+
"columns": [
|
|
332
|
+
"project",
|
|
333
|
+
"kind"
|
|
334
|
+
],
|
|
335
|
+
"isUnique": false
|
|
336
|
+
},
|
|
337
|
+
"idx_symbols_project_name": {
|
|
338
|
+
"name": "idx_symbols_project_name",
|
|
339
|
+
"columns": [
|
|
340
|
+
"project",
|
|
341
|
+
"name"
|
|
342
|
+
],
|
|
343
|
+
"isUnique": false
|
|
344
|
+
},
|
|
345
|
+
"idx_symbols_fingerprint": {
|
|
346
|
+
"name": "idx_symbols_fingerprint",
|
|
347
|
+
"columns": [
|
|
348
|
+
"project",
|
|
349
|
+
"fingerprint"
|
|
350
|
+
],
|
|
351
|
+
"isUnique": false
|
|
352
|
+
}
|
|
353
|
+
},
|
|
354
|
+
"foreignKeys": {
|
|
355
|
+
"symbols_project_file_path_files_project_file_path_fk": {
|
|
356
|
+
"name": "symbols_project_file_path_files_project_file_path_fk",
|
|
357
|
+
"tableFrom": "symbols",
|
|
358
|
+
"tableTo": "files",
|
|
359
|
+
"columnsFrom": [
|
|
360
|
+
"project",
|
|
361
|
+
"file_path"
|
|
362
|
+
],
|
|
363
|
+
"columnsTo": [
|
|
364
|
+
"project",
|
|
365
|
+
"file_path"
|
|
366
|
+
],
|
|
367
|
+
"onDelete": "cascade",
|
|
368
|
+
"onUpdate": "no action"
|
|
369
|
+
}
|
|
370
|
+
},
|
|
371
|
+
"compositePrimaryKeys": {},
|
|
372
|
+
"uniqueConstraints": {},
|
|
373
|
+
"checkConstraints": {}
|
|
374
|
+
},
|
|
375
|
+
"watcher_owner": {
|
|
376
|
+
"name": "watcher_owner",
|
|
377
|
+
"columns": {
|
|
378
|
+
"id": {
|
|
379
|
+
"name": "id",
|
|
380
|
+
"type": "integer",
|
|
381
|
+
"primaryKey": true,
|
|
382
|
+
"notNull": true,
|
|
383
|
+
"autoincrement": false
|
|
384
|
+
},
|
|
385
|
+
"pid": {
|
|
386
|
+
"name": "pid",
|
|
387
|
+
"type": "integer",
|
|
388
|
+
"primaryKey": false,
|
|
389
|
+
"notNull": true,
|
|
390
|
+
"autoincrement": false
|
|
391
|
+
},
|
|
392
|
+
"started_at": {
|
|
393
|
+
"name": "started_at",
|
|
394
|
+
"type": "text",
|
|
395
|
+
"primaryKey": false,
|
|
396
|
+
"notNull": true,
|
|
397
|
+
"autoincrement": false
|
|
398
|
+
},
|
|
399
|
+
"heartbeat_at": {
|
|
400
|
+
"name": "heartbeat_at",
|
|
401
|
+
"type": "text",
|
|
402
|
+
"primaryKey": false,
|
|
403
|
+
"notNull": true,
|
|
404
|
+
"autoincrement": false
|
|
405
|
+
}
|
|
406
|
+
},
|
|
407
|
+
"indexes": {},
|
|
408
|
+
"foreignKeys": {},
|
|
409
|
+
"compositePrimaryKeys": {},
|
|
410
|
+
"uniqueConstraints": {},
|
|
411
|
+
"checkConstraints": {
|
|
412
|
+
"watcher_owner_singleton": {
|
|
413
|
+
"name": "watcher_owner_singleton",
|
|
414
|
+
"value": "\"watcher_owner\".\"id\" = 1"
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
},
|
|
419
|
+
"views": {},
|
|
420
|
+
"enums": {},
|
|
421
|
+
"_meta": {
|
|
422
|
+
"schemas": {},
|
|
423
|
+
"tables": {},
|
|
424
|
+
"columns": {}
|
|
425
|
+
},
|
|
426
|
+
"internal": {
|
|
427
|
+
"indexes": {}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
@@ -22,6 +22,20 @@
|
|
|
22
22
|
"when": 1771900800000,
|
|
23
23
|
"tag": "0002_fts_setup",
|
|
24
24
|
"breakpoints": true
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"idx": 3,
|
|
28
|
+
"version": "6",
|
|
29
|
+
"when": 1771949593329,
|
|
30
|
+
"tag": "0003_majestic_mongu",
|
|
31
|
+
"breakpoints": true
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"idx": 4,
|
|
35
|
+
"version": "6",
|
|
36
|
+
"when": 1772043335425,
|
|
37
|
+
"tag": "0004_cool_firestar",
|
|
38
|
+
"breakpoints": true
|
|
25
39
|
}
|
|
26
40
|
]
|
|
27
41
|
}
|
package/dist/src/errors.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Discriminated union type representing all possible error categories in Gildash.
|
|
3
3
|
*/
|
|
4
|
-
export type GildashErrorType = 'watcher' | 'parse' | 'extract' | 'index' | 'store' | 'search' | 'closed' | 'validation' | 'close';
|
|
4
|
+
export type GildashErrorType = 'watcher' | 'parse' | 'extract' | 'index' | 'store' | 'search' | 'closed' | 'validation' | 'close' | 'semantic';
|
|
5
5
|
/**
|
|
6
6
|
* Plain-object error value used throughout Gildash's Result-based error handling.
|
|
7
7
|
* Produced by {@link gildashError} and carried as the `data` field of an `Err<GildashError>`.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Program } from 'oxc-parser';
|
|
2
2
|
import type { TsconfigPaths } from '../common/tsconfig-resolver';
|
|
3
3
|
import type { CodeRelation } from './types';
|
|
4
|
-
export
|
|
4
|
+
export type ResolveImportFn = (currentFilePath: string, importPath: string, tsconfigPaths?: TsconfigPaths) => string[];
|
|
5
|
+
export declare function extractRelations(ast: Program, filePath: string, tsconfigPaths?: TsconfigPaths, resolveImportFn?: ResolveImportFn): CodeRelation[];
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { Result } from '@zipbul/result';
|
|
2
|
+
import type { ParsedFile } from '../parser/types';
|
|
3
|
+
import type { ParserOptions, Program } from 'oxc-parser';
|
|
4
|
+
import type { ExtractedSymbol, CodeRelation } from '../extractor/types';
|
|
5
|
+
import type { DbConnection } from '../store/connection';
|
|
6
|
+
import type { FileRepository } from '../store/repositories/file.repository';
|
|
7
|
+
import type { SymbolRepository } from '../store/repositories/symbol.repository';
|
|
8
|
+
import type { RelationRepository } from '../store/repositories/relation.repository';
|
|
9
|
+
import type { ProjectWatcher } from '../watcher/project-watcher';
|
|
10
|
+
import type { IndexCoordinator, IndexResult } from '../indexer/index-coordinator';
|
|
11
|
+
import type { FileChangeEvent } from '../watcher/types';
|
|
12
|
+
import type { WatcherOwnerStore } from '../watcher/ownership';
|
|
13
|
+
import type { WatcherRole } from '../watcher/types';
|
|
14
|
+
import type { ProjectBoundary } from '../common/project-discovery';
|
|
15
|
+
import type { TsconfigPaths } from '../common/tsconfig-resolver';
|
|
16
|
+
import type { SymbolSearchQuery, SymbolSearchResult, ISymbolRepo } from '../search/symbol-search';
|
|
17
|
+
import type { RelationSearchQuery, IRelationRepo } from '../search/relation-search';
|
|
18
|
+
import type { PatternMatch } from '../search/pattern-search';
|
|
19
|
+
import type { DependencyGraph } from '../search/dependency-graph';
|
|
20
|
+
import type { SemanticLayer } from '../semantic/index';
|
|
21
|
+
import type { ParseCache } from '../parser/parse-cache';
|
|
22
|
+
import type { GildashError } from '../errors';
|
|
23
|
+
import type { Logger } from './types';
|
|
24
|
+
export type ParseSourceFn = (filePath: string, sourceText: string, options?: ParserOptions) => Result<ParsedFile, GildashError>;
|
|
25
|
+
export type ExtractSymbolsFn = (parsed: ParsedFile) => ExtractedSymbol[];
|
|
26
|
+
export type ExtractRelationsFn = (ast: Program, filePath: string, tsconfigPaths?: TsconfigPaths) => CodeRelation[];
|
|
27
|
+
export type SymbolSearchFn = (options: {
|
|
28
|
+
symbolRepo: ISymbolRepo;
|
|
29
|
+
project?: string;
|
|
30
|
+
query: SymbolSearchQuery;
|
|
31
|
+
}) => SymbolSearchResult[];
|
|
32
|
+
export type RelationSearchFn = (options: {
|
|
33
|
+
relationRepo: IRelationRepo;
|
|
34
|
+
project?: string;
|
|
35
|
+
query: RelationSearchQuery;
|
|
36
|
+
}) => CodeRelation[];
|
|
37
|
+
export type PatternSearchFn = (opts: {
|
|
38
|
+
pattern: string;
|
|
39
|
+
filePaths: string[];
|
|
40
|
+
}) => Promise<PatternMatch[]>;
|
|
41
|
+
export type AcquireWatcherRoleFn = (db: WatcherOwnerStore, pid: number, options?: object) => WatcherRole | Promise<WatcherRole>;
|
|
42
|
+
export type ReleaseWatcherRoleFn = (db: WatcherOwnerStore, pid: number) => void;
|
|
43
|
+
export type UpdateHeartbeatFn = (db: WatcherOwnerStore, pid: number) => void;
|
|
44
|
+
export type DbStore = Pick<DbConnection, 'open' | 'close' | 'transaction'> & WatcherOwnerStore;
|
|
45
|
+
export type FileRepoLike = Pick<FileRepository, 'upsertFile' | 'getAllFiles' | 'getFilesMap' | 'deleteFile' | 'getFile'>;
|
|
46
|
+
export type ParseCacheLike = Pick<ParseCache, 'set' | 'get' | 'invalidate'>;
|
|
47
|
+
export type CoordinatorLike = Pick<IndexCoordinator, 'fullIndex' | 'shutdown' | 'onIndexed'> & {
|
|
48
|
+
tsconfigPaths?: Promise<TsconfigPaths | null>;
|
|
49
|
+
handleWatcherEvent?(event: FileChangeEvent): void;
|
|
50
|
+
};
|
|
51
|
+
export type WatcherLike = Pick<ProjectWatcher, 'start' | 'close'>;
|
|
52
|
+
export type SemanticLayerLike = Pick<SemanticLayer, 'collectTypeAt' | 'collectFileTypes' | 'findReferences' | 'findImplementations' | 'getModuleInterface' | 'getSymbolNode' | 'notifyFileChanged' | 'notifyFileDeleted' | 'dispose' | 'isDisposed' | 'lineColumnToPosition' | 'findNamePosition'>;
|
|
53
|
+
/** Internal shared state for all Gildash API modules. */
|
|
54
|
+
export interface GildashContext {
|
|
55
|
+
readonly projectRoot: string;
|
|
56
|
+
readonly extensions: string[];
|
|
57
|
+
readonly ignorePatterns: string[];
|
|
58
|
+
readonly logger: Logger;
|
|
59
|
+
readonly defaultProject: string;
|
|
60
|
+
readonly role: 'owner' | 'reader';
|
|
61
|
+
readonly db: DbStore;
|
|
62
|
+
readonly symbolRepo: SymbolRepository;
|
|
63
|
+
readonly relationRepo: RelationRepository;
|
|
64
|
+
readonly fileRepo: FileRepoLike;
|
|
65
|
+
readonly parseCache: ParseCacheLike;
|
|
66
|
+
readonly releaseWatcherRoleFn: ReleaseWatcherRoleFn;
|
|
67
|
+
readonly parseSourceFn: ParseSourceFn;
|
|
68
|
+
readonly extractSymbolsFn: ExtractSymbolsFn;
|
|
69
|
+
readonly extractRelationsFn: ExtractRelationsFn;
|
|
70
|
+
readonly symbolSearchFn: SymbolSearchFn;
|
|
71
|
+
readonly relationSearchFn: RelationSearchFn;
|
|
72
|
+
readonly patternSearchFn: PatternSearchFn;
|
|
73
|
+
readonly readFileFn: (filePath: string) => Promise<string>;
|
|
74
|
+
readonly unlinkFn: (filePath: string) => Promise<void>;
|
|
75
|
+
readonly existsSyncFn: (p: string) => boolean;
|
|
76
|
+
readonly acquireWatcherRoleFn: AcquireWatcherRoleFn;
|
|
77
|
+
readonly updateHeartbeatFn: UpdateHeartbeatFn;
|
|
78
|
+
readonly watcherFactory?: () => WatcherLike;
|
|
79
|
+
readonly coordinatorFactory?: () => CoordinatorLike;
|
|
80
|
+
closed: boolean;
|
|
81
|
+
coordinator: CoordinatorLike | null;
|
|
82
|
+
watcher: WatcherLike | null;
|
|
83
|
+
timer: ReturnType<typeof setInterval> | null;
|
|
84
|
+
signalHandlers: Array<[string, () => void]>;
|
|
85
|
+
tsconfigPaths: TsconfigPaths | null;
|
|
86
|
+
boundaries: ProjectBoundary[];
|
|
87
|
+
onIndexedCallbacks: Set<(result: IndexResult) => void>;
|
|
88
|
+
graphCache: DependencyGraph | null;
|
|
89
|
+
graphCacheKey: string | null;
|
|
90
|
+
semanticLayer: SemanticLayerLike | null;
|
|
91
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Result } from '@zipbul/result';
|
|
2
|
+
import type { ParsedFile } from '../parser/types';
|
|
3
|
+
import type { ExtractedSymbol, CodeRelation } from '../extractor/types';
|
|
4
|
+
import type { GildashError } from '../errors';
|
|
5
|
+
import type { GildashContext } from './context';
|
|
6
|
+
/** Extract all symbol declarations from a previously parsed file. */
|
|
7
|
+
export declare function extractSymbols(ctx: GildashContext, parsed: ParsedFile): Result<ExtractedSymbol[], GildashError>;
|
|
8
|
+
/** Extract inter-file relationships from a previously parsed file. */
|
|
9
|
+
export declare function extractRelations(ctx: GildashContext, parsed: ParsedFile): Result<CodeRelation[], GildashError>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type Result } from '@zipbul/result';
|
|
2
|
+
import type { GildashError } from '../errors';
|
|
3
|
+
import { DependencyGraph } from '../search/dependency-graph';
|
|
4
|
+
import type { GildashContext } from './context';
|
|
5
|
+
import type { FanMetrics } from './types';
|
|
6
|
+
/** Invalidate the cached DependencyGraph (called after every index run). */
|
|
7
|
+
export declare function invalidateGraphCache(ctx: GildashContext): void;
|
|
8
|
+
/**
|
|
9
|
+
* Return a cached or freshly-built DependencyGraph for the given project.
|
|
10
|
+
* Builds once per key; subsequent calls with the same key return the cached instance.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getOrBuildGraph(ctx: GildashContext, project?: string): DependencyGraph;
|
|
13
|
+
/** List the files that a given file directly imports. */
|
|
14
|
+
export declare function getDependencies(ctx: GildashContext, filePath: string, project?: string, limit?: number): Result<string[], GildashError>;
|
|
15
|
+
/** List the files that directly import a given file. */
|
|
16
|
+
export declare function getDependents(ctx: GildashContext, filePath: string, project?: string, limit?: number): Result<string[], GildashError>;
|
|
17
|
+
/** Compute the full set of files transitively affected by changes. */
|
|
18
|
+
export declare function getAffected(ctx: GildashContext, changedFiles: string[], project?: string): Promise<Result<string[], GildashError>>;
|
|
19
|
+
/** Check whether the import graph contains a circular dependency. */
|
|
20
|
+
export declare function hasCycle(ctx: GildashContext, project?: string): Promise<Result<boolean, GildashError>>;
|
|
21
|
+
/** Return the full import graph as an adjacency list. */
|
|
22
|
+
export declare function getImportGraph(ctx: GildashContext, project?: string): Promise<Result<Map<string, string[]>, GildashError>>;
|
|
23
|
+
/** Return all files that `filePath` transitively imports (forward BFS). */
|
|
24
|
+
export declare function getTransitiveDependencies(ctx: GildashContext, filePath: string, project?: string): Promise<Result<string[], GildashError>>;
|
|
25
|
+
/** Return all cycle paths in the import graph. */
|
|
26
|
+
export declare function getCyclePaths(ctx: GildashContext, project?: string, options?: {
|
|
27
|
+
maxCycles?: number;
|
|
28
|
+
}): Promise<Result<string[][], GildashError>>;
|
|
29
|
+
/** Compute import-graph fan metrics (fan-in / fan-out) for a single file. */
|
|
30
|
+
export declare function getFanMetrics(ctx: GildashContext, filePath: string, project?: string): Promise<Result<FanMetrics, GildashError>>;
|