@hyperjump/json-schema 1.17.1 → 1.17.3

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.
@@ -1,13 +1,13 @@
1
1
  import type { Browser, Document } from "@hyperjump/browser";
2
2
  import type { Json } from "@hyperjump/json-pointer";
3
- import type { Validator, Output, OutputUnit, OutputFormat, SchemaObject } from "./index.js";
3
+ import type { Validator, Output, OutputUnit, OutputFormat, SchemaObject, ValidationOptions } from "./index.js";
4
4
  import type { JsonNode } from "./instance.js";
5
5
 
6
6
 
7
7
  // Compile/interpret
8
8
  export const compile: (schema: Browser<SchemaDocument>) => Promise<CompiledSchema>;
9
9
  export const interpret: (
10
- (compiledSchema: CompiledSchema, value: JsonNode, outputFormat?: OutputFormat) => Output
10
+ (compiledSchema: CompiledSchema, value: JsonNode, outputFormat?: OutputFormat | ValidationOptions) => Output
11
11
  ) & (
12
12
  (compiledSchema: CompiledSchema) => Validator
13
13
  );
@@ -45,7 +45,6 @@ export const toSchema: (browser: Browser<SchemaDocument>, options?: ToSchemaOpti
45
45
  export type ToSchemaOptions = {
46
46
  contextDialectId?: string;
47
47
  includeDialect?: "auto" | "always" | "never";
48
- selfIdentify?: boolean;
49
48
  contextUri?: string;
50
49
  includeEmbedded?: boolean;
51
50
  };
@@ -80,7 +79,7 @@ export type Keyword<A, Context extends ValidationContext = ValidationContext> =
80
79
  compile: (schema: Browser<SchemaDocument>, ast: AST, parentSchema: Browser<SchemaDocument>) => Promise<A>;
81
80
  interpret: (compiledKeywordValue: A, instance: JsonNode, context: Context) => boolean;
82
81
  simpleApplicator?: boolean;
83
- annotation?: <B>(compiledKeywordValue: A, instance: JsonNode) => B | undefined;
82
+ annotation?: (compiledKeywordValue: A, instance: JsonNode) => unknown;
84
83
  plugin?: EvaluationPlugin<Context>;
85
84
  };
86
85
 
