alizarin 0.2.1-alpha.83

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 (57) hide show
  1. package/LICENSE.txt +661 -0
  2. package/README.md +160 -0
  3. package/dist/_wasm.d.ts +23 -0
  4. package/dist/alizarin.full.js +799 -0
  5. package/dist/alizarin.full.js.map +1 -0
  6. package/dist/alizarin.inline-full.js +4 -0
  7. package/dist/alizarin.inline.js +4 -0
  8. package/dist/alizarin.js +47 -0
  9. package/dist/alizarin.js.map +1 -0
  10. package/dist/alizarin_bg.wasm +0 -0
  11. package/dist/backend.d.ts +74 -0
  12. package/dist/cards.d.ts +21 -0
  13. package/dist/client.d.ts +86 -0
  14. package/dist/collectionMutator.d.ts +155 -0
  15. package/dist/csvModelLoader.d.ts +59 -0
  16. package/dist/full.d.ts +3 -0
  17. package/dist/graphManager.d.ts +259 -0
  18. package/dist/interfaces.d.ts +145 -0
  19. package/dist/main-r-MmUiQf.js +12355 -0
  20. package/dist/main-r-MmUiQf.js.map +1 -0
  21. package/dist/main.d.ts +28 -0
  22. package/dist/nodeConfig.d.ts +61 -0
  23. package/dist/pseudos.d.ts +118 -0
  24. package/dist/rdm.d.ts +68 -0
  25. package/dist/renderers.d.ts +65 -0
  26. package/dist/semantic.d.ts +35 -0
  27. package/dist/static-types.d.ts +172 -0
  28. package/dist/staticStore.d.ts +60 -0
  29. package/dist/tracing/index.d.ts +172 -0
  30. package/dist/utils.d.ts +43 -0
  31. package/dist/validation/index.d.ts +734 -0
  32. package/dist/validation/index.js +1194 -0
  33. package/dist/validation/index.js.map +1 -0
  34. package/dist/validation/validators/graphLoading.d.ts +69 -0
  35. package/dist/validation/validators/index.d.ts +1 -0
  36. package/dist/viewModels/BooleanViewModel.d.ts +17 -0
  37. package/dist/viewModels/ConceptListViewModel.d.ts +15 -0
  38. package/dist/viewModels/ConceptValueViewModel.d.ts +28 -0
  39. package/dist/viewModels/DateViewModel.d.ts +16 -0
  40. package/dist/viewModels/DomainValueListViewModel.d.ts +15 -0
  41. package/dist/viewModels/DomainValueViewModel.d.ts +17 -0
  42. package/dist/viewModels/EDTFViewModel.d.ts +13 -0
  43. package/dist/viewModels/GeoJSONViewModel.d.ts +26 -0
  44. package/dist/viewModels/NodeViewModel.d.ts +15 -0
  45. package/dist/viewModels/NonLocalizedStringViewModel.d.ts +13 -0
  46. package/dist/viewModels/NumberViewModel.d.ts +14 -0
  47. package/dist/viewModels/ResourceInstanceListViewModel.d.ts +25 -0
  48. package/dist/viewModels/ResourceInstanceViewModel.d.ts +62 -0
  49. package/dist/viewModels/StringViewModel.d.ts +17 -0
  50. package/dist/viewModels/UrlViewModel.d.ts +22 -0
  51. package/dist/viewModels/cacheEntries.d.ts +73 -0
  52. package/dist/viewModels/getViewModel.d.ts +4 -0
  53. package/dist/viewModels/index.d.ts +20 -0
  54. package/dist/viewModels/types.d.ts +15 -0
  55. package/dist/viewModels.d.ts +1 -0
  56. package/dist/wasmTiming.d.ts +11 -0
  57. package/package.json +93 -0
