@twin.org/data-json-ld 0.0.1-next.17 → 0.0.1-next.20

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 (40) hide show
  1. package/dist/cjs/index.cjs +136 -117
  2. package/dist/esm/index.mjs +137 -118
  3. package/dist/types/index.d.ts +25 -0
  4. package/dist/types/models/IJsonLdContainerType.d.ts +8 -0
  5. package/dist/types/models/IJsonLdContainerTypeArray.d.ts +9 -0
  6. package/dist/types/models/IJsonLdContextDefinition.d.ts +25 -0
  7. package/dist/types/models/IJsonLdContextDefinitionElement.d.ts +9 -0
  8. package/dist/types/models/IJsonLdContextDefinitionRoot.d.ts +9 -0
  9. package/dist/types/models/IJsonLdDocument.d.ts +2 -204
  10. package/dist/types/models/IJsonLdExpandedTermDefinition.d.ts +28 -0
  11. package/dist/types/models/IJsonLdGraphObject.d.ts +16 -0
  12. package/dist/types/models/IJsonLdIdMap.d.ts +12 -0
  13. package/dist/types/models/IJsonLdIncludedBlock.d.ts +10 -0
  14. package/dist/types/models/IJsonLdIndexMap.d.ts +13 -0
  15. package/dist/types/models/IJsonLdIndexMapItem.d.ts +12 -0
  16. package/dist/types/models/IJsonLdJsonArray.d.ts +9 -0
  17. package/dist/types/models/IJsonLdJsonObject.d.ts +11 -0
  18. package/dist/types/models/IJsonLdJsonPrimitive.d.ts +8 -0
  19. package/dist/types/models/IJsonLdJsonValue.d.ts +11 -0
  20. package/dist/types/models/IJsonLdKeyword.d.ts +42 -0
  21. package/dist/types/models/IJsonLdLanguageMap.d.ts +11 -0
  22. package/dist/types/models/IJsonLdListObject.d.ts +13 -0
  23. package/dist/types/models/IJsonLdListOrSetItem.d.ts +10 -0
  24. package/dist/types/models/IJsonLdNodeObject.d.ts +19 -0
  25. package/dist/types/models/IJsonLdNodePrimitive.d.ts +13 -0
  26. package/dist/types/models/IJsonLdObject.d.ts +24 -0
  27. package/dist/types/models/IJsonLdSetObject.d.ts +13 -0
  28. package/dist/types/models/IJsonLdTypeMap.d.ts +12 -0
  29. package/dist/types/models/IJsonLdValueObject.d.ts +26 -0
  30. package/dist/types/utils/jsonLdProcessor.d.ts +3 -1
  31. package/docs/changelog.md +1 -1
  32. package/docs/reference/index.md +17 -17
  33. package/docs/reference/interfaces/IJsonLdJsonObject.md +2 -0
  34. package/docs/reference/interfaces/IJsonLdNodeObject.md +1 -1
  35. package/docs/reference/type-aliases/IJsonLdContainerType.md +2 -0
  36. package/docs/reference/type-aliases/IJsonLdContainerTypeArray.md +2 -0
  37. package/docs/reference/type-aliases/IJsonLdJsonArray.md +2 -0
  38. package/docs/reference/type-aliases/IJsonLdJsonPrimitive.md +2 -0
  39. package/docs/reference/type-aliases/IJsonLdJsonValue.md +2 -0
  40. package/package.json +2 -2
@@ -115,6 +115,7 @@ const JsonLdTypes = {
115
115
  };
116
116
 
117
117
  var type$e = "string";
118
+ var description$n = "Helper Types";
118
119
  var JsonLdContainerTypeSchema = {
119
120
  type: type$e,
120
121
  "enum": [
@@ -123,7 +124,8 @@ var JsonLdContainerTypeSchema = {
123
124
  "@id",
124
125
  "@graph",
125
126
  "@type"
126
- ]
127
+ ],
128
+ description: description$n
127
129
  };
128
130
 
129
131
  var anyOf$8 = [
@@ -300,29 +302,42 @@ var anyOf$8 = [
300
302
  maxItems: 2
301
303
  }
302
304
  ];
305
+ var description$m = "Helper Types.";
303
306
  var JsonLdContainerTypeArraySchema = {
304
- anyOf: anyOf$8
307
+ anyOf: anyOf$8,
308
+ description: description$m
305
309
  };
306
310
 
307
311
  var type$d = "object";
