@twin.org/data-json-ld 0.0.2-next.4 → 0.0.3-next.2

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 (122) hide show
  1. package/dist/es/dataTypes/jsonLdDataTypes.js +171 -0
  2. package/dist/es/dataTypes/jsonLdDataTypes.js.map +1 -0
  3. package/dist/es/index.js +33 -0
  4. package/dist/es/index.js.map +1 -0
  5. package/dist/es/models/IJsonLdContainerType.js +4 -0
  6. package/dist/es/models/IJsonLdContainerType.js.map +1 -0
  7. package/dist/es/models/IJsonLdContainerTypeArray.js +2 -0
  8. package/dist/es/models/IJsonLdContainerTypeArray.js.map +1 -0
  9. package/dist/es/models/IJsonLdContextDefinition.js +2 -0
  10. package/dist/es/models/IJsonLdContextDefinition.js.map +1 -0
  11. package/dist/es/models/IJsonLdContextDefinitionElement.js +2 -0
  12. package/dist/es/models/IJsonLdContextDefinitionElement.js.map +1 -0
  13. package/dist/es/models/IJsonLdContextDefinitionRoot.js +2 -0
  14. package/dist/es/models/IJsonLdContextDefinitionRoot.js.map +1 -0
  15. package/dist/es/models/IJsonLdDocument.js +2 -0
  16. package/dist/es/models/IJsonLdDocument.js.map +1 -0
  17. package/dist/es/models/IJsonLdExpandedTermDefinition.js +2 -0
  18. package/dist/es/models/IJsonLdExpandedTermDefinition.js.map +1 -0
  19. package/dist/es/models/IJsonLdGraphObject.js +2 -0
  20. package/dist/es/models/IJsonLdGraphObject.js.map +1 -0
  21. package/dist/es/models/IJsonLdIdMap.js +2 -0
  22. package/dist/es/models/IJsonLdIdMap.js.map +1 -0
  23. package/dist/es/models/IJsonLdIncludedBlock.js +2 -0
  24. package/dist/es/models/IJsonLdIncludedBlock.js.map +1 -0
  25. package/dist/es/models/IJsonLdIndexMap.js +2 -0
  26. package/dist/es/models/IJsonLdIndexMap.js.map +1 -0
  27. package/dist/es/models/IJsonLdIndexMapItem.js +2 -0
  28. package/dist/es/models/IJsonLdIndexMapItem.js.map +1 -0
  29. package/dist/es/models/IJsonLdJsonArray.js +2 -0
  30. package/dist/es/models/IJsonLdJsonArray.js.map +1 -0
  31. package/dist/es/models/IJsonLdJsonObject.js +2 -0
  32. package/dist/es/models/IJsonLdJsonObject.js.map +1 -0
  33. package/dist/es/models/IJsonLdJsonPrimitive.js +4 -0
  34. package/dist/es/models/IJsonLdJsonPrimitive.js.map +1 -0
  35. package/dist/es/models/IJsonLdJsonValue.js +2 -0
  36. package/dist/es/models/IJsonLdJsonValue.js.map +1 -0
  37. package/dist/es/models/IJsonLdLanguageMap.js +4 -0
  38. package/dist/es/models/IJsonLdLanguageMap.js.map +1 -0
  39. package/dist/es/models/IJsonLdListObject.js +2 -0
  40. package/dist/es/models/IJsonLdListObject.js.map +1 -0
  41. package/dist/es/models/IJsonLdListOrSetItem.js +2 -0
  42. package/dist/es/models/IJsonLdListOrSetItem.js.map +1 -0
  43. package/dist/es/models/IJsonLdNodeObject.js +2 -0
  44. package/dist/es/models/IJsonLdNodeObject.js.map +1 -0
  45. package/dist/es/models/IJsonLdNodePrimitive.js +2 -0
  46. package/dist/es/models/IJsonLdNodePrimitive.js.map +1 -0
  47. package/dist/es/models/IJsonLdObject.js +2 -0
  48. package/dist/es/models/IJsonLdObject.js.map +1 -0
  49. package/dist/es/models/IJsonLdSetObject.js +2 -0
  50. package/dist/es/models/IJsonLdSetObject.js.map +1 -0
  51. package/dist/es/models/IJsonLdTypeMap.js +2 -0
  52. package/dist/es/models/IJsonLdTypeMap.js.map +1 -0
  53. package/dist/es/models/IJsonLdValueObject.js +2 -0
  54. package/dist/es/models/IJsonLdValueObject.js.map +1 -0
  55. package/dist/es/models/jsonLdContexts.js +13 -0
  56. package/dist/es/models/jsonLdContexts.js.map +1 -0
  57. package/dist/es/models/jsonLdTypes.js +113 -0
  58. package/dist/es/models/jsonLdTypes.js.map +1 -0
  59. package/dist/es/schemas/JsonLdContainerType.json +13 -0
  60. package/dist/es/schemas/JsonLdContainerTypeArray.json +179 -0
  61. package/dist/es/schemas/JsonLdContextDefinition.json +76 -0
  62. package/dist/es/schemas/JsonLdContextDefinitionElement.json +16 -0
  63. package/dist/es/schemas/JsonLdContextDefinitionRoot.json +16 -0
  64. package/dist/es/schemas/JsonLdDocument.json +48 -0
  65. package/dist/es/schemas/JsonLdExpandedTermDefinition.json +136 -0
  66. package/dist/es/schemas/JsonLdGraphObject.json +44 -0
  67. package/dist/es/schemas/JsonLdIdMap.json +9 -0
  68. package/dist/es/schemas/JsonLdIncludedBlock.json +16 -0
  69. package/dist/es/schemas/JsonLdIndexMap.json +19 -0
  70. package/dist/es/schemas/JsonLdIndexMapItem.json +31 -0
  71. package/dist/es/schemas/JsonLdJsonArray.json +9 -0
  72. package/dist/es/schemas/JsonLdJsonObject.json +16 -0
  73. package/dist/es/schemas/JsonLdJsonPrimitive.json +11 -0
  74. package/dist/es/schemas/JsonLdJsonValue.json +16 -0
  75. package/dist/es/schemas/JsonLdLanguageMap.json +22 -0
  76. package/dist/es/schemas/JsonLdListObject.json +28 -0
  77. package/dist/es/schemas/JsonLdListOrSetItem.json +25 -0
  78. package/dist/es/schemas/JsonLdNodeObject.json +100 -0
  79. package/dist/es/schemas/JsonLdNodePrimitive.json +34 -0
  80. package/dist/es/schemas/JsonLdObject.json +76 -0
  81. package/dist/es/schemas/JsonLdSetObject.json +28 -0
  82. package/dist/es/schemas/JsonLdTypeMap.json +16 -0
  83. package/dist/es/schemas/JsonLdValueObject.json +113 -0
  84. package/dist/es/utils/jsonLdHelper.js +131 -0
  85. package/dist/es/utils/jsonLdHelper.js.map +1 -0
  86. package/dist/es/utils/jsonLdProcessor.js +375 -0
  87. package/dist/es/utils/jsonLdProcessor.js.map +1 -0
  88. package/dist/types/index.d.ts +30 -30
  89. package/dist/types/models/IJsonLdContainerTypeArray.d.ts +1 -1
  90. package/dist/types/models/IJsonLdContextDefinition.d.ts +1 -1
  91. package/dist/types/models/IJsonLdContextDefinitionElement.d.ts +1 -1
  92. package/dist/types/models/IJsonLdContextDefinitionRoot.d.ts +1 -1
  93. package/dist/types/models/IJsonLdDocument.d.ts +3 -3
  94. package/dist/types/models/IJsonLdExpandedTermDefinition.d.ts +3 -3
  95. package/dist/types/models/IJsonLdGraphObject.d.ts +2 -2
  96. package/dist/types/models/IJsonLdIdMap.d.ts +1 -1
  97. package/dist/types/models/IJsonLdIncludedBlock.d.ts +1 -1
  98. package/dist/types/models/IJsonLdIndexMap.d.ts +1 -1
  99. package/dist/types/models/IJsonLdIndexMapItem.d.ts +4 -4
  100. package/dist/types/models/IJsonLdJsonArray.d.ts +1 -1
  101. package/dist/types/models/IJsonLdJsonObject.d.ts +1 -1
  102. package/dist/types/models/IJsonLdJsonValue.d.ts +3 -3
  103. package/dist/types/models/IJsonLdListObject.d.ts +1 -1
  104. package/dist/types/models/IJsonLdListOrSetItem.d.ts +2 -2
  105. package/dist/types/models/IJsonLdNodeObject.d.ts +7 -7
  106. package/dist/types/models/IJsonLdNodePrimitive.d.ts +5 -5
  107. package/dist/types/models/IJsonLdObject.d.ts +4 -4
  108. package/dist/types/models/IJsonLdSetObject.d.ts +1 -1
  109. package/dist/types/models/IJsonLdTypeMap.d.ts +1 -1
  110. package/dist/types/models/IJsonLdValueObject.d.ts +3 -3
  111. package/dist/types/utils/jsonLdHelper.d.ts +20 -1
  112. package/dist/types/utils/jsonLdProcessor.d.ts +4 -4
  113. package/docs/changelog.md +50 -0
  114. package/docs/reference/classes/JsonLdHelper.md +72 -0
  115. package/docs/reference/classes/JsonLdProcessor.md +9 -9
  116. package/docs/reference/interfaces/IJsonLdContextDefinition.md +4 -4
  117. package/docs/reference/interfaces/IJsonLdJsonObject.md +1 -1
  118. package/docs/reference/interfaces/IJsonLdLanguageMap.md +1 -1
  119. package/docs/reference/interfaces/IJsonLdNodeObject.md +1 -1
  120. package/package.json +6 -8
  121. package/dist/cjs/index.cjs +0 -2018
  122. package/dist/esm/index.mjs +0 -2012
