@hyperjump/json-schema 1.9.3 → 1.9.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 Jason Desrosiers
3
+ Copyright (c) 2022 Hyperjump Software, LLC
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/lib/instance.d.ts CHANGED
@@ -23,14 +23,14 @@ export const values: (node: JsonNode) => Generator<JsonNode>;
23
23
  export const entries: (node: JsonNode) => Generator<[JsonNode, JsonNode]>;
24
24
  export const length: (node: JsonNode) => number;
25
25
 
26
- export const allNodes: (node) => Generator<JsonNode>;
26
+ export const allNodes: (node: JsonNode) => Generator<JsonNode>;
27
27
 
28
28
  export type JsonNode = {
29
29
  baseUri: string;
30
30
  pointer: string;
31
31
  type: JsonNodeType;
32
32
  children: JsonNode[];
33
- parent: JsonNode;
33
+ parent?: JsonNode;
34
34
  root: JsonNode;
35
35
  valid: boolean;
36
36
  errors: Record<string, string>;
package/lib/instance.js CHANGED
@@ -118,7 +118,9 @@ export const values = function* (node) {
118
118
  }
119
119
 
120
120
  for (const property of node.children) {
121
- yield property.children[1];
121
+ if (property.children[1]) {
122
+ yield property.children[1];
123
+ }
122
124
  }
123
125
  };
124
126
 
@@ -128,7 +130,9 @@ export const entries = function* (node) {
128
130
  }
129
131
 
130
132
  for (const property of node.children) {
131
- yield property.children;
133
+ if (property.children.length === 2) {
134
+ yield property.children;
135
+ }
132
136
  }
133
137
  };
134
138
 
@@ -1,13 +1,18 @@
1
1
  import * as Browser from "@hyperjump/browser";
2
2
  import * as Instance from "../../annotations/annotated-instance.js";
3
+ import { pointerSegments } from "@hyperjump/json-pointer";
3
4
 
4
5
 
5
6
  const id = "https://json-schema.org/keyword/unknown";
6
7
 
7
- const compile = (schema) => Browser.value(schema);
8
+ const compile = (schema) => {
9
+ const keywordName = [...pointerSegments(schema.cursor)].pop();
10
+ return [keywordName, Browser.value(schema)];
11
+ };
8
12
 
9
- const interpret = (value, instance, _ast, _dynamicAnchors, _quiet, schemaLocation) => {
10
- Instance.setAnnotation(instance, id, schemaLocation, value);
13
+ const interpret = ([keywordName, value], instance, _ast, _dynamicAnchors, _quiet, schemaLocation) => {
14
+ const keywordId = `${id}#${keywordName}`;
15
+ Instance.setAnnotation(instance, keywordId, schemaLocation, value);
11
16
  return true;
12
17
  };
13
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperjump/json-schema",
3
- "version": "1.9.3",
3
+ "version": "1.9.4",
4
4
  "description": "A JSON Schema validator with support for custom keywords, vocabularies, and dialects",
5
5
  "type": "module",
6
6
  "main": "./stable/index.js",