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