json-schema-library 10.4.0 → 10.4.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/dist/index.d.mts +11 -9
- package/dist/index.d.ts +9 -483
- package/dist/index.js +1 -12
- package/dist/index.mjs +1 -12
- package/dist/jlib.js +3 -3
- package/package.json +5 -5
- package/src/formats/formats.ts +1 -1
- package/tsdown.config.ts +0 -2
- package/tsdown.iife.config.ts +10 -0
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
//#region rolldown:runtime
|
|
4
|
+
//#endregion
|
|
1
5
|
//#region src/Keyword.d.ts
|
|
2
6
|
type ValidationPath = {
|
|
3
7
|
pointer: string;
|
|
@@ -209,8 +213,6 @@ declare const errors: {
|
|
|
209
213
|
"unknown-property-error": string;
|
|
210
214
|
"value-not-empty-error": string;
|
|
211
215
|
};
|
|
212
|
-
//#endregion
|
|
213
|
-
//#region src/getNode.d.ts
|
|
214
216
|
declare function getNode(pointer: string, data: unknown, options: {
|
|
215
217
|
withSchemaWarning: true;
|
|
216
218
|
} & GetNodeOptions): NodeOrError;
|
|
@@ -393,7 +395,7 @@ declare const SchemaNodeMethods: {
|
|
|
393
395
|
* @returns SchemaNode representing the passed JSON Schema
|
|
394
396
|
*/
|
|
395
397
|
readonly compileSchema: (schema: JsonSchema, evaluationPath?: string, schemaLocation?: string, dynamicId?: string) => SchemaNode;
|
|
396
|
-
readonly createError: <T extends string = "additional-items-error" | "additional-properties-error" | "all-of-error" | "any-of-error" | "const-error" | "contains-any-error" | "contains-array-error" | "contains-error" | "contains-min-error" | "contains-max-error" | "enum-error" | "exclusive-maximum-error" | "exclusive-minimum-error" | "forbidden-property-error" | "format-date-error" | "format-date-time-error" | "format-duration-error" | "format-email-error" | "format-hostname-error" | "format-ipv4-error" | "format-ipv4-leading-zero-error" | "format-ipv6-error" | "format-ipv6-leading-zero-error" | "format-json-pointer-error" | "format-regex-error" | "format-time-error" | "format-uri-error" | "format-uri-reference-error" | "format-uri-template-error" | "format-url-error" | "format-uuid-error" | "invalid-data-error" | "invalid-property-name-error" | "maximum-error" | "max-items-error" | "max-length-error" | "max-properties-error" | "minimum-error" | "min-items-error" | "min-items-one-error" | "min-length-error" | "min-length-one-error" | "missing-one-of-declarator-error" | "min-properties-error" | "missing-array-item-error" | "missing-dependency-error" | "missing-one-of-property-error" | "multiple-of-error" | "multiple-one-of-error" | "no-additional-properties-error" | "not-error" | "one-of-error" | "one-of-property-error" | "pattern-error" | "pattern-properties-error" | "required-property-error" | "schema-warning" | "type-error" | "undefined-value-error" | "unevaluated-property-error" | "unevaluated-items-error" | "unique-items-error" | "unknown-property-error" | "value-not-empty-error">(code: T, data: ErrorData, message?: string) => JsonError;
|
|
398
|
+
readonly createError: <T$1 extends string = "additional-items-error" | "additional-properties-error" | "all-of-error" | "any-of-error" | "const-error" | "contains-any-error" | "contains-array-error" | "contains-error" | "contains-min-error" | "contains-max-error" | "enum-error" | "exclusive-maximum-error" | "exclusive-minimum-error" | "forbidden-property-error" | "format-date-error" | "format-date-time-error" | "format-duration-error" | "format-email-error" | "format-hostname-error" | "format-ipv4-error" | "format-ipv4-leading-zero-error" | "format-ipv6-error" | "format-ipv6-leading-zero-error" | "format-json-pointer-error" | "format-regex-error" | "format-time-error" | "format-uri-error" | "format-uri-reference-error" | "format-uri-template-error" | "format-url-error" | "format-uuid-error" | "invalid-data-error" | "invalid-property-name-error" | "maximum-error" | "max-items-error" | "max-length-error" | "max-properties-error" | "minimum-error" | "min-items-error" | "min-items-one-error" | "min-length-error" | "min-length-one-error" | "missing-one-of-declarator-error" | "min-properties-error" | "missing-array-item-error" | "missing-dependency-error" | "missing-one-of-property-error" | "multiple-of-error" | "multiple-one-of-error" | "no-additional-properties-error" | "not-error" | "one-of-error" | "one-of-property-error" | "pattern-error" | "pattern-properties-error" | "required-property-error" | "schema-warning" | "type-error" | "undefined-value-error" | "unevaluated-property-error" | "unevaluated-items-error" | "unique-items-error" | "unknown-property-error" | "value-not-empty-error">(code: T$1, data: ErrorData, message?: string) => JsonError;
|
|
397
399
|
readonly createSchema: typeof createSchema;
|
|
398
400
|
readonly getChildSelection: (property: string | number) => JsonError | SchemaNode[];
|
|
399
401
|
readonly getNode: typeof getNode;
|
|
@@ -435,7 +437,7 @@ declare const SchemaNodeMethods: {
|
|
|
435
437
|
/**
|
|
436
438
|
* @returns a list of values (including objects and arrays) and their corresponding JSON Schema as SchemaNode
|
|
437
439
|
*/
|
|
438
|
-
readonly toDataNodes: (data: unknown, pointer?: string) => DataNode[];
|
|
440
|
+
readonly toDataNodes: (data: unknown, pointer?: string) => import_dist.DataNode[];
|
|
439
441
|
readonly toJSON: () => any;
|
|
440
442
|
};
|
|
441
443
|
//#endregion
|
|
@@ -460,18 +462,18 @@ type NodeOrError = {
|
|
|
460
462
|
node: undefined;
|
|
461
463
|
error: JsonError;
|
|
462
464
|
};
|
|
463
|
-
type ErrorData<T extends Record<string, unknown> = {
|
|
465
|
+
type ErrorData<T$1 extends Record<string, unknown> = {
|
|
464
466
|
[p: string]: unknown;
|
|
465
|
-
}> = T & {
|
|
467
|
+
}> = T$1 & {
|
|
466
468
|
pointer: string;
|
|
467
469
|
schema: JsonSchema;
|
|
468
470
|
value: unknown;
|
|
469
471
|
};
|
|
470
|
-
type JsonError<T extends ErrorData = ErrorData> = {
|
|
472
|
+
type JsonError<T$1 extends ErrorData = ErrorData> = {
|
|
471
473
|
type: "error";
|
|
472
474
|
code: ErrorConfig | string;
|
|
473
475
|
message: string;
|
|
474
|
-
data: T;
|
|
476
|
+
data: T$1;
|
|
475
477
|
[p: string]: unknown;
|
|
476
478
|
};
|
|
477
479
|
/**
|
|
@@ -633,7 +635,7 @@ declare function getTypeOf(value: unknown): JSType;
|
|
|
633
635
|
declare function mergeNode(a: SchemaNode, b?: SchemaNode, ...omit: string[]): SchemaNode | undefined;
|
|
634
636
|
//#endregion
|
|
635
637
|
//#region src/utils/mergeSchema.d.ts
|
|
636
|
-
declare function mergeSchema<T extends JsonSchema>(a: T, b: T, ...omit: string[]): T;
|
|
638
|
+
declare function mergeSchema<T$1 extends JsonSchema>(a: T$1, b: T$1, ...omit: string[]): T$1;
|
|
637
639
|
//#endregion
|
|
638
640
|
//#region src/utils/getSchemaType.d.ts
|
|
639
641
|
declare const SCHEMA_TYPES: string[];
|
package/dist/index.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ interface JsonSchemaResolver {
|
|
|
30
30
|
order?: number;
|
|
31
31
|
(options: JsonSchemaResolverParams): SchemaNode | JsonError | undefined;
|
|
32
32
|
}
|
|
33
|
-
type ValidationResult
|
|
33
|
+
type ValidationResult = JsonError | Promise<JsonError>;
|
|
34
34
|
type JsonSchemaValidatorParams = {
|
|
35
35
|
pointer?: string;
|
|
36
36
|
data: unknown;
|
|
@@ -40,7 +40,7 @@ type JsonSchemaValidatorParams = {
|
|
|
40
40
|
interface JsonSchemaValidator {
|
|
41
41
|
toJSON?: () => string;
|
|
42
42
|
order?: number;
|
|
43
|
-
(options: JsonSchemaValidatorParams): undefined | ValidationResult
|
|
43
|
+
(options: JsonSchemaValidatorParams): undefined | ValidationResult | ValidationResult[];
|
|
44
44
|
}
|
|
45
45
|
type Keyword = {
|
|
46
46
|
id: string;
|
|
@@ -74,7 +74,7 @@ type DataNode = {
|
|
|
74
74
|
value: unknown;
|
|
75
75
|
pointer: string;
|
|
76
76
|
};
|
|
77
|
-
declare function toDataNodes
|
|
77
|
+
declare function toDataNodes(node: SchemaNode, data: unknown, pointer?: string, dataNodes?: DataNode[]): DataNode[];
|
|
78
78
|
//#endregion
|
|
79
79
|
//#region src/methods/getChildSelection.d.ts
|
|
80
80
|
/**
|
|
@@ -82,7 +82,7 @@ declare function toDataNodes$1(node: SchemaNode, data: unknown, pointer?: string
|
|
|
82
82
|
* could be added at the given property (e.g. item-index), thus an array of options is returned. In all other cases
|
|
83
83
|
* a list with a single item will be returned
|
|
84
84
|
*/
|
|
85
|
-
declare function getChildSelection
|
|
85
|
+
declare function getChildSelection(node: SchemaNode, property: string | number): SchemaNode[] | JsonError;
|
|
86
86
|
//#endregion
|
|
87
87
|
//#region src/methods/getData.d.ts
|
|
88
88
|
type TemplateOptions = {
|
|
@@ -110,7 +110,7 @@ type TemplateOptions = {
|
|
|
110
110
|
/** @internal context to track recursion limit */
|
|
111
111
|
cache?: Record<string, Record<string, number>>;
|
|
112
112
|
};
|
|
113
|
-
declare function getData
|
|
113
|
+
declare function getData(node: SchemaNode, data?: unknown, opts?: TemplateOptions): any;
|
|
114
114
|
//#endregion
|
|
115
115
|
//#region src/Draft.d.ts
|
|
116
116
|
type DraftVersion = "draft-04" | "draft-06" | "draft-07" | "draft-2019-09" | "draft-2020-12" | "latest";
|
|
@@ -124,9 +124,9 @@ interface Draft {
|
|
|
124
124
|
/** draft-dependent methods */
|
|
125
125
|
methods: {
|
|
126
126
|
createSchema: typeof createSchema;
|
|
127
|
-
getChildSelection: typeof getChildSelection
|
|
128
|
-
getData: typeof getData
|
|
129
|
-
toDataNodes: typeof toDataNodes
|
|
127
|
+
getChildSelection: typeof getChildSelection;
|
|
128
|
+
getData: typeof getData;
|
|
129
|
+
toDataNodes: typeof toDataNodes;
|
|
130
130
|
};
|
|
131
131
|
/** meta-schema url associated with this draft */
|
|
132
132
|
$schema?: string;
|
|
@@ -210,480 +210,6 @@ declare const errors: {
|
|
|
210
210
|
"value-not-empty-error": string;
|
|
211
211
|
};
|
|
212
212
|
//#endregion
|
|
213
|
-
//#region dist/index.d.mts
|
|
214
|
-
//#region src/Keyword.d.ts
|
|
215
|
-
type ValidationPath$1 = {
|
|
216
|
-
pointer: string;
|
|
217
|
-
node: SchemaNode$1;
|
|
218
|
-
}[];
|
|
219
|
-
type JsonSchemaReducerParams$1 = {
|
|
220
|
-
/** data of current node */
|
|
221
|
-
data: unknown;
|
|
222
|
-
/** optional key to used to resolve by property without having data */
|
|
223
|
-
key?: string | number;
|
|
224
|
-
/** node to reduce */
|
|
225
|
-
node: SchemaNode$1;
|
|
226
|
-
/** JSON pointer to data */
|
|
227
|
-
pointer: string;
|
|
228
|
-
/** passed through path for schema resolution, will be changed by reference */
|
|
229
|
-
path: ValidationPath$1;
|
|
230
|
-
};
|
|
231
|
-
interface JsonSchemaReducer$1 {
|
|
232
|
-
toJSON?: () => string;
|
|
233
|
-
order?: number;
|
|
234
|
-
(options: JsonSchemaReducerParams$1): SchemaNode$1 | JsonError$1 | undefined;
|
|
235
|
-
}
|
|
236
|
-
type JsonSchemaResolverParams$1 = {
|
|
237
|
-
key: string | number;
|
|
238
|
-
data: unknown;
|
|
239
|
-
node: SchemaNode$1;
|
|
240
|
-
};
|
|
241
|
-
interface JsonSchemaResolver$1 {
|
|
242
|
-
toJSON?: () => string;
|
|
243
|
-
order?: number;
|
|
244
|
-
(options: JsonSchemaResolverParams$1): SchemaNode$1 | JsonError$1 | undefined;
|
|
245
|
-
}
|
|
246
|
-
type ValidationResult = JsonError$1 | Promise<JsonError$1>;
|
|
247
|
-
type JsonSchemaValidatorParams$1 = {
|
|
248
|
-
pointer?: string;
|
|
249
|
-
data: unknown;
|
|
250
|
-
node: SchemaNode$1;
|
|
251
|
-
path?: ValidationPath$1;
|
|
252
|
-
};
|
|
253
|
-
interface JsonSchemaValidator$1 {
|
|
254
|
-
toJSON?: () => string;
|
|
255
|
-
order?: number;
|
|
256
|
-
(options: JsonSchemaValidatorParams$1): undefined | ValidationResult | ValidationResult[];
|
|
257
|
-
}
|
|
258
|
-
type Keyword$1 = {
|
|
259
|
-
id: string;
|
|
260
|
-
/** unique keyword corresponding to JSON Schema keywords (or custom) */
|
|
261
|
-
keyword: string;
|
|
262
|
-
/** sort order of keyword. Lower numbers will be processed last. Default is 0 */
|
|
263
|
-
order?: number;
|
|
264
|
-
/** called with compileSchema */
|
|
265
|
-
parse?: (node: SchemaNode$1) => void;
|
|
266
|
-
addResolve?: (node: SchemaNode$1) => boolean;
|
|
267
|
-
/** return node corresponding to passed in key or do nothing */
|
|
268
|
-
resolve?: JsonSchemaResolver$1;
|
|
269
|
-
addValidate?: (node: SchemaNode$1) => boolean;
|
|
270
|
-
/** validate data using node */
|
|
271
|
-
validate?: JsonSchemaValidator$1;
|
|
272
|
-
addReduce?: (node: SchemaNode$1) => boolean;
|
|
273
|
-
/** remove dynamic schema-keywords by merging valid sub-schemas */
|
|
274
|
-
reduce?: JsonSchemaReducer$1;
|
|
275
|
-
};
|
|
276
|
-
//#endregion
|
|
277
|
-
//#region src/methods/createSchema.d.ts
|
|
278
|
-
/**
|
|
279
|
-
* Create a simple json schema for the given input data
|
|
280
|
-
* @param data - data to get json schema for
|
|
281
|
-
*/
|
|
282
|
-
declare function createSchema$1(data: unknown): JsonSchema$1;
|
|
283
|
-
//#endregion
|
|
284
|
-
//#region src/methods/toDataNodes.d.ts
|
|
285
|
-
type DataNode$1 = {
|
|
286
|
-
node: SchemaNode$1;
|
|
287
|
-
value: unknown;
|
|
288
|
-
pointer: string;
|
|
289
|
-
};
|
|
290
|
-
declare function toDataNodes(node: SchemaNode$1, data: unknown, pointer?: string, dataNodes?: DataNode$1[]): DataNode$1[];
|
|
291
|
-
//#endregion
|
|
292
|
-
//#region src/methods/getChildSelection.d.ts
|
|
293
|
-
/**
|
|
294
|
-
* Returns a list of possible child-schemas for the given property key. In case of a oneOf selection, multiple schemas
|
|
295
|
-
* could be added at the given property (e.g. item-index), thus an array of options is returned. In all other cases
|
|
296
|
-
* a list with a single item will be returned
|
|
297
|
-
*/
|
|
298
|
-
declare function getChildSelection(node: SchemaNode$1, property: string | number): SchemaNode$1[] | JsonError$1;
|
|
299
|
-
//#endregion
|
|
300
|
-
//#region src/methods/getData.d.ts
|
|
301
|
-
type TemplateOptions$1 = {
|
|
302
|
-
/** Add all properties (required and optional) to the generated data */
|
|
303
|
-
addOptionalProps?: boolean;
|
|
304
|
-
/** Remove data that does not match input schema. Defaults to false */
|
|
305
|
-
removeInvalidData?: boolean;
|
|
306
|
-
/** Set to false to take default values as they are and not extend them.
|
|
307
|
-
* Defaults to true.
|
|
308
|
-
* This allows to control template data e.g. enforcing arrays to be empty,
|
|
309
|
-
* regardless of minItems settings.
|
|
310
|
-
*/
|
|
311
|
-
extendDefaults?: boolean;
|
|
312
|
-
/**
|
|
313
|
-
* Set to false to not use type specific initial values.Defaults to true
|
|
314
|
-
*/
|
|
315
|
-
useTypeDefaults?: boolean;
|
|
316
|
-
/**
|
|
317
|
-
* Limits how often a $ref should be followed before aborting. Prevents infinite data-structure.
|
|
318
|
-
* Defaults to 1
|
|
319
|
-
*/
|
|
320
|
-
recursionLimit?: number;
|
|
321
|
-
/** @internal disables recursion limit for next call */
|
|
322
|
-
disableRecursionLimit?: boolean;
|
|
323
|
-
/** @internal context to track recursion limit */
|
|
324
|
-
cache?: Record<string, Record<string, number>>;
|
|
325
|
-
};
|
|
326
|
-
declare function getData(node: SchemaNode$1, data?: unknown, opts?: TemplateOptions$1): any;
|
|
327
|
-
//#endregion
|
|
328
|
-
//#region src/Draft.d.ts
|
|
329
|
-
type DraftVersion$1 = "draft-04" | "draft-06" | "draft-07" | "draft-2019-09" | "draft-2020-12" | "latest";
|
|
330
|
-
interface Draft$1 {
|
|
331
|
-
/** test-string if draft can be used with $schema-url */
|
|
332
|
-
$schemaRegEx: string;
|
|
333
|
-
/** draft-version of this draft, e.g. draft-2020-12 */
|
|
334
|
-
version: DraftVersion$1;
|
|
335
|
-
/** supported keywords and implementation */
|
|
336
|
-
keywords: Keyword$1[];
|
|
337
|
-
/** draft-dependent methods */
|
|
338
|
-
methods: {
|
|
339
|
-
createSchema: typeof createSchema$1;
|
|
340
|
-
getChildSelection: typeof getChildSelection;
|
|
341
|
-
getData: typeof getData;
|
|
342
|
-
toDataNodes: typeof toDataNodes;
|
|
343
|
-
};
|
|
344
|
-
/** meta-schema url associated with this draft */
|
|
345
|
-
$schema?: string;
|
|
346
|
-
/** draft errors (this can still be global) */
|
|
347
|
-
errors: ErrorConfig$1;
|
|
348
|
-
formats: Record<string, JsonSchemaValidator$1>;
|
|
349
|
-
}
|
|
350
|
-
//#endregion
|
|
351
|
-
//#region src/errors/errors.d.ts
|
|
352
|
-
declare const errors$1: {
|
|
353
|
-
"additional-items-error": string;
|
|
354
|
-
"additional-properties-error": string;
|
|
355
|
-
"all-of-error": string;
|
|
356
|
-
"any-of-error": string;
|
|
357
|
-
"const-error": string;
|
|
358
|
-
"contains-any-error": string;
|
|
359
|
-
"contains-array-error": string;
|
|
360
|
-
"contains-error": string;
|
|
361
|
-
"contains-min-error": string;
|
|
362
|
-
"contains-max-error": string;
|
|
363
|
-
"enum-error": string;
|
|
364
|
-
"exclusive-maximum-error": string;
|
|
365
|
-
"exclusive-minimum-error": string;
|
|
366
|
-
"forbidden-property-error": string;
|
|
367
|
-
"format-date-error": string;
|
|
368
|
-
"format-date-time-error": string;
|
|
369
|
-
"format-duration-error": string;
|
|
370
|
-
"format-email-error": string;
|
|
371
|
-
"format-hostname-error": string;
|
|
372
|
-
"format-ipv4-error": string;
|
|
373
|
-
"format-ipv4-leading-zero-error": string;
|
|
374
|
-
"format-ipv6-error": string;
|
|
375
|
-
"format-ipv6-leading-zero-error": string;
|
|
376
|
-
"format-json-pointer-error": string;
|
|
377
|
-
"format-regex-error": string;
|
|
378
|
-
"format-time-error": string;
|
|
379
|
-
"format-uri-error": string;
|
|
380
|
-
"format-uri-reference-error": string;
|
|
381
|
-
"format-uri-template-error": string;
|
|
382
|
-
"format-url-error": string;
|
|
383
|
-
"format-uuid-error": string;
|
|
384
|
-
"invalid-data-error": string;
|
|
385
|
-
"invalid-property-name-error": string;
|
|
386
|
-
"maximum-error": string;
|
|
387
|
-
"max-items-error": string;
|
|
388
|
-
"max-length-error": string;
|
|
389
|
-
"max-properties-error": string;
|
|
390
|
-
"minimum-error": string;
|
|
391
|
-
"min-items-error": string;
|
|
392
|
-
"min-items-one-error": string;
|
|
393
|
-
"min-length-error": string;
|
|
394
|
-
"min-length-one-error": string;
|
|
395
|
-
"missing-one-of-declarator-error": string;
|
|
396
|
-
"min-properties-error": string;
|
|
397
|
-
"missing-array-item-error": string;
|
|
398
|
-
"missing-dependency-error": string;
|
|
399
|
-
"missing-one-of-property-error": string;
|
|
400
|
-
"multiple-of-error": string;
|
|
401
|
-
"multiple-one-of-error": string;
|
|
402
|
-
"no-additional-properties-error": string;
|
|
403
|
-
"not-error": string;
|
|
404
|
-
"one-of-error": string;
|
|
405
|
-
"one-of-property-error": string;
|
|
406
|
-
"pattern-error": string;
|
|
407
|
-
"pattern-properties-error": string;
|
|
408
|
-
"required-property-error": string;
|
|
409
|
-
/** return schema-warning with createSchemaWarning:true when a valid, but undefined property was found */
|
|
410
|
-
"schema-warning": string;
|
|
411
|
-
"type-error": string;
|
|
412
|
-
"undefined-value-error": string;
|
|
413
|
-
"unevaluated-property-error": string;
|
|
414
|
-
"unevaluated-items-error": string;
|
|
415
|
-
"unique-items-error": string;
|
|
416
|
-
"unknown-property-error": string;
|
|
417
|
-
"value-not-empty-error": string;
|
|
418
|
-
};
|
|
419
|
-
//#endregion
|
|
420
|
-
//#region src/getNode.d.ts
|
|
421
|
-
declare function getNode$1(pointer: string, data: unknown, options: {
|
|
422
|
-
withSchemaWarning: true;
|
|
423
|
-
} & GetNodeOptions$1): NodeOrError$1;
|
|
424
|
-
declare function getNode$1(pointer: string, data: unknown, options: {
|
|
425
|
-
createSchema: true;
|
|
426
|
-
} & GetNodeOptions$1): NodeOrError$1;
|
|
427
|
-
declare function getNode$1(pointer: string, data?: unknown, options?: GetNodeOptions$1): OptionalNodeOrError$1;
|
|
428
|
-
//#endregion
|
|
429
|
-
//#region src/getNodeChild.d.ts
|
|
430
|
-
declare function getNodeChild$1(key: string | number, data: unknown, options: {
|
|
431
|
-
withSchemaWarning: true;
|
|
432
|
-
} & GetNodeOptions$1): NodeOrError$1;
|
|
433
|
-
declare function getNodeChild$1(key: string | number, data: unknown, options: {
|
|
434
|
-
createSchema: true;
|
|
435
|
-
} & GetNodeOptions$1): NodeOrError$1;
|
|
436
|
-
declare function getNodeChild$1(key: string | number, data?: unknown, options?: GetNodeOptions$1): OptionalNodeOrError$1;
|
|
437
|
-
//#endregion
|
|
438
|
-
//#region src/SchemaNode.d.ts
|
|
439
|
-
|
|
440
|
-
type Context$1 = {
|
|
441
|
-
/** root node of this JSON Schema */
|
|
442
|
-
rootNode: SchemaNode$1;
|
|
443
|
-
/** available draft configurations */
|
|
444
|
-
drafts: Draft$1[];
|
|
445
|
-
/** [SHARED ACROSS REMOTES] root nodes of registered remote JSON Schema, stored by id/url */
|
|
446
|
-
remotes: Record<string, SchemaNode$1>;
|
|
447
|
-
/** references stored by fully resolved schema-$id + local-pointer */
|
|
448
|
-
refs: Record<string, SchemaNode$1>;
|
|
449
|
-
/** anchors stored by fully resolved schema-$id + $anchor */
|
|
450
|
-
anchors: Record<string, SchemaNode$1>;
|
|
451
|
-
/** [SHARED ACROSS REMOTES] dynamicAnchors stored by fully resolved schema-$id + $anchor */
|
|
452
|
-
dynamicAnchors: Record<string, SchemaNode$1>;
|
|
453
|
-
/** JSON Schema parser, validator, reducer and resolver for this JSON Schema (root schema and its child nodes) */
|
|
454
|
-
keywords: Draft$1["keywords"];
|
|
455
|
-
/** JSON Schema draft dependend methods */
|
|
456
|
-
methods: Draft$1["methods"];
|
|
457
|
-
/** draft version */
|
|
458
|
-
version: Draft$1["version"];
|
|
459
|
-
/** draft errors & template-strings */
|
|
460
|
-
errors: Draft$1["errors"];
|
|
461
|
-
/** draft formats & validators */
|
|
462
|
-
formats: Draft$1["formats"];
|
|
463
|
-
/** [SHARED USING ADD REMOTE] getData default options */
|
|
464
|
-
getDataDefaultOptions?: TemplateOptions$1;
|
|
465
|
-
};
|
|
466
|
-
interface SchemaNode$1 extends SchemaNodeMethodsType$1 {
|
|
467
|
-
/** shared context across nodes of JSON schema and shared properties across all remotes */
|
|
468
|
-
context: Context$1;
|
|
469
|
-
/** JSON Schema of node */
|
|
470
|
-
schema: JsonSchema$1;
|
|
471
|
-
/**
|
|
472
|
-
* Evaluation Path - The location of the keyword that produced the annotation or error.
|
|
473
|
-
* The purpose of this data is to show the resolution path which resulted in the subschema
|
|
474
|
-
* that contains the keyword.
|
|
475
|
-
*
|
|
476
|
-
* - relative to the root of the principal schema; should include (inline) any $ref segments in the path
|
|
477
|
-
* - JSON pointer
|
|
478
|
-
*/
|
|
479
|
-
evaluationPath: string;
|
|
480
|
-
/**
|
|
481
|
-
* Schema Location - The direct location to the keyword that produced the annotation
|
|
482
|
-
* or error. This is provided as a convenience to the user so that they don't have to resolve
|
|
483
|
-
* the keyword's subschema, which may not be trivial task. It is only provided if the relative
|
|
484
|
-
* location contains $refs (otherwise, the two locations will be the same).
|
|
485
|
-
*
|
|
486
|
-
* - absolute URI
|
|
487
|
-
* - may not have any association to the principal schema
|
|
488
|
-
*/
|
|
489
|
-
schemaLocation: string;
|
|
490
|
-
/** id created when combining subschemas */
|
|
491
|
-
dynamicId: string;
|
|
492
|
-
/** reference to parent node (node used to compile this node) */
|
|
493
|
-
parent?: SchemaNode$1 | undefined;
|
|
494
|
-
/** JSON Pointer from last $id ~~to this location~~ to resolve $refs to $id#/idLocalPointer */
|
|
495
|
-
lastIdPointer: string;
|
|
496
|
-
/** when reduced schema containing `oneOf` schema, `oneOfIndex` stores `oneOf`-item used for merge */
|
|
497
|
-
oneOfIndex?: number;
|
|
498
|
-
reducers: JsonSchemaReducer$1[];
|
|
499
|
-
resolvers: JsonSchemaResolver$1[];
|
|
500
|
-
validators: JsonSchemaValidator$1[];
|
|
501
|
-
resolveRef?: (args?: {
|
|
502
|
-
pointer?: string;
|
|
503
|
-
path?: ValidationPath$1;
|
|
504
|
-
}) => SchemaNode$1;
|
|
505
|
-
$id?: string;
|
|
506
|
-
$defs?: Record<string, SchemaNode$1>;
|
|
507
|
-
$ref?: string;
|
|
508
|
-
additionalProperties?: SchemaNode$1;
|
|
509
|
-
allOf?: SchemaNode$1[];
|
|
510
|
-
anyOf?: SchemaNode$1[];
|
|
511
|
-
contains?: SchemaNode$1;
|
|
512
|
-
dependentRequired?: Record<string, string[]>;
|
|
513
|
-
dependentSchemas?: Record<string, SchemaNode$1 | boolean>;
|
|
514
|
-
else?: SchemaNode$1;
|
|
515
|
-
if?: SchemaNode$1;
|
|
516
|
-
/**
|
|
517
|
-
* # Items-array schema - for all drafts
|
|
518
|
-
*
|
|
519
|
-
* - for drafts prior 2020-12 `schema.items[]`-schema stored as `node.prefixItems`
|
|
520
|
-
*
|
|
521
|
-
* Validation succeeds if each element of the instance validates against the schema at the
|
|
522
|
-
* same position, if any.
|
|
523
|
-
*
|
|
524
|
-
* The `prefixItems` keyword restricts a number of items from the start of an array instance
|
|
525
|
-
* to validate against the given sequence of subschemas, where the item at a given index in
|
|
526
|
-
* the array instance is evaluated against the subschema at the given index in the `prefixItems`
|
|
527
|
-
* array, if any. Array items outside the range described by the `prefixItems` keyword is
|
|
528
|
-
* evaluated against the items keyword, if present.
|
|
529
|
-
*
|
|
530
|
-
* [Docs](https://www.learnjsonschema.com/2020-12/applicator/prefixitems/)
|
|
531
|
-
* | [Examples](https://json-schema.org/understanding-json-schema/reference/array#tupleValidation)
|
|
532
|
-
*/
|
|
533
|
-
prefixItems?: SchemaNode$1[];
|
|
534
|
-
/**
|
|
535
|
-
* # Items-object schema for additional array item - for all drafts
|
|
536
|
-
*
|
|
537
|
-
* - for drafts prior 2020-12 `schema.additionalItems` object-schema stored as `node.items`
|
|
538
|
-
*
|
|
539
|
-
* Validation succeeds if each element of the instance not covered by `prefixItems` validates
|
|
540
|
-
* against this schema.
|
|
541
|
-
*
|
|
542
|
-
* The items keyword restricts array instance items not described by the sibling `prefixItems`
|
|
543
|
-
* keyword (if any), to validate against the given subschema. Whetherthis keyword was evaluated
|
|
544
|
-
* against any item of the array instance is reported using annotations.
|
|
545
|
-
*
|
|
546
|
-
* [Docs](https://www.learnjsonschema.com/2020-12/applicator/items/)
|
|
547
|
-
* | [Examples](https://json-schema.org/understanding-json-schema/reference/array#items)
|
|
548
|
-
* | [AdditionalItems Specification](https://json-schema.org/draft/2019-09/draft-handrews-json-schema-02#additionalItems)
|
|
549
|
-
*/
|
|
550
|
-
items?: SchemaNode$1;
|
|
551
|
-
not?: SchemaNode$1;
|
|
552
|
-
oneOf?: SchemaNode$1[];
|
|
553
|
-
patternProperties?: {
|
|
554
|
-
name: string;
|
|
555
|
-
pattern: RegExp;
|
|
556
|
-
node: SchemaNode$1;
|
|
557
|
-
}[];
|
|
558
|
-
properties?: Record<string, SchemaNode$1>;
|
|
559
|
-
propertyNames?: SchemaNode$1;
|
|
560
|
-
then?: SchemaNode$1;
|
|
561
|
-
unevaluatedItems?: SchemaNode$1;
|
|
562
|
-
unevaluatedProperties?: SchemaNode$1;
|
|
563
|
-
}
|
|
564
|
-
type SchemaNodeMethodsType$1 = typeof SchemaNodeMethods$1;
|
|
565
|
-
type GetNodeOptions$1 = {
|
|
566
|
-
/**
|
|
567
|
-
* Per default `undefined` is returned for valid data, but undefined schema.
|
|
568
|
-
*
|
|
569
|
-
* - Using `withSchemaWarning:true` will return an error instead: `{ type: "error", code: "schema-warning" }`
|
|
570
|
-
*/
|
|
571
|
-
withSchemaWarning?: boolean;
|
|
572
|
-
/**
|
|
573
|
-
* Per default `undefined` is returned for valid data, but undefined schema.
|
|
574
|
-
*
|
|
575
|
-
* - Using `createSchema:true` will create a schema instead
|
|
576
|
-
*/
|
|
577
|
-
createSchema?: boolean;
|
|
578
|
-
path?: ValidationPath$1;
|
|
579
|
-
pointer?: string;
|
|
580
|
-
};
|
|
581
|
-
type ValidateReturnType$1 = {
|
|
582
|
-
/**
|
|
583
|
-
* True, if data is valid to the compiled schema.
|
|
584
|
-
* Does not include async errors.
|
|
585
|
-
*/
|
|
586
|
-
valid: boolean;
|
|
587
|
-
/**
|
|
588
|
-
* List of validation errors or empty
|
|
589
|
-
*/
|
|
590
|
-
errors: JsonError$1[];
|
|
591
|
-
/**
|
|
592
|
-
* List of Promises resolving to `JsonError|undefined` or empty.
|
|
593
|
-
*/
|
|
594
|
-
errorsAsync: Promise<JsonError$1 | undefined>[];
|
|
595
|
-
};
|
|
596
|
-
declare const SchemaNodeMethods$1: {
|
|
597
|
-
/**
|
|
598
|
-
* Compiles a child-schema of this node to its context
|
|
599
|
-
* @returns SchemaNode representing the passed JSON Schema
|
|
600
|
-
*/
|
|
601
|
-
readonly compileSchema: (schema: JsonSchema$1, evaluationPath?: string, schemaLocation?: string, dynamicId?: string) => SchemaNode$1;
|
|
602
|
-
readonly createError: <T extends string = "additional-items-error" | "additional-properties-error" | "all-of-error" | "any-of-error" | "const-error" | "contains-any-error" | "contains-array-error" | "contains-error" | "contains-min-error" | "contains-max-error" | "enum-error" | "exclusive-maximum-error" | "exclusive-minimum-error" | "forbidden-property-error" | "format-date-error" | "format-date-time-error" | "format-duration-error" | "format-email-error" | "format-hostname-error" | "format-ipv4-error" | "format-ipv4-leading-zero-error" | "format-ipv6-error" | "format-ipv6-leading-zero-error" | "format-json-pointer-error" | "format-regex-error" | "format-time-error" | "format-uri-error" | "format-uri-reference-error" | "format-uri-template-error" | "format-url-error" | "format-uuid-error" | "invalid-data-error" | "invalid-property-name-error" | "maximum-error" | "max-items-error" | "max-length-error" | "max-properties-error" | "minimum-error" | "min-items-error" | "min-items-one-error" | "min-length-error" | "min-length-one-error" | "missing-one-of-declarator-error" | "min-properties-error" | "missing-array-item-error" | "missing-dependency-error" | "missing-one-of-property-error" | "multiple-of-error" | "multiple-one-of-error" | "no-additional-properties-error" | "not-error" | "one-of-error" | "one-of-property-error" | "pattern-error" | "pattern-properties-error" | "required-property-error" | "schema-warning" | "type-error" | "undefined-value-error" | "unevaluated-property-error" | "unevaluated-items-error" | "unique-items-error" | "unknown-property-error" | "value-not-empty-error">(code: T, data: ErrorData$1, message?: string) => JsonError$1;
|
|
603
|
-
readonly createSchema: typeof createSchema$1;
|
|
604
|
-
readonly getChildSelection: (property: string | number) => JsonError$1 | SchemaNode$1[];
|
|
605
|
-
readonly getNode: typeof getNode$1;
|
|
606
|
-
readonly getNodeChild: typeof getNodeChild$1;
|
|
607
|
-
/**
|
|
608
|
-
* @returns for $ref, the corresponding SchemaNode or undefined
|
|
609
|
-
*/
|
|
610
|
-
readonly getNodeRef: ($ref: string) => SchemaNode$1 | undefined;
|
|
611
|
-
readonly getNodeRoot: () => SchemaNode$1;
|
|
612
|
-
/**
|
|
613
|
-
* @returns draft version this JSON Schema is evaluated by
|
|
614
|
-
*/
|
|
615
|
-
readonly getDraftVersion: () => DraftVersion$1;
|
|
616
|
-
/**
|
|
617
|
-
* @returns data that is valid to the schema of this node
|
|
618
|
-
*/
|
|
619
|
-
readonly getData: (data?: unknown, options?: TemplateOptions$1) => any;
|
|
620
|
-
/**
|
|
621
|
-
* @returns SchemaNode with a reduced JSON Schema matching the given data
|
|
622
|
-
*/
|
|
623
|
-
readonly reduceNode: (data: unknown, options?: {
|
|
624
|
-
key?: string | number;
|
|
625
|
-
pointer?: string;
|
|
626
|
-
path?: ValidationPath$1;
|
|
627
|
-
}) => OptionalNodeOrError$1;
|
|
628
|
-
/**
|
|
629
|
-
* @returns validation result of data validated by this node's JSON Schema
|
|
630
|
-
*/
|
|
631
|
-
readonly validate: (data: unknown, pointer?: string, path?: ValidationPath$1) => ValidateReturnType$1;
|
|
632
|
-
/**
|
|
633
|
-
* Register a JSON Schema as a remote-schema to be resolved by $ref, $anchor, etc
|
|
634
|
-
* @returns the current node (not the remote schema-node)
|
|
635
|
-
*/
|
|
636
|
-
readonly addRemoteSchema: (url: string, schema: JsonSchema$1) => SchemaNode$1;
|
|
637
|
-
/**
|
|
638
|
-
* @returns a list of all sub-schema as SchemaNode
|
|
639
|
-
*/
|
|
640
|
-
readonly toSchemaNodes: () => SchemaNode$1[];
|
|
641
|
-
/**
|
|
642
|
-
* @returns a list of values (including objects and arrays) and their corresponding JSON Schema as SchemaNode
|
|
643
|
-
*/
|
|
644
|
-
readonly toDataNodes: (data: unknown, pointer?: string) => DataNode$1[];
|
|
645
|
-
readonly toJSON: () => any;
|
|
646
|
-
};
|
|
647
|
-
//#endregion
|
|
648
|
-
//#region src/types.d.ts
|
|
649
|
-
interface JsonSchema$1 {
|
|
650
|
-
[p: string]: any;
|
|
651
|
-
}
|
|
652
|
-
type DefaultErrors$1 = keyof typeof errors$1;
|
|
653
|
-
type ErrorConfig$1 = Record<DefaultErrors$1 | string, string | ((error: ErrorData$1) => void)>;
|
|
654
|
-
type OptionalNodeOrError$1 = {
|
|
655
|
-
node?: SchemaNode$1;
|
|
656
|
-
error: undefined;
|
|
657
|
-
} | {
|
|
658
|
-
node: undefined;
|
|
659
|
-
error?: JsonError$1;
|
|
660
|
-
};
|
|
661
|
-
type NodeOrError$1 = {
|
|
662
|
-
node: SchemaNode$1;
|
|
663
|
-
error: undefined;
|
|
664
|
-
} | {
|
|
665
|
-
node: undefined;
|
|
666
|
-
error: JsonError$1;
|
|
667
|
-
};
|
|
668
|
-
type ErrorData$1<T extends Record<string, unknown> = {
|
|
669
|
-
[p: string]: unknown;
|
|
670
|
-
}> = T & {
|
|
671
|
-
pointer: string;
|
|
672
|
-
schema: JsonSchema$1;
|
|
673
|
-
value: unknown;
|
|
674
|
-
};
|
|
675
|
-
type JsonError$1<T extends ErrorData$1 = ErrorData$1> = {
|
|
676
|
-
type: "error";
|
|
677
|
-
code: ErrorConfig$1 | string;
|
|
678
|
-
message: string;
|
|
679
|
-
data: T;
|
|
680
|
-
[p: string]: unknown;
|
|
681
|
-
};
|
|
682
|
-
/**
|
|
683
|
-
* ts type guard for json error
|
|
684
|
-
* @returns true if passed type is a JsonError
|
|
685
|
-
*/
|
|
686
|
-
//#endregion
|
|
687
213
|
//#region src/getNode.d.ts
|
|
688
214
|
declare function getNode(pointer: string, data: unknown, options: {
|
|
689
215
|
withSchemaWarning: true;
|
|
@@ -909,7 +435,7 @@ declare const SchemaNodeMethods: {
|
|
|
909
435
|
/**
|
|
910
436
|
* @returns a list of values (including objects and arrays) and their corresponding JSON Schema as SchemaNode
|
|
911
437
|
*/
|
|
912
|
-
readonly toDataNodes: (data: unknown, pointer?: string) =>
|
|
438
|
+
readonly toDataNodes: (data: unknown, pointer?: string) => void 0[];
|
|
913
439
|
readonly toJSON: () => any;
|
|
914
440
|
};
|
|
915
441
|
//#endregion
|