@hyperjump/json-schema 0.18.0 → 0.18.4

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/lib/draft-04.js CHANGED
@@ -1,7 +1,6 @@
1
1
  const { Core, Schema } = require("@hyperjump/json-schema-core");
2
2
  const keywords = require("./keywords");
3
3
  const metaSchema = require("../meta/draft-04/schema");
4
- const metaHyperSchema = require("../meta/draft-04/hyper-schema");
5
4
 
6
5
 
7
6
  // JSON Schema Draft-04
@@ -45,50 +44,3 @@ Core.defineVocabulary(schemaVersion, {
45
44
  "type": keywords.type,
46
45
  "uniqueItems": keywords.uniqueItems
47
46
  });
48
-
49
- // JSON Hyper-Schema Draft-04
50
- const hyperSchemaVersion = "http://json-schema.org/draft-04/hyper-schema";
51
-
52
- Schema.setConfig(hyperSchemaVersion, "baseToken", "id");
53
- Schema.setConfig(hyperSchemaVersion, "embeddedToken", "id");
54
- Schema.setConfig(hyperSchemaVersion, "anchorToken", "id");
55
- Schema.setConfig(hyperSchemaVersion, "jrefToken", "$ref");
56
-
57
- Schema.add(JSON.parse(metaHyperSchema));
58
- Core.defineVocabulary(hyperSchemaVersion, {
59
- "validate": keywords.validate,
60
- "additionalItems": keywords.additionalItems,
61
- "additionalProperties": keywords.additionalProperties,
62
- "allOf": keywords.allOf,
63
- "anyOf": keywords.anyOf,
64
- "default": keywords.metaData,
65
- "definitions": keywords.definitions,
66
- "dependencies": keywords.dependencies,
67
- "description": keywords.metaData,
68
- "enum": keywords.enum,
69
- "format": keywords.metaData,
70
- "fragmentResolution": keywords.metaData,
71
- "items": keywords.items,
72
- "maxItems": keywords.maxItems,
73
- "minProperties": keywords.minProperties,
74
- "maxProperties": keywords.maxProperties,
75
- "maximum": keywords.maximumExclusiveMaximum,
76
- "media": keywords.metaData,
77
- "minItems": keywords.minItems,
78
- "minLength": keywords.minLength,
79
- "maxLength": keywords.maxLength,
80
- "minimum": keywords.minimumExclusiveMinimum,
81
- "multipleOf": keywords.multipleOf,
82
- "links": keywords.metaData,
83
- "not": keywords.not,
84
- "oneOf": keywords.oneOf,
85
- "pathStart": keywords.metaData,
86
- "pattern": keywords.pattern,
87
- "patternProperties": keywords.patternProperties,
88
- "properties": keywords.properties,
89
- "readOnly": keywords.metaData,
90
- "required": keywords.required,
91
- "title": keywords.metaData,
92
- "type": keywords.type,
93
- "uniqueItems": keywords.uniqueItems
94
- });
package/lib/draft-07.d.ts CHANGED
@@ -36,7 +36,7 @@ export type Draft07Schema = boolean | {
36
36
  patternProperties?: Record<string, Draft07Schema>;
37
37
  dependencies?: Record<string, Draft07Schema | string[]>;
38
38
  propertyNames?: Draft07Schema;
39
- const?: Draft07Schema;
39
+ const?: Json;
40
40
  enum?: Json[];
41
41
  type?: JsonType | JsonType[];
42
42
  format?: "date-time" | "date" | "time" | "email" | "idn-email" | "hostname" | "idn-hostname" | "ipv4" | "ipv6" | "uri" | "uri-reference" | "iri" | "iri-reference" | "uri-template" | "json-pointer" | "relative-json-pointer" | "regex";
@@ -19,7 +19,7 @@ export type Draft201909Schema = boolean | {
19
19
  unevaluatedProperties?: Draft201909Schema;
20
20
  properties?: Record<string, Draft201909Schema>;
21
21
  patternProperties?: Record<string, Draft201909Schema>;
22
- dependentSchema?: Record<string, Draft201909Schema>;
22
+ dependentSchemas?: Record<string, Draft201909Schema>;
23
23
  propertyNames?: Draft201909Schema;
24
24
  if?: Draft201909Schema;
25
25
  then?: Draft201909Schema;
@@ -45,7 +45,7 @@ export type Draft201909Schema = boolean | {
45
45
  minProperties?: number;
46
46
  required?: string[];
47
47
  dependentRequired?: Record<string, string[]>;
48
- const?: Draft201909Schema;
48
+ const?: Json;
49
49
  enum?: Json[];
50
50
  type?: JsonType | JsonType[];
51
51
  title?: string;
@@ -13,13 +13,14 @@ export type Draft202012Schema = boolean | {
13
13
  $defs?: Record<string, Draft202012Schema>;
14
14
  additionalItems?: Draft202012Schema;
15
15
  unevaluatedItems?: Draft202012Schema;
16
- items?: Draft202012Schema | Draft202012Schema[];
16
+ prefixItems?: Draft202012Schema[];
17
+ items?: Draft202012Schema;
17
18
  contains?: Draft202012Schema;
18
19
  additionalProperties?: Draft202012Schema;
19
20
  unevaluatedProperties?: Draft202012Schema;
20
21
  properties?: Record<string, Draft202012Schema>;
21
22
  patternProperties?: Record<string, Draft202012Schema>;
22
- dependentSchema?: Record<string, Draft202012Schema>;
23
+ dependentSchemas?: Record<string, Draft202012Schema>;
23
24
  propertyNames?: Draft202012Schema;
24
25
  if?: Draft202012Schema;
25
26
  then?: Draft202012Schema;
@@ -45,7 +46,7 @@ export type Draft202012Schema = boolean | {
45
46
  minProperties?: number;
46
47
  required?: string[];
47
48
  dependentRequired?: Record<string, string[]>;
48
- const?: Draft202012Schema;
49
+ const?: Json;
49
50
  enum?: Json[];
50
51
  type?: JsonType | JsonType[];
51
52
  title?: string;
package/lib/index.d.ts CHANGED
@@ -17,6 +17,18 @@ export type JsonSchema = {
17
17
  InvalidSchemaError: typeof InvalidSchemaError;
18
18
  };
19
19
 
20
+ export const add: JsonSchema["add"];
21
+ export const get: JsonSchema["get"];
22
+ export const validate: JsonSchema["validate"];
23
+ export const compile: JsonSchema["compile"];
24
+ export const interpret: JsonSchema["interpret"];
25
+ export const setMetaOutputFormat: JsonSchema["setMetaOutputFormat"];
26
+ export const setShouldMetaValidate: JsonSchema["setShouldMetaValidate"];
27
+ export const FLAG: JsonSchema["FLAG"];
28
+ export const BASIC: JsonSchema["BASIC"];
29
+ export const DETAILED: JsonSchema["DETAILED"];
30
+ export const VERBOSE: JsonSchema["VERBOSE"];
31
+
20
32
  export * from "@hyperjump/json-schema-core";
21
33
  export * from "./draft-04";
22
34
  export * from "./draft-06";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperjump/json-schema",
3
- "version": "0.18.0",
3
+ "version": "0.18.4",
4
4
  "description": "A JSON Schema Validator",
5
5
  "main": "lib/index.js",
6
6
  "exports": {
@@ -12,7 +12,8 @@
12
12
  "lint": "eslint lib",
13
13
  "test": "mocha --require ts-node/register 'lib/**/*.spec.ts'",
14
14
  "build": "rollup --config rollup.config.js",
15
- "prepublishOnly": "npm run build"
15
+ "prepublishOnly": "npm run build",
16
+ "postinstall": "rm -rf dist"
16
17
  },
17
18
  "repository": "github:hyperjump-io/json-schema-validator",
18
19
  "keywords": [
@@ -44,14 +45,14 @@
44
45
  "eslint-import-resolver-typescript": "^2.4.0",
45
46
  "eslint-plugin-import": "^2.24.0",
46
47
  "json-schema-test-suite": "github:json-schema-org/JSON-Schema-Test-Suite",
47
- "mocha": "^9.0.3",
48
+ "mocha": "^9.1.3",
48
49
  "rollup": "^2.50.5",
49
50
  "rollup-plugin-terser": "^5.3.1",
50
51
  "ts-node": "^10.2.0",
51
52
  "typescript": "^4.3.5"
52
53
  },
53
54
  "dependencies": {
54
- "@hyperjump/json-schema-core": "^0.22.0",
55
+ "@hyperjump/json-schema-core": "^0.23.4",
55
56
  "fastest-stable-stringify": "^2.0.2"
56
57
  }
57
58
  }
@@ -1,136 +0,0 @@
1
- module.exports = `{
2
- "$schema": "http://json-schema.org/draft-04/hyper-schema#",
3
- "id": "http://json-schema.org/draft-04/hyper-schema#",
4
- "title": "JSON Hyper-Schema",
5
- "allOf": [
6
- {"$ref": "http://json-schema.org/draft-04/schema#"}
7
- ],
8
- "properties": {
9
- "additionalItems": {
10
- "anyOf": [
11
- {"type": "boolean"},
12
- {"$ref": "#"}
13
- ]
14
- },
15
- "additionalProperties": {
16
- "anyOf": [
17
- {"type": "boolean"},
18
- {"$ref": "#"}
19
- ]
20
- },
21
- "dependencies": {
22
- "additionalProperties": {
23
- "anyOf": [
24
- {"$ref": "#"},
25
- {"type": "array"}
26
- ]
27
- }
28
- },
29
- "items": {
30
- "anyOf": [
31
- {"$ref": "#"},
32
- {"$ref": "#/definitions/schemaArray"}
33
- ]
34
- },
35
- "definitions": {
36
- "additionalProperties": {"$ref": "#"}
37
- },
38
- "patternProperties": {
39
- "additionalProperties": {"$ref": "#"}
40
- },
41
- "properties": {
42
- "additionalProperties": {"$ref": "#"}
43
- },
44
- "allOf": {"$ref": "#/definitions/schemaArray"},
45
- "anyOf": {"$ref": "#/definitions/schemaArray"},
46
- "oneOf": {"$ref": "#/definitions/schemaArray"},
47
- "not": { "$ref": "#" },
48
-
49
- "links": {
50
- "type": "array",
51
- "items": {"$ref": "#/definitions/linkDescription"}
52
- },
53
- "fragmentResolution": {
54
- "type": "string"
55
- },
56
- "media": {
57
- "type": "object",
58
- "properties": {
59
- "type": {
60
- "description": "A media type, as described in RFC 2046",
61
- "type": "string"
62
- },
63
- "binaryEncoding": {
64
- "description": "A content encoding scheme, as described in RFC 2045",
65
- "type": "string"
66
- }
67
- }
68
- },
69
- "pathStart": {
70
- "description": "Instances' URIs must start with this value for this schema to apply to them",
71
- "type": "string",
72
- "format": "uri"
73
- }
74
- },
75
- "definitions": {
76
- "schemaArray": {
77
- "type": "array",
78
- "items": {"$ref": "#"}
79
- },
80
- "linkDescription": {
81
- "title": "Link Description Object",
82
- "type": "object",
83
- "required": ["href", "rel"],
84
- "properties": {
85
- "href": {
86
- "description": "a URI template, as defined by RFC 6570, with the addition of the $, ( and ) characters for pre-processing",
87
- "type": "string"
88
- },
89
- "rel": {
90
- "description": "relation to the target resource of the link",
91
- "type": "string"
92
- },
93
- "title": {
94
- "description": "a title for the link",
95
- "type": "string"
96
- },
97
- "targetSchema": {
98
- "description": "JSON Schema describing the link target",
99
- "$ref": "#"
100
- },
101
- "mediaType": {
102
- "description": "media type (as defined by RFC 2046) describing the link target",
103
- "type": "string"
104
- },
105
- "method": {
106
- "description": "method for requesting the target of the link (e.g. for HTTP this might be \\"GET\\" or \\"DELETE\\")",
107
- "type": "string"
108
- },
109
- "encType": {
110
- "description": "The media type in which to submit data along with the request",
111
- "type": "string",
112
- "default": "application/json"
113
- },
114
- "schema": {
115
- "description": "Schema describing the data to submit along with the request",
116
- "$ref": "#"
117
- }
118
- }
119
- },
120
- "readOnly": {
121
- "description": "If true, indicates that the value of this property is controlled by the server.",
122
- "type": "boolean",
123
- "default": false
124
- }
125
- },
126
- "links": [
127
- {
128
- "rel": "self",
129
- "href": "{+id}"
130
- },
131
- {
132
- "rel": "full",
133
- "href": "{+($ref)}"
134
- }
135
- ]
136
- }`;