@forklaunch/validator 0.4.11 → 0.4.12

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,5 +1,5 @@
1
1
  import { SchemaObject } from 'openapi3-ts/oas31';
2
- import { S as SchemaValidator, L as LiteralSchema, a as ParseResult } from '../../schema.types-BA3PeCI5.mjs';
2
+ import { S as SchemaValidator, L as LiteralSchema, a as ParseResult } from '../../schema.types-LkSEBFTv.mjs';
3
3
  import '@forklaunch/common';
4
4
  import '@sinclair/typebox';
5
5
  import '@sinclair/typebox/compiler';
@@ -1,5 +1,5 @@
1
1
  import { SchemaObject } from 'openapi3-ts/oas31';
2
- import { S as SchemaValidator, L as LiteralSchema, a as ParseResult } from '../../schema.types-BA3PeCI5.js';
2
+ import { S as SchemaValidator, L as LiteralSchema, a as ParseResult } from '../../schema.types-LkSEBFTv.js';
3
3
  import '@forklaunch/common';
4
4
  import '@sinclair/typebox';
5
5
  import '@sinclair/typebox/compiler';
package/lib/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as ParseError } from './schema.types-BA3PeCI5.mjs';
2
- export { A as AnySchemaValidator, I as IdiomaticSchema, e as Increment, K as KeyTypes, L as LiteralSchema, a as ParseResult, d as Schema, b as SchemaResolve, c as SchemaTranslate, S as SchemaValidator, U as UnboxedObjectSchema } from './schema.types-BA3PeCI5.mjs';
1
+ import { P as ParseError } from './schema.types-LkSEBFTv.mjs';
2
+ export { A as AnySchemaValidator, I as IdiomaticSchema, e as Increment, K as KeyTypes, L as LiteralSchema, a as ParseResult, d as Schema, b as SchemaResolve, c as SchemaTranslate, S as SchemaValidator, U as UnboxedObjectSchema } from './schema.types-LkSEBFTv.mjs';
3
3
  import '@forklaunch/common';
4
4
  import 'openapi3-ts/oas31';
5
5
  import '@sinclair/typebox';
package/lib/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as ParseError } from './schema.types-BA3PeCI5.js';
2
- export { A as AnySchemaValidator, I as IdiomaticSchema, e as Increment, K as KeyTypes, L as LiteralSchema, a as ParseResult, d as Schema, b as SchemaResolve, c as SchemaTranslate, S as SchemaValidator, U as UnboxedObjectSchema } from './schema.types-BA3PeCI5.js';
1
+ import { P as ParseError } from './schema.types-LkSEBFTv.js';
2
+ export { A as AnySchemaValidator, I as IdiomaticSchema, e as Increment, K as KeyTypes, L as LiteralSchema, a as ParseResult, d as Schema, b as SchemaResolve, c as SchemaTranslate, S as SchemaValidator, U as UnboxedObjectSchema } from './schema.types-LkSEBFTv.js';
3
3
  import '@forklaunch/common';
4
4
  import 'openapi3-ts/oas31';
5
5
  import '@sinclair/typebox';
@@ -1,9 +1,122 @@
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, TSchema, TUnknown, TKind, TObject as TObject$1, TNever, StaticDecode } from '@sinclair/typebox';
4
5
  import { TypeCheck } from '@sinclair/typebox/compiler';
5
6
  import { ZodObject as ZodObject$1, ZodRawShape, ZodOptional, ZodArray, ZodUnion, ZodLiteral, ZodType, z, ZodUnknown, ZodNever, ZodTypeAny } from 'zod';
6
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 TUnionContainer>(schemas: [...T]) => TUnion<UnionTResolve<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
+ ]>, (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
+ any: _sinclair_typebox.TAny;
31
+ unknown: _sinclair_typebox.TUnknown;
32
+ never: _sinclair_typebox.TNever;
33
+ /**
34
+ * Extracts the error type of a schema for error messages.
35
+ *
36
+ * @param {TCatchall} schema - A schema that contains some type information.
37
+ * @returns The type of the schema for error messages.
38
+ */
39
+ private errorType;
40
+ /**
41
+ * Compiles schema if this exists, for optimal performance.
42
+ *
43
+ * @param {TObject<TProperties>} schema - The schema to compile.
44
+ * @returns {TypeCheck<T>} - The compiled schema.
45
+ */
46
+ compile<T extends TObject<TProperties>>(schema: T): TypeCheck<T>;
47
+ /**
48
+ * Convert a schema to a TypeBox schema.
49
+ * @param {TIdiomaticSchema} schema - The schema to convert.
50
+ * @returns {TResolve<T>} The resolved schema.
51
+ */
52
+ schemify<T extends TIdiomaticSchema>(schema: T): TResolve<T>;
53
+ /**
54
+ * Make a schema optional.
55
+ * @param {TIdiomaticSchema} schema - The schema to make optional.
56
+ * @returns {TOptional<TResolve<T>>} The optional schema.
57
+ */
58
+ optional<T extends TIdiomaticSchema>(schema: T): TOptional<TResolve<T>>;
59
+ /**
60
+ * Create an array schema.
61
+ * @param {TIdiomaticSchema} schema - The schema to use for array items.
62
+ * @returns {TArray<TResolve<T>>} The array schema.
63
+ */
64
+ array<T extends TIdiomaticSchema>(schema: T): TArray<TResolve<T>>;
65
+ /**
66
+ * Create a union schema.
67
+ * @param {TUnionContainer} schemas - The schemas to union.
68
+ * @returns {TUnion<UnionTResolve<T>>} The union schema.
69
+ *
70
+ * WARNING: If "nullish" or TUndefined is included in the union, the key will still be expected.
71
+ * This is a limitation of TypeBox. Consider using "optional" instead.
72
+ */
73
+ union<T extends TUnionContainer>(schemas: [...T]): TUnion<UnionTResolve<T>>;
74
+ /**
75
+ * Create a literal schema.
76
+ * @param {LiteralSchema} value - The literal value.
77
+ * @returns {TLiteral<T>} The literal schema.
78
+ */
79
+ literal<T extends LiteralSchema>(value: T): TLiteral<T>;
80
+ /**
81
+ * Create an enum schema.
82
+ * @param {Record<string, LiteralSchema>} schemaEnum - The enum schema.
83
+ * @returns {TUnion<UnionTResolve<T[]>>} The enum schema.
84
+ */
85
+ enum_<T extends Record<string, LiteralSchema>>(schemaEnum: T): TUnion<[
86
+ {
87
+ [K in keyof T]: TLiteral<T[K]>;
88
+ }[keyof T]
89
+ ]>;
90
+ /**
91
+ * Check if a value is a TypeBox object schema.
92
+ * @param {unknown} value - The value to check.
93
+ * @returns {boolean} True if the value is a TypeBox object schema.
94
+ */
95
+ isSchema(value: unknown): value is TSchema;
96
+ /**
97
+ * Validate a value against a schema.
98
+ *
99
+ * @param {TSchema} schema - The schema to validate against.
100
+ * @param {unknown} value - The value to validate.
101
+ * @returns {boolean} True if valid, otherwise false.
102
+ */
103
+ validate<T extends TIdiomaticSchema | TCatchall>(schema: T | TypeCheck<TResolve<T>>, value: unknown): boolean;
104
+ /**
105
+ * Parse a value against a schema.
106
+ *
107
+ * @param {TSchema} schema - The schema to validate against.
108
+ * @param {unknown} value - The value to validate.
109
+ * @returns {ParseResult<TResolve<T>>} The parsing result.
110
+ */
111
+ parse<T extends TIdiomaticSchema | TCatchall>(schema: T | TypeCheck<TResolve<T>>, value: unknown): ParseResult<TResolve<T>>;
112
+ /**
113
+ * Convert a schema to an OpenAPI schema object.
114
+ * @param {TIdiomaticSchema | TCatchall} schema - The schema to convert.
115
+ * @returns {SchemaObject} The OpenAPI schema object.
116
+ */
117
+ openapi<T extends TIdiomaticSchema | TCatchall>(schema: T): SchemaObject;
118
+ }
119
+
7
120
  /**
8
121
  * Represents a catch-all schema type.
9
122
  */
