@powerlines/schema 0.11.44 → 0.11.46
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/bundle.cjs +1 -1
- package/dist/bundle.d.cts +1 -1
- package/dist/bundle.d.mts +1 -1
- package/dist/bundle.mjs +1 -1
- package/dist/bundle.mjs.map +1 -1
- package/dist/codegen.cjs +28 -22
- package/dist/codegen.d.cts +11 -11
- package/dist/codegen.d.cts.map +1 -1
- package/dist/codegen.d.mts +11 -11
- package/dist/codegen.d.mts.map +1 -1
- package/dist/codegen.mjs +36 -30
- package/dist/codegen.mjs.map +1 -1
- package/dist/constants.cjs +15 -11
- package/dist/constants.d.cts +4 -3
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.mts +4 -3
- package/dist/constants.d.mts.map +1 -1
- package/dist/constants.mjs +13 -10
- package/dist/constants.mjs.map +1 -1
- package/dist/extract.cjs +158 -20
- package/dist/extract.d.cts +55 -16
- package/dist/extract.d.cts.map +1 -1
- package/dist/extract.d.mts +55 -16
- package/dist/extract.d.mts.map +1 -1
- package/dist/extract.mjs +158 -22
- package/dist/extract.mjs.map +1 -1
- package/dist/helpers.cjs +43 -8
- package/dist/helpers.d.cts +40 -6
- package/dist/helpers.d.cts.map +1 -1
- package/dist/helpers.d.mts +40 -6
- package/dist/helpers.d.mts.map +1 -1
- package/dist/helpers.mjs +43 -10
- package/dist/helpers.mjs.map +1 -1
- package/dist/index.cjs +39 -7
- package/dist/index.d.cts +8 -8
- package/dist/index.d.mts +8 -8
- package/dist/index.mjs +7 -7
- package/dist/metadata.cjs +9 -35
- package/dist/metadata.d.cts +5 -26
- package/dist/metadata.d.cts.map +1 -1
- package/dist/metadata.d.mts +5 -26
- package/dist/metadata.d.mts.map +1 -1
- package/dist/metadata.mjs +9 -33
- package/dist/metadata.mjs.map +1 -1
- package/dist/persistence.d.cts +4 -4
- package/dist/persistence.d.cts.map +1 -1
- package/dist/persistence.d.mts +4 -4
- package/dist/persistence.d.mts.map +1 -1
- package/dist/persistence.mjs.map +1 -1
- package/dist/reflection.cjs +72 -50
- package/dist/reflection.d.cts +1 -1
- package/dist/reflection.d.cts.map +1 -1
- package/dist/reflection.d.mts +1 -1
- package/dist/reflection.d.mts.map +1 -1
- package/dist/reflection.mjs +74 -52
- package/dist/reflection.mjs.map +1 -1
- package/dist/resolve.cjs +2 -2
- package/dist/resolve.mjs +2 -2
- package/dist/resolve.mjs.map +1 -1
- package/dist/type-checks.cjs +363 -83
- package/dist/type-checks.d.cts +138 -16
- package/dist/type-checks.d.cts.map +1 -1
- package/dist/type-checks.d.mts +138 -16
- package/dist/type-checks.d.mts.map +1 -1
- package/dist/type-checks.mjs +336 -85
- package/dist/type-checks.mjs.map +1 -1
- package/dist/types.d.cts +901 -176
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +901 -176
- package/dist/types.d.mts.map +1 -1
- package/dist/validate.mjs.map +1 -1
- package/package.json +5 -5
package/dist/types.d.cts
CHANGED
|
@@ -1,187 +1,108 @@
|
|
|
1
|
+
import { JSON_SCHEMA_PRIMITIVE_TYPES, JSON_SCHEMA_TYPES } from "./constants.cjs";
|
|
1
2
|
import { Type } from "@powerlines/deepkit/vendor/type";
|
|
2
3
|
import { StandardJSONSchemaV1 } from "@standard-schema/spec";
|
|
3
4
|
import { TypeDefinition } from "@stryke/types/configuration";
|
|
4
|
-
import { FormatName } from "ajv-formats/dist/formats.js";
|
|
5
5
|
import { InputObject, Schema } from "untyped";
|
|
6
6
|
import { BaseIssue, BaseSchema } from "valibot";
|
|
7
7
|
import * as z3 from "zod/v3";
|
|
8
8
|
|
|
9
9
|
//#region src/types.d.ts
|
|
10
|
+
/**
|
|
11
|
+
* Alias for the Untyped object-input schema shape.
|
|
12
|
+
*/
|
|
10
13
|
type UntypedInputObject = InputObject;
|
|
14
|
+
/**
|
|
15
|
+
* Alias for the Untyped schema document shape.
|
|
16
|
+
*/
|
|
11
17
|
type UntypedSchema = Schema;
|
|
18
|
+
/**
|
|
19
|
+
* A Valibot schema instance.
|
|
20
|
+
*
|
|
21
|
+
* @template TInput - The raw input type accepted by the schema.
|
|
22
|
+
* @template TOutput - The parsed output type produced by the schema.
|
|
23
|
+
* @template TIssue - The issue type emitted for validation errors.
|
|
24
|
+
*/
|
|
12
25
|
type ValibotSchema<TInput = unknown, TOutput = unknown, TIssue extends BaseIssue<unknown> = BaseIssue<unknown>> = BaseSchema<TInput, TOutput, TIssue>;
|
|
13
26
|
/**
|
|
14
|
-
* JSON Schema
|
|
27
|
+
* Primitive JSON Schema `type` keyword values.
|
|
28
|
+
*
|
|
29
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-7.6.1
|
|
15
30
|
*/
|
|
16
|
-
type JsonSchemaPrimitiveType =
|
|
17
|
-
type StrictNullChecksWrapper<Name extends string, Type> = undefined extends null ? `strictNullChecks must be true in tsconfig to use ${Name}` : Type;
|
|
18
|
-
type UnionToIntersection<U> = (U extends any ? (_: U) => void : never) extends ((_: infer I) => void) ? I : never;
|
|
31
|
+
type JsonSchemaPrimitiveType = (typeof JSON_SCHEMA_PRIMITIVE_TYPES)[number];
|
|
19
32
|
/**
|
|
20
|
-
*
|
|
33
|
+
* JSON Schema type names for the `type` keyword.
|
|
34
|
+
*
|
|
35
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-7.6.1
|
|
21
36
|
*/
|
|
22
|
-
type
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
/** The inclusive upper bound allowed for numeric values. */
|
|
30
|
-
maximum?: number;
|
|
31
|
-
/** The exclusive lower bound allowed for numeric values. */
|
|
32
|
-
exclusiveMinimum?: number;
|
|
33
|
-
/** The exclusive upper bound allowed for numeric values. */
|
|
34
|
-
exclusiveMaximum?: number;
|
|
35
|
-
/** The numeric increment that values must be a multiple of. */
|
|
36
|
-
multipleOf?: number;
|
|
37
|
-
/** The numeric format hint recognized by compatible validators. */
|
|
38
|
-
format?: NumberFormat | string;
|
|
39
|
-
}
|
|
40
|
-
interface StringKeywords {
|
|
41
|
-
/** The minimum number of characters allowed in the string. */
|
|
42
|
-
minLength?: number;
|
|
43
|
-
/** The maximum number of characters allowed in the string. */
|
|
44
|
-
maxLength?: number;
|
|
45
|
-
/** A regular expression that matching strings must satisfy. */
|
|
46
|
-
pattern?: string;
|
|
37
|
+
type JsonSchemaType = (typeof JSON_SCHEMA_TYPES)[number];
|
|
38
|
+
/**
|
|
39
|
+
* Metadata and annotation keywords shared across JSON Schema shapes.
|
|
40
|
+
*
|
|
41
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-8
|
|
42
|
+
*/
|
|
43
|
+
interface JsonSchemaMetadataKeywords {
|
|
47
44
|
/**
|
|
48
|
-
* A
|
|
49
|
-
*
|
|
50
|
-
* @see https://ajv.js.org/packages/ajv-formats.html
|
|
45
|
+
* 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.
|
|
51
46
|
*
|
|
52
|
-
* @
|
|
53
|
-
*
|
|
54
|
-
*/
|
|
55
|
-
format?: FormatName | string;
|
|
56
|
-
}
|
|
57
|
-
type Known = {
|
|
58
|
-
[key: string]: Known;
|
|
59
|
-
} | [Known, ...Known[]] | Known[] | number | string | boolean | null;
|
|
60
|
-
type UncheckedPropertiesSchema<T> = { [K in keyof T]-?: (UncheckedJsonSchemaType<T[K], false> & JsonSchemaNullable<T[K]>) | {
|
|
61
|
-
$ref: string;
|
|
62
|
-
} };
|
|
63
|
-
type UncheckedRequiredMembers<T> = { [K in keyof T]-?: undefined extends T[K] ? never : K }[keyof T];
|
|
64
|
-
type JsonSchemaNullable<T> = undefined extends T ? {
|
|
65
|
-
/** Indicates that the value may be null in addition to the declared type. */nullable: true; /** A constant value constrained to null when the schema is nullable. */
|
|
66
|
-
const?: null; /** Allowed values, including null when the schema is nullable. */
|
|
67
|
-
enum?: readonly (T | null)[]; /** The default value to use when none is provided. */
|
|
68
|
-
default?: T | null;
|
|
69
|
-
} : {
|
|
70
|
-
/** Indicates whether the value may be null. */nullable?: false; /** A constant value allowed by the schema. */
|
|
71
|
-
const?: T; /** The set of values allowed by the schema. */
|
|
72
|
-
enum?: readonly T[]; /** The default value to use when none is provided. */
|
|
73
|
-
default?: T;
|
|
74
|
-
};
|
|
75
|
-
type UncheckedJsonSchemaType<T, IsPartial extends boolean> = ({
|
|
76
|
-
anyOf: readonly UncheckedJsonSchemaType<T, IsPartial>[];
|
|
77
|
-
} | {
|
|
78
|
-
oneOf: readonly UncheckedJsonSchemaType<T, IsPartial>[];
|
|
79
|
-
} | ({
|
|
80
|
-
type: readonly (T extends number ? JsonType<"number" | "integer", IsPartial> : T extends string ? JsonType<"string", IsPartial> : T extends boolean ? JsonType<"boolean", IsPartial> : never)[];
|
|
81
|
-
} & UnionToIntersection<T extends number ? NumberKeywords : T extends string ? StringKeywords : T extends boolean ? {} : never>) | ((T extends number ? {
|
|
82
|
-
type: JsonType<"number" | "integer", IsPartial>;
|
|
83
|
-
} & NumberKeywords : T extends string ? {
|
|
84
|
-
type: JsonType<"string", IsPartial>;
|
|
85
|
-
} & StringKeywords : T extends boolean ? {
|
|
86
|
-
type: JsonType<"boolean", IsPartial>;
|
|
87
|
-
} : T extends readonly [any, ...any[]] ? {
|
|
88
|
-
type: JsonType<"array", IsPartial>; /** The tuple items in order. */
|
|
89
|
-
items: { readonly [K in keyof T]-?: UncheckedJsonSchemaType<T[K], false> & JsonSchemaNullable<T[K]> } & {
|
|
90
|
-
length: T["length"];
|
|
91
|
-
}; /** The minimum number of items allowed in the tuple. */
|
|
92
|
-
minItems: T["length"];
|
|
93
|
-
} & ({
|
|
94
|
-
/** The maximum number of items allowed in the tuple. */maxItems: T["length"];
|
|
95
|
-
} | {
|
|
96
|
-
/** Disallows items beyond the tuple length. */additionalItems: false;
|
|
97
|
-
}) : T extends readonly any[] ? {
|
|
98
|
-
type: JsonType<"array", IsPartial>; /** The schema that each array item must satisfy. */
|
|
99
|
-
items: UncheckedJsonSchemaType<T[0], false>; /** A schema that at least one array item must satisfy. */
|
|
100
|
-
contains?: UncheckedPartialSchema<T[0]>; /** The minimum number of items allowed in the array. */
|
|
101
|
-
minItems?: number; /** The maximum number of items allowed in the array. */
|
|
102
|
-
maxItems?: number; /** The minimum number of matching items required by {@link contains}. */
|
|
103
|
-
minContains?: number; /** The maximum number of matching items allowed by {@link contains}. */
|
|
104
|
-
maxContains?: number; /** Indicates that array items must be unique. */
|
|
105
|
-
uniqueItems?: true; /** Additional tuple items are not permitted in this schema shape. */
|
|
106
|
-
additionalItems?: never;
|
|
107
|
-
} : T extends Record<string, any> ? {
|
|
108
|
-
type: JsonType<"object", IsPartial>; /** The schema for properties not matched by {@link properties} or {@link patternProperties}. */
|
|
109
|
-
additionalProperties?: boolean | UncheckedJsonSchemaType<T[string], false>; /** The schema for properties not yet evaluated by other object keywords. */
|
|
110
|
-
unevaluatedProperties?: boolean | UncheckedJsonSchemaType<T[string], false>; /** The declared object properties and their schemas. */
|
|
111
|
-
properties?: IsPartial extends true ? Partial<UncheckedPropertiesSchema<T>> : UncheckedPropertiesSchema<T>; /** The schemas for properties whose names match the given patterns. */
|
|
112
|
-
patternProperties?: Record<string, UncheckedJsonSchemaType<T[string], false>>; /** The schema that each property name must satisfy. */
|
|
113
|
-
propertyNames?: Omit<UncheckedJsonSchemaType<string, false>, "type"> & {
|
|
114
|
-
type?: "string";
|
|
115
|
-
}; /** A map of property-specific dependency requirements. */
|
|
116
|
-
dependencies?: { [K in keyof T]?: readonly (keyof T)[] | UncheckedPartialSchema<T> }; /** Properties that become required when the key property is present. */
|
|
117
|
-
dependentRequired?: { [K in keyof T]?: readonly (keyof T)[] }; /** Subschemas that apply when the key property is present. */
|
|
118
|
-
dependentSchemas?: { [K in keyof T]?: UncheckedPartialSchema<T> }; /** The minimum number of own properties allowed. */
|
|
119
|
-
minProperties?: number; /** The maximum number of own properties allowed. */
|
|
120
|
-
maxProperties?: number;
|
|
121
|
-
/**
|
|
122
|
-
* 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.
|
|
47
|
+
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.1
|
|
48
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-8.2.1
|
|
123
49
|
*/
|
|
124
|
-
|
|
50
|
+
$id?: string;
|
|
125
51
|
/**
|
|
126
|
-
* A
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
/** The set of required property names for partial schemas. */required: readonly (keyof T)[];
|
|
131
|
-
} : [UncheckedRequiredMembers<T>] extends [never] ? {
|
|
132
|
-
/** The set of required property names when none are statically required. */required?: readonly UncheckedRequiredMembers<T>[];
|
|
133
|
-
} : {
|
|
134
|
-
/** The set of required property names for the object. */required: readonly UncheckedRequiredMembers<T>[];
|
|
135
|
-
}) : T extends null ? {
|
|
136
|
-
/** The JSON Schema null type. */type: JsonType<"null", IsPartial>; /** Indicates that only null is allowed. */
|
|
137
|
-
nullable: true;
|
|
138
|
-
} : never) & {
|
|
139
|
-
/** A set of schemas where the data must satisfy all members. */allOf?: readonly UncheckedPartialSchema<T>[]; /** A set of schemas where the data must satisfy at least one member. */
|
|
140
|
-
anyOf?: readonly UncheckedPartialSchema<T>[]; /** A set of schemas where the data must satisfy exactly one member. */
|
|
141
|
-
oneOf?: readonly UncheckedPartialSchema<T>[]; /** A schema that the data must not satisfy. */
|
|
142
|
-
if?: UncheckedPartialSchema<T>; /** A schema applied when {@link if} matches. */
|
|
143
|
-
then?: UncheckedPartialSchema<T>; /** A schema applied when {@link if} does not match. */
|
|
144
|
-
else?: UncheckedPartialSchema<T>; /** A schema that must not match the data. */
|
|
145
|
-
not?: UncheckedPartialSchema<T>;
|
|
146
|
-
})) & {
|
|
147
|
-
/**
|
|
148
|
-
* A unique identifier for the schema, which can be used to reference or identify the schema in various contexts. This property is part of the JSON Schema specification and 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.
|
|
52
|
+
* 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.
|
|
53
|
+
*
|
|
54
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-8.1.1
|
|
55
|
+
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.2
|
|
149
56
|
*/
|
|
150
|
-
$
|
|
57
|
+
$schema?: string;
|
|
151
58
|
/**
|
|
152
|
-
* A
|
|
59
|
+
* A keyword that is used in meta-schemas to identify the vocabularies available for use in schemas described by that meta-schema.
|
|
60
|
+
*
|
|
61
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-8.1.2
|
|
62
|
+
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.2
|
|
153
63
|
*/
|
|
154
|
-
$
|
|
64
|
+
$vocabulary?: Record<string, boolean>;
|
|
155
65
|
/**
|
|
156
|
-
* A comment or annotation for the schema, which can be used to provide additional context or information about the schema.
|
|
66
|
+
* 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.
|
|
67
|
+
*
|
|
68
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-8.3
|
|
69
|
+
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.3
|
|
157
70
|
*/
|
|
158
71
|
$comment?: string;
|
|
159
72
|
/**
|
|
160
|
-
* A
|
|
73
|
+
* A plain-name fragment identifier for the schema resource.
|
|
74
|
+
*
|
|
75
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-8.2.2
|
|
161
76
|
*/
|
|
162
|
-
$
|
|
77
|
+
$anchor?: string;
|
|
163
78
|
/**
|
|
164
|
-
*
|
|
79
|
+
* 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.
|
|
80
|
+
*
|
|
81
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-8.2.4
|
|
82
|
+
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.4
|
|
83
|
+
* @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00#section-8.2.4
|
|
84
|
+
* @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#appendix-A
|
|
165
85
|
*/
|
|
166
|
-
|
|
86
|
+
$defs?: Record<string, JsonSchema>;
|
|
167
87
|
/**
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
* @remarks
|
|
171
|
-
* This property is a legacy version of {@link UncheckedJsonSchemaType.$id} and is maintained for backward compatibility with earlier versions of the JSON Schema specification. The presence of this property does not affect the validation behavior of the schema itself, but it can be used to reference or identify the schema in various contexts when used in conjunction with compatible tools.
|
|
88
|
+
* 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.
|
|
172
89
|
*
|
|
173
|
-
* @
|
|
90
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-8.2.3.2
|
|
91
|
+
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.6
|
|
92
|
+
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.7
|
|
174
93
|
*/
|
|
175
|
-
|
|
94
|
+
$dynamicRef?: string;
|
|
176
95
|
/**
|
|
177
|
-
*
|
|
96
|
+
* 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.
|
|
178
97
|
*
|
|
179
|
-
* @
|
|
98
|
+
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.6
|
|
99
|
+
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.7
|
|
180
100
|
*/
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
101
|
+
$dynamicAnchor?: string;
|
|
102
|
+
/**
|
|
103
|
+
* 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.
|
|
104
|
+
*/
|
|
105
|
+
name?: string;
|
|
185
106
|
/**
|
|
186
107
|
* 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.
|
|
187
108
|
*/
|
|
@@ -209,7 +130,11 @@ interface SchemaMetadata {
|
|
|
209
130
|
/**
|
|
210
131
|
* 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.
|
|
211
132
|
*/
|
|
212
|
-
deprecated?: boolean
|
|
133
|
+
deprecated?: boolean | string | {
|
|
134
|
+
message?: string;
|
|
135
|
+
since?: string;
|
|
136
|
+
alternative?: string;
|
|
137
|
+
};
|
|
213
138
|
/**
|
|
214
139
|
* 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.
|
|
215
140
|
*/
|
|
@@ -236,103 +161,903 @@ interface SchemaMetadata {
|
|
|
236
161
|
* 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.
|
|
237
162
|
*/
|
|
238
163
|
writeOnly?: boolean;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* 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.
|
|
167
|
+
*
|
|
168
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.2.1
|
|
169
|
+
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.5
|
|
170
|
+
*/
|
|
171
|
+
interface JsonSchemaLogicKeywords {
|
|
172
|
+
/**
|
|
173
|
+
* A set of schemas where the data must satisfy all members.
|
|
174
|
+
*
|
|
175
|
+
* @remarks
|
|
176
|
+
* An instance validates successfully against this keyword if it validates successfully against all schemas defined by this keyword's value.
|
|
177
|
+
*
|
|
178
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.2.1.1
|
|
179
|
+
*/
|
|
180
|
+
allOf?: JsonSchema[];
|
|
181
|
+
/**
|
|
182
|
+
* A set of schemas where the data must satisfy at least one member.
|
|
183
|
+
*
|
|
184
|
+
* @remarks
|
|
185
|
+
* 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.
|
|
186
|
+
*
|
|
187
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.2.1.2
|
|
188
|
+
*/
|
|
189
|
+
anyOf?: JsonSchema[];
|
|
190
|
+
/**
|
|
191
|
+
* A set of schemas where the data must satisfy exactly one member.
|
|
192
|
+
*
|
|
193
|
+
* @remarks
|
|
194
|
+
* An instance validates successfully against this keyword if it validates successfully against exactly one schema defined by this keyword's value.
|
|
195
|
+
*
|
|
196
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.2.1.3
|
|
197
|
+
*/
|
|
198
|
+
oneOf?: JsonSchema[];
|
|
199
|
+
/**
|
|
200
|
+
* A schema that must not match the data.
|
|
201
|
+
*
|
|
202
|
+
* @remarks
|
|
203
|
+
* An instance is valid against this keyword if it fails to validate successfully against the schema defined by this keyword
|
|
204
|
+
*
|
|
205
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.2.1.4
|
|
206
|
+
*/
|
|
207
|
+
not?: JsonSchema;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* 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.
|
|
211
|
+
*
|
|
212
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.2.2
|
|
213
|
+
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.5
|
|
214
|
+
*/
|
|
215
|
+
interface JsonSchemaConditionalKeywords {
|
|
216
|
+
/**
|
|
217
|
+
* A schema that the data must not satisfy.
|
|
218
|
+
*
|
|
219
|
+
* @remarks
|
|
220
|
+
* 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.
|
|
221
|
+
*
|
|
222
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.2.2.1
|
|
223
|
+
*/
|
|
224
|
+
if?: JsonSchema;
|
|
225
|
+
/**
|
|
226
|
+
* A schema applied when {@link if} matches.
|
|
227
|
+
*
|
|
228
|
+
* @remarks
|
|
229
|
+
* 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.
|
|
230
|
+
*
|
|
231
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.2.2.2
|
|
232
|
+
*/
|
|
233
|
+
then?: JsonSchema;
|
|
234
|
+
/**
|
|
235
|
+
* A schema applied when {@link if} does not match.
|
|
236
|
+
*
|
|
237
|
+
* @remarks
|
|
238
|
+
* 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.
|
|
239
|
+
*
|
|
240
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.2.2.3
|
|
241
|
+
*/
|
|
242
|
+
else?: JsonSchema;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Shared JSON Schema keyword groups applied to most schema variants.
|
|
246
|
+
*/
|
|
247
|
+
type JsonSchemaKeywords = JsonSchemaMetadataKeywords & JsonSchemaLogicKeywords & JsonSchemaConditionalKeywords;
|
|
248
|
+
/**
|
|
249
|
+
* A schema that can point to another schema via `$ref`.
|
|
250
|
+
*/
|
|
251
|
+
interface JsonSchemaAny extends JsonSchemaKeywords {
|
|
252
|
+
/**
|
|
253
|
+
* A URI reference to another schema.
|
|
254
|
+
*
|
|
255
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-8.2.3.1
|
|
256
|
+
*/
|
|
257
|
+
$ref?: string;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* JSON Schema keywords for array validation.
|
|
261
|
+
*
|
|
262
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.3.1
|
|
263
|
+
*/
|
|
264
|
+
interface JsonSchemaArray extends JsonSchemaKeywords {
|
|
265
|
+
/**
|
|
266
|
+
* Declares that the instance must be an array.
|
|
267
|
+
*/
|
|
268
|
+
type: "array";
|
|
269
|
+
/**
|
|
270
|
+
* Schemas for positional items at each tuple index.
|
|
271
|
+
*
|
|
272
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.3.1.1
|
|
273
|
+
*/
|
|
274
|
+
prefixItems?: JsonSchema[];
|
|
239
275
|
/**
|
|
240
|
-
*
|
|
276
|
+
* Schema for array items beyond `prefixItems`, or all items when `prefixItems` is omitted.
|
|
277
|
+
*
|
|
278
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.3.1.2
|
|
279
|
+
*/
|
|
280
|
+
items?: JsonSchema;
|
|
281
|
+
/**
|
|
282
|
+
* A subschema that at least one array item must satisfy.
|
|
283
|
+
*
|
|
284
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.3.1.3
|
|
285
|
+
*/
|
|
286
|
+
contains?: JsonSchema;
|
|
287
|
+
/**
|
|
288
|
+
* Minimum number of items allowed.
|
|
289
|
+
*/
|
|
290
|
+
minItems?: number;
|
|
291
|
+
/**
|
|
292
|
+
* Maximum number of items allowed.
|
|
293
|
+
*/
|
|
294
|
+
maxItems?: number;
|
|
295
|
+
/**
|
|
296
|
+
* Whether all items must be unique.
|
|
297
|
+
*/
|
|
298
|
+
uniqueItems?: boolean;
|
|
299
|
+
/**
|
|
300
|
+
* Minimum count of items that must satisfy `contains`.
|
|
301
|
+
*/
|
|
302
|
+
minContains?: number;
|
|
303
|
+
/**
|
|
304
|
+
* Maximum count of items that may satisfy `contains`.
|
|
305
|
+
*/
|
|
306
|
+
maxContains?: number;
|
|
307
|
+
/**
|
|
308
|
+
* Controls validation of array items not covered by prior applicators.
|
|
309
|
+
*
|
|
310
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-11.2
|
|
311
|
+
*/
|
|
312
|
+
unevaluatedItems?: boolean | JsonSchema;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Integer schema specialized for 64-bit integer semantics.
|
|
316
|
+
*/
|
|
317
|
+
interface JsonSchemaBigint extends JsonSchemaKeywords {
|
|
318
|
+
/**
|
|
319
|
+
* Declares that the instance must be an integer.
|
|
320
|
+
*/
|
|
321
|
+
type: "integer";
|
|
322
|
+
/**
|
|
323
|
+
* Identifies an `int64` integer representation.
|
|
324
|
+
*/
|
|
325
|
+
format: "int64";
|
|
326
|
+
/**
|
|
327
|
+
* Inclusive lower bound for valid values.
|
|
328
|
+
*/
|
|
329
|
+
minimum?: bigint;
|
|
330
|
+
/**
|
|
331
|
+
* Exclusive lower bound for valid values.
|
|
332
|
+
*/
|
|
333
|
+
exclusiveMinimum?: bigint;
|
|
334
|
+
/**
|
|
335
|
+
* Inclusive upper bound for valid values.
|
|
336
|
+
*/
|
|
337
|
+
maximum?: bigint;
|
|
338
|
+
/**
|
|
339
|
+
* Exclusive upper bound for valid values.
|
|
340
|
+
*/
|
|
341
|
+
exclusiveMaximum?: bigint;
|
|
342
|
+
/**
|
|
343
|
+
* Constraint requiring values to be divisible by this number.
|
|
344
|
+
*/
|
|
345
|
+
multipleOf?: bigint;
|
|
346
|
+
/**
|
|
347
|
+
* 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.
|
|
348
|
+
*
|
|
349
|
+
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-10.2
|
|
350
|
+
*/
|
|
351
|
+
default?: bigint;
|
|
352
|
+
/**
|
|
353
|
+
* Fixed set of allowed integer values.
|
|
354
|
+
*/
|
|
355
|
+
enum?: bigint[];
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Boolean schema keywords.
|
|
359
|
+
*/
|
|
360
|
+
interface JsonSchemaBoolean extends JsonSchemaKeywords {
|
|
361
|
+
/**
|
|
362
|
+
* Declares that the instance must be a boolean.
|
|
363
|
+
*/
|
|
364
|
+
type: "boolean";
|
|
365
|
+
/**
|
|
366
|
+
* 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.
|
|
367
|
+
*
|
|
368
|
+
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-10.2
|
|
369
|
+
*/
|
|
370
|
+
default?: boolean;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Date and time schema variants.
|
|
374
|
+
*
|
|
375
|
+
* @remarks
|
|
376
|
+
* This type supports either direct date/time format constraints or recursive unions through `anyOf`.
|
|
377
|
+
*
|
|
378
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-validation#section-7
|
|
379
|
+
*/
|
|
380
|
+
type JsonSchemaDate = JsonSchemaKeywords & ({
|
|
381
|
+
/**
|
|
382
|
+
* Declares the storage type used for temporal values.
|
|
383
|
+
*/
|
|
384
|
+
type: "integer" | "string";
|
|
385
|
+
/**
|
|
386
|
+
* A date/time format name used for semantic validation.
|
|
387
|
+
*/
|
|
388
|
+
format: "date" | "time" | "date-time" | "iso-time" | "iso-date-time" | "unix-time";
|
|
389
|
+
/**
|
|
390
|
+
* Inclusive lower bound for numeric time representations.
|
|
391
|
+
*/
|
|
392
|
+
minimum?: number;
|
|
393
|
+
/**
|
|
394
|
+
* Inclusive upper bound for numeric time representations.
|
|
395
|
+
*/
|
|
396
|
+
maximum?: number;
|
|
397
|
+
/**
|
|
398
|
+
* 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.
|
|
399
|
+
*
|
|
400
|
+
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-10.2
|
|
401
|
+
*/
|
|
402
|
+
default?: string | number;
|
|
403
|
+
} | {
|
|
404
|
+
/**
|
|
405
|
+
* Alternative date/time schemas where at least one must match.
|
|
406
|
+
*/
|
|
407
|
+
anyOf: JsonSchemaDate[];
|
|
408
|
+
});
|
|
409
|
+
/**
|
|
410
|
+
* Enum-constrained schema.
|
|
411
|
+
*
|
|
412
|
+
* @template T - The literal type allowed by the enum values.
|
|
413
|
+
*/
|
|
414
|
+
interface JsonSchemaEnum<T extends string | number | bigint | boolean | null = string | number | bigint | boolean | null> extends JsonSchemaKeywords {
|
|
415
|
+
/**
|
|
416
|
+
* Primitive type of the enum values.
|
|
417
|
+
*/
|
|
418
|
+
type: JsonSchemaPrimitiveType;
|
|
419
|
+
/**
|
|
420
|
+
* The complete set of allowed literal values.
|
|
421
|
+
*/
|
|
422
|
+
enum: T[];
|
|
423
|
+
/**
|
|
424
|
+
* 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.
|
|
425
|
+
*
|
|
426
|
+
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-10.2
|
|
427
|
+
*/
|
|
428
|
+
default?: T;
|
|
429
|
+
}
|
|
430
|
+
interface JsonSchemaAllOf extends JsonSchemaKeywords {
|
|
431
|
+
/**
|
|
432
|
+
* Subschemas that must all validate successfully.
|
|
433
|
+
*/
|
|
434
|
+
allOf: JsonSchema[];
|
|
435
|
+
/**
|
|
436
|
+
* Controls validation for object properties not evaluated by prior keywords.
|
|
437
|
+
*/
|
|
438
|
+
unevaluatedProperties?: boolean | JsonSchema;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* A schema that matches exactly one literal value.
|
|
442
|
+
*/
|
|
443
|
+
interface JsonSchemaLiteral extends JsonSchemaKeywords {
|
|
444
|
+
/**
|
|
445
|
+
* Constant value that an instance must equal.
|
|
446
|
+
*/
|
|
447
|
+
const: unknown;
|
|
448
|
+
/**
|
|
449
|
+
* Optional explicit type constraint for the constant.
|
|
450
|
+
*/
|
|
451
|
+
type?: JsonSchemaType | JsonSchemaType[];
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Array representation for map-like entries as `[key, value]` tuples.
|
|
455
|
+
*/
|
|
456
|
+
interface JsonSchemaMap extends JsonSchemaKeywords {
|
|
457
|
+
/**
|
|
458
|
+
* Declares that the map is represented as an array.
|
|
459
|
+
*/
|
|
460
|
+
type: "array";
|
|
461
|
+
/**
|
|
462
|
+
* Maximum number of entries allowed.
|
|
463
|
+
*/
|
|
464
|
+
maxItems: 125;
|
|
465
|
+
/**
|
|
466
|
+
* Tuple schema describing each map entry as `[key, value]`.
|
|
467
|
+
*/
|
|
468
|
+
items: {
|
|
469
|
+
/**
|
|
470
|
+
* Declares that each entry is an array tuple.
|
|
471
|
+
*/
|
|
472
|
+
type: "array";
|
|
473
|
+
/**
|
|
474
|
+
* Two-position tuple schemas for key and value.
|
|
475
|
+
*/
|
|
476
|
+
prefixItems: [JsonSchema, JsonSchema];
|
|
477
|
+
/**
|
|
478
|
+
* Disallows additional tuple positions.
|
|
479
|
+
*/
|
|
480
|
+
items?: false;
|
|
481
|
+
/**
|
|
482
|
+
* Minimum tuple length.
|
|
483
|
+
*/
|
|
484
|
+
minItems: 2;
|
|
485
|
+
/**
|
|
486
|
+
* Maximum tuple length.
|
|
487
|
+
*/
|
|
488
|
+
maxItems: 2;
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Enum schema that allows both string and numeric enum members.
|
|
493
|
+
*/
|
|
494
|
+
interface JsonSchemaNativeEnum extends JsonSchemaKeywords {
|
|
495
|
+
/**
|
|
496
|
+
* Type domain allowed by the native enum.
|
|
497
|
+
*/
|
|
498
|
+
type: "string" | "number" | ["string", "number"];
|
|
499
|
+
/**
|
|
500
|
+
* Allowed enum member values.
|
|
501
|
+
*/
|
|
502
|
+
enum: (string | number)[];
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* A schema that intentionally matches no values.
|
|
506
|
+
*/
|
|
507
|
+
interface JsonSchemaNever extends JsonSchemaKeywords {
|
|
508
|
+
/**
|
|
509
|
+
* Negated schema used to make validation impossible.
|
|
510
|
+
*/
|
|
511
|
+
not: JsonSchemaAny;
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Schema representing the JSON `null` literal type.
|
|
515
|
+
*/
|
|
516
|
+
interface JsonSchemaNull extends JsonSchemaKeywords {
|
|
517
|
+
/**
|
|
518
|
+
* 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.
|
|
519
|
+
*/
|
|
520
|
+
type: "null";
|
|
521
|
+
/**
|
|
522
|
+
* A constant value constrained to null when the schema is nullable.
|
|
523
|
+
*/
|
|
524
|
+
const?: null;
|
|
525
|
+
/**
|
|
526
|
+
* Allowed values, including null when the schema is nullable.
|
|
527
|
+
*/
|
|
528
|
+
enum?: null[];
|
|
529
|
+
/**
|
|
530
|
+
* 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.
|
|
531
|
+
*
|
|
532
|
+
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-10.2
|
|
533
|
+
*/
|
|
534
|
+
default?: null;
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Nullable schema variants that include an explicit `null` branch.
|
|
538
|
+
*/
|
|
539
|
+
type JsonSchemaNullable = JsonSchemaKeywords & ({
|
|
540
|
+
/**
|
|
541
|
+
* Two-branch union that includes a non-null schema and explicit `null` schema.
|
|
542
|
+
*/
|
|
543
|
+
anyOf: [JsonSchema, JsonSchemaNull];
|
|
544
|
+
} | {
|
|
545
|
+
/**
|
|
546
|
+
* Primitive `type` tuple that explicitly includes `null`.
|
|
547
|
+
*/
|
|
548
|
+
type: [Exclude<JsonSchemaType, "null">, "null"] | ["null", Exclude<JsonSchemaType, "null">];
|
|
549
|
+
});
|
|
550
|
+
/**
|
|
551
|
+
* Numeric schema keywords for numbers and integers.
|
|
552
|
+
*
|
|
553
|
+
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-6.2
|
|
554
|
+
*/
|
|
555
|
+
interface JsonSchemaNumber extends JsonSchemaKeywords {
|
|
556
|
+
/**
|
|
557
|
+
* Declares whether values are numbers or integers.
|
|
558
|
+
*/
|
|
559
|
+
type: "number" | "integer";
|
|
560
|
+
/**
|
|
561
|
+
* Optional semantic format for numeric values.
|
|
562
|
+
*/
|
|
563
|
+
format?: "int32" | "float" | "double" | "int8" | "uint8" | "int16" | "uint16" | "uint64" | string;
|
|
564
|
+
/**
|
|
565
|
+
* Inclusive lower bound for numeric values.
|
|
566
|
+
*/
|
|
567
|
+
minimum?: number;
|
|
568
|
+
/**
|
|
569
|
+
* Exclusive lower bound for numeric values.
|
|
570
|
+
*/
|
|
571
|
+
exclusiveMinimum?: number;
|
|
572
|
+
/**
|
|
573
|
+
* Inclusive upper bound for numeric values.
|
|
574
|
+
*/
|
|
575
|
+
maximum?: number;
|
|
576
|
+
/**
|
|
577
|
+
* Exclusive upper bound for numeric values.
|
|
578
|
+
*/
|
|
579
|
+
exclusiveMaximum?: number;
|
|
580
|
+
/**
|
|
581
|
+
* Constraint requiring values to be divisible by this value.
|
|
582
|
+
*/
|
|
583
|
+
multipleOf?: number;
|
|
584
|
+
/**
|
|
585
|
+
* 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.
|
|
586
|
+
*
|
|
587
|
+
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-10.2
|
|
588
|
+
*/
|
|
589
|
+
default?: number;
|
|
590
|
+
/**
|
|
591
|
+
* Fixed set of allowed numeric values.
|
|
592
|
+
*/
|
|
593
|
+
enum?: number[];
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Integer-only numeric schema.
|
|
597
|
+
*/
|
|
598
|
+
interface JsonSchemaInteger extends JsonSchemaNumber {
|
|
599
|
+
/**
|
|
600
|
+
* Declares that values must be integers.
|
|
601
|
+
*/
|
|
602
|
+
type: "integer";
|
|
603
|
+
/**
|
|
604
|
+
* Optional integer-specific format.
|
|
605
|
+
*/
|
|
606
|
+
format?: "int32" | "int8" | "uint8" | "int16" | "uint16" | "uint64" | string;
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
609
|
+
* Floating-point numeric schema.
|
|
610
|
+
*/
|
|
611
|
+
interface JsonSchemaDecimal extends JsonSchemaNumber {
|
|
612
|
+
/**
|
|
613
|
+
* Declares that values are non-integer numbers.
|
|
614
|
+
*/
|
|
615
|
+
type: "number";
|
|
616
|
+
/**
|
|
617
|
+
* Optional floating-point format.
|
|
618
|
+
*/
|
|
619
|
+
format?: "float" | "double" | string;
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* Object schema keywords.
|
|
623
|
+
*
|
|
624
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.3.2
|
|
625
|
+
*/
|
|
626
|
+
interface JsonSchemaObject extends JsonSchemaKeywords {
|
|
627
|
+
/**
|
|
628
|
+
* 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.
|
|
629
|
+
*/
|
|
630
|
+
type: "object";
|
|
631
|
+
/**
|
|
632
|
+
* 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.
|
|
633
|
+
*
|
|
634
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.3.2.1
|
|
635
|
+
*/
|
|
636
|
+
properties?: Record<string, JsonSchema>;
|
|
637
|
+
/**
|
|
638
|
+
* The schemas for properties whose names match the given patterns.
|
|
639
|
+
*
|
|
640
|
+
* @remarks
|
|
641
|
+
* 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.
|
|
642
|
+
*
|
|
643
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.3.2.2
|
|
644
|
+
*/
|
|
645
|
+
patternProperties?: Record<string, JsonSchema>;
|
|
646
|
+
/**
|
|
647
|
+
* 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.
|
|
648
|
+
*
|
|
649
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.3.2.3
|
|
650
|
+
*/
|
|
651
|
+
additionalProperties?: boolean | JsonSchema;
|
|
652
|
+
/**
|
|
653
|
+
* 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.
|
|
654
|
+
*/
|
|
655
|
+
required?: string[];
|
|
656
|
+
/**
|
|
657
|
+
* 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.
|
|
658
|
+
*
|
|
659
|
+
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-10.2
|
|
660
|
+
*/
|
|
661
|
+
default?: Record<string, unknown>;
|
|
662
|
+
/**
|
|
663
|
+
* 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.
|
|
664
|
+
*/
|
|
665
|
+
unevaluatedProperties?: boolean | JsonSchema;
|
|
666
|
+
/**
|
|
667
|
+
* A map of property-specific dependency requirements.
|
|
668
|
+
*/
|
|
669
|
+
dependencies?: Record<string, string[] | JsonSchema>;
|
|
670
|
+
/**
|
|
671
|
+
* Properties that become required when the key property is present.
|
|
672
|
+
*/
|
|
673
|
+
dependentRequired?: Record<string, string[]>;
|
|
674
|
+
/**
|
|
675
|
+
* Subschemas that apply when the key property is present.
|
|
676
|
+
*
|
|
677
|
+
* @remarks
|
|
678
|
+
* 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.
|
|
679
|
+
*
|
|
680
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.2.2.4
|
|
681
|
+
*/
|
|
682
|
+
dependentSchemas?: Record<string, JsonSchema>;
|
|
683
|
+
/**
|
|
684
|
+
* The minimum number of own properties allowed.
|
|
685
|
+
*/
|
|
686
|
+
minProperties?: number;
|
|
687
|
+
/**
|
|
688
|
+
* The maximum number of own properties allowed.
|
|
689
|
+
*/
|
|
690
|
+
maxProperties?: number;
|
|
691
|
+
/**
|
|
692
|
+
* 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.
|
|
693
|
+
*/
|
|
694
|
+
primaryKey?: string[];
|
|
695
|
+
/**
|
|
696
|
+
* 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.
|
|
697
|
+
*/
|
|
698
|
+
databaseSchema?: string;
|
|
699
|
+
}
|
|
700
|
+
interface JsonSchemaString extends JsonSchemaKeywords {
|
|
701
|
+
/**
|
|
702
|
+
* Declares that the instance must be a string.
|
|
703
|
+
*/
|
|
704
|
+
type: "string";
|
|
705
|
+
/**
|
|
706
|
+
* The minimum number of characters allowed in the string.
|
|
707
|
+
*/
|
|
708
|
+
minLength?: number;
|
|
709
|
+
/**
|
|
710
|
+
* The maximum number of characters allowed in the string.
|
|
711
|
+
*/
|
|
712
|
+
maxLength?: number;
|
|
713
|
+
/**
|
|
714
|
+
* A regular expression that matching strings must satisfy.
|
|
715
|
+
*/
|
|
716
|
+
pattern?: string;
|
|
717
|
+
/**
|
|
718
|
+
* 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.
|
|
719
|
+
*
|
|
720
|
+
* @see https://ajv.js.org/packages/ajv-formats.html
|
|
721
|
+
*
|
|
722
|
+
* @remarks
|
|
723
|
+
* 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.
|
|
724
|
+
*/
|
|
725
|
+
format?: "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" | "int32" | "int64" | "float" | "double" | "password" | "binary" | string;
|
|
726
|
+
/**
|
|
727
|
+
* 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.
|
|
728
|
+
*
|
|
729
|
+
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-10.2
|
|
730
|
+
*/
|
|
731
|
+
default?: string;
|
|
732
|
+
/**
|
|
733
|
+
* Fixed set of allowed string values.
|
|
734
|
+
*/
|
|
735
|
+
enum?: string[];
|
|
736
|
+
/**
|
|
737
|
+
* 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.
|
|
738
|
+
*
|
|
739
|
+
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.8
|
|
241
740
|
*/
|
|
242
741
|
contentMediaType?: string;
|
|
243
742
|
/**
|
|
244
|
-
*
|
|
743
|
+
* 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.
|
|
744
|
+
*
|
|
745
|
+
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.8
|
|
245
746
|
*/
|
|
246
747
|
contentEncoding?: string;
|
|
247
748
|
/**
|
|
248
|
-
*
|
|
749
|
+
* 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.
|
|
750
|
+
*
|
|
751
|
+
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-8.2.9
|
|
249
752
|
*/
|
|
250
753
|
contentSchema?: string;
|
|
251
754
|
}
|
|
252
|
-
|
|
253
|
-
|
|
755
|
+
/**
|
|
756
|
+
* Set-like array schema that enforces item uniqueness.
|
|
757
|
+
*/
|
|
758
|
+
interface JsonSchemaSet extends JsonSchemaKeywords {
|
|
759
|
+
/**
|
|
760
|
+
* Declares that set values are serialized as arrays.
|
|
761
|
+
*/
|
|
762
|
+
type: "array";
|
|
763
|
+
/**
|
|
764
|
+
* Enforces set semantics by requiring distinct elements.
|
|
765
|
+
*/
|
|
766
|
+
uniqueItems: true;
|
|
767
|
+
/**
|
|
768
|
+
* Schemas for positional items at each tuple index.
|
|
769
|
+
*/
|
|
770
|
+
prefixItems?: JsonSchema[];
|
|
771
|
+
/**
|
|
772
|
+
* Schema for remaining items.
|
|
773
|
+
*/
|
|
774
|
+
items?: JsonSchema;
|
|
775
|
+
/**
|
|
776
|
+
* Subschema that at least one item must satisfy.
|
|
777
|
+
*/
|
|
778
|
+
contains?: JsonSchema;
|
|
779
|
+
/**
|
|
780
|
+
* Minimum number of items allowed.
|
|
781
|
+
*/
|
|
782
|
+
minItems?: number;
|
|
783
|
+
/**
|
|
784
|
+
* Maximum number of items allowed.
|
|
785
|
+
*/
|
|
786
|
+
maxItems?: number;
|
|
787
|
+
/**
|
|
788
|
+
* Minimum number of items that must satisfy {@link JsonSchemaSet.contains | contains}.
|
|
789
|
+
*/
|
|
790
|
+
minContains?: number;
|
|
791
|
+
/**
|
|
792
|
+
* Maximum number of items that may satisfy {@link JsonSchemaSet.contains | contains}.
|
|
793
|
+
*/
|
|
794
|
+
maxContains?: number;
|
|
795
|
+
/**
|
|
796
|
+
* Controls validation for items not otherwise evaluated.
|
|
797
|
+
*/
|
|
798
|
+
unevaluatedItems?: boolean | JsonSchema;
|
|
799
|
+
}
|
|
800
|
+
/**
|
|
801
|
+
* Schema used to validate record keys.
|
|
802
|
+
*/
|
|
803
|
+
type JsonSchemaRecordPropertyNames = JsonSchema;
|
|
804
|
+
/**
|
|
805
|
+
* Record/object schema with key constraints.
|
|
806
|
+
*/
|
|
807
|
+
interface JsonSchemaRecord extends JsonSchemaKeywords {
|
|
808
|
+
/**
|
|
809
|
+
* Declares that the instance must be an object.
|
|
810
|
+
*/
|
|
811
|
+
type: "object";
|
|
812
|
+
/**
|
|
813
|
+
* The schemas for properties whose names match the given patterns.
|
|
814
|
+
*
|
|
815
|
+
* @remarks
|
|
816
|
+
* 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.
|
|
817
|
+
*
|
|
818
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.3.2.2
|
|
819
|
+
*/
|
|
820
|
+
patternProperties?: Record<string, JsonSchema>;
|
|
821
|
+
/**
|
|
822
|
+
* 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.
|
|
823
|
+
*
|
|
824
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.3.2.3
|
|
825
|
+
*/
|
|
826
|
+
additionalProperties?: boolean | JsonSchema;
|
|
827
|
+
/**
|
|
828
|
+
* The schema that each property name must satisfy.
|
|
829
|
+
*/
|
|
830
|
+
propertyNames?: JsonSchemaRecordPropertyNames;
|
|
831
|
+
/**
|
|
832
|
+
* 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.
|
|
833
|
+
*
|
|
834
|
+
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-10.2
|
|
835
|
+
*/
|
|
836
|
+
default?: Record<string, unknown>;
|
|
837
|
+
}
|
|
838
|
+
/**
|
|
839
|
+
* Tuple schema modeled with positional {@link JsonSchemaTuple.prefixItems | prefixItems} plus optional trailing {@link JsonSchemaTuple.items | items}.
|
|
840
|
+
*/
|
|
841
|
+
type JsonSchemaTuple = JsonSchemaKeywords & {
|
|
842
|
+
/**
|
|
843
|
+
* Declares that tuple values are represented as arrays.
|
|
844
|
+
*/
|
|
845
|
+
type: "array";
|
|
846
|
+
/**
|
|
847
|
+
* Minimum number of elements required.
|
|
848
|
+
*/
|
|
849
|
+
minItems?: number;
|
|
850
|
+
/**
|
|
851
|
+
* Maximum number of elements allowed.
|
|
852
|
+
*/
|
|
853
|
+
maxItems?: number;
|
|
854
|
+
/**
|
|
855
|
+
* Positional schemas for tuple elements.
|
|
856
|
+
*/
|
|
857
|
+
prefixItems: JsonSchema[];
|
|
858
|
+
/**
|
|
859
|
+
* The schema applied to items beyond {@link prefixItems}. In draft 2020-12,
|
|
860
|
+
* tuple positions are modeled with {@link prefixItems}, while {@link items}
|
|
861
|
+
* applies to the remaining elements.
|
|
862
|
+
*
|
|
863
|
+
* @remarks
|
|
864
|
+
* 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.
|
|
865
|
+
*
|
|
866
|
+
* @see https://json-schema.org/draft/2020-12/json-schema-core#section-10.3.1.2
|
|
867
|
+
*/
|
|
868
|
+
items?: JsonSchema;
|
|
869
|
+
/**
|
|
870
|
+
* Subschema that at least one tuple element must satisfy.
|
|
871
|
+
*/
|
|
872
|
+
contains?: JsonSchema;
|
|
873
|
+
/**
|
|
874
|
+
* Whether tuple elements must be unique.
|
|
875
|
+
*/
|
|
876
|
+
uniqueItems?: boolean;
|
|
877
|
+
/**
|
|
878
|
+
* Minimum number of elements that must satisfy {@link JsonSchemaTuple.contains | contains}.
|
|
879
|
+
*/
|
|
880
|
+
minContains?: number;
|
|
881
|
+
/**
|
|
882
|
+
* Maximum number of elements that may satisfy {@link JsonSchemaTuple.contains | contains}.
|
|
883
|
+
*/
|
|
884
|
+
maxContains?: number;
|
|
254
885
|
/**
|
|
255
|
-
*
|
|
886
|
+
* Controls validation of unevaluated tuple elements.
|
|
256
887
|
*/
|
|
257
|
-
|
|
888
|
+
unevaluatedItems?: boolean | JsonSchema;
|
|
258
889
|
};
|
|
259
890
|
/**
|
|
260
|
-
*
|
|
891
|
+
* Schema used to represent undefined-like semantics through negation.
|
|
261
892
|
*/
|
|
262
|
-
|
|
893
|
+
interface JsonSchemaUndefined extends JsonSchemaKeywords {
|
|
894
|
+
/**
|
|
895
|
+
* Negated schema marker used to represent undefined-like semantics.
|
|
896
|
+
*/
|
|
897
|
+
not: JsonSchemaAny;
|
|
898
|
+
/**
|
|
899
|
+
* 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.
|
|
900
|
+
*
|
|
901
|
+
* @see https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-10.2
|
|
902
|
+
*/
|
|
903
|
+
default?: undefined;
|
|
904
|
+
}
|
|
263
905
|
/**
|
|
264
|
-
*
|
|
906
|
+
* Union schema represented as either primitive type unions or `anyOf` compositions.
|
|
907
|
+
*/
|
|
908
|
+
type JsonSchemaUnion = JsonSchemaKeywords & (JsonSchemaPrimitiveUnion | JsonSchemaAnyOf);
|
|
909
|
+
/**
|
|
910
|
+
* Union of primitive type combinations and enum-backed primitive unions.
|
|
911
|
+
*/
|
|
912
|
+
type JsonSchemaPrimitiveUnion = JsonSchemaKeywords & ({
|
|
913
|
+
/**
|
|
914
|
+
* Primitive `type` or list of primitive types accepted by the union.
|
|
915
|
+
*/
|
|
916
|
+
type: JsonSchemaPrimitiveType | JsonSchemaPrimitiveType[];
|
|
917
|
+
} | {
|
|
918
|
+
/**
|
|
919
|
+
* Enum values that may be of different primitive types.
|
|
920
|
+
*/
|
|
921
|
+
enum: (string | number | bigint | boolean | null)[];
|
|
922
|
+
});
|
|
923
|
+
/**
|
|
924
|
+
* Permissive schema alias for unknown values.
|
|
925
|
+
*/
|
|
926
|
+
type JsonSchemaUnknown = JsonSchemaKeywords & JsonSchemaAny;
|
|
927
|
+
/**
|
|
928
|
+
* `anyOf` composition schema.
|
|
929
|
+
*/
|
|
930
|
+
interface JsonSchemaAnyOf extends JsonSchemaKeywords {
|
|
931
|
+
/**
|
|
932
|
+
* Subschemas where at least one must validate.
|
|
933
|
+
*/
|
|
934
|
+
anyOf: JsonSchema[];
|
|
935
|
+
}
|
|
936
|
+
/**
|
|
937
|
+
* A reference schema that resolves through a URI.
|
|
938
|
+
*/
|
|
939
|
+
interface JsonSchemaRef extends JsonSchemaKeywords {
|
|
940
|
+
/**
|
|
941
|
+
* URI reference to a schema definition.
|
|
942
|
+
*/
|
|
943
|
+
$ref: string;
|
|
944
|
+
}
|
|
945
|
+
/**
|
|
946
|
+
* 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.
|
|
947
|
+
*
|
|
948
|
+
* @see https://json-schema.org/draft/2020-12
|
|
949
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
|
|
950
|
+
*/
|
|
951
|
+
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;
|
|
952
|
+
/**
|
|
953
|
+
* Supported source variants from which a schema can be extracted.
|
|
265
954
|
*/
|
|
266
|
-
type JsonSchemaObject<T extends Record<string, any> = Record<string, any>> = Omit<JsonSchemaLike, "type" | "properties" | "required"> & {
|
|
267
|
-
/** The JSON Schema object type discriminator. */type: "object"; /** The object properties mapped to their schema definitions. */
|
|
268
|
-
properties: Record<string, JsonSchemaProperty<T>>; /** The property names that are required on the object. */
|
|
269
|
-
required?: string[];
|
|
270
|
-
} & SchemaMetadata;
|
|
271
955
|
type SchemaSourceVariant = "standard-schema" | "json-schema" | "zod3" | "untyped" | "valibot" | "reflection";
|
|
956
|
+
/**
|
|
957
|
+
* Accepted schema input variants, including raw type definitions.
|
|
958
|
+
*/
|
|
272
959
|
type SchemaInputVariant = SchemaSourceVariant | "type-definition";
|
|
273
|
-
|
|
960
|
+
/**
|
|
961
|
+
* Raw schema source input union before normalization.
|
|
962
|
+
*/
|
|
963
|
+
type SchemaSourceInput = StandardJSONSchemaV1 | JsonSchema | z3.ZodTypeAny | UntypedInputObject | UntypedSchema | ValibotSchema | Type;
|
|
964
|
+
/**
|
|
965
|
+
* A reusable reference to a type definition value or identifier.
|
|
966
|
+
*/
|
|
274
967
|
type TypeDefinitionReference = TypeDefinition | string;
|
|
275
|
-
|
|
968
|
+
/**
|
|
969
|
+
* Any accepted schema input, including normalized schemas and references.
|
|
970
|
+
*/
|
|
971
|
+
type SchemaInput = SchemaSourceInput | Schema$1 | TypeDefinitionReference;
|
|
276
972
|
/**
|
|
277
973
|
* A schema extracted from a source input, normalized to JSON Schema.
|
|
278
974
|
*/
|
|
279
|
-
interface Schema$1<
|
|
975
|
+
interface Schema$1<TJsonSchema extends JsonSchema = JsonSchema> {
|
|
280
976
|
/** A stable content hash for the normalized schema. */
|
|
281
977
|
hash: string;
|
|
282
978
|
/** The source variant used to derive the normalized {@link JsonSchema}. */
|
|
283
979
|
variant: SchemaInputVariant;
|
|
284
980
|
/** The normalized schema definition. */
|
|
285
|
-
schema:
|
|
981
|
+
schema: TJsonSchema;
|
|
286
982
|
}
|
|
287
|
-
|
|
983
|
+
/**
|
|
984
|
+
* Base metadata captured for schema source inputs.
|
|
985
|
+
*/
|
|
986
|
+
interface BaseSchemaSource {
|
|
288
987
|
/** A stable content hash for the original source schema. */
|
|
289
988
|
hash: string;
|
|
290
989
|
/** The specific source format used for the schema input. */
|
|
291
990
|
variant: SchemaSourceVariant;
|
|
292
991
|
/** The original schema input captured before normalization. */
|
|
293
|
-
schema: SchemaSourceInput
|
|
992
|
+
schema: SchemaSourceInput;
|
|
294
993
|
}
|
|
295
|
-
|
|
994
|
+
/**
|
|
995
|
+
* Source descriptor for schemas that already use JSON Schema.
|
|
996
|
+
*/
|
|
997
|
+
interface JsonSchemaSchemaSource extends BaseSchemaSource {
|
|
296
998
|
/** Indicates the source input already uses JSON Schema syntax. */
|
|
297
999
|
variant: "json-schema";
|
|
298
1000
|
/** The original JSON Schema document. */
|
|
299
|
-
schema: JsonSchema
|
|
1001
|
+
schema: JsonSchema;
|
|
300
1002
|
}
|
|
1003
|
+
/**
|
|
1004
|
+
* Source descriptor for Standard Schema inputs.
|
|
1005
|
+
*/
|
|
301
1006
|
interface StandardSchemaSchemaSource extends BaseSchemaSource {
|
|
302
1007
|
/** Indicates the source input follows the Standard Schema format. */
|
|
303
1008
|
variant: "standard-schema";
|
|
304
1009
|
/** The original Standard Schema document. */
|
|
305
1010
|
schema: StandardJSONSchemaV1;
|
|
306
1011
|
}
|
|
1012
|
+
/**
|
|
1013
|
+
* Source descriptor for Zod v3 schema inputs.
|
|
1014
|
+
*/
|
|
307
1015
|
interface Zod3SchemaSource extends BaseSchemaSource {
|
|
308
1016
|
/** Indicates the source input is a Zod v3 schema. */
|
|
309
1017
|
variant: "zod3";
|
|
310
1018
|
/** The original Zod v3 schema instance. */
|
|
311
1019
|
schema: z3.ZodTypeAny;
|
|
312
1020
|
}
|
|
1021
|
+
/**
|
|
1022
|
+
* Source descriptor for Deepkit reflection type inputs.
|
|
1023
|
+
*/
|
|
313
1024
|
interface ReflectionSchemaSource extends BaseSchemaSource {
|
|
314
1025
|
/** Indicates the source input is a Deepkit reflection {@link Type}. */
|
|
315
1026
|
variant: "reflection";
|
|
316
1027
|
/** The original Deepkit reflection type. */
|
|
317
1028
|
schema: Type;
|
|
318
1029
|
}
|
|
1030
|
+
/**
|
|
1031
|
+
* Source descriptor for Untyped schema inputs.
|
|
1032
|
+
*/
|
|
319
1033
|
interface UntypedSchemaSource extends BaseSchemaSource {
|
|
320
1034
|
/** Indicates the source input comes from the Untyped schema model. */
|
|
321
1035
|
variant: "untyped";
|
|
322
1036
|
/** The original Untyped schema input. */
|
|
323
1037
|
schema: UntypedInputObject | UntypedSchema;
|
|
324
1038
|
}
|
|
1039
|
+
/**
|
|
1040
|
+
* Source descriptor for Valibot schema inputs.
|
|
1041
|
+
*/
|
|
325
1042
|
interface ValibotSchemaSource extends BaseSchemaSource {
|
|
326
1043
|
/** Indicates the source input comes from the Valibot schema model. */
|
|
327
1044
|
variant: "valibot";
|
|
328
1045
|
/** The original Valibot schema input. */
|
|
329
1046
|
schema: ValibotSchema;
|
|
330
1047
|
}
|
|
1048
|
+
/**
|
|
1049
|
+
* Union of all normalized schema source descriptor variants.
|
|
1050
|
+
*/
|
|
331
1051
|
type SchemaSource = JsonSchemaSchemaSource | StandardSchemaSchemaSource | Zod3SchemaSource | UntypedSchemaSource | ValibotSchemaSource | ReflectionSchemaSource;
|
|
332
|
-
|
|
333
|
-
|
|
1052
|
+
/**
|
|
1053
|
+
* A normalized schema plus metadata about the source that produced it.
|
|
1054
|
+
*/
|
|
1055
|
+
interface ExtractedSchema extends Schema$1 {
|
|
1056
|
+
/**
|
|
1057
|
+
* The schema source that produced this normalized schema.
|
|
1058
|
+
*/
|
|
334
1059
|
source: SchemaSource;
|
|
335
1060
|
}
|
|
336
1061
|
//#endregion
|
|
337
|
-
export { BaseSchemaSource, ExtractedSchema, JsonSchema,
|
|
1062
|
+
export { BaseSchemaSource, ExtractedSchema, JsonSchema, JsonSchemaAllOf, JsonSchemaAny, JsonSchemaAnyOf, JsonSchemaArray, JsonSchemaBigint, JsonSchemaBoolean, JsonSchemaConditionalKeywords, JsonSchemaDate, JsonSchemaDecimal, JsonSchemaEnum, JsonSchemaInteger, JsonSchemaKeywords, JsonSchemaLiteral, JsonSchemaLogicKeywords, JsonSchemaMap, JsonSchemaMetadataKeywords, JsonSchemaNativeEnum, JsonSchemaNever, JsonSchemaNull, JsonSchemaNullable, JsonSchemaNumber, JsonSchemaObject, JsonSchemaPrimitiveType, JsonSchemaPrimitiveUnion, JsonSchemaRecord, JsonSchemaRecordPropertyNames, JsonSchemaRef, JsonSchemaSchemaSource, JsonSchemaSet, JsonSchemaString, JsonSchemaTuple, JsonSchemaType, JsonSchemaUndefined, JsonSchemaUnion, JsonSchemaUnknown, ReflectionSchemaSource, Schema$1 as Schema, SchemaInput, SchemaInputVariant, SchemaSource, SchemaSourceInput, SchemaSourceVariant, StandardSchemaSchemaSource, TypeDefinitionReference, UntypedInputObject, UntypedSchema, UntypedSchemaSource, ValibotSchema, ValibotSchemaSource, Zod3SchemaSource };
|
|
338
1063
|
//# sourceMappingURL=types.d.cts.map
|