json-schema-library 11.0.1 → 11.0.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/.vscode/launch.json +37 -0
- package/README.md +4 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +27 -3
- package/dist/index.d.mts +27 -3
- package/dist/index.mjs +1 -1
- package/dist/jlib.js +2 -2
- package/package.json +2 -2
- package/src/SchemaNode.ts +26 -4
- package/src/draftEditor.ts +4 -4
- package/src/errors/errors.ts +3 -2
- package/src/getNode.oneOfProperty.test.ts +43 -0
- package/src/{compileSchema.getNode.test.ts → getNode.test.ts} +1 -1
- package/src/getNode.ts +16 -3
- package/src/getNodeChild.ts +34 -28
- package/src/keywords/oneOf.test.ts +40 -17
- package/src/keywords/oneOf.ts +23 -8
- package/src/methods/getChildSelection.test.ts +18 -0
- package/src/methods/getChildSelection.ts +1 -1
- package/src/{compileSchema.reduceSchema.test.ts → reduceNode.test.ts} +0 -1
- /package/src/{compileSchema.getChild.test.ts → getChildNode.test.ts} +0 -0
- /package/src/{compileSchema.validate.test.ts → validate.test.ts} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -74,7 +74,7 @@ declare function toDataNodes(node: SchemaNode, data: unknown, pointer?: string,
|
|
|
74
74
|
* could be added at the given property (e.g. item-index), thus an array of options is returned. In all other cases
|
|
75
75
|
* a list with a single item will be returned
|
|
76
76
|
*/
|
|
77
|
-
declare function getChildSelection(node: SchemaNode, property: string | number): SchemaNode[]
|
|
77
|
+
declare function getChildSelection(node: SchemaNode, property: string | number): JsonError | SchemaNode[];
|
|
78
78
|
//#endregion
|
|
79
79
|
//#region src/methods/getData.d.ts
|
|
80
80
|
type TemplateOptions = {
|
|
@@ -317,6 +317,22 @@ interface SchemaNodeMethodsType {
|
|
|
317
317
|
createError<T extends string = DefaultErrors>(code: T, data: AnnotationData, message?: string): JsonError;
|
|
318
318
|
createAnnotation<T extends string = DefaultErrors>(code: T, data: AnnotationData, message?: string): JsonAnnotation;
|
|
319
319
|
createSchema(data?: unknown): JsonSchema;
|
|
320
|
+
/**
|
|
321
|
+
* Returns a node matching the given location (pointer) in data
|
|
322
|
+
*
|
|
323
|
+
* - the returned node will have a **reduced schema** based on given input data
|
|
324
|
+
* - return returned node $ref is resolved
|
|
325
|
+
*
|
|
326
|
+
* To resolve dynamic schema where the type of JSON Schema is evaluated by
|
|
327
|
+
* its value, a data object has to be passed in options.
|
|
328
|
+
*
|
|
329
|
+
* Per default this function will return `undefined` schema for valid properties
|
|
330
|
+
* that do not have a defined schema. Use the option `withSchemaWarning: true` to
|
|
331
|
+
* receive an error with `code: schema-warning` containing the location of its
|
|
332
|
+
* last evaluated json-schema.
|
|
333
|
+
*
|
|
334
|
+
* @returns { node } or { error } where node can also be undefined (valid but undefined)
|
|
335
|
+
*/
|
|
320
336
|
getNode(pointer: string, data: unknown, options: {
|
|
321
337
|
withSchemaWarning: true;
|
|
322
338
|
} & GetNodeOptions): NodeOrError;
|
|
@@ -324,6 +340,14 @@ interface SchemaNodeMethodsType {
|
|
|
324
340
|
createSchema: true;
|
|
325
341
|
} & GetNodeOptions): NodeOrError;
|
|
326
342
|
getNode(pointer: string, data?: unknown, options?: GetNodeOptions): OptionalNodeOrError;
|
|
343
|
+
/**
|
|
344
|
+
* Returns the child for the given property-name or array-index
|
|
345
|
+
*
|
|
346
|
+
* - the returned child node is **not reduced**
|
|
347
|
+
* - a child node $ref is resolved
|
|
348
|
+
*
|
|
349
|
+
* @returns { node } or { error } where node can also be undefined (valid but undefined)
|
|
350
|
+
*/
|
|
327
351
|
getNodeChild(key: string | number, data: unknown, options: {
|
|
328
352
|
withSchemaWarning: true;
|
|
329
353
|
} & GetNodeOptions): NodeOrError;
|
|
@@ -564,9 +588,9 @@ declare const draft2020: Draft;
|
|
|
564
588
|
//#endregion
|
|
565
589
|
//#region src/draftEditor.d.ts
|
|
566
590
|
/**
|
|
567
|
-
* @draft-editor https://json-schema.org/draft/
|
|
591
|
+
* @draft-editor https://json-schema.org/draft/2020-12/release-notes
|
|
568
592
|
*
|
|
569
|
-
* Uses Draft
|
|
593
|
+
* Uses Draft 2020-12 and changes resolveOneOf to be fuzzy
|
|
570
594
|
*/
|
|
571
595
|
declare const draftEditor: Draft;
|
|
572
596
|
//#endregion
|
package/dist/index.d.mts
CHANGED
|
@@ -74,7 +74,7 @@ declare function toDataNodes(node: SchemaNode, data: unknown, pointer?: string,
|
|
|
74
74
|
* could be added at the given property (e.g. item-index), thus an array of options is returned. In all other cases
|
|
75
75
|
* a list with a single item will be returned
|
|
76
76
|
*/
|
|
77
|
-
declare function getChildSelection(node: SchemaNode, property: string | number): SchemaNode[]
|
|
77
|
+
declare function getChildSelection(node: SchemaNode, property: string | number): JsonError | SchemaNode[];
|
|
78
78
|
//#endregion
|
|
79
79
|
//#region src/methods/getData.d.ts
|
|
80
80
|
type TemplateOptions = {
|
|
@@ -317,6 +317,22 @@ interface SchemaNodeMethodsType {
|
|
|
317
317
|
createError<T extends string = DefaultErrors>(code: T, data: AnnotationData, message?: string): JsonError;
|
|
318
318
|
createAnnotation<T extends string = DefaultErrors>(code: T, data: AnnotationData, message?: string): JsonAnnotation;
|
|
319
319
|
createSchema(data?: unknown): JsonSchema;
|
|
320
|
+
/**
|
|
321
|
+
* Returns a node matching the given location (pointer) in data
|
|
322
|
+
*
|
|
323
|
+
* - the returned node will have a **reduced schema** based on given input data
|
|
324
|
+
* - return returned node $ref is resolved
|
|
325
|
+
*
|
|
326
|
+
* To resolve dynamic schema where the type of JSON Schema is evaluated by
|
|
327
|
+
* its value, a data object has to be passed in options.
|
|
328
|
+
*
|
|
329
|
+
* Per default this function will return `undefined` schema for valid properties
|
|
330
|
+
* that do not have a defined schema. Use the option `withSchemaWarning: true` to
|
|
331
|
+
* receive an error with `code: schema-warning` containing the location of its
|
|
332
|
+
* last evaluated json-schema.
|
|
333
|
+
*
|
|
334
|
+
* @returns { node } or { error } where node can also be undefined (valid but undefined)
|
|
335
|
+
*/
|
|
320
336
|
getNode(pointer: string, data: unknown, options: {
|
|
321
337
|
withSchemaWarning: true;
|
|
322
338
|
} & GetNodeOptions): NodeOrError;
|
|
@@ -324,6 +340,14 @@ interface SchemaNodeMethodsType {
|
|
|
324
340
|
createSchema: true;
|
|
325
341
|
} & GetNodeOptions): NodeOrError;
|
|
326
342
|
getNode(pointer: string, data?: unknown, options?: GetNodeOptions): OptionalNodeOrError;
|
|
343
|
+
/**
|
|
344
|
+
* Returns the child for the given property-name or array-index
|
|
345
|
+
*
|
|
346
|
+
* - the returned child node is **not reduced**
|
|
347
|
+
* - a child node $ref is resolved
|
|
348
|
+
*
|
|
349
|
+
* @returns { node } or { error } where node can also be undefined (valid but undefined)
|
|
350
|
+
*/
|
|
327
351
|
getNodeChild(key: string | number, data: unknown, options: {
|
|
328
352
|
withSchemaWarning: true;
|
|
329
353
|
} & GetNodeOptions): NodeOrError;
|
|
@@ -564,9 +588,9 @@ declare const draft2020: Draft;
|
|
|
564
588
|
//#endregion
|
|
565
589
|
//#region src/draftEditor.d.ts
|
|
566
590
|
/**
|
|
567
|
-
* @draft-editor https://json-schema.org/draft/
|
|
591
|
+
* @draft-editor https://json-schema.org/draft/2020-12/release-notes
|
|
568
592
|
*
|
|
569
|
-
* Uses Draft
|
|
593
|
+
* Uses Draft 2020-12 and changes resolveOneOf to be fuzzy
|
|
570
594
|
*/
|
|
571
595
|
declare const draftEditor: Draft;
|
|
572
596
|
//#endregion
|