@jarenjs/refs 0.8.2 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +20 -2
- package/dist/types/index.d.ts +44 -0
- package/dist/types/index.import.no-lint.d.ts +417 -0
- package/dist/types/json-schema-2019-09/index.d.ts +370 -0
- package/dist/types/json-schema-2019-09/index.import.no-lint.d.ts +378 -0
- package/dist/types/json-schema-2020-12/index.d.ts +411 -0
- package/dist/types/json-schema-2020-12/index.import.no-lint.d.ts +421 -0
- package/package.json +32 -10
- package/src/data.json +13 -0
- package/src/index.import.no-lint.js +5 -0
- package/src/index.js +86 -0
- package/src/json-schema-2019-09/index.import.no-lint.js +17 -0
- package/src/json-schema-2019-09/index.js +12 -0
- package/src/json-schema-2019-09/meta/applicator.json +53 -0
- package/src/json-schema-2019-09/meta/content.json +17 -0
- package/src/json-schema-2019-09/meta/core.json +57 -0
- package/src/json-schema-2019-09/meta/format.json +14 -0
- package/src/json-schema-2019-09/meta/meta-data.json +37 -0
- package/src/json-schema-2019-09/meta/validation.json +90 -0
- package/src/json-schema-2019-09/schema.json +39 -0
- package/src/json-schema-2020-12/index.import.no-lint.js +21 -0
- package/src/json-schema-2020-12/index.js +16 -0
- package/src/json-schema-2020-12/meta/applicator.json +48 -0
- package/src/json-schema-2020-12/meta/content.json +17 -0
- package/src/json-schema-2020-12/meta/core.json +51 -0
- package/src/json-schema-2020-12/meta/format-annotation.json +14 -0
- package/src/json-schema-2020-12/meta/format-assertion.json +13 -0
- package/src/json-schema-2020-12/meta/meta-data.json +37 -0
- package/src/json-schema-2020-12/meta/unevaluated.json +15 -0
- package/src/json-schema-2020-12/meta/validation.json +90 -0
- package/src/json-schema-2020-12/schema.json +55 -0
- package/src/json-schema-draft-06.json +137 -0
- package/src/json-schema-draft-07.json +152 -0
- package/src/json-schema-secure.json +88 -0
- package/dist/index.js +0 -1054
- package/dist/index.js.map +0 -7
- package/dist/index.min.js +0 -2
- package/dist/index.min.js.map +0 -7
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
metaSchema: {
|
|
3
|
+
$schema: string;
|
|
4
|
+
$id: string;
|
|
5
|
+
$vocabulary: {
|
|
6
|
+
"https://json-schema.org/draft/2020-12/vocab/core": boolean;
|
|
7
|
+
"https://json-schema.org/draft/2020-12/vocab/applicator": boolean;
|
|
8
|
+
"https://json-schema.org/draft/2020-12/vocab/unevaluated": boolean;
|
|
9
|
+
"https://json-schema.org/draft/2020-12/vocab/validation": boolean;
|
|
10
|
+
"https://json-schema.org/draft/2020-12/vocab/meta-data": boolean;
|
|
11
|
+
"https://json-schema.org/draft/2020-12/vocab/format-annotation": boolean;
|
|
12
|
+
"https://json-schema.org/draft/2020-12/vocab/content": boolean;
|
|
13
|
+
};
|
|
14
|
+
$dynamicAnchor: string;
|
|
15
|
+
title: string;
|
|
16
|
+
allOf: {
|
|
17
|
+
$ref: string;
|
|
18
|
+
}[];
|
|
19
|
+
type: string[];
|
|
20
|
+
$comment: string;
|
|
21
|
+
properties: {
|
|
22
|
+
definitions: {
|
|
23
|
+
$comment: string;
|
|
24
|
+
type: string;
|
|
25
|
+
additionalProperties: {
|
|
26
|
+
$dynamicRef: string;
|
|
27
|
+
};
|
|
28
|
+
deprecated: boolean;
|
|
29
|
+
default: {};
|
|
30
|
+
};
|
|
31
|
+
dependencies: {
|
|
32
|
+
$comment: string;
|
|
33
|
+
type: string;
|
|
34
|
+
additionalProperties: {
|
|
35
|
+
anyOf: ({
|
|
36
|
+
$dynamicRef: string;
|
|
37
|
+
$ref?: undefined;
|
|
38
|
+
} | {
|
|
39
|
+
$dynamicRef?: undefined;
|
|
40
|
+
$ref: string;
|
|
41
|
+
})[];
|
|
42
|
+
};
|
|
43
|
+
deprecated: boolean;
|
|
44
|
+
default: {};
|
|
45
|
+
};
|
|
46
|
+
$recursiveAnchor: {
|
|
47
|
+
$comment: string;
|
|
48
|
+
$ref: string;
|
|
49
|
+
deprecated: boolean;
|
|
50
|
+
};
|
|
51
|
+
$recursiveRef: {
|
|
52
|
+
$comment: string;
|
|
53
|
+
$ref: string;
|
|
54
|
+
deprecated: boolean;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
applicator: {
|
|
59
|
+
$schema: string;
|
|
60
|
+
$id: string;
|
|
61
|
+
$vocabulary: {
|
|
62
|
+
"https://json-schema.org/draft/2020-12/vocab/applicator": boolean;
|
|
63
|
+
};
|
|
64
|
+
$dynamicAnchor: string;
|
|
65
|
+
title: string;
|
|
66
|
+
type: string[];
|
|
67
|
+
properties: {
|
|
68
|
+
prefixItems: {
|
|
69
|
+
$ref: string;
|
|
70
|
+
};
|
|
71
|
+
items: {
|
|
72
|
+
$dynamicRef: string;
|
|
73
|
+
};
|
|
74
|
+
contains: {
|
|
75
|
+
$dynamicRef: string;
|
|
76
|
+
};
|
|
77
|
+
additionalProperties: {
|
|
78
|
+
$dynamicRef: string;
|
|
79
|
+
};
|
|
80
|
+
properties: {
|
|
81
|
+
type: string;
|
|
82
|
+
additionalProperties: {
|
|
83
|
+
$dynamicRef: string;
|
|
84
|
+
};
|
|
85
|
+
default: {};
|
|
86
|
+
};
|
|
87
|
+
patternProperties: {
|
|
88
|
+
type: string;
|
|
89
|
+
additionalProperties: {
|
|
90
|
+
$dynamicRef: string;
|
|
91
|
+
};
|
|
92
|
+
propertyNames: {
|
|
93
|
+
format: string;
|
|
94
|
+
};
|
|
95
|
+
default: {};
|
|
96
|
+
};
|
|
97
|
+
dependentSchemas: {
|
|
98
|
+
type: string;
|
|
99
|
+
additionalProperties: {
|
|
100
|
+
$dynamicRef: string;
|
|
101
|
+
};
|
|
102
|
+
default: {};
|
|
103
|
+
};
|
|
104
|
+
propertyNames: {
|
|
105
|
+
$dynamicRef: string;
|
|
106
|
+
};
|
|
107
|
+
if: {
|
|
108
|
+
$dynamicRef: string;
|
|
109
|
+
};
|
|
110
|
+
then: {
|
|
111
|
+
$dynamicRef: string;
|
|
112
|
+
};
|
|
113
|
+
else: {
|
|
114
|
+
$dynamicRef: string;
|
|
115
|
+
};
|
|
116
|
+
allOf: {
|
|
117
|
+
$ref: string;
|
|
118
|
+
};
|
|
119
|
+
anyOf: {
|
|
120
|
+
$ref: string;
|
|
121
|
+
};
|
|
122
|
+
oneOf: {
|
|
123
|
+
$ref: string;
|
|
124
|
+
};
|
|
125
|
+
not: {
|
|
126
|
+
$dynamicRef: string;
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
$defs: {
|
|
130
|
+
schemaArray: {
|
|
131
|
+
type: string;
|
|
132
|
+
minItems: number;
|
|
133
|
+
items: {
|
|
134
|
+
$dynamicRef: string;
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
unevaluated: {
|
|
140
|
+
$schema: string;
|
|
141
|
+
$id: string;
|
|
142
|
+
$vocabulary: {
|
|
143
|
+
"https://json-schema.org/draft/2020-12/vocab/unevaluated": boolean;
|
|
144
|
+
};
|
|
145
|
+
$dynamicAnchor: string;
|
|
146
|
+
title: string;
|
|
147
|
+
type: string[];
|
|
148
|
+
properties: {
|
|
149
|
+
unevaluatedItems: {
|
|
150
|
+
$dynamicRef: string;
|
|
151
|
+
};
|
|
152
|
+
unevaluatedProperties: {
|
|
153
|
+
$dynamicRef: string;
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
content: {
|
|
158
|
+
$schema: string;
|
|
159
|
+
$id: string;
|
|
160
|
+
$vocabulary: {
|
|
161
|
+
"https://json-schema.org/draft/2020-12/vocab/content": boolean;
|
|
162
|
+
};
|
|
163
|
+
$dynamicAnchor: string;
|
|
164
|
+
title: string;
|
|
165
|
+
type: string[];
|
|
166
|
+
properties: {
|
|
167
|
+
contentEncoding: {
|
|
168
|
+
type: string;
|
|
169
|
+
};
|
|
170
|
+
contentMediaType: {
|
|
171
|
+
type: string;
|
|
172
|
+
};
|
|
173
|
+
contentSchema: {
|
|
174
|
+
$dynamicRef: string;
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
core: {
|
|
179
|
+
$schema: string;
|
|
180
|
+
$id: string;
|
|
181
|
+
$vocabulary: {
|
|
182
|
+
"https://json-schema.org/draft/2020-12/vocab/core": boolean;
|
|
183
|
+
};
|
|
184
|
+
$dynamicAnchor: string;
|
|
185
|
+
title: string;
|
|
186
|
+
type: string[];
|
|
187
|
+
properties: {
|
|
188
|
+
$id: {
|
|
189
|
+
$ref: string;
|
|
190
|
+
$comment: string;
|
|
191
|
+
pattern: string;
|
|
192
|
+
};
|
|
193
|
+
$schema: {
|
|
194
|
+
$ref: string;
|
|
195
|
+
};
|
|
196
|
+
$ref: {
|
|
197
|
+
$ref: string;
|
|
198
|
+
};
|
|
199
|
+
$anchor: {
|
|
200
|
+
$ref: string;
|
|
201
|
+
};
|
|
202
|
+
$dynamicRef: {
|
|
203
|
+
$ref: string;
|
|
204
|
+
};
|
|
205
|
+
$dynamicAnchor: {
|
|
206
|
+
$ref: string;
|
|
207
|
+
};
|
|
208
|
+
$vocabulary: {
|
|
209
|
+
type: string;
|
|
210
|
+
propertyNames: {
|
|
211
|
+
$ref: string;
|
|
212
|
+
};
|
|
213
|
+
additionalProperties: {
|
|
214
|
+
type: string;
|
|
215
|
+
};
|
|
216
|
+
};
|
|
217
|
+
$comment: {
|
|
218
|
+
type: string;
|
|
219
|
+
};
|
|
220
|
+
$defs: {
|
|
221
|
+
type: string;
|
|
222
|
+
additionalProperties: {
|
|
223
|
+
$dynamicRef: string;
|
|
224
|
+
};
|
|
225
|
+
};
|
|
226
|
+
};
|
|
227
|
+
$defs: {
|
|
228
|
+
anchorString: {
|
|
229
|
+
type: string;
|
|
230
|
+
pattern: string;
|
|
231
|
+
};
|
|
232
|
+
uriString: {
|
|
233
|
+
type: string;
|
|
234
|
+
format: string;
|
|
235
|
+
};
|
|
236
|
+
uriReferenceString: {
|
|
237
|
+
type: string;
|
|
238
|
+
format: string;
|
|
239
|
+
};
|
|
240
|
+
};
|
|
241
|
+
};
|
|
242
|
+
formatAnnotation: {
|
|
243
|
+
$schema: string;
|
|
244
|
+
$id: string;
|
|
245
|
+
$vocabulary: {
|
|
246
|
+
"https://json-schema.org/draft/2020-12/vocab/format-annotation": boolean;
|
|
247
|
+
};
|
|
248
|
+
$dynamicAnchor: string;
|
|
249
|
+
title: string;
|
|
250
|
+
type: string[];
|
|
251
|
+
properties: {
|
|
252
|
+
format: {
|
|
253
|
+
type: string;
|
|
254
|
+
};
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
formatAssertion: {
|
|
258
|
+
$schema: string;
|
|
259
|
+
$id: string;
|
|
260
|
+
$vocabulary: {
|
|
261
|
+
"https://json-schema.org/draft/2020-12/vocab/format-assertion": boolean;
|
|
262
|
+
};
|
|
263
|
+
$dynamicAnchor: string;
|
|
264
|
+
title: string;
|
|
265
|
+
type: string[];
|
|
266
|
+
properties: {
|
|
267
|
+
format: {
|
|
268
|
+
type: string;
|
|
269
|
+
};
|
|
270
|
+
};
|
|
271
|
+
};
|
|
272
|
+
metadata: {
|
|
273
|
+
$schema: string;
|
|
274
|
+
$id: string;
|
|
275
|
+
$vocabulary: {
|
|
276
|
+
"https://json-schema.org/draft/2020-12/vocab/meta-data": boolean;
|
|
277
|
+
};
|
|
278
|
+
$dynamicAnchor: string;
|
|
279
|
+
title: string;
|
|
280
|
+
type: string[];
|
|
281
|
+
properties: {
|
|
282
|
+
title: {
|
|
283
|
+
type: string;
|
|
284
|
+
};
|
|
285
|
+
description: {
|
|
286
|
+
type: string;
|
|
287
|
+
};
|
|
288
|
+
default: boolean;
|
|
289
|
+
deprecated: {
|
|
290
|
+
type: string;
|
|
291
|
+
default: boolean;
|
|
292
|
+
};
|
|
293
|
+
readOnly: {
|
|
294
|
+
type: string;
|
|
295
|
+
default: boolean;
|
|
296
|
+
};
|
|
297
|
+
writeOnly: {
|
|
298
|
+
type: string;
|
|
299
|
+
default: boolean;
|
|
300
|
+
};
|
|
301
|
+
examples: {
|
|
302
|
+
type: string;
|
|
303
|
+
items: boolean;
|
|
304
|
+
};
|
|
305
|
+
};
|
|
306
|
+
};
|
|
307
|
+
validation: {
|
|
308
|
+
$schema: string;
|
|
309
|
+
$id: string;
|
|
310
|
+
$vocabulary: {
|
|
311
|
+
"https://json-schema.org/draft/2020-12/vocab/validation": boolean;
|
|
312
|
+
};
|
|
313
|
+
$dynamicAnchor: string;
|
|
314
|
+
title: string;
|
|
315
|
+
type: string[];
|
|
316
|
+
properties: {
|
|
317
|
+
type: {
|
|
318
|
+
anyOf: ({
|
|
319
|
+
$ref: string;
|
|
320
|
+
type?: undefined;
|
|
321
|
+
items?: undefined;
|
|
322
|
+
minItems?: undefined;
|
|
323
|
+
uniqueItems?: undefined;
|
|
324
|
+
} | {
|
|
325
|
+
$ref?: undefined;
|
|
326
|
+
type: string;
|
|
327
|
+
items: {
|
|
328
|
+
$ref: string;
|
|
329
|
+
};
|
|
330
|
+
minItems: number;
|
|
331
|
+
uniqueItems: boolean;
|
|
332
|
+
})[];
|
|
333
|
+
};
|
|
334
|
+
const: boolean;
|
|
335
|
+
enum: {
|
|
336
|
+
type: string;
|
|
337
|
+
items: boolean;
|
|
338
|
+
};
|
|
339
|
+
multipleOf: {
|
|
340
|
+
type: string;
|
|
341
|
+
exclusiveMinimum: number;
|
|
342
|
+
};
|
|
343
|
+
maximum: {
|
|
344
|
+
type: string;
|
|
345
|
+
};
|
|
346
|
+
exclusiveMaximum: {
|
|
347
|
+
type: string;
|
|
348
|
+
};
|
|
349
|
+
minimum: {
|
|
350
|
+
type: string;
|
|
351
|
+
};
|
|
352
|
+
exclusiveMinimum: {
|
|
353
|
+
type: string;
|
|
354
|
+
};
|
|
355
|
+
maxLength: {
|
|
356
|
+
$ref: string;
|
|
357
|
+
};
|
|
358
|
+
minLength: {
|
|
359
|
+
$ref: string;
|
|
360
|
+
};
|
|
361
|
+
pattern: {
|
|
362
|
+
type: string;
|
|
363
|
+
format: string;
|
|
364
|
+
};
|
|
365
|
+
maxItems: {
|
|
366
|
+
$ref: string;
|
|
367
|
+
};
|
|
368
|
+
minItems: {
|
|
369
|
+
$ref: string;
|
|
370
|
+
};
|
|
371
|
+
uniqueItems: {
|
|
372
|
+
type: string;
|
|
373
|
+
default: boolean;
|
|
374
|
+
};
|
|
375
|
+
maxContains: {
|
|
376
|
+
$ref: string;
|
|
377
|
+
};
|
|
378
|
+
minContains: {
|
|
379
|
+
$ref: string;
|
|
380
|
+
default: number;
|
|
381
|
+
};
|
|
382
|
+
maxProperties: {
|
|
383
|
+
$ref: string;
|
|
384
|
+
};
|
|
385
|
+
minProperties: {
|
|
386
|
+
$ref: string;
|
|
387
|
+
};
|
|
388
|
+
required: {
|
|
389
|
+
$ref: string;
|
|
390
|
+
};
|
|
391
|
+
dependentRequired: {
|
|
392
|
+
type: string;
|
|
393
|
+
additionalProperties: {
|
|
394
|
+
$ref: string;
|
|
395
|
+
};
|
|
396
|
+
};
|
|
397
|
+
};
|
|
398
|
+
$defs: {
|
|
399
|
+
nonNegativeInteger: {
|
|
400
|
+
type: string;
|
|
401
|
+
minimum: number;
|
|
402
|
+
};
|
|
403
|
+
nonNegativeIntegerDefault0: {
|
|
404
|
+
$ref: string;
|
|
405
|
+
default: number;
|
|
406
|
+
};
|
|
407
|
+
simpleTypes: {
|
|
408
|
+
enum: string[];
|
|
409
|
+
};
|
|
410
|
+
stringArray: {
|
|
411
|
+
type: string;
|
|
412
|
+
items: {
|
|
413
|
+
type: string;
|
|
414
|
+
};
|
|
415
|
+
uniqueItems: boolean;
|
|
416
|
+
default: never[];
|
|
417
|
+
};
|
|
418
|
+
};
|
|
419
|
+
};
|
|
420
|
+
};
|
|
421
|
+
export default _default;
|
package/package.json
CHANGED
|
@@ -1,20 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jarenjs/refs",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.9.2",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./
|
|
6
|
+
"main": "./src/index.js",
|
|
7
|
+
"types": "./dist/types/index.d.ts",
|
|
8
|
+
"sideEffects": false,
|
|
7
9
|
"files": [
|
|
8
|
-
"dist"
|
|
10
|
+
"dist/types/",
|
|
11
|
+
"src/"
|
|
9
12
|
],
|
|
10
13
|
"description": "Jaren JSON Schema Draft Specifications",
|
|
11
14
|
"author": "joham",
|
|
12
15
|
"repository": {
|
|
13
16
|
"type": "git",
|
|
14
|
-
"url": "https://github.com/jklarenbeek/jarenjs.git",
|
|
17
|
+
"url": "git+https://github.com/jklarenbeek/jarenjs.git",
|
|
15
18
|
"directory": "packages/refs"
|
|
16
19
|
},
|
|
17
20
|
"license": "MIT",
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=22"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public",
|
|
26
|
+
"registry": "https://registry.npmjs.org/"
|
|
27
|
+
},
|
|
18
28
|
"keywords": [
|
|
19
29
|
"jaren",
|
|
20
30
|
"draft-06",
|
|
@@ -26,16 +36,28 @@
|
|
|
26
36
|
"json"
|
|
27
37
|
],
|
|
28
38
|
"exports": {
|
|
29
|
-
".":
|
|
39
|
+
".": {
|
|
40
|
+
"types": "./dist/types/index.d.ts",
|
|
41
|
+
"default": "./src/index.js"
|
|
42
|
+
},
|
|
30
43
|
"./draft-06": "./src/json-schema-draft-06.json",
|
|
31
44
|
"./draft-07": "./src/json-schema-draft-07.json",
|
|
32
|
-
"./draft-2019-09":
|
|
33
|
-
|
|
45
|
+
"./draft-2019-09": {
|
|
46
|
+
"types": "./dist/types/json-schema-2019-09/index.d.ts",
|
|
47
|
+
"default": "./src/json-schema-2019-09/index.js"
|
|
48
|
+
},
|
|
49
|
+
"./draft-2020-12": {
|
|
50
|
+
"types": "./dist/types/json-schema-2020-12/index.d.ts",
|
|
51
|
+
"default": "./src/json-schema-2020-12/index.js"
|
|
52
|
+
},
|
|
53
|
+
"./package.json": "./package.json"
|
|
34
54
|
},
|
|
35
55
|
"scripts": {
|
|
36
|
-
"build": "node esbuild.config.js"
|
|
56
|
+
"build": "node esbuild.config.js && npm run build:types",
|
|
57
|
+
"build:types": "tsc -p tsconfig.json",
|
|
58
|
+
"prepack": "npm run build:types"
|
|
37
59
|
},
|
|
38
|
-
"
|
|
39
|
-
"
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"@jarenjs/core": "^0.9.2"
|
|
40
62
|
}
|
|
41
63
|
}
|
package/src/data.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",
|
|
3
|
+
"description": "Meta-schema for $data reference (JSON AnySchema extension proposal)",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"required": ["$data"],
|
|
6
|
+
"properties": {
|
|
7
|
+
"$data": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"anyOf": [{"format": "relative-json-pointer"}, {"format": "json-pointer"}]
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"additionalProperties": false
|
|
13
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
//@ts-check
|
|
2
|
+
import { isStringType } from '@jarenjs/core';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
_draft6,
|
|
6
|
+
_draft7
|
|
7
|
+
} from './index.import.no-lint.js';
|
|
8
|
+
|
|
9
|
+
import _draft2019 from './json-schema-2019-09/index.js';
|
|
10
|
+
import _draft2020 from './json-schema-2020-12/index.js';
|
|
11
|
+
|
|
12
|
+
const schemaDrafts = {
|
|
13
|
+
6: { draft: 'http://json-schema.org/draft-06/schema', schema: [_draft6] },
|
|
14
|
+
7: { draft: 'http://json-schema.org/draft-07/schema', schema: [_draft7] },
|
|
15
|
+
2019: { draft: 'https://json-schema.org/draft/2019-09/schema', schema: _draft2019 },
|
|
16
|
+
2020: { draft: 'https://json-schema.org/draft/2020-12/schema', schema: _draft2020 },
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A JSON Schema draft specification bundle: the draft's canonical URI and
|
|
21
|
+
* the meta-schema document(s) that define it. For draft 2019-09 and
|
|
22
|
+
* 2020-12 the `schema` array holds the main meta-schema followed by its
|
|
23
|
+
* vocabulary meta-schemas; for draft-06/07 it holds the single meta-schema.
|
|
24
|
+
* @typedef {Object} SchemaDraftInfo
|
|
25
|
+
* @property {string} draft - The draft's canonical URI (e.g. 'http://json-schema.org/draft-07/schema')
|
|
26
|
+
* @property {object[]} schema - The meta-schema document(s) of the draft
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Gets a schema draft bundle by version number.
|
|
31
|
+
* @param {6 | 7 | 2019 | 2020} version - The draft version
|
|
32
|
+
* @returns {SchemaDraftInfo} The draft URI and its meta-schema document(s)
|
|
33
|
+
* @throws {Error} When the version is unknown
|
|
34
|
+
*/
|
|
35
|
+
export function getSchemaDraftByVersion(version) {
|
|
36
|
+
if (version in schemaDrafts)
|
|
37
|
+
return schemaDrafts[version];
|
|
38
|
+
else
|
|
39
|
+
throw new Error('Unknown reference schema version');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Gets a schema draft bundle by name. Accepts the common spellings of
|
|
44
|
+
* each draft name (e.g. 'draft-07', '2019-09', 'draft2020-12').
|
|
45
|
+
* @param {'6'|'draft6'|'draft-6'|'draft06'|'draft-06'
|
|
46
|
+
* |'7'|'draft7'|'draft-7'|'draft07'|'draft-07'
|
|
47
|
+
* |'draft2019'|'draft-2019'|'draft2019-09'|'2019'|'2019-09'
|
|
48
|
+
* |'draft2020'|'draft-2020'|'draft2020-12'|'2020'|'2020-12'} name - The draft name variant
|
|
49
|
+
* @returns {SchemaDraftInfo} The draft URI and its meta-schema document(s)
|
|
50
|
+
* @throws {Error} When the name is unknown
|
|
51
|
+
*/
|
|
52
|
+
export function getSchemaDraftByName(name) {
|
|
53
|
+
switch (name) {
|
|
54
|
+
case '6': case 'draft6': case 'draft-6': case 'draft06': case 'draft-06':
|
|
55
|
+
return getSchemaDraftByVersion(6);
|
|
56
|
+
case '7': case 'draft7': case 'draft-7': case 'draft07': case 'draft-07':
|
|
57
|
+
return getSchemaDraftByVersion(7);
|
|
58
|
+
case 'draft2019': case 'draft-2019': case 'draft2019-09': case '2019': case '2019-09':
|
|
59
|
+
return getSchemaDraftByVersion(2019);
|
|
60
|
+
case 'draft2020': case 'draft-2020': case 'draft2020-12': case '2020': case '2020-12':
|
|
61
|
+
return getSchemaDraftByVersion(2020);
|
|
62
|
+
default:
|
|
63
|
+
throw new Error(`Unknown reference schema name: '${name}'`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Gets a schema draft bundle by its canonical $id URI (case-insensitive).
|
|
69
|
+
* @param {string} schemaId - The schema $id URI
|
|
70
|
+
* @returns {SchemaDraftInfo} The draft URI and its meta-schema document(s)
|
|
71
|
+
* @throws {Error} When the schema id is not a string or not found
|
|
72
|
+
*/
|
|
73
|
+
export function getSchemaDraftById(schemaId) {
|
|
74
|
+
if (!isStringType(schemaId))
|
|
75
|
+
throw new Error('The schema id must be of type string');
|
|
76
|
+
|
|
77
|
+
const $id = schemaId.toLowerCase();
|
|
78
|
+
// eslint-disable-next-line no-unused-vars
|
|
79
|
+
for (const [_, item] of Object.entries(schemaDrafts)) {
|
|
80
|
+
const draft = item.draft;
|
|
81
|
+
if (draft.toLowerCase() === $id)
|
|
82
|
+
return item;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
throw new Error(`Schema draft with id '${schemaId}' does not exists`);
|
|
86
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import metaSchema from './schema.json' with { type: 'json' };
|
|
2
|
+
import applicator from './meta/applicator.json' with { type: 'json' };
|
|
3
|
+
import content from './meta/content.json' with { type: 'json' };
|
|
4
|
+
import core from './meta/core.json' with { type: 'json' };
|
|
5
|
+
import format from './meta/format.json' with { type: 'json' };
|
|
6
|
+
import metadata from './meta/meta-data.json' with { type: 'json' };
|
|
7
|
+
import validation from './meta/validation.json' with { type: 'json' };
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
metaSchema,
|
|
11
|
+
applicator,
|
|
12
|
+
content,
|
|
13
|
+
core,
|
|
14
|
+
format,
|
|
15
|
+
metadata,
|
|
16
|
+
validation,
|
|
17
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2019-09/schema",
|
|
3
|
+
"$id": "https://json-schema.org/draft/2019-09/meta/applicator",
|
|
4
|
+
"$vocabulary": {
|
|
5
|
+
"https://json-schema.org/draft/2019-09/vocab/applicator": true
|
|
6
|
+
},
|
|
7
|
+
"$recursiveAnchor": true,
|
|
8
|
+
|
|
9
|
+
"title": "Applicator vocabulary meta-schema",
|
|
10
|
+
"type": ["object", "boolean"],
|
|
11
|
+
"properties": {
|
|
12
|
+
"additionalItems": {"$recursiveRef": "#"},
|
|
13
|
+
"unevaluatedItems": {"$recursiveRef": "#"},
|
|
14
|
+
"items": {
|
|
15
|
+
"anyOf": [{"$recursiveRef": "#"}, {"$ref": "#/$defs/schemaArray"}]
|
|
16
|
+
},
|
|
17
|
+
"contains": {"$recursiveRef": "#"},
|
|
18
|
+
"additionalProperties": {"$recursiveRef": "#"},
|
|
19
|
+
"unevaluatedProperties": {"$recursiveRef": "#"},
|
|
20
|
+
"properties": {
|
|
21
|
+
"type": "object",
|
|
22
|
+
"additionalProperties": {"$recursiveRef": "#"},
|
|
23
|
+
"default": {}
|
|
24
|
+
},
|
|
25
|
+
"patternProperties": {
|
|
26
|
+
"type": "object",
|
|
27
|
+
"additionalProperties": {"$recursiveRef": "#"},
|
|
28
|
+
"propertyNames": {"format": "regex"},
|
|
29
|
+
"default": {}
|
|
30
|
+
},
|
|
31
|
+
"dependentSchemas": {
|
|
32
|
+
"type": "object",
|
|
33
|
+
"additionalProperties": {
|
|
34
|
+
"$recursiveRef": "#"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"propertyNames": {"$recursiveRef": "#"},
|
|
38
|
+
"if": {"$recursiveRef": "#"},
|
|
39
|
+
"then": {"$recursiveRef": "#"},
|
|
40
|
+
"else": {"$recursiveRef": "#"},
|
|
41
|
+
"allOf": {"$ref": "#/$defs/schemaArray"},
|
|
42
|
+
"anyOf": {"$ref": "#/$defs/schemaArray"},
|
|
43
|
+
"oneOf": {"$ref": "#/$defs/schemaArray"},
|
|
44
|
+
"not": {"$recursiveRef": "#"}
|
|
45
|
+
},
|
|
46
|
+
"$defs": {
|
|
47
|
+
"schemaArray": {
|
|
48
|
+
"type": "array",
|
|
49
|
+
"minItems": 1,
|
|
50
|
+
"items": {"$recursiveRef": "#"}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2019-09/schema",
|
|
3
|
+
"$id": "https://json-schema.org/draft/2019-09/meta/content",
|
|
4
|
+
"$vocabulary": {
|
|
5
|
+
"https://json-schema.org/draft/2019-09/vocab/content": true
|
|
6
|
+
},
|
|
7
|
+
"$recursiveAnchor": true,
|
|
8
|
+
|
|
9
|
+
"title": "Content vocabulary meta-schema",
|
|
10
|
+
|
|
11
|
+
"type": ["object", "boolean"],
|
|
12
|
+
"properties": {
|
|
13
|
+
"contentMediaType": {"type": "string"},
|
|
14
|
+
"contentEncoding": {"type": "string"},
|
|
15
|
+
"contentSchema": {"$recursiveRef": "#"}
|
|
16
|
+
}
|
|
17
|
+
}
|