@@ -0,0 +1,1194 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+ import Ajv from "ajv";
5
+ import addFormats from "ajv-formats";
6
+ import { readdirSync, readFileSync, existsSync } from "fs";
7
+ import { join } from "path";
8
+ const $schema$2 = "http://json-schema.org/draft-07/schema#";
9
+ const title$2 = "Arches Graph Model Schema";
10
+ const description$2 = "JSON Schema for Arches heritage management graph model definition files";
11
+ const type$2 = "object";
12
+ const required$2 = [
13
+ "graph"
14
+ ];
15
+ const properties$2 = {
16
+ graph: {
17
+ type: "array",
18
+ items: {
19
+ $ref: "#/definitions/graph"
20
+ },
21
+ minItems: 1,
22
+ maxItems: 1
23
+ }
24
+ };
25
+ const definitions$2 = {
26
+ uuid: {
27
+ type: "string",
28
+ pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
29
+ },
30
+ multilingualString: {
31
+ type: "object",
32
+ patternProperties: {
33
+ "^[a-z]{2}(-[A-Z]{2})?$": {
34
+ type: "string"
35
+ }
36
+ },
37
+ additionalProperties: false,
38
+ minProperties: 1
39
+ },
40
+ graph: {
41
+ type: "object",
42
+ required: [
43
+ "graphid",
44
+ "name",
45
+ "isresource",
46
+ "nodes",
47
+ "nodegroups",
48
+ "edges",
49
+ "cards"
50
+ ],
51
+ properties: {
52
+ graphid: {
53
+ $ref: "#/definitions/uuid"
54
+ },
55
+ name: {
56
+ $ref: "#/definitions/multilingualString"
57
+ },
58
+ subtitle: {
59
+ $ref: "#/definitions/multilingualString"
60
+ },
61
+ description: {
62
+ $ref: "#/definitions/multilingualString"
63
+ },
64
+ author: {
65
+ type: "string"
66
+ },
67
+ deploymentdate: {
68
+ type: "string",
69
+ format: "date-time"
70
+ },
71
+ version: {
72
+ type: "string"
73
+ },
74
+ isresource: {
75
+ type: "boolean"
76
+ },
77
+ iconclass: {
78
+ type: "string"
79
+ },
80
+ color: {
81
+ type: "string",
82
+ pattern: "^#[0-9a-f]{6}$"
83
+ },
84
+ ontology_id: {
85
+ oneOf: [
86
+ {
87
+ type: "string"
88
+ },
89
+ {
90
+ type: "array",
91
+ items: {
92
+ type: "string"
93
+ },
94
+ minItems: 1
95
+ },
96
+ {
97
+ type: "null"
98
+ }
99
+ ]
100
+ },
101
+ template_id: {
102
+ $ref: "#/definitions/uuid"
103
+ },
104
+ functions: {
105
+ type: "array"
106
+ },
107
+ nodes: {
108
+ type: "array",
109
+ items: {
110
+ $ref: "#/definitions/node"
111
+ },
112
+ minItems: 1
113
+ },
114
+ nodegroups: {
115
+ type: "array",
116
+ items: {
117
+ $ref: "#/definitions/nodegroup"
118
+ },
119
+ minItems: 1
120
+ },
121
+ edges: {
122
+ type: "array",
123
+ items: {
124
+ $ref: "#/definitions/edge"
125
+ }
126
+ },
127
+ cards: {
128
+ type: "array",
129
+ items: {
130
+ $ref: "#/definitions/card"
131
+ }
132
+ },
133
+ cards_x_nodes_x_widgets: {
134
+ type: "array"
135
+ },
136
+ relatable_resource_model_ids: {
137
+ type: "array"
138
+ },
139
+ resource_2_resource_constraints: {
140
+ type: "array"
141
+ },
142
+ functions_x_graphs: {
143
+ type: "array"
144
+ },
145
+ publication: {
146
+ type: [
147
+ "object",
148
+ "null"
149
+ ]
150
+ }
151
+ }
152
+ },
153
+ node: {
154
+ type: "object",
155
+ required: [
156
+ "nodeid",
157
+ "name",
158
+ "datatype",
159
+ "istopnode"
160
+ ],
161
+ properties: {
162
+ nodeid: {
163
+ $ref: "#/definitions/uuid"
164
+ },
165
+ name: {
166
+ type: "string"
167
+ },
168
+ description: {
169
+ type: "string"
170
+ },
171
+ datatype: {
172
+ type: "string",
173
+ "enum": [
174
+ "semantic",
175
+ "string",
176
+ "number",
177
+ "boolean",
178
+ "date",
179
+ "concept",
180
+ "file-list",
181
+ "geojson-feature-collection",
182
+ "resource-instance"
183
+ ]
184
+ },
185
+ istopnode: {
186
+ type: "boolean"
187
+ },
188
+ nodegroup_id: {
189
+ oneOf: [
190
+ {
191
+ $ref: "#/definitions/uuid"
192
+ },
193
+ {
194
+ type: "null"
195
+ }
196
+ ]
197
+ },
198
+ config: {
199
+ type: "object"
200
+ },
201
+ graph_id: {
202
+ $ref: "#/definitions/uuid"
203
+ },
204
+ sortorder: {
205
+ type: "number"
206
+ },
207
+ fieldname: {
208
+ type: [
209
+ "string",
210
+ "null"
211
+ ]
212
+ },
213
+ exportable: {
214
+ type: "boolean"
215
+ },
216
+ isrequired: {
217
+ type: "boolean"
218
+ },
219
+ issearchable: {
220
+ type: "boolean"
221
+ },
222
+ is_collector: {
223
+ type: "boolean"
224
+ },
225
+ hascustomalias: {
226
+ type: "boolean"
227
+ },
228
+ ontologyclass: {
229
+ oneOf: [
230
+ {
231
+ type: "string"
232
+ },
233
+ {
234
+ type: "array",
235
+ items: {
236
+ type: "string"
237
+ },
238
+ minItems: 1
239
+ },
240
+ {
241
+ type: "null"
242
+ }
243
+ ]
244
+ },
245
+ alias: {
246
+ type: [
247
+ "string",
248
+ "null"
249
+ ]
250
+ },
251
+ parentproperty: {
252
+ type: [
253
+ "string",
254
+ "null"
255
+ ]
256
+ },
257
+ sourcebranchpublication_id: {
258
+ type: [
259
+ "string",
260
+ "null"
261
+ ]
262
+ }
263
+ },
264
+ "if": {
265
+ properties: {
266
+ istopnode: {
267
+ "const": true
268
+ }
269
+ }
270
+ },
271
+ then: {
272
+ properties: {
273
+ nodegroup_id: {
274
+ type: "null"
275
+ }
276
+ },
277
+ required: [
278
+ "nodegroup_id"
279
+ ]
280
+ },
281
+ "else": {
282
+ properties: {
283
+ nodegroup_id: {
284
+ $ref: "#/definitions/uuid"
285
+ }
286
+ },
287
+ required: [
288
+ "nodegroup_id"
289
+ ]
290
+ }
291
+ },
292
+ nodegroup: {
293
+ type: "object",
294
+ required: [
295
+ "nodegroupid"
296
+ ],
297
+ properties: {
298
+ nodegroupid: {
299
+ $ref: "#/definitions/uuid"
300
+ },
301
+ cardinality: {
302
+ type: [
303
+ "string",
304
+ "null"
305
+ ],
306
+ "enum": [
307
+ "1",
308
+ "n",
309
+ null
310
+ ]
311
+ },
312
+ parentnodegroup_id: {
313
+ oneOf: [
314
+ {
315
+ $ref: "#/definitions/uuid"
316
+ },
317
+ {
318
+ type: "null"
319
+ }
320
+ ]
321
+ },
322
+ legacygroupid: {
323
+ type: [
324
+ "string",
325
+ "null"
326
+ ]
327
+ },
328
+ name: {
329
+ type: "string"
330
+ },
331
+ sortorder: {
332
+ type: "number"
333
+ }
334
+ }
335
+ },
336
+ edge: {
337
+ type: "object",
338
+ required: [
339
+ "edgeid",
340
+ "graph_id",
341
+ "domainnode_id",
342
+ "rangenode_id"
343
+ ],
344
+ properties: {
345
+ edgeid: {
346
+ $ref: "#/definitions/uuid"
347
+ },
348
+ graph_id: {
349
+ $ref: "#/definitions/uuid"
350
+ },
351
+ domainnode_id: {
352
+ $ref: "#/definitions/uuid"
353
+ },
354
+ rangenode_id: {
355
+ $ref: "#/definitions/uuid"
356
+ },
357
+ name: {
358
+ type: [
359
+ "string",
360
+ "null"
361
+ ]
362
+ },
363
+ description: {
364
+ type: [
365
+ "string",
366
+ "null"
367
+ ]
368
+ },
369
+ ontologyproperty: {
370
+ type: [
371
+ "string",
372
+ "null"
373
+ ]
374
+ },
375
+ sortorder: {
376
+ type: "number"
377
+ }
378
+ }
379
+ },
380
+ card: {
381
+ type: "object",
382
+ required: [
383
+ "cardid",
384
+ "nodegroup_id",
385
+ "graph_id",
386
+ "name",
387
+ "active",
388
+ "visible"
389
+ ],
390
+ properties: {
391
+ cardid: {
392
+ $ref: "#/definitions/uuid"
393
+ },
394
+ nodegroup_id: {
395
+ $ref: "#/definitions/uuid"
396
+ },
397
+ graph_id: {
398
+ $ref: "#/definitions/uuid"
399
+ },
400
+ name: {
401
+ $ref: "#/definitions/multilingualString"
402
+ },
403
+ description: {
404
+ type: "string"
405
+ },
406
+ instructions: {
407
+ $ref: "#/definitions/multilingualString"
408
+ },
409
+ helptext: {
410
+ $ref: "#/definitions/multilingualString"
411
+ },
412
+ helptitle: {
413
+ $ref: "#/definitions/multilingualString"
414
+ },
415
+ active: {
416
+ type: "boolean"
417
+ },
418
+ visible: {
419
+ type: "boolean"
420
+ },
421
+ sortorder: {
422
+ type: "number"
423
+ },
424
+ helpenabled: {
425
+ type: "boolean"
426
+ },
427
+ cssclass: {
428
+ type: "string"
429
+ },
430
+ is_editable: {
431
+ type: "boolean"
432
+ },
433
+ config: {
434
+ type: [
435
+ "object",
436
+ "null"
437
+ ]
438
+ },
439
+ constraints: {
440
+ type: "array"
441
+ }
442
+ }
443
+ }
444
+ };
445
+ const allOf = [
446
+ {
447
+ description: "Constraint: Top nodes must have nodegroup_id: null for Alizarin compatibility",
448
+ "if": {
449
+ properties: {
450
+ graph: {
451
+ type: "array",
452
+ items: {
453
+ properties: {
454
+ nodes: {
455
+ type: "array",
456
+ contains: {
457
+ properties: {
458
+ istopnode: {
459
+ "const": true
460
+ }
461
+ }
462
+ }
463
+ }
464
+ }
465
+ }
466
+ }
467
+ }
468
+ },
469
+ then: {
470
+ properties: {
471
+ graph: {
472
+ items: {
473
+ properties: {
474
+ nodes: {
475
+ items: {
476
+ "if": {
477
+ properties: {
478
+ istopnode: {
479
+ "const": true
480
+ }
481
+ }
482
+ },
483
+ then: {
484
+ properties: {
485
+ nodegroup_id: {
486
+ type: "null"
487
+ }
488
+ },
489
+ required: [
490
+ "nodegroup_id"
491
+ ]
492
+ }
493
+ }
494
+ }
495
+ }
496
+ }
497
+ }
498
+ }
499
+ }
500
+ },
501
+ {
502
+ description: "Constraint: Root nodegroups can have only one node, all nodegroups must have a node with matching ID",
503
+ properties: {
504
+ graph: {
505
+ items: {
506
+ type: "object",
507
+ properties: {
508
+ nodes: {
509
+ type: "array",
510
+ items: {
511
+ type: "object",
512
+ properties: {
513
+ nodegroup_id: {
514
+ oneOf: [
515
+ {
516
+ $ref: "#/definitions/uuid"
517
+ },
518
+ {
519
+ type: "null"
520
+ }
521
+ ]
522
+ },
523
+ istopnode: {
524
+ type: "boolean"
525
+ }
526
+ }
527
+ }
528
+ },
529
+ nodegroups: {
530
+ type: "array",
531
+ items: {
532
+ type: "object",
533
+ properties: {
534
+ nodegroupid: {
535
+ $ref: "#/definitions/uuid"
536
+ }
537
+ }
538
+ }
539
+ }
540
+ }
541
+ }
542
+ }
543
+ },
544
+ additionalProperties: true
545
+ }
546
+ ];
547
+ const graphModelSchema = {
548
+ $schema: $schema$2,
549
+ title: title$2,
550
+ description: description$2,
551
+ type: type$2,
552
+ required: required$2,
553
+ properties: properties$2,
554
+ definitions: definitions$2,
555
+ allOf
556
+ };
557
+ const $schema$1 = "http://json-schema.org/draft-07/schema#";
558
+ const title$1 = "Arches Business Data Schema";
559
+ const description$1 = "JSON Schema for Arches heritage management business data files with Alizarin compatibility";
560
+ const type$1 = "object";
561
+ const required$1 = [
562
+ "business_data"
563
+ ];
564
+ const properties$1 = {
565
+ business_data: {
566
+ $ref: "#/definitions/businessData"
567
+ }
568
+ };
569
+ const definitions$1 = {
570
+ uuid: {
571
+ type: "string",
572
+ pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
573
+ },
574
+ businessData: {
575
+ type: "object",
576
+ required: [
577
+ "resources"
578
+ ],
579
+ properties: {
580
+ resources: {
581
+ type: "array",
582
+ items: {
583
+ $ref: "#/definitions/resource"
584
+ },
585
+ minItems: 1
586
+ }
587
+ }
588
+ },
589
+ resource: {
590
+ type: "object",
591
+ required: [
592
+ "resourceid",
593
+ "graph_id",
594
+ "tiles",
595
+ "resourceinstance"
596
+ ],
597
+ properties: {
598
+ resourceid: {
599
+ $ref: "#/definitions/uuid"
600
+ },
601
+ graph_id: {
602
+ $ref: "#/definitions/uuid"
603
+ },
604
+ legacyid: {
605
+ type: [
606
+ "string",
607
+ "null"
608
+ ]
609
+ },
610
+ tiles: {
611
+ type: "array",
612
+ items: {
613
+ $ref: "#/definitions/tile"
614
+ },
615
+ minItems: 1
616
+ },
617
+ resourceinstance: {
618
+ $ref: "#/definitions/resourceInstance"
619
+ }
620
+ }
621
+ },
622
+ resourceInstance: {
623
+ type: "object",
624
+ required: [
625
+ "resourceinstanceid",
626
+ "graph_id",
627
+ "legacyid",
628
+ "name",
629
+ "displayname",
630
+ "descriptors"
631
+ ],
632
+ properties: {
633
+ resourceinstanceid: {
634
+ $ref: "#/definitions/uuid"
635
+ },
636
+ graph_id: {
637
+ $ref: "#/definitions/uuid"
638
+ },
639
+ legacyid: {
640
+ type: "string",
641
+ minLength: 1,
642
+ description: "Legacy identifier for the resource - required for Alizarin"
643
+ },
644
+ createdtime: {
645
+ type: "string",
646
+ format: "date-time"
647
+ },
648
+ name: {
649
+ type: "string",
650
+ minLength: 1,
651
+ description: "Display name for the resource - required for Alizarin"
652
+ },
653
+ displayname: {
654
+ type: "string",
655
+ minLength: 1,
656
+ description: "Display name for UI purposes - required for Alizarin"
657
+ },
658
+ map_popup: {
659
+ type: "string",
660
+ description: "Text to show in map popups"
661
+ },
662
+ provisional: {
663
+ type: "string",
664
+ "enum": [
665
+ "true",
666
+ "false"
667
+ ]
668
+ },
669
+ descriptors: {
670
+ type: "object",
671
+ required: [
672
+ "name",
673
+ "description",
674
+ "map_popup",
675
+ "displayname"
676
+ ],
677
+ properties: {
678
+ name: {
679
+ type: "string",
680
+ minLength: 1
681
+ },
682
+ description: {
683
+ type: "string",
684
+ minLength: 1
685
+ },
686
+ map_popup: {
687
+ type: "string",
688
+ minLength: 1
689
+ },
690
+ displayname: {
691
+ type: "string",
692
+ minLength: 1
693
+ }
694
+ },
695
+ additionalProperties: false,
696
+ description: "Descriptors object - required for Alizarin resource metadata"
697
+ },
698
+ graph_publication_id: {
699
+ $ref: "#/definitions/uuid"
700
+ },
701
+ publication_id: {
702
+ $ref: "#/definitions/uuid"
703
+ }
704
+ }
705
+ },
706
+ tile: {
707
+ type: "object",
708
+ required: [
709
+ "tileid",
710
+ "nodegroup_id",
711
+ "data"
712
+ ],
713
+ properties: {
714
+ tileid: {
715
+ $ref: "#/definitions/uuid"
716
+ },
717
+ nodegroup_id: {
718
+ $ref: "#/definitions/uuid"
719
+ },
720
+ parenttile_id: {
721
+ oneOf: [
722
+ {
723
+ $ref: "#/definitions/uuid"
724
+ },
725
+ {
726
+ type: "null"
727
+ }
728
+ ]
729
+ },
730
+ resourceid: {
731
+ oneOf: [
732
+ {
733
+ $ref: "#/definitions/uuid"
734
+ },
735
+ {
736
+ type: "null"
737
+ }
738
+ ]
739
+ },
740
+ sortorder: {
741
+ type: "number"
742
+ },
743
+ tiles: {
744
+ type: "array",
745
+ items: {
746
+ $ref: "#/definitions/tile"
747
+ }
748
+ },
749
+ provisionaledits: {
750
+ type: [
751
+ "array",
752
+ "null"
753
+ ]
754
+ },
755
+ data: {
756
+ type: "object",
757
+ patternProperties: {
758
+ "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$": {
759
+ oneOf: [
760
+ {
761
+ type: "string"
762
+ },
763
+ {
764
+ type: "number"
765
+ },
766
+ {
767
+ type: "boolean"
768
+ },
769
+ {
770
+ type: "null"
771
+ },
772
+ {
773
+ type: "object",
774
+ properties: {
775
+ en: {
776
+ type: "object",
777
+ required: [
778
+ "value",
779
+ "direction"
780
+ ],
781
+ properties: {
782
+ value: {
783
+ type: "string"
784
+ },
785
+ direction: {
786
+ type: "string",
787
+ "enum": [
788
+ "ltr",
789
+ "rtl"
790
+ ]
791
+ }
792
+ }
793
+ }
794
+ }
795
+ }
796
+ ]
797
+ }
798
+ },
799
+ additionalProperties: false,
800
+ minProperties: 1
801
+ }
802
+ }
803
+ }
804
+ };
805
+ const businessDataSchema = {
806
+ $schema: $schema$1,
807
+ title: title$1,
808
+ description: description$1,
809
+ type: type$1,
810
+ required: required$1,
811
+ properties: properties$1,
812
+ definitions: definitions$1
813
+ };
814
+ const $schema = "http://json-schema.org/draft-07/schema#";
815
+ const title = "Arches Graphs Registry Schema";
816
+ const description = "JSON Schema for graphs.json registry file used by Alizarin";
817
+ const type = "object";
818
+ const required = [
819
+ "models"
820
+ ];
821
+ const properties = {
822
+ models: {
823
+ type: "object",
824
+ patternProperties: {
825
+ "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$": {
826
+ $ref: "#/definitions/modelReference"
827
+ }
828
+ },
829
+ additionalProperties: false,
830
+ minProperties: 1
831
+ }
832
+ };
833
+ const definitions = {
834
+ uuid: {
835
+ type: "string",
836
+ pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
837
+ },
838
+ multilingualString: {
839
+ type: "object",
840
+ patternProperties: {
841
+ "^[a-z]{2}(-[A-Z]{2})?$": {
842
+ type: "string"
843
+ }
844
+ },
845
+ additionalProperties: false,
846
+ minProperties: 1
847
+ },
848
+ modelReference: {
849
+ type: "object",
850
+ required: [
851
+ "id",
852
+ "name",
853
+ "slug"
854
+ ],
855
+ properties: {
856
+ id: {
857
+ $ref: "#/definitions/uuid"
858
+ },
859
+ name: {
860
+ $ref: "#/definitions/multilingualString"
861
+ },
862
+ slug: {
863
+ type: "string",
864
+ pattern: "^[a-z][a-z0-9-]*[a-z0-9]$",
865
+ minLength: 2
866
+ },
867
+ subtitle: {
868
+ $ref: "#/definitions/multilingualString"
869
+ },
870
+ color: {
871
+ type: "string",
872
+ pattern: "^#[0-9a-f]{6}$"
873
+ },
874
+ iconclass: {
875
+ type: "string",
876
+ pattern: "^fa fa-[a-z-]+$"
877
+ }
878
+ }
879
+ }
880
+ };
881
+ const graphsRegistrySchema = {
882
+ $schema,
883
+ title,
884
+ description,
885
+ type,
886
+ required,
887
+ properties,
888
+ definitions
889
+ };
890
+ class GraphLoadingValidator {
891
+ constructor(basePath = ".") {
892
+ __publicField(this, "ajv");
893
+ __publicField(this, "validateGraphModel");
894
+ __publicField(this, "validateBusinessData");
895
+ __publicField(this, "validateGraphsRegistry");
896
+ __publicField(this, "results");
897
+ __publicField(this, "basePath");
898
+ this.basePath = basePath;
899
+ this.ajv = new Ajv({
900
+ allErrors: true,
901
+ verbose: true,
902
+ strict: false
903
+ });
904
+ addFormats(this.ajv);
905
+ this.validateGraphModel = this.ajv.compile(graphModelSchema);
906
+ this.validateBusinessData = this.ajv.compile(businessDataSchema);
907
+ this.validateGraphsRegistry = this.ajv.compile(graphsRegistrySchema);
908
+ this.results = {
909
+ graphModels: { passed: 0, failed: 0, errors: [] },
910
+ businessData: { passed: 0, failed: 0, errors: [] },
911
+ graphsRegistry: { passed: 0, failed: 0, errors: [] },
912
+ alizarinCompatibility: { passed: 0, failed: 0, errors: [] },
913
+ graphLoadingTests: { passed: 0, failed: 0, errors: [] }
914
+ };
915
+ }
916
+ reportError(category, file, error) {
917
+ this.results[category].failed++;
918
+ this.results[category].errors.push({ file, error });
919
+ }
920
+ reportSuccess(category, _file) {
921
+ this.results[category].passed++;
922
+ }
923
+ formatErrors(errors) {
924
+ if (!errors) return "Unknown error";
925
+ return errors.map((e) => `${e.instancePath || "root"}: ${e.message}`).join("; ");
926
+ }
927
+ /**
928
+ * Validate graph model files
929
+ */
930
+ validateGraphModels() {
931
+ const modelFiles = readdirSync(this.basePath).filter(
932
+ (f) => f.startsWith("arches-") && f.endsWith("-model.json")
933
+ );
934
+ modelFiles.forEach((file) => {
935
+ try {
936
+ const content = JSON.parse(readFileSync(join(this.basePath, file), "utf8"));
937
+ if (this.validateGraphModel(content)) {
938
+ this.reportSuccess("graphModels", file);
939
+ } else {
940
+ const error = this.formatErrors(this.validateGraphModel.errors);
941
+ this.reportError("graphModels", file, error);
942
+ }
943
+ } catch (error) {
944
+ this.reportError("graphModels", file, `Parse error: ${error.message}`);
945
+ }
946
+ });
947
+ }
948
+ /**
949
+ * Validate business data files
950
+ */
951
+ validateBusinessDataFiles() {
952
+ const businessDataFiles = readdirSync(this.basePath).filter(
953
+ (f) => f.startsWith("arches-business-data-") && f.endsWith(".json") && f !== "arches-business-data-schema.json"
954
+ );
955
+ businessDataFiles.forEach((file) => {
956
+ try {
957
+ const content = JSON.parse(readFileSync(join(this.basePath, file), "utf8"));
958
+ if (this.validateBusinessData(content)) {
959
+ this.reportSuccess("businessData", file);
960
+ } else {
961
+ const error = this.formatErrors(this.validateBusinessData.errors);
962
+ this.reportError("businessData", file, error);
963
+ }
964
+ } catch (error) {
965
+ this.reportError("businessData", file, `Parse error: ${error.message}`);
966
+ }
967
+ });
968
+ }
969
+ /**
970
+ * Validate graphs registry file
971
+ */
972
+ validateGraphsRegistryFile() {
973
+ const registryPath = join(this.basePath, "graphs.json");
974
+ if (existsSync(registryPath)) {
975
+ try {
976
+ const content = JSON.parse(readFileSync(registryPath, "utf8"));
977
+ if (this.validateGraphsRegistry(content)) {
978
+ this.reportSuccess("graphsRegistry", "graphs.json");
979
+ } else {
980
+ const error = this.formatErrors(this.validateGraphsRegistry.errors);
981
+ this.reportError("graphsRegistry", "graphs.json", error);
982
+ }
983
+ } catch (error) {
984
+ this.reportError("graphsRegistry", "graphs.json", `Parse error: ${error.message}`);
985
+ }
986
+ } else {
987
+ this.reportError("graphsRegistry", "graphs.json", "File does not exist");
988
+ }
989
+ }
990
+ /**
991
+ * Check Alizarin compatibility requirements
992
+ */
993
+ checkAlizarinCompatibility() {
994
+ const registryPath = join(this.basePath, "graphs.json");
995
+ if (!existsSync(registryPath)) {
996
+ return;
997
+ }
998
+ const graphs = JSON.parse(readFileSync(registryPath, "utf8"));
999
+ const availableGraphIds = new Set(Object.keys(graphs.models || {}));
1000
+ const businessDataFiles = readdirSync(this.basePath).filter(
1001
+ (f) => f.startsWith("arches-business-data-") && f.endsWith(".json") && f !== "arches-business-data-schema.json"
1002
+ );
1003
+ businessDataFiles.forEach((file) => {
1004
+ var _a;
1005
+ try {
1006
+ const content = JSON.parse(readFileSync(join(this.basePath, file), "utf8"));
1007
+ const resources = ((_a = content.business_data) == null ? void 0 : _a.resources) || [];
1008
+ resources.forEach((resource, index) => {
1009
+ const graphId = resource.graph_id;
1010
+ if (!availableGraphIds.has(graphId)) {
1011
+ this.reportError(
1012
+ "alizarinCompatibility",
1013
+ file,
1014
+ `Resource ${index}: graph_id ${graphId} not found in graphs.json`
1015
+ );
1016
+ return;
1017
+ }
1018
+ const ri = resource.resourceinstance;
1019
+ if (!ri) {
1020
+ this.reportError(
1021
+ "alizarinCompatibility",
1022
+ file,
1023
+ `Resource ${index}: Missing resourceinstance - required for Alizarin`
1024
+ );
1025
+ return;
1026
+ }
1027
+ const requiredFields = ["resourceinstanceid", "graph_id", "legacyid", "name", "displayname", "descriptors"];
1028
+ for (const field of requiredFields) {
1029
+ if (!ri[field]) {
1030
+ this.reportError(
1031
+ "alizarinCompatibility",
1032
+ file,
1033
+ `Resource ${index}: Missing resourceinstance.${field} - required for Alizarin`
1034
+ );
1035
+ return;
1036
+ }
1037
+ }
1038
+ const descriptors = ri.descriptors;
1039
+ const requiredDescriptors = ["name", "description", "map_popup", "displayname"];
1040
+ for (const field of requiredDescriptors) {
1041
+ if (!descriptors[field]) {
1042
+ this.reportError(
1043
+ "alizarinCompatibility",
1044
+ file,
1045
+ `Resource ${index}: Missing descriptors.${field} - required for Alizarin`
1046
+ );
1047
+ return;
1048
+ }
1049
+ }
1050
+ });
1051
+ if (resources.length > 0) {
1052
+ this.reportSuccess("alizarinCompatibility", file);
1053
+ }
1054
+ } catch (error) {
1055
+ this.reportError("alizarinCompatibility", file, `Parse error: ${error.message}`);
1056
+ }
1057
+ });
1058
+ }
1059
+ /**
1060
+ * Simulate graph loading process (as Alizarin would do it)
1061
+ */
1062
+ simulateGraphLoading() {
1063
+ var _a;
1064
+ const registryPath = join(this.basePath, "graphs.json");
1065
+ if (!existsSync(registryPath)) {
1066
+ this.reportError("graphLoadingTests", "graphs.json", "Registry file does not exist");
1067
+ return;
1068
+ }
1069
+ try {
1070
+ const graphsRegistry = JSON.parse(readFileSync(registryPath, "utf8"));
1071
+ for (const [graphId, model] of Object.entries(graphsRegistry.models)) {
1072
+ const modelFile = `arches-${model.slug}-model.json`;
1073
+ const modelPath = join(this.basePath, modelFile);
1074
+ if (!existsSync(modelPath)) {
1075
+ this.reportError("graphLoadingTests", graphId, `Model file ${modelFile} not found`);
1076
+ continue;
1077
+ }
1078
+ try {
1079
+ const modelContent = JSON.parse(readFileSync(modelPath, "utf8"));
1080
+ if (modelContent.graph[0].graphid !== graphId) {
1081
+ this.reportError(
1082
+ "graphLoadingTests",
1083
+ graphId,
1084
+ `Graph ID mismatch: registry has ${graphId}, model has ${modelContent.graph[0].graphid}`
1085
+ );
1086
+ continue;
1087
+ }
1088
+ const businessDataFiles = readdirSync(this.basePath).filter(
1089
+ (f) => f.startsWith("arches-business-data-") && f.endsWith(".json")
1090
+ );
1091
+ for (const file of businessDataFiles) {
1092
+ try {
1093
+ const content = JSON.parse(readFileSync(join(this.basePath, file), "utf8"));
1094
+ const resources = ((_a = content.business_data) == null ? void 0 : _a.resources) || [];
1095
+ if (resources.some((r) => r.graph_id === graphId)) {
1096
+ break;
1097
+ }
1098
+ } catch (error) {
1099
+ this.reportError("graphLoadingTests", graphId, `Business data file parse error: ${error.message}`);
1100
+ }
1101
+ }
1102
+ this.reportSuccess("graphLoadingTests", graphId);
1103
+ } catch (error) {
1104
+ this.reportError("graphLoadingTests", graphId, `Model file parse error: ${error.message}`);
1105
+ }
1106
+ }
1107
+ } catch (error) {
1108
+ this.reportError("graphLoadingTests", "graphs.json", `Registry parse error: ${error.message}`);
1109
+ }
1110
+ }
1111
+ /**
1112
+ * Run all validation checks
1113
+ */
1114
+ validate() {
1115
+ this.validateGraphModels();
1116
+ this.validateBusinessDataFiles();
1117
+ this.validateGraphsRegistryFile();
1118
+ this.checkAlizarinCompatibility();
1119
+ this.simulateGraphLoading();
1120
+ const totalPassed = Object.values(this.results).reduce((sum, result) => sum + result.passed, 0);
1121
+ const totalFailed = Object.values(this.results).reduce((sum, result) => sum + result.failed, 0);
1122
+ return {
1123
+ results: this.results,
1124
+ totalPassed,
1125
+ totalFailed,
1126
+ success: totalFailed === 0
1127
+ };
1128
+ }
1129
+ /**
1130
+ * Get validation results
1131
+ */
1132
+ getResults() {
1133
+ return this.results;
1134
+ }
1135
+ /**
1136
+ * Print validation summary to console
1137
+ */
1138
+ printSummary(summary) {
1139
+ console.log("\n\u{1F4CA} VALIDATION SUMMARY");
1140
+ console.log("====================\n");
1141
+ const categories = [
1142
+ { name: "Graph Models", key: "graphModels" },
1143
+ { name: "Business Data", key: "businessData" },
1144
+ { name: "Graphs Registry", key: "graphsRegistry" },
1145
+ { name: "Alizarin Compatibility", key: "alizarinCompatibility" },
1146
+ { name: "Graph Loading Tests", key: "graphLoadingTests" }
1147
+ ];
1148
+ categories.forEach((category) => {
1149
+ const result = summary.results[category.key];
1150
+ const total = result.passed + result.failed;
1151
+ const percentage = total > 0 ? Math.round(result.passed / total * 100) : 0;
1152
+ console.log(`${category.name}: ${result.passed}/${total} passed (${percentage}%)`);
1153
+ if (result.failed > 0) {
1154
+ console.log(` \u274C ${result.failed} failures:`);
1155
+ result.errors.slice(0, 3).forEach((error) => {
1156
+ console.log(` \u2022 ${error.file}: ${error.error}`);
1157
+ });
1158
+ if (result.errors.length > 3) {
1159
+ console.log(` \u2022 ... and ${result.errors.length - 3} more errors`);
1160
+ }
1161
+ }
1162
+ });
1163
+ console.log("");
1164
+ console.log(`\u{1F3AF} OVERALL RESULT: ${summary.totalPassed}/${summary.totalPassed + summary.totalFailed} checks passed`);
1165
+ if (summary.success) {
1166
+ console.log("\u{1F389} ALL VALIDATION CHECKS PASSED!");
1167
+ console.log("\u2705 Graph structure is valid");
1168
+ console.log("\u2705 Business data has proper Alizarin metadata");
1169
+ console.log("\u2705 All files can be loaded by Alizarin");
1170
+ console.log("\u2705 No compatibility issues detected");
1171
+ } else {
1172
+ console.log(`\u26A0\uFE0F ${summary.totalFailed} validation issues found`);
1173
+ console.log("\u{1F4A1} Review the errors above and fix the issues");
1174
+ console.log("\u{1F4A1} Re-run this validator after making corrections");
1175
+ }
1176
+ }
1177
+ }
1178
+ function validateGraphLoading(basePath = ".") {
1179
+ const validator = new GraphLoadingValidator(basePath);
1180
+ const summary = validator.validate();
1181
+ validator.printSummary(summary);
1182
+ return summary;
1183
+ }
1184
+ const schemas = {
1185
+ graphModel: graphModelSchema,
1186
+ businessData: businessDataSchema,
1187
+ graphsRegistry: graphsRegistrySchema
1188
+ };
1189
+ export {
1190
+ GraphLoadingValidator,
1191
+ validateGraphLoading as quickValidate,
1192
+ schemas,
1193
+ validateGraphLoading
1194
+ };