308
312
  var properties$6 = {
309
313
  "@base": {
310
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
314
+ type: [
315
+ "string",
316
+ "null"
317
+ ]
311
318
  },
312
319
  "@direction": {
313
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
320
+ type: [
321
+ "string",
322
+ "null"
323
+ ],
324
+ "enum": [
325
+ "ltr",
326
+ "rtl",
327
+ null
328
+ ]
314
329
  },
315
330
  "@import": {
316
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
331
+ type: "string"
317
332
  },
318
333
  "@language": {
319
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
334
+ type: "string"
320
335
  },
321
336
  "@propagate": {
322
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
337
+ type: "boolean"
323
338
  },
324
339
  "@protected": {
325
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
340
+ type: "boolean"
326
341
  },
327
342
  "@type": {
328
343
  type: "object",
@@ -332,7 +347,7 @@ var properties$6 = {
332
347
  "const": "@set"
333
348
  },
334
349
  "@protected": {
335
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
350
+ type: "boolean"
336
351
  }
337
352
  },
338
353
  required: [
@@ -341,10 +356,14 @@ var properties$6 = {
341
356
  additionalProperties: false
342
357
  },
343
358
  "@version": {
344
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
359
+ type: "string",
360
+ "const": "1.1"
345
361
  },
346
362
  "@vocab": {
347
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
363
+ type: [
364
+ "string",
365
+ "null"
366
+ ]
348
367
  }
349
368
  };
350
369
  var additionalProperties$b = {
@@ -360,12 +379,12 @@ var additionalProperties$b = {
360
379
  }
361
380
  ]
362
381
  };
363
- var description$h = "A context definition defines a local context in a node object.";
382
+ var description$l = "A context definition defines a local context in a node object.";
364
383
  var JsonLdContextDefinitionSchema = {
365
384
  type: type$d,
366
385
  properties: properties$6,
367
386
  additionalProperties: additionalProperties$b,
368
- description: description$h
387
+ description: description$l
369
388
  };
370
389
 
371
390
  var anyOf$7 = [
@@ -411,10 +430,10 @@ var anyOf$7 = [
411
430
  additionalProperties: false
412
431
  }
413
432
  ];
414
- var description$g = "A JSON-LD document MUST be valid JSON text as described in [RFC8259], or some format that can be represented in the JSON-LD internal representation that is equivalent to valid JSON text.";
433
+ var description$k = "A JSON-LD document MUST be valid JSON text as described in [RFC8259], or some format that can be represented in the JSON-LD internal representation that is equivalent to valid JSON text.";
415
434
  var JsonLdDocumentSchema = {
416
435
  anyOf: anyOf$7,
417
- description: description$g
436
+ description: description$k
418
437
  };
419
438
 
