@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.
Files changed (39) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +20 -2
  3. package/dist/types/index.d.ts +44 -0
  4. package/dist/types/index.import.no-lint.d.ts +417 -0
  5. package/dist/types/json-schema-2019-09/index.d.ts +370 -0
  6. package/dist/types/json-schema-2019-09/index.import.no-lint.d.ts +378 -0
  7. package/dist/types/json-schema-2020-12/index.d.ts +411 -0
  8. package/dist/types/json-schema-2020-12/index.import.no-lint.d.ts +421 -0
  9. package/package.json +32 -10
  10. package/src/data.json +13 -0
  11. package/src/index.import.no-lint.js +5 -0
  12. package/src/index.js +86 -0
  13. package/src/json-schema-2019-09/index.import.no-lint.js +17 -0
  14. package/src/json-schema-2019-09/index.js +12 -0
  15. package/src/json-schema-2019-09/meta/applicator.json +53 -0
  16. package/src/json-schema-2019-09/meta/content.json +17 -0
  17. package/src/json-schema-2019-09/meta/core.json +57 -0
  18. package/src/json-schema-2019-09/meta/format.json +14 -0
  19. package/src/json-schema-2019-09/meta/meta-data.json +37 -0
  20. package/src/json-schema-2019-09/meta/validation.json +90 -0
  21. package/src/json-schema-2019-09/schema.json +39 -0
  22. package/src/json-schema-2020-12/index.import.no-lint.js +21 -0
  23. package/src/json-schema-2020-12/index.js +16 -0
  24. package/src/json-schema-2020-12/meta/applicator.json +48 -0
  25. package/src/json-schema-2020-12/meta/content.json +17 -0
  26. package/src/json-schema-2020-12/meta/core.json +51 -0
  27. package/src/json-schema-2020-12/meta/format-annotation.json +14 -0
  28. package/src/json-schema-2020-12/meta/format-assertion.json +13 -0
  29. package/src/json-schema-2020-12/meta/meta-data.json +37 -0
  30. package/src/json-schema-2020-12/meta/unevaluated.json +15 -0
  31. package/src/json-schema-2020-12/meta/validation.json +90 -0
  32. package/src/json-schema-2020-12/schema.json +55 -0
  33. package/src/json-schema-draft-06.json +137 -0
  34. package/src/json-schema-draft-07.json +152 -0
  35. package/src/json-schema-secure.json +88 -0
  36. package/dist/index.js +0 -1054
  37. package/dist/index.js.map +0 -7
  38. package/dist/index.min.js +0 -2
  39. package/dist/index.min.js.map +0 -7
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Joham
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,21 @@
1
- # Jaren Schema References Package
1
+ # @jarenjs/refs
2
2
 