@@ -29,7 +142,7 @@ type TObject<T> = T extends TObjectShape ? TObject$1<T> : TNever;
29
142
  *
30
143
  * @template T - The schema type to translate.
31
144
  */
32
- type TSchemaTranslate<T> = T extends TCatchall ? StaticDecode<T> : TNever;
145
+ type TSchemaTranslate<T> = T extends TSchema ? StaticDecode<T> : TNever;
33
146
  /**
34
147
  * Represents an unboxed object schema where each key can have an idiomatic schema.
35
148
  */
@@ -39,7 +152,7 @@ type UnboxedTObjectSchema = {
39
152
  /**
40
153
  * Represents an idiomatic schema which can be an unboxed object schema or a literal schema.
41
154
  */
42
- type TIdiomaticSchema = UnboxedTObjectSchema | LiteralSchema;
155
+ type TIdiomaticSchema = IdiomaticSchema<TypeboxSchemaValidator>;
43
156
  /**
44
157
  * Represents a container for a union of idiomatic schemas.
45
158
  */
@@ -49,16 +162,19 @@ type TUnionContainer = [...TIdiomaticSchema[]];
49
162
  *
50
163
  * @template T - The union container to resolve.
51
164
  */
52
- type UnionTResolve<T extends TUnionContainer> = T extends (infer UnionTypes)[] ? [TResolve<UnionTypes>] : TNever;
165
+ type UnionTResolve<T extends TUnionContainer, Acc extends TIdiomaticSchema[] = []> = T extends [
166
+ infer Head extends TIdiomaticSchema,
167
+ ...infer Tail extends TUnionContainer
168
+ ] ? UnionTResolve<Tail, [...Acc, TResolve<Head>]> : T extends [] ? Acc : TNever[];
53
169
  /**
54
170
  * Resolves a schema type T to its resolved type. The depth is limited to 12 to prevent infinite recursion, due to StaticDecode limitations.
55
171
  *
56
172
  * @template T - The schema type to resolve.
57
173
  * @template Depth - The current depth of the resolution.
58
174
  */
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<{
175
+ 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
176
  [K in keyof T]: TResolve<T[K], Increment<Depth>>;
61
- }> : TNever;
177
+ }> extends infer R ? R : TNever : T extends TypeCheck<infer Type> ? TResolve<Type, Increment<Depth>> : TNever;
62
178
 
63
179
  /**
64
180
  * This module provides a Zod-based schema definition.
@@ -227,14 +343,14 @@ type UnionZodResolve<T extends ZodUnionContainer> = T extends [
227
343
  }
228
344
  ] : [ZodNever, ZodNever];
229
345
  /**
230
- * Resolves a Zod schema type T to its resolved type. The depth is limited to 31 to prevent infinite recursion.
346
+ * Resolves a Zod schema type T to its resolved type. The depth is limited to 29 to prevent infinite recursion.
231
347
  *
232
348
  * @template T - The Zod schema type to resolve.
233
349
  * @template Depth - The current depth of the resolution.
234
350
  */
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<{
351
+ 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
352
  [K in keyof T]: ZodResolve<T[K], Increment<Depth>>;
237
- }> : ZodNever;
353
+ }> extends infer R ? R : ZodNever : ZodNever;
238
354
 
239
355
  /**
240
356
  * Represents an error with a path and message.
@@ -493,4 +609,4 @@ type Increment<T extends number> = T extends 0 ? 1 : T extends 1 ? 2 : T extends
493
609
  */
494
610
  type KeyTypes = string | number;
