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/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[] | JsonError;
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/2019-09/release-notes
591
+ * @draft-editor https://json-schema.org/draft/2020-12/release-notes
568
592
  *
569
- * Uses Draft 2019-09 and changes resolveOneOf to be fuzzy
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[] | JsonError;
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/2019-09/release-notes
591
+ * @draft-editor https://json-schema.org/draft/2020-12/release-notes
568
592
  *
569
- * Uses Draft 2019-09 and changes resolveOneOf to be fuzzy
593
+ * Uses Draft 2020-12 and changes resolveOneOf to be fuzzy
570
594
  */
571
595
  declare const draftEditor: Draft;
572
596
  //#endregion