From a8e270c6a7f28d539ca3449003865669038a5043 Mon Sep 17 00:00:00 2001 From: alexander-akait Date: Tue, 22 Apr 2025 15:54:18 +0300 Subject: [PATCH] fix: export `Schema` and additional schemas --- declarations/index.d.ts | 5 +++++ declarations/validate.d.ts | 4 ++-- src/index.js | 6 ++++++ src/validate.js | 4 ++-- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/declarations/index.d.ts b/declarations/index.d.ts index def01ba..18c0b8e 100644 --- a/declarations/index.d.ts +++ b/declarations/index.d.ts @@ -1,3 +1,8 @@ +export type Schema = import("./validate").Schema; +export type JSONSchema4 = import("./validate").JSONSchema4; +export type JSONSchema6 = import("./validate").JSONSchema6; +export type JSONSchema7 = import("./validate").JSONSchema7; +export type ExtendedSchema = import("./validate").ExtendedSchema; import { validate } from "./validate"; import { ValidationError } from "./validate"; import { enableValidation } from "./validate"; diff --git a/declarations/validate.d.ts b/declarations/validate.d.ts index 800d717..5ed73b2 100644 --- a/declarations/validate.d.ts +++ b/declarations/validate.d.ts @@ -2,7 +2,7 @@ export type JSONSchema4 = import("json-schema").JSONSchema4; export type JSONSchema6 = import("json-schema").JSONSchema6; export type JSONSchema7 = import("json-schema").JSONSchema7; export type ErrorObject = import("ajv").ErrorObject; -export type Extend = { +export type ExtendedSchema = { formatMinimum?: (string | number) | undefined; formatMaximum?: (string | number) | undefined; formatExclusiveMinimum?: (string | boolean) | undefined; @@ -10,7 +10,7 @@ export type Extend = { link?: string | undefined; undefinedAsNull?: boolean | undefined; }; -export type Schema = (JSONSchema4 | JSONSchema6 | JSONSchema7) & Extend; +export type Schema = (JSONSchema4 | JSONSchema6 | JSONSchema7) & ExtendedSchema; export type SchemaUtilErrorObject = ErrorObject & { children?: Array; }; diff --git a/src/index.js b/src/index.js index 1166d6f..71368c2 100644 --- a/src/index.js +++ b/src/index.js @@ -1,3 +1,9 @@ +/** @typedef {import("./validate").Schema} Schema */ +/** @typedef {import("./validate").JSONSchema4} JSONSchema4 */ +/** @typedef {import("./validate").JSONSchema6} JSONSchema6 */ +/** @typedef {import("./validate").JSONSchema7} JSONSchema7 */ +/** @typedef {import("./validate").ExtendedSchema} ExtendedSchema */ + const { validate, ValidationError, diff --git a/src/validate.js b/src/validate.js index 47e982c..3b0cb38 100644 --- a/src/validate.js +++ b/src/validate.js @@ -50,7 +50,7 @@ const getAjv = memoize(() => { /** @typedef {import("ajv").ErrorObject} ErrorObject */ /** - * @typedef {Object} Extend + * @typedef {Object} ExtendedSchema * @property {(string | number)=} formatMinimum * @property {(string | number)=} formatMaximum * @property {(string | boolean)=} formatExclusiveMinimum @@ -59,7 +59,7 @@ const getAjv = memoize(() => { * @property {boolean=} undefinedAsNull */ -/** @typedef {(JSONSchema4 | JSONSchema6 | JSONSchema7) & Extend} Schema */ +/** @typedef {(JSONSchema4 | JSONSchema6 | JSONSchema7) & ExtendedSchema} Schema */ /** @typedef {ErrorObject & { children?: Array }} SchemaUtilErrorObject */