@@ -1,2012 +0,0 @@
1
- import { DataTypeHandlerFactory, DataTypeHelper } from '@twin.org/data-core';
2
- import { SharedStore, Is, ObjectHelper, GeneralError, BaseError, ArrayHelper } from '@twin.org/core';
3
- import { FetchHelper, HttpMethod, HeaderTypes, MimeTypes } from '@twin.org/web';
4
- import jsonLd from 'jsonld';
5
-
6
- // Copyright 2024 IOTA Stiftung.
7
- // SPDX-License-Identifier: Apache-2.0.
8
- /**
9
- * The contexts of JSON-LD data.
10
- */
11
- // eslint-disable-next-line @typescript-eslint/naming-convention
12
- const JsonLdContexts = {
13
- /**
14
- * Context Root.
15
- */
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 = {
26
- /**
27
- * Represents JSON-LD Document.
28
- */
29
- Document: "JsonLdDocument",
30
- /**
31
- * Represents JSON-LD Object.
32
- */
33
- Object: "JsonLdObject",
34
- /**
35
- * Represents JSON-LD Node Object.
36
- */
37
- NodeObject: "JsonLdNodeObject",
38
- /**
39
- * Represents JSON-LD Node Primitive.
40
- */
41
- NodePrimitive: "JsonLdNodePrimitive",
42
- /**
43
- * Represents JSON-LD Graph Object.
44
- */
45
- GraphObject: "JsonLdGraphObject",
46
- /**
47
- * Represents JSON-LD Value Object.
48
- */
49
- ValueObject: "JsonLdValueObject",
50
- /**
51
- * Represents JSON-LD List Object.
52
- */
53
- ListObject: "JsonLdListObject",
54
- /**
55
- * Represents JSON-LD Set Object.
56
- */
57
- SetObject: "JsonLdSetObject",
58
- /**
59
- * Represents JSON-LD Language Map.
60
- */
61
- LanguageMap: "JsonLdLanguageMap",
62
- /**
63
- * Represents JSON-LD Index Map.
64
- */
65
- IndexMap: "JsonLdIndexMap",
66
- /**
67
- * Represents JSON-LD Index Map Item.
68
- */
69
- IndexMapItem: "JsonLdIndexMapItem",
70
- /**
71
- * Represents JSON-LD Id Map.
72
- */
73
- IdMap: "JsonLdIdMap",
74
- /**
75
- * Represents JSON-LD Type Map.
76
- */
77
- TypeMap: "JsonLdTypeMap",
78
- /**
79
- * Represents JSON-LD Included block.
80
- */
81
- IncludedBlock: "JsonLdIncludedBlock",
82
- /**
83
- * Represents JSON-LD Context Definition.
84
- */
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",
94
- /**
95
- * Represents JSON-LD Expanded Term Definition.
96
- */
97
- ExpandedTermDefinition: "JsonLdExpandedTermDefinition",
98
- /**
99
- * Represents JSON-LD Keyword.
100
- */
101
- Keyword: "JsonLdKeyword",
102
- /**
103
- * Represents JSON-LD List or Set Item.
104
- */
105
- ListOrSetItem: "JsonLdListOrSetItem",
106
- /**
107
- * Represents JSON-LD Container Type.
108
- */
109
- ContainerType: "JsonLdContainerType",
110
- /**
111
- * Represents JSON-LD Container Type Array.
112
- */
113
- ContainerTypeArray: "JsonLdContainerTypeArray",
114
- /**
115
- * Represents JSON-LD JSON Primitive.
116
- */
117
- JsonPrimitive: "JsonLdJsonPrimitive",
118
- /**
119
- * Represents JSON-LD JSON Array.
120
- */
121
- JsonArray: "JsonLdJsonArray",
122
- /**
123
- * Represents JSON-LD JSON Object.
124
- */
125
- JsonObject: "JsonLdJsonObject",
126
- /**
127
- * Represents JSON-LD JSON Value.
128
- */
129
- JsonValue: "JsonLdJsonValue"
130
- };
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.";
135
- var type$d = "string";
136
- var JsonLdContainerTypeSchema = {
137
- $schema: $schema$o,
138
- $id: $id$o,
139
- description: description$o,
140
- type: type$d,
141
- "enum": [
142
- "@language",
143
- "@index",
144
- "@id",
145
- "@graph",
146
- "@type"
147
- ]
148
- };
149
-
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 = [
154
- {
155
- type: "array",
156
- minItems: 2,
157
- items: false,
158
- maxItems: 2,
159
- prefixItems: [
160
- {
161
- type: "string",
162
- "const": "@graph"
163
- },
164
- {
165
- type: "string",
166
- "const": "@id"
167
- }
168
- ]
169
- },
170
- {
171
- type: "array",
172
- minItems: 2,
173
- items: false,
174
- maxItems: 2,
175
- prefixItems: [
176
- {
177
- type: "string",
178
- "const": "@id"
179
- },
180
- {
181
- type: "string",
182
- "const": "@graph"
183
- }
184
- ]
185
- },
186
- {
187
- type: "array",
188
- minItems: 3,
189
- items: false,
190
- maxItems: 3,
191
- prefixItems: [
192
- {
193
- type: "string",
194
- "const": "@set"
195
- },
196
- {
197
- type: "string",
198
- "const": "@graph"
199
- },
200
- {
201
- type: "string",
202
- "const": "@id"
203
- }
204
- ]
205
- },
206
- {
207
- type: "array",
208
- minItems: 3,
209
- items: false,
210
- maxItems: 3,
211
- prefixItems: [
212
- {
213
- type: "string",
214
- "const": "@set"
215
- },
216
- {
217
- type: "string",
218
- "const": "@id"
219
- },
220
- {
221
- type: "string",
222
- "const": "@graph"
223
- }
224
- ]
225
- },
226
- {
227
- type: "array",
228
- minItems: 3,
229
- items: false,
230
- maxItems: 3,
231
- prefixItems: [
232
- {
233
- type: "string",
234
- "const": "@graph"
235
- },
236
- {
237
- type: "string",
238
- "const": "@set"
239
- },
240
- {
241
- type: "string",
242
- "const": "@id"
243
- }
244
- ]
245
- },
246
- {
247
- type: "array",
248
- minItems: 3,
249
- items: false,
250
- maxItems: 3,
251
- prefixItems: [
252
- {
253
- type: "string",
254
- "const": "@id"
255
- },
256
- {
257
- type: "string",
258
- "const": "@set"
259
- },
260
- {
261
- type: "string",
262
- "const": "@graph"
263
- }
264
- ]
265
- },
266
- {
267
- type: "array",
268
- minItems: 3,
269
- items: false,
270
- maxItems: 3,
271
- prefixItems: [
272
- {
273
- type: "string",
274
- "const": "@graph"
275
- },
276
- {
277
- type: "string",
278
- "const": "@id"
279
- },
280
- {
281
- type: "string",
282
- "const": "@set"
283
- }
284
- ]
285
- },
286
- {
287
- type: "array",
288
- minItems: 3,
289
- items: false,
290
- maxItems: 3,
291
- prefixItems: [
292
- {
293
- type: "string",
294
- "const": "@id"
295
- },
296
- {
297
- type: "string",
298
- "const": "@graph"
299
- },
300
- {
301
- type: "string",
302
- "const": "@set"
303
- }
304
- ]
305
- },
306
- {
307
- type: "array",
308
- minItems: 2,
309
- items: false,
310
- maxItems: 2,
311
- prefixItems: [
312
- {
313
- type: "string",
314
- "const": "@set"
315
- },
316
- {
317
- $ref: "https://schema.twindev.org/json-ld/JsonLdContainerType"
318
- }
319
- ]
320
- },
321
- {
322
- type: "array",
323
- minItems: 2,
324
- items: false,
325
- maxItems: 2,
326
- prefixItems: [
327
- {
328
- $ref: "https://schema.twindev.org/json-ld/JsonLdContainerType"
329
- },
330
- {
331
- type: "string",
332
- "const": "@set"
333
- }
334
- ]
335
- }
336
- ];
337
- var JsonLdContainerTypeArraySchema = {
338
- $schema: $schema$n,
339
- $id: $id$n,
340
- description: description$n,
341
- anyOf: anyOf$a
342
- };
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.";
347
- var type$c = "object";
348
- var properties$5 = {
349
- "@base": {
350
- type: [
351
- "string",
352
- "null"
353
- ]
354
- },
355
- "@direction": {
356
- type: [
357
- "string",
358
- "null"
359
- ],
360
- "enum": [
361
- "ltr",
362
- "rtl",
363
- null
364
- ]
365
- },
366
- "@import": {
367
- type: "string"
368
- },
369
- "@language": {
370
- type: "string"
371
- },
372
- "@propagate": {
373
- type: "boolean"
374
- },
375
- "@protected": {
376
- type: "boolean"
377
- },
378
- "@type": {
379
- type: "object",
380
- properties: {
381
- "@container": {
382
- type: "string",
383
- "const": "@set"
384
- },
385
- "@protected": {
386
- type: "boolean"
387
- }
388
- },
389
- required: [
390
- "@container"
391
- ],
392
- additionalProperties: false
393
- },
394
- "@version": {
395
- type: "string",
396
- "const": "1.1"
397
- },
398
- "@vocab": {
399
- type: [
400
- "string",
401
- "null"
402
- ]
403
- }
404
- };
405
- var additionalProperties$a = {
406
- anyOf: [
407
- {
408
- type: "null"
409
- },
410
- {
411
- type: "string"
412
- },
413
- {
414
- $ref: "https://schema.twindev.org/json-ld/JsonLdExpandedTermDefinition"
415
- }
416
- ]
417
- };
418
- var JsonLdContextDefinitionSchema = {
419
- $schema: $schema$m,
420
- $id: $id$m,
421
- description: description$m,
422
- type: type$c,
423
- properties: properties$5,
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
470
- };
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.";
475
- var anyOf$7 = [
476
- {
477
- $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
478
- },
479
- {
480
- type: "array",
481
- items: false,
482
- prefixItems: [
483
- {
484
- $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
485
- }
486
- ]
487
- },
488
- {
489
- type: "object",
490
- properties: {
491
- "@context": {
492
- $ref: "https://schema.twindev.org/json-ld/JsonLdContextDefinitionRoot"
493
- },
494
- "@graph": {
495
- anyOf: [
496
- {
497
- $ref: "https://schema.twindev.org/json-ld/JsonLdValueObject"
498
- },
499
- {
500
- $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
501
- },
502
- {
503
- type: "array",
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
- ]
517
- }
518
- ]
519
- }
520
- },
521
- additionalProperties: false
522
- }
523
- ];
524
- var JsonLdDocumentSchema = {
525
- $schema: $schema$j,
526
- $id: $id$j,
527
- description: description$j,
528
- anyOf: anyOf$7
529
- };
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.";
534
- var anyOf$6 = [
535
- {
536
- type: "object",
537
- additionalProperties: false,
538
- properties: {
539
- "@id": {
540
- anyOf: [
541
- {
542
- type: "string"
543
- },
544
- {
545
- type: "array",
546
- items: false,
547
- prefixItems: [
548
- {
549
- type: "string"
550
- }
551
- ]
552
- },
553
- {
554
- type: "null"
555
- }
556
- ]
557
- },
558
- "@nest": {
559
- type: "string"
560
- },
561
- "@container": {
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
- ]
602
- },
603
- "@type": {
604
- type: "string"
605
- },
606
- "@language": {
607
- type: "string"
608
- },
609
- "@index": {
610
- type: "string"
611
- },
612
- "@context": {
613
- $ref: "https://schema.twindev.org/json-ld/JsonLdContextDefinition"
614
- },
615
- "@prefix": {
616
- type: "boolean"
617
- },
618
- "@propagate": {
619
- type: "boolean"
620
- },
621
- "@protected": {
622
- type: "boolean"
623
- }
624
- }
625
- },
626
- {
627
- type: "object",
628
- additionalProperties: false,
629
- properties: {
630
- "@reverse": {
631
- type: "string"
632
- },
633
- "@container": {
634
- type: [
635
- "string",
636
- "null"
637
- ],
638
- "enum": [
639
- "@set",
640
- "@index",
641
- null
642
- ]
643
- },
644
- "@type": {
645
- type: "string"
646
- },
647
- "@language": {
648
- type: "string"
649
- },
650
- "@index": {
651
- type: "string"
652
- },
653
- "@context": {
654
- $ref: "https://schema.twindev.org/json-ld/JsonLdContextDefinition"
655
- },
656
- "@prefix": {
657
- type: "boolean"
658
- },
659
- "@propagate": {
660
- type: "boolean"
661
- },
662
- "@protected": {
663
- type: "boolean"
664
- }
665
- },
666
- required: [
667
- "@reverse"
668
- ]
669
- }
670
- ];
671
- var JsonLdExpandedTermDefinitionSchema = {
672
- $schema: $schema$i,
673
- $id: $id$i,
674
- description: description$i,
675
- anyOf: anyOf$6
676
- };
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.";
681
- var type$b = "object";
682
- var properties$4 = {
683
- "@graph": {
684
- anyOf: [
685
- {
686
- $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
687
- },
688
- {
689
- type: "array",
690
- items: false,
691
- prefixItems: [
692
- {
693
- $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
694
- }
695
- ]
696
- }
697
- ]
698
- },
699
- "@index": {
700
- type: "string"
701
- },
702
- "@id": {
703
- anyOf: [
704
- {
705
- type: "string"
706
- },
707
- {
708
- type: "array",
709
- items: false,
710
- prefixItems: [
711
- {
712
- type: "string"
713
- }
714
- ]
715
- }
716
- ]
717
- },
718
- "@context": {
719
- $ref: "https://schema.twindev.org/json-ld/JsonLdContextDefinitionRoot"
720
- }
721
- };
722
- var required$2 = [
723
- "@graph"
724
- ];
725
- var additionalProperties$9 = false;
726
- var JsonLdGraphObjectSchema = {
727
- $schema: $schema$h,
728
- $id: $id$h,
729
- description: description$h,
730
- type: type$b,
731
- properties: properties$4,
732
- required: required$2,
733
- additionalProperties: additionalProperties$9
734
- };
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.";
739
- var type$a = "object";
740
- var additionalProperties$8 = {
741
- $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
742
- };
743
- var JsonLdIdMapSchema = {
744
- $schema: $schema$g,
745
- $id: $id$g,
746
- description: description$g,
747
- type: type$a,
748
- additionalProperties: additionalProperties$8
749
- };
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.";
754
- var anyOf$5 = [
755
- {
756
- $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
757
- },
758
- {
759
- type: "array",
760
- items: false,
761
- prefixItems: [
762
- {
763
- $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
764
- }
765
- ]
766
- }
767
- ];
768
- var JsonLdIncludedBlockSchema = {
769
- $schema: $schema$f,
770
- $id: $id$f,
771
- description: description$f,
772
- anyOf: anyOf$5
773
- };
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.";
778
- var type$9 = "object";
779
- var additionalProperties$7 = {
780
- anyOf: [
781
- {
782
- $ref: "https://schema.twindev.org/json-ld/JsonLdIndexMapItem"
783
- },
784
- {
785
- type: "array",
786
- items: false,
787
- prefixItems: [
788
- {
789
- $ref: "https://schema.twindev.org/json-ld/JsonLdIndexMapItem"
790
- }
791
- ]
792
- }
793
- ]
794
- };
795
- var JsonLdIndexMapSchema = {
796
- $schema: $schema$e,
797
- $id: $id$e,
798
- description: description$e,
799
- type: type$9,
800
- additionalProperties: additionalProperties$7
801
- };
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.";
806
- var anyOf$4 = [
807
- {
808
- type: "null"
809
- },
810
- {
811
- type: "boolean"
812
- },
813
- {
814
- type: "number"
815
- },
816
- {
817
- type: "string"
818
- },
819
- {
820
- $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
821
- },
822
- {
823
- $ref: "https://schema.twindev.org/json-ld/JsonLdValueObject"
824
- },
825
- {
826
- $ref: "https://schema.twindev.org/json-ld/JsonLdListObject"
827
- },
828
- {
829
- $ref: "https://schema.twindev.org/json-ld/JsonLdSetObject"
830
- }
831
- ];
832
- var JsonLdIndexMapItemSchema = {
833
- $schema: $schema$d,
834
- $id: $id$d,
835
- description: description$d,
836
- anyOf: anyOf$4
837
- };
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.";
842
- var type$8 = "array";
843
- var items = false;
844
- var prefixItems = [
845
- {
846
- $ref: "https://schema.twindev.org/json-ld/JsonLdJsonValue"
847
- }
848
- ];
849
- var JsonLdJsonArraySchema = {
850
- $schema: $schema$c,
851
- $id: $id$c,
852
- description: description$c,
853
- type: type$8,
854
- items: items,
855
- prefixItems: prefixItems
856
- };
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.";
861
- var type$7 = "object";
862
- var additionalProperties$6 = {
863
- anyOf: [
864
- {
865
- $ref: "https://schema.twindev.org/json-ld/JsonLdJsonValue"
866
- },
867
- {
868
- not: {
869
- }
870
- }
871
- ]
872
- };
873
- var JsonLdJsonObjectSchema = {
874
- $schema: $schema$b,
875
- $id: $id$b,
876
- description: description$b,
877
- type: type$7,
878
- additionalProperties: additionalProperties$6
879
- };
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.";
884
- var type$6 = [
885
- "string",
886
- "number",
887
- "boolean",
888
- "null"
889
- ];
890
- var JsonLdJsonPrimitiveSchema = {
891
- $schema: $schema$a,
892
- $id: $id$a,
893
- description: description$a,
894
- type: type$6
895
- };
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.";
900
- var anyOf$3 = [
901
- {
902
- $ref: "https://schema.twindev.org/json-ld/JsonLdJsonPrimitive"
903
- },
904
- {
905
- $ref: "https://schema.twindev.org/json-ld/JsonLdJsonArray"
906
- },
907
- {
908
- $ref: "https://schema.twindev.org/json-ld/JsonLdJsonObject"
909
- }
910
- ];
911
- var JsonLdJsonValueSchema = {
912
- $schema: $schema$9,
913
- $id: $id$9,
914
- description: description$9,
915
- anyOf: anyOf$3
916
- };
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.";
921
- var type$5 = "object";
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"
936
- }
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": {
955
- anyOf: [
956
- {
957
- $ref: "https://schema.twindev.org/json-ld/JsonLdListOrSetItem"
958
- },
959
- {
960
- type: "array",
961
- items: false,
962
- prefixItems: [
963
- {
964
- $ref: "https://schema.twindev.org/json-ld/JsonLdListOrSetItem"
965
- }
966
- ]
967
- }
968
- ]
969
- },
970
- "@index": {
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"
994
- },
995
- {
996
- type: "boolean"
997
- },
998
- {
999
- type: "number"
1000
- },
1001
- {
1002
- type: "string"
1003
- },
1004
- {
1005
- $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
1006
- },
1007
- {
1008
- $ref: "https://schema.twindev.org/json-ld/JsonLdValueObject"
1009
- }
1010
- ];
1011
- var JsonLdListOrSetItemSchema = {
1012
- $schema: $schema$6,
1013
- $id: $id$6,
1014
- description: description$6,
1015
- anyOf: anyOf$2
1016
- };
1017
-
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 = {
1023
- anyOf: [
1024
- {
1025
- $ref: "https://schema.twindev.org/json-ld/JsonLdNodePrimitive"
1026
- },
1027
- {
1028
- $ref: "https://schema.twindev.org/json-ld/JsonLdLanguageMap"
1029
- },
1030
- {
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"
1044
- }
1045
- ]
1046
- };
1047
- var properties$2 = {
1048
- "@context": {
1049
- $ref: "https://schema.twindev.org/json-ld/JsonLdContextDefinitionRoot"
1050
- },
1051
- "@id": {
1052
- anyOf: [
1053
- {
1054
- type: "string"
1055
- },
1056
- {
1057
- type: "array",
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
- ]
1099
- }
1100
- ]
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
- },
1124
- "@index": {
1125
- type: "string"
1126
- }
1127
- };
1128
- var JsonLdNodeObjectSchema = {
1129
- $schema: $schema$5,
1130
- $id: $id$5,
1131
- description: description$5,
1132
- type: type$3,
1133
- additionalProperties: additionalProperties$3,
1134
- properties: properties$2
1135
- };
1136
-
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 = [
1141
- {
1142
- type: "null"
1143
- },
1144
- {
1145
- type: "boolean"
1146
- },
1147
- {
1148
- type: "number"
1149
- },
1150
- {
1151
- type: "string"
1152
- },
1153
- {
1154
- $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
1155
- },
1156
- {
1157
- $ref: "https://schema.twindev.org/json-ld/JsonLdGraphObject"
1158
- },
1159
- {
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"
1167
- }
1168
- ];
1169
- var JsonLdNodePrimitiveSchema = {
1170
- $schema: $schema$4,
1171
- $id: $id$4,
1172
- description: description$4,
1173
- anyOf: anyOf$1
1174
- };
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.";
1179
- var type$2 = "object";
1180
- var properties$1 = {
1181
- "@context": {
1182
- $ref: "https://schema.twindev.org/json-ld/JsonLdContextDefinitionRoot"
1183
- },
1184
- "@id": {
1185
- anyOf: [
1186
- {
1187
- type: "string"
1188
- },
1189
- {
1190
- type: "array",
1191
- items: false,
1192
- prefixItems: [
1193
- {
1194
- type: "string"
1195
- }
1196
- ]
1197
- }
1198
- ]
1199
- },
1200
- "@included": {
1201
- $ref: "https://schema.twindev.org/json-ld/JsonLdIncludedBlock"
1202
- },
1203
- "@graph": {
1204
- anyOf: [
1205
- {
1206
- $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
1207
- },
1208
- {
1209
- type: "array",
1210
- items: false,
1211
- prefixItems: [
1212
- {
1213
- $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
1214
- }
1215
- ]
1216
- }
1217
- ]
1218
- },
1219
- "@nest": {
1220
- anyOf: [
1221
- {
1222
- $ref: "https://schema.twindev.org/json-ld/JsonLdJsonObject"
1223
- },
1224
- {
1225
- type: "array",
1226
- items: false,
1227
- prefixItems: [
1228
- {
1229
- $ref: "https://schema.twindev.org/json-ld/JsonLdJsonObject"
1230
- }
1231
- ]
1232
- }
1233
- ]
1234
- },
1235
- "@type": {
1236
- anyOf: [
1237
- {
1238
- type: "string"
1239
- },
1240
- {
1241
- type: "array",
1242
- items: false,
1243
- prefixItems: [
1244
- {
1245
- type: "string"
1246
- }
1247
- ]
1248
- }
1249
- ]
1250
- },
1251
- "@reverse": {
1252
- type: "object",
1253
- additionalProperties: {
1254
- type: "string"
1255
- }
1256
- },
1257
- "@index": {
1258
- type: "string"
1259
- }
1260
- };
1261
- var additionalProperties$2 = false;
1262
- var JsonLdObjectSchema = {
1263
- $schema: $schema$3,
1264
- $id: $id$3,
1265
- description: description$3,
1266
- type: type$2,
1267
- properties: properties$1,
1268
- additionalProperties: additionalProperties$2
1269
- };
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.";
1274
- var type$1 = "object";
1275
- var properties = {
1276
- "@set": {
1277
- anyOf: [
1278
- {
1279
- $ref: "https://schema.twindev.org/json-ld/JsonLdListOrSetItem"
1280
- },
1281
- {
1282
- type: "array",
1283
- items: false,
1284
- prefixItems: [
1285
- {
1286
- $ref: "https://schema.twindev.org/json-ld/JsonLdListOrSetItem"
1287
- }
1288
- ]
1289
- }
1290
- ]
1291
- },
1292
- "@index": {
1293
- type: "string"
1294
- }
1295
- };
1296
- var required = [
1297
- "@set"
1298
- ];
1299
- var additionalProperties$1 = false;
1300
- var JsonLdSetObjectSchema = {
1301
- $schema: $schema$2,
1302
- $id: $id$2,
1303
- description: description$2,
1304
- type: type$1,
1305
- properties: properties,
1306
- required: required,
1307
- additionalProperties: additionalProperties$1
1308
- };
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.";
1313
- var type = "object";
1314
- var additionalProperties = {
1315
- anyOf: [
1316
- {
1317
- type: "string"
1318
- },
1319
- {
1320
- $ref: "https://schema.twindev.org/json-ld/JsonLdNodeObject"
1321
- }
1322
- ]
1323
- };
1324
- var JsonLdTypeMapSchema = {
1325
- $schema: $schema$1,
1326
- $id: $id$1,
1327
- description: description$1,
1328
- type: type,
1329
- additionalProperties: additionalProperties
1330
- };
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.";
1335
- var anyOf = [
1336
- {
1337
- type: "object",
1338
- additionalProperties: false,
1339
- properties: {
1340
- "@value": {
1341
- type: [
1342
- "null",
1343
- "boolean",
1344
- "number",
1345
- "string"
1346
- ]
1347
- },
1348
- "@language": {
1349
- type: "string"
1350
- },
1351
- "@direction": {
1352
- type: [
1353
- "string",
1354
- "null"
1355
- ],
1356
- "enum": [
1357
- "ltr",
1358
- "rtl",
1359
- null
1360
- ]
1361
- },
1362
- "@index": {
1363
- type: "string"
1364
- },
1365
- "@context": {
1366
- $ref: "https://schema.twindev.org/json-ld/JsonLdContextDefinitionRoot"
1367
- }
1368
- },
1369
- required: [
1370
- "@value"
1371
- ]
1372
- },
1373
- {
1374
- type: "object",
1375
- additionalProperties: false,
1376
- properties: {
1377
- "@value": {
1378
- type: [
1379
- "null",
1380
- "boolean",
1381
- "number",
1382
- "string"
1383
- ]
1384
- },
1385
- "@type": {
1386
- type: "string"
1387
- },
1388
- "@index": {
1389
- type: "string"
1390
- },
1391
- "@context": {
1392
- $ref: "https://schema.twindev.org/json-ld/JsonLdContextDefinitionRoot"
1393
- }
1394
- },
1395
- required: [
1396
- "@type",
1397
- "@value"
1398
- ]
1399
- },
1400
- {
1401
- type: "object",
1402
- additionalProperties: false,
1403
- properties: {
1404
- "@value": {
1405
- anyOf: [
1406
- {
1407
- type: "null"
1408
- },
1409
- {
1410
- type: "boolean"
1411
- },
1412
- {
1413
- type: "number"
1414
- },
1415
- {
1416
- type: "string"
1417
- },
1418
- {
1419
- $ref: "https://schema.twindev.org/json-ld/JsonLdJsonObject"
1420
- },
1421
- {
1422
- $ref: "https://schema.twindev.org/json-ld/JsonLdJsonArray"
1423
- }
1424
- ]
1425
- },
1426
- "@type": {
1427
- type: "string",
1428
- "const": "@json"
1429
- },
1430
- "@index": {
1431
- type: "string"
1432
- },
1433
- "@context": {
1434
- $ref: "https://schema.twindev.org/json-ld/JsonLdContextDefinitionRoot"
1435
- }
1436
- },
1437
- required: [
1438
- "@type",
1439
- "@value"
1440
- ]
1441
- }
1442
- ];
1443
- var JsonLdValueObjectSchema = {
1444
- $schema: $schema,
1445
- $id: $id,
1446
- description: description,
1447
- anyOf: anyOf
1448
- };
1449
-
1450
- // Copyright 2024 IOTA Stiftung.
1451
- // SPDX-License-Identifier: Apache-2.0.
1452
- /**
1453
- * Handle all the data types for JSON-LD.
1454
- */
1455
- class JsonLdDataTypes {
1456
- /**
1457
- * Register all the data types.
1458
- */
1459
- static registerTypes() {
1460
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.Document}`, () => ({
1461
- context: JsonLdContexts.ContextRoot,
1462
- type: JsonLdTypes.Document,
1463
- jsonSchema: async () => JsonLdDocumentSchema
1464
- }));
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,
1472
- type: JsonLdTypes.NodeObject,
1473
- jsonSchema: async () => JsonLdNodeObjectSchema
1474
- }));
1475
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.NodePrimitive}`, () => ({
1476
- context: JsonLdContexts.ContextRoot,
1477
- type: JsonLdTypes.NodePrimitive,
1478
- jsonSchema: async () => JsonLdNodePrimitiveSchema
1479
- }));
1480
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.GraphObject}`, () => ({
1481
- context: JsonLdContexts.ContextRoot,
1482
- type: JsonLdTypes.GraphObject,
1483
- jsonSchema: async () => JsonLdGraphObjectSchema
1484
- }));
1485
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.ValueObject}`, () => ({
1486
- context: JsonLdContexts.ContextRoot,
1487
- type: JsonLdTypes.ValueObject,
1488
- jsonSchema: async () => JsonLdValueObjectSchema
1489
- }));
1490
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.ListObject}`, () => ({
1491
- context: JsonLdContexts.ContextRoot,
1492
- type: JsonLdTypes.ListObject,
1493
- jsonSchema: async () => JsonLdListObjectSchema
1494
- }));
1495
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.ListObject}`, () => ({
1496
- context: JsonLdContexts.ContextRoot,
1497
- type: JsonLdTypes.ListObject,
1498
- jsonSchema: async () => JsonLdListObjectSchema
1499
- }));
1500
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.SetObject}`, () => ({
1501
- context: JsonLdContexts.ContextRoot,
1502
- type: JsonLdTypes.SetObject,
1503
- jsonSchema: async () => JsonLdSetObjectSchema
1504
- }));
1505
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.LanguageMap}`, () => ({
1506
- context: JsonLdContexts.ContextRoot,
1507
- type: JsonLdTypes.LanguageMap,
1508
- jsonSchema: async () => JsonLdLanguageMapSchema
1509
- }));
1510
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.IndexMap}`, () => ({
1511
- context: JsonLdContexts.ContextRoot,
1512
- type: JsonLdTypes.IndexMap,
1513
- jsonSchema: async () => JsonLdIndexMapSchema
1514
- }));
1515
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.IndexMapItem}`, () => ({
1516
- context: JsonLdContexts.ContextRoot,
1517
- type: JsonLdTypes.IndexMapItem,
1518
- jsonSchema: async () => JsonLdIndexMapItemSchema
1519
- }));
1520
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.IdMap}`, () => ({
1521
- context: JsonLdContexts.ContextRoot,
1522
- type: JsonLdTypes.IdMap,
1523
- jsonSchema: async () => JsonLdIdMapSchema
1524
- }));
1525
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.TypeMap}`, () => ({
1526
- context: JsonLdContexts.ContextRoot,
1527
- type: JsonLdTypes.TypeMap,
1528
- jsonSchema: async () => JsonLdTypeMapSchema
1529
- }));
1530
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.IncludedBlock}`, () => ({
1531
- context: JsonLdContexts.ContextRoot,
1532
- type: JsonLdTypes.IncludedBlock,
1533
- jsonSchema: async () => JsonLdIncludedBlockSchema
1534
- }));
1535
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.ContextDefinition}`, () => ({
1536
- context: JsonLdContexts.ContextRoot,
1537
- type: JsonLdTypes.ContextDefinition,
1538
- jsonSchema: async () => JsonLdContextDefinitionSchema
1539
- }));
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,
1552
- type: JsonLdTypes.ExpandedTermDefinition,
1553
- jsonSchema: async () => JsonLdExpandedTermDefinitionSchema
1554
- }));
1555
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.ListOrSetItem}`, () => ({
1556
- context: JsonLdContexts.ContextRoot,
1557
- type: JsonLdTypes.ListOrSetItem,
1558
- jsonSchema: async () => JsonLdListOrSetItemSchema
1559
- }));
1560
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.ContainerType}`, () => ({
1561
- context: JsonLdContexts.ContextRoot,
1562
- type: JsonLdTypes.ContainerType,
1563
- jsonSchema: async () => JsonLdContainerTypeSchema
1564
- }));
1565
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.ContainerTypeArray}`, () => ({
1566
- context: JsonLdContexts.ContextRoot,
1567
- type: JsonLdTypes.ContainerTypeArray,
1568
- jsonSchema: async () => JsonLdContainerTypeArraySchema
1569
- }));
1570
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.JsonPrimitive}`, () => ({
1571
- context: JsonLdContexts.ContextRoot,
1572
- type: JsonLdTypes.JsonPrimitive,
1573
- jsonSchema: async () => JsonLdJsonPrimitiveSchema
1574
- }));
1575
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.JsonArray}`, () => ({
1576
- context: JsonLdContexts.ContextRoot,
1577
- type: JsonLdTypes.JsonArray,
1578
- jsonSchema: async () => JsonLdJsonArraySchema
1579
- }));
1580
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.JsonObject}`, () => ({
1581
- context: JsonLdContexts.ContextRoot,
1582
- type: JsonLdTypes.JsonObject,
1583
- jsonSchema: async () => JsonLdJsonObjectSchema
1584
- }));
1585
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.JsonValue}`, () => ({
1586
- context: JsonLdContexts.ContextRoot,
1587
- type: JsonLdTypes.JsonValue,
1588
- jsonSchema: async () => JsonLdJsonValueSchema
1589
- }));
1590
- }
1591
- }
1592
-
1593
- // Copyright 2024 IOTA Stiftung.
1594
- // SPDX-License-Identifier: Apache-2.0.
1595
- /**
1596
- * JSON-LD Processor.
1597
- */
1598
- class JsonLdProcessor {
1599
- /**
1600
- * The class name.
1601
- * @internal
1602
- */
1603
- static CLASS_NAME = "JsonLdProcessor";
1604
- /**
1605
- * The document loader to use.
1606
- * @param documentLoader The document loader to use.
1607
- */
1608
- static setDocumentLoader(documentLoader) {
1609
- SharedStore.set("jsonLdDocumentLoader", documentLoader);
1610
- }
1611
- /**
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.function(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.
1651
- */
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
- }
1660
- /**
1661
- * Compact a document according to a particular context.
1662
- * @param document The JSON-LD document to compact.
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.
1666
- * @returns The compacted JSON-LD document.
1667
- */
1668
- static async compact(document, context, options) {
1669
- try {
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"];
1674
- }
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);
1696
- }
1697
- }
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]);
1704
- }
1705
- return compacted;
1706
- }
1707
- return document;
1708
- }
1709
- catch (err) {
1710
- JsonLdProcessor.handleCommonErrors(err);
1711
- throw new GeneralError(JsonLdProcessor.CLASS_NAME, "compact", undefined, err);
1712
- }
1713
- }
1714
- /**
1715
- * Expand a document, removing its context.
1716
- * @param compacted The compacted JSON-LD document to expand.
1717
- * @returns The expanded JSON-LD document.
1718
- */
1719
- static async expand(compacted) {
1720
- try {
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 [];
1728
- }
1729
- catch (err) {
1730
- JsonLdProcessor.handleCommonErrors(err);
1731
- throw new GeneralError(JsonLdProcessor.CLASS_NAME, "expand", undefined, err);
1732
- }
1733
- }
1734
- /**
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.
1740
- */
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);
1753
- }
1754
- }
1755
- /**
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.
1759
- */
1760
- static addRedirect(from, to) {
1761
- const redirects = JsonLdProcessor.getRedirects();
1762
- if (!redirects.some(r => r.from === from)) {
1763
- redirects.push({ from, to });
1764
- }
1765
- }
1766
- /**
1767
- * Combine contexts.
1768
- * @param context1 The first JSON-LD context to combine.
1769
- * @param context2 The second JSON-LD context to combine.
1770
- * @returns The combined context.
1771
- */
1772
- static combineContexts(context1, context2) {
1773
- const combinedContext = [];
1774
- if (Is.string(context1)) {
1775
- if (!combinedContext.includes(context1)) {
1776
- combinedContext.push(context1);
1777
- }
1778
- }
1779
- else if (Is.array(context1)) {
1780
- for (const context of context1) {
1781
- const hasMatch = combinedContext.some(c => ObjectHelper.equal(c, context));
1782
- if (!hasMatch) {
1783
- combinedContext.push(context);
1784
- }
1785
- }
1786
- }
1787
- else if (Is.object(context1)) {
1788
- const hasMatch = combinedContext.some(c => ObjectHelper.equal(c, context1));
1789
- if (!hasMatch) {
1790
- combinedContext.push(context1);
1791
- }
1792
- }
1793
- if (Is.string(context2)) {
1794
- if (!combinedContext.includes(context2)) {
1795
- combinedContext.push(context2);
1796
- }
1797
- }
1798
- else if (Is.array(context2)) {
1799
- for (const context of context2) {
1800
- const hasMatch = combinedContext.some(c => ObjectHelper.equal(c, context));
1801
- if (!hasMatch) {
1802
- combinedContext.push(context);
1803
- }
1804
- }
1805
- }
1806
- else if (Is.object(context2)) {
1807
- const hasMatch = combinedContext.some(c => ObjectHelper.equal(c, context2));
1808
- if (!hasMatch) {
1809
- combinedContext.push(context2);
1810
- }
1811
- }
1812
- if (combinedContext.length === 0) {
1813
- return null;
1814
- }
1815
- if (combinedContext.length === 1) {
1816
- return combinedContext[0];
1817
- }
1818
- return combinedContext;
1819
- }
1820
- /**
1821
- * Gather all the contexts from the element and it's children.
1822
- * @param element The element to gather the contexts from.
1823
- * @param initial The initial context.
1824
- * @returns The combined contexts.
1825
- */
1826
- static gatherContexts(element, initial) {
1827
- let combinedContexts = initial;
1828
- if (Is.object(element)) {
1829
- if (!Is.empty(element["@context"])) {
1830
- combinedContexts = JsonLdProcessor.combineContexts(initial, element["@context"]);
1831
- }
1832
- for (const prop of Object.keys(element)) {
1833
- const value = element[prop];
1834
- if (Is.object(value)) {
1835
- combinedContexts = JsonLdProcessor.gatherContexts(value, combinedContexts);
1836
- }
1837
- else if (Is.array(value)) {
1838
- for (const item of value) {
1839
- if (Is.object(item)) {
1840
- combinedContexts = JsonLdProcessor.gatherContexts(item, combinedContexts);
1841
- }
1842
- }
1843
- }
1844
- }
1845
- }
1846
- return combinedContexts;
1847
- }
1848
- /**
1849
- * Remove all the contexts that match the pattern.
1850
- * @param context The context to remove the entries from.
1851
- * @param match The element to try and match.
1852
- * @returns The updated contexts.
1853
- */
1854
- static removeContexts(context, match) {
1855
- if (!Is.arrayValue(match)) {
1856
- return context;
1857
- }
1858
- let finalContext;
1859
- if (Is.string(context)) {
1860
- for (const m of match) {
1861
- if (context === m) {
1862
- break;
1863
- }
1864
- }
1865
- }
1866
- else if (Is.array(context)) {
1867
- for (const item of context) {
1868
- const hasMatch = match.some(m => ObjectHelper.equal(m, item));
1869
- if (!hasMatch) {
1870
- finalContext ??= [];
1871
- if (Is.array(finalContext)) {
1872
- finalContext.push(item);
1873
- }
1874
- }
1875
- }
1876
- }
1877
- else if (Is.object(context)) {
1878
- const hasMatch = match.some(m => ObjectHelper.equal(m, context));
1879
- if (!hasMatch) {
1880
- finalContext = context;
1881
- }
1882
- }
1883
- return Is.arrayValue(finalContext) && finalContext.length === 1
1884
- ? finalContext[0]
1885
- : finalContext;
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
- }
1904
- /**
1905
- * Document loader which uses a caching mechanism.
1906
- * @param url The document url to load.
1907
- * @returns The document.
1908
- * @internal
1909
- */
1910
- static async documentLoader(url) {
1911
- const redirects = JsonLdProcessor.getRedirects();
1912
- for (const redirect of redirects) {
1913
- if (redirect.from.test(url)) {
1914
- url = redirect.to;
1915
- break;
1916
- }
1917
- }
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
- const { code, ...other } = err.details ?? {};
1960
- throw new GeneralError(JsonLdProcessor.CLASS_NAME, "jsonLdError", { code, ...other }, err);
1961
- }
1962
- }
1963
- }
1964
-
1965
- // Copyright 2024 IOTA Stiftung.
1966
- // SPDX-License-Identifier: Apache-2.0.
1967
- /**
1968
- * Class to help with JSON LD.
1969
- */
1970
- class JsonLdHelper {
1971
- /**
1972
- * Validate a JSON-LD document.
1973
- * @param document The JSON-LD document to validate.
1974
- * @param validationFailures The list of validation failures to add to.
1975
- * @param options Optional options for validation.
1976
- * @param options.failOnMissingType If true, will fail validation if the data type is missing, defaults to false.
1977
- * @param options.validationMode The validation mode to use, defaults to either.
1978
- * @returns True if the document was valid.
1979
- */
1980
- static async validate(document, validationFailures, options) {
1981
- if (Is.array(document)) {
1982
- // If the document is an array of nodes, validate each node
1983
- for (const node of document) {
1984
- await JsonLdHelper.validate(node, validationFailures, options);
1985
- }
1986
- }
1987
- else if (Is.array(document["@graph"])) {
1988
- // If the graph is an array of nodes, validate each node
1989
- for (const node of document["@graph"]) {
1990
- await JsonLdHelper.validate(node, validationFailures, options);
1991
- }
1992
- }
1993
- else if (Is.object(document)) {
1994
- // Expand the document to ensure we have the full context for types
1995
- // As the data types in the factories are always fully qualified
1996
- const expandedDocs = await JsonLdProcessor.expand(document);
1997
- if (Is.arrayValue(expandedDocs)) {
1998
- for (const expandedDoc of expandedDocs) {
1999
- const expandedDataTypes = ArrayHelper.fromObjectOrArray(expandedDoc["@type"]);
2000
- if (Is.arrayValue(expandedDataTypes)) {
2001
- for (const expandedDataType of expandedDataTypes) {
2002
- await DataTypeHelper.validate("document", expandedDataType, document, validationFailures, options);
2003
- }
2004
- }
2005
- }
2006
- }
2007
- }
2008
- return validationFailures.length === 0;
2009
- }
2010
- }
2011
-
2012
- export { JsonLdContexts, JsonLdDataTypes, JsonLdHelper, JsonLdProcessor, JsonLdTypes };