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