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

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 (66) hide show
  1. package/dist/cjs/index.cjs +958 -607
  2. package/dist/esm/index.mjs +960 -610
  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 +24 -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 +5 -199
  10. package/dist/types/models/IJsonLdExpandedTermDefinition.d.ts +29 -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/IJsonLdLanguageMap.d.ts +11 -0
  21. package/dist/types/models/IJsonLdListObject.d.ts +13 -0
  22. package/dist/types/models/IJsonLdListOrSetItem.d.ts +10 -0
  23. package/dist/types/models/IJsonLdNodeObject.d.ts +19 -0
  24. package/dist/types/models/IJsonLdNodePrimitive.d.ts +13 -0
  25. package/dist/types/models/IJsonLdObject.d.ts +25 -0
  26. package/dist/types/models/IJsonLdSetObject.d.ts +13 -0
  27. package/dist/types/models/IJsonLdTypeMap.d.ts +12 -0
  28. package/dist/types/models/IJsonLdValueObject.d.ts +26 -0
  29. package/dist/types/models/jsonLdContexts.d.ts +13 -0
  30. package/dist/types/models/jsonLdTypes.d.ts +34 -26
  31. package/dist/types/utils/jsonLdHelper.d.ts +7 -2
  32. package/dist/types/utils/jsonLdProcessor.d.ts +66 -19
  33. package/docs/changelog.md +146 -1
  34. package/docs/reference/classes/JsonLdDataTypes.md +3 -3
  35. package/docs/reference/classes/JsonLdHelper.md +26 -8
  36. package/docs/reference/classes/JsonLdProcessor.md +248 -46
  37. package/docs/reference/index.md +18 -16
  38. package/docs/reference/interfaces/IJsonLdContextDefinition.md +1 -1
  39. package/docs/reference/interfaces/IJsonLdIdMap.md +1 -1
  40. package/docs/reference/interfaces/IJsonLdIndexMap.md +1 -1
  41. package/docs/reference/interfaces/IJsonLdJsonObject.md +3 -1
  42. package/docs/reference/interfaces/IJsonLdLanguageMap.md +1 -1
  43. package/docs/reference/interfaces/IJsonLdNodeObject.md +39 -3
  44. package/docs/reference/interfaces/IJsonLdObject.md +64 -0
  45. package/docs/reference/interfaces/IJsonLdTypeMap.md +1 -1
  46. package/docs/reference/type-aliases/IJsonLdContainerType.md +3 -1
  47. package/docs/reference/type-aliases/IJsonLdContainerTypeArray.md +3 -1
  48. package/docs/reference/type-aliases/IJsonLdContextDefinitionElement.md +1 -1
  49. package/docs/reference/type-aliases/IJsonLdContextDefinitionRoot.md +1 -1
  50. package/docs/reference/type-aliases/IJsonLdDocument.md +1 -1
  51. package/docs/reference/type-aliases/IJsonLdExpandedTermDefinition.md +6 -6
  52. package/docs/reference/type-aliases/IJsonLdIncludedBlock.md +1 -1
  53. package/docs/reference/type-aliases/IJsonLdIndexMapItem.md +1 -1
  54. package/docs/reference/type-aliases/IJsonLdJsonArray.md +3 -1
  55. package/docs/reference/type-aliases/IJsonLdJsonPrimitive.md +3 -1
  56. package/docs/reference/type-aliases/IJsonLdJsonValue.md +3 -1
  57. package/docs/reference/type-aliases/IJsonLdListOrSetItem.md +1 -1
  58. package/docs/reference/type-aliases/IJsonLdNodePrimitive.md +1 -1
  59. package/docs/reference/type-aliases/IJsonLdValueObject.md +3 -3
  60. package/docs/reference/type-aliases/JsonLdContexts.md +5 -0
  61. package/docs/reference/type-aliases/JsonLdTypes.md +1 -1
  62. package/docs/reference/variables/JsonLdContexts.md +13 -0
  63. package/docs/reference/variables/JsonLdTypes.md +40 -28
  64. package/locales/en.json +8 -4
  65. package/package.json +10 -11
  66. package/docs/reference/type-aliases/IJsonLdKeyword.md +0 -105
@@ -8,110 +8,137 @@ var jsonLd = require('jsonld');
8
8
  // Copyright 2024 IOTA Stiftung.
9
9
  // SPDX-License-Identifier: Apache-2.0.
10
10
  /**
11
- * The types of JSON-LD data.
11
+ * The contexts of JSON-LD data.
12
12
  */
13
13
  // eslint-disable-next-line @typescript-eslint/naming-convention
