@hyperjump/json-schema 0.23.3 → 1.0.0
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 +1 -1
- package/README.md +459 -120
- package/draft-04/additionalItems.js +29 -0
- package/{lib/keywords → draft-04}/dependencies.js +9 -5
- package/draft-04/exclusiveMaximum.js +5 -0
- package/draft-04/exclusiveMinimum.js +5 -0
- package/draft-04/id.js +1 -0
- package/draft-04/index.d.ts +43 -0
- package/draft-04/index.js +69 -0
- package/draft-04/items.js +35 -0
- package/draft-04/maximum.js +26 -0
- package/draft-04/minimum.js +25 -0
- package/draft-04/ref.js +1 -0
- package/draft-04/schema.js +149 -0
- package/draft-06/contains.js +13 -0
- package/draft-06/index.d.ts +47 -0
- package/draft-06/index.js +66 -0
- package/draft-06/schema.js +154 -0
- package/{lib/draft-07.d.ts → draft-07/index.d.ts} +21 -19
- package/draft-07/index.js +72 -0
- package/draft-07/schema.js +172 -0
- package/{lib/keywords/contains-minContains-maxContains.js → draft-2019-09/contains.js} +14 -7
- package/{lib/draft-2019-09.d.ts → draft-2019-09/index.d.ts} +24 -22
- package/draft-2019-09/index.js +117 -0
- package/draft-2019-09/meta/applicator.js +55 -0
- package/draft-2019-09/meta/content.js +17 -0
- package/draft-2019-09/meta/core.js +57 -0
- package/draft-2019-09/meta/format.js +14 -0
- package/draft-2019-09/meta/meta-data.js +37 -0
- package/draft-2019-09/meta/validation.js +98 -0
- package/draft-2019-09/recursiveAnchor.js +1 -0
- package/draft-2019-09/recursiveRef.js +19 -0
- package/draft-2019-09/schema.js +42 -0
- package/draft-2020-12/dynamicAnchor.js +1 -0
- package/draft-2020-12/dynamicRef.js +35 -0
- package/draft-2020-12/index.d.ts +66 -0
- package/draft-2020-12/index.js +124 -0
- package/draft-2020-12/meta/applicator.js +46 -0
- package/draft-2020-12/meta/content.js +14 -0
- package/draft-2020-12/meta/core.js +54 -0
- package/draft-2020-12/meta/format-annotation.js +11 -0
- package/draft-2020-12/meta/format-assertion.js +11 -0
- package/draft-2020-12/meta/meta-data.js +34 -0
- package/draft-2020-12/meta/unevaluated.js +12 -0
- package/draft-2020-12/meta/validation.js +95 -0
- package/draft-2020-12/schema.js +44 -0
- package/lib/common.d.ts +5 -1
- package/lib/common.js +80 -9
- package/lib/configuration.d.ts +9 -0
- package/lib/configuration.js +18 -0
- package/lib/core.d.ts +48 -0
- package/lib/core.js +102 -0
- package/lib/experimental.d.ts +8 -0
- package/lib/experimental.js +4 -0
- package/lib/fetch.browser.js +1 -0
- package/lib/fetch.js +19 -0
- package/lib/index.d.ts +11 -42
- package/lib/index.js +130 -23
- package/lib/instance.d.ts +75 -0
- package/lib/instance.js +58 -0
- package/lib/invalid-schema-error.d.ts +8 -0
- package/lib/invalid-schema-error.js +7 -0
- package/lib/keywords/additionalProperties.js +19 -17
- package/lib/keywords/allOf.js +10 -7
- package/lib/keywords/anchor.js +1 -0
- package/lib/keywords/anyOf.js +10 -7
- package/lib/keywords/comment.js +4 -0
- package/lib/keywords/const.js +6 -3
- package/lib/keywords/contains.js +48 -5
- package/lib/keywords/contentEncoding.js +4 -0
- package/lib/keywords/contentMediaType.js +4 -0
- package/lib/keywords/contentSchema.js +4 -0
- package/lib/keywords/default.js +4 -0
- package/lib/keywords/definitions.js +7 -4
- package/lib/keywords/dependentRequired.js +6 -3
- package/lib/keywords/dependentSchemas.js +10 -6
- package/lib/keywords/deprecated.js +4 -0
- package/lib/keywords/description.js +4 -0
- package/lib/keywords/dynamicAnchor.js +1 -0
- package/lib/keywords/dynamicRef.js +13 -17
- package/lib/keywords/else.js +16 -11
- package/lib/keywords/enum.js +6 -3
- package/lib/keywords/examples.js +4 -0
- package/lib/keywords/exclusiveMaximum.js +5 -2
- package/lib/keywords/exclusiveMinimum.js +5 -2
- package/lib/keywords/format.js +4 -0
- package/lib/keywords/id.js +1 -0
- package/lib/keywords/if.js +8 -6
- package/lib/keywords/items.js +17 -19
- package/lib/keywords/maxContains.js +4 -0
- package/lib/keywords/maxItems.js +5 -2
- package/lib/keywords/maxLength.js +5 -2
- package/lib/keywords/maxProperties.js +5 -2
- package/lib/keywords/maximum.js +5 -2
- package/lib/keywords/meta-data.js +4 -0
- package/lib/keywords/minContains.js +4 -0
- package/lib/keywords/minItems.js +5 -2
- package/lib/keywords/minLength.js +5 -2
- package/lib/keywords/minProperties.js +5 -2
- package/lib/keywords/minimum.js +5 -2
- package/lib/keywords/multipleOf.js +5 -2
- package/lib/keywords/not.js +6 -4
- package/lib/keywords/oneOf.js +9 -6
- package/lib/keywords/pattern.js +5 -2
- package/lib/keywords/patternProperties.js +9 -5
- package/lib/keywords/prefixItems.js +28 -0
- package/lib/keywords/properties.js +11 -6
- package/lib/keywords/propertyDependencies.js +49 -0
- package/lib/keywords/propertyNames.js +7 -4
- package/lib/keywords/readOnly.js +4 -0
- package/lib/keywords/ref.js +9 -6
- package/lib/keywords/requireAllExcept.js +24 -0
- package/lib/keywords/required.js +5 -2
- package/lib/keywords/then.js +16 -11
- package/lib/keywords/title.js +4 -0
- package/lib/keywords/type.js +5 -2
- package/lib/keywords/unevaluatedItems.js +9 -5
- package/lib/keywords/unevaluatedProperties.js +9 -5
- package/lib/keywords/uniqueItems.js +6 -3
- package/lib/keywords/validation.js +123 -0
- package/lib/keywords/vocabulary.js +1 -0
- package/lib/keywords/writeOnly.js +4 -0
- package/lib/keywords.d.ts +19 -0
- package/lib/keywords.js +59 -0
- package/lib/media-types.d.ts +9 -0
- package/lib/media-types.js +26 -0
- package/lib/pubsub.js +42 -0
- package/lib/reference.d.ts +11 -0
- package/lib/reference.js +11 -0
- package/lib/schema.d.ts +64 -0
- package/lib/schema.js +308 -0
- package/package.json +31 -22
- package/{lib/draft-2020-12.d.ts → stable/index.d.ts} +26 -24
- package/stable/index.js +118 -0
- package/stable/meta/applicator.js +49 -0
- package/stable/meta/content.js +12 -0
- package/stable/meta/core.js +49 -0
- package/stable/meta/format-annotation.js +10 -0
- package/stable/meta/format-assertion.js +10 -0
- package/stable/meta/meta-data.js +16 -0
- package/stable/meta/unevaluated.js +11 -0
- package/stable/meta/validation.js +67 -0
- package/stable/validation.js +24 -0
- package/dist/json-schema-amd.js +0 -6602
- package/dist/json-schema-amd.js.map +0 -1
- package/dist/json-schema-amd.min.js +0 -3
- package/dist/json-schema-amd.min.js.map +0 -1
- package/dist/json-schema-cjs.js +0 -6600
- package/dist/json-schema-cjs.js.map +0 -1
- package/dist/json-schema-cjs.min.js +0 -3
- package/dist/json-schema-cjs.min.js.map +0 -1
- package/dist/json-schema-esm.js +0 -6596
- package/dist/json-schema-esm.js.map +0 -1
- package/dist/json-schema-esm.min.js +0 -3
- package/dist/json-schema-esm.min.js.map +0 -1
- package/dist/json-schema-iife.js +0 -6605
- package/dist/json-schema-iife.js.map +0 -1
- package/dist/json-schema-iife.min.js +0 -3
- package/dist/json-schema-iife.min.js.map +0 -1
- package/dist/json-schema-system.js +0 -6603
- package/dist/json-schema-system.js.map +0 -1
- package/dist/json-schema-system.min.js +0 -3
- package/dist/json-schema-system.min.js.map +0 -1
- package/dist/json-schema-umd.js +0 -6606
- package/dist/json-schema-umd.js.map +0 -1
- package/dist/json-schema-umd.min.js +0 -3
- package/dist/json-schema-umd.min.js.map +0 -1
- package/lib/draft-04.d.ts +0 -41
- package/lib/draft-04.js +0 -46
- package/lib/draft-06.d.ts +0 -45
- package/lib/draft-06.js +0 -51
- package/lib/draft-07.js +0 -55
- package/lib/draft-2019-09.js +0 -92
- package/lib/draft-2020-12.js +0 -103
- package/lib/index.mjs +0 -19
- package/lib/keywords/additionalItems.js +0 -27
- package/lib/keywords/additionalItems6.js +0 -23
- package/lib/keywords/additionalProperties6.js +0 -28
- package/lib/keywords/index.js +0 -53
- package/lib/keywords/items202012.js +0 -23
- package/lib/keywords/maximum-exclusiveMaximum.js +0 -20
- package/lib/keywords/minimum-exclusiveMinimum.js +0 -20
- package/lib/keywords/tupleItems.js +0 -24
- package/meta/draft/2019-09/meta/applicator.js +0 -55
- package/meta/draft/2019-09/meta/content.js +0 -17
- package/meta/draft/2019-09/meta/core.js +0 -57
- package/meta/draft/2019-09/meta/format.js +0 -14
- package/meta/draft/2019-09/meta/meta-data.js +0 -37
- package/meta/draft/2019-09/meta/validation.js +0 -98
- package/meta/draft/2019-09/schema.js +0 -42
- package/meta/draft/2020-12/meta/applicator.js +0 -49
- package/meta/draft/2020-12/meta/content.js +0 -17
- package/meta/draft/2020-12/meta/core.js +0 -57
- package/meta/draft/2020-12/meta/format-annotation.js +0 -14
- package/meta/draft/2020-12/meta/format-assertion.js +0 -14
- package/meta/draft/2020-12/meta/meta-data.js +0 -37
- package/meta/draft/2020-12/meta/unevaluated.js +0 -15
- package/meta/draft/2020-12/meta/validation.js +0 -98
- package/meta/draft/2020-12/schema.js +0 -44
- package/meta/draft-04/schema.js +0 -149
- package/meta/draft-06/schema.js +0 -154
- package/meta/draft-07/schema.js +0 -172
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { addKeyword, defineVocabulary, loadDialect } from "../lib/keywords.js";
|
|
2
|
+
import { addSchema } from "../lib/core.js";
|
|
3
|
+
|
|
4
|
+
import metaSchema from "./schema.js";
|
|
5
|
+
import coreMetaSchema from "./meta/core.js";
|
|
6
|
+
import applicatorMetaSchema from "./meta/applicator.js";
|
|
7
|
+
import validationMetaSchema from "./meta/validation.js";
|
|
8
|
+
import metaDataMetaSchema from "./meta/meta-data.js";
|
|
9
|
+
import formatAnnotationMetaSchema from "./meta/format-annotation.js";
|
|
10
|
+
import formatAssertionMetaSchema from "./meta/format-assertion.js";
|
|
11
|
+
import contentMetaSchema from "./meta/content.js";
|
|
12
|
+
import unevaluatedMetaSchema from "./meta/unevaluated.js";
|
|
13
|
+
|
|
14
|
+
import contains from "../draft-2019-09/contains.js";
|
|
15
|
+
import dynamicAnchor from "./dynamicAnchor.js";
|
|
16
|
+
import dynamicRef from "./dynamicRef.js";
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
addKeyword(contains);
|
|
20
|
+
addKeyword(dynamicRef);
|
|
21
|
+
addKeyword(dynamicAnchor);
|
|
22
|
+
|
|
23
|
+
defineVocabulary("https://json-schema.org/draft/2020-12/vocab/core", {
|
|
24
|
+
"$anchor": "https://json-schema.org/keyword/anchor",
|
|
25
|
+
"$comment": "https://json-schema.org/keyword/comment",
|
|
26
|
+
"$defs": "https://json-schema.org/keyword/definitions",
|
|
27
|
+
"$dynamicAnchor": "https://json-schema.org/keyword/draft-2020-12/dynamicAnchor",
|
|
28
|
+
"$dynamicRef": "https://json-schema.org/keyword/draft-2020-12/dynamicRef",
|
|
29
|
+
"$id": "https://json-schema.org/keyword/id",
|
|
30
|
+
"$ref": "https://json-schema.org/keyword/ref",
|
|
31
|
+
"$vocabulary": "https://json-schema.org/keyword/vocabulary"
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
defineVocabulary("https://json-schema.org/draft/2020-12/vocab/applicator", {
|
|
35
|
+
"additionalProperties": "https://json-schema.org/keyword/additionalProperties",
|
|
36
|
+
"allOf": "https://json-schema.org/keyword/allOf",
|
|
37
|
+
"anyOf": "https://json-schema.org/keyword/anyOf",
|
|
38
|
+
"contains": "https://json-schema.org/keyword/draft-2019-09/contains",
|
|
39
|
+
"dependentSchemas": "https://json-schema.org/keyword/dependentSchemas",
|
|
40
|
+
"if": "https://json-schema.org/keyword/if",
|
|
41
|
+
"then": "https://json-schema.org/keyword/then",
|
|
42
|
+
"else": "https://json-schema.org/keyword/else",
|
|
43
|
+
"items": "https://json-schema.org/keyword/items",
|
|
44
|
+
"not": "https://json-schema.org/keyword/not",
|
|
45
|
+
"oneOf": "https://json-schema.org/keyword/oneOf",
|
|
46
|
+
"patternProperties": "https://json-schema.org/keyword/patternProperties",
|
|
47
|
+
"prefixItems": "https://json-schema.org/keyword/prefixItems",
|
|
48
|
+
"properties": "https://json-schema.org/keyword/properties",
|
|
49
|
+
"propertyNames": "https://json-schema.org/keyword/propertyNames"
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
defineVocabulary("https://json-schema.org/draft/2020-12/vocab/validation", {
|
|
53
|
+
"const": "https://json-schema.org/keyword/const",
|
|
54
|
+
"dependentRequired": "https://json-schema.org/keyword/dependentRequired",
|
|
55
|
+
"enum": "https://json-schema.org/keyword/enum",
|
|
56
|
+
"exclusiveMaximum": "https://json-schema.org/keyword/exclusiveMaximum",
|
|
57
|
+
"exclusiveMinimum": "https://json-schema.org/keyword/exclusiveMinimum",
|
|
58
|
+
"maxContains": "https://json-schema.org/keyword/maxContains",
|
|
59
|
+
"maxItems": "https://json-schema.org/keyword/maxItems",
|
|
60
|
+
"maxLength": "https://json-schema.org/keyword/maxLength",
|
|
61
|
+
"maxProperties": "https://json-schema.org/keyword/maxProperties",
|
|
62
|
+
"maximum": "https://json-schema.org/keyword/maximum",
|
|
63
|
+
"minContains": "https://json-schema.org/keyword/minContains",
|
|
64
|
+
"minItems": "https://json-schema.org/keyword/minItems",
|
|
65
|
+
"minLength": "https://json-schema.org/keyword/minLength",
|
|
66
|
+
"minProperties": "https://json-schema.org/keyword/minProperties",
|
|
67
|
+
"minimum": "https://json-schema.org/keyword/minimum",
|
|
68
|
+
"multipleOf": "https://json-schema.org/keyword/multipleOf",
|
|
69
|
+
"pattern": "https://json-schema.org/keyword/pattern",
|
|
70
|
+
"required": "https://json-schema.org/keyword/required",
|
|
71
|
+
"type": "https://json-schema.org/keyword/type",
|
|
72
|
+
"uniqueItems": "https://json-schema.org/keyword/uniqueItems"
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
defineVocabulary("https://json-schema.org/draft/2020-12/vocab/meta-data", {
|
|
76
|
+
"default": "https://json-schema.org/keyword/default",
|
|
77
|
+
"deprecated": "https://json-schema.org/keyword/deprecated",
|
|
78
|
+
"description": "https://json-schema.org/keyword/description",
|
|
79
|
+
"examples": "https://json-schema.org/keyword/examples",
|
|
80
|
+
"readOnly": "https://json-schema.org/keyword/readOnly",
|
|
81
|
+
"title": "https://json-schema.org/keyword/title",
|
|
82
|
+
"writeOnly": "https://json-schema.org/keyword/writeOnly"
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
defineVocabulary("https://json-schema.org/draft/2020-12/vocab/format-annotation", {
|
|
86
|
+
"format": "https://json-schema.org/keyword/format"
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
defineVocabulary("https://json-schema.org/draft/2020-12/vocab/format-assertion", {
|
|
90
|
+
"format": "https://json-schema.org/keyword/format-assertion"
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
defineVocabulary("https://json-schema.org/draft/2020-12/vocab/content", {
|
|
94
|
+
"contentEncoding": "https://json-schema.org/keyword/contentEncoding",
|
|
95
|
+
"contentMediaType": "https://json-schema.org/keyword/contentMediaType",
|
|
96
|
+
"contentSchema": "https://json-schema.org/keyword/contentSchema"
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
defineVocabulary("https://json-schema.org/draft/2020-12/vocab/unevaluated", {
|
|
100
|
+
"unevaluatedItems": "https://json-schema.org/keyword/unevaluatedItems",
|
|
101
|
+
"unevaluatedProperties": "https://json-schema.org/keyword/unevaluatedProperties"
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
loadDialect("https://json-schema.org/draft/2020-12/schema", {
|
|
105
|
+
"https://json-schema.org/draft/2020-12/vocab/core": true,
|
|
106
|
+
"https://json-schema.org/draft/2020-12/vocab/applicator": true,
|
|
107
|
+
"https://json-schema.org/draft/2020-12/vocab/validation": true,
|
|
108
|
+
"https://json-schema.org/draft/2020-12/vocab/meta-data": true,
|
|
109
|
+
"https://json-schema.org/draft/2020-12/vocab/format-annotation": true,
|
|
110
|
+
"https://json-schema.org/draft/2020-12/vocab/content": true,
|
|
111
|
+
"https://json-schema.org/draft/2020-12/vocab/unevaluated": true
|
|
112
|
+
}, true);
|
|
113
|
+
|
|
114
|
+
addSchema(metaSchema);
|
|
115
|
+
addSchema(coreMetaSchema);
|
|
116
|
+
addSchema(applicatorMetaSchema);
|
|
117
|
+
addSchema(validationMetaSchema);
|
|
118
|
+
addSchema(metaDataMetaSchema);
|
|
119
|
+
addSchema(formatAnnotationMetaSchema);
|
|
120
|
+
addSchema(formatAssertionMetaSchema);
|
|
121
|
+
addSchema(contentMetaSchema);
|
|
122
|
+
addSchema(unevaluatedMetaSchema);
|
|
123
|
+
|
|
124
|
+
export * from "../lib/index.js";
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"$id": "https://json-schema.org/draft/2020-12/meta/applicator",
|
|
3
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
4
|
+
"$dynamicAnchor": "meta",
|
|
5
|
+
|
|
6
|
+
"title": "Applicator vocabulary meta-schema",
|
|
7
|
+
"type": ["object", "boolean"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"prefixItems": { "$ref": "#/$defs/schemaArray" },
|
|
10
|
+
"items": { "$dynamicRef": "#meta" },
|
|
11
|
+
"contains": { "$dynamicRef": "#meta" },
|
|
12
|
+
"additionalProperties": { "$dynamicRef": "#meta" },
|
|
13
|
+
"properties": {
|
|
14
|
+
"type": "object",
|
|
15
|
+
"additionalProperties": { "$dynamicRef": "#meta" },
|
|
16
|
+
"default": {}
|
|
17
|
+
},
|
|
18
|
+
"patternProperties": {
|
|
19
|
+
"type": "object",
|
|
20
|
+
"additionalProperties": { "$dynamicRef": "#meta" },
|
|
21
|
+
"propertyNames": { "format": "regex" },
|
|
22
|
+
"default": {}
|
|
23
|
+
},
|
|
24
|
+
"dependentSchemas": {
|
|
25
|
+
"type": "object",
|
|
26
|
+
"additionalProperties": {
|
|
27
|
+
"$dynamicRef": "#meta"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"propertyNames": { "$dynamicRef": "#meta" },
|
|
31
|
+
"if": { "$dynamicRef": "#meta" },
|
|
32
|
+
"then": { "$dynamicRef": "#meta" },
|
|
33
|
+
"else": { "$dynamicRef": "#meta" },
|
|
34
|
+
"allOf": { "$ref": "#/$defs/schemaArray" },
|
|
35
|
+
"anyOf": { "$ref": "#/$defs/schemaArray" },
|
|
36
|
+
"oneOf": { "$ref": "#/$defs/schemaArray" },
|
|
37
|
+
"not": { "$dynamicRef": "#meta" }
|
|
38
|
+
},
|
|
39
|
+
"$defs": {
|
|
40
|
+
"schemaArray": {
|
|
41
|
+
"type": "array",
|
|
42
|
+
"minItems": 1,
|
|
43
|
+
"items": { "$dynamicRef": "#meta" }
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"$id": "https://json-schema.org/draft/2020-12/meta/content",
|
|
3
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
4
|
+
"$dynamicAnchor": "meta",
|
|
5
|
+
|
|
6
|
+
"title": "Content vocabulary meta-schema",
|
|
7
|
+
|
|
8
|
+
"type": ["object", "boolean"],
|
|
9
|
+
"properties": {
|
|
10
|
+
"contentMediaType": { "type": "string" },
|
|
11
|
+
"contentEncoding": { "type": "string" },
|
|
12
|
+
"contentSchema": { "$dynamicRef": "#meta" }
|
|
13
|
+
}
|
|
14
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"$id": "https://json-schema.org/draft/2020-12/meta/core",
|
|
3
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
4
|
+
"$dynamicAnchor": "meta",
|
|
5
|
+
|
|
6
|
+
"title": "Core vocabulary meta-schema",
|
|
7
|
+
"type": ["object", "boolean"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"$id": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"format": "uri-reference",
|
|
12
|
+
"$comment": "Non-empty fragments not allowed.",
|
|
13
|
+
"pattern": "^[^#]*#?$"
|
|
14
|
+
},
|
|
15
|
+
"$schema": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"format": "uri"
|
|
18
|
+
},
|
|
19
|
+
"$anchor": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"pattern": "^[A-Za-z_][-A-Za-z0-9._]*$"
|
|
22
|
+
},
|
|
23
|
+
"$ref": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"format": "uri-reference"
|
|
26
|
+
},
|
|
27
|
+
"$dynamicRef": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"format": "uri-reference"
|
|
30
|
+
},
|
|
31
|
+
"$dynamicAnchor": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"pattern": "^[A-Za-z_][-A-Za-z0-9._]*$"
|
|
34
|
+
},
|
|
35
|
+
"$vocabulary": {
|
|
36
|
+
"type": "object",
|
|
37
|
+
"propertyNames": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"format": "uri"
|
|
40
|
+
},
|
|
41
|
+
"additionalProperties": {
|
|
42
|
+
"type": "boolean"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"$comment": {
|
|
46
|
+
"type": "string"
|
|
47
|
+
},
|
|
48
|
+
"$defs": {
|
|
49
|
+
"type": "object",
|
|
50
|
+
"additionalProperties": { "$dynamicRef": "#meta" },
|
|
51
|
+
"default": {}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"$id": "https://json-schema.org/draft/2020-12/meta/format-annotation",
|
|
3
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
4
|
+
"$dynamicAnchor": "meta",
|
|
5
|
+
|
|
6
|
+
"title": "Format vocabulary meta-schema for annotation results",
|
|
7
|
+
"type": ["object", "boolean"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"format": { "type": "string" }
|
|
10
|
+
}
|
|
11
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"$id": "https://json-schema.org/draft/2020-12/meta/format-assertion",
|
|
3
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
4
|
+
"$dynamicAnchor": "meta",
|
|
5
|
+
|
|
6
|
+
"title": "Format vocabulary meta-schema for assertion results",
|
|
7
|
+
"type": ["object", "boolean"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"format": { "type": "string" }
|
|
10
|
+
}
|
|
11
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"$id": "https://json-schema.org/draft/2020-12/meta/meta-data",
|
|
3
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
4
|
+
"$dynamicAnchor": "meta",
|
|
5
|
+
|
|
6
|
+
"title": "Meta-data vocabulary meta-schema",
|
|
7
|
+
|
|
8
|
+
"type": ["object", "boolean"],
|
|
9
|
+
"properties": {
|
|
10
|
+
"title": {
|
|
11
|
+
"type": "string"
|
|
12
|
+
},
|
|
13
|
+
"description": {
|
|
14
|
+
"type": "string"
|
|
15
|
+
},
|
|
16
|
+
"default": true,
|
|
17
|
+
"deprecated": {
|
|
18
|
+
"type": "boolean",
|
|
19
|
+
"default": false
|
|
20
|
+
},
|
|
21
|
+
"readOnly": {
|
|
22
|
+
"type": "boolean",
|
|
23
|
+
"default": false
|
|
24
|
+
},
|
|
25
|
+
"writeOnly": {
|
|
26
|
+
"type": "boolean",
|
|
27
|
+
"default": false
|
|
28
|
+
},
|
|
29
|
+
"examples": {
|
|
30
|
+
"type": "array",
|
|
31
|
+
"items": true
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"$id": "https://json-schema.org/draft/2020-12/meta/unevaluated",
|
|
3
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
4
|
+
"$dynamicAnchor": "meta",
|
|
5
|
+
|
|
6
|
+
"title": "Unevaluated applicator vocabulary meta-schema",
|
|
7
|
+
"type": ["object", "boolean"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"unevaluatedItems": { "$dynamicRef": "#meta" },
|
|
10
|
+
"unevaluatedProperties": { "$dynamicRef": "#meta" }
|
|
11
|
+
}
|
|
12
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"$id": "https://json-schema.org/draft/2020-12/meta/validation",
|
|
3
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
4
|
+
"$dynamicAnchor": "meta",
|
|
5
|
+
|
|
6
|
+
"title": "Validation vocabulary meta-schema",
|
|
7
|
+
"type": ["object", "boolean"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"multipleOf": {
|
|
10
|
+
"type": "number",
|
|
11
|
+
"exclusiveMinimum": 0
|
|
12
|
+
},
|
|
13
|
+
"maximum": {
|
|
14
|
+
"type": "number"
|
|
15
|
+
},
|
|
16
|
+
"exclusiveMaximum": {
|
|
17
|
+
"type": "number"
|
|
18
|
+
},
|
|
19
|
+
"minimum": {
|
|
20
|
+
"type": "number"
|
|
21
|
+
},
|
|
22
|
+
"exclusiveMinimum": {
|
|
23
|
+
"type": "number"
|
|
24
|
+
},
|
|
25
|
+
"maxLength": { "$ref": "#/$defs/nonNegativeInteger" },
|
|
26
|
+
"minLength": { "$ref": "#/$defs/nonNegativeIntegerDefault0" },
|
|
27
|
+
"pattern": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"format": "regex"
|
|
30
|
+
},
|
|
31
|
+
"maxItems": { "$ref": "#/$defs/nonNegativeInteger" },
|
|
32
|
+
"minItems": { "$ref": "#/$defs/nonNegativeIntegerDefault0" },
|
|
33
|
+
"uniqueItems": {
|
|
34
|
+
"type": "boolean",
|
|
35
|
+
"default": false
|
|
36
|
+
},
|
|
37
|
+
"maxContains": { "$ref": "#/$defs/nonNegativeInteger" },
|
|
38
|
+
"minContains": {
|
|
39
|
+
"$ref": "#/$defs/nonNegativeInteger",
|
|
40
|
+
"default": 1
|
|
41
|
+
},
|
|
42
|
+
"maxProperties": { "$ref": "#/$defs/nonNegativeInteger" },
|
|
43
|
+
"minProperties": { "$ref": "#/$defs/nonNegativeIntegerDefault0" },
|
|
44
|
+
"required": { "$ref": "#/$defs/stringArray" },
|
|
45
|
+
"dependentRequired": {
|
|
46
|
+
"type": "object",
|
|
47
|
+
"additionalProperties": {
|
|
48
|
+
"$ref": "#/$defs/stringArray"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"const": true,
|
|
52
|
+
"enum": {
|
|
53
|
+
"type": "array",
|
|
54
|
+
"items": true
|
|
55
|
+
},
|
|
56
|
+
"type": {
|
|
57
|
+
"anyOf": [
|
|
58
|
+
{ "$ref": "#/$defs/simpleTypes" },
|
|
59
|
+
{
|
|
60
|
+
"type": "array",
|
|
61
|
+
"items": { "$ref": "#/$defs/simpleTypes" },
|
|
62
|
+
"minItems": 1,
|
|
63
|
+
"uniqueItems": true
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"$defs": {
|
|
69
|
+
"nonNegativeInteger": {
|
|
70
|
+
"type": "integer",
|
|
71
|
+
"minimum": 0
|
|
72
|
+
},
|
|
73
|
+
"nonNegativeIntegerDefault0": {
|
|
74
|
+
"$ref": "#/$defs/nonNegativeInteger",
|
|
75
|
+
"default": 0
|
|
76
|
+
},
|
|
77
|
+
"simpleTypes": {
|
|
78
|
+
"enum": [
|
|
79
|
+
"array",
|
|
80
|
+
"boolean",
|
|
81
|
+
"integer",
|
|
82
|
+
"null",
|
|
83
|
+
"number",
|
|
84
|
+
"object",
|
|
85
|
+
"string"
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
"stringArray": {
|
|
89
|
+
"type": "array",
|
|
90
|
+
"items": { "type": "string" },
|
|
91
|
+
"uniqueItems": true,
|
|
92
|
+
"default": []
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://json-schema.org/draft/2020-12/schema",
|
|
4
|
+
"$vocabulary": {
|
|
5
|
+
"https://json-schema.org/draft/2020-12/vocab/core": true,
|
|
6
|
+
"https://json-schema.org/draft/2020-12/vocab/applicator": true,
|
|
7
|
+
"https://json-schema.org/draft/2020-12/vocab/unevaluated": true,
|
|
8
|
+
"https://json-schema.org/draft/2020-12/vocab/validation": true,
|
|
9
|
+
"https://json-schema.org/draft/2020-12/vocab/meta-data": true,
|
|
10
|
+
"https://json-schema.org/draft/2020-12/vocab/format-annotation": true,
|
|
11
|
+
"https://json-schema.org/draft/2020-12/vocab/content": true
|
|
12
|
+
},
|
|
13
|
+
"$dynamicAnchor": "meta",
|
|
14
|
+
|
|
15
|
+
"title": "Core and Validation specifications meta-schema",
|
|
16
|
+
"allOf": [
|
|
17
|
+
{ "$ref": "meta/core" },
|
|
18
|
+
{ "$ref": "meta/applicator" },
|
|
19
|
+
{ "$ref": "meta/unevaluated" },
|
|
20
|
+
{ "$ref": "meta/validation" },
|
|
21
|
+
{ "$ref": "meta/meta-data" },
|
|
22
|
+
{ "$ref": "meta/format-annotation" },
|
|
23
|
+
{ "$ref": "meta/content" }
|
|
24
|
+
],
|
|
25
|
+
"type": ["object", "boolean"],
|
|
26
|
+
"properties": {
|
|
27
|
+
"definitions": {
|
|
28
|
+
"$comment": "While no longer an official keyword as it is replaced by $defs, this keyword is retained in the meta-schema to prevent incompatible extensions as it remains in common use.",
|
|
29
|
+
"type": "object",
|
|
30
|
+
"additionalProperties": { "$dynamicRef": "#meta" },
|
|
31
|
+
"default": {}
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"$comment": "\"dependencies\" is no longer a keyword, but schema authors should avoid redefining it to facilitate a smooth transition to \"dependentSchemas\" and \"dependentRequired\"",
|
|
35
|
+
"type": "object",
|
|
36
|
+
"additionalProperties": {
|
|
37
|
+
"anyOf": [
|
|
38
|
+
{ "$dynamicRef": "#meta" },
|
|
39
|
+
{ "$ref": "meta/validation#/$defs/stringArray" }
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
package/lib/common.d.ts
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type JsonType = "object" | "array" | "string" | "number" | "boolean" | "null";
|
|
2
|
+
export type JsonSchemaType = JsonType | "integer";
|
|
3
|
+
|
|
4
|
+
type PathRelative = (from: string, to: string) => string;
|
|
5
|
+
export const pathRelative: PathRelative;
|
package/lib/common.js
CHANGED
|
@@ -1,13 +1,84 @@
|
|
|
1
1
|
const isObject = (value) => typeof value === "object" && !Array.isArray(value) && value !== null;
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
const isType = {
|
|
3
|
+
null: (value) => value === null,
|
|
4
|
+
boolean: (value) => typeof value === "boolean",
|
|
5
|
+
object: isObject,
|
|
6
|
+
array: (value) => Array.isArray(value),
|
|
7
|
+
number: (value) => typeof value === "number",
|
|
8
|
+
integer: (value) => Number.isInteger(value),
|
|
9
|
+
string: (value) => typeof value === "string"
|
|
10
|
+
};
|
|
11
|
+
export const jsonTypeOf = (value, type) => isType[type](value);
|
|
9
12
|
|
|
10
|
-
|
|
13
|
+
export const resolveUrl = (url, baseUri = undefined) => {
|
|
14
|
+
const resolved = new URL(url, baseUri);
|
|
15
|
+
if (baseUri && new URL("", baseUri).protocol !== "file:" && resolved.protocol === "file:") {
|
|
16
|
+
throw Error(`Can't access file '${resolved.href}' resource from network context '${baseUri}'`);
|
|
17
|
+
}
|
|
18
|
+
return resolved.href;
|
|
11
19
|
};
|
|
12
20
|
|
|
13
|
-
|
|
21
|
+
export const urlFragment = (url) => decodeURIComponent(new URL(url).hash.slice(1));
|
|
22
|
+
|
|
23
|
+
const CHAR_BACKWARD_SLASH = 47;
|
|
24
|
+
|
|
25
|
+
export const pathRelative = (from, to) => {
|
|
26
|
+
if (from === to) {
|
|
27
|
+
return "";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let toStart = 1;
|
|
31
|
+
const fromLen = from.length - 1;
|
|
32
|
+
const toLen = to.length - toStart;
|
|
33
|
+
|
|
34
|
+
// Compare paths to find the longest common path from root
|
|
35
|
+
const length = fromLen < toLen ? fromLen : toLen;
|
|
36
|
+
let lastCommonSep = -1;
|
|
37
|
+
let i = 0;
|
|
38
|
+
for (; i < length; i++) {
|
|
39
|
+
const fromCode = from.charCodeAt(i + 1);
|
|
40
|
+
if (fromCode !== to.charCodeAt(toStart + i)) {
|
|
41
|
+
break;
|
|
42
|
+
} else if (fromCode === CHAR_BACKWARD_SLASH) {
|
|
43
|
+
lastCommonSep = i;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (toLen > length) {
|
|
48
|
+
if (to.charCodeAt(toStart + i) === CHAR_BACKWARD_SLASH) {
|
|
49
|
+
return to.slice(toStart + i + 1);
|
|
50
|
+
}
|
|
51
|
+
if (i === 0) {
|
|
52
|
+
return to.slice(toStart + i);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (fromLen > length) {
|
|
56
|
+
if (from.charCodeAt(i + 1) === CHAR_BACKWARD_SLASH) {
|
|
57
|
+
lastCommonSep = i;
|
|
58
|
+
} else if (length === 0) {
|
|
59
|
+
lastCommonSep = 0;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
let out = "";
|
|
64
|
+
// Generate the relative path based on the path difference between `to` and `from`
|
|
65
|
+
for (i = lastCommonSep + 2; i <= from.length; ++i) {
|
|
66
|
+
if (i === from.length || from.charCodeAt(i) === CHAR_BACKWARD_SLASH) {
|
|
67
|
+
out += out.length === 0 ? ".." : "/..";
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
toStart += lastCommonSep;
|
|
72
|
+
|
|
73
|
+
// Lastly, append the rest of the destination (`to`) path that comes after
|
|
74
|
+
// the common path parts
|
|
75
|
+
if (out.length > 0) {
|
|
76
|
+
return `${out}${to.slice(toStart, to.length)}`;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (to.charCodeAt(toStart) === CHAR_BACKWARD_SLASH) {
|
|
80
|
+
++toStart;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return to.slice(toStart, to.length);
|
|
84
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { OutputFormat } from "./core.js";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export const setMetaSchemaOutputFormat: (format: OutputFormat) => void;
|
|
5
|
+
export const getMetaSchemaOutputFormat: () => OutputFormat;
|
|
6
|
+
export const setShouldValidateSchema: (isEnabled: boolean) => void;
|
|
7
|
+
export const getShouldValidateSchema: () => boolean;
|
|
8
|
+
export const setExperimentalKeywordEnabled: (keywordId: string, isEnabled: boolean) => void;
|
|
9
|
+
export const isExperimentalKeywordEnabled: (keywordId: string) => boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
let metaSchemaOutputFormat;
|
|
2
|
+
let shouldValidateSchema = true;
|
|
3
|
+
let enabledExperimentalKeywords = {};
|
|
4
|
+
|
|
5
|
+
export const getMetaSchemaOutputFormat = () => metaSchemaOutputFormat;
|
|
6
|
+
export const setMetaSchemaOutputFormat = (format) => {
|
|
7
|
+
metaSchemaOutputFormat = format;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const getShouldValidateSchema = () => shouldValidateSchema;
|
|
11
|
+
export const setShouldValidateSchema = (isEnabled) => {
|
|
12
|
+
shouldValidateSchema = isEnabled;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const isExperimentalKeywordEnabled = (keywordId) => enabledExperimentalKeywords[keywordId];
|
|
16
|
+
export const setExperimentalKeywordEnabled = (keywordId, isEnabled) => {
|
|
17
|
+
enabledExperimentalKeywords[keywordId] = isEnabled;
|
|
18
|
+
};
|
package/lib/core.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { add, Anchors } from "./schema.js";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export const validate: (
|
|
5
|
+
(url: string, value: unknown, outputFormat?: OutputFormat) => Promise<OutputUnit>
|
|
6
|
+
) & (
|
|
7
|
+
(url: string) => Promise<Validator>
|
|
8
|
+
);
|
|
9
|
+
export const compile: (url: string) => Promise<CompiledSchema>;
|
|
10
|
+
export const interpret: (
|
|
11
|
+
(compiledSchema: CompiledSchema, value: unknown, outputFormat?: OutputFormat) => OutputUnit
|
|
12
|
+
) & (
|
|
13
|
+
(compiledSchema: CompiledSchema) => Validator
|
|
14
|
+
);
|
|
15
|
+
export const FLAG: "FLAG";
|
|
16
|
+
export const BASIC: "BASIC";
|
|
17
|
+
export const DETAILED: "DETAILED";
|
|
18
|
+
export const VERBOSE: "VERBOSE";
|
|
19
|
+
export const addSchema: typeof add;
|
|
20
|
+
|
|
21
|
+
export type Validator = (value: unknown, outputFormat?: OutputFormat) => OutputUnit;
|
|
22
|
+
|
|
23
|
+
export type OutputFormat = "FLAG" | "BASIC" | "DETAILED" | "VERBOSE" | string;
|
|
24
|
+
|
|
25
|
+
export type OutputUnit = {
|
|
26
|
+
keyword: string;
|
|
27
|
+
absoluteKeywordLocation: string;
|
|
28
|
+
instanceLocation: string;
|
|
29
|
+
valid: boolean;
|
|
30
|
+
errors?: OutputUnit[];
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type CompiledSchema = {
|
|
34
|
+
schemaUri: string;
|
|
35
|
+
ast: AST;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
type AST = {
|
|
39
|
+
metaData: Record<string, MetaData>;
|
|
40
|
+
} & Record<string, Node<Node<unknown>[] | boolean>>;
|
|
41
|
+
|
|
42
|
+
type Node<A> = [keywordId: string, schemaUri: string, keywordValue: A];
|
|
43
|
+
|
|
44
|
+
type MetaData = {
|
|
45
|
+
id: string;
|
|
46
|
+
dynamicAnchors: Anchors;
|
|
47
|
+
anchors: Anchors;
|
|
48
|
+
};
|