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