14
- const JsonLdTypes = {
14
+ const JsonLdContexts = {
15
15
  /**
16
16
  * Context Root.
17
17
  */
18
- ContextRoot: "https://schema.twindev.org/json-ld/",
18
+ ContextRoot: "https://schema.twindev.org/json-ld/"
19
+ };
20
+
21
+ // Copyright 2024 IOTA Stiftung.
22
+ // SPDX-License-Identifier: Apache-2.0.
23
+ /**
24
+ * The types of JSON-LD data.
25
+ */
26
+ // eslint-disable-next-line @typescript-eslint/naming-convention
27
+ const JsonLdTypes = {
19
28
  /**
20
29
  * Represents JSON-LD Document.
21
30
  */
22
- Document: "https://schema.twindev.org/json-ld/JsonLdDocument",
31
+ Document: "JsonLdDocument",
32
+ /**
33
+ * Represents JSON-LD Object.
34
+ */
35
+ Object: "JsonLdObject",
23
36
  /**
24
37
  * Represents JSON-LD Node Object.
25
38
  */
26
- NodeObject: "https://schema.twindev.org/json-ld/JsonLdNodeObject",
39
+ NodeObject: "JsonLdNodeObject",
27
40
  /**
28
41
  * Represents JSON-LD Node Primitive.
29
42
  */
30
- NodePrimitive: "https://schema.twindev.org/json-ld/JsonLdNodePrimitive",
43
+ NodePrimitive: "JsonLdNodePrimitive",
31
44
  /**
32
45
  * Represents JSON-LD Graph Object.
33
46
  */
34
- GraphObject: "https://schema.twindev.org/json-ld/JsonLdGraphObject",
47
+ GraphObject: "JsonLdGraphObject",
35
48
  /**
36
49
  * Represents JSON-LD Value Object.
37
50
  */
38
- ValueObject: "https://schema.twindev.org/json-ld/JsonLdValueObject",
51
+ ValueObject: "JsonLdValueObject",
39
52
  /**
40
53
  * Represents JSON-LD List Object.
41
54
  */
42
- ListObject: "https://schema.twindev.org/json-ld/JsonLdListObject",
55
+ ListObject: "JsonLdListObject",
43
56
  /**
44
57
  * Represents JSON-LD Set Object.
45
58
  */
46
- SetObject: "https://schema.twindev.org/json-ld/JsonLdSetObject",
59
+ SetObject: "JsonLdSetObject",
47
60
  /**
48
61
  * Represents JSON-LD Language Map.
49
62
  */
50
- LanguageMap: "https://schema.twindev.org/json-ld/JsonLdLanguageMap",
63
+ LanguageMap: "JsonLdLanguageMap",
51
64
  /**
52
65
  * Represents JSON-LD Index Map.
53
66
  */
54
- IndexMap: "https://schema.twindev.org/json-ld/JsonLdIndexMap",
67
+ IndexMap: "JsonLdIndexMap",
55
68
  /**
56
69
  * Represents JSON-LD Index Map Item.
57
70
  */
58
- IndexMapItem: "https://schema.twindev.org/json-ld/JsonLdIndexMapItem",
71
+ IndexMapItem: "JsonLdIndexMapItem",
59
72
  /**
60
73
  * Represents JSON-LD Id Map.
61
74
  */
62
- IdMap: "https://schema.twindev.org/json-ld/JsonLdIdMap",
75
+ IdMap: "JsonLdIdMap",
63
76
  /**
64
77
  * Represents JSON-LD Type Map.
65
78
  */
66
- TypeMap: "https://schema.twindev.org/json-ld/JsonLdTypeMap",
79
+ TypeMap: "JsonLdTypeMap",
67
80
  /**
68
81
  * Represents JSON-LD Included block.
69
82
  */
70
- IncludedBlock: "https://schema.twindev.org/json-ld/JsonLdIncludedBlock",
83
+ IncludedBlock: "JsonLdIncludedBlock",
71
84
  /**
72
85
  * Represents JSON-LD Context Definition.
73
86
  */
74
- ContextDefinition: "https://schema.twindev.org/json-ld/JsonLdContextDefinition",
87
+ ContextDefinition: "JsonLdContextDefinition",
88
+ /**
89
+ * Represents JSON-LD Context Definition Element.
90
+ */
91
+ ContextDefinitionElement: "JsonLdContextDefinitionElement",
92
+ /**
93
+ * Represents JSON-LD Context Definition Root.
94
+ */
95
+ ContextDefinitionRoot: "JsonLdContextDefinitionRoot",
75
96
  /**
76
97
  * Represents JSON-LD Expanded Term Definition.
77
98
  */
78
- ExpandedTermDefinition: "https://schema.twindev.org/json-ld/JsonLdExpandedTermDefinition",
99
+ ExpandedTermDefinition: "JsonLdExpandedTermDefinition",
79
100
  /**
80
101
  * Represents JSON-LD Keyword.
81
102
  */
82
- Keyword: "https://schema.twindev.org/json-ld/JsonLdKeyword",
103
+ Keyword: "JsonLdKeyword",
83
104
  /**
84
105
  * Represents JSON-LD List or Set Item.
85
106
  */
86
- ListOrSetItem: "https://schema.twindev.org/json-ld/JsonLdListOrSetItem",
107
+ ListOrSetItem: "JsonLdListOrSetItem",
87
108
  /**
88
109
  * Represents JSON-LD Container Type.
89
110
  */
90
- ContainerType: "https://schema.twindev.org/json-ld/JsonLdContainerType",
111
+ ContainerType: "JsonLdContainerType",
91
112
  /**
92
113
  * Represents JSON-LD Container Type Array.
93
114
  */
94
- ContainerTypeArray: "https://schema.twindev.org/json-ld/JsonLdContainerTypeArray",
115
+ ContainerTypeArray: "JsonLdContainerTypeArray",
95
116
  /**
96
117
  * Represents JSON-LD JSON Primitive.
97
118
  */
98
- JsonPrimitive: "https://schema.twindev.org/json-ld/JsonLdJsonPrimitive",
119
+ JsonPrimitive: "JsonLdJsonPrimitive",
99
120
  /**
100
121
  * Represents JSON-LD JSON Array.
101
122
  */
102
- JsonArray: "https://schema.twindev.org/json-ld/JsonLdJsonArray",
123
+ JsonArray: "JsonLdJsonArray",
103
124
  /**
104
125
  * Represents JSON-LD JSON Object.
105
126
  */
106
- JsonObject: "https://schema.twindev.org/json-ld/JsonLdJsonObject",
127
+ JsonObject: "JsonLdJsonObject",
107
128
  /**
108
129
  * Represents JSON-LD JSON Value.
109
130
  */
110
- JsonValue: "https://schema.twindev.org/json-ld/JsonLdJsonValue"
131
+ JsonValue: "JsonLdJsonValue"
111
132
  };
112
133
 
134
+ var $schema$o = "https://json-schema.org/draft/2020-12/schema";
135
+ var $id$o = "https://schema.twindev.org/json-ld/JsonLdContainerType";
136
+ var description$o = "JSON-LD container types.";
113
137
  var type$d = "string";
114
138
  var JsonLdContainerTypeSchema = {
139
+ $schema: $schema$o,
140
+ $id: $id$o,
141
+ description: description$o,
115
142
  type: type$d,
116
143
  "enum": [
117
144
  "@language",
@@ -122,11 +149,16 @@ var JsonLdContainerTypeSchema = {
122
149
  ]
123
150
  };
124
151
 
125
- var anyOf$8 = [
152
+ var $schema$n = "https://json-schema.org/draft/2020-12/schema";
153
+ var $id$n = "https://schema.twindev.org/json-ld/JsonLdContainerTypeArray";
154
+ var description$n = "JSON-LD container type array.";
155
+ var anyOf$a = [
126
156
  {
127
157
  type: "array",
128
158
  minItems: 2,
129
- items: [
159
+ items: false,
160
+ maxItems: 2,
161
+ prefixItems: [
130
162
  {
131
163
  type: "string",
132
164
  "const": "@graph"
@@ -135,13 +167,14 @@ var anyOf$8 = [
135
167
  type: "string",
136
168
  "const": "@id"
137
169
  }
138
- ],
139
- maxItems: 2
170
+ ]
140
171
  },
141
172
  {
142
173
  type: "array",
143
174
  minItems: 2,
144
- items: [
175
+ items: false,
176
+ maxItems: 2,
177
+ prefixItems: [
145
178
  {
146
179
  type: "string",
147
180
  "const": "@id"
@@ -150,13 +183,14 @@ var anyOf$8 = [
150
183
  type: "string",
151
184
  "const": "@graph"
152
185
  }
153
- ],
154
- maxItems: 2
186
+ ]
155
187
  },
156
188
  {
157
189
  type: "array",
158
190
  minItems: 3,
159
- items: [
191
+ items: false,
192
+ maxItems: 3,
193
+ prefixItems: [
160
194
  {
161
195
  type: "string",
162
196
  "const": "@set"
@@ -169,13 +203,14 @@ var anyOf$8 = [
169
203
  type: "string",
170
204
  "const": "@id"
171
205
  }
172
- ],
173
- maxItems: 3
206
+ ]
174
207
  },
175
208
  {
176
209
  type: "array",
177
210
  minItems: 3,
178
- items: [
211
+ items: false,
212
+ maxItems: 3,
213
+ prefixItems: [
179
214
  {
180
215
  type: "string",
181
216
  "const": "@set"
@@ -188,13 +223,14 @@ var anyOf$8 = [
188
223
  type: "string",
189
224
  "const": "@graph"
190
225
  }
191
- ],
192
- maxItems: 3
226
+ ]
193
227
  },
194
228
  {
195
229
  type: "array",
196
230
  minItems: 3,
197
- items: [
231
+ items: false,
232
+ maxItems: 3,
233
+ prefixItems: [
198
234
  {
199
235
  type: "string",
200
236
  "const": "@graph"
@@ -207,13 +243,14 @@ var anyOf$8 = [
207
243
  type: "string",
208
244
  "const": "@id"
209
245
  }
210
- ],
211
- maxItems: 3
246
+ ]
212
247
  },
213
248
  {
214
249
  type: "array",
215
250
  minItems: 3,
216
- items: [
251
+ items: false,
252
+ maxItems: 3,
253
+ prefixItems: [
217
254
  {
218
255
  type: "string",
219
256
  "const": "@id"
@@ -226,13 +263,14 @@ var anyOf$8 = [
226
263
  type: "string",
227
264
  "const": "@graph"
228
265
  }
229
- ],
230
- maxItems: 3
266
+ ]
231
267
  },
232
268
  {
233
269
  type: "array",
234
270
  minItems: 3,
235
- items: [
271
+ items: false,
272
+ maxItems: 3,
273
+ prefixItems: [
236
274
  {
237
275
  type: "string",
238
276
  "const": "@graph"
@@ -245,13 +283,14 @@ var anyOf$8 = [
245
283
  type: "string",
246
284
  "const": "@set"
247
285
  }
248
- ],
249
- maxItems: 3
286
+ ]
250
287
  },
251
288
  {
252
289
  type: "array",
253
290
  minItems: 3,
254
- items: [
291
+ items: false,
292
+ maxItems: 3,
293
+ prefixItems: [
255
294
  {
256
295
  type: "string",
257
296
  "const": "@id"
@@ -264,13 +303,14 @@ var anyOf$8 = [
264
303
  type: "string",
265
304
  "const": "@set"
266
305
  }
267
- ],
268
- maxItems: 3
306
+ ]
269
307
  },
270
308
  {
271
309
  type: "array",
272
310
  minItems: 2,
273
- items: [
311
+ items: false,
312
+ maxItems: 2,
313
+ prefixItems: [
274
314
  {
275
315
  type: "string",
276
316
  "const": "@set"
@@ -278,13 +318,14 @@ var anyOf$8 = [
278
318
  {
279
319
  $ref: "https://schema.twindev.org/json-ld/JsonLdContainerType"
280
320
  }
281
- ],
282
- maxItems: 2
321
+ ]
283
322
  },
284
323
  {
285
324
  type: "array",
286
325
  minItems: 2,
287
- items: [
326
+ items: false,
327
+ maxItems: 2,
328
+ prefixItems: [
288
329
  {
289
330
  $ref: "https://schema.twindev.org/json-ld/JsonLdContainerType"
290
331
  },
@@ -292,33 +333,49 @@ var anyOf$8 = [
292
333
  type: "string",
293
334
  "const": "@set"
294
335
  }
295
- ],
296
- maxItems: 2
336
+ ]
297
337
  }
298
338
  ];
299
339
  var JsonLdContainerTypeArraySchema = {
300
- anyOf: anyOf$8
340
+ $schema: $schema$n,
341
+ $id: $id$n,
342
+ description: description$n,
343
+ anyOf: anyOf$a
301
344
  };
302
345
 
346
+ var $schema$m = "https://json-schema.org/draft/2020-12/schema";
347
+ var $id$m = "https://schema.twindev.org/json-ld/JsonLdContextDefinition";
348
+ var description$m = "A context definition defines a local context in a node object.";
303
349
  var type$c = "object";
304
350
  var properties$5 = {
305
351
  "@base": {
306
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
352
+ type: [
353
+ "string",
354
+ "null"
355
+ ]
307
356
  },
308
357
  "@direction": {
309
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
358
+ type: [
359
+ "string",
360
+ "null"
361
+ ],
362
+ "enum": [
363
+ "ltr",
364
+ "rtl",
365
+ null
366
+ ]
310
367
  },
311
368
  "@import": {
312
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
369
+ type: "string"
313
370
  },
314
371
  "@language": {
315
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
372
+ type: "string"
316
373
  },
317
374
  "@propagate": {
318
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
375
+ type: "boolean"
319
376
  },
320
377
  "@protected": {
321
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
378
+ type: "boolean"
322
379
  },
323
380
  "@type": {
324
381
  type: "object",
@@ -328,7 +385,7 @@ var properties$5 = {
328
385
  "const": "@set"
329
386
  },
330
387
  "@protected": {
331
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
388
+ type: "boolean"
332
389
  }
333
390
  },
334
391
  required: [
@@ -337,10 +394,14 @@ var properties$5 = {
337
394
  additionalProperties: false
338
395
  },
339
396
  "@version": {
340
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
397
+ type: "string",
398
+ "const": "1.1"
341
399
  },
342
400
  "@vocab": {
343
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
401
+ type: [
402
+ "string",
403
+ "null"
404
+ ]
344
405
  }
345
406
  };
346
407
  var additionalProperties$a = {
@@ -356,23 +417,75 @@ var additionalProperties$a = {
356
417
  }
357
418
  ]
358
419
  };
359
- var description$g = "A context definition defines a local context in a node object.";
360
420
  var JsonLdContextDefinitionSchema = {
421
+ $schema: $schema$m,
422
+ $id: $id$m,
423
+ description: description$m,
361
424
  type: type$c,
362
425
  properties: properties$5,
363
- additionalProperties: additionalProperties$a,
364
- description: description$g
426
+ additionalProperties: additionalProperties$a
427
+ };
428
+
429
+ var $schema$l = "https://json-schema.org/draft/2020-12/schema";
430
+ var $id$l = "https://schema.twindev.org/json-ld/JsonLdContextDefinitionElement";
431
+ var description$l = "A context definition element is used to define the types of a context definition.";
432
+ var anyOf$9 = [
433
+ {
434
+ type: "null"
435
+ },
436
+ {
437
+ type: "string"
438
+ },
439
+ {
440
+ $ref: "https://schema.twindev.org/json-ld/JsonLdContextDefinition"
441
+ }
442
+ ];
443
+ var JsonLdContextDefinitionElementSchema = {
444
+ $schema: $schema$l,
445
+ $id: $id$l,
446
+ description: description$l,
447
+ anyOf: anyOf$9
448
+ };
449
+
450
+ var $schema$k = "https://json-schema.org/draft/2020-12/schema";
451
+ var $id$k = "https://schema.twindev.org/json-ld/JsonLdContextDefinitionRoot";
452
+ var description$k = "A context definition root is used to define the root of a context definition.";
453
+ var anyOf$8 = [
454
+ {
455
+ $ref: "https://schema.twindev.org/json-ld/JsonLdContextDefinitionElement"
456
+ },
457
+ {
458
+ type: "array",
459
+ items: false,
460
+ prefixItems: [
461
+ {
462
+ $ref: "https://schema.twindev.org/json-ld/JsonLdContextDefinitionElement"
463
+ }
464
+ ]
465
+ }
466
+ ];
467
+ var JsonLdContextDefinitionRootSchema = {
468
+ $schema: $schema$k,
469
+ $id: $id$k,
470
+ description: description$k,
471
+ anyOf: anyOf$8
365
472
  };
366
473
 
474
+ var $schema$j = "https://json-schema.org/draft/2020-12/schema";
475
+ var $id$j = "https://schema.twindev.org/json-ld/JsonLdDocument";
476
+ var description$j = "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.";
367
477
  var anyOf$7 = [
368
478
  {
369
479
  $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
370
480
  },
371
481
  {
372
482
  type: "array",
373
- items: {
374
- $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
375
- }
483
+ items: false,
484
+ prefixItems: [
485
+ {
486
+ $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
487
+ }
488
+ ]
376
489
  },
377
490
  {
378
491
  type: "object",
@@ -390,16 +503,19 @@ var anyOf$7 = [
390
503
  },
391
504
  {
392
505
  type: "array",
393
- items: {
394
- anyOf: [
395
- {
396
- $ref: "https://schema.twindev.org/json-ld/JsonLdValueObject"
397
- },
398
- {
399
- $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
400
- }
401
- ]
402
- }
506
+ items: false,
507
+ prefixItems: [
508
+ {
509
+ anyOf: [
510
+ {
511
+ $ref: "https://schema.twindev.org/json-ld/JsonLdValueObject"
512
+ },
513
+ {
514
+ $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
515
+ }
516
+ ]
517
+ }
518
+ ]
403
519
  }
404
520
  ]
405
521
  }
@@ -407,12 +523,16 @@ var anyOf$7 = [
407
523
  additionalProperties: false
408
524
  }
409
525
  ];
410
- var description$f = "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.";
411
526
  var JsonLdDocumentSchema = {
412
- anyOf: anyOf$7,
413
- description: description$f
527
+ $schema: $schema$j,
528
+ $id: $id$j,
529
+ description: description$j,
530
+ anyOf: anyOf$7
414
531
  };
415
532
 
533
+ var $schema$i = "https://json-schema.org/draft/2020-12/schema";
534
+ var $id$i = "https://schema.twindev.org/json-ld/JsonLdExpandedTermDefinition";
535
+ var description$i = "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.";
416
536
  var anyOf$6 = [
417
537
  {
418
538
  type: "object",
@@ -421,7 +541,16 @@ var anyOf$6 = [
421
541
  "@id": {
422
542
  anyOf: [
423
543
  {
424
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
544
+ type: "string"
545
+ },
546
+ {
547
+ type: "array",
548
+ items: false,
549
+ prefixItems: [
550
+ {
551
+ type: "string"
552
+ }
553
+ ]
425
554
  },
426
555
  {
427
556
  type: "null"
@@ -432,28 +561,67 @@ var anyOf$6 = [
432
561
  type: "string"
433
562
  },
434
563
  "@container": {
435
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
564
+ anyOf: [
565
+ {
566
+ type: "string",
567
+ "const": "@list"
568
+ },
569
+ {
570
+ type: "string",
571
+ "const": "@set"
572
+ },
573
+ {
574
+ $ref: "https://schema.twindev.org/json-ld/JsonLdContainerType"
575
+ },
576
+ {
577
+ type: "array",
578
+ items: false,
579
+ prefixItems: [
580
+ {
581
+ anyOf: [
582
+ {
583
+ type: "string",
584
+ "const": "@list"
585
+ },
586
+ {
587
+ type: "string",
588
+ "const": "@set"
589
+ },
590
+ {
591
+ $ref: "https://schema.twindev.org/json-ld/JsonLdContainerType"
592
+ }
593
+ ]
594
+ }
595
+ ]
596
+ },
597
+ {
598
+ $ref: "https://schema.twindev.org/json-ld/JsonLdContainerTypeArray"
599
+ },
600
+ {
601
+ type: "null"
602
+ }
603
+ ]
436
604
  },
437
605
  "@type": {
438
606
  type: "string"
439
607
  },
440
608
  "@language": {
441
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
609
+ type: "string"
442
610
  },
443
611
  "@index": {
444
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
612
+ type: "string"
445
613
  },
446
614
  "@context": {
447
615
  $ref: "https://schema.twindev.org/json-ld/JsonLdContextDefinition"
448
616
  },
449
617
  "@prefix": {
450
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
618
+ type: "boolean"
451
619
  },
452
620
  "@propagate": {
453
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
621
+ type: "boolean"
454
622
  },
455
623
  "@protected": {
456
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
624
+ type: "boolean"
457
625
  }
458
626
  }
459
627
  },
@@ -462,7 +630,7 @@ var anyOf$6 = [
462
630
  additionalProperties: false,
463
631
  properties: {
464
632
  "@reverse": {
465
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
633
+ type: "string"
466
634
  },
467
635
  "@container": {
468
636
  type: [
@@ -479,22 +647,22 @@ var anyOf$6 = [
479
647
  type: "string"
480
648
  },
481
649
  "@language": {
482
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
650
+ type: "string"
483
651
  },
484
652
  "@index": {
485
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
653
+ type: "string"
486
654
  },
487
655
  "@context": {
488
656
  $ref: "https://schema.twindev.org/json-ld/JsonLdContextDefinition"
489
657
  },
490
658
  "@prefix": {
491
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
659
+ type: "boolean"
492
660
  },
493
661
  "@propagate": {
494
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
662
+ type: "boolean"
495
663
  },
496
664
  "@protected": {
497
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
665
+ type: "boolean"
498
666
  }
499
667
  },
500
668
  required: [
@@ -502,12 +670,16 @@ var anyOf$6 = [
502
670
  ]
503
671
  }
504
672
  ];
505
- var description$e = "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.";
506
673
  var JsonLdExpandedTermDefinitionSchema = {
507
- anyOf: anyOf$6,
508
- description: description$e
674
+ $schema: $schema$i,
675
+ $id: $id$i,
676
+ description: description$i,
677
+ anyOf: anyOf$6
509
678
  };
510
679
 
680
+ var $schema$h = "https://json-schema.org/draft/2020-12/schema";
681
+ var $id$h = "https://schema.twindev.org/json-ld/JsonLdGraphObject";
682
+ var description$h = "A graph object represents a named graph, which MAY include an explicit graph name.";
511
683
  var type$b = "object";
512
684
  var properties$4 = {
513
685
  "@graph": {
@@ -517,9 +689,12 @@ var properties$4 = {
517
689
  },
518
690
  {
519
691
  type: "array",
520
- items: {
521
- $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
522
- }
692
+ items: false,
693
+ prefixItems: [
694
+ {
695
+ $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
696
+ }
697
+ ]
523
698
  }
524
699
  ]
525
700
  },
@@ -533,9 +708,12 @@ var properties$4 = {
533
708
  },
534
709
  {
535
710
  type: "array",
536
- items: {
537
- type: "string"
538
- }
711
+ items: false,
712
+ prefixItems: [
713
+ {
714
+ type: "string"
715
+ }
716
+ ]
539
717
  }
540
718
  ]
541
719
  },
@@ -543,47 +721,62 @@ var properties$4 = {
543
721
  $ref: "https://schema.twindev.org/json-ld/JsonLdContextDefinitionRoot"
544
722
  }
545
723
  };
546
- var required$3 = [
724
+ var required$2 = [
547
725
  "@graph"
548
726
  ];
549
727
  var additionalProperties$9 = false;
550
- var description$d = "A graph object represents a named graph, which MAY include an explicit graph name.";
551
728
  var JsonLdGraphObjectSchema = {
729
+ $schema: $schema$h,
730
+ $id: $id$h,
731
+ description: description$h,
552
732
  type: type$b,
553
733
  properties: properties$4,
554
- required: required$3,
555
- additionalProperties: additionalProperties$9,
556
- description: description$d
734
+ required: required$2,
735
+ additionalProperties: additionalProperties$9
557
736
  };
558
737
 
738
+ var $schema$g = "https://json-schema.org/draft/2020-12/schema";
739
+ var $id$g = "https://schema.twindev.org/json-ld/JsonLdIdMap";
740
+ var description$g = "An id map is used to associate an IRI with a value that allows easy programmatic access.";
559
741
  var type$a = "object";
560
742
  var additionalProperties$8 = {
561
743
  $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
562
744
  };
563
- var description$c = "An id map is used to associate an IRI with a value that allows easy programmatic access.";
564
745
  var JsonLdIdMapSchema = {
746
+ $schema: $schema$g,
747
+ $id: $id$g,
748
+ description: description$g,
565
749
  type: type$a,
566
- additionalProperties: additionalProperties$8,
567
- description: description$c
750
+ additionalProperties: additionalProperties$8
568
751
  };
569
752
 
753
+ var $schema$f = "https://json-schema.org/draft/2020-12/schema";
754
+ var $id$f = "https://schema.twindev.org/json-ld/JsonLdIncludedBlock";
755
+ var description$f = "An included block is used to provide a set of node objects.";
570
756
  var anyOf$5 = [
571
757
  {
572
758
  $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
573
759
  },
574
760
  {
575
761
  type: "array",
576
- items: {
577
- $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
578
- }
762
+ items: false,
763
+ prefixItems: [
764
+ {
765
+ $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
766
+ }
767
+ ]
579
768
  }
580
769
  ];
581
- var description$b = "An included block is used to provide a set of node objects.";
582
770
  var JsonLdIncludedBlockSchema = {
583
- anyOf: anyOf$5,
584
- description: description$b
771
+ $schema: $schema$f,
772
+ $id: $id$f,
773
+ description: description$f,
774
+ anyOf: anyOf$5
585
775
  };
586
776
 
777
+ var $schema$e = "https://json-schema.org/draft/2020-12/schema";
778
+ var $id$e = "https://schema.twindev.org/json-ld/JsonLdIndexMap";
779
+ var description$e = "An index map allows keys that have no semantic meaning, but should be preserved regardless, to be used in JSON-LD documents.";
587
780
  var type$9 = "object";
588
781
  var additionalProperties$7 = {
589
782
  anyOf: [
@@ -592,19 +785,26 @@ var additionalProperties$7 = {
592
785
  },
593
786
  {
594
787
  type: "array",
595
- items: {
596
- $ref: "https://schema.twindev.org/json-ld/JsonLdIndexMapItem"
597
- }
788
+ items: false,
789
+ prefixItems: [
790
+ {
791
+ $ref: "https://schema.twindev.org/json-ld/JsonLdIndexMapItem"
792
+ }
793
+ ]
598
794
  }
599
795
  ]
600
796
  };
601
- var description$a = "An index map allows keys that have no semantic meaning, but should be preserved regardless, to be used in JSON-LD documents.";
602
797
  var JsonLdIndexMapSchema = {
798
+ $schema: $schema$e,
799
+ $id: $id$e,
800
+ description: description$e,
603
801
  type: type$9,
604
- additionalProperties: additionalProperties$7,
605
- description: description$a
802
+ additionalProperties: additionalProperties$7
606
803
  };
607
804
 
805
+ var $schema$d = "https://json-schema.org/draft/2020-12/schema";
806
+ var $id$d = "https://schema.twindev.org/json-ld/JsonLdIndexMapItem";
807
+ var description$d = "The items that can be stored in an index map.";
608
808
  var anyOf$4 = [
609
809
  {
610
810
  type: "null"
@@ -631,21 +831,35 @@ var anyOf$4 = [
631
831
  $ref: "https://schema.twindev.org/json-ld/JsonLdSetObject"
632
832
  }
633
833
  ];
634
- var description$9 = "The items that can be stored in an index map.";
635
834
  var JsonLdIndexMapItemSchema = {
636
- anyOf: anyOf$4,
637
- description: description$9
835
+ $schema: $schema$d,
836
+ $id: $id$d,
837
+ description: description$d,
838
+ anyOf: anyOf$4
638
839
  };
639
840
 
841
+ var $schema$c = "https://json-schema.org/draft/2020-12/schema";
842
+ var $id$c = "https://schema.twindev.org/json-ld/JsonLdJsonArray";
843
+ var description$c = "JSON Type for array.";
640
844
  var type$8 = "array";
641
- var items = {
642
- $ref: "https://schema.twindev.org/json-ld/JsonLdJsonValue"
643
- };
845
+ var items = false;
846
+ var prefixItems = [
847
+ {
848
+ $ref: "https://schema.twindev.org/json-ld/JsonLdJsonValue"
849
+ }
850
+ ];
644
851
  var JsonLdJsonArraySchema = {
852
+ $schema: $schema$c,
853
+ $id: $id$c,
854
+ description: description$c,
645
855
  type: type$8,
646
- items: items
856
+ items: items,
857
+ prefixItems: prefixItems
647
858
  };
648
859
 
860
+ var $schema$b = "https://json-schema.org/draft/2020-12/schema";
861
+ var $id$b = "https://schema.twindev.org/json-ld/JsonLdJsonObject";
862
+ var description$b = "JSON Type for object.";
649
863
  var type$7 = "object";
650
864
  var additionalProperties$6 = {
651
865
  anyOf: [
@@ -659,10 +873,16 @@ var additionalProperties$6 = {
659
873
  ]
660
874
  };
661
875
  var JsonLdJsonObjectSchema = {
876
+ $schema: $schema$b,
877
+ $id: $id$b,
878
+ description: description$b,
662
879
  type: type$7,
663
880
  additionalProperties: additionalProperties$6
664
881
  };
665
882
 
883
+ var $schema$a = "https://json-schema.org/draft/2020-12/schema";
884
+ var $id$a = "https://schema.twindev.org/json-ld/JsonLdJsonPrimitive";
885
+ var description$a = "JSON Primitive.";
666
886
  var type$6 = [
667
887
  "string",
668
888
  "number",
@@ -670,9 +890,15 @@ var type$6 = [
670
890
  "null"
671
891
  ];
672
892
  var JsonLdJsonPrimitiveSchema = {
893
+ $schema: $schema$a,
894
+ $id: $id$a,
895
+ description: description$a,
673
896
  type: type$6
674
897
  };
675
898
 
899
+ var $schema$9 = "https://json-schema.org/draft/2020-12/schema";
900
+ var $id$9 = "https://schema.twindev.org/json-ld/JsonLdJsonValue";
901
+ var description$9 = "JSON Value.";
676
902
  var anyOf$3 = [
677
903
  {
678
904
  $ref: "https://schema.twindev.org/json-ld/JsonLdJsonPrimitive"
@@ -685,281 +911,235 @@ var anyOf$3 = [
685
911
  }
686
912
  ];
687
913
  var JsonLdJsonValueSchema = {
914
+ $schema: $schema$9,
915
+ $id: $id$9,
916
+ description: description$9,
688
917
  anyOf: anyOf$3
689
918
  };
690
919
 
920
+ var $schema$8 = "https://json-schema.org/draft/2020-12/schema";
921
+ var $id$8 = "https://schema.twindev.org/json-ld/JsonLdLanguageMap";
922
+ var description$8 = "A language map is used to associate a language with a value in a way that allows easy programmatic access.";
691
923
  var type$5 = "object";
692
- var properties$3 = {
693
- "@base": {
694
- type: [
695
- "string",
696
- "null"
697
- ]
698
- },
699
- "@container": {
700
- anyOf: [
701
- {
702
- type: "string",
703
- "const": "@list"
704
- },
705
- {
706
- type: "string",
707
- "const": "@set"
708
- },
709
- {
710
- $ref: "https://schema.twindev.org/json-ld/JsonLdContainerType"
711
- },
712
- {
713
- type: "array",
714
- items: {
715
- anyOf: [
716
- {
717
- type: "string",
718
- "const": "@list"
719
- },
720
- {
721
- type: "string",
722
- "const": "@set"
723
- },
724
- {
725
- $ref: "https://schema.twindev.org/json-ld/JsonLdContainerType"
726
- }
727
- ]
728
- }
729
- },
730
- {
731
- $ref: "https://schema.twindev.org/json-ld/JsonLdContainerTypeArray"
732
- },
733
- {
734
- type: "null"
735
- }
736
- ]
737
- },
738
- "@context": {
739
- $ref: "https://schema.twindev.org/json-ld/JsonLdContextDefinitionRoot"
740
- },
741
- "@direction": {
742
- type: [
743
- "string",
744
- "null"
745
- ],
746
- "enum": [
747
- "ltr",
748
- "rtl",
749
- null
750
- ]
751
- },
752
- "@graph": {
753
- anyOf: [
754
- {
755
- $ref: "https://schema.twindev.org/json-ld/JsonLdValueObject"
756
- },
757
- {
758
- $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
759
- },
760
- {
761
- type: "array",
762
- items: {
763
- anyOf: [
764
- {
765
- $ref: "https://schema.twindev.org/json-ld/JsonLdValueObject"
766
- },
767
- {
768
- $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
769
- }
770
- ]
924
+ var additionalProperties$5 = {
925
+ anyOf: [
926
+ {
927
+ type: "null"
928
+ },
929
+ {
930
+ type: "string"
931
+ },
932
+ {
933
+ type: "array",
934
+ items: false,
935
+ prefixItems: [
936
+ {
937
+ type: "string"
771
938
  }
772
- }
773
- ]
774
- },
775
- "@id": {
939
+ ]
940
+ }
941
+ ]
942
+ };
943
+ var JsonLdLanguageMapSchema = {
944
+ $schema: $schema$8,
945
+ $id: $id$8,
946
+ description: description$8,
947
+ type: type$5,
948
+ additionalProperties: additionalProperties$5
949
+ };
950
+
951
+ var $schema$7 = "https://json-schema.org/draft/2020-12/schema";
952
+ var $id$7 = "https://schema.twindev.org/json-ld/JsonLdListObject";
953
+ var description$7 = "A list represents an ordered set of values.";
954
+ var type$4 = "object";
955
+ var properties$3 = {
956
+ "@list": {
776
957
  anyOf: [
777
958
  {
778
- type: "string"
959
+ $ref: "https://schema.twindev.org/json-ld/JsonLdListOrSetItem"
779
960
  },
780
961
  {
781
962
  type: "array",
782
- items: {
783
- type: "string"
784
- }
963
+ items: false,
964
+ prefixItems: [
965
+ {
966
+ $ref: "https://schema.twindev.org/json-ld/JsonLdListOrSetItem"
967
+ }
968
+ ]
785
969
  }
786
970
  ]
787
971
  },
788
- "@import": {
789
- type: "string"
790
- },
791
- "@included": {
792
- $ref: "https://schema.twindev.org/json-ld/JsonLdIncludedBlock"
793
- },
794
972
  "@index": {
795
973
  type: "string"
974
+ }
975
+ };
976
+ var required$1 = [
977
+ "@list"
978
+ ];
979
+ var additionalProperties$4 = false;
980
+ var JsonLdListObjectSchema = {
981
+ $schema: $schema$7,
982
+ $id: $id$7,
983
+ description: description$7,
984
+ type: type$4,
985
+ properties: properties$3,
986
+ required: required$1,
987
+ additionalProperties: additionalProperties$4
988
+ };
989
+
990
+ var $schema$6 = "https://json-schema.org/draft/2020-12/schema";
991
+ var $id$6 = "https://schema.twindev.org/json-ld/JsonLdListOrSetItem";
992
+ var description$6 = "A list or set item can be a null, boolean, number, string, node object, or value object.";
993
+ var anyOf$2 = [
994
+ {
995
+ type: "null"
796
996
  },
797
- "@json": {
798
- type: "string",
799
- "const": "@json"
997
+ {
998
+ type: "boolean"
800
999
  },
801
- "@language": {
1000
+ {
1001
+ type: "number"
1002
+ },
1003
+ {
802
1004
  type: "string"
803
1005
  },
804
- "@list": {
805
- anyOf: [
806
- {
807
- $ref: "https://schema.twindev.org/json-ld/JsonLdListOrSetItem"
808
- },
809
- {
810
- type: "array",
811
- items: {
812
- $ref: "https://schema.twindev.org/json-ld/JsonLdListOrSetItem"
813
- }
814
- }
815
- ]
816
- },
817
- "@nest": {
818
- type: "object"
819
- },
820
- "@none": {
821
- type: "string",
822
- "const": "@none"
823
- },
824
- "@prefix": {
825
- type: "boolean"
826
- },
827
- "@propagate": {
828
- type: "boolean"
829
- },
830
- "@protected": {
831
- type: "boolean"
832
- },
833
- "@reverse": {
834
- type: "string"
835
- },
836
- "@set": {
837
- anyOf: [
838
- {
839
- $ref: "https://schema.twindev.org/json-ld/JsonLdListOrSetItem"
840
- },
841
- {
842
- type: "array",
843
- items: {
844
- $ref: "https://schema.twindev.org/json-ld/JsonLdListOrSetItem"
845
- }
846
- }
847
- ]
848
- },
849
- "@type": {
850
- type: "string"
851
- },
852
- "@value": {
853
- type: [
854
- "null",
855
- "boolean",
856
- "number",
857
- "string"
858
- ]
859
- },
860
- "@version": {
861
- type: "string",
862
- "const": "1.1"
1006
+ {
1007
+ $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
863
1008
  },
864
- "@vocab": {
865
- type: [
866
- "string",
867
- "null"
868
- ]
1009
+ {
1010
+ $ref: "https://schema.twindev.org/json-ld/JsonLdValueObject"
869
1011
  }
870
- };
871
- var required$2 = [
872
- "@base",
873
- "@container",
874
- "@context",
875
- "@direction",
876
- "@graph",
877
- "@id",
878
- "@import",
879
- "@included",
880
- "@index",
881
- "@json",
882
- "@language",
883
- "@list",
884
- "@nest",
885
- "@none",
886
- "@prefix",
887
- "@propagate",
888
- "@protected",
889
- "@reverse",
890
- "@set",
891
- "@type",
892
- "@value",
893
- "@version",
894
- "@vocab"
895
1012
  ];
896
- var additionalProperties$5 = false;
897
- var description$8 = "A list of keywords and their types. Only used for internal reference; not an actual interface. Not for export.";
898
- var JsonLdKeywordSchema = {
899
- type: type$5,
900
- properties: properties$3,
901
- required: required$2,
902
- additionalProperties: additionalProperties$5,
903
- description: description$8
1013
+ var JsonLdListOrSetItemSchema = {
1014
+ $schema: $schema$6,
1015
+ $id: $id$6,
1016
+ description: description$6,
1017
+ anyOf: anyOf$2
904
1018
  };
905
1019
 
906
- var type$4 = "object";
907
- var additionalProperties$4 = {
1020
+ var $schema$5 = "https://json-schema.org/draft/2020-12/schema";
1021
+ var $id$5 = "https://schema.twindev.org/json-ld/JsonLdNodeObject";
1022
+ var description$5 = "A node object represents zero or more properties of a node in the graph serialized by the JSON-LD document.";
1023
+ var type$3 = "object";
1024
+ var additionalProperties$3 = {
908
1025
  anyOf: [
909
1026
  {
910
- type: "null"
1027
+ $ref: "https://schema.twindev.org/json-ld/JsonLdNodePrimitive"
911
1028
  },
912
1029
  {
913
- type: "string"
1030
+ $ref: "https://schema.twindev.org/json-ld/JsonLdLanguageMap"
914
1031
  },
915
1032
  {
916
- type: "array",
917
- items: {
918
- type: "string"
919
- }
1033
+ $ref: "https://schema.twindev.org/json-ld/JsonLdIndexMap"
1034
+ },
1035
+ {
1036
+ $ref: "https://schema.twindev.org/json-ld/JsonLdIncludedBlock"
1037
+ },
1038
+ {
1039
+ $ref: "https://schema.twindev.org/json-ld/JsonLdIdMap"
1040
+ },
1041
+ {
1042
+ $ref: "https://schema.twindev.org/json-ld/JsonLdTypeMap"
1043
+ },
1044
+ {
1045
+ type: "array"
920
1046
  }
921
1047
  ]
922
1048
  };
923
- var description$7 = "A language map is used to associate a language with a value in a way that allows easy programmatic access.";
924
- var JsonLdLanguageMapSchema = {
925
- type: type$4,
926
- additionalProperties: additionalProperties$4,
927
- description: description$7
928
- };
929
-
930
- var type$3 = "object";
931
1049
  var properties$2 = {
932
- "@list": {
1050
+ "@context": {
1051
+ $ref: "https://schema.twindev.org/json-ld/JsonLdContextDefinitionRoot"
1052
+ },
1053
+ "@id": {
933
1054
  anyOf: [
934
1055
  {
935
- $ref: "https://schema.twindev.org/json-ld/JsonLdListOrSetItem"
1056
+ type: "string"
936
1057
  },
937
1058
  {
938
1059
  type: "array",
939
- items: {
940
- $ref: "https://schema.twindev.org/json-ld/JsonLdListOrSetItem"
941
- }
1060
+ items: false,
1061
+ prefixItems: [
1062
+ {
1063
+ type: "string"
1064
+ }
1065
+ ]
1066
+ }
1067
+ ]
1068
+ },
1069
+ "@included": {
1070
+ $ref: "https://schema.twindev.org/json-ld/JsonLdIncludedBlock"
1071
+ },
1072
+ "@graph": {
1073
+ anyOf: [
1074
+ {
1075
+ $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
1076
+ },
1077
+ {
1078
+ type: "array",
1079
+ items: false,
1080
+ prefixItems: [
1081
+ {
1082
+ $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
1083
+ }
1084
+ ]
1085
+ }
1086
+ ]
1087
+ },
1088
+ "@nest": {
1089
+ anyOf: [
1090
+ {
1091
+ $ref: "https://schema.twindev.org/json-ld/JsonLdJsonObject"
1092
+ },
1093
+ {
1094
+ type: "array",
1095
+ items: false,
1096
+ prefixItems: [
1097
+ {
1098
+ $ref: "https://schema.twindev.org/json-ld/JsonLdJsonObject"
1099
+ }
1100
+ ]
942
1101
  }
943
1102
  ]
944
1103
  },
1104
+ "@type": {
1105
+ anyOf: [
1106
+ {
1107
+ type: "string"
1108
+ },
1109
+ {
1110
+ type: "array",
1111
+ items: false,
1112
+ prefixItems: [
1113
+ {
1114
+ type: "string"
1115
+ }
1116
+ ]
1117
+ }
1118
+ ]
1119
+ },
1120
+ "@reverse": {
1121
+ type: "object",
1122
+ additionalProperties: {
1123
+ type: "string"
1124
+ }
1125
+ },
945
1126
  "@index": {
946
1127
  type: "string"
947
1128
  }
948
1129
  };
949
- var required$1 = [
950
- "@list"
951
- ];
952
- var additionalProperties$3 = false;
953
- var description$6 = "A list represents an ordered set of values.";
954
- var JsonLdListObjectSchema = {
1130
+ var JsonLdNodeObjectSchema = {
1131
+ $schema: $schema$5,
1132
+ $id: $id$5,
1133
+ description: description$5,
955
1134
  type: type$3,
956
- properties: properties$2,
957
- required: required$1,
958
1135
  additionalProperties: additionalProperties$3,
959
- description: description$6
1136
+ properties: properties$2
960
1137
  };
961
1138
 
962
- var anyOf$2 = [
1139
+ var $schema$4 = "https://json-schema.org/draft/2020-12/schema";
1140
+ var $id$4 = "https://schema.twindev.org/json-ld/JsonLdNodePrimitive";
1141
+ var description$4 = "A node primitive is a JSON-LD value which is not one of the defined NodeObject properties.";
1142
+ var anyOf$1 = [
963
1143
  {
964
1144
  type: "null"
965
1145
  },
@@ -975,16 +1155,29 @@ var anyOf$2 = [
975
1155
  {
976
1156
  $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
977
1157
  },
1158
+ {
1159
+ $ref: "https://schema.twindev.org/json-ld/JsonLdGraphObject"
1160
+ },
978
1161
  {
979
1162
  $ref: "https://schema.twindev.org/json-ld/JsonLdValueObject"
1163
+ },
1164
+ {
1165
+ $ref: "https://schema.twindev.org/json-ld/JsonLdListObject"
1166
+ },
1167
+ {
1168
+ $ref: "https://schema.twindev.org/json-ld/JsonLdSetObject"
980
1169
  }
981
1170
  ];
982
- var description$5 = "A list or set item can be a null, boolean, number, string, node object, or value object.";
983
- var JsonLdListOrSetItemSchema = {
984
- anyOf: anyOf$2,
985
- description: description$5
1171
+ var JsonLdNodePrimitiveSchema = {
1172
+ $schema: $schema$4,
1173
+ $id: $id$4,
1174
+ description: description$4,
1175
+ anyOf: anyOf$1
986
1176
  };
987
1177
 
1178
+ var $schema$3 = "https://json-schema.org/draft/2020-12/schema";
1179
+ var $id$3 = "https://schema.twindev.org/json-ld/JsonLdObject";
1180
+ var description$3 = "An object represents the pre-defined properties of the node object in the graph serialized by the JSON-LD document.";
988
1181
  var type$2 = "object";
989
1182
  var properties$1 = {
990
1183
  "@context": {
@@ -997,9 +1190,12 @@ var properties$1 = {
997
1190
  },
998
1191
  {
999
1192
  type: "array",
1000
- items: {
1001
- type: "string"
1002
- }
1193
+ items: false,
1194
+ prefixItems: [
1195
+ {
1196
+ type: "string"
1197
+ }
1198
+ ]
1003
1199
  }
1004
1200
  ]
1005
1201
  },
@@ -1013,9 +1209,12 @@ var properties$1 = {
1013
1209
  },
1014
1210
  {
1015
1211
  type: "array",
1016
- items: {
1017
- $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
1018
- }
1212
+ items: false,
1213
+ prefixItems: [
1214
+ {
1215
+ $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
1216
+ }
1217
+ ]
1019
1218
  }
1020
1219
  ]
1021
1220
  },
@@ -1026,9 +1225,12 @@ var properties$1 = {
1026
1225
  },
1027
1226
  {
1028
1227
  type: "array",
1029
- items: {
1030
- $ref: "https://schema.twindev.org/json-ld/JsonLdJsonObject"
1031
- }
1228
+ items: false,
1229
+ prefixItems: [
1230
+ {
1231
+ $ref: "https://schema.twindev.org/json-ld/JsonLdJsonObject"
1232
+ }
1233
+ ]
1032
1234
  }
1033
1235
  ]
1034
1236
  },
@@ -1039,9 +1241,12 @@ var properties$1 = {
1039
1241
  },
1040
1242
  {
1041
1243
  type: "array",
1042
- items: {
1043
- type: "string"
1044
- }
1244
+ items: false,
1245
+ prefixItems: [
1246
+ {
1247
+ type: "string"
1248
+ }
1249
+ ]
1045
1250
  }
1046
1251
  ]
1047
1252
  },
@@ -1055,77 +1260,19 @@ var properties$1 = {
1055
1260
  type: "string"
1056
1261
  }
1057
1262
  };
1058
- var additionalProperties$2 = {
1059
- anyOf: [
1060
- {
1061
- $ref: "https://schema.twindev.org/json-ld/JsonLdNodePrimitive"
1062
- },
1063
- {
1064
- type: "array",
1065
- items: {
1066
- $ref: "https://schema.twindev.org/json-ld/JsonLdNodePrimitive"
1067
- }
1068
- },
1069
- {
1070
- $ref: "https://schema.twindev.org/json-ld/JsonLdLanguageMap"
1071
- },
1072
- {
1073
- $ref: "https://schema.twindev.org/json-ld/JsonLdIndexMap"
1074
- },
1075
- {
1076
- $ref: "https://schema.twindev.org/json-ld/JsonLdIncludedBlock"
1077
- },
1078
- {
1079
- $ref: "https://schema.twindev.org/json-ld/JsonLdIdMap"
1080
- },
1081
- {
1082
- $ref: "https://schema.twindev.org/json-ld/JsonLdTypeMap"
1083
- }
1084
- ]
1085
- };
1086
- var description$4 = "A node object represents zero or more properties of a node in the graph serialized by the JSON-LD document.";
1087
- var JsonLdNodeObjectSchema = {
1263
+ var additionalProperties$2 = false;
1264
+ var JsonLdObjectSchema = {
1265
+ $schema: $schema$3,
1266
+ $id: $id$3,
1267
+ description: description$3,
1088
1268
  type: type$2,
1089
1269
  properties: properties$1,
1090
- additionalProperties: additionalProperties$2,
1091
- description: description$4
1092
- };
1093
-
1094
- var anyOf$1 = [
1095
- {
1096
- type: "null"
1097
- },
1098
- {
1099
- type: "boolean"
1100
- },
1101
- {
1102
- type: "number"
1103
- },
1104
- {
1105
- type: "string"
1106
- },
1107
- {
1108
- $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
1109
- },
1110
- {
1111
- $ref: "https://schema.twindev.org/json-ld/JsonLdGraphObject"
1112
- },
1113
- {
1114
- $ref: "https://schema.twindev.org/json-ld/JsonLdValueObject"
1115
- },
1116
- {
1117
- $ref: "https://schema.twindev.org/json-ld/JsonLdListObject"
1118
- },
1119
- {
1120
- $ref: "https://schema.twindev.org/json-ld/JsonLdSetObject"
1121
- }
1122
- ];
1123
- var description$3 = "A node primitive is a JSON-LD value which is not one of the defined NodeObject properties.";
1124
- var JsonLdNodePrimitiveSchema = {
1125
- anyOf: anyOf$1,
1126
- description: description$3
1270
+ additionalProperties: additionalProperties$2
1127
1271
  };
1128
1272
 
1273
+ var $schema$2 = "https://json-schema.org/draft/2020-12/schema";
1274
+ var $id$2 = "https://schema.twindev.org/json-ld/JsonLdSetObject";
1275
+ var description$2 = "A set represents an unordered set of values.";
1129
1276
  var type$1 = "object";
1130
1277
  var properties = {
1131
1278
  "@set": {
@@ -1135,9 +1282,12 @@ var properties = {
1135
1282
  },
1136
1283
  {
1137
1284
  type: "array",
1138
- items: {
1139
- $ref: "https://schema.twindev.org/json-ld/JsonLdListOrSetItem"
1140
- }
1285
+ items: false,
1286
+ prefixItems: [
1287
+ {
1288
+ $ref: "https://schema.twindev.org/json-ld/JsonLdListOrSetItem"
1289
+ }
1290
+ ]
1141
1291
  }
1142
1292
  ]
1143
1293
  },
@@ -1149,15 +1299,19 @@ var required = [
1149
1299
  "@set"
1150
1300
  ];
1151
1301
  var additionalProperties$1 = false;
1152
- var description$2 = "A set represents an unordered set of values.";
1153
1302
  var JsonLdSetObjectSchema = {
1303
+ $schema: $schema$2,
1304
+ $id: $id$2,
1305
+ description: description$2,
1154
1306
  type: type$1,
1155
1307
  properties: properties,
1156
1308
  required: required,
1157
- additionalProperties: additionalProperties$1,
1158
- description: description$2
1309
+ additionalProperties: additionalProperties$1
1159
1310
  };
1160
1311
 
1312
+ var $schema$1 = "https://json-schema.org/draft/2020-12/schema";
1313
+ var $id$1 = "https://schema.twindev.org/json-ld/JsonLdTypeMap";
1314
+ var description$1 = "A type map is used to associate an IRI with a value that allows easy programmatic access.";
1161
1315
  var type = "object";
1162
1316
  var additionalProperties = {
1163
1317
  anyOf: [
@@ -1169,32 +1323,49 @@ var additionalProperties = {
1169
1323
  }
1170
1324
  ]
1171
1325
  };
1172
- var description$1 = "A type map is used to associate an IRI with a value that allows easy programmatic access.";
1173
1326
  var JsonLdTypeMapSchema = {
1327
+ $schema: $schema$1,
1328
+ $id: $id$1,
1329
+ description: description$1,
1174
1330
  type: type,
1175
- additionalProperties: additionalProperties,
1176
- description: description$1
1331
+ additionalProperties: additionalProperties
1177
1332
  };
1178
1333
 
1334
+ var $schema = "https://json-schema.org/draft/2020-12/schema";
1335
+ var $id = "https://schema.twindev.org/json-ld/JsonLdValueObject";
1336
+ var description = "A value object is used to explicitly associate a type or a language with a value to create a typed value or a language-tagged string and possibly associate a base direction.";
1179
1337
  var anyOf = [
1180
1338
  {
1181
1339
  type: "object",
1182
1340
  additionalProperties: false,
1183
1341
  properties: {
1184
1342
  "@value": {
1185
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
1343
+ type: [
1344
+ "null",
1345
+ "boolean",
1346
+ "number",
1347
+ "string"
1348
+ ]
1186
1349
  },
1187
1350
  "@language": {
1188
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
1351
+ type: "string"
1189
1352
  },
1190
1353
  "@direction": {
1191
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
1354
+ type: [
1355
+ "string",
1356
+ "null"
1357
+ ],
1358
+ "enum": [
1359
+ "ltr",
1360
+ "rtl",
1361
+ null
1362
+ ]
1192
1363
  },
1193
1364
  "@index": {
1194
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
1365
+ type: "string"
1195
1366
  },
1196
1367
  "@context": {
1197
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
1368
+ $ref: "https://schema.twindev.org/json-ld/JsonLdContextDefinitionRoot"
1198
1369
  }
1199
1370
  },
1200
1371
  required: [
@@ -1206,16 +1377,21 @@ var anyOf = [
1206
1377
  additionalProperties: false,
1207
1378
  properties: {
1208
1379
  "@value": {
1209
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
1380
+ type: [
1381
+ "null",
1382
+ "boolean",
1383
+ "number",
1384
+ "string"
1385
+ ]
1210
1386
  },
1211
1387
  "@type": {
1212
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
1388
+ type: "string"
1213
1389
  },
1214
1390
  "@index": {
1215
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
1391
+ type: "string"
1216
1392
  },
1217
1393
  "@context": {
1218
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
1394
+ $ref: "https://schema.twindev.org/json-ld/JsonLdContextDefinitionRoot"
1219
1395
  }
1220
1396
  },
1221
1397
  required: [
@@ -1230,7 +1406,16 @@ var anyOf = [
1230
1406
  "@value": {
1231
1407
  anyOf: [
1232
1408
  {
1233
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
1409
+ type: "null"
1410
+ },
1411
+ {
1412
+ type: "boolean"
1413
+ },
1414
+ {
1415
+ type: "number"
1416
+ },
1417
+ {
1418
+ type: "string"
1234
1419
  },
1235
1420
  {
1236
1421
  $ref: "https://schema.twindev.org/json-ld/JsonLdJsonObject"
@@ -1245,10 +1430,10 @@ var anyOf = [
1245
1430
  "const": "@json"
1246
1431
  },
1247
1432
  "@index": {
1248
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
1433
+ type: "string"
1249
1434
  },
1250
1435
  "@context": {
1251
- $ref: "https://schema.twindev.org/json-ld/JsonLdKeyword"
1436
+ $ref: "https://schema.twindev.org/json-ld/JsonLdContextDefinitionRoot"
1252
1437
  }
1253
1438
  },
1254
1439
  required: [
@@ -1257,10 +1442,11 @@ var anyOf = [
1257
1442
  ]
1258
1443
  }
1259
1444
  ];
1260
- var description = "A value object is used to explicitly associate a type or a language with a value to create a typed value or a language-tagged string and possibly associate a base direction.";
1261
1445
  var JsonLdValueObjectSchema = {
1262
- anyOf: anyOf,
1263
- description: description
1446
+ $schema: $schema,
1447
+ $id: $id,
1448
+ description: description,
1449
+ anyOf: anyOf
1264
1450
  };
1265
1451
 
1266
1452
  // Copyright 2024 IOTA Stiftung.
@@ -1273,142 +1459,139 @@ class JsonLdDataTypes {
1273
1459
  * Register all the data types.
1274
1460
  */
1275
1461
  static registerTypes() {
1276
- dataCore.DataTypeHandlerFactory.register(JsonLdTypes.Document, () => ({
1462
+ dataCore.DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.Document}`, () => ({
1463
+ context: JsonLdContexts.ContextRoot,
1277
1464
  type: JsonLdTypes.Document,
1278
1465
  jsonSchema: async () => JsonLdDocumentSchema
1279
1466
  }));
1280
- dataCore.DataTypeHandlerFactory.register(JsonLdTypes.NodeObject, () => ({
1467
+ dataCore.DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.Object}`, () => ({
1468
+ context: JsonLdContexts.ContextRoot,
1469
+ type: JsonLdTypes.Object,
1470
+ jsonSchema: async () => JsonLdObjectSchema
1471
+ }));
1472
+ dataCore.DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.NodeObject}`, () => ({
1473
+ context: JsonLdContexts.ContextRoot,
1281
1474
  type: JsonLdTypes.NodeObject,
1282
1475
  jsonSchema: async () => JsonLdNodeObjectSchema
1283
1476
  }));
1284
- dataCore.DataTypeHandlerFactory.register(JsonLdTypes.NodePrimitive, () => ({
1477
+ dataCore.DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.NodePrimitive}`, () => ({
1478
+ context: JsonLdContexts.ContextRoot,
1285
1479
  type: JsonLdTypes.NodePrimitive,
1286
1480
  jsonSchema: async () => JsonLdNodePrimitiveSchema
1287
1481
  }));
1288
- dataCore.DataTypeHandlerFactory.register(JsonLdTypes.GraphObject, () => ({
1482
+ dataCore.DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.GraphObject}`, () => ({
1483
+ context: JsonLdContexts.ContextRoot,
1289
1484
  type: JsonLdTypes.GraphObject,
1290
1485
  jsonSchema: async () => JsonLdGraphObjectSchema
1291
1486
  }));
1292
- dataCore.DataTypeHandlerFactory.register(JsonLdTypes.ValueObject, () => ({
1487
+ dataCore.DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.ValueObject}`, () => ({
1488
+ context: JsonLdContexts.ContextRoot,
1293
1489
  type: JsonLdTypes.ValueObject,
1294
1490
  jsonSchema: async () => JsonLdValueObjectSchema
1295
1491
  }));
1296
- dataCore.DataTypeHandlerFactory.register(JsonLdTypes.ListObject, () => ({
1492
+ dataCore.DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.ListObject}`, () => ({
1493
+ context: JsonLdContexts.ContextRoot,
1297
1494
  type: JsonLdTypes.ListObject,
1298
1495
  jsonSchema: async () => JsonLdListObjectSchema
1299
1496
  }));
1300
- dataCore.DataTypeHandlerFactory.register(JsonLdTypes.ListObject, () => ({
1497
+ dataCore.DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.ListObject}`, () => ({
1498
+ context: JsonLdContexts.ContextRoot,
1301
1499
  type: JsonLdTypes.ListObject,
1302
1500
  jsonSchema: async () => JsonLdListObjectSchema
1303
1501
  }));
1304
- dataCore.DataTypeHandlerFactory.register(JsonLdTypes.SetObject, () => ({
1502
+ dataCore.DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.SetObject}`, () => ({
1503
+ context: JsonLdContexts.ContextRoot,
1305
1504
  type: JsonLdTypes.SetObject,
1306
1505
  jsonSchema: async () => JsonLdSetObjectSchema
1307
1506
  }));
1308
- dataCore.DataTypeHandlerFactory.register(JsonLdTypes.LanguageMap, () => ({
1507
+ dataCore.DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.LanguageMap}`, () => ({
1508
+ context: JsonLdContexts.ContextRoot,
1309
1509
  type: JsonLdTypes.LanguageMap,
1310
1510
  jsonSchema: async () => JsonLdLanguageMapSchema
1311
1511
  }));
1312
- dataCore.DataTypeHandlerFactory.register(JsonLdTypes.IndexMap, () => ({
1512
+ dataCore.DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.IndexMap}`, () => ({
1513
+ context: JsonLdContexts.ContextRoot,
1313
1514
  type: JsonLdTypes.IndexMap,
1314
1515
  jsonSchema: async () => JsonLdIndexMapSchema
1315
1516
  }));
1316
- dataCore.DataTypeHandlerFactory.register(JsonLdTypes.IndexMapItem, () => ({
1517
+ dataCore.DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.IndexMapItem}`, () => ({
1518
+ context: JsonLdContexts.ContextRoot,
1317
1519
  type: JsonLdTypes.IndexMapItem,
1318
1520
  jsonSchema: async () => JsonLdIndexMapItemSchema
1319
1521
  }));
1320
- dataCore.DataTypeHandlerFactory.register(JsonLdTypes.IdMap, () => ({
1522
+ dataCore.DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.IdMap}`, () => ({
1523
+ context: JsonLdContexts.ContextRoot,
1321
1524
  type: JsonLdTypes.IdMap,
1322
1525
  jsonSchema: async () => JsonLdIdMapSchema
1323
1526
  }));
1324
- dataCore.DataTypeHandlerFactory.register(JsonLdTypes.TypeMap, () => ({
1527
+ dataCore.DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.TypeMap}`, () => ({
1528
+ context: JsonLdContexts.ContextRoot,
1325
1529
  type: JsonLdTypes.TypeMap,
1326
1530
  jsonSchema: async () => JsonLdTypeMapSchema
1327
1531
  }));
1328
- dataCore.DataTypeHandlerFactory.register(JsonLdTypes.IncludedBlock, () => ({
1532
+ dataCore.DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.IncludedBlock}`, () => ({
1533
+ context: JsonLdContexts.ContextRoot,
1329
1534
  type: JsonLdTypes.IncludedBlock,
1330
1535
  jsonSchema: async () => JsonLdIncludedBlockSchema
1331
1536
  }));
1332
- dataCore.DataTypeHandlerFactory.register(JsonLdTypes.ContextDefinition, () => ({
1537
+ dataCore.DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.ContextDefinition}`, () => ({
1538
+ context: JsonLdContexts.ContextRoot,
1333
1539
  type: JsonLdTypes.ContextDefinition,
1334
1540
  jsonSchema: async () => JsonLdContextDefinitionSchema
1335
1541
  }));
1336
- dataCore.DataTypeHandlerFactory.register(JsonLdTypes.ExpandedTermDefinition, () => ({
1542
+ dataCore.DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.ContextDefinitionElement}`, () => ({
1543
+ context: JsonLdContexts.ContextRoot,
1544
+ type: JsonLdTypes.ContextDefinitionElement,
1545
+ jsonSchema: async () => JsonLdContextDefinitionElementSchema
1546
+ }));
1547
+ dataCore.DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.ContextDefinitionRoot}`, () => ({
1548
+ context: JsonLdContexts.ContextRoot,
1549
+ type: JsonLdTypes.ContextDefinitionRoot,
1550
+ jsonSchema: async () => JsonLdContextDefinitionRootSchema
1551
+ }));
1552
+ dataCore.DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.ExpandedTermDefinition}`, () => ({
1553
+ context: JsonLdContexts.ContextRoot,
1337
1554
  type: JsonLdTypes.ExpandedTermDefinition,
1338
1555
  jsonSchema: async () => JsonLdExpandedTermDefinitionSchema
1339
1556
  }));
1340
- dataCore.DataTypeHandlerFactory.register(JsonLdTypes.Keyword, () => ({
1341
- type: JsonLdTypes.Keyword,
1342
- jsonSchema: async () => JsonLdKeywordSchema
1343
- }));
1344
- dataCore.DataTypeHandlerFactory.register(JsonLdTypes.ListOrSetItem, () => ({
1557
+ dataCore.DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.ListOrSetItem}`, () => ({
1558
+ context: JsonLdContexts.ContextRoot,
1345
1559
  type: JsonLdTypes.ListOrSetItem,
1346
1560
  jsonSchema: async () => JsonLdListOrSetItemSchema
1347
1561
  }));
1348
- dataCore.DataTypeHandlerFactory.register(JsonLdTypes.ContainerType, () => ({
1562
+ dataCore.DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.ContainerType}`, () => ({
1563
+ context: JsonLdContexts.ContextRoot,
1349
1564
  type: JsonLdTypes.ContainerType,
1350
1565
  jsonSchema: async () => JsonLdContainerTypeSchema
1351
1566
  }));
1352
- dataCore.DataTypeHandlerFactory.register(JsonLdTypes.ContainerTypeArray, () => ({
1567
+ dataCore.DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.ContainerTypeArray}`, () => ({
1568
+ context: JsonLdContexts.ContextRoot,
1353
1569
  type: JsonLdTypes.ContainerTypeArray,
1354
1570
  jsonSchema: async () => JsonLdContainerTypeArraySchema
1355
1571
  }));
1356
- dataCore.DataTypeHandlerFactory.register(JsonLdTypes.JsonPrimitive, () => ({
1572
+ dataCore.DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.JsonPrimitive}`, () => ({
1573
+ context: JsonLdContexts.ContextRoot,
1357
1574
  type: JsonLdTypes.JsonPrimitive,
1358
1575
  jsonSchema: async () => JsonLdJsonPrimitiveSchema
1359
1576
  }));
1360
- dataCore.DataTypeHandlerFactory.register(JsonLdTypes.JsonArray, () => ({
1577
+ dataCore.DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.JsonArray}`, () => ({
1578
+ context: JsonLdContexts.ContextRoot,
1361
1579
  type: JsonLdTypes.JsonArray,
1362
1580
  jsonSchema: async () => JsonLdJsonArraySchema
1363
1581
  }));
1364
- dataCore.DataTypeHandlerFactory.register(JsonLdTypes.JsonObject, () => ({
1582
+ dataCore.DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.JsonObject}`, () => ({
1583
+ context: JsonLdContexts.ContextRoot,
1365
1584
  type: JsonLdTypes.JsonObject,
1366
1585
  jsonSchema: async () => JsonLdJsonObjectSchema
1367
1586
  }));
1368
- dataCore.DataTypeHandlerFactory.register(JsonLdTypes.JsonValue, () => ({
1587
+ dataCore.DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.JsonValue}`, () => ({
1588
+ context: JsonLdContexts.ContextRoot,
1369
1589
  type: JsonLdTypes.JsonValue,
1370
1590
  jsonSchema: async () => JsonLdJsonValueSchema
1371
1591
  }));
1372
1592
  }
1373
1593
  }
1374
1594
 
1375
- // Copyright 2024 IOTA Stiftung.
1376
- // SPDX-License-Identifier: Apache-2.0.
1377
- /**
1378
- * Class to help with JSON LD.
1379
- */
1380
- class JsonLdHelper {
1381
- /**
1382
- * Validate a JSON-LD document.
1383
- * @param document The JSON-LD document to validate.
1384
- * @param validationFailures The list of validation failures to add to.
1385
- * @param validationMode The validation mode to use, defaults to either.
1386
- * @returns True if the document was valid.
1387
- */
1388
- static async validate(document, validationFailures, validationMode) {
1389
- if (core.Is.array(document)) {
1390
- // If the document is an array of nodes, validate each node
1391
- for (const node of document) {
1392
- await JsonLdHelper.validate(node, validationFailures, validationMode);
1393
- }
1394
- }
1395
- else if (core.Is.array(document["@graph"])) {
1396
- // If the graph is an array of nodes, validate each node
1397
- for (const node of document["@graph"]) {
1398
- await JsonLdHelper.validate(node, validationFailures, validationMode);
1399
- }
1400
- }
1401
- else if (core.Is.object(document)) {
1402
- // If the graph is a single node, then use the validate the node schema
1403
- const dataType = document["@type"];
1404
- if (core.Is.stringValue(dataType)) {
1405
- await dataCore.DataTypeHelper.validate("document", dataType, document, validationFailures, validationMode);
1406
- }
1407
- }
1408
- return validationFailures.length === 0;
1409
- }
1410
- }
1411
-
1412
1595
  // Copyright 2024 IOTA Stiftung.
1413
1596
  // SPDX-License-Identifier: Apache-2.0.
1414
1597
  /**
@@ -1421,49 +1604,112 @@ class JsonLdProcessor {
1421
1604
  */
1422
1605
  static _CLASS_NAME = "JsonLdProcessor";
1423
1606
  /**
1424
- * Redirects to use during document resolution.
1607
+ * The document loader to use.
1608
+ * @param documentLoader The document loader to use.
1425
1609
  */
1426
- static _redirects = [];
1610
+ static setDocumentLoader(documentLoader) {
1611
+ core.SharedStore.set("jsonLdDocumentLoader", documentLoader);
1612
+ }
1427
1613
  /**
1428
- * The document loader to use.
1614
+ * The document loader to use for retrieving JSON-LD documents.
1615
+ * @returns The document loader.
1616
+ */
1617
+ static getDocumentLoader() {
1618
+ let documentLoader = core.SharedStore.get("jsonLdDocumentLoader");
1619
+ if (core.Is.empty(documentLoader)) {
1620
+ documentLoader = async (url) => JsonLdProcessor.documentLoader(url);
1621
+ }
1622
+ return documentLoader;
1623
+ }
1624
+ /**
1625
+ * Set the cache time limit for documents.
1626
+ * @param cacheLimitMs The cache limit in milliseconds.
1627
+ */
1628
+ static setCacheLimit(cacheLimitMs) {
1629
+ core.SharedStore.set("jsonLdDocumentCacheLimit", cacheLimitMs);
1630
+ }
1631
+ /**
1632
+ * Get the cache limit for documents.
1633
+ * @returns The document loader.
1634
+ */
1635
+ static getCacheLimit() {
1636
+ let cacheLimitMs = core.SharedStore.get("jsonLdDocumentCacheLimit");
1637
+ if (core.Is.empty(cacheLimitMs)) {
1638
+ cacheLimitMs = 3600000;
1639
+ core.SharedStore.set("jsonLdDocumentCacheLimit", cacheLimitMs);
1640
+ }
1641
+ return cacheLimitMs;
1642
+ }
1643
+ /**
1644
+ * Set the global redirects for JSON-LD, use addRedirect for default handling.
1645
+ * @param redirects The redirects to use.
1646
+ */
1647
+ static setRedirects(redirects) {
1648
+ core.SharedStore.set("jsonLdRedirects", redirects);
1649
+ }
1650
+ /**
1651
+ * Get the global redirects for JSON-LD.
1652
+ * @returns The registered redirects.
1429
1653
  */
1430
- static DOCUMENT_LOADER = async (url) => JsonLdProcessor.documentLoader(url);
1654
+ static getRedirects() {
1655
+ let redirects = core.SharedStore.get("jsonLdRedirects");
1656
+ if (core.Is.empty(redirects)) {
1657
+ redirects = [];
1658
+ core.SharedStore.set("jsonLdRedirects", redirects);
1659
+ }
1660
+ return redirects;
1661
+ }
1431
1662
  /**
1432
1663
  * Compact a document according to a particular context.
1433
1664
  * @param document The JSON-LD document to compact.
1434
- * @param context The context to compact the document to, if not provided will try and gather from the object.
1665
+ * @param context The context to compact the document to, if not provided will use the one in the document.
1666
+ * @param options The options for compacting the document.
1667
+ * @param options.itemListOverride Whether to override the itemListElement context with a set, defaults to true.
1435
1668
  * @returns The compacted JSON-LD document.
1436
1669
  */
1437
- static async compact(document, context) {
1670
+ static async compact(document, context, options) {
1438
1671
  try {
1439
- // There is a cast here because the jsonld types are not correct.
1440
- // A context definition can be an array or an object, but the types only allow an object.
1441
- if (core.Is.empty(context)) {
1442
- context = {};
1443
- if (core.Is.array(document)) {
1444
- for (const node of document) {
1445
- context = JsonLdProcessor.gatherContexts(node, context);
1446
- }
1672
+ if (core.Is.object(document)) {
1673
+ // If the user didn't provide a context, use the one from the document
1674
+ if (core.Is.empty(context) && !core.Is.empty(document["@context"])) {
1675
+ context = document["@context"];
1447
1676
  }
1448
- else if (core.Is.array(document["@graph"])) {
1449
- for (const node of document["@graph"]) {
1450
- context = JsonLdProcessor.gatherContexts(node, context);
1677
+ const overrideListElementOption = options?.itemListOverride ?? true;
1678
+ let overrideContext;
1679
+ if (overrideListElementOption) {
1680
+ // The compactArrays flag doesn't work with the current version of jsonld.js
1681
+ // For list results we standardise on ItemList and itemListElement
1682
+ // so we modify the schema.org type for itemListElement to be a set which bypasses the issue
1683
+ // https://github.com/digitalbazaar/jsonld.js/issues/247
1684
+ overrideContext = {
1685
+ itemListElement: {
1686
+ "@id": "http://schema.org/itemListElement",
1687
+ "@container": "@set",
1688
+ "@protected": true
1689
+ }
1690
+ };
1691
+ if (core.Is.object(context) && "@context" in context) {
1692
+ // If the context is an object, we need to merge it with the override context
1693
+ context = JsonLdProcessor.combineContexts(context["@context"], overrideContext);
1694
+ }
1695
+ else {
1696
+ // If the context is a string or an array, we need to merge it with the override context
1697
+ context = JsonLdProcessor.combineContexts(context, overrideContext);
1451
1698
  }
1452
1699
  }
1453
- else if (core.Is.object(document)) {
1454
- context = JsonLdProcessor.gatherContexts(document, context);
1700
+ const compacted = await jsonLd.compact(core.ObjectHelper.removeEmptyProperties(document), context, {
1701
+ documentLoader: JsonLdProcessor.getDocumentLoader()
1702
+ });
1703
+ if (!core.Is.empty(overrideContext)) {
1704
+ // Remove the override context from the compacted document
1705
+ compacted["@context"] = JsonLdProcessor.removeContexts(compacted["@context"], [overrideContext]);
1455
1706
  }
1707
+ return compacted;
1456
1708
  }
1457
- const compacted = await jsonLd.compact(document, context, {
1458
- documentLoader: JsonLdProcessor.DOCUMENT_LOADER
1459
- });
1460
- return compacted;
1709
+ return document;
1461
1710
  }
1462
1711
  catch (err) {
1463
- if (core.Is.object(err) &&
1464
- err.name === "jsonld.InvalidUrl") {
1465
- throw new core.GeneralError(JsonLdProcessor._CLASS_NAME, "invalidUrl", { url: err.details?.url }, err);
1466
- }
1712
+ JsonLdProcessor.handleCommonErrors(err);
1467
1713
  throw new core.GeneralError(JsonLdProcessor._CLASS_NAME, "compact", undefined, err);
1468
1714
  }
1469
1715
  }
@@ -1474,45 +1720,50 @@ class JsonLdProcessor {
1474
1720
  */
1475
1721
  static async expand(compacted) {
1476
1722
  try {
1477
- const expanded = await jsonLd.expand(compacted, {
1478
- documentLoader: JsonLdProcessor.DOCUMENT_LOADER
1479
- });
1480
- return expanded;
1723
+ if (core.Is.object(compacted)) {
1724
+ const expanded = await jsonLd.expand(core.ObjectHelper.removeEmptyProperties(compacted), {
1725
+ documentLoader: JsonLdProcessor.getDocumentLoader()
1726
+ });
1727
+ return expanded;
1728
+ }
1729
+ return [];
1481
1730
  }
1482
1731
  catch (err) {
1483
- if (core.Is.object(err) &&
1484
- err.name === "jsonld.InvalidUrl") {
1485
- throw new core.GeneralError(JsonLdProcessor._CLASS_NAME, "invalidUrl", { url: err.details?.url }, err);
1486
- }
1732
+ JsonLdProcessor.handleCommonErrors(err);
1487
1733
  throw new core.GeneralError(JsonLdProcessor._CLASS_NAME, "expand", undefined, err);
1488
1734
  }
1489
1735
  }
1490
1736
  /**
1491
- * Add a redirect to use during document resolution.
1492
- * @param from The URL to redirect from.
1493
- * @param to The URL to redirect to.
1737
+ * Canonize a document.
1738
+ * @param document The document to canonize.
1739
+ * @param options The options for canonization.
1740
+ * @param options.algorithm The algorithm to use for canonization, defaults to URDNA2015.
1741
+ * @returns The canonized document.
1494
1742
  */
1495
- static addRedirect(from, to) {
1496
- if (!this._redirects.some(r => r.from === from)) {
1497
- this._redirects.push({ from, to });
1743
+ static async canonize(document, options) {
1744
+ try {
1745
+ const normalized = await jsonLd.canonize(core.ObjectHelper.removeEmptyProperties(document), {
1746
+ algorithm: options?.algorithm ?? "URDNA2015",
1747
+ format: "application/n-quads",
1748
+ documentLoader: JsonLdProcessor.getDocumentLoader()
1749
+ });
1750
+ return normalized;
1751
+ }
1752
+ catch (err) {
1753
+ JsonLdProcessor.handleCommonErrors(err);
1754
+ throw new core.GeneralError(JsonLdProcessor._CLASS_NAME, "canonize", undefined, err);
1498
1755
  }
1499
1756
  }
1500
1757
  /**
1501
- * Extract a property from the JSON-LD.
1502
- * @param nodeObject The JSON-LD node object to extract from.
1503
- * @param propertyNames The possible names for the property.
1504
- * @param deleteProperty Delete the property from the object, defaults to true.
1505
- * @returns The properties if available.
1758
+ * Add a redirect to use during document resolution.
1759
+ * @param from The URL to redirect from.
1760
+ * @param to The URL to redirect to.
1506
1761
  */
1507
- static extractProperty(nodeObject, propertyNames, deleteProperty = true) {
1508
- let retVal;
1509
- for (const prop of propertyNames) {
1510
- retVal ??= nodeObject[prop];
1511
- if (deleteProperty) {
1512
- delete nodeObject[prop];
1513
- }
1762
+ static addRedirect(from, to) {
1763
+ const redirects = JsonLdProcessor.getRedirects();
1764
+ if (!redirects.some(r => r.from === from)) {
1765
+ redirects.push({ from, to });
1514
1766
  }
1515
- return retVal;
1516
1767
  }
1517
1768
  /**
1518
1769
  * Combine contexts.
@@ -1576,18 +1827,20 @@ class JsonLdProcessor {
1576
1827
  */
1577
1828
  static gatherContexts(element, initial) {
1578
1829
  let combinedContexts = initial;
1579
- if (!core.Is.empty(element["@context"])) {
1580
- combinedContexts = JsonLdProcessor.combineContexts(initial, element["@context"]);
1581
- }
1582
- for (const prop of Object.keys(element)) {
1583
- const value = element[prop];
1584
- if (core.Is.object(value)) {
1585
- combinedContexts = this.gatherContexts(value, combinedContexts);
1830
+ if (core.Is.object(element)) {
1831
+ if (!core.Is.empty(element["@context"])) {
1832
+ combinedContexts = JsonLdProcessor.combineContexts(initial, element["@context"]);
1586
1833
  }
1587
- else if (core.Is.array(value)) {
1588
- for (const item of value) {
1589
- if (core.Is.object(item)) {
1590
- combinedContexts = this.gatherContexts(item, combinedContexts);
1834
+ for (const prop of Object.keys(element)) {
1835
+ const value = element[prop];
1836
+ if (core.Is.object(value)) {
1837
+ combinedContexts = this.gatherContexts(value, combinedContexts);
1838
+ }
1839
+ else if (core.Is.array(value)) {
1840
+ for (const item of value) {
1841
+ if (core.Is.object(item)) {
1842
+ combinedContexts = this.gatherContexts(item, combinedContexts);
1843
+ }
1591
1844
  }
1592
1845
  }
1593
1846
  }
@@ -1633,6 +1886,23 @@ class JsonLdProcessor {
1633
1886
  ? finalContext[0]
1634
1887
  : finalContext;
1635
1888
  }
1889
+ /**
1890
+ * Add a context directly to the document loader cache.
1891
+ * @param url The url the ld context is for.
1892
+ * @param ldContext The context to add.
1893
+ * @returns Nothing.
1894
+ */
1895
+ static async documentCacheAdd(url, ldContext) {
1896
+ await web.FetchHelper.setCacheEntry(url, ldContext);
1897
+ }
1898
+ /**
1899
+ * Remove a context from the document loader cache.
1900
+ * @param url The url the ld context is for.
1901
+ * @returns Nothing.
1902
+ */
1903
+ static async documentCacheRemove(url) {
1904
+ await web.FetchHelper.removeCacheEntry(url);
1905
+ }
1636
1906
  /**
1637
1907
  * Document loader which uses a caching mechanism.
1638
1908
  * @param url The document url to load.
@@ -1640,26 +1910,107 @@ class JsonLdProcessor {
1640
1910
  * @internal
1641
1911
  */
1642
1912
  static async documentLoader(url) {
1643
- for (const redirect of JsonLdProcessor._redirects) {
1913
+ const redirects = JsonLdProcessor.getRedirects();
1914
+ for (const redirect of redirects) {
1644
1915
  if (redirect.from.test(url)) {
1645
1916
  url = redirect.to;
1646
1917
  break;
1647
1918
  }
1648
1919
  }
1649
- // Cache the results for an hour
1650
- const response = await web.FetchHelper.fetchJson(JsonLdProcessor._CLASS_NAME, url, web.HttpMethod.GET, undefined, {
1651
- cacheTtlMs: 3600000,
1652
- headers: {
1653
- Accept: `${web.MimeTypes.JsonLd},${web.MimeTypes.Json}`
1920
+ try {
1921
+ const response = await web.FetchHelper.fetchJson(JsonLdProcessor._CLASS_NAME, url, web.HttpMethod.GET, undefined, {
1922
+ cacheTtlMs: JsonLdProcessor.getCacheLimit(),
1923
+ headers: {
1924
+ [web.HeaderTypes.Accept]: web.MimeTypes.JsonLd
1925
+ }
1926
+ });
1927
+ return {
1928
+ documentUrl: url,
1929
+ document: response
1930
+ };
1931
+ }
1932
+ catch (err) {
1933
+ const error = core.BaseError.fromError(err);
1934
+ if (error.message.includes("is not valid JSON")) {
1935
+ const response = await web.FetchHelper.fetchJson(JsonLdProcessor._CLASS_NAME, url, web.HttpMethod.GET, undefined, {
1936
+ cacheTtlMs: JsonLdProcessor.getCacheLimit(),
1937
+ headers: {
1938
+ [web.HeaderTypes.Accept]: web.MimeTypes.Json
1939
+ }
1940
+ });
1941
+ return {
1942
+ documentUrl: url,
1943
+ document: response
1944
+ };
1945
+ }
1946
+ throw err;
1947
+ }
1948
+ }
1949
+ /**
1950
+ * Handle common errors.
1951
+ * @param err The error to handle.
1952
+ * @internal
1953
+ */
1954
+ static handleCommonErrors(err) {
1955
+ if (core.Is.object(err) &&
1956
+ err.name === "jsonld.InvalidUrl") {
1957
+ throw new core.GeneralError(JsonLdProcessor._CLASS_NAME, "invalidUrl", { url: err.details?.url }, err);
1958
+ }
1959
+ else if (core.Is.object(err) &&
1960
+ err.name.startsWith("jsonld.")) {
1961
+ throw new core.GeneralError(JsonLdProcessor._CLASS_NAME, "jsonLdError", err.details, err);
1962
+ }
1963
+ }
1964
+ }
1965
+
1966
+ // Copyright 2024 IOTA Stiftung.
1967
+ // SPDX-License-Identifier: Apache-2.0.
1968
+ /**
1969
+ * Class to help with JSON LD.
1970
+ */
1971
+ class JsonLdHelper {
1972
+ /**
1973
+ * Validate a JSON-LD document.
1974
+ * @param document The JSON-LD document to validate.
1975
+ * @param validationFailures The list of validation failures to add to.
1976
+ * @param options Optional options for validation.
1977
+ * @param options.failOnMissingType If true, will fail validation if the data type is missing, defaults to false.
1978
+ * @param options.validationMode The validation mode to use, defaults to either.
1979
+ * @returns True if the document was valid.
1980
+ */
1981
+ static async validate(document, validationFailures, options) {
1982
+ if (core.Is.array(document)) {
1983
+ // If the document is an array of nodes, validate each node
1984
+ for (const node of document) {
1985
+ await JsonLdHelper.validate(node, validationFailures, options);
1986
+ }
1987
+ }
1988
+ else if (core.Is.array(document["@graph"])) {
1989
+ // If the graph is an array of nodes, validate each node
1990
+ for (const node of document["@graph"]) {
1991
+ await JsonLdHelper.validate(node, validationFailures, options);
1992
+ }
1993
+ }
1994
+ else if (core.Is.object(document)) {
1995
+ // Expand the document to ensure we have the full context for types
1996
+ // As the data types in the factories are always fully qualified
1997
+ const expandedDocs = await JsonLdProcessor.expand(document);
1998
+ if (core.Is.arrayValue(expandedDocs)) {
1999
+ for (const expandedDoc of expandedDocs) {
2000
+ const expandedDataTypes = core.ArrayHelper.fromObjectOrArray(expandedDoc["@type"]);
2001
+ if (core.Is.arrayValue(expandedDataTypes)) {
2002
+ for (const expandedDataType of expandedDataTypes) {
2003
+ await dataCore.DataTypeHelper.validate("document", expandedDataType, document, validationFailures, options);
2004
+ }
2005
+ }
2006
+ }
1654
2007
  }
1655
- });
1656
- return {
1657
- documentUrl: url,
1658
- document: response
1659
- };
2008
+ }
2009
+ return validationFailures.length === 0;
1660
2010
  }
1661
2011
  }
1662
2012
 
2013
+ exports.JsonLdContexts = JsonLdContexts;
1663
2014
  exports.JsonLdDataTypes = JsonLdDataTypes;
1664
2015
  exports.JsonLdHelper = JsonLdHelper;
1665
2016
  exports.JsonLdProcessor = JsonLdProcessor;