@mastra/schema-compat 1.3.11-alpha.0 → 1.3.11
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/dist/_types/@internal_ai-sdk-v4/dist/index.d.ts +1 -1
- package/dist/_types/@internal_ai-sdk-v4/package.json +1 -0
- package/dist/_types/@internal_ai-sdk-v5/dist/index.d.ts +1 -1
- package/dist/_types/@internal_ai-sdk-v5/package.json +1 -0
- package/dist/_types/@internal_ai-v6/dist/index.d.ts +1 -1
- package/dist/_types/@internal_ai-v6/package.json +1 -0
- package/dist/_types/@standard-schema_spec/package.json +1 -0
- package/dist/_types/@types_json-schema/package.json +1 -0
- package/dist/_types/ajv/dist/ajv.d.ts +18 -0
- package/dist/_types/ajv/dist/compile/codegen/code.d.ts +40 -0
- package/dist/_types/ajv/dist/compile/codegen/index.d.ts +79 -0
- package/dist/_types/ajv/dist/compile/codegen/scope.d.ts +79 -0
- package/dist/_types/ajv/dist/compile/errors.d.ts +13 -0
- package/dist/_types/ajv/dist/compile/index.d.ts +80 -0
- package/dist/_types/ajv/dist/compile/ref_error.d.ts +6 -0
- package/dist/_types/ajv/dist/compile/resolve.d.ts +12 -0
- package/dist/_types/ajv/dist/compile/rules.d.ts +28 -0
- package/dist/_types/ajv/dist/compile/util.d.ts +40 -0
- package/dist/_types/ajv/dist/compile/validate/dataType.d.ts +17 -0
- package/dist/_types/ajv/dist/compile/validate/index.d.ts +42 -0
- package/dist/_types/ajv/dist/compile/validate/subschema.d.ts +47 -0
- package/dist/_types/ajv/dist/core.d.ts +174 -0
- package/dist/_types/ajv/dist/runtime/validation_error.d.ts +7 -0
- package/dist/_types/ajv/dist/types/index.d.ts +183 -0
- package/dist/_types/ajv/dist/types/json-schema.d.ts +125 -0
- package/dist/_types/ajv/dist/types/jtd-schema.d.ts +174 -0
- package/dist/_types/ajv/dist/vocabularies/applicator/additionalItems.d.ts +8 -0
- package/dist/_types/ajv/dist/vocabularies/applicator/additionalProperties.d.ts +6 -0
- package/dist/_types/ajv/dist/vocabularies/applicator/anyOf.d.ts +4 -0
- package/dist/_types/ajv/dist/vocabularies/applicator/contains.d.ts +7 -0
- package/dist/_types/ajv/dist/vocabularies/applicator/dependencies.d.ts +21 -0
- package/dist/_types/ajv/dist/vocabularies/applicator/if.d.ts +6 -0
- package/dist/_types/ajv/dist/vocabularies/applicator/index.d.ts +13 -0
- package/dist/_types/ajv/dist/vocabularies/applicator/items2020.d.ts +6 -0
- package/dist/_types/ajv/dist/vocabularies/applicator/not.d.ts +4 -0
- package/dist/_types/ajv/dist/vocabularies/applicator/oneOf.d.ts +6 -0
- package/dist/_types/ajv/dist/vocabularies/applicator/propertyNames.d.ts +6 -0
- package/dist/_types/ajv/dist/vocabularies/discriminator/index.d.ts +5 -0
- package/dist/_types/ajv/dist/vocabularies/discriminator/types.d.ts +10 -0
- package/dist/_types/ajv/dist/vocabularies/errors.d.ts +9 -0
- package/dist/_types/ajv/dist/vocabularies/format/format.d.ts +8 -0
- package/dist/_types/ajv/dist/vocabularies/unevaluated/unevaluatedItems.d.ts +6 -0
- package/dist/_types/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.d.ts +6 -0
- package/dist/_types/ajv/dist/vocabularies/validation/const.d.ts +6 -0
- package/dist/_types/ajv/dist/vocabularies/validation/dependentRequired.d.ts +5 -0
- package/dist/_types/ajv/dist/vocabularies/validation/enum.d.ts +8 -0
- package/dist/_types/ajv/dist/vocabularies/validation/index.d.ts +16 -0
- package/dist/_types/ajv/dist/vocabularies/validation/limitNumber.d.ts +11 -0
- package/dist/_types/ajv/dist/vocabularies/validation/multipleOf.d.ts +8 -0
- package/dist/_types/ajv/dist/vocabularies/validation/pattern.d.ts +8 -0
- package/dist/_types/ajv/dist/vocabularies/validation/required.d.ts +8 -0
- package/dist/_types/ajv/dist/vocabularies/validation/uniqueItems.d.ts +9 -0
- package/dist/_types/ajv/package.json +1 -0
- package/dist/_types/fast-uri/package.json +1 -0
- package/dist/_types/fast-uri/types/index.d.ts +60 -0
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/json-schema/utils.d.ts +1 -1
- package/dist/{json-schema-C7Uhaeop.cjs → json-schema-8xkiEZVb.cjs} +3 -3
- package/dist/{json-schema-C7Uhaeop.cjs.map → json-schema-8xkiEZVb.cjs.map} +1 -1
- package/dist/{json-schema-BKit3LVN.js → json-schema-DaHLYDhg.js} +3 -3
- package/dist/{json-schema-BKit3LVN.js.map → json-schema-DaHLYDhg.js.map} +1 -1
- package/dist/json-schema.d.ts +3 -3
- package/dist/provider-compats/anthropic.d.ts +2 -2
- package/dist/provider-compats/deepseek.d.ts +2 -2
- package/dist/provider-compats/google.d.ts +1 -1
- package/dist/provider-compats/google.d.ts.map +1 -1
- package/dist/provider-compats/meta.d.ts +2 -2
- package/dist/provider-compats/openai.d.ts +1 -1
- package/dist/{schema-D_ikovK6.js → schema-BwlBcZRB.js} +2 -2
- package/dist/{schema-D_ikovK6.js.map → schema-BwlBcZRB.js.map} +1 -1
- package/dist/{schema-5p36X0wR.cjs → schema-D35TsNfD.cjs} +2 -2
- package/dist/{schema-5p36X0wR.cjs.map → schema-D35TsNfD.cjs.map} +1 -1
- package/dist/schema.cjs +1 -1
- package/dist/schema.js +1 -1
- package/dist/schema.types.d.ts +4 -4
- package/dist/standard-schema/adapters/ai-sdk.d.ts +2 -2
- package/dist/standard-schema/adapters/json-schema.cjs +1 -1
- package/dist/standard-schema/adapters/json-schema.d.ts +2 -2
- package/dist/standard-schema/adapters/json-schema.d.ts.map +1 -1
- package/dist/standard-schema/adapters/json-schema.js +1 -1
- package/dist/standard-schema/adapters/zod-v4.d.ts +1 -1
- package/dist/standard-schema/standard-schema.d.ts +2 -2
- package/dist/standard-schema/standard-schema.types.d.ts +1 -1
- package/dist/zod-to-json.d.ts +1 -1
- package/package.json +8 -8
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
export { Format, FormatDefinition, AsyncFormatDefinition, KeywordDefinition, KeywordErrorDefinition, CodeKeywordDefinition, MacroKeywordDefinition, FuncKeywordDefinition, Vocabulary, Schema, SchemaObject, AnySchemaObject, AsyncSchema, AnySchema, ValidateFunction, AsyncValidateFunction, AnyValidateFunction, ErrorObject, ErrorNoParams, } from "./types";
|
|
2
|
+
export { SchemaCxt, SchemaObjCxt } from "./compile";
|
|
3
|
+
export interface Plugin<Opts> {
|
|
4
|
+
(ajv: Ajv, options?: Opts): Ajv;
|
|
5
|
+
[prop: string]: any;
|
|
6
|
+
}
|
|
7
|
+
export { KeywordCxt } from "./compile/validate";
|
|
8
|
+
export { DefinedError } from "./vocabularies/errors";
|
|
9
|
+
export { JSONType } from "./compile/rules";
|
|
10
|
+
export { JSONSchemaType } from "./types/json-schema";
|
|
11
|
+
export { JTDSchemaType, SomeJTDSchemaType, JTDDataType } from "./types/jtd-schema";
|
|
12
|
+
export { _, str, stringify, nil, Name, Code, CodeGen, CodeGenOptions } from "./compile/codegen";
|
|
13
|
+
import type { Schema, AnySchema, AnySchemaObject, SchemaObject, AsyncSchema, Vocabulary, KeywordDefinition, AddedKeywordDefinition, AnyValidateFunction, ValidateFunction, AsyncValidateFunction, ErrorObject, Format, AddedFormat, RegExpEngine, UriResolver } from "./types";
|
|
14
|
+
import type { JSONSchemaType } from "./types/json-schema";
|
|
15
|
+
import type { JTDSchemaType, SomeJTDSchemaType, JTDDataType } from "./types/jtd-schema";
|
|
16
|
+
import ValidationError from "./runtime/validation_error";
|
|
17
|
+
import MissingRefError from "./compile/ref_error";
|
|
18
|
+
import { ValidationRules } from "./compile/rules";
|
|
19
|
+
import { SchemaEnv } from "./compile";
|
|
20
|
+
import { Code, ValueScope } from "./compile/codegen";
|
|
21
|
+
export type Options = CurrentOptions & DeprecatedOptions;
|
|
22
|
+
export interface CurrentOptions {
|
|
23
|
+
strict?: boolean | "log";
|
|
24
|
+
strictSchema?: boolean | "log";
|
|
25
|
+
strictNumbers?: boolean | "log";
|
|
26
|
+
strictTypes?: boolean | "log";
|
|
27
|
+
strictTuples?: boolean | "log";
|
|
28
|
+
strictRequired?: boolean | "log";
|
|
29
|
+
allowMatchingProperties?: boolean;
|
|
30
|
+
allowUnionTypes?: boolean;
|
|
31
|
+
validateFormats?: boolean;
|
|
32
|
+
$data?: boolean;
|
|
33
|
+
allErrors?: boolean;
|
|
34
|
+
verbose?: boolean;
|
|
35
|
+
discriminator?: boolean;
|
|
36
|
+
unicodeRegExp?: boolean;
|
|
37
|
+
timestamp?: "string" | "date";
|
|
38
|
+
parseDate?: boolean;
|
|
39
|
+
allowDate?: boolean;
|
|
40
|
+
specialNumbers?: "fast" | "null";
|
|
41
|
+
$comment?: true | ((comment: string, schemaPath?: string, rootSchema?: AnySchemaObject) => unknown);
|
|
42
|
+
formats?: {
|
|
43
|
+
[Name in string]?: Format;
|
|
44
|
+
};
|
|
45
|
+
keywords?: Vocabulary;
|
|
46
|
+
schemas?: AnySchema[] | {
|
|
47
|
+
[Key in string]?: AnySchema;
|
|
48
|
+
};
|
|
49
|
+
logger?: Logger | false;
|
|
50
|
+
loadSchema?: (uri: string) => Promise<AnySchemaObject>;
|
|
51
|
+
removeAdditional?: boolean | "all" | "failing";
|
|
52
|
+
useDefaults?: boolean | "empty";
|
|
53
|
+
coerceTypes?: boolean | "array";
|
|
54
|
+
next?: boolean;
|
|
55
|
+
unevaluated?: boolean;
|
|
56
|
+
dynamicRef?: boolean;
|
|
57
|
+
schemaId?: "id" | "$id";
|
|
58
|
+
jtd?: boolean;
|
|
59
|
+
meta?: SchemaObject | boolean;
|
|
60
|
+
defaultMeta?: string | AnySchemaObject;
|
|
61
|
+
validateSchema?: boolean | "log";
|
|
62
|
+
addUsedSchema?: boolean;
|
|
63
|
+
inlineRefs?: boolean | number;
|
|
64
|
+
passContext?: boolean;
|
|
65
|
+
loopRequired?: number;
|
|
66
|
+
loopEnum?: number;
|
|
67
|
+
ownProperties?: boolean;
|
|
68
|
+
multipleOfPrecision?: number;
|
|
69
|
+
int32range?: boolean;
|
|
70
|
+
messages?: boolean;
|
|
71
|
+
code?: CodeOptions;
|
|
72
|
+
uriResolver?: UriResolver;
|
|
73
|
+
}
|
|
74
|
+
export interface CodeOptions {
|
|
75
|
+
es5?: boolean;
|
|
76
|
+
esm?: boolean;
|
|
77
|
+
lines?: boolean;
|
|
78
|
+
optimize?: boolean | number;
|
|
79
|
+
formats?: Code;
|
|
80
|
+
source?: boolean;
|
|
81
|
+
process?: (code: string, schema?: SchemaEnv) => string;
|
|
82
|
+
regExp?: RegExpEngine;
|
|
83
|
+
}
|
|
84
|
+
interface InstanceCodeOptions extends CodeOptions {
|
|
85
|
+
regExp: RegExpEngine;
|
|
86
|
+
optimize: number;
|
|
87
|
+
}
|
|
88
|
+
interface DeprecatedOptions {
|
|
89
|
+
/** @deprecated */
|
|
90
|
+
ignoreKeywordsWithRef?: boolean;
|
|
91
|
+
/** @deprecated */
|
|
92
|
+
jsPropertySyntax?: boolean;
|
|
93
|
+
/** @deprecated */
|
|
94
|
+
unicode?: boolean;
|
|
95
|
+
}
|
|
96
|
+
type RequiredInstanceOptions = {
|
|
97
|
+
[K in "strictSchema" | "strictNumbers" | "strictTypes" | "strictTuples" | "strictRequired" | "inlineRefs" | "loopRequired" | "loopEnum" | "meta" | "messages" | "schemaId" | "addUsedSchema" | "validateSchema" | "validateFormats" | "int32range" | "unicodeRegExp" | "uriResolver"]: NonNullable<Options[K]>;
|
|
98
|
+
} & {
|
|
99
|
+
code: InstanceCodeOptions;
|
|
100
|
+
};
|
|
101
|
+
export type InstanceOptions = Options & RequiredInstanceOptions;
|
|
102
|
+
export interface Logger {
|
|
103
|
+
log(...args: unknown[]): unknown;
|
|
104
|
+
warn(...args: unknown[]): unknown;
|
|
105
|
+
error(...args: unknown[]): unknown;
|
|
106
|
+
}
|
|
107
|
+
export default class Ajv {
|
|
108
|
+
opts: InstanceOptions;
|
|
109
|
+
errors?: ErrorObject[] | null;
|
|
110
|
+
logger: Logger;
|
|
111
|
+
readonly scope: ValueScope;
|
|
112
|
+
readonly schemas: {
|
|
113
|
+
[Key in string]?: SchemaEnv;
|
|
114
|
+
};
|
|
115
|
+
readonly refs: {
|
|
116
|
+
[Ref in string]?: SchemaEnv | string;
|
|
117
|
+
};
|
|
118
|
+
readonly formats: {
|
|
119
|
+
[Name in string]?: AddedFormat;
|
|
120
|
+
};
|
|
121
|
+
readonly RULES: ValidationRules;
|
|
122
|
+
readonly _compilations: Set<SchemaEnv>;
|
|
123
|
+
private readonly _loading;
|
|
124
|
+
private readonly _cache;
|
|
125
|
+
private readonly _metaOpts;
|
|
126
|
+
static ValidationError: typeof ValidationError;
|
|
127
|
+
static MissingRefError: typeof MissingRefError;
|
|
128
|
+
constructor(opts?: Options);
|
|
129
|
+
_addVocabularies(): void;
|
|
130
|
+
_addDefaultMetaSchema(): void;
|
|
131
|
+
defaultMeta(): string | AnySchemaObject | undefined;
|
|
132
|
+
validate(schema: Schema | string, data: unknown): boolean;
|
|
133
|
+
validate(schemaKeyRef: AnySchema | string, data: unknown): boolean | Promise<unknown>;
|
|
134
|
+
validate<T>(schema: Schema | JSONSchemaType<T> | string, data: unknown): data is T;
|
|
135
|
+
validate<T>(schema: JTDSchemaType<T>, data: unknown): data is T;
|
|
136
|
+
validate<N extends never, T extends SomeJTDSchemaType>(schema: T, data: unknown): data is JTDDataType<T>;
|
|
137
|
+
validate<T>(schema: AsyncSchema, data: unknown | T): Promise<T>;
|
|
138
|
+
validate<T>(schemaKeyRef: AnySchema | string, data: unknown): data is T | Promise<T>;
|
|
139
|
+
compile<T = unknown>(schema: Schema | JSONSchemaType<T>, _meta?: boolean): ValidateFunction<T>;
|
|
140
|
+
compile<T = unknown>(schema: JTDSchemaType<T>, _meta?: boolean): ValidateFunction<T>;
|
|
141
|
+
compile<N extends never, T extends SomeJTDSchemaType>(schema: T, _meta?: boolean): ValidateFunction<JTDDataType<T>>;
|
|
142
|
+
compile<T = unknown>(schema: AsyncSchema, _meta?: boolean): AsyncValidateFunction<T>;
|
|
143
|
+
compile<T = unknown>(schema: AnySchema, _meta?: boolean): AnyValidateFunction<T>;
|
|
144
|
+
compileAsync<T = unknown>(schema: SchemaObject | JSONSchemaType<T>, _meta?: boolean): Promise<ValidateFunction<T>>;
|
|
145
|
+
compileAsync<T = unknown>(schema: JTDSchemaType<T>, _meta?: boolean): Promise<ValidateFunction<T>>;
|
|
146
|
+
compileAsync<T = unknown>(schema: AsyncSchema, meta?: boolean): Promise<AsyncValidateFunction<T>>;
|
|
147
|
+
compileAsync<T = unknown>(schema: AnySchemaObject, meta?: boolean): Promise<AnyValidateFunction<T>>;
|
|
148
|
+
addSchema(schema: AnySchema | AnySchema[], // If array is passed, `key` will be ignored
|
|
149
|
+
key?: string, // Optional schema key. Can be passed to `validate` method instead of schema object or id/ref. One schema per instance can have empty `id` and `key`.
|
|
150
|
+
_meta?: boolean, // true if schema is a meta-schema. Used internally, addMetaSchema should be used instead.
|
|
151
|
+
_validateSchema?: boolean | "log"): Ajv;
|
|
152
|
+
addMetaSchema(schema: AnySchemaObject, key?: string, // schema key
|
|
153
|
+
_validateSchema?: boolean | "log"): Ajv;
|
|
154
|
+
validateSchema(schema: AnySchema, throwOrLogError?: boolean): boolean | Promise<unknown>;
|
|
155
|
+
getSchema<T = unknown>(keyRef: string): AnyValidateFunction<T> | undefined;
|
|
156
|
+
removeSchema(schemaKeyRef?: AnySchema | string | RegExp): Ajv;
|
|
157
|
+
addVocabulary(definitions: Vocabulary): Ajv;
|
|
158
|
+
addKeyword(kwdOrDef: string | KeywordDefinition, def?: KeywordDefinition): Ajv;
|
|
159
|
+
getKeyword(keyword: string): AddedKeywordDefinition | boolean;
|
|
160
|
+
removeKeyword(keyword: string): Ajv;
|
|
161
|
+
addFormat(name: string, format: Format): Ajv;
|
|
162
|
+
errorsText(errors?: ErrorObject[] | null | undefined, // optional array of validation errors
|
|
163
|
+
{ separator, dataVar }?: ErrorsTextOptions): string;
|
|
164
|
+
$dataMetaSchema(metaSchema: AnySchemaObject, keywordsJsonPointers: string[]): AnySchemaObject;
|
|
165
|
+
private _removeAllSchemas;
|
|
166
|
+
_addSchema(schema: AnySchema, meta?: boolean, baseId?: string, validateSchema?: boolean | "log", addSchema?: boolean): SchemaEnv;
|
|
167
|
+
private _checkUnique;
|
|
168
|
+
private _compileSchemaEnv;
|
|
169
|
+
private _compileMetaSchema;
|
|
170
|
+
}
|
|
171
|
+
export interface ErrorsTextOptions {
|
|
172
|
+
separator?: string;
|
|
173
|
+
dataVar?: string;
|
|
174
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { URIComponent } from "../../../fast-uri/types/index.js";
|
|
2
|
+
import type { CodeGen, Code, Name, ScopeValueSets, ValueScopeName } from "../compile/codegen";
|
|
3
|
+
import type { SchemaEnv, SchemaCxt, SchemaObjCxt } from "../compile";
|
|
4
|
+
import type { JSONType } from "../compile/rules";
|
|
5
|
+
import type { KeywordCxt } from "../compile/validate";
|
|
6
|
+
import type Ajv from "../core";
|
|
7
|
+
interface _SchemaObject {
|
|
8
|
+
id?: string;
|
|
9
|
+
$id?: string;
|
|
10
|
+
$schema?: string;
|
|
11
|
+
[x: string]: any;
|
|
12
|
+
}
|
|
13
|
+
export interface SchemaObject extends _SchemaObject {
|
|
14
|
+
id?: string;
|
|
15
|
+
$id?: string;
|
|
16
|
+
$schema?: string;
|
|
17
|
+
$async?: false;
|
|
18
|
+
[x: string]: any;
|
|
19
|
+
}
|
|
20
|
+
export interface AsyncSchema extends _SchemaObject {
|
|
21
|
+
$async: true;
|
|
22
|
+
}
|
|
23
|
+
export type AnySchemaObject = SchemaObject | AsyncSchema;
|
|
24
|
+
export type Schema = SchemaObject | boolean;
|
|
25
|
+
export type AnySchema = Schema | AsyncSchema;
|
|
26
|
+
export type SchemaMap = {
|
|
27
|
+
[Key in string]?: AnySchema;
|
|
28
|
+
};
|
|
29
|
+
export interface SourceCode {
|
|
30
|
+
validateName: ValueScopeName;
|
|
31
|
+
validateCode: string;
|
|
32
|
+
scopeValues: ScopeValueSets;
|
|
33
|
+
evaluated?: Code;
|
|
34
|
+
}
|
|
35
|
+
export interface DataValidationCxt<T extends string | number = string | number> {
|
|
36
|
+
instancePath: string;
|
|
37
|
+
parentData: {
|
|
38
|
+
[K in T]: any;
|
|
39
|
+
};
|
|
40
|
+
parentDataProperty: T;
|
|
41
|
+
rootData: Record<string, any> | any[];
|
|
42
|
+
dynamicAnchors: {
|
|
43
|
+
[Ref in string]?: ValidateFunction;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export interface ValidateFunction<T = unknown> {
|
|
47
|
+
(this: Ajv | any, data: any, dataCxt?: DataValidationCxt): data is T;
|
|
48
|
+
errors?: null | ErrorObject[];
|
|
49
|
+
evaluated?: Evaluated;
|
|
50
|
+
schema: AnySchema;
|
|
51
|
+
schemaEnv: SchemaEnv;
|
|
52
|
+
source?: SourceCode;
|
|
53
|
+
}
|
|
54
|
+
export interface JTDParser<T = unknown> {
|
|
55
|
+
(json: string): T | undefined;
|
|
56
|
+
message?: string;
|
|
57
|
+
position?: number;
|
|
58
|
+
}
|
|
59
|
+
export type EvaluatedProperties = {
|
|
60
|
+
[K in string]?: true;
|
|
61
|
+
} | true;
|
|
62
|
+
export type EvaluatedItems = number | true;
|
|
63
|
+
export interface Evaluated {
|
|
64
|
+
props?: EvaluatedProperties;
|
|
65
|
+
items?: EvaluatedItems;
|
|
66
|
+
dynamicProps: boolean;
|
|
67
|
+
dynamicItems: boolean;
|
|
68
|
+
}
|
|
69
|
+
export interface AsyncValidateFunction<T = unknown> extends ValidateFunction<T> {
|
|
70
|
+
(...args: Parameters<ValidateFunction<T>>): Promise<T>;
|
|
71
|
+
$async: true;
|
|
72
|
+
}
|
|
73
|
+
export type AnyValidateFunction<T = any> = ValidateFunction<T> | AsyncValidateFunction<T>;
|
|
74
|
+
export interface ErrorObject<K extends string = string, P = Record<string, any>, S = unknown> {
|
|
75
|
+
keyword: K;
|
|
76
|
+
instancePath: string;
|
|
77
|
+
schemaPath: string;
|
|
78
|
+
params: P;
|
|
79
|
+
propertyName?: string;
|
|
80
|
+
message?: string;
|
|
81
|
+
schema?: S;
|
|
82
|
+
parentSchema?: AnySchemaObject;
|
|
83
|
+
data?: unknown;
|
|
84
|
+
}
|
|
85
|
+
export type ErrorNoParams<K extends string, S = unknown> = ErrorObject<K, Record<string, never>, S>;
|
|
86
|
+
interface _KeywordDef {
|
|
87
|
+
keyword: string | string[];
|
|
88
|
+
type?: JSONType | JSONType[];
|
|
89
|
+
schemaType?: JSONType | JSONType[];
|
|
90
|
+
allowUndefined?: boolean;
|
|
91
|
+
$data?: boolean;
|
|
92
|
+
implements?: string[];
|
|
93
|
+
before?: string;
|
|
94
|
+
post?: boolean;
|
|
95
|
+
metaSchema?: AnySchemaObject;
|
|
96
|
+
validateSchema?: AnyValidateFunction;
|
|
97
|
+
dependencies?: string[];
|
|
98
|
+
error?: KeywordErrorDefinition;
|
|
99
|
+
$dataError?: KeywordErrorDefinition;
|
|
100
|
+
}
|
|
101
|
+
export interface CodeKeywordDefinition extends _KeywordDef {
|
|
102
|
+
code: (cxt: KeywordCxt, ruleType?: string) => void;
|
|
103
|
+
trackErrors?: boolean;
|
|
104
|
+
}
|
|
105
|
+
export type MacroKeywordFunc = (schema: any, parentSchema: AnySchemaObject, it: SchemaCxt) => AnySchema;
|
|
106
|
+
export type CompileKeywordFunc = (schema: any, parentSchema: AnySchemaObject, it: SchemaObjCxt) => DataValidateFunction;
|
|
107
|
+
export interface DataValidateFunction {
|
|
108
|
+
(...args: Parameters<ValidateFunction>): boolean | Promise<any>;
|
|
109
|
+
errors?: Partial<ErrorObject>[];
|
|
110
|
+
}
|
|
111
|
+
export interface SchemaValidateFunction {
|
|
112
|
+
(schema: any, data: any, parentSchema?: AnySchemaObject, dataCxt?: DataValidationCxt): boolean | Promise<any>;
|
|
113
|
+
errors?: Partial<ErrorObject>[];
|
|
114
|
+
}
|
|
115
|
+
export interface FuncKeywordDefinition extends _KeywordDef {
|
|
116
|
+
validate?: SchemaValidateFunction | DataValidateFunction;
|
|
117
|
+
compile?: CompileKeywordFunc;
|
|
118
|
+
schema?: boolean;
|
|
119
|
+
modifying?: boolean;
|
|
120
|
+
async?: boolean;
|
|
121
|
+
valid?: boolean;
|
|
122
|
+
errors?: boolean | "full";
|
|
123
|
+
}
|
|
124
|
+
export interface MacroKeywordDefinition extends FuncKeywordDefinition {
|
|
125
|
+
macro: MacroKeywordFunc;
|
|
126
|
+
}
|
|
127
|
+
export type KeywordDefinition = CodeKeywordDefinition | FuncKeywordDefinition | MacroKeywordDefinition;
|
|
128
|
+
export type AddedKeywordDefinition = KeywordDefinition & {
|
|
129
|
+
type: JSONType[];
|
|
130
|
+
schemaType: JSONType[];
|
|
131
|
+
};
|
|
132
|
+
export interface KeywordErrorDefinition {
|
|
133
|
+
message: string | Code | ((cxt: KeywordErrorCxt) => string | Code);
|
|
134
|
+
params?: Code | ((cxt: KeywordErrorCxt) => Code);
|
|
135
|
+
}
|
|
136
|
+
export type Vocabulary = (KeywordDefinition | string)[];
|
|
137
|
+
export interface KeywordErrorCxt {
|
|
138
|
+
gen: CodeGen;
|
|
139
|
+
keyword: string;
|
|
140
|
+
data: Name;
|
|
141
|
+
$data?: string | false;
|
|
142
|
+
schema: any;
|
|
143
|
+
parentSchema?: AnySchemaObject;
|
|
144
|
+
schemaCode: Code | number | boolean;
|
|
145
|
+
schemaValue: Code | number | boolean;
|
|
146
|
+
schemaType?: JSONType[];
|
|
147
|
+
errsCount?: Name;
|
|
148
|
+
params: KeywordCxtParams;
|
|
149
|
+
it: SchemaCxt;
|
|
150
|
+
}
|
|
151
|
+
export type KeywordCxtParams = {
|
|
152
|
+
[P in string]?: Code | string | number;
|
|
153
|
+
};
|
|
154
|
+
export type FormatValidator<T extends string | number> = (data: T) => boolean;
|
|
155
|
+
export type FormatCompare<T extends string | number> = (data1: T, data2: T) => number | undefined;
|
|
156
|
+
export type AsyncFormatValidator<T extends string | number> = (data: T) => Promise<boolean>;
|
|
157
|
+
export interface FormatDefinition<T extends string | number> {
|
|
158
|
+
type?: T extends string ? "string" | undefined : "number";
|
|
159
|
+
validate: FormatValidator<T> | (T extends string ? string | RegExp : never);
|
|
160
|
+
async?: false | undefined;
|
|
161
|
+
compare?: FormatCompare<T>;
|
|
162
|
+
}
|
|
163
|
+
export interface AsyncFormatDefinition<T extends string | number> {
|
|
164
|
+
type?: T extends string ? "string" | undefined : "number";
|
|
165
|
+
validate: AsyncFormatValidator<T>;
|
|
166
|
+
async: true;
|
|
167
|
+
compare?: FormatCompare<T>;
|
|
168
|
+
}
|
|
169
|
+
export type AddedFormat = true | RegExp | FormatValidator<string> | FormatDefinition<string> | FormatDefinition<number> | AsyncFormatDefinition<string> | AsyncFormatDefinition<number>;
|
|
170
|
+
export type Format = AddedFormat | string;
|
|
171
|
+
export interface RegExpEngine {
|
|
172
|
+
(pattern: string, u: string): RegExpLike;
|
|
173
|
+
code: string;
|
|
174
|
+
}
|
|
175
|
+
export interface RegExpLike {
|
|
176
|
+
test: (s: string) => boolean;
|
|
177
|
+
}
|
|
178
|
+
export interface UriResolver {
|
|
179
|
+
parse(uri: string): URIComponent;
|
|
180
|
+
resolve(base: string, path: string): string;
|
|
181
|
+
serialize(component: URIComponent): string;
|
|
182
|
+
}
|
|
183
|
+
export {};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
type StrictNullChecksWrapper<Name extends string, Type> = undefined extends null ? `strictNullChecks must be true in tsconfig to use ${Name}` : Type;
|
|
2
|
+
type UnionToIntersection<U> = (U extends any ? (_: U) => void : never) extends (_: infer I) => void ? I : never;
|
|
3
|
+
export type SomeJSONSchema = UncheckedJSONSchemaType<Known, true>;
|
|
4
|
+
type UncheckedPartialSchema<T> = Partial<UncheckedJSONSchemaType<T, true>>;
|
|
5
|
+
export type PartialSchema<T> = StrictNullChecksWrapper<"PartialSchema", UncheckedPartialSchema<T>>;
|
|
6
|
+
type JSONType<T extends string, IsPartial extends boolean> = IsPartial extends true ? T | undefined : T;
|
|
7
|
+
interface NumberKeywords {
|
|
8
|
+
minimum?: number;
|
|
9
|
+
maximum?: number;
|
|
10
|
+
exclusiveMinimum?: number;
|
|
11
|
+
exclusiveMaximum?: number;
|
|
12
|
+
multipleOf?: number;
|
|
13
|
+
format?: string;
|
|
14
|
+
}
|
|
15
|
+
interface StringKeywords {
|
|
16
|
+
minLength?: number;
|
|
17
|
+
maxLength?: number;
|
|
18
|
+
pattern?: string;
|
|
19
|
+
format?: string;
|
|
20
|
+
}
|
|
21
|
+
type UncheckedJSONSchemaType<T, IsPartial extends boolean> = (// these two unions allow arbitrary unions of types
|
|
22
|
+
{
|
|
23
|
+
anyOf: readonly UncheckedJSONSchemaType<T, IsPartial>[];
|
|
24
|
+
} | {
|
|
25
|
+
oneOf: readonly UncheckedJSONSchemaType<T, IsPartial>[];
|
|
26
|
+
} | ({
|
|
27
|
+
type: readonly (T extends number ? JSONType<"number" | "integer", IsPartial> : T extends string ? JSONType<"string", IsPartial> : T extends boolean ? JSONType<"boolean", IsPartial> : never)[];
|
|
28
|
+
} & UnionToIntersection<T extends number ? NumberKeywords : T extends string ? StringKeywords : T extends boolean ? {} : never>) | ((T extends number ? {
|
|
29
|
+
type: JSONType<"number" | "integer", IsPartial>;
|
|
30
|
+
} & NumberKeywords : T extends string ? {
|
|
31
|
+
type: JSONType<"string", IsPartial>;
|
|
32
|
+
} & StringKeywords : T extends boolean ? {
|
|
33
|
+
type: JSONType<"boolean", IsPartial>;
|
|
34
|
+
} : T extends readonly [any, ...any[]] ? {
|
|
35
|
+
type: JSONType<"array", IsPartial>;
|
|
36
|
+
items: {
|
|
37
|
+
readonly [K in keyof T]-?: UncheckedJSONSchemaType<T[K], false> & Nullable<T[K]>;
|
|
38
|
+
} & {
|
|
39
|
+
length: T["length"];
|
|
40
|
+
};
|
|
41
|
+
minItems: T["length"];
|
|
42
|
+
} & ({
|
|
43
|
+
maxItems: T["length"];
|
|
44
|
+
} | {
|
|
45
|
+
additionalItems: false;
|
|
46
|
+
}) : T extends readonly any[] ? {
|
|
47
|
+
type: JSONType<"array", IsPartial>;
|
|
48
|
+
items: UncheckedJSONSchemaType<T[0], false>;
|
|
49
|
+
contains?: UncheckedPartialSchema<T[0]>;
|
|
50
|
+
minItems?: number;
|
|
51
|
+
maxItems?: number;
|
|
52
|
+
minContains?: number;
|
|
53
|
+
maxContains?: number;
|
|
54
|
+
uniqueItems?: true;
|
|
55
|
+
additionalItems?: never;
|
|
56
|
+
} : T extends Record<string, any> ? {
|
|
57
|
+
type: JSONType<"object", IsPartial>;
|
|
58
|
+
additionalProperties?: boolean | UncheckedJSONSchemaType<T[string], false>;
|
|
59
|
+
unevaluatedProperties?: boolean | UncheckedJSONSchemaType<T[string], false>;
|
|
60
|
+
properties?: IsPartial extends true ? Partial<UncheckedPropertiesSchema<T>> : UncheckedPropertiesSchema<T>;
|
|
61
|
+
patternProperties?: Record<string, UncheckedJSONSchemaType<T[string], false>>;
|
|
62
|
+
propertyNames?: Omit<UncheckedJSONSchemaType<string, false>, "type"> & {
|
|
63
|
+
type?: "string";
|
|
64
|
+
};
|
|
65
|
+
dependencies?: {
|
|
66
|
+
[K in keyof T]?: readonly (keyof T)[] | UncheckedPartialSchema<T>;
|
|
67
|
+
};
|
|
68
|
+
dependentRequired?: {
|
|
69
|
+
[K in keyof T]?: readonly (keyof T)[];
|
|
70
|
+
};
|
|
71
|
+
dependentSchemas?: {
|
|
72
|
+
[K in keyof T]?: UncheckedPartialSchema<T>;
|
|
73
|
+
};
|
|
74
|
+
minProperties?: number;
|
|
75
|
+
maxProperties?: number;
|
|
76
|
+
} & (IsPartial extends true ? {
|
|
77
|
+
required: readonly (keyof T)[];
|
|
78
|
+
} : [UncheckedRequiredMembers<T>] extends [never] ? {
|
|
79
|
+
required?: readonly UncheckedRequiredMembers<T>[];
|
|
80
|
+
} : {
|
|
81
|
+
required: readonly UncheckedRequiredMembers<T>[];
|
|
82
|
+
}) : T extends null ? {
|
|
83
|
+
type: JSONType<"null", IsPartial>;
|
|
84
|
+
nullable: true;
|
|
85
|
+
} : never) & {
|
|
86
|
+
allOf?: readonly UncheckedPartialSchema<T>[];
|
|
87
|
+
anyOf?: readonly UncheckedPartialSchema<T>[];
|
|
88
|
+
oneOf?: readonly UncheckedPartialSchema<T>[];
|
|
89
|
+
if?: UncheckedPartialSchema<T>;
|
|
90
|
+
then?: UncheckedPartialSchema<T>;
|
|
91
|
+
else?: UncheckedPartialSchema<T>;
|
|
92
|
+
not?: UncheckedPartialSchema<T>;
|
|
93
|
+
})) & {
|
|
94
|
+
[keyword: string]: any;
|
|
95
|
+
$id?: string;
|
|
96
|
+
$ref?: string;
|
|
97
|
+
$defs?: Record<string, UncheckedJSONSchemaType<Known, true>>;
|
|
98
|
+
definitions?: Record<string, UncheckedJSONSchemaType<Known, true>>;
|
|
99
|
+
};
|
|
100
|
+
export type JSONSchemaType<T> = StrictNullChecksWrapper<"JSONSchemaType", UncheckedJSONSchemaType<T, false>>;
|
|
101
|
+
type Known = {
|
|
102
|
+
[key: string]: Known;
|
|
103
|
+
} | [Known, ...Known[]] | Known[] | number | string | boolean | null;
|
|
104
|
+
type UncheckedPropertiesSchema<T> = {
|
|
105
|
+
[K in keyof T]-?: (UncheckedJSONSchemaType<T[K], false> & Nullable<T[K]>) | {
|
|
106
|
+
$ref: string;
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
export type PropertiesSchema<T> = StrictNullChecksWrapper<"PropertiesSchema", UncheckedPropertiesSchema<T>>;
|
|
110
|
+
type UncheckedRequiredMembers<T> = {
|
|
111
|
+
[K in keyof T]-?: undefined extends T[K] ? never : K;
|
|
112
|
+
}[keyof T];
|
|
113
|
+
export type RequiredMembers<T> = StrictNullChecksWrapper<"RequiredMembers", UncheckedRequiredMembers<T>>;
|
|
114
|
+
type Nullable<T> = undefined extends T ? {
|
|
115
|
+
nullable: true;
|
|
116
|
+
const?: null;
|
|
117
|
+
enum?: readonly (T | null)[];
|
|
118
|
+
default?: T | null;
|
|
119
|
+
} : {
|
|
120
|
+
nullable?: false;
|
|
121
|
+
const?: T;
|
|
122
|
+
enum?: readonly T[];
|
|
123
|
+
default?: T;
|
|
124
|
+
};
|
|
125
|
+
export {};
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/** numeric strings */
|
|
2
|
+
type NumberType = "float32" | "float64" | "int8" | "uint8" | "int16" | "uint16" | "int32" | "uint32";
|
|
3
|
+
/** string strings */
|
|
4
|
+
type StringType = "string" | "timestamp";
|
|
5
|
+
/** Generic JTD Schema without inference of the represented type */
|
|
6
|
+
export type SomeJTDSchemaType = (// ref
|
|
7
|
+
{
|
|
8
|
+
ref: string;
|
|
9
|
+
} | {
|
|
10
|
+
type: NumberType | StringType | "boolean";
|
|
11
|
+
} | {
|
|
12
|
+
enum: string[];
|
|
13
|
+
} | {
|
|
14
|
+
elements: SomeJTDSchemaType;
|
|
15
|
+
} | {
|
|
16
|
+
values: SomeJTDSchemaType;
|
|
17
|
+
} | {
|
|
18
|
+
properties: Record<string, SomeJTDSchemaType>;
|
|
19
|
+
optionalProperties?: Record<string, SomeJTDSchemaType>;
|
|
20
|
+
additionalProperties?: boolean;
|
|
21
|
+
} | {
|
|
22
|
+
properties?: Record<string, SomeJTDSchemaType>;
|
|
23
|
+
optionalProperties: Record<string, SomeJTDSchemaType>;
|
|
24
|
+
additionalProperties?: boolean;
|
|
25
|
+
} | {
|
|
26
|
+
discriminator: string;
|
|
27
|
+
mapping: Record<string, SomeJTDSchemaType>;
|
|
28
|
+
} | {}) & {
|
|
29
|
+
nullable?: boolean;
|
|
30
|
+
metadata?: Record<string, unknown>;
|
|
31
|
+
definitions?: Record<string, SomeJTDSchemaType>;
|
|
32
|
+
};
|
|
33
|
+
/** required keys of an object, not undefined */
|
|
34
|
+
type RequiredKeys<T> = {
|
|
35
|
+
[K in keyof T]-?: undefined extends T[K] ? never : K;
|
|
36
|
+
}[keyof T];
|
|
37
|
+
/** optional or undifined-able keys of an object */
|
|
38
|
+
type OptionalKeys<T> = {
|
|
39
|
+
[K in keyof T]-?: undefined extends T[K] ? K : never;
|
|
40
|
+
}[keyof T];
|
|
41
|
+
/** type is true if T is a union type */
|
|
42
|
+
type IsUnion_<T, U extends T = T> = false extends (T extends unknown ? ([U] extends [T] ? false : true) : never) ? false : true;
|
|
43
|
+
type IsUnion<T> = IsUnion_<T>;
|
|
44
|
+
/** type is true if T is identically E */
|
|
45
|
+
type TypeEquality<T, E> = [T] extends [E] ? ([E] extends [T] ? true : false) : false;
|
|
46
|
+
/** type is true if T or null is identically E or null*/
|
|
47
|
+
type NullTypeEquality<T, E> = TypeEquality<T | null, E | null>;
|
|
48
|
+
/** gets only the string literals of a type or null if a type isn't a string literal */
|
|
49
|
+
type EnumString<T> = [T] extends [never] ? null : T extends string ? string extends T ? null : T : null;
|
|
50
|
+
/** true if type is a union of string literals */
|
|
51
|
+
type IsEnum<T> = null extends EnumString<T> ? false : true;
|
|
52
|
+
/** true only if all types are array types (not tuples) */
|
|
53
|
+
type IsElements<T> = false extends IsUnion<T> ? [T] extends [readonly unknown[]] ? undefined extends T[0.5] ? false : true : false : false;
|
|
54
|
+
/** true if the the type is a values type */
|
|
55
|
+
type IsValues<T> = false extends IsUnion<T> ? TypeEquality<keyof T, string> : false;
|
|
56
|
+
/** true if type is a properties type and Union is false, or type is a discriminator type and Union is true */
|
|
57
|
+
type IsRecord<T, Union extends boolean> = Union extends IsUnion<T> ? null extends EnumString<keyof T> ? false : true : false;
|
|
58
|
+
/** true if type represents an empty record */
|
|
59
|
+
type IsEmptyRecord<T> = [T] extends [Record<string, never>] ? [T] extends [never] ? false : true : false;
|
|
60
|
+
/** actual schema */
|
|
61
|
+
export type JTDSchemaType<T, D extends Record<string, unknown> = Record<string, never>> = (// refs - where null wasn't specified, must match exactly
|
|
62
|
+
(null extends EnumString<keyof D> ? never : ({
|
|
63
|
+
[K in keyof D]: [T] extends [D[K]] ? {
|
|
64
|
+
ref: K;
|
|
65
|
+
} : never;
|
|
66
|
+
}[keyof D] & {
|
|
67
|
+
nullable?: false;
|
|
68
|
+
}) | (null extends T ? {
|
|
69
|
+
[K in keyof D]: [Exclude<T, null>] extends [Exclude<D[K], null>] ? {
|
|
70
|
+
ref: K;
|
|
71
|
+
} : never;
|
|
72
|
+
}[keyof D] & {
|
|
73
|
+
nullable: true;
|
|
74
|
+
} : never)) | (unknown extends T ? {
|
|
75
|
+
nullable?: boolean;
|
|
76
|
+
} : never) | ((true extends NullTypeEquality<T, number> ? {
|
|
77
|
+
type: NumberType;
|
|
78
|
+
} : true extends NullTypeEquality<T, boolean> ? {
|
|
79
|
+
type: "boolean";
|
|
80
|
+
} : true extends NullTypeEquality<T, string> ? {
|
|
81
|
+
type: StringType;
|
|
82
|
+
} : true extends NullTypeEquality<T, Date> ? {
|
|
83
|
+
type: "timestamp";
|
|
84
|
+
} : true extends IsEnum<Exclude<T, null>> ? {
|
|
85
|
+
enum: EnumString<Exclude<T, null>>[];
|
|
86
|
+
} : true extends IsElements<Exclude<T, null>> ? T extends readonly (infer E)[] ? {
|
|
87
|
+
elements: JTDSchemaType<E, D>;
|
|
88
|
+
} : never : true extends IsEmptyRecord<Exclude<T, null>> ? {
|
|
89
|
+
properties: Record<string, never>;
|
|
90
|
+
optionalProperties?: Record<string, never>;
|
|
91
|
+
} | {
|
|
92
|
+
optionalProperties: Record<string, never>;
|
|
93
|
+
} : true extends IsValues<Exclude<T, null>> ? T extends Record<string, infer V> ? {
|
|
94
|
+
values: JTDSchemaType<V, D>;
|
|
95
|
+
} : never : true extends IsRecord<Exclude<T, null>, false> ? ([RequiredKeys<Exclude<T, null>>] extends [never] ? {
|
|
96
|
+
properties?: Record<string, never>;
|
|
97
|
+
} : {
|
|
98
|
+
properties: {
|
|
99
|
+
[K in RequiredKeys<T>]: JTDSchemaType<T[K], D>;
|
|
100
|
+
};
|
|
101
|
+
}) & ([OptionalKeys<Exclude<T, null>>] extends [never] ? {
|
|
102
|
+
optionalProperties?: Record<string, never>;
|
|
103
|
+
} : {
|
|
104
|
+
optionalProperties: {
|
|
105
|
+
[K in OptionalKeys<T>]: JTDSchemaType<Exclude<T[K], undefined>, D>;
|
|
106
|
+
};
|
|
107
|
+
}) & {
|
|
108
|
+
additionalProperties?: boolean;
|
|
109
|
+
} : true extends IsRecord<Exclude<T, null>, true> ? {
|
|
110
|
+
[K in keyof Exclude<T, null>]-?: Exclude<T, null>[K] extends string ? {
|
|
111
|
+
discriminator: K;
|
|
112
|
+
mapping: {
|
|
113
|
+
[M in Exclude<T, null>[K]]: JTDSchemaType<Omit<T extends Record<K, M> ? T : never, K>, D>;
|
|
114
|
+
};
|
|
115
|
+
} : never;
|
|
116
|
+
}[keyof Exclude<T, null>] : never) & (null extends T ? {
|
|
117
|
+
nullable: true;
|
|
118
|
+
} : {
|
|
119
|
+
nullable?: false;
|
|
120
|
+
}))) & {
|
|
121
|
+
metadata?: Record<string, unknown>;
|
|
122
|
+
definitions?: {
|
|
123
|
+
[K in keyof D]: JTDSchemaType<D[K], D>;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
type JTDDataDef<S, D extends Record<string, unknown>> = // ref
|
|
127
|
+
(S extends {
|
|
128
|
+
ref: string;
|
|
129
|
+
} ? D extends {
|
|
130
|
+
[K in S["ref"]]: infer V;
|
|
131
|
+
} ? JTDDataDef<V, D> : never : S extends {
|
|
132
|
+
type: NumberType;
|
|
133
|
+
} ? number : S extends {
|
|
134
|
+
type: "boolean";
|
|
135
|
+
} ? boolean : S extends {
|
|
136
|
+
type: "string";
|
|
137
|
+
} ? string : S extends {
|
|
138
|
+
type: "timestamp";
|
|
139
|
+
} ? string | Date : S extends {
|
|
140
|
+
enum: readonly (infer E)[];
|
|
141
|
+
} ? string extends E ? never : [E] extends [string] ? E : never : S extends {
|
|
142
|
+
elements: infer E;
|
|
143
|
+
} ? JTDDataDef<E, D>[] : S extends {
|
|
144
|
+
properties: Record<string, unknown>;
|
|
145
|
+
optionalProperties?: Record<string, unknown>;
|
|
146
|
+
additionalProperties?: boolean;
|
|
147
|
+
} ? {
|
|
148
|
+
-readonly [K in keyof S["properties"]]-?: JTDDataDef<S["properties"][K], D>;
|
|
149
|
+
} & {
|
|
150
|
+
-readonly [K in keyof S["optionalProperties"]]+?: JTDDataDef<S["optionalProperties"][K], D>;
|
|
151
|
+
} & ([S["additionalProperties"]] extends [true] ? Record<string, unknown> : unknown) : S extends {
|
|
152
|
+
properties?: Record<string, unknown>;
|
|
153
|
+
optionalProperties: Record<string, unknown>;
|
|
154
|
+
additionalProperties?: boolean;
|
|
155
|
+
} ? {
|
|
156
|
+
-readonly [K in keyof S["properties"]]-?: JTDDataDef<S["properties"][K], D>;
|
|
157
|
+
} & {
|
|
158
|
+
-readonly [K in keyof S["optionalProperties"]]+?: JTDDataDef<S["optionalProperties"][K], D>;
|
|
159
|
+
} & ([S["additionalProperties"]] extends [true] ? Record<string, unknown> : unknown) : S extends {
|
|
160
|
+
values: infer V;
|
|
161
|
+
} ? Record<string, JTDDataDef<V, D>> : S extends {
|
|
162
|
+
discriminator: infer M;
|
|
163
|
+
mapping: Record<string, unknown>;
|
|
164
|
+
} ? [M] extends [string] ? {
|
|
165
|
+
[K in keyof S["mapping"]]: JTDDataDef<S["mapping"][K], D> & {
|
|
166
|
+
[KM in M]: K;
|
|
167
|
+
};
|
|
168
|
+
}[keyof S["mapping"]] : never : unknown) | (S extends {
|
|
169
|
+
nullable: true;
|
|
170
|
+
} ? null : never);
|
|
171
|
+
export type JTDDataType<S> = S extends {
|
|
172
|
+
definitions: Record<string, unknown>;
|
|
173
|
+
} ? JTDDataDef<S, S["definitions"]> : JTDDataDef<S, Record<string, never>>;
|
|
174
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CodeKeywordDefinition, ErrorObject, AnySchema } from "../../types";
|
|
2
|
+
import type { KeywordCxt } from "../../compile/validate";
|
|
3
|
+
export type AdditionalItemsError = ErrorObject<"additionalItems", {
|
|
4
|
+
limit: number;
|
|
5
|
+
}, AnySchema>;
|
|
6
|
+
declare const def: CodeKeywordDefinition;
|
|
7
|
+
export declare function validateAdditionalItems(cxt: KeywordCxt, items: AnySchema[]): void;
|
|
8
|
+
export default def;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CodeKeywordDefinition, AddedKeywordDefinition, ErrorObject, AnySchema } from "../../types";
|
|
2
|
+
export type AdditionalPropertiesError = ErrorObject<"additionalProperties", {
|
|
3
|
+
additionalProperty: string;
|
|
4
|
+
}, AnySchema>;
|
|
5
|
+
declare const def: CodeKeywordDefinition & AddedKeywordDefinition;
|
|
6
|
+
export default def;
|