@forklaunch/validator 0.1.14 → 0.1.15
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/index.d.ts +9 -14
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -11,18 +11,13 @@ import { TCatchall, TObject, TObjectShape, TOuterArray, TResolve, TSchemaTransla
|
|
|
11
11
|
import { IdiomaticSchema } from "./types/schema.types";
|
|
12
12
|
import { ZodSchemaValidator } from "./zod";
|
|
13
13
|
import { ZodCatchall, ZodObject, ZodObjectShape, ZodOuterArray, ZodResolve, ZodSchemaTranslate } from "./zod/types/zod.schema.types";
|
|
14
|
-
/**
|
|
15
|
-
* Interface representing any schema validator.
|
|
16
|
-
* Extends the SchemaValidator interface with any schema types.
|
|
17
|
-
*/
|
|
18
|
-
type AnySchemaValidator = SchemaValidator;
|
|
19
14
|
/**
|
|
20
15
|
* Type alias for a schema object shape.
|
|
21
16
|
* Resolves to ZodObjectShape for Zod schemas and TObjectShape for TypeBox schemas.
|
|
22
17
|
*
|
|
23
18
|
* @template SV - SchemaValidator type.
|
|
24
19
|
*/
|
|
25
|
-
type SchemaObjectShape<SV extends
|
|
20
|
+
type SchemaObjectShape<SV extends SchemaValidator> = (SV extends ZodSchemaValidator ? ZodObjectShape : SV extends TypeboxSchemaValidator ? TObjectShape : never);
|
|
26
21
|
/**
|
|
27
22
|
* Type alias for a schema object.
|
|
28
23
|
* Resolves to ZodObject for Zod schemas and TObject for TypeBox schemas.
|
|
@@ -30,7 +25,7 @@ type SchemaObjectShape<SV extends AnySchemaValidator> = (SV extends ZodSchemaVal
|
|
|
30
25
|
* @template T - Schema object shape.
|
|
31
26
|
* @template SV - SchemaValidator type.
|
|
32
27
|
*/
|
|
33
|
-
type SchemaObject<T extends SchemaObjectShape<SV>, SV extends
|
|
28
|
+
type SchemaObject<T extends SchemaObjectShape<SV>, SV extends SchemaValidator> = (SV extends ZodSchemaValidator ? ZodObject<T> : SV extends TypeboxSchemaValidator ? TObject<T> : never);
|
|
34
29
|
/**
|
|
35
30
|
* Type alias for a schema outer array.
|
|
36
31
|
* Resolves to ZodOuterArray for Zod schemas and TOuterArray for TypeBox schemas.
|
|
@@ -38,7 +33,7 @@ type SchemaObject<T extends SchemaObjectShape<SV>, SV extends AnySchemaValidator
|
|
|
38
33
|
* @template T - Schema object.
|
|
39
34
|
* @template SV - SchemaValidator type.
|
|
40
35
|
*/
|
|
41
|
-
type SchemaOuterArray<T extends SchemaObject<SchemaObjectShape<SV>, SV>, SV extends
|
|
36
|
+
type SchemaOuterArray<T extends SchemaObject<SchemaObjectShape<SV>, SV>, SV extends SchemaValidator> = (SV extends ZodSchemaValidator ? ZodOuterArray<T> : SV extends TypeboxSchemaValidator ? TOuterArray<T> : never);
|
|
42
37
|
/**
|
|
43
38
|
* Type alias for resolving a schema.
|
|
44
39
|
* Resolves to ZodResolve for Zod schemas and TResolve for TypeBox schemas.
|
|
@@ -46,7 +41,7 @@ type SchemaOuterArray<T extends SchemaObject<SchemaObjectShape<SV>, SV>, SV exte
|
|
|
46
41
|
* @template T - Schema type.
|
|
47
42
|
* @template SV - SchemaValidator type.
|
|
48
43
|
*/
|
|
49
|
-
type SchemaResolve<T, SV extends
|
|
44
|
+
type SchemaResolve<T, SV extends SchemaValidator> = (SV extends ZodSchemaValidator ? ZodResolve<T> : SV extends TypeboxSchemaValidator ? TResolve<T> : never);
|
|
50
45
|
/**
|
|
51
46
|
* Type alias for translating a schema.
|
|
52
47
|
* Resolves to ZodSchemaTranslate for Zod schemas and TSchemaTranslate for TypeBox schemas.
|
|
@@ -54,7 +49,7 @@ type SchemaResolve<T, SV extends AnySchemaValidator> = (SV extends ZodSchemaVali
|
|
|
54
49
|
* @template T - Schema type.
|
|
55
50
|
* @template SV - SchemaValidator type.
|
|
56
51
|
*/
|
|
57
|
-
type SchemaTranslate<T, SV extends
|
|
52
|
+
type SchemaTranslate<T, SV extends SchemaValidator> = (SV extends ZodSchemaValidator ? ZodSchemaTranslate<T> : SV extends TypeboxSchemaValidator ? TSchemaTranslate<T> : never);
|
|
58
53
|
/**
|
|
59
54
|
* Type alias for prettifying a schema translation.
|
|
60
55
|
* Uses the Prettify utility from @forklaunch/common.
|
|
@@ -62,21 +57,21 @@ type SchemaTranslate<T, SV extends AnySchemaValidator> = (SV extends ZodSchemaVa
|
|
|
62
57
|
* @template T - Schema type.
|
|
63
58
|
* @template SV - SchemaValidator type.
|
|
64
59
|
*/
|
|
65
|
-
type SchemaPrettify<T, SV extends
|
|
60
|
+
type SchemaPrettify<T, SV extends SchemaValidator> = Prettify<SchemaTranslate<T, SV>>;
|
|
66
61
|
/**
|
|
67
62
|
* Type alias for a schema catchall type.
|
|
68
63
|
* Resolves to ZodCatchall for Zod schemas and TCatchall for TypeBox schemas.
|
|
69
64
|
*
|
|
70
65
|
* @template SV - SchemaValidator type.
|
|
71
66
|
*/
|
|
72
|
-
export type SchemaCatchall<SV extends
|
|
67
|
+
export type SchemaCatchall<SV extends SchemaValidator> = (SV extends ZodSchemaValidator ? ZodCatchall : SV extends TypeboxSchemaValidator ? TCatchall : never);
|
|
73
68
|
/**
|
|
74
69
|
* Type alias for a valid schema object.
|
|
75
70
|
* Can be a schema object or a schema outer array.
|
|
76
71
|
*
|
|
77
72
|
* @template SV - SchemaValidator type.
|
|
78
73
|
*/
|
|
79
|
-
export type ValidSchemaObject<SV extends
|
|
74
|
+
export type ValidSchemaObject<SV extends SchemaValidator> = SchemaObject<SchemaObjectShape<SV>, SV> | SchemaOuterArray<SchemaObject<SchemaObjectShape<SV>, SV>, SV>;
|
|
80
75
|
/**
|
|
81
76
|
* Type alias for a schema.
|
|
82
77
|
* Applies prettification to the resolved schema.
|
|
@@ -84,5 +79,5 @@ export type ValidSchemaObject<SV extends AnySchemaValidator> = SchemaObject<Sche
|
|
|
84
79
|
* @template T - Valid schema object or idiomatic schema.
|
|
85
80
|
* @template SV - SchemaValidator type.
|
|
86
81
|
*/
|
|
87
|
-
export type Schema<T extends ValidSchemaObject<SV> | IdiomaticSchema<SchemaCatchall<SV>>, SV extends
|
|
82
|
+
export type Schema<T extends ValidSchemaObject<SV> | IdiomaticSchema<SchemaCatchall<SV>>, SV extends SchemaValidator> = SchemaPrettify<SchemaResolve<T, SV>, SV>;
|
|
88
83
|
export {};
|