@linklabjs/core 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.
Files changed (72) hide show
  1. package/README.md +411 -0
  2. package/package.json +48 -0
  3. package/src/api/DomainNode.ts +1433 -0
  4. package/src/api/Graph.ts +271 -0
  5. package/src/api/PathBuilder.ts +247 -0
  6. package/src/api/index.ts +15 -0
  7. package/src/api/loadGraph.ts +207 -0
  8. package/src/api/test-api.ts +153 -0
  9. package/src/api/test-domain.ts +119 -0
  10. package/src/api/types.ts +88 -0
  11. package/src/config/synonyms.json +28 -0
  12. package/src/core/EventBus.ts +187 -0
  13. package/src/core/GraphEvents.ts +153 -0
  14. package/src/core/PathFinder.ts +283 -0
  15. package/src/formatters/BaseFormatter.ts +17 -0
  16. package/src/graph/GraphAssembler.ts +50 -0
  17. package/src/graph/GraphCompiler.ts +412 -0
  18. package/src/graph/GraphExtractor.ts +191 -0
  19. package/src/graph/GraphOptimizer.ts +404 -0
  20. package/src/graph/GraphTrainer.ts +247 -0
  21. package/src/http/LinkBuilder.ts +244 -0
  22. package/src/http/TrailRequest.ts +48 -0
  23. package/src/http/example-netflix.ts +59 -0
  24. package/src/http/hateoas/README.md +87 -0
  25. package/src/http/index.ts +33 -0
  26. package/src/http/plugin.ts +360 -0
  27. package/src/index.ts +121 -0
  28. package/src/instrumentation/TelemetryShim.ts +172 -0
  29. package/src/navigation/NavigationEngine.ts +441 -0
  30. package/src/navigation/Resolver.ts +134 -0
  31. package/src/navigation/Scheduler.ts +136 -0
  32. package/src/navigation/Trail.ts +252 -0
  33. package/src/navigation/TrailParser.ts +207 -0
  34. package/src/navigation/index.ts +11 -0
  35. package/src/providers/MockProvider.ts +68 -0
  36. package/src/providers/PostgresProvider.ts +187 -0
  37. package/src/runtime/CompiledGraphEngine.ts +274 -0
  38. package/src/runtime/DataLoader.ts +236 -0
  39. package/src/runtime/Engine.ts +163 -0
  40. package/src/runtime/QueryEngine.ts +222 -0
  41. package/src/scenarios/test-metro-paris/config.json +6 -0
  42. package/src/scenarios/test-metro-paris/graph.json +16325 -0
  43. package/src/scenarios/test-metro-paris/queries.ts +152 -0
  44. package/src/scenarios/test-metro-paris/stack.json +1 -0
  45. package/src/scenarios/test-musicians/config.json +10 -0
  46. package/src/scenarios/test-musicians/graph.json +20 -0
  47. package/src/scenarios/test-musicians/stack.json +1 -0
  48. package/src/scenarios/test-netflix/MIGRATION.md +23 -0
  49. package/src/scenarios/test-netflix/README.md +138 -0
  50. package/src/scenarios/test-netflix/actions.ts +92 -0
  51. package/src/scenarios/test-netflix/config.json +6 -0
  52. package/src/scenarios/test-netflix/data/categories.json +1 -0
  53. package/src/scenarios/test-netflix/data/companies.json +1 -0
  54. package/src/scenarios/test-netflix/data/credits.json +19797 -0
  55. package/src/scenarios/test-netflix/data/departments.json +18 -0
  56. package/src/scenarios/test-netflix/data/jobs.json +142 -0
  57. package/src/scenarios/test-netflix/data/movies.json +3497 -0
  58. package/src/scenarios/test-netflix/data/people.json +1 -0
  59. package/src/scenarios/test-netflix/data/synonyms.json +8 -0
  60. package/src/scenarios/test-netflix/data/users.json +70 -0
  61. package/src/scenarios/test-netflix/graph.json +1017 -0
  62. package/src/scenarios/test-netflix/queries.ts +159 -0
  63. package/src/scenarios/test-netflix/stack.json +14 -0
  64. package/src/schema/GraphBuilder.ts +106 -0
  65. package/src/schema/JsonSchemaExtractor.ts +107 -0
  66. package/src/schema/SchemaAnalyzer.ts +175 -0
  67. package/src/schema/SchemaExtractor.ts +102 -0
  68. package/src/schema/SynonymResolver.ts +143 -0
  69. package/src/scripts/dictionary.json +796 -0
  70. package/src/scripts/graph.json +664 -0
  71. package/src/scripts/regenerate.ts +248 -0
  72. package/src/types/index.ts +506 -0