420
439
  var anyOf$6 = [
@@ -425,7 +444,13 @@ var anyOf$6 = [
425
444
  "@id": {
426
445
  anyOf: [
427
446
  {
428
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
447
+ type: "string"
448
+ },
449
+ {
450
+ type: "array",
451
+ items: {
452
+ type: "string"
453
+ }
429
454
  },
430
455
  {
431
456
  type: "null"
@@ -436,28 +461,64 @@ var anyOf$6 = [
436
461
  type: "string"
437
462
  },
438
463
  "@container": {
439
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
464
+ anyOf: [
465
+ {
466
+ type: "string",
467
+ "const": "@list"
468
+ },
469
+ {
470
+ type: "string",
471
+ "const": "@set"
472
+ },
473
+ {
474
+ $ref: "https://schema.twindev.org/json-ld/JsonLdContainerType"
475
+ },
476
+ {
477
+ type: "array",
478
+ items: {
479
+ anyOf: [
480
+ {
481
+ type: "string",
482
+ "const": "@list"
483
+ },
484
+ {
485
+ type: "string",
486
+ "const": "@set"
487
+ },
488
+ {
489
+ $ref: "https://schema.twindev.org/json-ld/JsonLdContainerType"
490
+ }
491
+ ]
492
+ }
493
+ },
494
+ {
495
+ $ref: "https://schema.twindev.org/json-ld/JsonLdContainerTypeArray"
496
+ },
497
+ {
498
+ type: "null"
499
+ }
500
+ ]
440
501
  },
441
502
  "@type": {
442
503
  type: "string"
443
504
  },
444
505
  "@language": {
445
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
506
+ type: "string"
446
507
  },
447
508
  "@index": {
448
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
509
+ type: "string"
449
510
  },
450
511
  "@context": {
451
512
  $ref: "https://schema.twindev.org/json-ld/JsonLdContextDefinition"
452
513
  },
453
514
  "@prefix": {
454
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
515
+ type: "boolean"
455
516
  },
456
517
  "@propagate": {
457
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
518
+ type: "boolean"
458
519
  },
459
520
  "@protected": {
460
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
521
+ type: "boolean"
461
522
  }
462
523
  }
463
524
  },
@@ -466,7 +527,7 @@ var anyOf$6 = [
466
527
  additionalProperties: false,
467
528
  properties: {
468
529
  "@reverse": {
469
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
530
+ type: "string"
470
531
  },
471
532
  "@container": {
472
533
  type: [
@@ -483,22 +544,22 @@ var anyOf$6 = [
483
544
  type: "string"
484
545
  },
485
546
  "@language": {
486
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
547
+ type: "string"
487
548
  },
488
549
  "@index": {
489
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
550
+ type: "string"
490
551
  },
491
552
  "@context": {
492
553
  $ref: "https://schema.twindev.org/json-ld/JsonLdContextDefinition"
493
554
  },
494
555
  "@prefix": {
495
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
556
+ type: "boolean"
496
557
  },
497
558
  "@propagate": {
498
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
559
+ type: "boolean"
499
560
  },
500
561
  "@protected": {
501
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
562
+ type: "boolean"
502
563
  }
503
564
  },
504
565
  required: [
@@ -506,10 +567,10 @@ var anyOf$6 = [
506
567
  ]
507
568
  }
508
569
  ];
509
- var description$f = "An expanded term definition is used to describe the mapping between a term and its expanded identifier, as well as other properties of the value associated with the term when it is used as key in a node object.";
570
+ var description$j = "An expanded term definition is used to describe the mapping between a term and its expanded identifier, as well as other properties of the value associated with the term when it is used as key in a node object.";
510
571
  var JsonLdExpandedTermDefinitionSchema = {
511
572
  anyOf: anyOf$6,
512
- description: description$f
573
+ description: description$j
513
574
  };
514
575
 
515
576
  var type$c = "object";
@@ -528,47 +589,37 @@ var properties$5 = {
528
589
  ]
529
590
  },
530
591
  "@index": {
531
- type: "string"
592
+ $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
532
593
  },
533
594
  "@id": {
534
- anyOf: [
535
- {
536
- type: "string"
537
- },
538
- {
539
- type: "array",
540
- items: {
541
- type: "string"
542
- }
543
- }
544
- ]
595
+ $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
545
596
  },
546
597
  "@context": {
547
- $ref: "https://schema.twindev.org/json-ld/JsonLdContextDefinitionRoot"
598
+ $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
548
599
  }
549
600
  };
550
601
  var required$3 = [
551
602
  "@graph"
552
603
  ];
553
604
  var additionalProperties$a = false;
554
- var description$e = "A graph object represents a named graph, which MAY include an explicit graph name.";
605
+ var description$i = "A graph object represents a named graph, which MAY include an explicit graph name.";
555
606
  var JsonLdGraphObjectSchema = {
556
607
  type: type$c,
557
608
  properties: properties$5,
558
609
  required: required$3,
559
610
  additionalProperties: additionalProperties$a,
560
- description: description$e
611
+ description: description$i
561
612
  };
562
613
 
563
614
  var type$b = "object";
564
615
  var additionalProperties$9 = {
565
616
  $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
566
617
  };
567
- var description$d = "An id map is used to associate an IRI with a value that allows easy programmatic access.";
618
+ var description$h = "An id map is used to associate an IRI with a value that allows easy programmatic access.";
568
619
  var JsonLdIdMapSchema = {
569
620
  type: type$b,
570
621
  additionalProperties: additionalProperties$9,
571
- description: description$d
622
+ description: description$h
572
623
  };
573
624
 
574
625
  var anyOf$5 = [
@@ -582,10 +633,10 @@ var anyOf$5 = [
582
633
  }
583
634
  }
584
635
  ];
585
- var description$c = "An included block is used to provide a set of node objects.";
636
+ var description$g = "An included block is used to provide a set of node objects.";
586
637
  var JsonLdIncludedBlockSchema = {
587
638
  anyOf: anyOf$5,
588
- description: description$c
639
+ description: description$g
589
640
  };
590
641
 
591
642
  var type$a = "object";
@@ -602,11 +653,11 @@ var additionalProperties$8 = {
602
653
  }
603
654
  ]
604
655
  };
