@powerlines/schema 0.11.81 → 0.11.82
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/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/bundle.cjs +49 -0
- package/dist/bundle.d.cts +21 -0
- package/dist/bundle.d.cts.map +1 -0
- package/dist/bundle.d.mts +21 -0
- package/dist/bundle.d.mts.map +1 -0
- package/dist/bundle.mjs +48 -0
- package/dist/bundle.mjs.map +1 -0
- package/dist/codegen.cjs +312 -0
- package/dist/codegen.d.cts +67 -0
- package/dist/codegen.d.cts.map +1 -0
- package/dist/codegen.d.mts +67 -0
- package/dist/codegen.d.mts.map +1 -0
- package/dist/codegen.mjs +306 -0
- package/dist/codegen.mjs.map +1 -0
- package/dist/constants.cjs +61 -0
- package/dist/constants.d.cts +17 -0
- package/dist/constants.d.cts.map +1 -0
- package/dist/constants.d.mts +17 -0
- package/dist/constants.d.mts.map +1 -0
- package/dist/constants.mjs +57 -0
- package/dist/constants.mjs.map +1 -0
- package/dist/extract.cjs +482 -0
- package/dist/extract.d.cts +125 -0
- package/dist/extract.d.cts.map +1 -0
- package/dist/extract.d.mts +125 -0
- package/dist/extract.d.mts.map +1 -0
- package/dist/extract.mjs +472 -0
- package/dist/extract.mjs.map +1 -0
- package/dist/helpers.cjs +241 -0
- package/dist/helpers.d.cts +121 -0
- package/dist/helpers.d.cts.map +1 -0
- package/dist/helpers.d.mts +121 -0
- package/dist/helpers.d.mts.map +1 -0
- package/dist/helpers.mjs +234 -0
- package/dist/helpers.mjs.map +1 -0
- package/dist/index.cjs +95 -2434
- package/dist/index.d.cts +11 -1892
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +11 -1892
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +12 -2321
- package/dist/metadata.cjs +53 -0
- package/dist/metadata.d.cts +31 -0
- package/dist/metadata.d.cts.map +1 -0
- package/dist/metadata.d.mts +31 -0
- package/dist/metadata.d.mts.map +1 -0
- package/dist/metadata.mjs +52 -0
- package/dist/metadata.mjs.map +1 -0
- package/dist/persistence.cjs +74 -0
- package/dist/persistence.d.cts +47 -0
- package/dist/persistence.d.cts.map +1 -0
- package/dist/persistence.d.mts +47 -0
- package/dist/persistence.d.mts.map +1 -0
- package/dist/persistence.mjs +71 -0
- package/dist/persistence.mjs.map +1 -0
- package/dist/reflection.cjs +426 -0
- package/dist/reflection.d.cts +11 -0
- package/dist/reflection.d.cts.map +1 -0
- package/dist/reflection.d.mts +11 -0
- package/dist/reflection.d.mts.map +1 -0
- package/dist/reflection.mjs +425 -0
- package/dist/reflection.mjs.map +1 -0
- package/dist/resolve.cjs +105 -0
- package/dist/resolve.d.cts +36 -0
- package/dist/resolve.d.cts.map +1 -0
- package/dist/resolve.d.mts +36 -0
- package/dist/resolve.d.mts.map +1 -0
- package/dist/resolve.mjs +102 -0
- package/dist/resolve.mjs.map +1 -0
- package/dist/type-checks.cjs +633 -0
- package/dist/type-checks.d.cts +316 -0
- package/dist/type-checks.d.cts.map +1 -0
- package/dist/type-checks.d.mts +316 -0
- package/dist/type-checks.d.mts.map +1 -0
- package/dist/type-checks.mjs +594 -0
- package/dist/type-checks.mjs.map +1 -0
- package/dist/types.d.cts +1152 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +1152 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/validate.cjs +27 -0
- package/dist/validate.mjs +25 -0
- package/dist/validate.mjs.map +1 -0
- package/package.json +6 -6
- package/dist/index.mjs.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,1896 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
1
|
+
import { BundleOptions, bundle } from "./bundle.cjs";
|
|
2
|
+
import { JSON_SCHEMA_METADATA_KEYS, JSON_SCHEMA_PRIMITIVE_TYPES, JSON_SCHEMA_TYPES, JsonSchemaTypeNames, VALID_SOURCE_FILE_EXTENSIONS } from "./constants.cjs";
|
|
3
|
+
import { BaseSchemaSource, ExtractedSchema, JsonSchema, JsonSchemaAllOf, JsonSchemaAny, JsonSchemaAnyOf, JsonSchemaArray, JsonSchemaBigint, JsonSchemaBoolean, JsonSchemaConditionalKeywords, JsonSchemaDate, JsonSchemaDecimal, JsonSchemaDecimalFormat, JsonSchemaEnum, JsonSchemaInteger, JsonSchemaIntegerFormat, JsonSchemaKeywords, JsonSchemaLike, JsonSchemaLiteral, JsonSchemaLogicKeywords, JsonSchemaMap, JsonSchemaMetadataKeywords, JsonSchemaNativeEnum, JsonSchemaNever, JsonSchemaNull, JsonSchemaNullable, JsonSchemaNumber, JsonSchemaNumberFormat, JsonSchemaObject, JsonSchemaPrimitiveType, JsonSchemaPrimitiveUnion, JsonSchemaRecord, JsonSchemaRecordPropertyNames, JsonSchemaRef, JsonSchemaSchemaSource, JsonSchemaSet, JsonSchemaString, JsonSchemaStringFormat, JsonSchemaTuple, JsonSchemaType, JsonSchemaUndefined, JsonSchemaUnion, JsonSchemaUnknown, ReflectionSchemaSource, Schema, SchemaInput, SchemaInputVariant, SchemaSource, SchemaSourceInput, SchemaSourceVariant, StandardSchemaSchemaSource, UntypedInputObject, UntypedSchema, UntypedSchemaSource, ValibotSchema, ValibotSchemaSource, Zod3SchemaSource } from "./types.cjs";
|
|
4
|
+
import { generateCode, generateParserCode, generateValidationCode, getJsonSchemaType, stringifyType, stringifyValue } from "./codegen.cjs";
|
|
5
|
+
import { bundleReferences, extract, extractHash, extractJsonSchema, extractReflection, extractResolvedVariant, extractSchema, extractSchemaWithSource, extractSource, extractVariant } from "./extract.cjs";
|
|
6
|
+
import { GetPropertiesResult, addProperty, getJsonSchema, getJsonSchemaObject, getProperties, getPropertiesList, isPropertyOptional, isSchemaNullable, isValidSchemaInputFile, merge } from "./helpers.cjs";
|
|
7
|
+
import { applyJsonSchemaMetadata, getPrimarySchemaType, readSchemaTypes } from "./metadata.cjs";
|
|
8
|
+
import { getCacheDirectory, getCacheFilePath, readSchema, readSchemaSafe, writeSchema } from "./persistence.cjs";
|
|
9
|
+
import { reflectionToJsonSchema } from "./reflection.cjs";
|
|
10
|
+
import { resolve, resolveModule, resolveReflection } from "./resolve.cjs";
|
|
11
|
+
import { isJsonSchema, isJsonSchemaAllOf, isJsonSchemaAny, isJsonSchemaAnyOf, isJsonSchemaArray, isJsonSchemaBigint, isJsonSchemaBoolean, isJsonSchemaDate, isJsonSchemaDecimal, isJsonSchemaEnum, isJsonSchemaInteger, isJsonSchemaKeywords, isJsonSchemaLiteral, isJsonSchemaMap, isJsonSchemaNativeEnum, isJsonSchemaNever, isJsonSchemaNull, isJsonSchemaNullable, isJsonSchemaNumber, isJsonSchemaObject, isJsonSchemaPrimitiveType, isJsonSchemaPrimitiveUnion, isJsonSchemaRecord, isJsonSchemaRef, isJsonSchemaSet, isJsonSchemaString, isJsonSchemaTuple, isJsonSchemaType, isJsonSchemaUndefined, isJsonSchemaUnion, isJsonSchemaUnknown, isNullOnlyJsonSchema, isSchema, isSchemaObject, isSchemaWithSource, isStandardSchema, isUntypedInput, isUntypedInputStrict, isUntypedSchema, isUntypedSchemaStrict, isValibotSchema } from "./type-checks.cjs";
|
|
11
12
|
|
|
12
|
-
//#region src/bundle.d.ts
|
|
13
|
-
type BundleOptions = DeepPartial<BuildOptions> & {
|
|
14
|
-
name?: string;
|
|
15
|
-
resolve?: DeepPartial<ResolveOptions>;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Bundle a type definition to a module.
|
|
19
|
-
*
|
|
20
|
-
* @param context - The context object containing the environment paths.
|
|
21
|
-
* @param file - The file path to bundle.
|
|
22
|
-
* @param options - Optional overrides for the ESBuild configuration.
|
|
23
|
-
* @returns A promise that resolves to the bundled module.
|
|
24
|
-
*/
|
|
25
|
-
declare function bundle<TContext extends UnresolvedContext>(context: TContext, file: string, options?: BundleOptions): Promise<OutputFile>;
|
|
26
|
-
//#endregion
|
|
27
|
-
//#region src/constants.d.ts
|
|
28
|
-
declare const VALID_SOURCE_FILE_EXTENSIONS: string[];
|
|
29
|
-
declare const JsonSchemaTypeNames: {
|
|
30
|
-
readonly STRING: "string";
|
|
31
|
-
readonly NUMBER: "number";
|
|
32
|
-
readonly INTEGER: "integer";
|
|
33
|
-
readonly BOOLEAN: "boolean";
|
|
34
|
-
readonly NULL: "null";
|
|
35
|
-
readonly OBJECT: "object";
|
|
36
|
-
readonly ARRAY: "array";
|
|
37
|
-
};
|
|
38
|
-
declare const JSON_SCHEMA_PRIMITIVE_TYPES: readonly ["string", "number", "integer", "boolean", "null"];
|
|
39
|
-
declare const JSON_SCHEMA_TYPES: readonly ["string", "number", "integer", "boolean", "null", "array", "object"];
|
|
40
|
-
declare const JSON_SCHEMA_METADATA_KEYS: ("title" | "description" | "docs" | "examples" | "alias" | "tags" | "deprecated" | "hidden" | "ignore" | "internal" | "runtime" | "readOnly" | "writeOnly")[];
|
|
41
|
-
//#endregion
|
|
42
|
-
//#region src/types.d.ts
|
|
43
|
-
/**
|
|
44
|
-
* Alias for the Untyped object-input schema shape.
|
|
45
|
-
*/
|
|
46
|
-
type UntypedInputObject = InputObject;
|
|
47
|
-
/**
|
|
48
|
-
* Alias for the Untyped schema document shape.
|
|
49
|
-
*/
|
|
50
|
-
type UntypedSchema = Schema$1;
|
|
51
|
-
/**
|
|
52
|
-
* A Valibot schema instance.
|
|
53
|
-
*
|
|
54
|
-
* @template TInput - The raw input type accepted by the schema.
|
|
55
|
-
* @template TOutput - The parsed output type produced by the schema.
|
|
56
|
-
* @template TIssue - The issue type emitted for validation errors.
|
|
57
|
-
*/
|
|
58
|
-
type ValibotSchema<TInput = unknown, TOutput = unknown, TIssue extends BaseIssue<unknown> = BaseIssue<unknown>> = BaseSchema<TInput, TOutput, TIssue>;
|
|
59
|
-
/**
|
|
60
|
-
* Primitive JSON Schema `type` keyword values.
|
|
61
|
-
*
|
|
62
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-7.6.1
|
|
63
|
-
*/
|
|
64
|
-
type JsonSchemaPrimitiveType = (typeof JSON_SCHEMA_PRIMITIVE_TYPES)[number];
|
|
65
|
-
/**
|
|
66
|
-
* JSON Schema type names for the `type` keyword.
|
|
67
|
-
*
|
|
68
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-7.6.1
|
|
69
|
-
*/
|
|
70
|
-
type JsonSchemaType = (typeof JSON_SCHEMA_TYPES)[number];
|
|
71
|
-
/**
|
|
72
|
-
* Semantic format names for JSON Schema integer types.
|
|
73
|
-
*/
|
|
74
|
-
type JsonSchemaIntegerFormat = "int8" | "uint8" | "int16" | "uint16" | "int32" | "uint32" | "int64" | "uint64";
|
|
75
|
-
/**
|
|
76
|
-
* Semantic format names for JSON Schema decimal types.
|
|
77
|
-
*/
|
|
78
|
-
type JsonSchemaDecimalFormat = "float" | "double";
|
|
79
|
-
/**
|
|
80
|
-
* Semantic format names for JSON Schema numeric types, including both integer and decimal formats.
|
|
81
|
-
*/
|
|
82
|
-
type JsonSchemaNumberFormat = JsonSchemaDecimalFormat | JsonSchemaIntegerFormat;
|
|
83
|
-
/**
|
|
84
|
-
* Semantic format names for JSON Schema string types.
|
|
85
|
-
*/
|
|
86
|
-
type JsonSchemaStringFormat = "binary" | "date" | "time" | "date-time" | "iso-time" | "iso-date-time" | "duration" | "uri" | "uri-reference" | "uri-template" | "url" | "email" | "hostname" | "ipv4" | "ipv6" | "regex" | "uuid" | "json-pointer" | "json-pointer-uri-fragment" | "relative-json-pointer" | "byte" | "password";
|
|
87
|
-
/**
|
|
88
|
-
* Metadata and annotation keywords shared across JSON Schema shapes.
|
|
89
|
-
*
|
|
90
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-8
|
|
91
|
-
*/
|
|
92
|
-
interface JsonSchemaMetadataKeywords {
|
|
93
|
-
/**
|
|
94
|
-
* A unique identifier keyword that is used to identify a schema and can be used for referencing the schema within other schemas. It is a URI that serves as a unique identifier for the schema.
|
|
95
|
-
*
|
|
96
|
-
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.1
|
|
97
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-8.2.1
|
|
98
|
-
*/
|
|
99
|
-
$id?: string;
|
|
100
|
-
/**
|
|
101
|
-
* A keyword used to specify the version of the JSON Schema specification that the schema adheres to. It is a URI that indicates which version of the JSON Schema specification the schema is written against.
|
|
102
|
-
*
|
|
103
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-8.1.1
|
|
104
|
-
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.2
|
|
105
|
-
*/
|
|
106
|
-
$schema?: string;
|
|
107
|
-
/**
|
|
108
|
-
* A keyword that is used in meta-schemas to identify the vocabularies available for use in schemas described by that meta-schema.
|
|
109
|
-
*
|
|
110
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-8.1.2
|
|
111
|
-
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.2
|
|
112
|
-
*/
|
|
113
|
-
$vocabulary?: Record<string, boolean>;
|
|
114
|
-
/**
|
|
115
|
-
* A comment or annotation for the schema, which can be used to provide additional context or information about the schema. It allows schema authors to include human-readable explanations or notes within the schema without affecting its validation behavior.
|
|
116
|
-
*
|
|
117
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-8.3
|
|
118
|
-
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.3
|
|
119
|
-
*/
|
|
120
|
-
$comment?: string;
|
|
121
|
-
/**
|
|
122
|
-
* A plain-name fragment identifier for the schema resource.
|
|
123
|
-
*
|
|
124
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-8.2.2
|
|
125
|
-
*/
|
|
126
|
-
$anchor?: string;
|
|
127
|
-
/**
|
|
128
|
-
* The `$defs` keyword is used to define reusable sub-schemas within a JSON Schema. It allows you to define sub-schemas that can be referenced elsewhere in the schema using the `$ref` keyword. The `$defs` keyword is an object where each key is a unique identifier for the sub-schema, and the value is the sub-schema itself.
|
|
129
|
-
*
|
|
130
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-8.2.4
|
|
131
|
-
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.4
|
|
132
|
-
* @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00#section-8.2.4
|
|
133
|
-
* @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#appendix-A
|
|
134
|
-
*/
|
|
135
|
-
$defs?: Record<string, JsonSchema>;
|
|
136
|
-
/**
|
|
137
|
-
* The `$dynamicRef` keyword is used to reference a dynamic anchor defined in a JSON Schema. It allows you to reference a sub-schema that is determined at runtime based on the context of the validation. The value of `$dynamicRef` is a URI that points to the dynamic anchor defined using the `$dynamicAnchor` keyword.
|
|
138
|
-
*
|
|
139
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-8.2.3.2
|
|
140
|
-
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.6
|
|
141
|
-
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.7
|
|
142
|
-
*/
|
|
143
|
-
$dynamicRef?: string;
|
|
144
|
-
/**
|
|
145
|
-
* The `$dynamicAnchor` keyword is used to define a dynamic anchor within a JSON Schema. A dynamic anchor is a placeholder that can be referenced using the `$dynamicRef` keyword. It allows for more flexible referencing of sub-schemas, as the actual schema that the dynamic anchor points to can be determined at runtime based on the context of the validation.
|
|
146
|
-
*
|
|
147
|
-
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.6
|
|
148
|
-
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.7
|
|
149
|
-
*/
|
|
150
|
-
$dynamicAnchor?: string;
|
|
151
|
-
/**
|
|
152
|
-
* A name for the schema, which can be used by documentation tools or other libraries that support this feature to provide a human-readable name or description for the schema. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the schema when used in conjunction with compatible tools.
|
|
153
|
-
*/
|
|
154
|
-
name?: string;
|
|
155
|
-
/**
|
|
156
|
-
* A title for the schema, which can be used by documentation tools or other libraries that support this feature to provide a human-readable name or description for the schema. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the schema when used in conjunction with compatible tools.
|
|
157
|
-
*/
|
|
158
|
-
title?: string;
|
|
159
|
-
/**
|
|
160
|
-
* A description for the schema, which can be used by documentation tools or other libraries that support this feature to provide a human-readable explanation or summary of the schema's purpose and usage. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the schema when used in conjunction with compatible tools.
|
|
161
|
-
*/
|
|
162
|
-
description?: string;
|
|
163
|
-
/**
|
|
164
|
-
* A URL to external documentation for the schema, which can be used by documentation tools or other libraries that support this feature to provide additional information or resources related to the schema. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the schema when used in conjunction with compatible tools.
|
|
165
|
-
*/
|
|
166
|
-
docs?: string;
|
|
167
|
-
/**
|
|
168
|
-
* An array of example values that conform to the schema. This property can be used to provide sample data for documentation purposes or to assist developers in understanding the expected structure and content of the data that the schema represents. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
169
|
-
*/
|
|
170
|
-
examples?: unknown[];
|
|
171
|
-
/**
|
|
172
|
-
* An array of strings or an alias reference to indicate that the field is an alias for one or more other fields.
|
|
173
|
-
*/
|
|
174
|
-
alias?: string[];
|
|
175
|
-
/**
|
|
176
|
-
* An array of strings indicating groups that the schema belongs to. This property can be used for organizational or categorization purposes in documentation tools or other libraries that support this feature. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the schema when used in conjunction with compatible tools.
|
|
177
|
-
*/
|
|
178
|
-
tags?: string[];
|
|
179
|
-
/**
|
|
180
|
-
* An indicator specifying if the field is deprecated or not. This property can be used by documentation tools or other libraries that support this feature to provide additional information or warnings about the usage of the schema. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the schema when used in conjunction with compatible tools.
|
|
181
|
-
*/
|
|
182
|
-
deprecated?: boolean | string | {
|
|
183
|
-
message?: string;
|
|
184
|
-
since?: string;
|
|
185
|
-
alternative?: string;
|
|
186
|
-
};
|
|
187
|
-
/**
|
|
188
|
-
* An indicator specifying if the field should be marked as hidden or not. This property can be used by documentation tools or other libraries that support this feature to provide additional information or warnings about the usage of the schema. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the schema when used in conjunction with compatible tools.
|
|
189
|
-
*/
|
|
190
|
-
hidden?: boolean;
|
|
191
|
-
/**
|
|
192
|
-
* An indicator specifying if the field should be ignored or not. This property can be used by documentation tools or other libraries that support this feature to provide additional information or warnings about the usage of the schema. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the schema when used in conjunction with compatible tools.
|
|
193
|
-
*/
|
|
194
|
-
ignore?: boolean;
|
|
195
|
-
/**
|
|
196
|
-
* An indicator specifying if the field is internal or not.
|
|
197
|
-
*
|
|
198
|
-
* @internal
|
|
199
|
-
*/
|
|
200
|
-
internal?: boolean;
|
|
201
|
-
/**
|
|
202
|
-
* An indicator specifying if the field should only be populated at runtime or not.
|
|
203
|
-
*/
|
|
204
|
-
runtime?: boolean;
|
|
205
|
-
/**
|
|
206
|
-
* An indicator specifying if the field is read-only or not.
|
|
207
|
-
*/
|
|
208
|
-
readOnly?: boolean;
|
|
209
|
-
/**
|
|
210
|
-
* An indicator specifying if the field is write-only or not. This property can be used by documentation tools or other libraries that support this feature to provide additional information or warnings about the usage of the schema. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the schema when used in conjunction with compatible tools.
|
|
211
|
-
*/
|
|
212
|
-
writeOnly?: boolean;
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* A keyword group corresponding to logical operators for combining or modifying the boolean assertion results of the subschemas. They have no direct impact on annotation collection, although they enable the same annotation keyword to be applied to an instance location with different values.
|
|
216
|
-
*
|
|
217
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.2.1
|
|
218
|
-
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.5
|
|
219
|
-
*/
|
|
220
|
-
interface JsonSchemaLogicKeywords {
|
|
221
|
-
/**
|
|
222
|
-
* A set of schemas where the data must satisfy all members.
|
|
223
|
-
*
|
|
224
|
-
* @remarks
|
|
225
|
-
* An instance validates successfully against this keyword if it validates successfully against all schemas defined by this keyword's value.
|
|
226
|
-
*
|
|
227
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.2.1.1
|
|
228
|
-
*/
|
|
229
|
-
allOf?: JsonSchema[];
|
|
230
|
-
/**
|
|
231
|
-
* A set of schemas where the data must satisfy at least one member.
|
|
232
|
-
*
|
|
233
|
-
* @remarks
|
|
234
|
-
* An instance validates successfully against this keyword if it validates successfully against at least one schema defined by this keyword's value. Note that when annotations are being collected, all subschemas **MUST** be examined so that annotations are collected from each subschema that validates successfully.
|
|
235
|
-
*
|
|
236
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.2.1.2
|
|
237
|
-
*/
|
|
238
|
-
anyOf?: JsonSchema[];
|
|
239
|
-
/**
|
|
240
|
-
* A set of schemas where the data must satisfy exactly one member.
|
|
241
|
-
*
|
|
242
|
-
* @remarks
|
|
243
|
-
* An instance validates successfully against this keyword if it validates successfully against exactly one schema defined by this keyword's value.
|
|
244
|
-
*
|
|
245
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.2.1.3
|
|
246
|
-
*/
|
|
247
|
-
oneOf?: JsonSchema[];
|
|
248
|
-
/**
|
|
249
|
-
* A schema that must not match the data.
|
|
250
|
-
*
|
|
251
|
-
* @remarks
|
|
252
|
-
* An instance is valid against this keyword if it fails to validate successfully against the schema defined by this keyword
|
|
253
|
-
*
|
|
254
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.2.1.4
|
|
255
|
-
*/
|
|
256
|
-
not?: JsonSchema;
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* A set of JSON Schema keywords that define conditional combination rules for schemas. These keywords work together to implement conditional application of a subschema based on the outcome of another subschema.
|
|
260
|
-
*
|
|
261
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.2.2
|
|
262
|
-
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.5
|
|
263
|
-
*/
|
|
264
|
-
interface JsonSchemaConditionalKeywords {
|
|
265
|
-
/**
|
|
266
|
-
* A schema that the data must not satisfy.
|
|
267
|
-
*
|
|
268
|
-
* @remarks
|
|
269
|
-
* Instances that successfully validate against this keyword's subschema **MUST** also be valid against the subschema value of the {@link then} keyword, if present. Instances that fail to validate against this keyword's subschema **MUST** also be valid against the subschema value of the {@link else} keyword, if present.
|
|
270
|
-
*
|
|
271
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.2.2.1
|
|
272
|
-
*/
|
|
273
|
-
if?: JsonSchema;
|
|
274
|
-
/**
|
|
275
|
-
* A schema applied when {@link if} matches.
|
|
276
|
-
*
|
|
277
|
-
* @remarks
|
|
278
|
-
* When {@link if} is present, and the instance successfully validates against its subschema, then validation succeeds against this keyword if the instance also successfully validates against this keyword's subschema.
|
|
279
|
-
*
|
|
280
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.2.2.2
|
|
281
|
-
*/
|
|
282
|
-
then?: JsonSchema;
|
|
283
|
-
/**
|
|
284
|
-
* A schema applied when {@link if} does not match.
|
|
285
|
-
*
|
|
286
|
-
* @remarks
|
|
287
|
-
* When {@link if} is present, and the instance fails to validate against its subschema, then validation succeeds against this keyword if the instance successfully validates against this keyword's subschema.
|
|
288
|
-
*
|
|
289
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.2.2.3
|
|
290
|
-
*/
|
|
291
|
-
else?: JsonSchema;
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* Shared JSON Schema keyword groups applied to most schema variants.
|
|
295
|
-
*/
|
|
296
|
-
type JsonSchemaKeywords = JsonSchemaMetadataKeywords & JsonSchemaLogicKeywords & JsonSchemaConditionalKeywords;
|
|
297
|
-
/**
|
|
298
|
-
* A schema that can point to another schema via `$ref`.
|
|
299
|
-
*/
|
|
300
|
-
interface JsonSchemaAny extends JsonSchemaKeywords {
|
|
301
|
-
/**
|
|
302
|
-
* A URI reference to another schema.
|
|
303
|
-
*
|
|
304
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-8.2.3.1
|
|
305
|
-
*/
|
|
306
|
-
$ref?: string;
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* JSON Schema keywords for array validation.
|
|
310
|
-
*
|
|
311
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.3.1
|
|
312
|
-
*/
|
|
313
|
-
interface JsonSchemaArray extends JsonSchemaKeywords {
|
|
314
|
-
/**
|
|
315
|
-
* Declares that the instance must be an array.
|
|
316
|
-
*/
|
|
317
|
-
type: "array";
|
|
318
|
-
/**
|
|
319
|
-
* Schemas for positional items at each tuple index.
|
|
320
|
-
*
|
|
321
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.3.1.1
|
|
322
|
-
*/
|
|
323
|
-
prefixItems?: JsonSchema[];
|
|
324
|
-
/**
|
|
325
|
-
* Schema for array items beyond `prefixItems`, or all items when `prefixItems` is omitted.
|
|
326
|
-
*
|
|
327
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.3.1.2
|
|
328
|
-
*/
|
|
329
|
-
items?: JsonSchema;
|
|
330
|
-
/**
|
|
331
|
-
* A subschema that at least one array item must satisfy.
|
|
332
|
-
*
|
|
333
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.3.1.3
|
|
334
|
-
*/
|
|
335
|
-
contains?: JsonSchema;
|
|
336
|
-
/**
|
|
337
|
-
* Minimum number of items allowed.
|
|
338
|
-
*/
|
|
339
|
-
minItems?: number;
|
|
340
|
-
/**
|
|
341
|
-
* Maximum number of items allowed.
|
|
342
|
-
*/
|
|
343
|
-
maxItems?: number;
|
|
344
|
-
/**
|
|
345
|
-
* Whether all items must be unique.
|
|
346
|
-
*/
|
|
347
|
-
uniqueItems?: boolean;
|
|
348
|
-
/**
|
|
349
|
-
* Minimum count of items that must satisfy `contains`.
|
|
350
|
-
*/
|
|
351
|
-
minContains?: number;
|
|
352
|
-
/**
|
|
353
|
-
* Maximum count of items that may satisfy `contains`.
|
|
354
|
-
*/
|
|
355
|
-
maxContains?: number;
|
|
356
|
-
/**
|
|
357
|
-
* Controls validation of array items not covered by prior applicators.
|
|
358
|
-
*
|
|
359
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-11.2
|
|
360
|
-
*/
|
|
361
|
-
unevaluatedItems?: boolean | JsonSchema;
|
|
362
|
-
}
|
|
363
|
-
/**
|
|
364
|
-
* Integer schema specialized for 64-bit integer semantics.
|
|
365
|
-
*/
|
|
366
|
-
interface JsonSchemaBigint extends JsonSchemaKeywords {
|
|
367
|
-
/**
|
|
368
|
-
* Declares that the instance must be an integer.
|
|
369
|
-
*/
|
|
370
|
-
type: "integer";
|
|
371
|
-
/**
|
|
372
|
-
* Identifies an `int64` integer representation.
|
|
373
|
-
*/
|
|
374
|
-
format: "int64";
|
|
375
|
-
/**
|
|
376
|
-
* Inclusive lower bound for valid values.
|
|
377
|
-
*/
|
|
378
|
-
minimum?: bigint;
|
|
379
|
-
/**
|
|
380
|
-
* Exclusive lower bound for valid values.
|
|
381
|
-
*/
|
|
382
|
-
exclusiveMinimum?: bigint;
|
|
383
|
-
/**
|
|
384
|
-
* Inclusive upper bound for valid values.
|
|
385
|
-
*/
|
|
386
|
-
maximum?: bigint;
|
|
387
|
-
/**
|
|
388
|
-
* Exclusive upper bound for valid values.
|
|
389
|
-
*/
|
|
390
|
-
exclusiveMaximum?: bigint;
|
|
391
|
-
/**
|
|
392
|
-
* Constraint requiring values to be divisible by this number.
|
|
393
|
-
*/
|
|
394
|
-
multipleOf?: bigint;
|
|
395
|
-
/**
|
|
396
|
-
* A keyword that is used to specify a default value for a property in a JSON Schema. It provides a default value that can be used when an instance does not provide a value for that property.
|
|
397
|
-
*
|
|
398
|
-
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-10.2
|
|
399
|
-
*/
|
|
400
|
-
default?: bigint;
|
|
401
|
-
/**
|
|
402
|
-
* Fixed set of allowed integer values.
|
|
403
|
-
*/
|
|
404
|
-
enum?: bigint[];
|
|
405
|
-
}
|
|
406
|
-
/**
|
|
407
|
-
* Boolean schema keywords.
|
|
408
|
-
*/
|
|
409
|
-
interface JsonSchemaBoolean extends JsonSchemaKeywords {
|
|
410
|
-
/**
|
|
411
|
-
* Declares that the instance must be a boolean.
|
|
412
|
-
*/
|
|
413
|
-
type: "boolean";
|
|
414
|
-
/**
|
|
415
|
-
* A keyword that is used to specify a default value for a property in a JSON Schema. It provides a default value that can be used when an instance does not provide a value for that property.
|
|
416
|
-
*
|
|
417
|
-
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-10.2
|
|
418
|
-
*/
|
|
419
|
-
default?: boolean;
|
|
420
|
-
}
|
|
421
|
-
/**
|
|
422
|
-
* Date and time schema variants.
|
|
423
|
-
*
|
|
424
|
-
* @remarks
|
|
425
|
-
* This type supports either direct date/time format constraints or recursive unions through `anyOf`.
|
|
426
|
-
*
|
|
427
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-validation#section-7
|
|
428
|
-
*/
|
|
429
|
-
type JsonSchemaDate = JsonSchemaKeywords & ({
|
|
430
|
-
/**
|
|
431
|
-
* Declares the storage type used for temporal values.
|
|
432
|
-
*/
|
|
433
|
-
type: "integer" | "string";
|
|
434
|
-
/**
|
|
435
|
-
* A date/time format name used for semantic validation.
|
|
436
|
-
*/
|
|
437
|
-
format: "date" | "time" | "date-time" | "iso-time" | "iso-date-time" | "unix-time";
|
|
438
|
-
/**
|
|
439
|
-
* Inclusive lower bound for numeric time representations.
|
|
440
|
-
*/
|
|
441
|
-
minimum?: number;
|
|
442
|
-
/**
|
|
443
|
-
* Inclusive upper bound for numeric time representations.
|
|
444
|
-
*/
|
|
445
|
-
maximum?: number;
|
|
446
|
-
/**
|
|
447
|
-
* A keyword that is used to specify a default value for a property in a JSON Schema. It provides a default value that can be used when an instance does not provide a value for that property.
|
|
448
|
-
*
|
|
449
|
-
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-10.2
|
|
450
|
-
*/
|
|
451
|
-
default?: string | number;
|
|
452
|
-
} | {
|
|
453
|
-
/**
|
|
454
|
-
* Alternative date/time schemas where at least one must match.
|
|
455
|
-
*/
|
|
456
|
-
anyOf: JsonSchemaDate[];
|
|
457
|
-
});
|
|
458
|
-
/**
|
|
459
|
-
* Enum-constrained schema.
|
|
460
|
-
*
|
|
461
|
-
* @template T - The literal type allowed by the enum values.
|
|
462
|
-
*/
|
|
463
|
-
interface JsonSchemaEnum<T extends string | number | bigint | boolean | null = string | number | bigint | boolean | null> extends JsonSchemaKeywords {
|
|
464
|
-
/**
|
|
465
|
-
* Primitive type of the enum values.
|
|
466
|
-
*/
|
|
467
|
-
type: JsonSchemaPrimitiveType;
|
|
468
|
-
/**
|
|
469
|
-
* The complete set of allowed literal values.
|
|
470
|
-
*/
|
|
471
|
-
enum: T[];
|
|
472
|
-
/**
|
|
473
|
-
* A keyword that is used to specify a default value for a property in a JSON Schema. It provides a default value that can be used when an instance does not provide a value for that property.
|
|
474
|
-
*
|
|
475
|
-
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-10.2
|
|
476
|
-
*/
|
|
477
|
-
default?: T;
|
|
478
|
-
}
|
|
479
|
-
interface JsonSchemaAllOf extends JsonSchemaKeywords {
|
|
480
|
-
/**
|
|
481
|
-
* Subschemas that must all validate successfully.
|
|
482
|
-
*/
|
|
483
|
-
allOf: JsonSchema[];
|
|
484
|
-
/**
|
|
485
|
-
* Controls validation for object properties not evaluated by prior keywords.
|
|
486
|
-
*/
|
|
487
|
-
unevaluatedProperties?: boolean | JsonSchema;
|
|
488
|
-
}
|
|
489
|
-
/**
|
|
490
|
-
* A schema that matches exactly one literal value.
|
|
491
|
-
*/
|
|
492
|
-
interface JsonSchemaLiteral extends JsonSchemaKeywords {
|
|
493
|
-
/**
|
|
494
|
-
* Constant value that an instance must equal.
|
|
495
|
-
*/
|
|
496
|
-
const: unknown;
|
|
497
|
-
/**
|
|
498
|
-
* Optional explicit type constraint for the constant.
|
|
499
|
-
*/
|
|
500
|
-
type?: JsonSchemaType | JsonSchemaType[];
|
|
501
|
-
}
|
|
502
|
-
/**
|
|
503
|
-
* Array representation for map-like entries as `[key, value]` tuples.
|
|
504
|
-
*/
|
|
505
|
-
interface JsonSchemaMap extends JsonSchemaKeywords {
|
|
506
|
-
/**
|
|
507
|
-
* Declares that the map is represented as an array.
|
|
508
|
-
*/
|
|
509
|
-
type: "array";
|
|
510
|
-
/**
|
|
511
|
-
* Maximum number of entries allowed.
|
|
512
|
-
*/
|
|
513
|
-
maxItems: 125;
|
|
514
|
-
/**
|
|
515
|
-
* Tuple schema describing each map entry as `[key, value]`.
|
|
516
|
-
*/
|
|
517
|
-
items: {
|
|
518
|
-
/**
|
|
519
|
-
* Declares that each entry is an array tuple.
|
|
520
|
-
*/
|
|
521
|
-
type: "array";
|
|
522
|
-
/**
|
|
523
|
-
* Two-position tuple schemas for key and value.
|
|
524
|
-
*/
|
|
525
|
-
prefixItems: [JsonSchema, JsonSchema];
|
|
526
|
-
/**
|
|
527
|
-
* Disallows additional tuple positions.
|
|
528
|
-
*/
|
|
529
|
-
items?: false;
|
|
530
|
-
/**
|
|
531
|
-
* Minimum tuple length.
|
|
532
|
-
*/
|
|
533
|
-
minItems: 2;
|
|
534
|
-
/**
|
|
535
|
-
* Maximum tuple length.
|
|
536
|
-
*/
|
|
537
|
-
maxItems: 2;
|
|
538
|
-
};
|
|
539
|
-
}
|
|
540
|
-
/**
|
|
541
|
-
* Enum schema that allows both string and numeric enum members.
|
|
542
|
-
*/
|
|
543
|
-
interface JsonSchemaNativeEnum extends JsonSchemaKeywords {
|
|
544
|
-
/**
|
|
545
|
-
* Type domain allowed by the native enum.
|
|
546
|
-
*/
|
|
547
|
-
type: "string" | "number" | ["string", "number"];
|
|
548
|
-
/**
|
|
549
|
-
* Allowed enum member values.
|
|
550
|
-
*/
|
|
551
|
-
enum: (string | number)[];
|
|
552
|
-
}
|
|
553
|
-
/**
|
|
554
|
-
* A schema that intentionally matches no values.
|
|
555
|
-
*/
|
|
556
|
-
interface JsonSchemaNever extends JsonSchemaKeywords {
|
|
557
|
-
/**
|
|
558
|
-
* Negated schema used to make validation impossible.
|
|
559
|
-
*/
|
|
560
|
-
not: JsonSchemaAny;
|
|
561
|
-
}
|
|
562
|
-
/**
|
|
563
|
-
* Schema representing the JSON `null` literal type.
|
|
564
|
-
*/
|
|
565
|
-
interface JsonSchemaNull extends JsonSchemaKeywords {
|
|
566
|
-
/**
|
|
567
|
-
* The JSON Schema null type. This property is used to indicate that the schema represents a null value, which is a special value in JSON that represents the absence of a value or a null reference. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
568
|
-
*/
|
|
569
|
-
type: "null";
|
|
570
|
-
/**
|
|
571
|
-
* A constant value constrained to null when the schema is nullable.
|
|
572
|
-
*/
|
|
573
|
-
const?: null;
|
|
574
|
-
/**
|
|
575
|
-
* Allowed values, including null when the schema is nullable.
|
|
576
|
-
*/
|
|
577
|
-
enum?: null[];
|
|
578
|
-
/**
|
|
579
|
-
* A keyword that is used to specify a default value for a property in a JSON Schema. It provides a default value that can be used when an instance does not provide a value for that property.
|
|
580
|
-
*
|
|
581
|
-
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-10.2
|
|
582
|
-
*/
|
|
583
|
-
default?: null;
|
|
584
|
-
}
|
|
585
|
-
/**
|
|
586
|
-
* Nullable schema variants that include an explicit `null` branch.
|
|
587
|
-
*/
|
|
588
|
-
type JsonSchemaNullable = JsonSchemaKeywords & ({
|
|
589
|
-
/**
|
|
590
|
-
* Two-branch union that includes a non-null schema and explicit `null` schema.
|
|
591
|
-
*/
|
|
592
|
-
anyOf: [JsonSchema, JsonSchemaNull];
|
|
593
|
-
} | {
|
|
594
|
-
/**
|
|
595
|
-
* Primitive `type` tuple that explicitly includes `null`.
|
|
596
|
-
*/
|
|
597
|
-
type: [Exclude<JsonSchemaType, "null">, "null"] | ["null", Exclude<JsonSchemaType, "null">];
|
|
598
|
-
});
|
|
599
|
-
/**
|
|
600
|
-
* Numeric schema keywords for numbers and integers.
|
|
601
|
-
*
|
|
602
|
-
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-6.2
|
|
603
|
-
*/
|
|
604
|
-
interface JsonSchemaNumber extends JsonSchemaKeywords {
|
|
605
|
-
/**
|
|
606
|
-
* Declares whether values are numbers or integers.
|
|
607
|
-
*/
|
|
608
|
-
type: "number" | "integer";
|
|
609
|
-
/**
|
|
610
|
-
* Optional semantic format for numeric values.
|
|
611
|
-
*/
|
|
612
|
-
format?: JsonSchemaNumberFormat | string;
|
|
613
|
-
/**
|
|
614
|
-
* Inclusive lower bound for numeric values.
|
|
615
|
-
*/
|
|
616
|
-
minimum?: number;
|
|
617
|
-
/**
|
|
618
|
-
* Exclusive lower bound for numeric values.
|
|
619
|
-
*/
|
|
620
|
-
exclusiveMinimum?: number;
|
|
621
|
-
/**
|
|
622
|
-
* Inclusive upper bound for numeric values.
|
|
623
|
-
*/
|
|
624
|
-
maximum?: number;
|
|
625
|
-
/**
|
|
626
|
-
* Exclusive upper bound for numeric values.
|
|
627
|
-
*/
|
|
628
|
-
exclusiveMaximum?: number;
|
|
629
|
-
/**
|
|
630
|
-
* Constraint requiring values to be divisible by this value.
|
|
631
|
-
*/
|
|
632
|
-
multipleOf?: number;
|
|
633
|
-
/**
|
|
634
|
-
* A keyword that is used to specify a default value for a property in a JSON Schema. It provides a default value that can be used when an instance does not provide a value for that property.
|
|
635
|
-
*
|
|
636
|
-
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-10.2
|
|
637
|
-
*/
|
|
638
|
-
default?: number;
|
|
639
|
-
/**
|
|
640
|
-
* Fixed set of allowed numeric values.
|
|
641
|
-
*/
|
|
642
|
-
enum?: number[];
|
|
643
|
-
}
|
|
644
|
-
/**
|
|
645
|
-
* Integer-only numeric schema.
|
|
646
|
-
*/
|
|
647
|
-
interface JsonSchemaInteger extends JsonSchemaNumber {
|
|
648
|
-
/**
|
|
649
|
-
* Declares that values must be integers.
|
|
650
|
-
*/
|
|
651
|
-
type: "integer";
|
|
652
|
-
/**
|
|
653
|
-
* Optional integer-specific format.
|
|
654
|
-
*/
|
|
655
|
-
format?: JsonSchemaIntegerFormat | string;
|
|
656
|
-
}
|
|
657
|
-
/**
|
|
658
|
-
* Floating-point numeric schema.
|
|
659
|
-
*/
|
|
660
|
-
interface JsonSchemaDecimal extends JsonSchemaNumber {
|
|
661
|
-
/**
|
|
662
|
-
* Declares that values are non-integer numbers.
|
|
663
|
-
*/
|
|
664
|
-
type: "number";
|
|
665
|
-
/**
|
|
666
|
-
* Optional floating-point format.
|
|
667
|
-
*/
|
|
668
|
-
format?: JsonSchemaDecimalFormat | string;
|
|
669
|
-
}
|
|
670
|
-
/**
|
|
671
|
-
* Object schema keywords.
|
|
672
|
-
*
|
|
673
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.3.2
|
|
674
|
-
*/
|
|
675
|
-
interface JsonSchemaObject extends JsonSchemaKeywords {
|
|
676
|
-
/**
|
|
677
|
-
* The JSON Schema object type. This property is used to indicate that the schema represents an object, which is a collection of key-value pairs where the keys are strings and the values can be of any type defined by the schema. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
678
|
-
*/
|
|
679
|
-
type: "object";
|
|
680
|
-
/**
|
|
681
|
-
* The declared object properties and their schemas. This property can be used to define the expected structure of an object, where each key represents a property name and the corresponding value is a schema that defines the expected type and constraints for that property. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
682
|
-
*
|
|
683
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.3.2.1
|
|
684
|
-
*/
|
|
685
|
-
properties?: Record<string, JsonSchema>;
|
|
686
|
-
/**
|
|
687
|
-
* The schemas for properties whose names match the given patterns.
|
|
688
|
-
*
|
|
689
|
-
* @remarks
|
|
690
|
-
* Each property name of this object **SHOULD** be a valid regular expression, according to the [ECMA-262 regular expression dialect](https://www.ecma-international.org/ecma-262/). Each property value of this object **MUST** be a valid JSON Schema.
|
|
691
|
-
*
|
|
692
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.3.2.2
|
|
693
|
-
*/
|
|
694
|
-
patternProperties?: Record<string, JsonSchema>;
|
|
695
|
-
/**
|
|
696
|
-
* The schema for properties not matched by {@link properties} or {@link patternProperties}. This property can be used to allow additional properties in the object that are not explicitly defined in the {@link properties} or {@link patternProperties} keywords. The value of this property can be a boolean, where `true` allows any additional properties and `false` disallows any additional properties, or it can be a schema that defines the expected structure of the additional properties. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
697
|
-
*
|
|
698
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.3.2.3
|
|
699
|
-
*/
|
|
700
|
-
additionalProperties?: boolean | JsonSchema;
|
|
701
|
-
/**
|
|
702
|
-
* A list of property names that are required for the object. This property can be used by validation libraries or other tools that support this feature to enforce the presence of certain properties in the data that the schema represents. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
703
|
-
*/
|
|
704
|
-
required?: string[];
|
|
705
|
-
/**
|
|
706
|
-
* A keyword that is used to specify a default value for a property in a JSON Schema. It provides a default value that can be used when an instance does not provide a value for that property.
|
|
707
|
-
*
|
|
708
|
-
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-10.2
|
|
709
|
-
*/
|
|
710
|
-
default?: Record<string, unknown>;
|
|
711
|
-
/**
|
|
712
|
-
* The schema for properties that have not yet been evaluated by other object keywords. This property can be used to apply a schema to properties that are not explicitly defined in the {@link properties} or {@link patternProperties} keywords, and that have not been evaluated by any other object keywords such as {@link additionalProperties} or {@link dependencies}. The value of this property can be a boolean, where `true` allows any unevaluated properties and `false` disallows any unevaluated properties, or it can be a schema that defines the expected structure of the unevaluated properties. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
713
|
-
*/
|
|
714
|
-
unevaluatedProperties?: boolean | JsonSchema;
|
|
715
|
-
/**
|
|
716
|
-
* A map of property-specific dependency requirements.
|
|
717
|
-
*/
|
|
718
|
-
dependencies?: Record<string, string[] | JsonSchema>;
|
|
719
|
-
/**
|
|
720
|
-
* Properties that become required when the key property is present.
|
|
721
|
-
*/
|
|
722
|
-
dependentRequired?: Record<string, string[]>;
|
|
723
|
-
/**
|
|
724
|
-
* Subschemas that apply when the key property is present.
|
|
725
|
-
*
|
|
726
|
-
* @remarks
|
|
727
|
-
* If the object key is a property in the instance, the entire instance must validate against the subschema. Its use is dependent on the presence of the property.
|
|
728
|
-
*
|
|
729
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.2.2.4
|
|
730
|
-
*/
|
|
731
|
-
dependentSchemas?: Record<string, JsonSchema>;
|
|
732
|
-
/**
|
|
733
|
-
* The minimum number of own properties allowed.
|
|
734
|
-
*/
|
|
735
|
-
minProperties?: number;
|
|
736
|
-
/**
|
|
737
|
-
* The maximum number of own properties allowed.
|
|
738
|
-
*/
|
|
739
|
-
maxProperties?: number;
|
|
740
|
-
/**
|
|
741
|
-
* An optional array of property names that are considered primary keys for the object. This property can be used by validation libraries or other tools that support this feature to provide additional validation rules or constraints for the data that the schema represents. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
742
|
-
*/
|
|
743
|
-
primaryKey?: string[];
|
|
744
|
-
/**
|
|
745
|
-
* A name for the database schema associated with the data represented by this schema. This property can be used by documentation tools or other libraries that support this feature to provide additional context or information about the data model that the schema represents. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
746
|
-
*/
|
|
747
|
-
databaseSchema?: string;
|
|
748
|
-
}
|
|
749
|
-
interface JsonSchemaString extends JsonSchemaKeywords {
|
|
750
|
-
/**
|
|
751
|
-
* Declares that the instance must be a string.
|
|
752
|
-
*/
|
|
753
|
-
type: "string";
|
|
754
|
-
/**
|
|
755
|
-
* The minimum number of characters allowed in the string.
|
|
756
|
-
*/
|
|
757
|
-
minLength?: number;
|
|
758
|
-
/**
|
|
759
|
-
* The maximum number of characters allowed in the string.
|
|
760
|
-
*/
|
|
761
|
-
maxLength?: number;
|
|
762
|
-
/**
|
|
763
|
-
* A regular expression that matching strings must satisfy.
|
|
764
|
-
*/
|
|
765
|
-
pattern?: string;
|
|
766
|
-
/**
|
|
767
|
-
* A format for the schema, which can be used by validation libraries or other tools that support this feature to provide additional validation or formatting rules for the data that the schema represents. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
768
|
-
*
|
|
769
|
-
* @see https://ajv.js.org/packages/ajv-formats.html
|
|
770
|
-
*
|
|
771
|
-
* @remarks
|
|
772
|
-
* The `format` property is a string that specifies the format of the data that the schema represents. It can be used to indicate that a string should be validated as an email address, a date-time, a URI, or any other format supported by compatible validation libraries. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
773
|
-
*/
|
|
774
|
-
format?: JsonSchemaStringFormat | string;
|
|
775
|
-
/**
|
|
776
|
-
* A keyword that is used to specify a default value for a property in a JSON Schema. It provides a default value that can be used when an instance does not provide a value for that property.
|
|
777
|
-
*
|
|
778
|
-
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-10.2
|
|
779
|
-
*/
|
|
780
|
-
default?: string;
|
|
781
|
-
/**
|
|
782
|
-
* Fixed set of allowed string values.
|
|
783
|
-
*/
|
|
784
|
-
enum?: string[];
|
|
785
|
-
/**
|
|
786
|
-
* A keyword used to specify the media type of the content that the schema represents. It can be used by validation libraries or other tools that support this feature to provide additional validation or processing rules for the data based on its media type. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
787
|
-
*
|
|
788
|
-
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.8
|
|
789
|
-
*/
|
|
790
|
-
contentMediaType?: string;
|
|
791
|
-
/**
|
|
792
|
-
* A keyword used to specify the content encoding of the data that the schema represents. It can be used by validation libraries or other tools that support this feature to provide additional validation or processing rules for the data based on its content encoding. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
793
|
-
*
|
|
794
|
-
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.8
|
|
795
|
-
*/
|
|
796
|
-
contentEncoding?: string;
|
|
797
|
-
/**
|
|
798
|
-
* A keyword used to specify a schema for the content that the schema represents. It can be used by validation libraries or other tools that support this feature to provide additional validation or processing rules for the data based on its schema. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
799
|
-
*
|
|
800
|
-
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.9
|
|
801
|
-
*/
|
|
802
|
-
contentSchema?: string;
|
|
803
|
-
}
|
|
804
|
-
/**
|
|
805
|
-
* Set-like array schema that enforces item uniqueness.
|
|
806
|
-
*/
|
|
807
|
-
interface JsonSchemaSet extends JsonSchemaKeywords {
|
|
808
|
-
/**
|
|
809
|
-
* Declares that set values are serialized as arrays.
|
|
810
|
-
*/
|
|
811
|
-
type: "array";
|
|
812
|
-
/**
|
|
813
|
-
* Enforces set semantics by requiring distinct elements.
|
|
814
|
-
*/
|
|
815
|
-
uniqueItems: true;
|
|
816
|
-
/**
|
|
817
|
-
* Schemas for positional items at each tuple index.
|
|
818
|
-
*/
|
|
819
|
-
prefixItems?: JsonSchema[];
|
|
820
|
-
/**
|
|
821
|
-
* Schema for remaining items.
|
|
822
|
-
*/
|
|
823
|
-
items?: JsonSchema;
|
|
824
|
-
/**
|
|
825
|
-
* Subschema that at least one item must satisfy.
|
|
826
|
-
*/
|
|
827
|
-
contains?: JsonSchema;
|
|
828
|
-
/**
|
|
829
|
-
* Minimum number of items allowed.
|
|
830
|
-
*/
|
|
831
|
-
minItems?: number;
|
|
832
|
-
/**
|
|
833
|
-
* Maximum number of items allowed.
|
|
834
|
-
*/
|
|
835
|
-
maxItems?: number;
|
|
836
|
-
/**
|
|
837
|
-
* Minimum number of items that must satisfy {@link JsonSchemaSet.contains | contains}.
|
|
838
|
-
*/
|
|
839
|
-
minContains?: number;
|
|
840
|
-
/**
|
|
841
|
-
* Maximum number of items that may satisfy {@link JsonSchemaSet.contains | contains}.
|
|
842
|
-
*/
|
|
843
|
-
maxContains?: number;
|
|
844
|
-
/**
|
|
845
|
-
* Controls validation for items not otherwise evaluated.
|
|
846
|
-
*/
|
|
847
|
-
unevaluatedItems?: boolean | JsonSchema;
|
|
848
|
-
}
|
|
849
|
-
/**
|
|
850
|
-
* Schema used to validate record keys.
|
|
851
|
-
*/
|
|
852
|
-
type JsonSchemaRecordPropertyNames = JsonSchema;
|
|
853
|
-
/**
|
|
854
|
-
* Record/object schema with key constraints.
|
|
855
|
-
*/
|
|
856
|
-
interface JsonSchemaRecord extends JsonSchemaKeywords {
|
|
857
|
-
/**
|
|
858
|
-
* Declares that the instance must be an object.
|
|
859
|
-
*/
|
|
860
|
-
type: "object";
|
|
861
|
-
/**
|
|
862
|
-
* The schemas for properties whose names match the given patterns.
|
|
863
|
-
*
|
|
864
|
-
* @remarks
|
|
865
|
-
* Each property name of this object **SHOULD** be a valid regular expression, according to the [ECMA-262 regular expression dialect](https://www.ecma-international.org/ecma-262/). Each property value of this object **MUST** be a valid JSON Schema.
|
|
866
|
-
*
|
|
867
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.3.2.2
|
|
868
|
-
*/
|
|
869
|
-
patternProperties?: Record<string, JsonSchema>;
|
|
870
|
-
/**
|
|
871
|
-
* The schema for properties not matched by {@link properties} or {@link patternProperties}. This property can be used to allow additional properties in the object that are not explicitly defined in the `properties` or `patternProperties` keywords. The value of this property can be a boolean, where `true` allows any additional properties and `false` disallows any additional properties, or it can be a schema that defines the expected structure of the additional properties. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
872
|
-
*
|
|
873
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.3.2.3
|
|
874
|
-
*/
|
|
875
|
-
additionalProperties?: boolean | JsonSchema;
|
|
876
|
-
/**
|
|
877
|
-
* The schema that each property name must satisfy.
|
|
878
|
-
*/
|
|
879
|
-
propertyNames?: JsonSchemaRecordPropertyNames;
|
|
880
|
-
/**
|
|
881
|
-
* A keyword that is used to specify a default value for a property in a JSON Schema. It provides a default value that can be used when an instance does not provide a value for that property.
|
|
882
|
-
*
|
|
883
|
-
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-10.2
|
|
884
|
-
*/
|
|
885
|
-
default?: Record<string, unknown>;
|
|
886
|
-
}
|
|
887
|
-
/**
|
|
888
|
-
* Tuple schema modeled with positional {@link JsonSchemaTuple.prefixItems | prefixItems} plus optional trailing {@link JsonSchemaTuple.items | items}.
|
|
889
|
-
*/
|
|
890
|
-
type JsonSchemaTuple = JsonSchemaKeywords & {
|
|
891
|
-
/**
|
|
892
|
-
* Declares that tuple values are represented as arrays.
|
|
893
|
-
*/
|
|
894
|
-
type: "array";
|
|
895
|
-
/**
|
|
896
|
-
* Minimum number of elements required.
|
|
897
|
-
*/
|
|
898
|
-
minItems?: number;
|
|
899
|
-
/**
|
|
900
|
-
* Maximum number of elements allowed.
|
|
901
|
-
*/
|
|
902
|
-
maxItems?: number;
|
|
903
|
-
/**
|
|
904
|
-
* Positional schemas for tuple elements.
|
|
905
|
-
*/
|
|
906
|
-
prefixItems: JsonSchema[];
|
|
907
|
-
/**
|
|
908
|
-
* The schema applied to items beyond {@link prefixItems}. In draft 2020-12,
|
|
909
|
-
* tuple positions are modeled with {@link prefixItems}, while {@link items}
|
|
910
|
-
* applies to the remaining elements.
|
|
911
|
-
*
|
|
912
|
-
* @remarks
|
|
913
|
-
* The behavior of {@link items} without {@link prefixItems} is identical to that of the schema form of {@link items} in drafts prior to 2020-12. When {@link prefixItems} is present, the behavior of {@link items} is identical to the former {@link additionalItems} keyword.
|
|
914
|
-
*
|
|
915
|
-
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.3.1.2
|
|
916
|
-
*/
|
|
917
|
-
items?: JsonSchema;
|
|
918
|
-
/**
|
|
919
|
-
* Subschema that at least one tuple element must satisfy.
|
|
920
|
-
*/
|
|
921
|
-
contains?: JsonSchema;
|
|
922
|
-
/**
|
|
923
|
-
* Whether tuple elements must be unique.
|
|
924
|
-
*/
|
|
925
|
-
uniqueItems?: boolean;
|
|
926
|
-
/**
|
|
927
|
-
* Minimum number of elements that must satisfy {@link JsonSchemaTuple.contains | contains}.
|
|
928
|
-
*/
|
|
929
|
-
minContains?: number;
|
|
930
|
-
/**
|
|
931
|
-
* Maximum number of elements that may satisfy {@link JsonSchemaTuple.contains | contains}.
|
|
932
|
-
*/
|
|
933
|
-
maxContains?: number;
|
|
934
|
-
/**
|
|
935
|
-
* Controls validation of unevaluated tuple elements.
|
|
936
|
-
*/
|
|
937
|
-
unevaluatedItems?: boolean | JsonSchema;
|
|
938
|
-
};
|
|
939
|
-
/**
|
|
940
|
-
* Schema used to represent undefined-like semantics through negation.
|
|
941
|
-
*/
|
|
942
|
-
interface JsonSchemaUndefined extends JsonSchemaKeywords {
|
|
943
|
-
/**
|
|
944
|
-
* Negated schema marker used to represent undefined-like semantics.
|
|
945
|
-
*/
|
|
946
|
-
not: JsonSchemaAny;
|
|
947
|
-
/**
|
|
948
|
-
* A keyword that is used to specify a default value for a property in a JSON Schema. It provides a default value that can be used when an instance does not provide a value for that property.
|
|
949
|
-
*
|
|
950
|
-
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-10.2
|
|
951
|
-
*/
|
|
952
|
-
default?: undefined;
|
|
953
|
-
}
|
|
954
|
-
/**
|
|
955
|
-
* Union schema represented as either primitive type unions or `anyOf` compositions.
|
|
956
|
-
*/
|
|
957
|
-
type JsonSchemaUnion = JsonSchemaKeywords & (JsonSchemaPrimitiveUnion | JsonSchemaAnyOf);
|
|
958
|
-
/**
|
|
959
|
-
* Union of primitive type combinations and enum-backed primitive unions.
|
|
960
|
-
*/
|
|
961
|
-
type JsonSchemaPrimitiveUnion = JsonSchemaKeywords & ({
|
|
962
|
-
/**
|
|
963
|
-
* Primitive `type` or list of primitive types accepted by the union.
|
|
964
|
-
*/
|
|
965
|
-
type: JsonSchemaPrimitiveType | JsonSchemaPrimitiveType[];
|
|
966
|
-
} | {
|
|
967
|
-
/**
|
|
968
|
-
* Enum values that may be of different primitive types.
|
|
969
|
-
*/
|
|
970
|
-
enum: (string | number | bigint | boolean | null)[];
|
|
971
|
-
});
|
|
972
|
-
/**
|
|
973
|
-
* Permissive schema alias for unknown values.
|
|
974
|
-
*/
|
|
975
|
-
type JsonSchemaUnknown = JsonSchemaKeywords & JsonSchemaAny;
|
|
976
|
-
/**
|
|
977
|
-
* `anyOf` composition schema.
|
|
978
|
-
*/
|
|
979
|
-
interface JsonSchemaAnyOf extends JsonSchemaKeywords {
|
|
980
|
-
/**
|
|
981
|
-
* Subschemas where at least one must validate.
|
|
982
|
-
*/
|
|
983
|
-
anyOf: JsonSchema[];
|
|
984
|
-
}
|
|
985
|
-
/**
|
|
986
|
-
* A reference schema that resolves through a URI.
|
|
987
|
-
*/
|
|
988
|
-
interface JsonSchemaRef extends JsonSchemaKeywords {
|
|
989
|
-
/**
|
|
990
|
-
* URI reference to a schema definition.
|
|
991
|
-
*/
|
|
992
|
-
$ref: string;
|
|
993
|
-
}
|
|
994
|
-
/**
|
|
995
|
-
* JSON Schema (draft 2020-12) type that can be used to validate JSON data. It is a union of all the specific JSON Schema types, as well as the metadata properties that can be included in any JSON Schema.
|
|
996
|
-
*
|
|
997
|
-
* @see https://json-schema.org/draft/2020-12
|
|
998
|
-
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
|
|
999
|
-
*/
|
|
1000
|
-
type JsonSchema = JsonSchemaString | JsonSchemaInteger | JsonSchemaDecimal | JsonSchemaBigint | JsonSchemaBoolean | JsonSchemaDate | JsonSchemaEnum | JsonSchemaLiteral | JsonSchemaNativeEnum | JsonSchemaNull | JsonSchemaArray | JsonSchemaObject | JsonSchemaRecord | JsonSchemaTuple | JsonSchemaUnion | JsonSchemaUndefined | JsonSchemaRef | JsonSchemaNever | JsonSchemaMap | JsonSchemaAny | JsonSchemaNullable | JsonSchemaAllOf | JsonSchemaUnknown | JsonSchemaSet;
|
|
1001
|
-
/**
|
|
1002
|
-
* An object containing common JSON Schema metadata properties that can be included in any schema type. This interface is used to define the shared metadata properties that can be present in all JSON Schema types, such as `$id`, `$schema`, `title`, `description`, and others. It serves as a base for all specific JSON Schema types, allowing them to include these common metadata properties without having to redefine them in each type.
|
|
1003
|
-
*/
|
|
1004
|
-
interface JsonSchemaLike extends JsonSchemaKeywords {
|
|
1005
|
-
$id?: string;
|
|
1006
|
-
$schema?: string;
|
|
1007
|
-
$vocabulary?: Record<string, boolean>;
|
|
1008
|
-
$comment?: string;
|
|
1009
|
-
$anchor?: string;
|
|
1010
|
-
$defs?: Record<string, JsonSchema>;
|
|
1011
|
-
$dynamicRef?: string;
|
|
1012
|
-
$dynamicAnchor?: string;
|
|
1013
|
-
$ref?: string;
|
|
1014
|
-
name?: string;
|
|
1015
|
-
title?: string;
|
|
1016
|
-
description?: string;
|
|
1017
|
-
docs?: string;
|
|
1018
|
-
examples?: unknown[];
|
|
1019
|
-
alias?: string[];
|
|
1020
|
-
tags?: string[];
|
|
1021
|
-
deprecated?: boolean | string | {
|
|
1022
|
-
message?: string;
|
|
1023
|
-
since?: string;
|
|
1024
|
-
alternative?: string;
|
|
1025
|
-
};
|
|
1026
|
-
hidden?: boolean;
|
|
1027
|
-
ignore?: boolean;
|
|
1028
|
-
internal?: boolean;
|
|
1029
|
-
runtime?: boolean;
|
|
1030
|
-
readOnly?: boolean;
|
|
1031
|
-
writeOnly?: boolean;
|
|
1032
|
-
type?: JsonSchemaType | JsonSchemaType[] | JsonSchemaPrimitiveType | JsonSchemaPrimitiveType[] | [Exclude<JsonSchemaType, "null">, "null"] | ["null", Exclude<JsonSchemaType, "null">];
|
|
1033
|
-
const?: unknown;
|
|
1034
|
-
enum?: (string | number | bigint | boolean | null)[];
|
|
1035
|
-
format?: string;
|
|
1036
|
-
default?: unknown;
|
|
1037
|
-
allOf?: JsonSchema[];
|
|
1038
|
-
anyOf?: JsonSchema[] | [JsonSchema, JsonSchemaNull];
|
|
1039
|
-
oneOf?: JsonSchema[];
|
|
1040
|
-
not?: JsonSchema;
|
|
1041
|
-
if?: JsonSchema;
|
|
1042
|
-
then?: JsonSchema;
|
|
1043
|
-
else?: JsonSchema;
|
|
1044
|
-
properties?: Record<string, JsonSchema>;
|
|
1045
|
-
patternProperties?: Record<string, JsonSchema>;
|
|
1046
|
-
additionalProperties?: boolean | JsonSchema;
|
|
1047
|
-
required?: string[];
|
|
1048
|
-
propertyNames?: JsonSchemaRecordPropertyNames;
|
|
1049
|
-
dependencies?: Record<string, string[] | JsonSchema>;
|
|
1050
|
-
dependentRequired?: Record<string, string[]>;
|
|
1051
|
-
dependentSchemas?: Record<string, JsonSchema>;
|
|
1052
|
-
minProperties?: number;
|
|
1053
|
-
maxProperties?: number;
|
|
1054
|
-
primaryKey?: string[];
|
|
1055
|
-
databaseSchema?: string;
|
|
1056
|
-
unevaluatedProperties?: boolean | JsonSchema;
|
|
1057
|
-
prefixItems?: JsonSchema[];
|
|
1058
|
-
items?: JsonSchema | JsonSchemaMap["items"];
|
|
1059
|
-
contains?: JsonSchema;
|
|
1060
|
-
minItems?: number;
|
|
1061
|
-
maxItems?: number;
|
|
1062
|
-
uniqueItems?: boolean;
|
|
1063
|
-
minContains?: number;
|
|
1064
|
-
maxContains?: number;
|
|
1065
|
-
unevaluatedItems?: boolean | JsonSchema;
|
|
1066
|
-
minLength?: number;
|
|
1067
|
-
maxLength?: number;
|
|
1068
|
-
pattern?: string;
|
|
1069
|
-
contentMediaType?: string;
|
|
1070
|
-
contentEncoding?: string;
|
|
1071
|
-
contentSchema?: string;
|
|
1072
|
-
minimum?: number | bigint;
|
|
1073
|
-
exclusiveMinimum?: number | bigint;
|
|
1074
|
-
maximum?: number | bigint;
|
|
1075
|
-
exclusiveMaximum?: number | bigint;
|
|
1076
|
-
multipleOf?: number | bigint;
|
|
1077
|
-
}
|
|
1078
|
-
/**
|
|
1079
|
-
* Supported source variants from which a schema can be extracted.
|
|
1080
|
-
*/
|
|
1081
|
-
type SchemaSourceVariant = "standard-schema" | "json-schema" | "zod3" | "untyped" | "valibot" | "reflection";
|
|
1082
|
-
/**
|
|
1083
|
-
* Accepted schema input variants, including raw type definitions.
|
|
1084
|
-
*/
|
|
1085
|
-
type SchemaInputVariant = SchemaSourceVariant | "file-reference";
|
|
1086
|
-
/**
|
|
1087
|
-
* Raw schema source input union before normalization.
|
|
1088
|
-
*/
|
|
1089
|
-
type SchemaSourceInput = StandardJSONSchemaV1 | JsonSchema | z3.ZodTypeAny | UntypedInputObject | UntypedSchema | ValibotSchema | Type;
|
|
1090
|
-
/**
|
|
1091
|
-
* Any accepted schema input, including normalized schemas and references.
|
|
1092
|
-
*/
|
|
1093
|
-
type SchemaInput = SchemaSourceInput | Schema | FileReferenceInput;
|
|
1094
|
-
/**
|
|
1095
|
-
* A schema extracted from a source input, normalized to JSON Schema.
|
|
1096
|
-
*/
|
|
1097
|
-
interface Schema<TJsonSchema extends JsonSchema = JsonSchema> {
|
|
1098
|
-
/** A stable content hash for the normalized schema. */
|
|
1099
|
-
hash: string;
|
|
1100
|
-
/** The source variant used to derive the normalized {@link JsonSchema}. */
|
|
1101
|
-
variant: SchemaInputVariant;
|
|
1102
|
-
/** The normalized schema definition. */
|
|
1103
|
-
schema: TJsonSchema;
|
|
1104
|
-
}
|
|
1105
|
-
/**
|
|
1106
|
-
* Base metadata captured for schema source inputs.
|
|
1107
|
-
*/
|
|
1108
|
-
interface BaseSchemaSource {
|
|
1109
|
-
/** A stable content hash for the original source schema. */
|
|
1110
|
-
hash: string;
|
|
1111
|
-
/** The specific source format used for the schema input. */
|
|
1112
|
-
variant: SchemaSourceVariant;
|
|
1113
|
-
/** The original schema input captured before normalization. */
|
|
1114
|
-
schema: SchemaSourceInput;
|
|
1115
|
-
}
|
|
1116
|
-
/**
|
|
1117
|
-
* Source descriptor for schemas that already use JSON Schema.
|
|
1118
|
-
*/
|
|
1119
|
-
interface JsonSchemaSchemaSource extends BaseSchemaSource {
|
|
1120
|
-
/** Indicates the source input already uses JSON Schema syntax. */
|
|
1121
|
-
variant: "json-schema";
|
|
1122
|
-
/** The original JSON Schema document. */
|
|
1123
|
-
schema: JsonSchema;
|
|
1124
|
-
}
|
|
1125
|
-
/**
|
|
1126
|
-
* Source descriptor for Standard Schema inputs.
|
|
1127
|
-
*/
|
|
1128
|
-
interface StandardSchemaSchemaSource extends BaseSchemaSource {
|
|
1129
|
-
/** Indicates the source input follows the Standard Schema format. */
|
|
1130
|
-
variant: "standard-schema";
|
|
1131
|
-
/** The original Standard Schema document. */
|
|
1132
|
-
schema: StandardJSONSchemaV1;
|
|
1133
|
-
}
|
|
1134
|
-
/**
|
|
1135
|
-
* Source descriptor for Zod v3 schema inputs.
|
|
1136
|
-
*/
|
|
1137
|
-
interface Zod3SchemaSource extends BaseSchemaSource {
|
|
1138
|
-
/** Indicates the source input is a Zod v3 schema. */
|
|
1139
|
-
variant: "zod3";
|
|
1140
|
-
/** The original Zod v3 schema instance. */
|
|
1141
|
-
schema: z3.ZodTypeAny;
|
|
1142
|
-
}
|
|
1143
|
-
/**
|
|
1144
|
-
* Source descriptor for Deepkit reflection type inputs.
|
|
1145
|
-
*/
|
|
1146
|
-
interface ReflectionSchemaSource extends BaseSchemaSource {
|
|
1147
|
-
/** Indicates the source input is a Deepkit reflection {@link Type}. */
|
|
1148
|
-
variant: "reflection";
|
|
1149
|
-
/** The original Deepkit reflection type. */
|
|
1150
|
-
schema: Type;
|
|
1151
|
-
}
|
|
1152
|
-
/**
|
|
1153
|
-
* Source descriptor for Untyped schema inputs.
|
|
1154
|
-
*/
|
|
1155
|
-
interface UntypedSchemaSource extends BaseSchemaSource {
|
|
1156
|
-
/** Indicates the source input comes from the Untyped schema model. */
|
|
1157
|
-
variant: "untyped";
|
|
1158
|
-
/** The original Untyped schema input. */
|
|
1159
|
-
schema: UntypedInputObject | UntypedSchema;
|
|
1160
|
-
}
|
|
1161
|
-
/**
|
|
1162
|
-
* Source descriptor for Valibot schema inputs.
|
|
1163
|
-
*/
|
|
1164
|
-
interface ValibotSchemaSource extends BaseSchemaSource {
|
|
1165
|
-
/** Indicates the source input comes from the Valibot schema model. */
|
|
1166
|
-
variant: "valibot";
|
|
1167
|
-
/** The original Valibot schema input. */
|
|
1168
|
-
schema: ValibotSchema;
|
|
1169
|
-
}
|
|
1170
|
-
/**
|
|
1171
|
-
* Union of all normalized schema source descriptor variants.
|
|
1172
|
-
*/
|
|
1173
|
-
type SchemaSource = JsonSchemaSchemaSource | StandardSchemaSchemaSource | Zod3SchemaSource | UntypedSchemaSource | ValibotSchemaSource | ReflectionSchemaSource;
|
|
1174
|
-
/**
|
|
1175
|
-
* A normalized schema plus metadata about the source that produced it.
|
|
1176
|
-
*/
|
|
1177
|
-
interface ExtractedSchema extends Schema {
|
|
1178
|
-
/**
|
|
1179
|
-
* The schema source that produced this normalized schema.
|
|
1180
|
-
*/
|
|
1181
|
-
source: SchemaSource;
|
|
1182
|
-
}
|
|
1183
|
-
//#endregion
|
|
1184
|
-
//#region src/codegen.d.ts
|
|
1185
|
-
/**
|
|
1186
|
-
* Stringifies a value for generated TypeScript code.
|
|
1187
|
-
*/
|
|
1188
|
-
declare function stringifyValue(value?: unknown, type?: JsonSchemaType | string): string;
|
|
1189
|
-
/**
|
|
1190
|
-
* Stringifies a JSON Schema fragment into a TypeScript-like type string.
|
|
1191
|
-
*/
|
|
1192
|
-
declare function stringifyType(schema?: JsonSchema): string;
|
|
1193
|
-
/**
|
|
1194
|
-
* Returns a string type representation of a value based on its type and an optional JSON Schema primitive type hint.
|
|
1195
|
-
*
|
|
1196
|
-
* @param value - The value whose type is to be represented as a string.
|
|
1197
|
-
* @returns A string representation of the value's type, which may be influenced by the provided JSON Schema primitive type hint. The function handles various JavaScript types and formats them accordingly, including special handling for `undefined`, `null`, booleans, numbers (with formatting), strings, objects, and arrays. If a specific type hint is provided, it will take precedence in determining the string representation of the value.
|
|
1198
|
-
*/
|
|
1199
|
-
declare function getJsonSchemaType(value?: unknown): JsonSchemaType | undefined;
|
|
1200
|
-
/**
|
|
1201
|
-
* Generates standalone parser code for a JSON Schema.
|
|
1202
|
-
*
|
|
1203
|
-
* @remarks
|
|
1204
|
-
* The generated `parse` function reads an arbitrary input value and converts it
|
|
1205
|
-
* into the shape described by the schema. It walks the schema recursively to:
|
|
1206
|
-
*
|
|
1207
|
-
* - resolve local `$ref` pointers (`#/$defs/*` and `#/definitions/*`) into
|
|
1208
|
-
* dedicated parser functions so recursive schemas are supported,
|
|
1209
|
-
* - apply `default` values for object properties (and root/array values) that
|
|
1210
|
-
* are missing from the input,
|
|
1211
|
-
* - coerce primitive values to the declared type (for example `"42"` to `42`
|
|
1212
|
-
* for an `integer` schema, or `1` to `true` for a `boolean` schema),
|
|
1213
|
-
* - validate `const`, `enum`, `oneOf`/`anyOf` and `allOf` constraints, and
|
|
1214
|
-
* - collect detailed, path-aware errors and throw a `ParserError` when the
|
|
1215
|
-
* input cannot be converted into a valid value.
|
|
1216
|
-
*
|
|
1217
|
-
* @param schema - The JSON Schema to generate parser code for.
|
|
1218
|
-
* @returns The generated standalone parser code as a string.
|
|
1219
|
-
*/
|
|
1220
|
-
declare function generateParserCode(schema: JsonSchema): string;
|
|
1221
|
-
/**
|
|
1222
|
-
* Generates standalone JSON Schema validation code using Ajv.
|
|
1223
|
-
*
|
|
1224
|
-
* @remarks
|
|
1225
|
-
* The generated code includes a validation function that can be used to validate data against the provided JSON Schema at runtime. The validation function will throw an error if the data does not conform to the schema, providing detailed information about the validation errors.
|
|
1226
|
-
*
|
|
1227
|
-
* @param schema - The JSON Schema to generate validation code for.
|
|
1228
|
-
* @param refsOrFuncts - Optional additional references or functions for Ajv's standalone code generation.
|
|
1229
|
-
* @returns The generated standalone validation code as a string.
|
|
1230
|
-
*/
|
|
1231
|
-
declare function generateValidationCode(schema: JsonSchema, refsOrFuncts?: Parameters<typeof standaloneCode>[1]): string;
|
|
1232
|
-
/**
|
|
1233
|
-
* Generates standalone JavaScript code for validating and parsing data according to a JSON Schema.
|
|
1234
|
-
*
|
|
1235
|
-
* @remarks
|
|
1236
|
-
* The generated code includes:
|
|
1237
|
-
* - Validation code generated by Ajv for the provided JSON Schema, which can be used to validate data against the schema at runtime. The validation function will throw an error if the data does not conform to the schema, providing detailed information about the validation errors.
|
|
1238
|
-
* - Parsing code generated for the provided JSON Schema, which can be used to parse and validate data against the schema at runtime. The parsing function will apply default values specified in the schema if they are not present in the input data, throw an error if the input data does not conform to the schema (providing detailed information about the validation errors), and return the parsed data if it is valid according to the schema.
|
|
1239
|
-
*
|
|
1240
|
-
* @param schema - The JSON Schema to generate code for.
|
|
1241
|
-
* @param refsOrFuncts - Optional additional references or functions for Ajv's standalone code generation.
|
|
1242
|
-
* @returns The generated standalone validation and parsing code as a string.
|
|
1243
|
-
*/
|
|
1244
|
-
declare function generateCode(schema: JsonSchema, refsOrFuncts?: Parameters<typeof standaloneCode>[1]): string;
|
|
1245
|
-
//#endregion
|
|
1246
|
-
//#region src/extract.d.ts
|
|
1247
|
-
/**
|
|
1248
|
-
* Bundles all external references in a JSON Schema into a single schema document by collecting all reference targets and rewriting the references to point to the bundled definitions. This ensures that the resulting schema is self-contained and can be used independently without relying on external documents.
|
|
1249
|
-
*
|
|
1250
|
-
* @param schema - The JSON Schema to bundle references for.
|
|
1251
|
-
* @returns A new JSON Schema with all references bundled and rewritten to point to the bundled definitions.
|
|
1252
|
-
*/
|
|
1253
|
-
declare function bundleReferences(schema: JsonSchema): JsonSchema;
|
|
1254
|
-
/**
|
|
1255
|
-
* Creates a hash string for a given schema definition input.
|
|
1256
|
-
*/
|
|
1257
|
-
declare function extractHash(variant: SchemaInputVariant, input: SchemaInput): string;
|
|
1258
|
-
/**
|
|
1259
|
-
* Converts a reflected Deepkit {@link Type} into a JSON Schema (draft-2020-12) representation.
|
|
1260
|
-
*/
|
|
1261
|
-
declare function extractReflection(reflection: Type): JsonSchema | undefined;
|
|
1262
|
-
/**
|
|
1263
|
-
* Extracts a JSON Schema from Zod, Standard Schema, Valibot, untyped, or JSON Schema inputs.
|
|
1264
|
-
*
|
|
1265
|
-
* @param schema - The schema input to extract a JSON Schema from.
|
|
1266
|
-
* @returns The extracted JSON Schema, or `undefined` if the input is not a supported schema type.
|
|
1267
|
-
*/
|
|
1268
|
-
declare function extractJsonSchema(schema: unknown): JsonSchema | undefined;
|
|
1269
|
-
/**
|
|
1270
|
-
* Resolves the concrete source variant for a schema source input.
|
|
1271
|
-
*
|
|
1272
|
-
* @param input - The schema source input to inspect.
|
|
1273
|
-
* @returns The resolved schema source variant.
|
|
1274
|
-
* @throws Will throw an error when the input cannot be mapped to a supported source variant.
|
|
1275
|
-
*/
|
|
1276
|
-
declare function extractResolvedVariant(input: SchemaSourceInput): SchemaSourceVariant;
|
|
1277
|
-
/**
|
|
1278
|
-
* Determines the top-level input variant for schema extraction.
|
|
1279
|
-
*
|
|
1280
|
-
* @param input - The schema input to classify.
|
|
1281
|
-
* @returns The resolved schema input variant.
|
|
1282
|
-
*/
|
|
1283
|
-
declare function extractVariant(input: SchemaInput): SchemaInputVariant;
|
|
1284
|
-
/**
|
|
1285
|
-
* Extracts and normalizes a JSON Schema from a concrete schema source input.
|
|
1286
|
-
*
|
|
1287
|
-
* @param input - The schema source input to extract from.
|
|
1288
|
-
* @param variant - Optional source variant override. When omitted, the variant is inferred from the input.
|
|
1289
|
-
* @returns A promise that resolves to a bundled JSON Schema.
|
|
1290
|
-
* @throws Will throw an error if no valid JSON Schema can be extracted from the input.
|
|
1291
|
-
*/
|
|
1292
|
-
declare function extractSchema(input: SchemaSourceInput, variant?: SchemaInputVariant): Promise<JsonSchema>;
|
|
1293
|
-
/**
|
|
1294
|
-
* Builds source metadata for a schema input using a known source variant.
|
|
1295
|
-
*
|
|
1296
|
-
* @param variant - The schema source variant associated with the input.
|
|
1297
|
-
* @param input - The schema source input to wrap.
|
|
1298
|
-
* @returns The normalized schema source payload, including the source hash and variant.
|
|
1299
|
-
* @throws Will throw an error if the provided variant is unsupported.
|
|
1300
|
-
*/
|
|
1301
|
-
declare function extractSource(variant: SchemaSourceVariant, input: SchemaSourceInput): SchemaSource;
|
|
1302
|
-
/**
|
|
1303
|
-
* Extracts a JSON Schema from a given schema definition input, which can be a Zod schema, a Valibot schema, any Standard JSON Schema type, a plain JSON Schema object, an untyped schema, or a Deepkit Type object. If the input is a type definition reference (e.g. a file path with an export), it will be resolved and bundled using Rolldown to obtain the actual schema definition before extraction.
|
|
1304
|
-
*
|
|
1305
|
-
* @example
|
|
1306
|
-
* ```ts
|
|
1307
|
-
* // Resolve a schema definition from a file path
|
|
1308
|
-
* const schema1 = await extract(context, "./schemas.ts#MySchema");
|
|
1309
|
-
* // Resolve a schema definition from a JSON Schema object
|
|
1310
|
-
* const schema2 = await extract(context, schemaObject);
|
|
1311
|
-
* // Resolve a schema definition from a Zod schema
|
|
1312
|
-
* const schema3 = await extract(context, zodSchema);
|
|
1313
|
-
* // Resolve a schema definition from a reflected Deepkit Type object
|
|
1314
|
-
* const schema4 = await extract(context, reflectionType);
|
|
1315
|
-
* ```
|
|
1316
|
-
*
|
|
1317
|
-
* @see https://zod.dev/
|
|
1318
|
-
* @see https://valibot.dev/
|
|
1319
|
-
* @see https://standardschema.dev/json-schema#what-schema-libraries-support-this-spec
|
|
1320
|
-
* @see https://json-schema.org/
|
|
1321
|
-
* @see https://ajv.js.org/json-type-definition.html
|
|
1322
|
-
* @see https://deepkit.io/en/documentation/runtime-types/reflection
|
|
1323
|
-
*
|
|
1324
|
-
* @param context - The context object providing access to the file system and cache path.
|
|
1325
|
-
* @param input - The schema definition input to extract, which can be a Zod schema, a Valibot schema, any Standard JSON Schema type, a plain JSON Schema object, an untyped schema, or a reflected Deepkit Type object. If the input is a string or a type definition reference, it will be resolved and bundled to obtain the actual schema definition before extraction.
|
|
1326
|
-
* @param options - Optional overrides for the Rolldown configuration used during extraction. This can include custom plugins, loaders, or other build options to control how the schema definition is resolved and bundled when the input is a type definition reference.
|
|
1327
|
-
* @returns A promise that resolves to the extracted and normalized schema as a JSON Schema object. The function will attempt to extract a valid JSON Schema from the provided input, and if successful, it will return the schema. If the extraction process fails or if the input is not a valid schema definition, it will throw an error indicating the failure.
|
|
1328
|
-
*/
|
|
1329
|
-
declare function extractSchemaWithSource(context: Context, input: SchemaInput, options?: BundleOptions): Promise<ExtractedSchema>;
|
|
1330
|
-
/**
|
|
1331
|
-
* Extracts a JSON Schema from a given schema definition input, which can be a Zod schema, a Valibot schema, any Standard JSON Schema type, a plain JSON Schema object, an untyped schema, or a Deepkit Type object. If the input is a type definition reference (e.g. a file path with an export), it will be resolved and bundled using Rolldown to obtain the actual schema definition before extraction.
|
|
1332
|
-
*
|
|
1333
|
-
* @example
|
|
1334
|
-
* ```ts
|
|
1335
|
-
* // Resolve a schema definition from a file path
|
|
1336
|
-
* const schema1 = await extract(context, "./schemas.ts#MySchema");
|
|
1337
|
-
* // Resolve a schema definition from a JSON Schema object
|
|
1338
|
-
* const schema2 = await extract(context, schemaObject);
|
|
1339
|
-
* // Resolve a schema definition from a Zod schema
|
|
1340
|
-
* const schema3 = await extract(context, zodSchema);
|
|
1341
|
-
* // Resolve a schema definition from a Valibot schema
|
|
1342
|
-
* const schema4 = await extract(context, valibotSchema);
|
|
1343
|
-
* // Resolve a schema definition from a reflected Deepkit Type object
|
|
1344
|
-
* const schema5 = await extract(context, reflectionType);
|
|
1345
|
-
* ```
|
|
1346
|
-
*
|
|
1347
|
-
* @see https://zod.dev/
|
|
1348
|
-
* @see https://valibot.dev/
|
|
1349
|
-
* @see https://standardschema.dev/json-schema#what-schema-libraries-support-this-spec
|
|
1350
|
-
* @see https://json-schema.org/
|
|
1351
|
-
* @see https://ajv.js.org/json-type-definition.html
|
|
1352
|
-
* @see https://deepkit.io/en/documentation/runtime-types/reflection
|
|
1353
|
-
* @see https://github.com/unjs/untyped
|
|
1354
|
-
* @see https://www.typescriptlang.org/docs/handbook/2/types-from-types.html
|
|
1355
|
-
*
|
|
1356
|
-
* @param context - The context object providing access to the file system and cache path.
|
|
1357
|
-
* @param input - The schema definition input to extract, which can be a Zod schema, a Valibot schema, any Standard JSON Schema type, a plain JSON Schema object, an untyped schema, or a reflected Deepkit Type object.
|
|
1358
|
-
* @param options - Optional overrides for the Rolldown configuration used during extraction.
|
|
1359
|
-
* @returns A promise that resolves to the extracted and normalized schema as a JSON Schema object.
|
|
1360
|
-
* @throws Will throw an error if the input is not a valid schema definition or if the extraction process fails to produce a valid schema.
|
|
1361
|
-
*/
|
|
1362
|
-
declare function extract(context: Context, input: SchemaInput, options?: BundleOptions): Promise<Schema>;
|
|
1363
|
-
//#endregion
|
|
1364
|
-
//#region src/helpers.d.ts
|
|
1365
|
-
type GetPropertiesResult = JsonSchema & {
|
|
1366
|
-
name: string;
|
|
1367
|
-
required: boolean;
|
|
1368
|
-
default?: unknown;
|
|
1369
|
-
};
|
|
1370
|
-
/**
|
|
1371
|
-
* Retrieves the JSON Schema from a Schema wrapper or returns the input if it's already a JSON Schema.
|
|
1372
|
-
*
|
|
1373
|
-
* @remarks
|
|
1374
|
-
* This function checks if the input is a Schema wrapper (an object with a `schema` property) and returns the `schema` if it is. If the input is already a JSON Schema, it returns it directly. This allows for flexibility in handling both raw JSON Schema objects and wrapped schemas without needing to check the type at every usage point.
|
|
1375
|
-
*
|
|
1376
|
-
* @param input - The input which can be either a Schema wrapper or a JSON Schema object.
|
|
1377
|
-
* @returns The JSON Schema object.
|
|
1378
|
-
* @throws Will throw a TypeError if the input is neither a valid Schema wrapper nor a valid JSON Schema object.
|
|
1379
|
-
*/
|
|
1380
|
-
declare function getJsonSchema(input: Schema | JsonSchema): JsonSchema;
|
|
1381
|
-
/**
|
|
1382
|
-
* Retrieves the JSON Schema in Object form from a Schema wrapper or returns the input if it's already a JSON Schema.
|
|
1383
|
-
*
|
|
1384
|
-
* @remarks
|
|
1385
|
-
* This function checks if the input is a Schema wrapper (an object with a `schema` property) and returns the `schema` if it is. If the input is already a JSON Schema object, it returns it directly. This allows for flexibility in handling both raw JSON Schema objects and wrapped schemas without needing to check the type at every usage point.
|
|
1386
|
-
*
|
|
1387
|
-
* @param input - The input which can be either a Schema wrapper or a JSON Schema object.
|
|
1388
|
-
* @returns The JSON Schema object.
|
|
1389
|
-
* @throws Will throw a TypeError if the input is neither a valid Schema wrapper nor a valid JSON Schema object.
|
|
1390
|
-
*/
|
|
1391
|
-
declare function getJsonSchemaObject(input: Schema | JsonSchema): JsonSchemaObject;
|
|
1392
|
-
/**
|
|
1393
|
-
* Extracts object properties from a JSON Schema object form.
|
|
1394
|
-
*
|
|
1395
|
-
* @remarks
|
|
1396
|
-
* This function returns an empty object if the schema is not an object form or if it has no properties.
|
|
1397
|
-
*
|
|
1398
|
-
* @param obj - The JSON Schema object form or a Schema wrapper to extract properties from.
|
|
1399
|
-
* @returns An object mapping property names to their corresponding JSON Schema fragments, including metadata.
|
|
1400
|
-
*/
|
|
1401
|
-
declare function getProperties(obj: Schema | JsonSchemaObject): Record<string, JsonSchema & {
|
|
1402
|
-
name: string;
|
|
1403
|
-
required: boolean;
|
|
1404
|
-
default?: unknown;
|
|
1405
|
-
}>;
|
|
1406
|
-
/**
|
|
1407
|
-
* Returns object properties as an array.
|
|
1408
|
-
*
|
|
1409
|
-
* @remarks
|
|
1410
|
-
* This is a convenience function that extracts properties using `getProperties` and returns them as an array.
|
|
1411
|
-
*
|
|
1412
|
-
* @param obj - The JSON Schema object form or a Schema wrapper to extract properties from.
|
|
1413
|
-
* @returns An array of JSON Schema fragments representing the properties, each including metadata.
|
|
1414
|
-
*/
|
|
1415
|
-
declare function getPropertiesList(obj: Schema | JsonSchemaObject): (JsonSchema & {
|
|
1416
|
-
name: string;
|
|
1417
|
-
required: boolean;
|
|
1418
|
-
default?: unknown;
|
|
1419
|
-
})[];
|
|
1420
|
-
/**
|
|
1421
|
-
* Adds a property to a JSON Schema object form.
|
|
1422
|
-
*
|
|
1423
|
-
* @remarks
|
|
1424
|
-
* This function modifies the provided schema in place by adding a new property with the specified name and schema. It also updates the `required` array based on the `optional` flag of the property. If the property is marked as optional, it will be removed from the `required` array; otherwise, it will be added to it.
|
|
1425
|
-
*
|
|
1426
|
-
* @param obj - The JSON Schema object form or a Schema wrapper to which the property should be added.
|
|
1427
|
-
* @param name - The name of the property to add.
|
|
1428
|
-
* @param property - The JSON Schema fragment representing the property's schema, including metadata.
|
|
1429
|
-
* @throws Will throw an error if the provided schema is not an object form.
|
|
1430
|
-
*/
|
|
1431
|
-
declare function addProperty(obj: Schema | JsonSchemaObject, name: string, property: JsonSchema): void;
|
|
1432
|
-
/**
|
|
1433
|
-
* Merges multiple JSON Schemas into one.
|
|
1434
|
-
*
|
|
1435
|
-
* @remarks
|
|
1436
|
-
* This function takes multiple JSON Schemas or Schema wrappers and merges them
|
|
1437
|
-
* into a single JSON Schema object. Later schemas in the argument list take
|
|
1438
|
-
* precedence over earlier ones for scalar conflicts.
|
|
1439
|
-
*
|
|
1440
|
-
* Structured keywords are merged recursively:
|
|
1441
|
-
* - Named child schemas (`properties`, `$defs`, etc.) are merged
|
|
1442
|
-
* per-property via recursive calls to `merge`.
|
|
1443
|
-
* - Composition arrays (`allOf`, `anyOf`, `oneOf`) are concatenated.
|
|
1444
|
-
* - Single-schema keywords (`if`, `then`, `else`, `not`, `items`, etc.)
|
|
1445
|
-
* are merged recursively when both sides define them.
|
|
1446
|
-
* - `required` arrays are unioned and deduplicated.
|
|
1447
|
-
*
|
|
1448
|
-
* @param schemas - An array of JSON Schemas or Schema wrappers to merge.
|
|
1449
|
-
* @returns A new JSON Schema that is the result of merging all input schemas.
|
|
1450
|
-
*/
|
|
1451
|
-
declare function merge(...schemas: (JsonSchema | Schema)[]): JsonSchema;
|
|
1452
|
-
/**
|
|
1453
|
-
* Returns whether a JSON Schema fragment accepts `null`.
|
|
1454
|
-
*
|
|
1455
|
-
* @remarks
|
|
1456
|
-
* This is true if the schema has `nullable: true` or if its `type` includes `"null"`.
|
|
1457
|
-
*
|
|
1458
|
-
* @param schema - The JSON Schema fragment to check.
|
|
1459
|
-
* @returns `true` if the schema accepts `null`, otherwise `false`.
|
|
1460
|
-
*/
|
|
1461
|
-
declare function isSchemaNullable(schema?: JsonSchema): boolean;
|
|
1462
|
-
/**
|
|
1463
|
-
* Returns whether an object property is optional (not listed in `required`).
|
|
1464
|
-
*
|
|
1465
|
-
* @remarks
|
|
1466
|
-
* In JSON Schema, object properties are optional by default unless they are listed in the `required` array of the parent schema. This function checks whether a given property name is not included in the `required` array of its parent schema, indicating that it is optional.
|
|
1467
|
-
*
|
|
1468
|
-
* @param parent - The parent JSON Schema object containing the property.
|
|
1469
|
-
* @param propertyName - The name of the property to check for optionality.
|
|
1470
|
-
* @returns `true` if the property is optional, otherwise `false`.
|
|
1471
|
-
*/
|
|
1472
|
-
declare function isPropertyOptional(parent: JsonSchemaObject, propertyName: string): boolean;
|
|
1473
|
-
/**
|
|
1474
|
-
* Checks if a given file name has a valid schema input file extension.
|
|
1475
|
-
*
|
|
1476
|
-
* @param fileName - The file name to check for a valid schema input extension.
|
|
1477
|
-
* @returns `true` if the file name has a valid schema input extension, otherwise `false`.
|
|
1478
|
-
*/
|
|
1479
|
-
declare function isValidSchemaInputFile(fileName: string): boolean;
|
|
1480
|
-
//#endregion
|
|
1481
|
-
//#region src/metadata.d.ts
|
|
1482
|
-
/**
|
|
1483
|
-
* Applies Powerlines schema metadata onto a JSON Schema fragment.
|
|
1484
|
-
*
|
|
1485
|
-
* @param schema - The JSON Schema fragment to apply metadata to.
|
|
1486
|
-
* @param metadata - The Powerlines schema metadata to apply.
|
|
1487
|
-
* @returns A new JSON Schema fragment with the metadata applied.
|
|
1488
|
-
*/
|
|
1489
|
-
declare function applyJsonSchemaMetadata(schema: JsonSchema, metadata: JsonSchemaMetadataKeywords | undefined): JsonSchema;
|
|
1490
|
-
/**
|
|
1491
|
-
* Normalizes the JSON Schema `type` keyword to a string array.
|
|
1492
|
-
*
|
|
1493
|
-
* @remarks
|
|
1494
|
-
* This function ensures that the `type` keyword of a JSON Schema fragment is always represented as an array of strings, even if it was originally defined as a single string. This normalization simplifies type checking and processing of JSON Schemas by providing a consistent format for the `type` information.
|
|
1495
|
-
*
|
|
1496
|
-
* @param schema - The JSON Schema fragment to read types from.
|
|
1497
|
-
* @returns An array of JSON Schema primitive type names defined in the `type` keyword, or an empty array if no valid types are found.
|
|
1498
|
-
*/
|
|
1499
|
-
declare function readSchemaTypes(schema?: JsonSchema): JsonSchemaPrimitiveType[];
|
|
1500
|
-
/**
|
|
1501
|
-
* Returns the primary non-null JSON Schema type name for a fragment.
|
|
1502
|
-
*
|
|
1503
|
-
* @param schema - The JSON Schema fragment to check.
|
|
1504
|
-
* @returns The primary non-null JSON Schema type name, or `undefined` if none is found.
|
|
1505
|
-
*/
|
|
1506
|
-
declare function getPrimarySchemaType(schema?: JsonSchema): JsonSchemaPrimitiveType | undefined;
|
|
1507
|
-
//#endregion
|
|
1508
|
-
//#region src/persistence.d.ts
|
|
1509
|
-
/**
|
|
1510
|
-
* A helper function to get the cache directory path for storing schemas. This function takes a context object as input and returns the path to the cache directory where schemas are stored. The cache directory is constructed by joining the `cachePath` property from the context with a subdirectory named "schemas". This function is useful for centralizing the logic for determining where schema files should be cached, ensuring that all schema-related file operations use a consistent location for storing and retrieving cached schemas.
|
|
1511
|
-
*
|
|
1512
|
-
* @param context - The context object providing access to the cache path.
|
|
1513
|
-
* @returns The path to the cache directory for storing schemas, constructed by joining the context's `cachePath` with the "schemas" subdirectory.
|
|
1514
|
-
*/
|
|
1515
|
-
declare function getCacheDirectory(context: Context): string;
|
|
1516
|
-
/**
|
|
1517
|
-
* A helper function to get the file path for a cached schema based on the provided context and schema input. This function first extracts the variant and hash from the input schema using the `extractVariant` and `extractHash` functions, respectively. It then constructs the file path to the cached schema JSON file by joining the cache directory path (obtained from the `getCacheDirectory` function) with a filename derived from the extracted hash. The resulting file path points to where the cached schema should be stored or retrieved from in the file system. This function is essential for ensuring that all operations related to caching schemas use a consistent method for determining the correct file path based on the schema's unique identifier (hash).
|
|
1518
|
-
*
|
|
1519
|
-
* @param context - The context object providing access to the cache path.
|
|
1520
|
-
* @param input - The input schema from which to extract the variant and hash for constructing the cache file path.
|
|
1521
|
-
* @returns The file path to the cached schema JSON file, constructed by joining the cache directory path with a filename derived from the extracted hash of the schema input.
|
|
1522
|
-
*/
|
|
1523
|
-
declare function getCacheFilePath(context: Context, input: SchemaInput): string;
|
|
1524
|
-
/**
|
|
1525
|
-
* Writes a given schema to the file system using the provided context. This function first checks if the input is a valid schema using the `isSchema` type guard. If the input is not a valid schema, it throws an error indicating that the provided input is invalid. If the input is valid, it proceeds to write the schema to a JSON file in the cache directory specified by the context. The file is named using the hash of the schema to ensure uniqueness and easy retrieval in future operations. The schema is serialized to JSON format before being written to the file system. This function is asynchronous and returns a promise that resolves once the writing operation is complete.
|
|
1526
|
-
*
|
|
1527
|
-
* @param context - The context object providing access to the file system and cache path.
|
|
1528
|
-
* @param schema - The schema to be written to the file system, which must be a valid schema object containing a `variant`, `schema`, and `hash` property.
|
|
1529
|
-
* @throws Will throw an error if the provided input is not a valid schema.
|
|
1530
|
-
*/
|
|
1531
|
-
declare function writeSchema(context: Context, schema: Schema): Promise<void>;
|
|
1532
|
-
/**
|
|
1533
|
-
* A helper function to read a schema from the file system using the provided context. This function first extracts the variant and hash from the input schema using the `extractVariant` and `extractHash` functions, respectively. It then constructs the file path to the cached schema JSON file based on the cache path provided in the context and the extracted hash. The function checks if the file exists in the cache; if it does not exist, it returns `undefined`. If the file exists, it reads the contents of the file, parses it as JSON, and returns the resulting object. This function is asynchronous and returns a promise that resolves to either the parsed schema object or `undefined` if the schema is not found in the cache.
|
|
1534
|
-
*
|
|
1535
|
-
* @param context - The context object providing access to the file system and cache path.
|
|
1536
|
-
* @param input - The input schema from which to extract the variant and hash for locating the cached schema file.
|
|
1537
|
-
* @returns A promise that resolves to the parsed schema object if found in the cache, or `undefined` if the schema does not exist in the cache.
|
|
1538
|
-
*/
|
|
1539
|
-
declare function readSchemaSafe(context: Context, input: SchemaInput): Promise<Schema | undefined>;
|
|
1540
|
-
/**
|
|
1541
|
-
* Reads a schema from the file system using the provided context and input. This function first attempts to read the schema using the `readSchemaSafe` helper function, which returns `undefined` if the schema is not found in the cache. If the schema is not found, this function throws an error indicating that the schema with the specified variant and hash does not exist in the cache. The error message suggests that this may be due to a missing or corrupted cache file, or because the schema has not been written to the cache yet. It advises ensuring that the schema is properly written to the cache before attempting to read it. If the schema is successfully read from the cache, it is returned as a parsed object. This function is asynchronous and returns a promise that resolves to the parsed schema object if found, or throws an error if the schema is not found in the cache.
|
|
1542
|
-
*
|
|
1543
|
-
* @param context - The context object providing access to the file system and cache path.
|
|
1544
|
-
* @param input - The input schema from which to extract the variant and hash for locating the cached schema file.
|
|
1545
|
-
* @returns A promise that resolves to the parsed schema object if found in the cache, or throws an error if the schema does not exist in the cache.
|
|
1546
|
-
* @throws Will throw an error if the schema with the specified variant and hash does not exist in the cache.
|
|
1547
|
-
*/
|
|
1548
|
-
declare function readSchema(context: Context, input: SchemaInput): Promise<Schema>;
|
|
1549
|
-
//#endregion
|
|
1550
|
-
//#region src/reflection.d.ts
|
|
1551
|
-
/**
|
|
1552
|
-
* Converts a Deepkit type reflection into a JSON Schema (draft-07) fragment.
|
|
1553
|
-
*/
|
|
1554
|
-
declare function reflectionToJsonSchema(reflection: Type): JsonSchema | undefined;
|
|
1555
|
-
//#endregion
|
|
1556
|
-
//#region src/resolve.d.ts
|
|
1557
|
-
/**
|
|
1558
|
-
* Compiles a type definition to a module and returns the module.
|
|
1559
|
-
*
|
|
1560
|
-
* @param context - The context object containing the environment paths.
|
|
1561
|
-
* @param input - The type definition to compile. This can be either a string or a {@link FileReference} object.
|
|
1562
|
-
* @param overrides - Optional overrides for the ESBuild configuration.
|
|
1563
|
-
* @returns A promise that resolves to the compiled module.
|
|
1564
|
-
*/
|
|
1565
|
-
declare function resolveModule<TResult, TContext extends UnresolvedContext = UnresolvedContext>(context: TContext, input: FileReferenceInput, overrides?: BundleOptions): Promise<TResult>;
|
|
1566
|
-
/**
|
|
1567
|
-
* Compiles a type definition to a module and returns the specified export from the module.
|
|
1568
|
-
*
|
|
1569
|
-
* @param context - The context object containing the environment paths.
|
|
1570
|
-
* @param input - The type definition to compile. This can be either a string or a {@link FileReference} object.
|
|
1571
|
-
* @param options - Optional overrides for the ESBuild configuration.
|
|
1572
|
-
* @returns A promise that resolves to the compiled module.
|
|
1573
|
-
*/
|
|
1574
|
-
declare function resolve<TResult, TContext extends UnresolvedContext = UnresolvedContext>(context: TContext, input: FileReferenceInput, options?: BundleOptions): Promise<TResult>;
|
|
1575
|
-
/**
|
|
1576
|
-
* Resolves a type definition to a Deepkit Type reflection. This function compiles the provided type definition to a module, evaluates the module to get the specified export, and then reflects the export to get its Deepkit Type reflection.
|
|
1577
|
-
*
|
|
1578
|
-
* @param context - The context object containing the environment paths.
|
|
1579
|
-
* @param input - The type definition to compile. This can be either a string or a {@link FileReference} object.
|
|
1580
|
-
* @param options - Optional overrides for the ESBuild configuration.
|
|
1581
|
-
* @returns A promise that resolves to the Deepkit Type reflection.
|
|
1582
|
-
*/
|
|
1583
|
-
declare function resolveReflection<TContext extends PluginContext = PluginContext>(context: TContext, input: FileReference, options?: BundleOptions): Promise<Type>;
|
|
1584
|
-
//#endregion
|
|
1585
|
-
//#region src/type-checks.d.ts
|
|
1586
|
-
/**
|
|
1587
|
-
* A helper type guard to check if a value is a JSON Schema primitive type.
|
|
1588
|
-
*
|
|
1589
|
-
* @param value - The value to check.
|
|
1590
|
-
* @returns True if the value is a JSON Schema primitive type, false otherwise.
|
|
1591
|
-
*/
|
|
1592
|
-
declare function isJsonSchemaPrimitiveType(value: unknown): value is JsonSchemaPrimitiveType;
|
|
1593
|
-
/**
|
|
1594
|
-
* A helper type guard to check if a value is a JSON Schema type.
|
|
1595
|
-
*
|
|
1596
|
-
* @param value - The value to check.
|
|
1597
|
-
* @returns True if the value is a JSON Schema type, false otherwise.
|
|
1598
|
-
*/
|
|
1599
|
-
declare function isJsonSchemaType(value: unknown): value is JsonSchemaType;
|
|
1600
|
-
/**
|
|
1601
|
-
* Type guard for shared JSON Schema keyword groups.
|
|
1602
|
-
*
|
|
1603
|
-
* @param input - The value to check.
|
|
1604
|
-
* @returns True if the input is a JSON Schema keyword group, false otherwise.
|
|
1605
|
-
*/
|
|
1606
|
-
declare function isJsonSchemaKeywords(input: unknown): input is JsonSchemaKeywords;
|
|
1607
|
-
/**
|
|
1608
|
-
* Type guard for generic JSON Schema objects with optional `$ref`.
|
|
1609
|
-
*
|
|
1610
|
-
* @param input - The value to check.
|
|
1611
|
-
* @returns True if the input is a generic JSON Schema object, false otherwise.
|
|
1612
|
-
*/
|
|
1613
|
-
declare function isJsonSchemaAny(input: unknown): input is JsonSchemaAny;
|
|
1614
|
-
/**
|
|
1615
|
-
* Type guard for JSON Schema array types.
|
|
1616
|
-
*
|
|
1617
|
-
* @param input - The value to check.
|
|
1618
|
-
* @returns True if the input is a JSON Schema array schema, false otherwise.
|
|
1619
|
-
*/
|
|
1620
|
-
declare function isJsonSchemaArray(input: unknown): input is JsonSchemaArray;
|
|
1621
|
-
/**
|
|
1622
|
-
* Type guard for bigint-backed integer schemas.
|
|
1623
|
-
*
|
|
1624
|
-
* @param input - The value to check.
|
|
1625
|
-
* @returns True if the input is a bigint-backed integer schema, false otherwise.
|
|
1626
|
-
*/
|
|
1627
|
-
declare function isJsonSchemaBigint(input: unknown): input is JsonSchemaBigint;
|
|
1628
|
-
/**
|
|
1629
|
-
* Type guard for boolean schemas.
|
|
1630
|
-
*
|
|
1631
|
-
* @param input - The value to check.
|
|
1632
|
-
* @returns True if the input is a boolean schema, false otherwise.
|
|
1633
|
-
*/
|
|
1634
|
-
declare function isJsonSchemaBoolean(input: unknown): input is JsonSchemaBoolean;
|
|
1635
|
-
/**
|
|
1636
|
-
* Type guard for date/time schemas.
|
|
1637
|
-
*
|
|
1638
|
-
* @param input - The value to check.
|
|
1639
|
-
* @returns True if the input is a date or time schema, false otherwise.
|
|
1640
|
-
*/
|
|
1641
|
-
declare function isJsonSchemaDate(input: unknown): input is JsonSchemaDate;
|
|
1642
|
-
/**
|
|
1643
|
-
* Type guard for enum-constrained schemas.
|
|
1644
|
-
*
|
|
1645
|
-
* @param input - The value to check.
|
|
1646
|
-
* @returns True if the input is an enum-constrained schema, false otherwise.
|
|
1647
|
-
*/
|
|
1648
|
-
declare function isJsonSchemaEnum(input: unknown): input is JsonSchemaEnum;
|
|
1649
|
-
/**
|
|
1650
|
-
* Type guard for `allOf` composition schemas.
|
|
1651
|
-
*
|
|
1652
|
-
* @param input - The value to check.
|
|
1653
|
-
* @returns True if the input is an `allOf` schema, false otherwise.
|
|
1654
|
-
*/
|
|
1655
|
-
declare function isJsonSchemaAllOf(input: unknown): input is JsonSchemaAllOf;
|
|
1656
|
-
/**
|
|
1657
|
-
* Type guard for literal-value schemas.
|
|
1658
|
-
*
|
|
1659
|
-
* @param input - The value to check.
|
|
1660
|
-
* @returns True if the input is a literal-value schema, false otherwise.
|
|
1661
|
-
*/
|
|
1662
|
-
declare function isJsonSchemaLiteral(input: unknown): input is JsonSchemaLiteral;
|
|
1663
|
-
/**
|
|
1664
|
-
* Type guard for map tuple-array schemas.
|
|
1665
|
-
*
|
|
1666
|
-
* @param input - The value to check.
|
|
1667
|
-
* @returns True if the input is a map tuple-array schema, false otherwise.
|
|
1668
|
-
*/
|
|
1669
|
-
declare function isJsonSchemaMap(input: unknown): input is JsonSchemaMap;
|
|
1670
|
-
/**
|
|
1671
|
-
* Type guard for native enum schemas.
|
|
1672
|
-
*
|
|
1673
|
-
* @param input - The value to check.
|
|
1674
|
-
* @returns True if the input is a native enum schema, false otherwise.
|
|
1675
|
-
*/
|
|
1676
|
-
declare function isJsonSchemaNativeEnum(input: unknown): input is JsonSchemaNativeEnum;
|
|
1677
|
-
/**
|
|
1678
|
-
* Type guard for impossible/never schemas.
|
|
1679
|
-
*
|
|
1680
|
-
* @param input - The value to check.
|
|
1681
|
-
* @returns True if the input is a never schema, false otherwise.
|
|
1682
|
-
*/
|
|
1683
|
-
declare function isJsonSchemaNever(input: unknown): input is JsonSchemaNever;
|
|
1684
|
-
/**
|
|
1685
|
-
* Type guard for `null` schemas.
|
|
1686
|
-
*
|
|
1687
|
-
* @param input - The value to check.
|
|
1688
|
-
* @returns True if the input is a null schema, false otherwise.
|
|
1689
|
-
*/
|
|
1690
|
-
declare function isJsonSchemaNull(input: unknown): input is JsonSchemaNull;
|
|
1691
|
-
/**
|
|
1692
|
-
* Type guard for nullable schema unions.
|
|
1693
|
-
*
|
|
1694
|
-
* @param input - The value to check.
|
|
1695
|
-
* @returns True if the input is a nullable schema union, false otherwise.
|
|
1696
|
-
*/
|
|
1697
|
-
declare function isJsonSchemaNullable(input: unknown): input is JsonSchemaNullable;
|
|
1698
|
-
/**
|
|
1699
|
-
* Type guard for numeric schemas.
|
|
1700
|
-
*
|
|
1701
|
-
* @param input - The value to check.
|
|
1702
|
-
* @returns True if the input is a numeric schema, false otherwise.
|
|
1703
|
-
*/
|
|
1704
|
-
declare function isJsonSchemaNumber(input: unknown): input is JsonSchemaNumber;
|
|
1705
|
-
/**
|
|
1706
|
-
* Type guard for integer schemas.
|
|
1707
|
-
*
|
|
1708
|
-
* @param input - The value to check.
|
|
1709
|
-
* @returns True if the input is an integer schema, false otherwise.
|
|
1710
|
-
*/
|
|
1711
|
-
declare function isJsonSchemaInteger(input: unknown): input is JsonSchemaInteger;
|
|
1712
|
-
/**
|
|
1713
|
-
* Type guard for decimal schemas.
|
|
1714
|
-
*
|
|
1715
|
-
* @param input - The value to check.
|
|
1716
|
-
* @returns True if the input is a decimal schema, false otherwise.
|
|
1717
|
-
*/
|
|
1718
|
-
declare function isJsonSchemaDecimal(input: unknown): input is JsonSchemaDecimal;
|
|
1719
|
-
/**
|
|
1720
|
-
* Type guard for object schemas.
|
|
1721
|
-
*
|
|
1722
|
-
* @param input - The value to check.
|
|
1723
|
-
* @returns True if the input is an object schema, false otherwise.
|
|
1724
|
-
*/
|
|
1725
|
-
declare function isJsonSchemaObject(input: unknown): input is JsonSchemaObject;
|
|
1726
|
-
/**
|
|
1727
|
-
* Type guard for string schemas.
|
|
1728
|
-
*
|
|
1729
|
-
* @param input - The value to check.
|
|
1730
|
-
* @returns True if the input is a string schema, false otherwise.
|
|
1731
|
-
*/
|
|
1732
|
-
declare function isJsonSchemaString(input: unknown): input is JsonSchemaString;
|
|
1733
|
-
/**
|
|
1734
|
-
* Type guard for set-like array schemas.
|
|
1735
|
-
*
|
|
1736
|
-
* @param input - The value to check.
|
|
1737
|
-
* @returns True if the input is a set-like array schema, false otherwise.
|
|
1738
|
-
*/
|
|
1739
|
-
declare function isJsonSchemaSet(input: unknown): input is JsonSchemaSet;
|
|
1740
|
-
/**
|
|
1741
|
-
* Type guard for record schemas.
|
|
1742
|
-
*
|
|
1743
|
-
* @param input - The value to check.
|
|
1744
|
-
* @returns True if the input is a record schema, false otherwise.
|
|
1745
|
-
*/
|
|
1746
|
-
declare function isJsonSchemaRecord(input: unknown): input is JsonSchemaRecord;
|
|
1747
|
-
/**
|
|
1748
|
-
* Type guard for tuple schemas.
|
|
1749
|
-
*
|
|
1750
|
-
* @param input - The value to check.
|
|
1751
|
-
* @returns True if the input is a tuple schema, false otherwise.
|
|
1752
|
-
*/
|
|
1753
|
-
declare function isJsonSchemaTuple(input: unknown): input is JsonSchemaTuple;
|
|
1754
|
-
/**
|
|
1755
|
-
* Type guard for undefined-representing schemas.
|
|
1756
|
-
*
|
|
1757
|
-
* @param input - The value to check.
|
|
1758
|
-
* @returns True if the input is an undefined-representing schema, false otherwise.
|
|
1759
|
-
*/
|
|
1760
|
-
declare function isJsonSchemaUndefined(input: unknown): input is JsonSchemaUndefined;
|
|
1761
|
-
/**
|
|
1762
|
-
* Type guard for primitive-union schema variants.
|
|
1763
|
-
*
|
|
1764
|
-
* @param input - The value to check.
|
|
1765
|
-
* @returns True if the input is a primitive-union schema variant, false otherwise.
|
|
1766
|
-
*/
|
|
1767
|
-
declare function isJsonSchemaPrimitiveUnion(input: unknown): input is JsonSchemaPrimitiveUnion;
|
|
1768
|
-
/**
|
|
1769
|
-
* Type guard for union schemas.
|
|
1770
|
-
*
|
|
1771
|
-
* @param input - The value to check.
|
|
1772
|
-
* @returns True if the input is a union schema, false otherwise.
|
|
1773
|
-
*/
|
|
1774
|
-
declare function isJsonSchemaUnion(input: unknown): input is JsonSchemaUnion;
|
|
1775
|
-
/**
|
|
1776
|
-
* Type guard for permissive unknown schemas.
|
|
1777
|
-
*
|
|
1778
|
-
* @param input - The value to check.
|
|
1779
|
-
* @returns True if the input is a permissive unknown schema, false otherwise.
|
|
1780
|
-
*/
|
|
1781
|
-
declare function isJsonSchemaUnknown(input: unknown): input is JsonSchemaUnknown;
|
|
1782
|
-
/**
|
|
1783
|
-
* Type guard for `anyOf` composition schemas.
|
|
1784
|
-
*
|
|
1785
|
-
* @param input - The value to check.
|
|
1786
|
-
* @returns True if the input is an `anyOf` schema, false otherwise.
|
|
1787
|
-
*/
|
|
1788
|
-
declare function isJsonSchemaAnyOf(input: unknown): input is JsonSchemaAnyOf;
|
|
1789
|
-
/**
|
|
1790
|
-
* Type guard for reference schemas.
|
|
1791
|
-
*
|
|
1792
|
-
* @param input - The value to check.
|
|
1793
|
-
* @returns True if the input is a reference schema, false otherwise.
|
|
1794
|
-
*/
|
|
1795
|
-
declare function isJsonSchemaRef(input: unknown): input is JsonSchemaRef;
|
|
1796
|
-
/**
|
|
1797
|
-
* Type guard for Standard Schema V1 objects.
|
|
1798
|
-
*
|
|
1799
|
-
* @param input - The value to check.
|
|
1800
|
-
* @returns True if the input is a Standard Schema V1 object, false otherwise.
|
|
1801
|
-
*/
|
|
1802
|
-
declare function isStandardSchema(input: unknown): input is StandardSchemaV1;
|
|
1803
|
-
/**
|
|
1804
|
-
* Type guard for Valibot BaseSchema objects.
|
|
1805
|
-
*
|
|
1806
|
-
* @param input - The value to check.
|
|
1807
|
-
* @returns True if the input is a Valibot BaseSchema, false otherwise.
|
|
1808
|
-
*/
|
|
1809
|
-
declare function isValibotSchema(input: unknown): input is BaseSchema<any, any, any>;
|
|
1810
|
-
/**
|
|
1811
|
-
* Type guard for JSON Schema types.
|
|
1812
|
-
*
|
|
1813
|
-
* @remarks
|
|
1814
|
-
* This function checks if the input is a JSON Schema type, which is defined as having a `type` property or a `$ref` property. This is used to determine if a given input conforms to the structure of a JSON Schema definition that includes type information.
|
|
1815
|
-
*
|
|
1816
|
-
* @param input - The value to check.
|
|
1817
|
-
* @returns True if the input is a JSON Schema type, false otherwise.
|
|
1818
|
-
*/
|
|
1819
|
-
declare function isJsonSchema(input: unknown): input is JsonSchema;
|
|
1820
|
-
/**
|
|
1821
|
-
* Type guard for JSON Schemas that only accept `null`.
|
|
1822
|
-
*
|
|
1823
|
-
* @remarks
|
|
1824
|
-
* This function checks if the input is a JSON Schema that exclusively accepts the `null` type. It verifies that the input is a valid JSON Schema and that its `type` property is set to "null". This is useful for identifying schemas that are specifically designed to allow only `null` values.
|
|
1825
|
-
*
|
|
1826
|
-
* @param input - The value to check.
|
|
1827
|
-
* @returns True if the input is a JSON Schema that only accepts `null`, false otherwise.
|
|
1828
|
-
*/
|
|
1829
|
-
declare function isNullOnlyJsonSchema(input: unknown): input is JsonSchemaNull;
|
|
1830
|
-
/**
|
|
1831
|
-
* Type guard for untyped schema objects.
|
|
1832
|
-
*
|
|
1833
|
-
* @remarks
|
|
1834
|
-
* This function checks if the input is an untyped schema object, which is defined as having certain properties that are commonly found in untyped schema definitions. This includes properties such as `id`, `title`, `description`, `$schema`, `tsType`, `markdownType`, `type`, `required`, `tags`, `args`, `properties`, and `resolve`. The function verifies that these properties, if present, conform to the expected types (e.g., strings for certain properties, arrays for others). This type guard is used to determine if a given input can be treated as an untyped schema object within the context of the Powerlines schema system.
|
|
1835
|
-
*
|
|
1836
|
-
* @param input - The value to check.
|
|
1837
|
-
* @returns True if the input is an untyped schema object, false otherwise.
|
|
1838
|
-
*/
|
|
1839
|
-
declare function isUntypedSchema(input: unknown): input is Schema$1;
|
|
1840
|
-
/**
|
|
1841
|
-
* Strict type guard for untyped schema objects.
|
|
1842
|
-
*
|
|
1843
|
-
* @remarks
|
|
1844
|
-
* This guard narrows values to the Untyped schema model while explicitly
|
|
1845
|
-
* rejecting values that are also valid JSON Schema instances.
|
|
1846
|
-
*
|
|
1847
|
-
* @param input - The value to check.
|
|
1848
|
-
* @returns True if the input is an untyped schema and not a JSON Schema.
|
|
1849
|
-
*/
|
|
1850
|
-
declare function isUntypedSchemaStrict(input: unknown): input is Schema$1;
|
|
1851
|
-
/**
|
|
1852
|
-
* Type guard for untyped input objects.
|
|
1853
|
-
*
|
|
1854
|
-
* @remarks
|
|
1855
|
-
* This function checks if the input is an untyped input object, which is defined as having certain properties that are commonly found in untyped input definitions. This includes properties such as `$schema` and `$resolve`. The function verifies that these properties, if present, conform to the expected types (e.g., objects for `$schema`, functions for `$resolve`). This type guard is used to determine if a given input can be treated as an untyped input object within the context of the Powerlines schema system.
|
|
1856
|
-
*
|
|
1857
|
-
* @param input - The value to check.
|
|
1858
|
-
* @returns True if the input is an untyped input object, false otherwise.
|
|
1859
|
-
*/
|
|
1860
|
-
declare function isUntypedInput(input: unknown): input is InputObject;
|
|
1861
|
-
/**
|
|
1862
|
-
* Strict type guard for untyped input objects.
|
|
1863
|
-
*
|
|
1864
|
-
* @remarks
|
|
1865
|
-
* This guard narrows values to the Untyped input-object model while
|
|
1866
|
-
* explicitly rejecting values that are valid JSON Schema objects.
|
|
1867
|
-
*
|
|
1868
|
-
* @param input - The value to check.
|
|
1869
|
-
* @returns True if the input is an untyped input object and not JSON Schema.
|
|
1870
|
-
*/
|
|
1871
|
-
declare function isUntypedInputStrict(input: unknown): input is InputObject;
|
|
1872
|
-
/**
|
|
1873
|
-
* Type guard for Powerlines Schema objects.
|
|
1874
|
-
*
|
|
1875
|
-
* @param input - The value to check.
|
|
1876
|
-
* @returns True if the input is a Powerlines Schema object, false otherwise.
|
|
1877
|
-
*/
|
|
1878
|
-
declare function isSchema(input: unknown): input is Schema;
|
|
1879
|
-
/**
|
|
1880
|
-
* Type guard for extracted schema objects that include source information.
|
|
1881
|
-
*
|
|
1882
|
-
* @param input - The value to check.
|
|
1883
|
-
* @returns True if the input is a SchemaWithSource object, false otherwise.
|
|
1884
|
-
*/
|
|
1885
|
-
declare function isSchemaWithSource(input: unknown): input is ExtractedSchema;
|
|
1886
|
-
/**
|
|
1887
|
-
* Type guard for Powerlines Schemas that are in Object form.
|
|
1888
|
-
*
|
|
1889
|
-
* @param input - The value to check.
|
|
1890
|
-
* @returns True if the input is a Powerlines Schema object in Object form, false otherwise.
|
|
1891
|
-
*/
|
|
1892
|
-
declare function isSchemaObject(input: unknown): input is Schema<JsonSchemaObject>;
|
|
1893
|
-
//#endregion
|
|
1894
13
|
//#region src/index.d.ts
|
|
1895
14
|
declare module "zod" {
|
|
1896
15
|
interface GlobalMeta {
|