@@ -0,0 +1,664 @@
1
+ {
2
+ "nodes": [
3
+ {
4
+ "id": "actor",
5
+ "type": "table",
6
+ "columns": [
7
+ {
8
+ "name": "actor_id",
9
+ "type": "integer",
10
+ "description": ""
11
+ },
12
+ {
13
+ "name": "first_name",
14
+ "type": "character varying",
15
+ "description": ""
16
+ },
17
+ {
18
+ "name": "last_name",
19
+ "type": "character varying",
20
+ "description": ""
21
+ },
22
+ {
23
+ "name": "last_update",
24
+ "type": "timestamp without time zone",
25
+ "description": ""
26
+ }
27
+ ],
28
+ "rowCount": 200,
29
+ "description": ""
30
+ },
31
+ {
32
+ "id": "store",
33
+ "type": "table",
34
+ "columns": [
35
+ {
36
+ "name": "store_id",
37
+ "type": "integer",
38
+ "description": ""
39
+ },
40
+ {
41
+ "name": "manager_staff_id",
42
+ "type": "smallint",
43
+ "description": ""
44
+ },
45
+ {
46
+ "name": "address_id",
47
+ "type": "smallint",
48
+ "description": ""
49
+ },
50
+ {
51
+ "name": "last_update",
52
+ "type": "timestamp without time zone",
53
+ "description": ""
54
+ }
55
+ ],
56
+ "rowCount": 2,
57
+ "description": ""
58
+ },
59
+ {
60
+ "id": "address",
61
+ "type": "table",
62
+ "columns": [
63
+ {
64
+ "name": "address_id",
65
+ "type": "integer",
66
+ "description": ""
67
+ },
68
+ {
69
+ "name": "address",
70
+ "type": "character varying",
71
+ "description": ""
72
+ },
73
+ {
74
+ "name": "address2",
75
+ "type": "character varying",
76
+ "description": ""
77
+ },
78
+ {
79
+ "name": "district",
80
+ "type": "character varying",
81
+ "description": ""
82
+ },
83
+ {
84
+ "name": "city_id",
85
+ "type": "smallint",
86
+ "description": ""
87
+ },
88
+ {
89
+ "name": "postal_code",
90
+ "type": "character varying",
91
+ "description": ""
92
+ },
93
+ {
94
+ "name": "phone",
95
+ "type": "character varying",
96
+ "description": ""
97
+ },
98
+ {
99
+ "name": "last_update",
100
+ "type": "timestamp without time zone",
101
+ "description": ""
102
+ }
103
+ ],
104
+ "rowCount": 603,
105
+ "description": ""
106
+ },
107
+ {
108
+ "id": "category",
109
+ "type": "table",
110
+ "columns": [
111
+ {
112
+ "name": "category_id",
113
+ "type": "integer",
114
+ "description": ""
115
+ },
116
+ {
117
+ "name": "name",
118
+ "type": "character varying",
119
+ "description": ""
120
+ },
121
+ {
122
+ "name": "last_update",
123
+ "type": "timestamp without time zone",
124
+ "description": ""
125
+ }
126
+ ],
127
+ "rowCount": 16,
128
+ "description": ""
129
+ },
130
+ {
131
+ "id": "city",
132
+ "type": "table",
133
+ "columns": [
134
+ {
135
+ "name": "city_id",
136
+ "type": "integer",
137
+ "description": ""
138
+ },
139
+ {
140
+ "name": "city",
141
+ "type": "character varying",
142
+ "description": ""
143
+ },
144
+ {
145
+ "name": "country_id",
146
+ "type": "smallint",
147
+ "description": ""
148
+ },
149
+ {
150
+ "name": "last_update",
151
+ "type": "timestamp without time zone",
152
+ "description": ""
153
+ }
154
+ ],
155
+ "rowCount": 600,
156
+ "description": ""
157
+ },
158
+ {
159
+ "id": "country",
160
+ "type": "table",
161
+ "columns": [
162
+ {
163
+ "name": "country_id",
164
+ "type": "integer",
165
+ "description": ""
166
+ },
167
+ {
168
+ "name": "country",
169
+ "type": "character varying",
170
+ "description": ""
171
+ },
172
+ {
173
+ "name": "last_update",
174
+ "type": "timestamp without time zone",
175
+ "description": ""
176
+ }
177
+ ],
178
+ "rowCount": 109,
179
+ "description": ""
180
+ },
181
+ {
182
+ "id": "customer",
183
+ "type": "table",
184
+ "columns": [
185
+ {
186
+ "name": "customer_id",
187
+ "type": "integer",
188
+ "description": ""
189
+ },
190
+ {
191
+ "name": "store_id",
192
+ "type": "smallint",
193
+ "description": ""
194
+ },
195
+ {
196
+ "name": "first_name",
197
+ "type": "character varying",
198
+ "description": ""
199
+ },
200
+ {
201
+ "name": "last_name",
202
+ "type": "character varying",
203
+ "description": ""
204
+ },
205
+ {
206
+ "name": "email",
207
+ "type": "character varying",
208
+ "description": ""
209
+ },
210
+ {
211
+ "name": "address_id",
212
+ "type": "smallint",
213
+ "description": ""
214
+ },
215
+ {
216
+ "name": "activebool",
217
+ "type": "boolean",
218
+ "description": ""
219
+ },
220
+ {
221
+ "name": "create_date",
222
+ "type": "date",
223
+ "description": ""
224
+ },
225
+ {
226
+ "name": "last_update",
227
+ "type": "timestamp without time zone",
228
+ "description": ""
229
+ },
230
+ {
231
+ "name": "active",
232
+ "type": "integer",
233
+ "description": ""
234
+ }
235
+ ],
236
+ "rowCount": 599,
237
+ "description": ""
238
+ },
239
+ {
240
+ "id": "film_actor",
241
+ "type": "table",
242
+ "columns": [
243
+ {
244
+ "name": "actor_id",
245
+ "type": "smallint",
246
+ "description": ""
247
+ },
248
+ {
249
+ "name": "film_id",
250
+ "type": "smallint",
251
+ "description": ""
252
+ },
253
+ {
254
+ "name": "last_update",
255
+ "type": "timestamp without time zone",
256
+ "description": ""
257
+ }
258
+ ],
259
+ "rowCount": 5462,
260
+ "description": ""
261
+ },
262
+ {
263
+ "id": "film_category",
264
+ "type": "table",
265
+ "columns": [
266
+ {
267
+ "name": "film_id",
268
+ "type": "smallint",
269
+ "description": ""
270
+ },
271
+ {
272
+ "name": "category_id",
273
+ "type": "smallint",
274
+ "description": ""
275
+ },
276
+ {
277
+ "name": "last_update",
278
+ "type": "timestamp without time zone",
279
+ "description": ""
280
+ }
281
+ ],
282
+ "rowCount": 1000,
283
+ "description": ""
284
+ },
285
+ {
286
+ "id": "inventory",
287
+ "type": "table",
288
+ "columns": [
289
+ {
290
+ "name": "inventory_id",
291
+ "type": "integer",
292
+ "description": ""
293
+ },
294
+ {
295
+ "name": "film_id",
296
+ "type": "smallint",
297
+ "description": ""
298
+ },
299
+ {
300
+ "name": "store_id",
301
+ "type": "smallint",
302
+ "description": ""
303
+ },
304
+ {
305
+ "name": "last_update",
306
+ "type": "timestamp without time zone",
307
+ "description": ""
308
+ }
309
+ ],
310
+ "rowCount": 4581,
311
+ "description": ""
312
+ },
313
+ {
314
+ "id": "language",
315
+ "type": "table",
316
+ "columns": [
317
+ {
318
+ "name": "language_id",
319
+ "type": "integer",
320
+ "description": ""
321
+ },
322
+ {
323
+ "name": "name",
324
+ "type": "character",
325
+ "description": ""
326
+ },
327
+ {
328
+ "name": "last_update",
329
+ "type": "timestamp without time zone",
330
+ "description": ""
331
+ }
332
+ ],
333
+ "rowCount": 6,
334
+ "description": ""
335
+ },
336
+ {
337
+ "id": "rental",
338
+ "type": "table",
339
+ "columns": [
340
+ {
341
+ "name": "rental_id",
342
+ "type": "integer",
343
+ "description": ""
344
+ },
345
+ {
346
+ "name": "rental_date",
347
+ "type": "timestamp without time zone",
348
+ "description": ""
349
+ },
350
+ {
351
+ "name": "inventory_id",
352
+ "type": "integer",
353
+ "description": ""
354
+ },
355
+ {
356
+ "name": "customer_id",
357
+ "type": "smallint",
358
+ "description": ""
359
+ },
360
+ {
361
+ "name": "return_date",
362
+ "type": "timestamp without time zone",
363
+ "description": ""
364
+ },
365
+ {
366
+ "name": "staff_id",
367
+ "type": "smallint",
368
+ "description": ""
369
+ },
370
+ {
371
+ "name": "last_update",
372
+ "type": "timestamp without time zone",
373
+ "description": ""
374
+ }
375
+ ],
376
+ "rowCount": 16044,
377
+ "description": ""
378
+ },
379
+ {
380
+ "id": "staff",
381
+ "type": "table",
382
+ "columns": [
383
+ {
384
+ "name": "staff_id",
385
+ "type": "integer",
386
+ "description": ""
387
+ },
388
+ {
389
+ "name": "first_name",
390
+ "type": "character varying",
391
+ "description": ""
392
+ },
393
+ {
394
+ "name": "last_name",
395
+ "type": "character varying",
396
+ "description": ""
397
+ },
398
+ {
399
+ "name": "address_id",
400
+ "type": "smallint",
401
+ "description": ""
402
+ },
403
+ {
404
+ "name": "email",
405
+ "type": "character varying",
406
+ "description": ""
407
+ },
408
+ {
409
+ "name": "store_id",
410
+ "type": "smallint",
411
+ "description": ""
412
+ },
413
+ {
414
+ "name": "active",
415
+ "type": "boolean",
416
+ "description": ""
417
+ },
418
+ {
419
+ "name": "username",
420
+ "type": "character varying",
421
+ "description": ""
422
+ },
423
+ {
424
+ "name": "password",
425
+ "type": "character varying",
426
+ "description": ""
427
+ },
428
+ {
429
+ "name": "last_update",
430
+ "type": "timestamp without time zone",
431
+ "description": ""
432
+ },
433
+ {
434
+ "name": "picture",
435
+ "type": "bytea",
436
+ "description": ""
437
+ }
438
+ ],
439
+ "rowCount": 2,
440
+ "description": ""
441
+ },
442
+ {
443
+ "id": "payment",
444
+ "type": "table",
445
+ "columns": [
446
+ {
447
+ "name": "payment_id",
448
+ "type": "integer",
449
+ "description": ""
450
+ },
451
+ {
452
+ "name": "customer_id",
453
+ "type": "smallint",
454
+ "description": ""
455
+ },
456
+ {
457
+ "name": "staff_id",
458
+ "type": "smallint",
459
+ "description": ""
460
+ },
461
+ {
462
+ "name": "rental_id",
463
+ "type": "integer",
464
+ "description": ""
465
+ },
466
+ {
467
+ "name": "amount",
468
+ "type": "numeric",
469
+ "description": ""
470
+ },
471
+ {
472
+ "name": "payment_date",
473
+ "type": "timestamp without time zone",
474
+ "description": ""
475
+ }
476
+ ],
477
+ "rowCount": 14596,
478
+ "description": ""
479
+ },
480
+ {
481
+ "id": "film",
482
+ "type": "table",
483
+ "columns": [
484
+ {
485
+ "name": "film_id",
486
+ "type": "integer",
487
+ "description": ""
488
+ },
489
+ {
490
+ "name": "title",
491
+ "type": "character varying",
492
+ "description": ""
493
+ },
494
+ {
495
+ "name": "description",
496
+ "type": "text",
497
+ "description": ""
498
+ },
499
+ {
500
+ "name": "release_year",
501
+ "type": "integer",
502
+ "description": ""
503
+ },
504
+ {
505
+ "name": "language_id",
506
+ "type": "smallint",
507
+ "description": ""
508
+ },
509
+ {
510
+ "name": "rental_duration",
511
+ "type": "smallint",
512
+ "description": ""
513
+ },
514
+ {
515
+ "name": "rental_rate",
516
+ "type": "numeric",
517
+ "description": ""
518
+ },
519
+ {
520
+ "name": "length",
521
+ "type": "smallint",
522
+ "description": ""
523
+ },
524
+ {
525
+ "name": "replacement_cost",
526
+ "type": "numeric",
527
+ "description": ""
528
+ },
529
+ {
530
+ "name": "rating",
531
+ "type": "USER-DEFINED",
532
+ "description": ""
533
+ },
534
+ {
535
+ "name": "last_update",
536
+ "type": "timestamp without time zone",
537
+ "description": ""
538
+ },
539
+ {
540
+ "name": "special_features",
541
+ "type": "ARRAY",
542
+ "description": ""
543
+ },
544
+ {
545
+ "name": "fulltext",
546
+ "type": "tsvector",
547
+ "description": ""
548
+ }
549
+ ],
550
+ "rowCount": 1000,
551
+ "description": ""
552
+ }
553
+ ],
554
+ "edges": [
555
+ {
556
+ "name": "rel_undefined_undefined",
557
+ "via": "address_id",
558
+ "type": "foreign_key",
559
+ "weight": 1
560
+ },
561
+ {
562
+ "name": "rel_undefined_undefined",
563
+ "via": "actor_id",
564
+ "type": "foreign_key",
565
+ "weight": 1
566
+ },
567
+ {
568
+ "name": "rel_undefined_undefined",
569
+ "via": "film_id",
570
+ "type": "foreign_key",
571
+ "weight": 1
572
+ },
573
+ {
574
+ "name": "rel_undefined_undefined",
575
+ "via": "category_id",
576
+ "type": "foreign_key",
577
+ "weight": 1
578
+ },
579
+ {
580
+ "name": "rel_undefined_undefined",
581
+ "via": "film_id",
582
+ "type": "foreign_key",
583
+ "weight": 1
584
+ },
585
+ {
586
+ "name": "rel_undefined_undefined",
587
+ "via": "language_id",
588
+ "type": "foreign_key",
589
+ "weight": 1
590
+ },
591
+ {
592
+ "name": "rel_undefined_undefined",
593
+ "via": "city_id",
594
+ "type": "foreign_key",
595
+ "weight": 1
596
+ },
597
+ {
598
+ "name": "rel_undefined_undefined",
599
+ "via": "country_id",
600
+ "type": "foreign_key",
601
+ "weight": 1
602
+ },
603
+ {
604
+ "name": "rel_undefined_undefined",
605
+ "via": "film_id",
606
+ "type": "foreign_key",
607
+ "weight": 1
608
+ },
609
+ {
610
+ "name": "rel_undefined_undefined",
611
+ "via": "customer_id",
612
+ "type": "foreign_key",
613
+ "weight": 1
614
+ },
615
+ {
616
+ "name": "rel_undefined_undefined",
617
+ "via": "rental_id",
618
+ "type": "foreign_key",
619
+ "weight": 1
620
+ },
621
+ {
622
+ "name": "rel_undefined_undefined",
623
+ "via": "staff_id",
624
+ "type": "foreign_key",
625
+ "weight": 1
626
+ },
627
+ {
628
+ "name": "rel_undefined_undefined",
629
+ "via": "customer_id",
630
+ "type": "foreign_key",
631
+ "weight": 1
632
+ },
633
+ {
634
+ "name": "rel_undefined_undefined",
635
+ "via": "inventory_id",
636
+ "type": "foreign_key",
637
+ "weight": 1
638
+ },
639
+ {
640
+ "name": "rel_undefined_undefined",
641
+ "via": "staff_id",
642
+ "type": "foreign_key",
643
+ "weight": 1
644
+ },
645
+ {
646
+ "name": "rel_undefined_undefined",
647
+ "via": "address_id",
648
+ "type": "foreign_key",
649
+ "weight": 1
650
+ },
651
+ {
652
+ "name": "rel_undefined_undefined",
653
+ "via": "address_id",
654
+ "type": "foreign_key",
655
+ "weight": 1
656
+ },
657
+ {
658
+ "name": "rel_undefined_undefined",
659
+ "via": "manager_staff_id",
660
+ "type": "foreign_key",
661
+ "weight": 1
662
+ }
663
+ ]
664
+ }