@hyperjump/json-schema 1.7.3 → 1.8.0

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/README.md CHANGED
@@ -566,6 +566,10 @@ These are available from the `@hyperjump/json-schema/experimental` export.
566
566
  `$vocabulary` keyword in the meta-schema. The only time you would need to
567
567
  load a dialect manually is if you're creating a distinct version of JSON
568
568
  Schema rather than creating a dialect of an existing version of JSON Schema.
569
+ * **unloadDialect**: (dialectId: string) => void
570
+
571
+ Remove a dialect. You shouldn't need to use this function. It's called for
572
+ you when you call `unregisterSchema`.
569
573
  * **Validation**: Keyword
570
574
 
571
575
  A Keyword object that represents a "validate" operation. You would use this
@@ -63,6 +63,7 @@ export const getKeywordByName: <A>(keywordName: string, dialectId: string) => Ke
63
63
  export const getKeywordId: (keywordName: string, dialectId: string) => string;
64
64
  export const defineVocabulary: (id: string, keywords: { [keyword: string]: string }) => void;
65
65
  export const loadDialect: (dialectId: string, dialect: { [vocabularyId: string]: boolean }, allowUnknownKeywords?: boolean) => void;
66
+ export const unloadDialect: (dialectId: string) => void;
66
67
  export const hasDialect: (dialectId: string) => boolean;
67
68
 
68
69
  export type Keyword<A> = {
@@ -1,4 +1,8 @@
1
1
  export { compile, interpret, BASIC, DETAILED, VERBOSE } from "./core.js";
2
- export { getKeyword, getKeywordByName, addKeyword, defineVocabulary, getKeywordName, getKeywordId, loadDialect, hasDialect } from "./keywords.js";
2
+ export {
3
+ addKeyword, getKeyword, getKeywordByName, getKeywordName, getKeywordId,
4
+ defineVocabulary,
5
+ loadDialect, unloadDialect, hasDialect
6
+ } from "./keywords.js";
3
7
  export { getSchema, toSchema, canonicalUri, buildSchemaDocument } from "./schema.js";
4
8
  export { default as Validation } from "./keywords/validation.js";
package/lib/keywords.js CHANGED
@@ -81,3 +81,8 @@ export const loadDialect = (dialectId, dialect, allowUnknownKeywords = false) =>
81
81
  }
82
82
  });
83
83
  };
84
+
85
+ export const unloadDialect = (dialectId) => {
86
+ delete _allowUnknownKeywords[dialectId];
87
+ delete _dialects[dialectId];
88
+ };
package/lib/schema.js CHANGED
@@ -3,7 +3,7 @@ import { get as browserGet } from "@hyperjump/browser";
3
3
  import { Reference } from "@hyperjump/browser/jref";
4
4
  import { append } from "@hyperjump/json-pointer";
5
5
  import { resolveIri, toAbsoluteIri, normalizeIri } from "@hyperjump/uri";
6
- import { getKeywordName, loadDialect } from "./keywords.js";
6
+ import { getKeywordName, loadDialect, unloadDialect } from "./keywords.js";
7
7
  import { uriFragment, jsonStringify, jsonTypeOf, toRelativeIri } from "./common.js";
8
8
 
9
9
 
@@ -52,7 +52,9 @@ export const registerSchema = (schema, retrievalUri, contextDialectId) => {
52
52
  };
53
53
 
54
54
  export const unregisterSchema = (uri) => {
55
- delete schemaRegistry[toAbsoluteIri(uri)];
55
+ const normalizedUri = toAbsoluteIri(uri);
56
+ unloadDialect(normalizedUri);
57
+ delete schemaRegistry[normalizedUri];
56
58
  };
57
59
 
58
60
  export const buildSchemaDocument = (schema, id, dialectId, embedded = {}) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperjump/json-schema",
3
- "version": "1.7.3",
3
+ "version": "1.8.0",
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",