495
611
 
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 };
612
+ 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, 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 TUnionContainer as h, type UnionTResolve 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 ZodCatchall as t, type ZodOuterArray as u, type ZodObjectShape as v, type ZodObject as w, type ZodSchemaTranslate as x, type UnboxedZodObjectSchema as y };
@@ -1,9 +1,122 @@
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, TSchema, TUnknown, TKind, TObject as TObject$1, TNever, StaticDecode } from '@sinclair/typebox';
4
5
  import { TypeCheck } from '@sinclair/typebox/compiler';
5
6
  import { ZodObject as ZodObject$1, ZodRawShape, ZodOptional, ZodArray, ZodUnion, ZodLiteral, ZodType, z, ZodUnknown, ZodNever, ZodTypeAny } from 'zod';
6
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 TUnionContainer>(schemas: [...T]) => TUnion<UnionTResolve<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
+ ]>, (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
+ any: _sinclair_typebox.TAny;
31
+ unknown: _sinclair_typebox.TUnknown;
32
+ never: _sinclair_typebox.TNever;
33
+ /**
34
+ * Extracts the error type of a schema for error messages.
35
+ *
36
+ * @param {TCatchall} schema - A schema that contains some type information.
37
+ * @returns The type of the schema for error messages.
38
+ */
39
+ private errorType;
40
+ /**
41
+ * Compiles schema if this exists, for optimal performance.
42
+ *
43
+ * @param {TObject<TProperties>} schema - The schema to compile.
44
+ * @returns {TypeCheck<T>} - The compiled schema.
45
+ */
46
+ compile<T extends TObject<TProperties>>(schema: T): TypeCheck<T>;
47
+ /**
48
+ * Convert a schema to a TypeBox schema.
49
+ * @param {TIdiomaticSchema} schema - The schema to convert.
50
+ * @returns {TResolve<T>} The resolved schema.
51
+ */
52
+ schemify<T extends TIdiomaticSchema>(schema: T): TResolve<T>;
53
+ /**
54
+ * Make a schema optional.
55
+ * @param {TIdiomaticSchema} schema - The schema to make optional.
56
+ * @returns {TOptional<TResolve<T>>} The optional schema.
57
+ */
58
+ optional<T extends TIdiomaticSchema>(schema: T): TOptional<TResolve<T>>;
59
+ /**
60
+ * Create an array schema.
61
+ * @param {TIdiomaticSchema} schema - The schema to use for array items.
62
+ * @returns {TArray<TResolve<T>>} The array schema.
63
+ */
64
+ array<T extends TIdiomaticSchema>(schema: T): TArray<TResolve<T>>;
65
+ /**
66
+ * Create a union schema.
67
+ * @param {TUnionContainer} schemas - The schemas to union.
68
+ * @returns {TUnion<UnionTResolve<T>>} The union schema.
69
+ *
70
+ * WARNING: If "nullish" or TUndefined is included in the union, the key will still be expected.
71
+ * This is a limitation of TypeBox. Consider using "optional" instead.
72
+ */
73
+ union<T extends TUnionContainer>(schemas: [...T]): TUnion<UnionTResolve<T>>;
74
+ /**
75
+ * Create a literal schema.
76
+ * @param {LiteralSchema} value - The literal value.
77
+ * @returns {TLiteral<T>} The literal schema.
78
+ */
79
+ literal<T extends LiteralSchema>(value: T): TLiteral<T>;
80
+ /**
81
+ * Create an enum schema.
82
+ * @param {Record<string, LiteralSchema>} schemaEnum - The enum schema.
83
+ * @returns {TUnion<UnionTResolve<T[]>>} The enum schema.
84
+ */
85
+ enum_<T extends Record<string, LiteralSchema>>(schemaEnum: T): TUnion<[
86
+ {
87
+ [K in keyof T]: TLiteral<T[K]>;
88
+ }[keyof T]
89
+ ]>;
90
+ /**
91
+ * Check if a value is a TypeBox object schema.
92
+ * @param {unknown} value - The value to check.
93
+ * @returns {boolean} True if the value is a TypeBox object schema.
94
+ */
95
+ isSchema(value: unknown): value is TSchema;
96
+ /**
97
+ * Validate a value against a schema.
98
+ *
99
+ * @param {TSchema} schema - The schema to validate against.
100
+ * @param {unknown} value - The value to validate.
101
+ * @returns {boolean} True if valid, otherwise false.
102
+ */
103
+ validate<T extends TIdiomaticSchema | TCatchall>(schema: T | TypeCheck<TResolve<T>>, value: unknown): boolean;
104
+ /**
105
+ * Parse a value against a schema.
106
+ *
107
+ * @param {TSchema} schema - The schema to validate against.
108
+ * @param {unknown} value - The value to validate.
109
+ * @returns {ParseResult<TResolve<T>>} The parsing result.
110
+ */
111
+ parse<T extends TIdiomaticSchema | TCatchall>(schema: T | TypeCheck<TResolve<T>>, value: unknown): ParseResult<TResolve<T>>;
112
+ /**
113
+ * Convert a schema to an OpenAPI schema object.
114
+ * @param {TIdiomaticSchema | TCatchall} schema - The schema to convert.
115
+ * @returns {SchemaObject} The OpenAPI schema object.
116
+ */
117
+ openapi<T extends TIdiomaticSchema | TCatchall>(schema: T): SchemaObject;
118
+ }
119
+
7
120
  /**
8
121
  * Represents a catch-all schema type.
9
122
  */
@@ -29,7 +142,7 @@ type TObject<T> = T extends TObjectShape ? TObject$1<T> : TNever;
29
142
  *
30
143
  * @template T - The schema type to translate.
31
144
  */
32
- type TSchemaTranslate<T> = T extends TCatchall ? StaticDecode<T> : TNever;
145
+ type TSchemaTranslate<T> = T extends TSchema ? StaticDecode<T> : TNever;
33
146
  /**
34
147
  * Represents an unboxed object schema where each key can have an idiomatic schema.
35
148
  */