605
- var description$b = "An index map allows keys that have no semantic meaning, but should be preserved regardless, to be used in JSON-LD documents.";
656
+ var description$f = "An index map allows keys that have no semantic meaning, but should be preserved regardless, to be used in JSON-LD documents.";
606
657
  var JsonLdIndexMapSchema = {
607
658
  type: type$a,
608
659
  additionalProperties: additionalProperties$8,
609
- description: description$b
660
+ description: description$f
610
661
  };
611
662
 
612
663
  var anyOf$4 = [
@@ -635,19 +686,21 @@ var anyOf$4 = [
635
686
  $ref: "https://schema.twindev.org/json-ld/JsonLdSetObject"
636
687
  }
637
688
  ];
638
- var description$a = "The items that can be stored in an index map.";
689
+ var description$e = "The items that can be stored in an index map.";
639
690
  var JsonLdIndexMapItemSchema = {
640
691
  anyOf: anyOf$4,
641
- description: description$a
692
+ description: description$e
642
693
  };
643
694
 
644
695
  var type$9 = "array";
645
696
  var items = {
646
697
  $ref: "https://schema.twindev.org/json-ld/JsonLdJsonValue"
647
698
  };
699
+ var description$d = "JSON Type for array.";
648
700
  var JsonLdJsonArraySchema = {
649
701
  type: type$9,
650
- items: items
702
+ items: items,
703
+ description: description$d
651
704
  };
652
705
 
653
706
  var type$8 = "object";
@@ -662,9 +715,11 @@ var additionalProperties$7 = {
662
715
  }
663
716
  ]
664
717
  };
718
+ var description$c = "JSON Type for object.";
665
719
  var JsonLdJsonObjectSchema = {
666
720
  type: type$8,
667
- additionalProperties: additionalProperties$7
721
+ additionalProperties: additionalProperties$7,
722
+ description: description$c
668
723
  };
669
724
 
