@forklaunch/validator 0.4.11 → 0.5.0

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.
@@ -1,8 +1,144 @@
1
1
  import { Prettify } from '@forklaunch/common';
2
2
  import { SchemaObject } from 'openapi3-ts/oas31';
3
- import { TUnknown, TLiteral, TSchema, TKind, TProperties, TObject as TObject$1, TNever, StaticDecode, TArray } from '@sinclair/typebox';
3
+ import * as _sinclair_typebox from '@sinclair/typebox';
4
+ import { TProperties, TOptional, TArray, TUnion, TLiteral, TFunction, TRecord, TPromise, TSchema, TUnknown, TKind, TObject as TObject$1, TNever, StaticDecode } from '@sinclair/typebox';
4
5
  import { TypeCheck } from '@sinclair/typebox/compiler';
5
- import { ZodObject as ZodObject$1, ZodRawShape, ZodOptional, ZodArray, ZodUnion, ZodLiteral, ZodType, z, ZodUnknown, ZodNever, ZodTypeAny } from 'zod';
6
+ import { ZodObject as ZodObject$1, ZodRawShape, ZodOptional, ZodArray, ZodUnion, ZodLiteral, ZodFunction, ZodTuple, ZodRecord, ZodPromise, ZodType, z, ZodUnknown, ZodNever, ZodTypeAny } from 'zod';
7
+
8
+ /**
9
+ * Class representing a TypeBox schema definition.
10
+ * @implements {SchemaValidator}
11
+ */
12
+ declare class TypeboxSchemaValidator implements SchemaValidator<(<T extends TObject<TProperties>>(schema: T) => TypeCheck<T>), <T extends TIdiomaticSchema>(schema: T) => TResolve<T>, <T extends TIdiomaticSchema>(schema: T) => TOptional<TResolve<T>>, <T extends TIdiomaticSchema>(schema: T) => TArray<TResolve<T>>, <T extends TUnionTupleContainer>(schemas: [...T]) => TUnion<UnionTupleTResolve<T>>, <T extends LiteralSchema>(value: T) => TLiteral<T>, <T extends Record<string, LiteralSchema>>(schemaEnum: T) => TUnion<[
13
+ {
14
+ [K in keyof T]: TLiteral<T[K]>;
15
+ }[keyof T]
16
+ ]>, <Args extends TUnionTupleContainer, ReturnType extends TIdiomaticSchema>(args: [...Args], returnType: ReturnType) => TFunction<UnionTupleTResolve<Args>, TResolve<ReturnType>>, <Key extends TIdiomaticSchema, Value extends TIdiomaticSchema>(key: Key, value: Value) => TRecord<TResolve<Key>, TResolve<Value>>, <T extends TIdiomaticSchema>(schema: T) => TPromise<TResolve<T>>, (value: unknown) => value is TSchema, <T extends TIdiomaticSchema | TCatchall>(schema: T, value: unknown) => boolean, <T extends TIdiomaticSchema | TCatchall>(schema: T, value: unknown) => ParseResult<TResolve<T>>, <T extends TIdiomaticSchema | TCatchall>(schema: T) => SchemaObject> {
17
+ _Type: "TypeBox";
18
+ _SchemaCatchall: TCatchall;
19
+ _ValidSchemaObject: TObject<TProperties> | TArray<TObject<TProperties>>;
20
+ string: _sinclair_typebox.TString;
21
+ uuid: _sinclair_typebox.TString;
22
+ uri: _sinclair_typebox.TString;
23
+ email: _sinclair_typebox.TString;
24
+ number: _sinclair_typebox.TTransform<TUnion<[_sinclair_typebox.TNumber, _sinclair_typebox.TString, _sinclair_typebox.TBoolean, _sinclair_typebox.TNull, _sinclair_typebox.TDate, _sinclair_typebox.TBigInt]>, number>;
25
+ bigint: _sinclair_typebox.TTransform<TUnion<[_sinclair_typebox.TBigInt, _sinclair_typebox.TNumber, _sinclair_typebox.TString, _sinclair_typebox.TBoolean, _sinclair_typebox.TDate]>, bigint>;
26
+ boolean: _sinclair_typebox.TTransform<TUnion<[_sinclair_typebox.TBoolean, _sinclair_typebox.TString]>, boolean>;
27
+ date: _sinclair_typebox.TTransform<TUnion<[_sinclair_typebox.TDate, _sinclair_typebox.TNumber, _sinclair_typebox.TString, _sinclair_typebox.TBoolean, _sinclair_typebox.TNull]>, Date>;
28
+ symbol: _sinclair_typebox.TSymbol;
29
+ nullish: TUnion<[_sinclair_typebox.TVoid, _sinclair_typebox.TNull, _sinclair_typebox.TUndefined]>;
30
+ void: _sinclair_typebox.TVoid;
31
+ null: _sinclair_typebox.TNull;
32
+ undefined: _sinclair_typebox.TUndefined;
33
+ any: _sinclair_typebox.TAny;
34
+ unknown: _sinclair_typebox.TUnknown;
35
+ never: _sinclair_typebox.TNever;
36
+ /**
37
+ * Extracts the error type of a schema for error messages.
38
+ *
39
+ * @param {TCatchall} schema - A schema that contains some type information.
40
+ * @returns The type of the schema for error messages.
41
+ */
42
+ private errorType;
43
+ /**
44
+ * Compiles schema if this exists, for optimal performance.
45
+ *
46
+ * @param {TObject<TProperties>} schema - The schema to compile.
47
+ * @returns {TypeCheck<T>} - The compiled schema.
48
+ */
49
+ compile<T extends TObject<TProperties>>(schema: T): TypeCheck<T>;
50
+ /**
51
+ * Convert a schema to a TypeBox schema.
52
+ * @param {TIdiomaticSchema} schema - The schema to convert.
53
+ * @returns {TResolve<T>} The resolved schema.
54
+ */
55
+ schemify<T extends TIdiomaticSchema>(schema: T): TResolve<T>;
56
+ /**
57
+ * Make a schema optional.
58
+ * @param {TIdiomaticSchema} schema - The schema to make optional.
59
+ * @returns {TOptional<TResolve<T>>} The optional schema.
60
+ */
61
+ optional<T extends TIdiomaticSchema>(schema: T): TOptional<TResolve<T>>;
62
+ /**
63
+ * Create an array schema.
64
+ * @param {TIdiomaticSchema} schema - The schema to use for array items.
65
+ * @returns {TArray<TResolve<T>>} The array schema.
66
+ */
67
+ array<T extends TIdiomaticSchema>(schema: T): TArray<TResolve<T>>;
68
+ /**
69
+ * Create a union schema.
70
+ * @param {TUnionTupleContainer} schemas - The schemas to union.
71
+ * @returns {TUnion<UnionTupleTResolve<T>>} The union schema.
72
+ *
73
+ * WARNING: If "nullish" or TUndefined is included in the union, the key will still be expected.
74
+ * This is a limitation of TypeBox. Consider using "optional" instead.
75
+ */
76
+ union<T extends TUnionTupleContainer>(schemas: [...T]): TUnion<UnionTupleTResolve<T>>;
77
+ /**
78
+ * Create a literal schema.
79
+ * @param {LiteralSchema} value - The literal value.
80
+ * @returns {TLiteral<T>} The literal schema.
81
+ */
82
+ literal<T extends LiteralSchema>(value: T): TLiteral<T>;
83
+ /**
84
+ * Create an enum schema.
85
+ * @param {Record<string, LiteralSchema>} schemaEnum - The enum schema.
86
+ * @returns {TUnion<UnionTupleTResolve<T[]>>} The enum schema.
87
+ */
88
+ enum_<T extends Record<string, LiteralSchema>>(schemaEnum: T): TUnion<[
89
+ {
90
+ [K in keyof T]: TLiteral<T[K]>;
91
+ }[keyof T]
92
+ ]>;
93
+ /**
94
+ * Create a function schema.
95
+ * @param {TSchema[]} args - The arguments of the function.
96
+ * @param {TAny} returnType - The return type of the function.
97
+ * @returns {TFunction<Args, ReturnType>} The function schema.
98
+ */
99
+ function_<Args extends TUnionTupleContainer, ReturnType extends TIdiomaticSchema>(args: [...Args], returnType: ReturnType): TFunction<UnionTupleTResolve<Args>, TResolve<ReturnType>>;
100
+ /**
101
+ * Create a record schema.
102
+ * @param {TIdiomaticSchema} key - The key schema.
103
+ * @param {TIdiomaticSchema} value - The value schema.
104
+ * @returns {TRecord<TResolve<Key>, TResolve<Value>>} The record schema.
105
+ */
106
+ record<Key extends TIdiomaticSchema, Value extends TIdiomaticSchema>(key: Key, value: Value): TRecord<TResolve<Key>, TResolve<Value>>;
107
+ /**
108
+ * Create a promise schema.
109
+ * @param {TIdiomaticSchema} schema - The schema to use for the promise.
110
+ * @returns {TPromise<TResolve<T>>} The promise schema.
111
+ */
112
+ promise<T extends TIdiomaticSchema>(schema: T): TPromise<TResolve<T>>;
113
+ /**
114
+ * Check if a value is a TypeBox object schema.
115
+ * @param {unknown} value - The value to check.
116
+ * @returns {boolean} True if the value is a TypeBox object schema.
117
+ */
118
+ isSchema(value: unknown): value is TSchema;
119
+ /**
120
+ * Validate a value against a schema.
121
+ *
122
+ * @param {TSchema} schema - The schema to validate against.
123
+ * @param {unknown} value - The value to validate.
124
+ * @returns {boolean} True if valid, otherwise false.
125
+ */
126
+ validate<T extends TIdiomaticSchema | TCatchall>(schema: T | TypeCheck<TResolve<T>>, value: unknown): boolean;
127
+ /**
128
+ * Parse a value against a schema.
129
+ *
130
+ * @param {TSchema} schema - The schema to validate against.
131
+ * @param {unknown} value - The value to validate.
132
+ * @returns {ParseResult<TResolve<T>>} The parsing result.
133
+ */
134
+ parse<T extends TIdiomaticSchema | TCatchall>(schema: T | TypeCheck<TResolve<T>>, value: unknown): ParseResult<TResolve<T>>;
135
+ /**
136
+ * Convert a schema to an OpenAPI schema object.
137
+ * @param {TIdiomaticSchema | TCatchall} schema - The schema to convert.
138
+ * @returns {SchemaObject} The OpenAPI schema object.
139
+ */
140
+ openapi<T extends TIdiomaticSchema | TCatchall>(schema: T): SchemaObject;
141
+ }
6
142
 