@@ -39,7 +152,7 @@ type UnboxedTObjectSchema = {
39
152
  /**
40
153
  * Represents an idiomatic schema which can be an unboxed object schema or a literal schema.
41
154
  */
42
- type TIdiomaticSchema = UnboxedTObjectSchema | LiteralSchema;
155
+ type TIdiomaticSchema = IdiomaticSchema<TypeboxSchemaValidator>;
43
156
  /**
44
157
  * Represents a container for a union of idiomatic schemas.
45
158
  */
@@ -49,16 +162,19 @@ type TUnionContainer = [...TIdiomaticSchema[]];
49
162
  *
50
163
  * @template T - The union container to resolve.
51
164
  */
52
- type UnionTResolve<T extends TUnionContainer> = T extends (infer UnionTypes)[] ? [TResolve<UnionTypes>] : TNever;
165
+ type UnionTResolve<T extends TUnionContainer, Acc extends TIdiomaticSchema[] = []> = T extends [
166
+ infer Head extends TIdiomaticSchema,
167
+ ...infer Tail extends TUnionContainer
168
+ ] ? UnionTResolve<Tail, [...Acc, TResolve<Head>]> : T extends [] ? Acc : TNever[];
53
169
  /**
54
170
  * Resolves a schema type T to its resolved type. The depth is limited to 12 to prevent infinite recursion, due to StaticDecode limitations.
55
171
  *
56
172
  * @template T - The schema type to resolve.
57
173
  * @template Depth - The current depth of the resolution.
58
174
  */
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<{
175
+ 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
176
  [K in keyof T]: TResolve<T[K], Increment<Depth>>;
61
- }> : TNever;
177
+ }> extends infer R ? R : TNever : T extends TypeCheck<infer Type> ? TResolve<Type, Increment<Depth>> : TNever;
62
178
 
63
179
  /**
64
180
  * This module provides a Zod-based schema definition.
@@ -227,14 +343,14 @@ type UnionZodResolve<T extends ZodUnionContainer> = T extends [
227
343
  }
228
344
  ] : [ZodNever, ZodNever];
229
345
  /**
230
- * Resolves a Zod schema type T to its resolved type. The depth is limited to 31 to prevent infinite recursion.
346
+ * Resolves a Zod schema type T to its resolved type. The depth is limited to 29 to prevent infinite recursion.
231
347
  *
232
348
  * @template T - The Zod schema type to resolve.
233
349
  * @template Depth - The current depth of the resolution.
234
350
  */
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<{
351
+ 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
352
  [K in keyof T]: ZodResolve<T[K], Increment<Depth>>;
237
- }> : ZodNever;
353
+ }> extends infer R ? R : ZodNever : ZodNever;
238
354
 
239
355
  /**
240
356
  * Represents an error with a path and message.
@@ -493,4 +609,4 @@ type Increment<T extends number> = T extends 0 ? 1 : T extends 1 ? 2 : T extends
493
609
  */
494
610
  type KeyTypes = string | number;
495
611
 
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 };
612
+ 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, 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 TUnionContainer as h, type UnionTResolve 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 ZodCatchall as t, type ZodOuterArray as u, type ZodObjectShape as v, type ZodObject as w, type ZodSchemaTranslate as x, type UnboxedZodObjectSchema as y };
@@ -1,126 +1,11 @@
1
1
  import * as openapi3_ts_oas31 from 'openapi3-ts/oas31';
2
- import { SchemaObject } from 'openapi3-ts/oas31';
3
2
  import * as _sinclair_typebox_compiler from '@sinclair/typebox/compiler';
4
- import { TypeCheck } from '@sinclair/typebox/compiler';
5
- import { S as SchemaValidator$1, T as TObject, f as TIdiomaticSchema, g as TResolve, h as TUnionContainer, i as UnionTResolve, L as LiteralSchema, j as TCatchall, a as ParseResult } from '../../schema.types-BA3PeCI5.mjs';
6
- export { l as TObjectShape, k as TOuterArray, m as TSchemaTranslate, n as UnboxedTObjectSchema } from '../../schema.types-BA3PeCI5.mjs';
3
+ import { T as TypeboxSchemaValidator, f as TIdiomaticSchema, g as TResolve, h as TUnionContainer, i as UnionTResolve, L as LiteralSchema, j as TCatchall, a as ParseResult } from '../../schema.types-LkSEBFTv.mjs';
4
+ export { m as TObject, l as TObjectShape, k as TOuterArray, n as TSchemaTranslate, o as UnboxedTObjectSchema } from '../../schema.types-LkSEBFTv.mjs';
7
5
  import * as _sinclair_typebox from '@sinclair/typebox';
8
- import { TProperties, TOptional, TArray, TUnion, TLiteral, TSchema } from '@sinclair/typebox';
9
6
  import '@forklaunch/common';
10
7
  import 'zod';
11
8
 
