code-graph-context 0.1.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.
@@ -0,0 +1,799 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ // graph.ts - Optimized for Neo4j performance with context-based framework properties
3
+ // ============================================================================
4
+ // CORE ENUMS
5
+ // ============================================================================
6
+ /**
7
+ * Core TypeScript AST Node Types (from ts-morph)
8
+ */
9
+ export var CoreNodeType;
10
+ (function (CoreNodeType) {
11
+ // File System & Workspace
12
+ CoreNodeType["SOURCE_FILE"] = "SourceFile";
13
+ // Core TypeScript AST Declarations
14
+ CoreNodeType["CLASS_DECLARATION"] = "ClassDeclaration";
15
+ CoreNodeType["INTERFACE_DECLARATION"] = "InterfaceDeclaration";
16
+ CoreNodeType["ENUM_DECLARATION"] = "EnumDeclaration";
17
+ CoreNodeType["FUNCTION_DECLARATION"] = "FunctionDeclaration";
18
+ CoreNodeType["VARIABLE_DECLARATION"] = "VariableDeclaration";
19
+ // Class Members
20
+ CoreNodeType["METHOD_DECLARATION"] = "MethodDeclaration";
21
+ CoreNodeType["PROPERTY_DECLARATION"] = "PropertyDeclaration";
22
+ CoreNodeType["CONSTRUCTOR_DECLARATION"] = "ConstructorDeclaration";
23
+ CoreNodeType["PARAMETER_DECLARATION"] = "ParameterDeclaration";
24
+ // Import/Export System
25
+ CoreNodeType["IMPORT_DECLARATION"] = "ImportDeclaration";
26
+ CoreNodeType["EXPORT_DECLARATION"] = "ExportDeclaration";
27
+ // Decorators
28
+ CoreNodeType["DECORATOR"] = "Decorator";
29
+ })(CoreNodeType || (CoreNodeType = {}));
30
+ /**
31
+ * Core Edge Types (AST relationships)
32
+ */
33
+ export var CoreEdgeType;
34
+ (function (CoreEdgeType) {
35
+ // File Structure
36
+ CoreEdgeType["CONTAINS"] = "CONTAINS";
37
+ // Import/Export
38
+ CoreEdgeType["IMPORTS"] = "IMPORTS";
39
+ CoreEdgeType["EXPORTS"] = "EXPORTS";
40
+ // Type System
41
+ CoreEdgeType["EXTENDS"] = "EXTENDS";
42
+ CoreEdgeType["IMPLEMENTS"] = "IMPLEMENTS";
43
+ CoreEdgeType["TYPED_AS"] = "TYPED_AS";
44
+ // Code Structure
45
+ CoreEdgeType["HAS_MEMBER"] = "HAS_MEMBER";
46
+ CoreEdgeType["HAS_PARAMETER"] = "HAS_PARAMETER";
47
+ CoreEdgeType["CALLS"] = "CALLS";
48
+ // Decorator
49
+ CoreEdgeType["DECORATED_WITH"] = "DECORATED_WITH";
50
+ })(CoreEdgeType || (CoreEdgeType = {}));
51
+ /**
52
+ * Semantic Node Types (Framework interpretations)
53
+ */
54
+ export var SemanticNodeType;
55
+ (function (SemanticNodeType) {
56
+ // NestJS Framework Types
57
+ SemanticNodeType["NEST_MODULE"] = "NestModule";
58
+ SemanticNodeType["NEST_CONTROLLER"] = "NestController";
59
+ SemanticNodeType["NEST_SERVICE"] = "NestService";
60
+ SemanticNodeType["NEST_GUARD"] = "NestGuard";
61
+ SemanticNodeType["NEST_PIPE"] = "NestPipe";
62
+ SemanticNodeType["NEST_INTERCEPTOR"] = "NestInterceptor";
63
+ SemanticNodeType["NEST_FILTER"] = "NestFilter";
64
+ SemanticNodeType["NEST_PROVIDER"] = "NestProvider";
65
+ // HTTP & API Types
66
+ SemanticNodeType["HTTP_ENDPOINT"] = "HttpEndpoint";
67
+ SemanticNodeType["MESSAGE_HANDLER"] = "MessageHandler";
68
+ // Data Types
69
+ SemanticNodeType["DTO_CLASS"] = "DTOClass";
70
+ SemanticNodeType["ENTITY_CLASS"] = "EntityClass";
71
+ SemanticNodeType["CONFIG_CLASS"] = "ConfigClass";
72
+ // Testing
73
+ SemanticNodeType["TEST_CLASS"] = "TestClass";
74
+ })(SemanticNodeType || (SemanticNodeType = {}));
75
+ /**
76
+ * Semantic Edge Types (Framework relationships)
77
+ */
78
+ export var SemanticEdgeType;
79
+ (function (SemanticEdgeType) {
80
+ // NestJS Module System
81
+ SemanticEdgeType["MODULE_IMPORTS"] = "MODULE_IMPORTS";
82
+ SemanticEdgeType["MODULE_PROVIDES"] = "MODULE_PROVIDES";
83
+ SemanticEdgeType["MODULE_EXPORTS"] = "MODULE_EXPORTS";
84
+ // Dependency Injection
85
+ SemanticEdgeType["INJECTS"] = "INJECTS";
86
+ SemanticEdgeType["PROVIDED_BY"] = "PROVIDED_BY";
87
+ // HTTP API
88
+ SemanticEdgeType["EXPOSES"] = "EXPOSES";
89
+ SemanticEdgeType["ACCEPTS"] = "ACCEPTS";
90
+ SemanticEdgeType["RESPONDS_WITH"] = "RESPONDS_WITH";
91
+ SemanticEdgeType["CONSUMES_MESSAGE"] = "CONSUMES_MESSAGE";
92
+ // Security & Middleware
93
+ SemanticEdgeType["GUARDED_BY"] = "GUARDED_BY";
94
+ SemanticEdgeType["TRANSFORMED_BY"] = "TRANSFORMED_BY";
95
+ SemanticEdgeType["INTERCEPTED_BY"] = "INTERCEPTED_BY";
96
+ // Domain Logic
97
+ SemanticEdgeType["MANAGES"] = "MANAGES";
98
+ SemanticEdgeType["VALIDATES"] = "VALIDATES";
99
+ // Testing
100
+ SemanticEdgeType["TESTS"] = "TESTS";
101
+ })(SemanticEdgeType || (SemanticEdgeType = {}));
102
+ // ============================================================================
103
+ // CORE TYPESCRIPT SCHEMA
104
+ // ============================================================================
105
+ export const CORE_TYPESCRIPT_SCHEMA = {
106
+ name: 'Core TypeScript Schema',
107
+ version: '2.0.0',
108
+ // AST Getters Map - single source of truth
109
+ astGetters: {
110
+ [CoreNodeType.SOURCE_FILE]: 'self', // Special case - entry point
111
+ [CoreNodeType.CLASS_DECLARATION]: 'getClasses',
112
+ [CoreNodeType.METHOD_DECLARATION]: 'getMethods',
113
+ [CoreNodeType.PROPERTY_DECLARATION]: 'getProperties',
114
+ [CoreNodeType.PARAMETER_DECLARATION]: 'getParameters',
115
+ [CoreNodeType.DECORATOR]: 'getDecorators',
116
+ [CoreNodeType.INTERFACE_DECLARATION]: 'getInterfaces',
117
+ [CoreNodeType.FUNCTION_DECLARATION]: 'getFunctions',
118
+ [CoreNodeType.IMPORT_DECLARATION]: 'getImportDeclarations',
119
+ [CoreNodeType.VARIABLE_DECLARATION]: 'getDeclarations', // Called on VariableStatement
120
+ [CoreNodeType.ENUM_DECLARATION]: 'getEnums',
121
+ [CoreNodeType.CONSTRUCTOR_DECLARATION]: 'getConstructors',
122
+ [CoreNodeType.EXPORT_DECLARATION]: 'getExportDeclarations',
123
+ },
124
+ nodeTypes: {
125
+ [CoreNodeType.SOURCE_FILE]: {
126
+ coreType: CoreNodeType.SOURCE_FILE,
127
+ astNodeKind: 311,
128
+ astGetter: 'self',
129
+ properties: [
130
+ {
131
+ name: 'name',
132
+ type: 'string',
133
+ extraction: { method: 'ast', source: 'getBaseName' },
134
+ neo4j: { indexed: true, unique: false, required: true },
135
+ },
136
+ {
137
+ name: 'filePath',
138
+ type: 'string',
139
+ extraction: { method: 'ast', source: 'getFilePath' },
140
+ neo4j: { indexed: true, unique: true, required: true },
141
+ },
142
+ {
143
+ name: 'isExported',
144
+ type: 'boolean',
145
+ extraction: { method: 'static', defaultValue: false },
146
+ neo4j: { indexed: true, unique: false, required: true },
147
+ },
148
+ ],
149
+ relationships: [], // SourceFile doesn't have reference relationships, only containment
150
+ children: {
151
+ [CoreNodeType.CLASS_DECLARATION]: CoreEdgeType.CONTAINS,
152
+ [CoreNodeType.INTERFACE_DECLARATION]: CoreEdgeType.CONTAINS,
153
+ [CoreNodeType.FUNCTION_DECLARATION]: CoreEdgeType.CONTAINS,
154
+ [CoreNodeType.IMPORT_DECLARATION]: CoreEdgeType.CONTAINS,
155
+ [CoreNodeType.ENUM_DECLARATION]: CoreEdgeType.CONTAINS,
156
+ },
157
+ neo4j: {
158
+ labels: ['SourceFile', 'TypeScript'],
159
+ primaryLabel: 'SourceFile',
160
+ indexed: ['name', 'filePath', 'isExported'],
161
+ skipEmbedding: true,
162
+ },
163
+ },
164
+ [CoreNodeType.CLASS_DECLARATION]: {
165
+ coreType: CoreNodeType.CLASS_DECLARATION,
166
+ astNodeKind: 262,
167
+ astGetter: 'getClasses',
168
+ properties: [
169
+ {
170
+ name: 'name',
171
+ type: 'string',
172
+ extraction: { method: 'ast', source: 'getName' },
173
+ neo4j: { indexed: true, unique: false, required: true },
174
+ },
175
+ {
176
+ name: 'isExported',
177
+ type: 'boolean',
178
+ extraction: { method: 'ast', source: 'isExported', defaultValue: false },
179
+ neo4j: { indexed: true, unique: false, required: true },
180
+ },
181
+ {
182
+ name: 'visibility',
183
+ type: 'string',
184
+ extraction: {
185
+ method: 'function',
186
+ source: (node) => (node.isExported() ? 'public' : 'none'),
187
+ defaultValue: 'none',
188
+ },
189
+ neo4j: { indexed: true, unique: false, required: true },
190
+ },
191
+ ],
192
+ relationships: [
193
+ {
194
+ edgeType: CoreEdgeType.EXTENDS,
195
+ method: 'getBaseClass',
196
+ cardinality: 'single',
197
+ targetNodeType: CoreNodeType.CLASS_DECLARATION,
198
+ },
199
+ {
200
+ edgeType: CoreEdgeType.IMPLEMENTS,
201
+ method: 'getImplements',
202
+ cardinality: 'array',
203
+ targetNodeType: CoreNodeType.INTERFACE_DECLARATION,
204
+ },
205
+ ],
206
+ children: {
207
+ [CoreNodeType.METHOD_DECLARATION]: CoreEdgeType.HAS_MEMBER,
208
+ [CoreNodeType.PROPERTY_DECLARATION]: CoreEdgeType.HAS_MEMBER,
209
+ [CoreNodeType.CONSTRUCTOR_DECLARATION]: CoreEdgeType.HAS_MEMBER,
210
+ [CoreNodeType.DECORATOR]: CoreEdgeType.DECORATED_WITH,
211
+ },
212
+ neo4j: {
213
+ labels: ['Class', 'TypeScript'],
214
+ primaryLabel: 'Class',
215
+ indexed: ['name', 'isExported', 'visibility'],
216
+ },
217
+ },
218
+ [CoreNodeType.METHOD_DECLARATION]: {
219
+ coreType: CoreNodeType.METHOD_DECLARATION,
220
+ astNodeKind: 172,
221
+ astGetter: 'getMethods',
222
+ properties: [
223
+ {
224
+ name: 'name',
225
+ type: 'string',
226
+ extraction: { method: 'ast', source: 'getName' },
227
+ neo4j: { indexed: true, unique: false, required: true },
228
+ },
229
+ {
230
+ name: 'visibility',
231
+ type: 'string',
232
+ extraction: {
233
+ method: 'function',
234
+ source: (node) => {
235
+ const modifiers = node.getModifiers();
236
+ for (const modifier of modifiers) {
237
+ const kind = modifier.getKind();
238
+ if (kind === 125)
239
+ return 'public';
240
+ if (kind === 123)
241
+ return 'private';
242
+ if (kind === 124)
243
+ return 'protected';
244
+ }
245
+ return 'public';
246
+ },
247
+ defaultValue: 'public',
248
+ },
249
+ neo4j: { indexed: true, unique: false, required: true },
250
+ },
251
+ ],
252
+ relationships: [], // CALLS would need call-site analysis, not implemented yet
253
+ children: {
254
+ [CoreNodeType.PARAMETER_DECLARATION]: CoreEdgeType.HAS_PARAMETER,
255
+ [CoreNodeType.DECORATOR]: CoreEdgeType.DECORATED_WITH,
256
+ },
257
+ neo4j: {
258
+ labels: ['Method', 'TypeScript'],
259
+ primaryLabel: 'Method',
260
+ indexed: ['name', 'visibility'],
261
+ },
262
+ },
263
+ [CoreNodeType.PROPERTY_DECLARATION]: {
264
+ coreType: CoreNodeType.PROPERTY_DECLARATION,
265
+ astNodeKind: 171,
266
+ astGetter: 'getProperties',
267
+ properties: [
268
+ {
269
+ name: 'name',
270
+ type: 'string',
271
+ extraction: { method: 'ast', source: 'getName' },
272
+ neo4j: { indexed: true, unique: false, required: true },
273
+ },
274
+ {
275
+ name: 'visibility',
276
+ type: 'string',
277
+ extraction: {
278
+ method: 'function',
279
+ source: (node) => {
280
+ const modifiers = node.getModifiers();
281
+ for (const modifier of modifiers) {
282
+ const kind = modifier.getKind();
283
+ if (kind === 125)
284
+ return 'public';
285
+ if (kind === 123)
286
+ return 'private';
287
+ if (kind === 124)
288
+ return 'protected';
289
+ }
290
+ return 'public';
291
+ },
292
+ defaultValue: 'public',
293
+ },
294
+ neo4j: { indexed: true, unique: false, required: true },
295
+ },
296
+ ],
297
+ relationships: [], // TYPED_AS would need type resolution, not implemented yet
298
+ children: {
299
+ [CoreNodeType.DECORATOR]: CoreEdgeType.DECORATED_WITH,
300
+ },
301
+ neo4j: {
302
+ labels: ['Property', 'TypeScript'],
303
+ primaryLabel: 'Property',
304
+ indexed: ['name', 'visibility'],
305
+ skipEmbedding: true,
306
+ },
307
+ },
308
+ [CoreNodeType.PARAMETER_DECLARATION]: {
309
+ coreType: CoreNodeType.PARAMETER_DECLARATION,
310
+ astNodeKind: 169,
311
+ astGetter: 'getParameters',
312
+ properties: [
313
+ {
314
+ name: 'name',
315
+ type: 'string',
316
+ extraction: { method: 'ast', source: 'getName' },
317
+ neo4j: { indexed: true, unique: false, required: true },
318
+ },
319
+ ],
320
+ relationships: [], // TYPED_AS would need type resolution, not implemented yet
321
+ children: {
322
+ [CoreNodeType.DECORATOR]: CoreEdgeType.DECORATED_WITH,
323
+ },
324
+ neo4j: {
325
+ labels: ['Parameter', 'TypeScript'],
326
+ primaryLabel: 'Parameter',
327
+ indexed: ['name'],
328
+ skipEmbedding: true,
329
+ },
330
+ },
331
+ [CoreNodeType.IMPORT_DECLARATION]: {
332
+ coreType: CoreNodeType.IMPORT_DECLARATION,
333
+ astNodeKind: 272,
334
+ astGetter: 'getImportDeclarations',
335
+ properties: [
336
+ {
337
+ name: 'name',
338
+ type: 'string',
339
+ extraction: { method: 'ast', source: 'getModuleSpecifierValue' },
340
+ neo4j: { indexed: true, unique: false, required: true },
341
+ },
342
+ ],
343
+ relationships: [], // IMPORTS to SourceFile would need module resolution
344
+ children: {},
345
+ neo4j: {
346
+ labels: ['Import', 'TypeScript'],
347
+ primaryLabel: 'Import',
348
+ indexed: ['name'],
349
+ skipEmbedding: true,
350
+ },
351
+ },
352
+ [CoreNodeType.DECORATOR]: {
353
+ coreType: CoreNodeType.DECORATOR,
354
+ astNodeKind: 170,
355
+ astGetter: 'getDecorators',
356
+ properties: [
357
+ {
358
+ name: 'name',
359
+ type: 'string',
360
+ extraction: { method: 'ast', source: 'getName' },
361
+ neo4j: { indexed: true, unique: false, required: true },
362
+ },
363
+ ],
364
+ relationships: [],
365
+ children: {},
366
+ neo4j: {
367
+ labels: ['Decorator'],
368
+ primaryLabel: 'Decorator',
369
+ indexed: ['name'],
370
+ skipEmbedding: true,
371
+ },
372
+ },
373
+ [CoreNodeType.INTERFACE_DECLARATION]: {
374
+ coreType: CoreNodeType.INTERFACE_DECLARATION,
375
+ astNodeKind: 263,
376
+ astGetter: 'getInterfaces',
377
+ properties: [
378
+ {
379
+ name: 'name',
380
+ type: 'string',
381
+ extraction: { method: 'ast', source: 'getName' },
382
+ neo4j: { indexed: true, unique: false, required: true },
383
+ },
384
+ {
385
+ name: 'isExported',
386
+ type: 'boolean',
387
+ extraction: { method: 'ast', source: 'isExported', defaultValue: false },
388
+ neo4j: { indexed: true, unique: false, required: true },
389
+ },
390
+ ],
391
+ relationships: [
392
+ {
393
+ edgeType: CoreEdgeType.EXTENDS,
394
+ method: 'getExtends',
395
+ cardinality: 'array',
396
+ targetNodeType: CoreNodeType.INTERFACE_DECLARATION,
397
+ },
398
+ ],
399
+ children: {},
400
+ neo4j: {
401
+ labels: ['Interface', 'TypeScript'],
402
+ primaryLabel: 'Interface',
403
+ indexed: ['name', 'isExported'],
404
+ },
405
+ },
406
+ [CoreNodeType.ENUM_DECLARATION]: {
407
+ coreType: CoreNodeType.ENUM_DECLARATION,
408
+ astNodeKind: 264,
409
+ astGetter: 'getEnums',
410
+ properties: [
411
+ {
412
+ name: 'name',
413
+ type: 'string',
414
+ extraction: { method: 'ast', source: 'getName' },
415
+ neo4j: { indexed: true, unique: false, required: true },
416
+ },
417
+ {
418
+ name: 'isExported',
419
+ type: 'boolean',
420
+ extraction: { method: 'ast', source: 'isExported', defaultValue: false },
421
+ neo4j: { indexed: true, unique: false, required: true },
422
+ },
423
+ ],
424
+ relationships: [],
425
+ children: {},
426
+ neo4j: {
427
+ labels: ['Enum', 'TypeScript'],
428
+ primaryLabel: 'Enum',
429
+ indexed: ['name', 'isExported'],
430
+ skipEmbedding: true,
431
+ },
432
+ },
433
+ [CoreNodeType.FUNCTION_DECLARATION]: {
434
+ coreType: CoreNodeType.FUNCTION_DECLARATION,
435
+ astNodeKind: 261,
436
+ astGetter: 'getFunctions',
437
+ properties: [
438
+ {
439
+ name: 'name',
440
+ type: 'string',
441
+ extraction: { method: 'ast', source: 'getName' },
442
+ neo4j: { indexed: true, unique: false, required: true },
443
+ },
444
+ {
445
+ name: 'isExported',
446
+ type: 'boolean',
447
+ extraction: { method: 'ast', source: 'isExported', defaultValue: false },
448
+ neo4j: { indexed: true, unique: false, required: true },
449
+ },
450
+ ],
451
+ relationships: [], // CALLS would need call-site analysis, not implemented yet
452
+ children: {
453
+ [CoreNodeType.PARAMETER_DECLARATION]: CoreEdgeType.HAS_PARAMETER,
454
+ },
455
+ neo4j: {
456
+ labels: ['Function', 'TypeScript'],
457
+ primaryLabel: 'Function',
458
+ indexed: ['name', 'isExported'],
459
+ },
460
+ },
461
+ [CoreNodeType.VARIABLE_DECLARATION]: {
462
+ coreType: CoreNodeType.VARIABLE_DECLARATION,
463
+ astNodeKind: 258,
464
+ astGetter: 'getDeclarations',
465
+ properties: [
466
+ {
467
+ name: 'name',
468
+ type: 'string',
469
+ extraction: { method: 'ast', source: 'getName' },
470
+ neo4j: { indexed: true, unique: false, required: true },
471
+ },
472
+ ],
473
+ relationships: [],
474
+ children: {},
475
+ neo4j: {
476
+ labels: ['Variable', 'TypeScript'],
477
+ primaryLabel: 'Variable',
478
+ indexed: ['name'],
479
+ skipEmbedding: true,
480
+ },
481
+ },
482
+ [CoreNodeType.CONSTRUCTOR_DECLARATION]: {
483
+ coreType: CoreNodeType.CONSTRUCTOR_DECLARATION,
484
+ astNodeKind: 175,
485
+ astGetter: 'getConstructors',
486
+ properties: [
487
+ {
488
+ name: 'name',
489
+ type: 'string',
490
+ extraction: { method: 'static', defaultValue: 'constructor' },
491
+ neo4j: { indexed: true, unique: false, required: true },
492
+ },
493
+ ],
494
+ relationships: [], // Parameters are handled via children, not relationship extractors
495
+ children: {
496
+ [CoreNodeType.PARAMETER_DECLARATION]: CoreEdgeType.HAS_PARAMETER,
497
+ },
498
+ neo4j: {
499
+ labels: ['Constructor', 'TypeScript'],
500
+ primaryLabel: 'Constructor',
501
+ indexed: ['name'],
502
+ skipEmbedding: true,
503
+ },
504
+ },
505
+ [CoreNodeType.EXPORT_DECLARATION]: {
506
+ coreType: CoreNodeType.EXPORT_DECLARATION,
507
+ astNodeKind: 273,
508
+ astGetter: 'getExportDeclarations',
509
+ properties: [
510
+ {
511
+ name: 'name',
512
+ type: 'string',
513
+ extraction: { method: 'static', defaultValue: 'export' },
514
+ neo4j: { indexed: true, unique: false, required: true },
515
+ },
516
+ ],
517
+ relationships: [],
518
+ children: {},
519
+ neo4j: {
520
+ labels: ['Export', 'TypeScript'],
521
+ primaryLabel: 'Export',
522
+ indexed: ['name'],
523
+ skipEmbedding: true,
524
+ },
525
+ },
526
+ },
527
+ edgeTypes: {
528
+ [CoreEdgeType.CONTAINS]: {
529
+ coreType: CoreEdgeType.CONTAINS,
530
+ sourceTypes: [CoreNodeType.SOURCE_FILE, CoreNodeType.CLASS_DECLARATION],
531
+ targetTypes: [
532
+ CoreNodeType.CLASS_DECLARATION,
533
+ CoreNodeType.INTERFACE_DECLARATION,
534
+ CoreNodeType.FUNCTION_DECLARATION,
535
+ CoreNodeType.METHOD_DECLARATION,
536
+ CoreNodeType.PROPERTY_DECLARATION,
537
+ ],
538
+ properties: [
539
+ {
540
+ name: 'confidence',
541
+ type: 'number',
542
+ extraction: { method: 'static', defaultValue: 1.0 },
543
+ neo4j: { indexed: true, unique: false, required: true },
544
+ },
545
+ {
546
+ name: 'source',
547
+ type: 'string',
548
+ extraction: { method: 'static', defaultValue: 'ast' },
549
+ neo4j: { indexed: true, unique: false, required: true },
550
+ },
551
+ ],
552
+ relationshipWeight: 0.4, // Structural - useful but not primary focus
553
+ neo4j: {
554
+ relationshipType: 'CONTAINS',
555
+ direction: 'OUTGOING',
556
+ },
557
+ },
558
+ [CoreEdgeType.HAS_MEMBER]: {
559
+ coreType: CoreEdgeType.HAS_MEMBER,
560
+ sourceTypes: [CoreNodeType.CLASS_DECLARATION, CoreNodeType.INTERFACE_DECLARATION],
561
+ targetTypes: [
562
+ CoreNodeType.METHOD_DECLARATION,
563
+ CoreNodeType.PROPERTY_DECLARATION,
564
+ CoreNodeType.CONSTRUCTOR_DECLARATION,
565
+ ],
566
+ properties: [
567
+ {
568
+ name: 'confidence',
569
+ type: 'number',
570
+ extraction: { method: 'static', defaultValue: 1.0 },
571
+ neo4j: { indexed: true, unique: false, required: true },
572
+ },
573
+ {
574
+ name: 'source',
575
+ type: 'string',
576
+ extraction: { method: 'static', defaultValue: 'ast' },
577
+ neo4j: { indexed: true, unique: false, required: true },
578
+ },
579
+ ],
580
+ relationshipWeight: 0.6, // Medium - important for understanding class structure
581
+ neo4j: {
582
+ relationshipType: 'HAS_MEMBER',
583
+ direction: 'OUTGOING',
584
+ },
585
+ },
586
+ [CoreEdgeType.HAS_PARAMETER]: {
587
+ coreType: CoreEdgeType.HAS_PARAMETER,
588
+ sourceTypes: [
589
+ CoreNodeType.METHOD_DECLARATION,
590
+ CoreNodeType.FUNCTION_DECLARATION,
591
+ CoreNodeType.CONSTRUCTOR_DECLARATION,
592
+ ],
593
+ targetTypes: [CoreNodeType.PARAMETER_DECLARATION],
594
+ properties: [
595
+ {
596
+ name: 'confidence',
597
+ type: 'number',
598
+ extraction: { method: 'static', defaultValue: 1.0 },
599
+ neo4j: { indexed: true, unique: false, required: true },
600
+ },
601
+ {
602
+ name: 'source',
603
+ type: 'string',
604
+ extraction: { method: 'static', defaultValue: 'ast' },
605
+ neo4j: { indexed: true, unique: false, required: true },
606
+ },
607
+ ],
608
+ relationshipWeight: 0.35, // Low - rarely primary traversal target
609
+ neo4j: {
610
+ relationshipType: 'HAS_PARAMETER',
611
+ direction: 'OUTGOING',
612
+ },
613
+ },
614
+ [CoreEdgeType.DECORATED_WITH]: {
615
+ coreType: CoreEdgeType.DECORATED_WITH,
616
+ sourceTypes: [
617
+ CoreNodeType.CLASS_DECLARATION,
618
+ CoreNodeType.METHOD_DECLARATION,
619
+ CoreNodeType.PROPERTY_DECLARATION,
620
+ CoreNodeType.PARAMETER_DECLARATION,
621
+ ],
622
+ targetTypes: [CoreNodeType.DECORATOR],
623
+ properties: [
624
+ {
625
+ name: 'confidence',
626
+ type: 'number',
627
+ extraction: { method: 'static', defaultValue: 1.0 },
628
+ neo4j: { indexed: true, unique: false, required: true },
629
+ },
630
+ {
631
+ name: 'source',
632
+ type: 'string',
633
+ extraction: { method: 'static', defaultValue: 'ast' },
634
+ neo4j: { indexed: true, unique: false, required: true },
635
+ },
636
+ ],
637
+ relationshipWeight: 0.3, // Low - metadata, not code flow
638
+ neo4j: {
639
+ relationshipType: 'DECORATED_WITH',
640
+ direction: 'OUTGOING',
641
+ },
642
+ },
643
+ [CoreEdgeType.IMPORTS]: {
644
+ coreType: CoreEdgeType.IMPORTS,
645
+ sourceTypes: [CoreNodeType.SOURCE_FILE],
646
+ targetTypes: [CoreNodeType.SOURCE_FILE],
647
+ properties: [
648
+ {
649
+ name: 'confidence',
650
+ type: 'number',
651
+ extraction: { method: 'static', defaultValue: 1.0 },
652
+ neo4j: { indexed: true, unique: false, required: true },
653
+ },
654
+ {
655
+ name: 'source',
656
+ type: 'string',
657
+ extraction: { method: 'static', defaultValue: 'ast' },
658
+ neo4j: { indexed: true, unique: false, required: true },
659
+ },
660
+ ],
661
+ relationshipWeight: 0.55, // Medium - useful for dependency tracing
662
+ neo4j: {
663
+ relationshipType: 'IMPORTS',
664
+ direction: 'OUTGOING',
665
+ },
666
+ },
667
+ [CoreEdgeType.EXPORTS]: {
668
+ coreType: CoreEdgeType.EXPORTS,
669
+ sourceTypes: [CoreNodeType.SOURCE_FILE],
670
+ targetTypes: [
671
+ CoreNodeType.CLASS_DECLARATION,
672
+ CoreNodeType.INTERFACE_DECLARATION,
673
+ CoreNodeType.FUNCTION_DECLARATION,
674
+ ],
675
+ properties: [
676
+ {
677
+ name: 'confidence',
678
+ type: 'number',
679
+ extraction: { method: 'static', defaultValue: 1.0 },
680
+ neo4j: { indexed: true, unique: false, required: true },
681
+ },
682
+ {
683
+ name: 'source',
684
+ type: 'string',
685
+ extraction: { method: 'static', defaultValue: 'ast' },
686
+ neo4j: { indexed: true, unique: false, required: true },
687
+ },
688
+ ],
689
+ relationshipWeight: 0.5, // Medium - public API surface
690
+ neo4j: {
691
+ relationshipType: 'EXPORTS',
692
+ direction: 'OUTGOING',
693
+ },
694
+ },
695
+ [CoreEdgeType.EXTENDS]: {
696
+ coreType: CoreEdgeType.EXTENDS,
697
+ sourceTypes: [CoreNodeType.CLASS_DECLARATION, CoreNodeType.INTERFACE_DECLARATION],
698
+ targetTypes: [CoreNodeType.CLASS_DECLARATION, CoreNodeType.INTERFACE_DECLARATION],
699
+ properties: [
700
+ {
701
+ name: 'confidence',
702
+ type: 'number',
703
+ extraction: { method: 'static', defaultValue: 1.0 },
704
+ neo4j: { indexed: true, unique: false, required: true },
705
+ },
706
+ {
707
+ name: 'source',
708
+ type: 'string',
709
+ extraction: { method: 'static', defaultValue: 'ast' },
710
+ neo4j: { indexed: true, unique: false, required: true },
711
+ },
712
+ ],
713
+ relationshipWeight: 0.85, // High - inheritance is critical for understanding
714
+ neo4j: {
715
+ relationshipType: 'EXTENDS',
716
+ direction: 'OUTGOING',
717
+ },
718
+ },
719
+ [CoreEdgeType.IMPLEMENTS]: {
720
+ coreType: CoreEdgeType.IMPLEMENTS,
721
+ sourceTypes: [CoreNodeType.CLASS_DECLARATION],
722
+ targetTypes: [CoreNodeType.INTERFACE_DECLARATION],
723
+ properties: [
724
+ {
725
+ name: 'confidence',
726
+ type: 'number',
727
+ extraction: { method: 'static', defaultValue: 1.0 },
728
+ neo4j: { indexed: true, unique: false, required: true },
729
+ },
730
+ {
731
+ name: 'source',
732
+ type: 'string',
733
+ extraction: { method: 'static', defaultValue: 'ast' },
734
+ neo4j: { indexed: true, unique: false, required: true },
735
+ },
736
+ ],
737
+ relationshipWeight: 0.75, // High - contract relationships are important
738
+ neo4j: {
739
+ relationshipType: 'IMPLEMENTS',
740
+ direction: 'OUTGOING',
741
+ },
742
+ },
743
+ [CoreEdgeType.TYPED_AS]: {
744
+ coreType: CoreEdgeType.TYPED_AS,
745
+ sourceTypes: [CoreNodeType.PARAMETER_DECLARATION, CoreNodeType.PROPERTY_DECLARATION],
746
+ targetTypes: [CoreNodeType.CLASS_DECLARATION, CoreNodeType.INTERFACE_DECLARATION],
747
+ properties: [
748
+ {
749
+ name: 'confidence',
750
+ type: 'number',
751
+ extraction: { method: 'static', defaultValue: 1.0 },
752
+ neo4j: { indexed: true, unique: false, required: true },
753
+ },
754
+ {
755
+ name: 'source',
756
+ type: 'string',
757
+ extraction: { method: 'static', defaultValue: 'ast' },
758
+ neo4j: { indexed: true, unique: false, required: true },
759
+ },
760
+ ],
761
+ relationshipWeight: 0.5, // Medium - type info useful but not primary
762
+ neo4j: {
763
+ relationshipType: 'TYPED_AS',
764
+ direction: 'OUTGOING',
765
+ },
766
+ },
767
+ [CoreEdgeType.CALLS]: {
768
+ coreType: CoreEdgeType.CALLS,
769
+ sourceTypes: [CoreNodeType.METHOD_DECLARATION, CoreNodeType.FUNCTION_DECLARATION],
770
+ targetTypes: [CoreNodeType.METHOD_DECLARATION, CoreNodeType.FUNCTION_DECLARATION],
771
+ properties: [
772
+ {
773
+ name: 'confidence',
774
+ type: 'number',
775
+ extraction: { method: 'static', defaultValue: 0.8 },
776
+ neo4j: { indexed: true, unique: false, required: true },
777
+ },
778
+ {
779
+ name: 'source',
780
+ type: 'string',
781
+ extraction: { method: 'static', defaultValue: 'pattern' },
782
+ neo4j: { indexed: true, unique: false, required: true },
783
+ },
784
+ ],
785
+ relationshipWeight: 0.85, // Critical - execution flow is primary
786
+ neo4j: {
787
+ relationshipType: 'CALLS',
788
+ direction: 'OUTGOING',
789
+ },
790
+ },
791
+ },
792
+ };
793
+ export const DEFAULT_PARSE_OPTIONS = {
794
+ includePatterns: ['**/*.ts', '**/*.tsx'],
795
+ excludePatterns: ['node_modules/', 'dist/', 'coverage/', '.d.ts', '.spec.ts', '.test.ts'],
796
+ maxFiles: 1000,
797
+ coreSchema: CORE_TYPESCRIPT_SCHEMA,
798
+ frameworkSchemas: [],
799
+ };