package/lib/index.d.ts CHANGED
@@ -48,14 +48,14 @@ export type OutputUnit = {
48
48
 
49
49
  export const FLAG: "FLAG";
50
50
 
51
- export type OutputFormat = "FLAG" | "BASIC" | "DETAILED" | "VERBOSE";
51
+ export type OutputFormat = "FLAG" | "BASIC" | "DETAILED";
52
52
 
53
53
  export const setMetaSchemaOutputFormat: (format: OutputFormat) => void;
54
54
  export const getMetaSchemaOutputFormat: () => OutputFormat;
55
55
  export const setShouldValidateSchema: (isEnabled: boolean) => void;
56
56
  export const getShouldValidateSchema: () => boolean;
57
- export const setShouldValidateFormat: (isEnabled: boolean) => void;
58
- export const getShouldValidateFormat: () => boolean;
57
+ export const setShouldValidateFormat: (isEnabled: boolean | undefined) => void;
58
+ export const getShouldValidateFormat: () => boolean | undefined;
59
59
 
60
60
  export class InvalidSchemaError extends Error {
61
61
  public output: Output & { valid: false };
package/lib/instance.d.ts CHANGED
@@ -32,7 +32,7 @@ export type JsonNode = {
32
32
  children: JsonNode[];
33
33
  parent?: JsonNode;
34
34
  root: JsonNode;
35
- annotations: Record<string, Record<string, unknown>>;
35
+ annotations: Record<string, unknown[]>;
36
36
  };
37
37
 
38
38
  type JsonNodeType = "object" | "array" | "string" | "number" | "boolean" | "null" | "property";
@@ -141,7 +141,7 @@ type Components = {
141
141
  headers?: Record<string, Header | Reference>;
142
142
  securitySchemes?: Record<string, SecurityScheme | Reference>;
143
143
  links?: Record<string, Link | Reference>;
144
- callbacks?: Record<string, Callbacks | Reference>;
144
+ callbacks?: Record<string, Callback | Reference>;
145
145
  pathItems?: Record<string, PathItem | Reference>;
146
146
  };
147
147
 
@@ -169,7 +169,7 @@ type Operation = {
169
169
  parameters?: (Parameter | Reference)[];
170
170
  requestBody?: RequestBody | Reference;
171
171
  responses?: Record<string, Response | Reference>;
172
- callbacks?: Record<string, Callbacks | Reference>;
172
+ callbacks?: Record<string, Callback | Reference>;
173
173
  deprecated?: boolean;
174
174
  security?: SecurityRequirement[];
175
175
  servers?: Server[];
@@ -259,7 +259,7 @@ type Response = {
259
259
  links?: Record<string, Link | Reference>;
260
260
  };
261
261
 
262
- type Callbacks = Record<string, PathItem | Reference>;
262
+ type Callback = Record<string, PathItem>;
263
263
 
264
264
  type Example = {
265
265
  summary?: string;
@@ -69,7 +69,7 @@ export type OasSchema32 = boolean | {
69
69
 
70
70
  type Discriminator = {
71
71
  propertyName: string;
72
- mappings?: Record<string, string>;
72
+ mapping?: Record<string, string>;
73
73
  defaultMapping?: string;
74
74
  };
75
75
 
@@ -145,7 +145,7 @@ type Components = {
145
145
  headers?: Record<string, Header | Reference>;
146
146
  securitySchemes?: Record<string, SecurityScheme | Reference>;
147
147
  links?: Record<string, Link | Reference>;
148
- callbacks?: Record<string, Callbacks | Reference>;
148
+ callbacks?: Record<string, Callback | Reference>;
149
149
  pathItems?: Record<string, PathItem>;
150
150
  mediaTypes?: Record<string, MediaType | Reference>;
151
151
  };
@@ -163,7 +163,7 @@ type PathItem = {
163
163
  patch?: Operation;
164
164
  trace?: Operation;
165
165
  query?: Operation;
166
- additionOperations?: Record<string, Operation>;
166
+ additionalOperations?: Record<string, Operation>;
167
167
  servers?: Server[];
168
168
  parameters?: (Parameter | Reference)[];
169
169
  };
@@ -177,7 +177,7 @@ type Operation = {
177
177
  parameters?: (Parameter | Reference)[];
178
178
  requestBody?: RequestBody | Reference;
179
179
  responses?: Responses;
180
- callbacks?: Record<string, Callbacks | Reference>;
180
+ callbacks?: Record<string, Callback | Reference>;
181
181
  deprecated?: boolean;
182
182
  security?: SecurityRequirement[];
183
183
  servers?: Server[];
@@ -188,7 +188,6 @@ export type Parameter = {
188
188
  description?: string;
189
189
  required?: boolean;
190
190
  deprecated?: boolean;
191
- allowEmptyValue?: boolean;
192
191
  } & Examples & (
193
192
  (
194
193
  {
@@ -201,6 +200,7 @@ export type Parameter = {
201
200
  ) | (
202
201
  {
203
202
  in: "query";
203
+ allowEmptyValue?: boolean;
204
204
  } & (
205
205
  ({ style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject" } & SchemaParameter)
206
206
  | ContentParameter
@@ -283,7 +283,7 @@ type Response = {
283
283
  links?: Record<string, Link | Reference>;
284
284
  };
285
285
 
286
- type Callbacks = Record<string, PathItem | Reference>;
286
+ type Callback = Record<string, PathItem>;
287
287
 
288
288
  type Examples = {
289
289
  example?: Json;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperjump/json-schema",
3
- "version": "1.17.1",
3
+ "version": "1.17.3",
4
4
  "description": "A JSON Schema validator with support for custom keywords, vocabularies, and dialects",
5
5
  "type": "module",
6
6
  "main": "./v1/index.js",