7
143
  /**
8
144
  * Represents a catch-all schema type.
@@ -29,7 +165,7 @@ type TObject<T> = T extends TObjectShape ? TObject$1<T> : TNever;
29
165
  *
30
166
  * @template T - The schema type to translate.
31
167
  */
32
- type TSchemaTranslate<T> = T extends TCatchall ? StaticDecode<T> : TNever;
168
+ type TSchemaTranslate<T> = T extends TSchema ? StaticDecode<T> : TNever;
33
169
  /**
34
170
  * Represents an unboxed object schema where each key can have an idiomatic schema.
35
171
  */
@@ -39,26 +175,29 @@ type UnboxedTObjectSchema = {
39
175
  /**
40
176
  * Represents an idiomatic schema which can be an unboxed object schema or a literal schema.
41
177
  */
42
- type TIdiomaticSchema = UnboxedTObjectSchema | LiteralSchema;
178
+ type TIdiomaticSchema = IdiomaticSchema<TypeboxSchemaValidator>;
43
179
  /**
44
180
  * Represents a container for a union of idiomatic schemas.
45
181
  */
46
- type TUnionContainer = [...TIdiomaticSchema[]];
182
+ type TUnionTupleContainer = [...TIdiomaticSchema[]];
47
183
  /**
48
184
  * Resolves a union container to a tuple of resolved idiomatic schemas.
49
185
  *
50
186
  * @template T - The union container to resolve.
51
187
  */
52
- type UnionTResolve<T extends TUnionContainer> = T extends (infer UnionTypes)[] ? [TResolve<UnionTypes>] : TNever;
188
+ type UnionTupleTResolve<T extends TUnionTupleContainer, Acc extends TIdiomaticSchema[] = []> = T extends [
189
+ infer Head extends TIdiomaticSchema,
190
+ ...infer Tail extends TUnionTupleContainer
191
+ ] ? UnionTupleTResolve<Tail, [...Acc, TResolve<Head>]> : T extends [] ? Acc : TNever[];
53
192
  /**
54
193
  * Resolves a schema type T to its resolved type. The depth is limited to 12 to prevent infinite recursion, due to StaticDecode limitations.
55
194
  *
56
195
  * @template T - The schema type to resolve.
57
196
  * @template Depth - The current depth of the resolution.
58
197
  */
59
- type TResolve<T, Depth extends number = 0> = Depth extends 10 ? TUnknown : T extends LiteralSchema ? TLiteral<T> : T extends TSchema ? T : T extends TKind ? T : T extends TObject<TObjectShape> ? T : T extends TypeCheck<infer Type> ? TResolve<Type, Increment<Depth>> : T extends UnboxedTObjectSchema ? TObject<{
198
+ type TResolve<T, Depth extends number = 0> = Depth extends 12 ? TUnknown : T extends LiteralSchema ? TLiteral<T> : T extends TSchema ? T : T extends TKind ? T : T extends UnboxedTObjectSchema ? TObject<{
60
199
  [K in keyof T]: TResolve<T[K], Increment<Depth>>;
61
- }> : TNever;
200
+ }> extends infer R ? R : TNever : T extends TypeCheck<infer Type> ? TResolve<Type, Increment<Depth>> : TNever;
62
201
 
63
202
  /**
64
203
  * This module provides a Zod-based schema definition.
@@ -71,11 +210,11 @@ type TResolve<T, Depth extends number = 0> = Depth extends 10 ? TUnknown : T ext
71
210
  * Class representing a Zod schema definition.
72
211
  * @implements {StaticSchemaValidator}
73
212
  */
74
- declare class ZodSchemaValidator implements SchemaValidator<(<T extends ZodObject$1<ZodRawShape>>(schema: T) => ZodResolve<T>), <T extends ZodIdiomaticSchema>(schema: T) => ZodResolve<T>, <T extends ZodIdiomaticSchema>(schema: T) => ZodOptional<ZodResolve<T>>, <T extends ZodIdiomaticSchema>(schema: T) => ZodArray<ZodResolve<T>>, <T extends ZodUnionContainer>(schemas: T) => ZodUnion<UnionZodResolve<T>>, <T extends LiteralSchema>(value: T) => ZodLiteral<ZodResolve<T>>, <T extends Record<string, LiteralSchema>>(schemaEnum: T) => ZodUnion<[
213
+ declare class ZodSchemaValidator implements SchemaValidator<(<T extends ZodObject$1<ZodRawShape>>(schema: T) => ZodResolve<T>), <T extends ZodIdiomaticSchema>(schema: T) => ZodResolve<T>, <T extends ZodIdiomaticSchema>(schema: T) => ZodOptional<ZodResolve<T>>, <T extends ZodIdiomaticSchema>(schema: T) => ZodArray<ZodResolve<T>>, <T extends ZodUnionContainer>(schemas: T) => ZodUnion<UnionZodResolve<T>>, <T extends LiteralSchema>(value: T) => ZodLiteral<T>, <T extends Record<string, LiteralSchema>>(schemaEnum: T) => ZodUnion<[
75
214
  {
76
215
  [K in keyof T]: ZodLiteral<T[K]>;
77
216
  }[keyof T]
78
- ]>, (value: unknown) => value is ZodType, <T extends ZodIdiomaticSchema | ZodCatchall>(schema: T, value: unknown) => boolean, <T extends ZodIdiomaticSchema | ZodCatchall>(schema: T, value: unknown) => ParseResult<ZodResolve<T>>, <T extends ZodIdiomaticSchema | ZodCatchall>(schema: T) => SchemaObject> {
217
+ ]>, <Args extends ZodTupleContainer, ReturnType extends ZodIdiomaticSchema>(args: Args, returnType: ReturnType) => ZodFunction<ZodTuple<TupleZodResolve<Args>, null>, ZodResolve<ReturnType>>, <Key extends ZodIdiomaticSchema, Value extends ZodIdiomaticSchema>(key: Key, value: Value) => ZodRecord<ZodRecordKey<Key>, ZodResolve<Value>>, <T extends ZodIdiomaticSchema>(schema: T) => ZodPromise<ZodResolve<T>>, (value: unknown) => value is ZodType, <T extends ZodIdiomaticSchema | ZodCatchall>(schema: T, value: unknown) => boolean, <T extends ZodIdiomaticSchema | ZodCatchall>(schema: T, value: unknown) => ParseResult<ZodResolve<T>>, <T extends ZodIdiomaticSchema | ZodCatchall>(schema: T) => SchemaObject> {
79
218
  _Type: "Zod";
80
219
  _SchemaCatchall: ZodType;
81
220
  _ValidSchemaObject: ZodObject$1<ZodRawShape> | ZodArray<ZodObject$1<ZodRawShape>>;
@@ -88,7 +227,10 @@ declare class ZodSchemaValidator implements SchemaValidator<(<T extends ZodObjec
88
227
  boolean: z.ZodEffects<z.ZodBoolean, boolean, unknown>;
89
228
  date: z.ZodPipeline<z.ZodEffects<z.ZodAny, any, any>, z.ZodDate>;
90
229
  symbol: z.ZodSymbol;
91
- nullish: ZodUnion<[z.ZodVoid, z.ZodNull, z.ZodUndefined]>;
230
+ nullish: z.ZodUnion<[z.ZodVoid, z.ZodNull, z.ZodUndefined]>;
231
+ void: z.ZodVoid;
232
+ null: z.ZodNull;
233
+ undefined: z.ZodUndefined;
92
234
  any: z.ZodAny;
93
235
  unknown: z.ZodUnknown;
94
236
  never: z.ZodNever;
@@ -128,7 +270,7 @@ declare class ZodSchemaValidator implements SchemaValidator<(<T extends ZodObjec
128
270
  * @param {LiteralSchema} value - The literal value.
129
271
  * @returns {ZodLiteral<ZodResolve<T>>} The literal schema.
130
272
  */
131
- literal<T extends LiteralSchema>(value: T): ZodLiteral<ZodResolve<T>>;
273
+ literal<T extends LiteralSchema>(value: T): ZodLiteral<T>;
132
274
  /**
133
275
  * Create an enum schema.
134
276
  * @param {Record<string, LiteralSchema>} schemaEnum - The enum schema.
@@ -139,6 +281,26 @@ declare class ZodSchemaValidator implements SchemaValidator<(<T extends ZodObjec
139
281
  [K in keyof T]: ZodLiteral<T[K]>;
140
282
  }[keyof T]
141
283
  ]>;
284
+ /**
285
+ * Create a function schema.
286
+ * @param {ZodTuple} args - The arguments of the function.
287
+ * @param {ZodAny} returnType - The return type of the function.
288
+ * @returns {ZodFunction<Args, ReturnType>} The function schema.
289
+ */
290
+ function_<Args extends ZodTupleContainer, ReturnType extends ZodIdiomaticSchema>(args: Args, returnType: ReturnType): ZodFunction<ZodTuple<TupleZodResolve<Args>, null>, ZodResolve<ReturnType>>;
291
+ /**
292
+ * Create a record schema.
293
+ * @param {ZodIdiomaticSchema} key - The key schema.
294
+ * @param {ZodIdiomaticSchema} value - The value schema.
295
+ * @returns {ZodRecord<ZodResolve<Key>, ZodResolve<Value>>} The record schema.
296
+ */
297
+ record<Key extends ZodIdiomaticSchema, Value extends ZodIdiomaticSchema>(key: Key, value: Value): ZodRecord<ZodRecordKey<Key>, ZodResolve<Value>>;
298
+ /**
299
+ * Create a promise schema.
300
+ * @param {ZodIdiomaticSchema} schema - The schema to use for the promise.
301
+ * @returns {ZodPromise<ZodResolve<T>>} The promise schema.
302
+ */
303
+ promise<T extends ZodIdiomaticSchema>(schema: T): ZodPromise<ZodResolve<T>>;
142
304
  /**
143
305
  * Checks if a value is a Zod schema.
144
306
  * @param {unknown} value - The value to check.
@@ -202,6 +364,24 @@ type UnboxedZodObjectSchema = UnboxedObjectSchema<ZodSchemaValidator>;
202
364
  * Represents an idiomatic schema for Zod which can be an unboxed object schema or a literal schema.
203
365
  */
204
366
  type ZodIdiomaticSchema = IdiomaticSchema<ZodSchemaValidator>;
367
+ /**
368
+ * Represents a container for a union of Zod idiomatic schemas.
369
+ */
370
+ type ZodTupleContainer = readonly [] | readonly [ZodIdiomaticSchema, ...ZodIdiomaticSchema[]];
371
+ /**
372
+ * Resolves a union container to a tuple of resolved Zod idiomatic schemas.
373
+ *
374
+ * @template T - The union container to resolve.
375
+ */
376
+ type TupleZodResolve<T extends ZodTupleContainer> = T extends [
377
+ infer A extends ZodIdiomaticSchema,
378
+ ...infer B extends ZodIdiomaticSchema[]
379
+ ] ? [
380
+ ZodResolve<A>,
381
+ ...{
382
+ [K in keyof B]: ZodResolve<B[K]>;
383
+ }
384
+ ] : [];
205
385
  /**
206
386
  * Represents a container for a union of Zod idiomatic schemas.
207
387
  */
@@ -227,14 +407,20 @@ type UnionZodResolve<T extends ZodUnionContainer> = T extends [
227
407
  }
228
408
  ] : [ZodNever, ZodNever];
229
409
  /**
230
- * Resolves a Zod schema type T to its resolved type. The depth is limited to 31 to prevent infinite recursion.
410
+ * Resolves a Zod schema type T to its resolved type. The depth is limited to 29 to prevent infinite recursion.
231
411
  *
232
412
  * @template T - The Zod schema type to resolve.
233
413
  * @template Depth - The current depth of the resolution.
234
414
  */
235
- type ZodResolve<T, Depth extends number = 0> = Depth extends 30 ? ZodUnknown : T extends LiteralSchema ? ZodLiteral<T> : T extends ZodType ? T : T extends UnboxedZodObjectSchema ? ZodObject<{
415
+ type ZodResolve<T, Depth extends number = 0> = Depth extends 29 ? ZodUnknown : T extends LiteralSchema ? ZodLiteral<T> : T extends ZodType ? T : T extends UnboxedZodObjectSchema ? ZodObject<{
236
416
  [K in keyof T]: ZodResolve<T[K], Increment<Depth>>;
237
- }> : ZodNever;
417
+ }> extends infer R ? R : ZodNever : ZodNever;
418
+ /**
419
+ * Represents the key type of a Zod record schema.
420
+ *
421
+ * @template T - The Zod idiomatic schema to get the key type from.
422
+ */
423
+ type ZodRecordKey<T extends ZodIdiomaticSchema> = ZodResolve<T> extends infer R ? R extends boolean ? never : unknown extends R ? never : R : never;
238
424
 
239
425
  /**
240
426
  * Represents an error with a path and message.
@@ -266,7 +452,7 @@ type ParseResult<T> = {
266
452
  * @template ParseFunction - The function type for parsing a value against a schema.
267
453
  * @template OpenAPIFunction - The function type for converting a schema into an OpenAPI schema object.
268
454
  */
269
- interface SchemaValidator<CompilationFunction = <T>(schema: T) => unknown, SchematicFunction = <T>(schema: T) => unknown, OptionalFunction = <T>(schema: T) => unknown, ArrayFunction = <T>(schema: T) => unknown, UnionFunction = <T>(schemas: T[]) => unknown, LiteralFunction = <T extends LiteralSchema>(schema: T) => unknown, EnumFunction = <T extends LiteralSchema>(schemaEnum: Record<string, T>) => unknown, SchemaGuardFunction = <T>(value: unknown) => value is T, ValidationFunction = <T>(schema: T, value: unknown) => boolean, ParseFunction = <T>(schema: T, value: unknown) => ParseResult<SchemaResolve<T>>, OpenAPIFunction = <T>(schema: T) => SchemaObject> {
455
+ interface SchemaValidator<CompilationFunction = <T>(schema: T) => unknown, SchematicFunction = <T>(schema: T) => unknown, OptionalFunction = <T>(schema: T) => unknown, ArrayFunction = <T>(schema: T) => unknown, UnionFunction = <T>(schemas: T[]) => unknown, LiteralFunction = <T extends LiteralSchema>(schema: T) => unknown, EnumFunction = <T extends LiteralSchema>(schemaEnum: Record<string, T>) => unknown, FunctionFunction = <Args, ReturnType>(args: Args, returnType: ReturnType) => unknown, RecordFunction = <Key, Value>(key: Key, value: Value) => unknown, PromiseFunction = <T>(schema: T) => unknown, SchemaGuardFunction = <T>(value: unknown) => value is T, ValidationFunction = <T>(schema: T, value: unknown) => boolean, ParseFunction = <T>(schema: T, value: unknown) => ParseResult<SchemaResolve<T>>, OpenAPIFunction = <T>(schema: T) => SchemaObject> {
270
456
  /**
271
457
  * The type of the schema validator.
272
458
  */
@@ -380,6 +566,29 @@ interface SchemaValidator<CompilationFunction = <T>(schema: T) => unknown, Schem
380
566
  * @returns {unknown} - The enum schema.
381
567
  */
382
568
  enum_: EnumFunction;
569
+ /**
570
+ * Creates a function schema from a tuple of arguments and a return type.
571
+ *
572
+ * @param {Args} args - The arguments of the function.
573
+ * @param {ReturnType} returnType - The return type of the function.
574
+ * @returns {unknown} - The function schema.
575
+ */
576
+ function_: FunctionFunction;
577
+ /**
578
+ * Creates a promise schema from a schema.
579
+ *
580
+ * @param {T} schema - The schema to use for the promise.
581
+ * @returns {unknown} - The promise schema.
582
+ */
583
+ promise: PromiseFunction;
584
+ /**
585
+ * Creates a record schema from a key and value schema.
586
+ *
587
+ * @param {Key} key - The key schema.
588
+ * @param {Value} value - The value schema.
589
+ * @returns {unknown} - The record schema.
590
+ */
591
+ record: RecordFunction;
383
592
  /**
384
593
  * Checks if a value is a schema.
385
594
  *
@@ -414,7 +623,7 @@ interface SchemaValidator<CompilationFunction = <T>(schema: T) => unknown, Schem
414
623
  /**
415
624
  * Type representing any schema validator.
416
625
  */
417
- type AnySchemaValidator = SchemaValidator<unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown> & {
626
+ type AnySchemaValidator = SchemaValidator<unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown> & {
418
627
  /**
419
628
  * The type of the schema resolver.
420
629
  */
@@ -463,7 +672,7 @@ type SchemaPrettify<T, SV extends AnySchemaValidator> = Prettify<SchemaTranslate
463
672
  * @template T - The type of the schema.
464
673
  * @template SV - The type of the schema validator.
465
674
  */
466
- type Schema<T extends SV['_ValidSchemaObject'] | IdiomaticSchema<SV>, SV extends AnySchemaValidator> = SchemaPrettify<SchemaResolve<T>[SV['_Type']], SV>;
675
+ type Schema<T extends SV['_ValidSchemaObject'] | IdiomaticSchema<SV>, SV extends AnySchemaValidator> = SchemaTranslate<SchemaResolve<T>[SV['_Type']]>[SV['_Type']] extends infer Schema ? Schema extends (...args: infer Args) => infer Return ? (...args: Args) => Return : SchemaPrettify<SchemaResolve<T>[SV['_Type']], SV> : never;
467
676
  /**
468
677
  * Represents a schema for an unboxed object where each key can have an idiomatic schema.
469
678
  *
@@ -493,4 +702,4 @@ type Increment<T extends number> = T extends 0 ? 1 : T extends 1 ? 2 : T extends
493
702
  */
494
703
  type KeyTypes = string | number;
495
704
 
496
- export { type AnySchemaValidator as A, type IdiomaticSchema as I, type KeyTypes as K, type LiteralSchema as L, type ParseError as P, type SchemaValidator as S, type TObject as T, type UnboxedObjectSchema as U, ZodSchemaValidator as Z, type ParseResult as a, type SchemaResolve as b, type SchemaTranslate as c, type Schema as d, type Increment as e, type TIdiomaticSchema as f, type TResolve as g, type TUnionContainer as h, type UnionTResolve as i, type TCatchall as j, type TOuterArray as k, type TObjectShape as l, type TSchemaTranslate as m, type UnboxedTObjectSchema as n, type ZodIdiomaticSchema as o, type ZodResolve as p, type ZodUnionContainer as q, type UnionZodResolve as r, type ZodCatchall as s, type ZodOuterArray as t, type ZodObjectShape as u, type ZodObject as v, type ZodSchemaTranslate as w, type UnboxedZodObjectSchema as x };
705
+ export { type AnySchemaValidator as A, type ZodSchemaTranslate as B, type UnboxedZodObjectSchema as C, type IdiomaticSchema as I, type KeyTypes as K, type LiteralSchema as L, type ParseError as P, type SchemaValidator as S, TypeboxSchemaValidator as T, type UnboxedObjectSchema as U, ZodSchemaValidator as Z, type ParseResult as a, type SchemaResolve as b, type SchemaTranslate as c, type Schema as d, type Increment as e, type TIdiomaticSchema as f, type TResolve as g, type TUnionTupleContainer as h, type UnionTupleTResolve as i, type TCatchall as j, type TOuterArray as k, type TObjectShape as l, type TObject as m, type TSchemaTranslate as n, type UnboxedTObjectSchema as o, type ZodIdiomaticSchema as p, type ZodResolve as q, type ZodUnionContainer as r, type UnionZodResolve as s, type ZodTupleContainer as t, type TupleZodResolve as u, type ZodRecordKey as v, type ZodCatchall as w, type ZodOuterArray as x, type ZodObjectShape as y, type ZodObject as z };