3
- **this is a working package in need of documentation**
3
+ The official JSON Schema meta-schemas for `draft-06`, `draft-07`, `draft 2019-09` and `draft 2020-12`, bundled for offline use with [Jaren](https://github.com/jklarenbeek/jarenjs).
4
+
5
+ ## Usage
6
+
7
+ ```javascript
8
+ import { JarenValidator } from '@jarenjs/validate';
9
+ import { getSchemaDraftByName, getSchemaDraftByVersion } from '@jarenjs/refs';
10
+
11
+ const meta = getSchemaDraftByName('draft2020-12'); // or getSchemaDraftByVersion(2020)
12
+
13
+ const jaren = new JarenValidator()
14
+ .addMetaSchema([...meta.schema], meta.draft);
15
+ ```
16
+
17
+ `getSchemaDraftByVersion` accepts `6`, `7`, `2019` and `2020`; `getSchemaDraftByName` accepts the common spellings (`draft7`, `draft-07`, `2019-09`, `draft2020-12`, ...). Each returns `{ draft, schema }` where `schema` is the array of meta-schema documents for that draft (2019-09 and 2020-12 ship multiple vocabulary documents).
18
+
19
+ The meta-schemas matter beyond `$ref` resolution: [`@jarenjs/validate`](../validate) uses them for draft detection, `$vocabulary`-aware keyword selection (including `format-assertion`), and cross-draft references — all offline, with no network fetches.
20
+
21
+ See the repository [README](../../README.md) for full documentation and the [HOWTO](../../HOWTO.md) for multi-draft setups.
@@ -0,0 +1,44 @@
1
+ export type SchemaDraftInfo = {
2
+ /**
3
+ * - The draft's canonical URI (e.g. 'http://json-schema.org/draft-07/schema')
4
+ */
5
+ draft: string;
6
+ /**
7
+ * - The meta-schema document(s) of the draft
8
+ */
9
+ schema: object[];
10
+ };
11
+ /**
12
+ * A JSON Schema draft specification bundle: the draft's canonical URI and
13
+ * the meta-schema document(s) that define it. For draft 2019-09 and
14
+ * 2020-12 the `schema` array holds the main meta-schema followed by its
15
+ * vocabulary meta-schemas; for draft-06/07 it holds the single meta-schema.
16
+ * @typedef {Object} SchemaDraftInfo
17
+ * @property {string} draft - The draft's canonical URI (e.g. 'http://json-schema.org/draft-07/schema')
18
+ * @property {object[]} schema - The meta-schema document(s) of the draft
19
+ */
20
+ /**
21
+ * Gets a schema draft bundle by version number.
22
+ * @param {6 | 7 | 2019 | 2020} version - The draft version
23
+ * @returns {SchemaDraftInfo} The draft URI and its meta-schema document(s)
24
+ * @throws {Error} When the version is unknown
25
+ */
26
+ export declare function getSchemaDraftByVersion(version: 6 | 7 | 2019 | 2020): SchemaDraftInfo;
27
+ /**
28
+ * Gets a schema draft bundle by name. Accepts the common spellings of
29
+ * each draft name (e.g. 'draft-07', '2019-09', 'draft2020-12').
30
+ * @param {'6'|'draft6'|'draft-6'|'draft06'|'draft-06'
31
+ * |'7'|'draft7'|'draft-7'|'draft07'|'draft-07'
32
+ * |'draft2019'|'draft-2019'|'draft2019-09'|'2019'|'2019-09'
33
+ * |'draft2020'|'draft-2020'|'draft2020-12'|'2020'|'2020-12'} name - The draft name variant
34
+ * @returns {SchemaDraftInfo} The draft URI and its meta-schema document(s)
35
+ * @throws {Error} When the name is unknown
36
+ */
37
+ export declare function getSchemaDraftByName(name: '6' | 'draft6' | 'draft-6' | 'draft06' | 'draft-06' | '7' | 'draft7' | 'draft-7' | 'draft07' | 'draft-07' | 'draft2019' | 'draft-2019' | 'draft2019-09' | '2019' | '2019-09' | 'draft2020' | 'draft-2020' | 'draft2020-12' | '2020' | '2020-12'): SchemaDraftInfo;
38
+ /**
39
+ * Gets a schema draft bundle by its canonical $id URI (case-insensitive).
40
+ * @param {string} schemaId - The schema $id URI
41
+ * @returns {SchemaDraftInfo} The draft URI and its meta-schema document(s)
42
+ * @throws {Error} When the schema id is not a string or not found
43
+ */
44
+ export declare function getSchemaDraftById(schemaId: string): SchemaDraftInfo;
@@ -0,0 +1,417 @@
1
+ export declare const _draft6: {
2
+ $schema: string;
3
+ $id: string;
4
+ title: string;
5
+ definitions: {
6
+ schemaArray: {
7
+ type: string;
8
+ minItems: number;
9
+ items: {
10
+ $ref: string;
11
+ };
12
+ };
13
+ nonNegativeInteger: {
14
+ type: string;
15
+ minimum: number;
16
+ };
17
+ nonNegativeIntegerDefault0: {
18
+ allOf: ({
19
+ $ref: string;
20
+ default?: undefined;
21
+ } | {
22
+ default: number;
23
+ $ref?: undefined;
24
+ })[];
25
+ };
26
+ simpleTypes: {
27
+ enum: string[];
28
+ };
29
+ stringArray: {
30
+ type: string;
31
+ items: {
32
+ type: string;
33
+ };
34
+ uniqueItems: boolean;
35
+ default: never[];
36
+ };
37
+ };
38
+ type: string[];
39
+ properties: {
40
+ $id: {
41
+ type: string;
42
+ format: string;
43
+ };
44
+ $schema: {
45
+ type: string;
46
+ format: string;
47
+ };
48
+ $ref: {
49
+ type: string;
50
+ format: string;
51
+ };
52
+ title: {
53
+ type: string;
54
+ };
55
+ description: {
56
+ type: string;
57
+ };
58
+ default: {};
59
+ examples: {
60
+ type: string;
61
+ items: {};
62
+ };
63
+ multipleOf: {
64
+ type: string;
65
+ exclusiveMinimum: number;
66
+ };
67
+ maximum: {
68
+ type: string;
69
+ };
70
+ exclusiveMaximum: {
71
+ type: string;
72
+ };
73
+ minimum: {
74
+ type: string;
75
+ };
76
+ exclusiveMinimum: {
77
+ type: string;
78
+ };
79
+ maxLength: {
80
+ $ref: string;
81
+ };
82
+ minLength: {
83
+ $ref: string;
84
+ };
85
+ pattern: {
86
+ type: string;
87
+ format: string;
88
+ };
89
+ additionalItems: {
90
+ $ref: string;
91
+ };
92
+ items: {
93
+ anyOf: {
94
+ $ref: string;
95
+ }[];
96
+ default: {};
97
+ };
98
+ maxItems: {
99
+ $ref: string;
100
+ };
101
+ minItems: {
102
+ $ref: string;
103
+ };
104
+ uniqueItems: {
105
+ type: string;
106
+ default: boolean;
107
+ };
108
+ contains: {
109
+ $ref: string;
110
+ };
111
+ maxProperties: {
112
+ $ref: string;
113
+ };
114
+ minProperties: {
115
+ $ref: string;
116
+ };
117
+ required: {
118
+ $ref: string;
119
+ };
120
+ additionalProperties: {
121
+ $ref: string;
122
+ };
123
+ definitions: {
124
+ type: string;
125
+ additionalProperties: {
126
+ $ref: string;
127
+ };
128
+ default: {};
129
+ };
130
+ properties: {
131
+ type: string;
132
+ additionalProperties: {
133
+ $ref: string;
134
+ };
135
+ default: {};
136
+ };
137
+ patternProperties: {
138
+ type: string;
139
+ additionalProperties: {
140
+ $ref: string;
141
+ };
142
+ default: {};
143
+ };
144
+ dependencies: {
145
+ type: string;
146
+ additionalProperties: {
147
+ anyOf: {
148
+ $ref: string;
149
+ }[];
150
+ };
151
+ };
152
+ propertyNames: {
153
+ $ref: string;
154
+ };
155
+ const: {};
156
+ enum: {
157
+ type: string;
158
+ minItems: number;
159
+ uniqueItems: boolean;
160
+ };
161
+ type: {
162
+ anyOf: ({
163
+ $ref: string;
164
+ type?: undefined;
165
+ items?: undefined;
166
+ minItems?: undefined;
167
+ uniqueItems?: undefined;
168
+ } | {
169
+ type: string;
170
+ items: {
171
+ $ref: string;
172
+ };
173
+ minItems: number;
174
+ uniqueItems: boolean;
175
+ $ref?: undefined;
176
+ })[];
177
+ };
178
+ format: {
179
+ type: string;
180
+ };
181
+ allOf: {
182
+ $ref: string;
183
+ };
184
+ anyOf: {
185
+ $ref: string;
186
+ };
187
+ oneOf: {
188
+ $ref: string;
189
+ };
190
+ not: {
191
+ $ref: string;
192
+ };
193
+ };
194
+ default: {};
195
+ };
196
+ export declare const _draft7: {
197
+ $schema: string;
198
+ $id: string;
199
+ title: string;
200
+ definitions: {
201
+ schemaArray: {
202
+ type: string;
203
+ minItems: number;
204
+ items: {
205
+ $ref: string;
206
+ };
207
+ };
208
+ nonNegativeInteger: {
209
+ type: string;
210
+ minimum: number;
211
+ };
212
+ nonNegativeIntegerDefault0: {
213
+ allOf: ({
214
+ default?: undefined;
215
+ $ref: string;
216
+ } | {
217
+ default: number;
218
+ $ref?: undefined;
219
+ })[];
220
+ };
221
+ simpleTypes: {
222
+ enum: string[];
223
+ };
224
+ stringArray: {
225
+ type: string;
226
+ items: {
227
+ type: string;
228
+ };
229
+ uniqueItems: boolean;
230
+ default: never[];
231
+ };
232
+ };
233
+ type: string[];
234
+ properties: {
235
+ $id: {
236
+ type: string;
237
+ format: string;
238
+ pattern: string;
239
+ };
240
+ $schema: {
241
+ type: string;
242
+ format: string;
243
+ };
244
+ $ref: {
245
+ type: string;
246
+ format: string;
247
+ };
248
+ $comment: {
249
+ type: string;
250
+ };
251
+ title: {
252
+ type: string;
253
+ };
254
+ description: {
255
+ type: string;
256
+ };
257
+ default: boolean;
258
+ readOnly: {
259
+ type: string;
260
+ default: boolean;
261
+ };
262
+ examples: {
263
+ type: string;
264
+ items: boolean;
265
+ };
266
+ multipleOf: {
267
+ type: string;
268
+ exclusiveMinimum: number;
269
+ };
270
+ maximum: {
271
+ type: string;
272
+ };
273
+ exclusiveMaximum: {
274
+ type: string;
275
+ };
276
+ minimum: {
277
+ type: string;
278
+ };
279
+ exclusiveMinimum: {
280
+ type: string;
281
+ };
282
+ maxLength: {
283
+ $ref: string;
284
+ };
285
+ minLength: {
286
+ $ref: string;
287
+ };
288
+ pattern: {
289
+ type: string;
290
+ format: string;
291
+ };
292
+ additionalItems: {
293
+ $ref: string;
294
+ };
295
+ items: {
296
+ anyOf: {
297
+ $ref: string;
298
+ }[];
299
+ default: boolean;
300
+ };
301
+ maxItems: {
302
+ $ref: string;
303
+ };
304
+ minItems: {
305
+ $ref: string;
306
+ };
307
+ uniqueItems: {
308
+ type: string;
309
+ default: boolean;
310
+ };
311
+ contains: {
312
+ $ref: string;
313
+ };
314
+ maxProperties: {
315
+ $ref: string;
316
+ };
317
+ minProperties: {
318
+ $ref: string;
319
+ };
320
+ required: {
321
+ $ref: string;
322
+ };
323
+ additionalProperties: {
324
+ $ref: string;
325
+ };
326
+ definitions: {
327
+ type: string;
328
+ additionalProperties: {
329
+ $ref: string;
330
+ };
331
+ default: {};
332
+ };
333
+ properties: {
334
+ type: string;
335
+ additionalProperties: {
336
+ $ref: string;
337
+ };
338
+ default: {};
339
+ };
340
+ patternProperties: {
341
+ type: string;
342
+ additionalProperties: {
343
+ $ref: string;
344
+ };
345
+ propertyNames: {
346
+ format: string;
347
+ };
348
+ default: {};
349
+ };
350
+ dependencies: {
351
+ type: string;
352
+ additionalProperties: {
353
+ anyOf: {
354
+ $ref: string;
355
+ }[];
356
+ };
357
+ };
358
+ propertyNames: {
359
+ $ref: string;
360
+ };
361
+ const: boolean;
362
+ enum: {
363
+ type: string;
364
+ items: boolean;
365
+ minItems: number;
366
+ uniqueItems: boolean;
367
+ };
368
+ type: {
369
+ anyOf: ({
370
+ $ref: string;
371
+ type?: undefined;
372
+ items?: undefined;
373
+ minItems?: undefined;
374
+ uniqueItems?: undefined;
375
+ } | {
376
+ type: string;
377
+ items: {
378
+ $ref: string;
379
+ };
380
+ minItems: number;
381
+ uniqueItems: boolean;
382
+ $ref?: undefined;
383
+ })[];
384
+ };
385
+ format: {
386
+ type: string;
387
+ };
388
+ contentMediaType: {
389
+ type: string;
390
+ };
391
+ contentEncoding: {
392
+ type: string;
393
+ };
394
+ if: {
395
+ $ref: string;
396
+ };
397
+ then: {
398
+ $ref: string;
399
+ };
400
+ else: {
401
+ $ref: string;
402
+ };
403
+ allOf: {
404
+ $ref: string;
405
+ };
406
+ anyOf: {
407
+ $ref: string;
408
+ };
409
+ oneOf: {
410
+ $ref: string;
411
+ };
412
+ not: {
413
+ $ref: string;
414
+ };
415
+ };
416
+ default: boolean;
417
+ };