@hyperjump/json-schema 1.7.0 → 1.7.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.
@@ -37,7 +37,7 @@ export const annotate = (instance, keyword, value) => {
37
37
  export const annotatedWith = (instance, keyword, dialectId = defaultDialectId) => {
38
38
  const instances = [];
39
39
 
40
- const keywordId = getKeywordId(dialectId, keyword);
40
+ const keywordId = getKeywordId(keyword, dialectId);
41
41
  for (const instancePointer in instance.annotations) {
42
42
  if (keywordId in instance.annotations[instancePointer]) {
43
43
  instances.push(get(`#${instancePointer}`, instance));
@@ -7,7 +7,7 @@ const id = "https://json-schema.org/keyword/requireAllExcept";
7
7
 
8
8
  const compile = async (schema, _ast, parentSchema) => {
9
9
  const requireAllExcept = await Browser.value(schema);
10
- const propertiesKeyword = getKeywordName(schema.dialectId, "https://json-schema.org/keyword/properties");
10
+ const propertiesKeyword = getKeywordName(schema.document.dialectId, "https://json-schema.org/keyword/properties");
11
11
  const propertiesSchema = await Browser.step(propertiesKeyword, parentSchema);
12
12
  const propertyNames = Browser.typeOf(propertiesSchema) === "object" ? Browser.keys(propertiesSchema) : [];
13
13
 
package/lib/keywords.js CHANGED
@@ -2,7 +2,14 @@ import { toAbsoluteUri } from "./common.js";
2
2
 
3
3
 
4
4
  const _keywords = {};
5
- export const getKeyword = (id) => _keywords[toAbsoluteUri(id)];
5
+ export const getKeyword = (id) => {
6
+ if (id.indexOf("#") !== -1) {
7
+ const absoluteId = toAbsoluteUri(id);
8
+ return { ..._keywords[absoluteId], id };
9
+ }
10
+
11
+ return _keywords[id];
12
+ };
6
13
 
7
14
  export const getKeywordByName = (keyword, dialectId) => {
8
15
  const keywordId = getKeywordId(keyword, dialectId);
package/lib/schema.js CHANGED
@@ -14,20 +14,18 @@ export const schemaPlugin = {
14
14
 
15
15
  return buildSchemaDocument(await response.json(), response.url, contextDialectId);
16
16
  },
17
- fileMatcher: (path) => path.endsWith(".schema.json")
17
+ fileMatcher: (path) => /(\.|\/)schema\.json$/.test(path)
18
18
  };
19
19
 
20
20
  const schemaRegistry = {};
21
21
 
22
22
  export const getSchema = async (uri, browser = undefined) => {
23
23
  if (!browser) {
24
- const cache = {};
24
+ browser = { _cache: {} };
25
25
 
26
26
  for (const uri in schemaRegistry) {
27
- cache[uri] = schemaRegistry[uri];
27
+ browser._cache[uri] = schemaRegistry[uri];
28
28
  }
29
-
30
- browser = { _cache: cache };
31
29
  }
32
30
 
33
31
  const schema = await browserGet(uri, browser);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperjump/json-schema",
3
- "version": "1.7.0",
3
+ "version": "1.7.2",
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",