670
725
  var type$7 = [
@@ -673,8 +728,10 @@ var type$7 = [
673
728
  "boolean",
674
729
  "null"
675
730
  ];
731
+ var description$b = "JSON Primitive.";
676
732
  var JsonLdJsonPrimitiveSchema = {
677
- type: type$7
733
+ type: type$7,
734
+ description: description$b
678
735
  };
679
736
 
680
737
  var anyOf$3 = [
@@ -688,8 +745,10 @@ var anyOf$3 = [
688
745
  $ref: "https://schema.twindev.org/json-ld/JsonLdJsonObject"
689
746
  }
690
747
  ];
748
+ var description$a = "JSON Value.";
691
749
  var JsonLdJsonValueSchema = {
692
- anyOf: anyOf$3
750
+ anyOf: anyOf$3,
751
+ description: description$a
693
752
  };
694
753
 
695
754
  var type$6 = "object";
@@ -934,20 +993,10 @@ var JsonLdLanguageMapSchema = {
934
993
  var type$4 = "object";
935
994
  var properties$3 = {
936
995
  "@list": {
937
- anyOf: [
938
- {
939
- $ref: "https://schema.twindev.org/json-ld/JsonLdListOrSetItem"
940
- },
941
- {
942
- type: "array",
943
- items: {
944
- $ref: "https://schema.twindev.org/json-ld/JsonLdListOrSetItem"
945
- }
946
- }
947
- ]
996
+ $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
948
997
  },
949
998
  "@index": {
950
- type: "string"
999
+ $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
951
1000
  }
952
1001
  };
953
1002
  var required$1 = [
@@ -1017,23 +1066,13 @@ var additionalProperties$3 = {
1017
1066
  };
1018
1067
  var properties$2 = {
1019
1068
  "@context": {
1020
- $ref: "https://schema.twindev.org/json-ld/JsonLdContextDefinitionRoot"
1069
+ $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
1021
1070
  },
1022
1071
  "@id": {
1023
- anyOf: [
1024
- {
1025
- type: "string"
1026
- },
1027
- {
1028
- type: "array",
1029
- items: {
1030
- type: "string"
1031
- }
1032
- }
1033
- ]
1072
+ $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
1034
1073
  },
1035
1074
  "@included": {
1036
- $ref: "https://schema.twindev.org/json-ld/JsonLdIncludedBlock"
1075
+ $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
1037
1076
  },
1038
1077
  "@graph": {
1039
1078
  anyOf: [
@@ -1064,12 +1103,12 @@ var properties$2 = {
1064
1103
  "@type": {
1065
1104
  anyOf: [
1066
1105
  {
1067
- type: "string"
1106
+ $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
1068
1107
  },
1069
1108
  {
1070
1109
  type: "array",
1071
1110
  items: {
1072
- type: "string"
1111
+ $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
1073
1112
  }
1074
1113
  }
1075
1114
  ]
@@ -1077,11 +1116,11 @@ var properties$2 = {
1077
1116
  "@reverse": {
1078
1117
  type: "object",
1079
1118
  additionalProperties: {
1080
- type: "string"
1119
+ $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
1081
1120
  }
1082
1121
  },
1083
1122
  "@index": {
1084
- type: "string"
1123
+ $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
1085
1124
  }
1086
1125
  };
1087
1126
  var description$5 = "A node object represents zero or more properties of a node in the graph serialized by the JSON-LD document.";
@@ -1130,23 +1169,13 @@ var JsonLdNodePrimitiveSchema = {
1130
1169
  var type$2 = "object";
1131
1170
  var properties$1 = {
1132
1171
  "@context": {
1133
- $ref: "https://schema.twindev.org/json-ld/JsonLdContextDefinitionRoot"
1172
+ $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
1134
1173
  },
1135
1174
  "@id": {
1136
- anyOf: [
1137
- {
1138
- type: "string"
1139
- },
1140
- {
1141
- type: "array",
1142
- items: {
1143
- type: "string"
1144
- }
1145
- }
1146
- ]
1175
+ $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
1147
1176
  },
1148
1177
  "@included": {
1149
- $ref: "https://schema.twindev.org/json-ld/JsonLdIncludedBlock"
1178
+ $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
1150
1179
  },
1151
1180
  "@graph": {
1152
1181
  anyOf: [
@@ -1177,12 +1206,12 @@ var properties$1 = {
1177
1206
  "@type": {
1178
1207
  anyOf: [
1179
1208
  {
1180
- type: "string"
1209
+ $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
1181
1210
  },
1182
1211
  {
1183
1212
  type: "array",
1184
1213
  items: {
1185
- type: "string"
1214
+ $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
1186
1215
  }
1187
1216
  }
1188
1217
  ]
@@ -1190,11 +1219,11 @@ var properties$1 = {
1190
1219
  "@reverse": {
1191
1220
  type: "object",
1192
1221
  additionalProperties: {
1193
- type: "string"
1222
+ $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
1194
1223
  }
1195
1224
  },
1196
1225
  "@index": {
1197
- type: "string"
1226
+ $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
1198
1227
  }
1199
1228
  };
1200
1229
  var additionalProperties$2 = false;
@@ -1209,20 +1238,10 @@ var JsonLdObjectSchema = {
1209
1238
  var type$1 = "object";
1210
1239
  var properties = {
1211
1240
  "@set": {
1212
- anyOf: [
1213
- {
1214
- $ref: "https://schema.twindev.org/json-ld/JsonLdListOrSetItem"
1215
- },
1216
- {
1217
- type: "array",
1218
- items: {
1219
- $ref: "https://schema.twindev.org/json-ld/JsonLdListOrSetItem"
1220
- }
1221
- }
1222
- ]
1241
+ $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
1223
1242
  },
1224
1243
  "@index": {
1225
- type: "string"
1244
+ $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
1226
1245
  }
1227
1246
  };
1228
1247
  var required = [
@@ -1538,7 +1557,7 @@ class JsonLdProcessor {
1538
1557
  context = JsonLdProcessor.gatherContexts(document, context);
1539
1558
  }
1540
1559
  }
1541
- const compacted = await jsonLd.compact(document, context, {
1560
+ const compacted = await jsonLd.compact(core.ObjectHelper.removeEmptyProperties(document), context, {
1542
1561
  documentLoader: JsonLdProcessor.DOCUMENT_LOADER
1543
1562
  });
1544
1563
  return compacted;
@@ -1562,7 +1581,7 @@ class JsonLdProcessor {
1562
1581
  */
1563
1582
  static async expand(compacted) {
1564
1583
  try {
1565
- const expanded = await jsonLd.expand(compacted, {
1584
+ const expanded = await jsonLd.expand(core.ObjectHelper.removeEmptyProperties(compacted), {
1566
1585
  documentLoader: JsonLdProcessor.DOCUMENT_LOADER
1567
1586
  });
1568
1587
  return expanded;