From c6ae4a964c586ac4dd1ea256dc60b6ce6f107833 Mon Sep 17 00:00:00 2001 From: Diya Date: Sat, 8 Jun 2024 12:39:41 +0530 Subject: [PATCH] Exposed getDialect --- README.md | 3 +++ lib/experimental.d.ts | 1 + lib/experimental.js | 2 +- lib/keywords.js | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c00a4745..8f00ff4a 100644 --- a/README.md +++ b/README.md @@ -568,6 +568,9 @@ These are available from the `@hyperjump/json-schema/experimental` export. * **getDialectIds** This function retrieves the identifiers of all loaded JSON Schema dialects. +* **getDialect**: (dialectId: string) => Record; + + This function retrieves all the keywords appropriate for a particular dialect. * **Validation**: Keyword A Keyword object that represents a "validate" operation. You would use this diff --git a/lib/experimental.d.ts b/lib/experimental.d.ts index 062fc22e..01d388f3 100644 --- a/lib/experimental.d.ts +++ b/lib/experimental.d.ts @@ -64,6 +64,7 @@ export const loadDialect: (dialectId: string, dialect: { [vocabularyId: string]: export const unloadDialect: (dialectId: string) => void; export const hasDialect: (dialectId: string) => boolean; export const getDialectIds: () => string[]; +export const getDialect: (dialectId: string) => Record; export type Keyword = { id: string; diff --git a/lib/experimental.js b/lib/experimental.js index bd2d9061..bd59dede 100644 --- a/lib/experimental.js +++ b/lib/experimental.js @@ -2,7 +2,7 @@ export { compile, interpret, BASIC } from "./core.js"; export { addKeyword, getKeyword, getKeywordByName, getKeywordName, getKeywordId, defineVocabulary, - loadDialect, unloadDialect, hasDialect, getDialectIds + loadDialect, unloadDialect, hasDialect, getDialectIds, getDialect } from "./keywords.js"; export { getSchema, toSchema, canonicalUri, buildSchemaDocument } from "./schema.js"; export { default as Validation } from "./keywords/validation.js"; diff --git a/lib/keywords.js b/lib/keywords.js index e0a3530e..2027cd06 100644 --- a/lib/keywords.js +++ b/lib/keywords.js @@ -50,7 +50,7 @@ export const getKeywordName = (dialectId, keywordId) => { } }; -const getDialect = (dialectId) => { +export const getDialect = (dialectId) => { if (!(dialectId in _dialects)) { throw Error(`Encountered unknown dialect '${dialectId}'`); }