12
- /**
13
- * Class representing a TypeBox schema definition.
14
- * @implements {SchemaValidator}
15
- */
16
- declare class TypeboxSchemaValidator implements SchemaValidator$1<(<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 TUnionContainer>(schemas: [...T]) => TUnion<UnionTResolve<T>>, <T extends LiteralSchema>(value: T) => TLiteral<T>, <T extends Record<string, LiteralSchema>>(schemaEnum: T) => TUnion<[
17
- {
18
- [K in keyof T]: TLiteral<T[K]>;
19
- }[keyof T]
20
- ]>, (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> {
21
- _Type: "TypeBox";
22
- _SchemaCatchall: TSchema;
23
- _ValidSchemaObject: TObject<TProperties> | TArray<TObject<TProperties>>;
24
- string: _sinclair_typebox.TString;
25
- uuid: _sinclair_typebox.TString;
26
- uri: _sinclair_typebox.TString;
27
- email: _sinclair_typebox.TString;
28
- number: _sinclair_typebox.TTransform<TUnion<[_sinclair_typebox.TNumber, _sinclair_typebox.TString, _sinclair_typebox.TBoolean, _sinclair_typebox.TNull, _sinclair_typebox.TDate, _sinclair_typebox.TBigInt]>, number>;
29
- bigint: _sinclair_typebox.TTransform<TUnion<[_sinclair_typebox.TBigInt, _sinclair_typebox.TNumber, _sinclair_typebox.TString, _sinclair_typebox.TBoolean, _sinclair_typebox.TDate]>, bigint>;
30
- boolean: _sinclair_typebox.TTransform<TUnion<[_sinclair_typebox.TBoolean, _sinclair_typebox.TString]>, boolean>;
31
- date: _sinclair_typebox.TTransform<TUnion<[_sinclair_typebox.TDate, _sinclair_typebox.TNumber, _sinclair_typebox.TString, _sinclair_typebox.TBoolean, _sinclair_typebox.TNull]>, Date>;
32
- symbol: _sinclair_typebox.TSymbol;
33
- nullish: TUnion<[_sinclair_typebox.TVoid, _sinclair_typebox.TNull, _sinclair_typebox.TUndefined]>;
34
- any: _sinclair_typebox.TAny;
35
- unknown: _sinclair_typebox.TUnknown;
36
- never: _sinclair_typebox.TNever;
37
- /**
38
- * Extracts the error type of a schema for error messages.
39
- *
40
- * @param {TCatchall} schema - A schema that contains some type information.
41
- * @returns The type of the schema for error messages.
42
- */
43
- private errorType;
44
- /**
45
- * Compiles schema if this exists, for optimal performance.
46
- *
47
- * @param {TObject<TProperties>} schema - The schema to compile.
48
- * @returns {TypeCheck<T>} - The compiled schema.
49
- */
50
- compile<T extends TObject<TProperties>>(schema: T): TypeCheck<T>;
51
- /**
52
- * Convert a schema to a TypeBox schema.
53
- * @param {TIdiomaticSchema} schema - The schema to convert.
54
- * @returns {TResolve<T>} The resolved schema.
55
- */
56
- schemify<T extends TIdiomaticSchema>(schema: T): TResolve<T>;
57
- /**
58
- * Make a schema optional.
59
- * @param {TIdiomaticSchema} schema - The schema to make optional.
60
- * @returns {TOptional<TResolve<T>>} The optional schema.
61
- */
62
- optional<T extends TIdiomaticSchema>(schema: T): TOptional<TResolve<T>>;
63
- /**
64
- * Create an array schema.
65
- * @param {TIdiomaticSchema} schema - The schema to use for array items.
66
- * @returns {TArray<TResolve<T>>} The array schema.
67
- */
68
- array<T extends TIdiomaticSchema>(schema: T): TArray<TResolve<T>>;
69
- /**
70
- * Create a union schema.
71
- * @param {TUnionContainer} schemas - The schemas to union.
72
- * @returns {TUnion<UnionTResolve<T>>} The union schema.
73
- *
74
- * WARNING: If "nullish" or TUndefined is included in the union, the key will still be expected.
75
- * This is a limitation of TypeBox. Consider using "optional" instead.
76
- */
77
- union<T extends TUnionContainer>(schemas: [...T]): TUnion<UnionTResolve<T>>;
78
- /**
79
- * Create a literal schema.
80
- * @param {LiteralSchema} value - The literal value.
81
- * @returns {TLiteral<T>} The literal schema.
82
- */
83
- literal<T extends LiteralSchema>(value: T): TLiteral<T>;
84
- /**
85
- * Create an enum schema.
86
- * @param {Record<string, LiteralSchema>} schemaEnum - The enum schema.
87
- * @returns {TUnion<UnionTResolve<T[]>>} The enum schema.
88
- */
89
- enum_<T extends Record<string, LiteralSchema>>(schemaEnum: T): TUnion<[
90
- {
91
- [K in keyof T]: TLiteral<T[K]>;
92
- }[keyof T]
93
- ]>;
94
- /**
95
- * Check if a value is a TypeBox object schema.
96
- * @param {unknown} value - The value to check.
97
- * @returns {boolean} True if the value is a TypeBox object schema.
98
- */
99
- isSchema(value: unknown): value is TSchema;
100
- /**
101
- * Validate a value against a schema.
102
- *
103
- * @param {TSchema} schema - The schema to validate against.
104
- * @param {unknown} value - The value to validate.
105
- * @returns {boolean} True if valid, otherwise false.
106
- */
107
- validate<T extends TIdiomaticSchema | TSchema>(schema: T | TypeCheck<TResolve<T>>, value: unknown): boolean;
108
- /**
109
- * Parse a value against a schema.
110
- *
111
- * @param {TSchema} schema - The schema to validate against.
112
- * @param {unknown} value - The value to validate.
113
- * @returns {ParseResult<TResolve<T>>} The parsing result.
114
- */
115
- parse<T extends TIdiomaticSchema | TSchema>(schema: T | TypeCheck<TResolve<T>>, value: unknown): ParseResult<TResolve<T>>;
116
- /**
117
- * Convert a schema to an OpenAPI schema object.
118
- * @param {TIdiomaticSchema | TSchema} schema - The schema to convert.
119
- * @returns {SchemaObject} The OpenAPI schema object.
120
- */
121
- openapi<T extends TIdiomaticSchema | TSchema>(schema: T): SchemaObject;
122
- }
123
-
124
9
  /**
125
10
  * Factory function for creating a TypeboxSchemaValidator instance.
126
11
  * @returns {TypeboxSchemaValidator} The TypeboxSchemaValidator instance.
@@ -209,14 +94,14 @@ declare const isSchema: (value: unknown) => value is _sinclair_typebox.TSchema;
209
94
  /**
210
95
  * Validates a value against a valid schema.
211
96
  */
212
- declare const validate: <T extends TIdiomaticSchema | _sinclair_typebox.TSchema>(schema: T | _sinclair_typebox_compiler.TypeCheck<TResolve<T>>, value: unknown) => boolean;
97
+ declare const validate: <T extends TIdiomaticSchema | TCatchall>(schema: T | _sinclair_typebox_compiler.TypeCheck<TResolve<T>>, value: unknown) => boolean;
213
98
  /**
214
99
  * Parses a value against a valid schema.
215
100
  */
216
- declare const parse: <T extends TIdiomaticSchema | _sinclair_typebox.TSchema>(schema: T | _sinclair_typebox_compiler.TypeCheck<TResolve<T>>, value: unknown) => ParseResult<TResolve<T>>;
101
+ declare const parse: <T extends TIdiomaticSchema | TCatchall>(schema: T | _sinclair_typebox_compiler.TypeCheck<TResolve<T>>, value: unknown) => ParseResult<TResolve<T>>;
217
102
  /**
218
103
  * Generates an OpenAPI schema object from a valid schema.
219
104
  */
220
- declare const openapi: <T extends TIdiomaticSchema | _sinclair_typebox.TSchema>(schema: T) => openapi3_ts_oas31.SchemaObject;
105
+ declare const openapi: <T extends TIdiomaticSchema | TCatchall>(schema: T) => openapi3_ts_oas31.SchemaObject;
221
106
 
222
- export { SchemaValidator, TCatchall, TIdiomaticSchema, TObject, TResolve, TUnionContainer, TypeboxSchemaValidator, UnionTResolve, any, array, bigint, boolean, date, email, enum_, isSchema, literal, never, nullish, number, openapi, optional, parse, schemify, string, symbol, union, unknown, uri, uuid, validate };
107
+ export { SchemaValidator, TCatchall, TIdiomaticSchema, TResolve, TUnionContainer, TypeboxSchemaValidator, UnionTResolve, any, array, bigint, boolean, date, email, enum_, isSchema, literal, never, nullish, number, openapi, optional, parse, schemify, string, symbol, union, unknown, uri, uuid, validate };
@@ -1,126 +1,11 @@
1
1
  import * as openapi3_ts_oas31 from 'openapi3-ts/oas31';
2
- import { SchemaObject } from 'openapi3-ts/oas31';
3
2
  import * as _sinclair_typebox_compiler from '@sinclair/typebox/compiler';
4
- import { TypeCheck } from '@sinclair/typebox/compiler';
5
- import { S as SchemaValidator$1, T as TObject, f as TIdiomaticSchema, g as TResolve, h as TUnionContainer, i as UnionTResolve, L as LiteralSchema, j as TCatchall, a as ParseResult } from '../../schema.types-BA3PeCI5.js';
6
- export { l as TObjectShape, k as TOuterArray, m as TSchemaTranslate, n as UnboxedTObjectSchema } from '../../schema.types-BA3PeCI5.js';
3
+ import { T as TypeboxSchemaValidator, f as TIdiomaticSchema, g as TResolve, h as TUnionContainer, i as UnionTResolve, L as LiteralSchema, j as TCatchall, a as ParseResult } from '../../schema.types-LkSEBFTv.js';
4
+ export { m as TObject, l as TObjectShape, k as TOuterArray, n as TSchemaTranslate, o as UnboxedTObjectSchema } from '../../schema.types-LkSEBFTv.js';
7
5
  import * as _sinclair_typebox from '@sinclair/typebox';
8
- import { TProperties, TOptional, TArray, TUnion, TLiteral, TSchema } from '@sinclair/typebox';
9
6
  import '@forklaunch/common';
10
7
  import 'zod';
11
8
 
12
- /**
13
- * Class representing a TypeBox schema definition.
14
- * @implements {SchemaValidator}
15
- */
16
- declare class TypeboxSchemaValidator implements SchemaValidator$1<(<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 TUnionContainer>(schemas: [...T]) => TUnion<UnionTResolve<T>>, <T extends LiteralSchema>(value: T) => TLiteral<T>, <T extends Record<string, LiteralSchema>>(schemaEnum: T) => TUnion<[
17
- {
18
- [K in keyof T]: TLiteral<T[K]>;
19
- }[keyof T]
20
- ]>, (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> {
21
- _Type: "TypeBox";
22
- _SchemaCatchall: TSchema;
23
- _ValidSchemaObject: TObject<TProperties> | TArray<TObject<TProperties>>;
24
- string: _sinclair_typebox.TString;
25
- uuid: _sinclair_typebox.TString;
26
- uri: _sinclair_typebox.TString;
27
- email: _sinclair_typebox.TString;
28
- number: _sinclair_typebox.TTransform<TUnion<[_sinclair_typebox.TNumber, _sinclair_typebox.TString, _sinclair_typebox.TBoolean, _sinclair_typebox.TNull, _sinclair_typebox.TDate, _sinclair_typebox.TBigInt]>, number>;
29
- bigint: _sinclair_typebox.TTransform<TUnion<[_sinclair_typebox.TBigInt, _sinclair_typebox.TNumber, _sinclair_typebox.TString, _sinclair_typebox.TBoolean, _sinclair_typebox.TDate]>, bigint>;
30
- boolean: _sinclair_typebox.TTransform<TUnion<[_sinclair_typebox.TBoolean, _sinclair_typebox.TString]>, boolean>;
31
- date: _sinclair_typebox.TTransform<TUnion<[_sinclair_typebox.TDate, _sinclair_typebox.TNumber, _sinclair_typebox.TString, _sinclair_typebox.TBoolean, _sinclair_typebox.TNull]>, Date>;
32
- symbol: _sinclair_typebox.TSymbol;
33
- nullish: TUnion<[_sinclair_typebox.TVoid, _sinclair_typebox.TNull, _sinclair_typebox.TUndefined]>;
34
- any: _sinclair_typebox.TAny;
35
- unknown: _sinclair_typebox.TUnknown;
36
- never: _sinclair_typebox.TNever;
37
- /**
38
- * Extracts the error type of a schema for error messages.
39
- *
40
- * @param {TCatchall} schema - A schema that contains some type information.
41
- * @returns The type of the schema for error messages.
42
- */
43
- private errorType;
44
- /**
45
- * Compiles schema if this exists, for optimal performance.
46
- *
47
- * @param {TObject<TProperties>} schema - The schema to compile.
48
- * @returns {TypeCheck<T>} - The compiled schema.
49
- */
50
- compile<T extends TObject<TProperties>>(schema: T): TypeCheck<T>;
51
- /**
52
- * Convert a schema to a TypeBox schema.
53
- * @param {TIdiomaticSchema} schema - The schema to convert.
54
- * @returns {TResolve<T>} The resolved schema.
55
- */
56
- schemify<T extends TIdiomaticSchema>(schema: T): TResolve<T>;
57
- /**
58
- * Make a schema optional.
59
- * @param {TIdiomaticSchema} schema - The schema to make optional.
60
- * @returns {TOptional<TResolve<T>>} The optional schema.
61
- */
62
- optional<T extends TIdiomaticSchema>(schema: T): TOptional<TResolve<T>>;
63
- /**
64
- * Create an array schema.
65
- * @param {TIdiomaticSchema} schema - The schema to use for array items.
66
- * @returns {TArray<TResolve<T>>} The array schema.
67
- */
68
- array<T extends TIdiomaticSchema>(schema: T): TArray<TResolve<T>>;
69
- /**
70
- * Create a union schema.
71
- * @param {TUnionContainer} schemas - The schemas to union.
72
- * @returns {TUnion<UnionTResolve<T>>} The union schema.
73
- *
74
- * WARNING: If "nullish" or TUndefined is included in the union, the key will still be expected.
75
- * This is a limitation of TypeBox. Consider using "optional" instead.
76
- */
77
- union<T extends TUnionContainer>(schemas: [...T]): TUnion<UnionTResolve<T>>;
78
- /**
79
- * Create a literal schema.
80
- * @param {LiteralSchema} value - The literal value.
81
- * @returns {TLiteral<T>} The literal schema.
82
- */
83
- literal<T extends LiteralSchema>(value: T): TLiteral<T>;
84
- /**
85
- * Create an enum schema.
86
- * @param {Record<string, LiteralSchema>} schemaEnum - The enum schema.
87
- * @returns {TUnion<UnionTResolve<T[]>>} The enum schema.
88
- */
89
- enum_<T extends Record<string, LiteralSchema>>(schemaEnum: T): TUnion<[
90
- {
91
- [K in keyof T]: TLiteral<T[K]>;
92
- }[keyof T]
93
- ]>;
94
- /**
95
- * Check if a value is a TypeBox object schema.
96
- * @param {unknown} value - The value to check.
97
- * @returns {boolean} True if the value is a TypeBox object schema.
98
- */
99
- isSchema(value: unknown): value is TSchema;
100
- /**
101
- * Validate a value against a schema.
102
- *
103
- * @param {TSchema} schema - The schema to validate against.
104
- * @param {unknown} value - The value to validate.
105
- * @returns {boolean} True if valid, otherwise false.
106
- */
107
- validate<T extends TIdiomaticSchema | TSchema>(schema: T | TypeCheck<TResolve<T>>, value: unknown): boolean;
108
- /**
109
- * Parse a value against a schema.
110
- *
111
- * @param {TSchema} schema - The schema to validate against.
112
- * @param {unknown} value - The value to validate.
113
- * @returns {ParseResult<TResolve<T>>} The parsing result.
114
- */
115
- parse<T extends TIdiomaticSchema | TSchema>(schema: T | TypeCheck<TResolve<T>>, value: unknown): ParseResult<TResolve<T>>;
116
- /**
117
- * Convert a schema to an OpenAPI schema object.
118
- * @param {TIdiomaticSchema | TSchema} schema - The schema to convert.
119
- * @returns {SchemaObject} The OpenAPI schema object.
120
- */
121
- openapi<T extends TIdiomaticSchema | TSchema>(schema: T): SchemaObject;
122
- }
123
-
124
9
  /**
125
10
  * Factory function for creating a TypeboxSchemaValidator instance.
126
11
  * @returns {TypeboxSchemaValidator} The TypeboxSchemaValidator instance.
@@ -209,14 +94,14 @@ declare const isSchema: (value: unknown) => value is _sinclair_typebox.TSchema;
209
94
  /**
210
95
  * Validates a value against a valid schema.
211
96
  */
212
- declare const validate: <T extends TIdiomaticSchema | _sinclair_typebox.TSchema>(schema: T | _sinclair_typebox_compiler.TypeCheck<TResolve<T>>, value: unknown) => boolean;
97
+ declare const validate: <T extends TIdiomaticSchema | TCatchall>(schema: T | _sinclair_typebox_compiler.TypeCheck<TResolve<T>>, value: unknown) => boolean;
213
98
  /**
214
99
  * Parses a value against a valid schema.
215
100
  */
216
- declare const parse: <T extends TIdiomaticSchema | _sinclair_typebox.TSchema>(schema: T | _sinclair_typebox_compiler.TypeCheck<TResolve<T>>, value: unknown) => ParseResult<TResolve<T>>;
101
+ declare const parse: <T extends TIdiomaticSchema | TCatchall>(schema: T | _sinclair_typebox_compiler.TypeCheck<TResolve<T>>, value: unknown) => ParseResult<TResolve<T>>;
217
102
  /**
218
103
  * Generates an OpenAPI schema object from a valid schema.
219
104
  */
220
- declare const openapi: <T extends TIdiomaticSchema | _sinclair_typebox.TSchema>(schema: T) => openapi3_ts_oas31.SchemaObject;
105
+ declare const openapi: <T extends TIdiomaticSchema | TCatchall>(schema: T) => openapi3_ts_oas31.SchemaObject;
221
106
 
222
- export { SchemaValidator, TCatchall, TIdiomaticSchema, TObject, TResolve, TUnionContainer, TypeboxSchemaValidator, UnionTResolve, any, array, bigint, boolean, date, email, enum_, isSchema, literal, never, nullish, number, openapi, optional, parse, schemify, string, symbol, union, unknown, uri, uuid, validate };
107
+ export { SchemaValidator, TCatchall, TIdiomaticSchema, TResolve, TUnionContainer, TypeboxSchemaValidator, UnionTResolve, any, array, bigint, boolean, date, email, enum_, isSchema, literal, never, nullish, number, openapi, optional, parse, schemify, string, symbol, union, unknown, uri, uuid, validate };
@@ -68,7 +68,6 @@ var TypeboxSchemaValidator = class {
68
68
  _SchemaCatchall;
69
69
  _ValidSchemaObject;
70
70
  string = import_typebox.Type.String();
71
- // uuid = Type.String({ format: 'uuid' });
72
71
  uuid = import_typebox.Type.String({
73
72
  pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$",
74
73
  errorType: "uuid"
@@ -191,7 +190,7 @@ var TypeboxSchemaValidator = class {
191
190
  * @returns The type of the schema for error messages.
192
191
  */
193
192
  errorType(schema) {
194
- if (Object.hasOwn(schema, "errorType")) {
193
+ if (import_typebox.KindGuard.IsSchema(schema) && Object.hasOwn(schema, "errorType")) {
195
194
  return schema.errorType;
196
195
  } else if (import_typebox.KindGuard.IsLiteral(schema)) {
197
196
  return schema.const;
@@ -374,7 +373,7 @@ var TypeboxSchemaValidator = class {
374
373
  }
375
374
  /**
376
375
  * Convert a schema to an OpenAPI schema object.
377
- * @param {TIdiomaticSchema | TSchema} schema - The schema to convert.
376
+ * @param {TIdiomaticSchema | TCatchall} schema - The schema to convert.
378
377
  * @returns {SchemaObject} The OpenAPI schema object.
379
378
  */
380
379
  openapi(schema) {
@@ -27,7 +27,6 @@ var TypeboxSchemaValidator = class {
27
27
  _SchemaCatchall;
28
28
  _ValidSchemaObject;
29
29
  string = Type.String();
30
- // uuid = Type.String({ format: 'uuid' });
31
30
  uuid = Type.String({
32
31
  pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$",
33
32
  errorType: "uuid"
@@ -150,7 +149,7 @@ var TypeboxSchemaValidator = class {
150
149
  * @returns The type of the schema for error messages.
151
150
  */
152
151
  errorType(schema) {
153
- if (Object.hasOwn(schema, "errorType")) {
152
+ if (KindGuard.IsSchema(schema) && Object.hasOwn(schema, "errorType")) {
154
153
  return schema.errorType;
155
154
  } else if (KindGuard.IsLiteral(schema)) {
156
155
  return schema.const;
@@ -333,7 +332,7 @@ var TypeboxSchemaValidator = class {
333
332
  }
334
333
  /**
335
334
  * Convert a schema to an OpenAPI schema object.
336
- * @param {TIdiomaticSchema | TSchema} schema - The schema to convert.
335
+ * @param {TIdiomaticSchema | TCatchall} schema - The schema to convert.
337
336
  * @returns {SchemaObject} The OpenAPI schema object.
338
337
  */
339
338
  openapi(schema) {
@@ -1,6 +1,6 @@
1
1
  import * as openapi3_ts_oas31 from 'openapi3-ts/oas31';
2
- import { Z as ZodSchemaValidator, o as ZodIdiomaticSchema, p as ZodResolve, q as ZodUnionContainer, r as UnionZodResolve, L as LiteralSchema, s as ZodCatchall, a as ParseResult } from '../../schema.types-BA3PeCI5.mjs';
3
- export { x as UnboxedZodObjectSchema, v as ZodObject, u as ZodObjectShape, t as ZodOuterArray, w as ZodSchemaTranslate } from '../../schema.types-BA3PeCI5.mjs';
2
+ import { Z as ZodSchemaValidator, p as ZodIdiomaticSchema, q as ZodResolve, r as ZodUnionContainer, s as UnionZodResolve, L as LiteralSchema, t as ZodCatchall, a as ParseResult } from '../../schema.types-LkSEBFTv.mjs';
3
+ export { y as UnboxedZodObjectSchema, w as ZodObject, v as ZodObjectShape, u as ZodOuterArray, x as ZodSchemaTranslate } from '../../schema.types-LkSEBFTv.mjs';
4
4
  import * as zod from 'zod';
5
5
  import '@forklaunch/common';
6
6
  import '@sinclair/typebox';
@@ -1,6 +1,6 @@
1
1
  import * as openapi3_ts_oas31 from 'openapi3-ts/oas31';
2
- import { Z as ZodSchemaValidator, o as ZodIdiomaticSchema, p as ZodResolve, q as ZodUnionContainer, r as UnionZodResolve, L as LiteralSchema, s as ZodCatchall, a as ParseResult } from '../../schema.types-BA3PeCI5.js';
3
- export { x as UnboxedZodObjectSchema, v as ZodObject, u as ZodObjectShape, t as ZodOuterArray, w as ZodSchemaTranslate } from '../../schema.types-BA3PeCI5.js';
2
+ import { Z as ZodSchemaValidator, p as ZodIdiomaticSchema, q as ZodResolve, r as ZodUnionContainer, s as UnionZodResolve, L as LiteralSchema, t as ZodCatchall, a as ParseResult } from '../../schema.types-LkSEBFTv.js';
3
+ export { y as UnboxedZodObjectSchema, w as ZodObject, v as ZodObjectShape, u as ZodOuterArray, x as ZodSchemaTranslate } from '../../schema.types-LkSEBFTv.js';
4
4
  import * as zod from 'zod';
5
5
  import '@forklaunch/common';
6
6
  import '@sinclair/typebox';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forklaunch/validator",
3
- "version": "0.4.11",
3
+ "version": "0.4.12",
4
4
  "description": "Schema validator for ForkLaunch components.",
5
5
  "homepage": "https://github.com/forklaunch/forklaunch-js#readme",
6
6
  "bugs": {