envin 1.1.7 → 1.1.8
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/types.d.ts +11 -6
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -90,17 +90,22 @@ type Mutable<T> = T extends Readonly<infer U> ? U : T;
|
|
|
90
90
|
type ExtractExtendsArray<T> = T extends {
|
|
91
91
|
extends?: infer E;
|
|
92
92
|
} ? E extends ExtendsFormat ? E : [] : [];
|
|
93
|
-
type
|
|
93
|
+
type Depth = 0 | 1 | 2 | 3 | 4;
|
|
94
|
+
type DefaultDepth = 2;
|
|
95
|
+
type Prev = [0, 0, 1, 2, 3];
|
|
96
|
+
type Dec<N extends Depth> = Prev[N];
|
|
97
|
+
type AsDictionary<T> = T extends object ? StandardSchemaDictionary<object, object> & T : StandardSchemaDictionary<object, object>;
|
|
98
|
+
type ExtractCombinedSchema<T, D extends Depth = DefaultDepth> = T extends ValidationOptions<PrefixFormat, infer Shared, infer Server, infer Client> ? CombinedSchema<AsDictionary<Reduce<ExtractExtendsArray<T>, StandardSchemaDictionary<object, object>, D>>, AsDictionary<CombinedSchema<Shared, Server, Client>>> : T extends Readonly<ValidationOptions<PrefixFormat, infer Shared, infer Server, infer Client>> ? CombinedSchema<AsDictionary<Reduce<ExtractExtendsArray<T>, StandardSchemaDictionary<object, object>, D>>, AsDictionary<CombinedSchema<Shared, Server, Client>>> : CombinedSchema<AsDictionary<Reduce<ExtractExtendsArray<T>, StandardSchemaDictionary<object, object>, D>>, AsDictionary<CombinedSchema<T extends {
|
|
94
99
|
shared: infer S;
|
|
95
100
|
} ? S extends SharedFormat ? S : StandardSchemaDictionary<object, object> : StandardSchemaDictionary<object, object>, T extends {
|
|
96
101
|
server: infer Sv;
|
|
97
102
|
} ? Sv extends ServerFormat ? Sv : StandardSchemaDictionary<object, object> : StandardSchemaDictionary<object, object>, T extends {
|
|
98
103
|
client: infer C;
|
|
99
|
-
} ? C extends ClientFormat ? C : StandardSchemaDictionary<object, object> : StandardSchemaDictionary<object, object
|
|
104
|
+
} ? C extends ClientFormat ? C : StandardSchemaDictionary<object, object> : StandardSchemaDictionary<object, object>>>>;
|
|
100
105
|
/** Reduces an array of schemas to a single schema */
|
|
101
|
-
type Reduce<Arr extends readonly unknown[] | unknown[], Acc extends StandardSchemaDictionary<object, object> = StandardSchemaDictionary<object, object
|
|
106
|
+
type Reduce<Arr extends readonly unknown[] | unknown[], Acc extends StandardSchemaDictionary<object, object> = StandardSchemaDictionary<object, object>, D extends Depth = DefaultDepth> = D extends 0 ? Acc : Arr extends readonly [] | [] ? Acc : Arr extends readonly [infer Head, ...infer Tail] | [infer Head, ...infer Tail] ? Tail extends readonly unknown[] | unknown[] ? Mutable<Reduce<Tail, CombinedSchema<AsDictionary<Acc>, AsDictionary<ExtractCombinedSchema<Head, Dec<D>>>>, D>> : never : never;
|
|
102
107
|
type InferPresetOutput<T extends ExtendsFormat[number]> = StandardSchemaDictionary.InferOutput<ExtractCombinedSchema<T>>;
|
|
103
|
-
type CombinedSchema<Shared extends SharedFormat = SharedFormat, Server extends ServerFormat = ServerFormat, Client extends ClientFormat = ClientFormat> = Merge<Shared, Merge<Server, Client>>;
|
|
108
|
+
type CombinedSchema<Shared extends SharedFormat = SharedFormat, Server extends ServerFormat = ServerFormat, Client extends ClientFormat = ClientFormat> = StandardSchemaDictionary<object, object> & Merge<Shared, Merge<Server, Client>>;
|
|
104
109
|
type PrefixFormat = string | undefined;
|
|
105
110
|
type SharedFormat = StandardSchemaDictionary<object, object>;
|
|
106
111
|
type ServerFormat = StandardSchemaDictionary<object, object>;
|
|
@@ -204,8 +209,8 @@ interface TransformSchemaOptions<Shared extends SharedFormat, Server extends Ser
|
|
|
204
209
|
transform?: (shape: Simplify<FullSchemaShape<Shared, Server, Client, Extends>>, isServer: boolean) => FinalSchema;
|
|
205
210
|
}
|
|
206
211
|
type EnvOptions<Prefix extends PrefixFormat = PrefixFormat, Shared extends SharedFormat = SharedFormat, Server extends ServerFormat = ServerFormat, Client extends ClientFormat = ClientFormat, Extends extends ExtendsFormat = ExtendsFormat, FinalSchema extends Schema = Schema> = (LooseOptions<Extends> | StrictOptions<Prefix, Server, Client, Shared, Extends>) & ValidationOptions<Prefix, Shared, Server, Client> & TransformSchemaOptions<Shared, Server, Client, Extends, FinalSchema>;
|
|
207
|
-
type FullSchemaShape<Shared extends SharedFormat, Server extends ServerFormat, Client extends ClientFormat, Extends extends ExtendsFormat> = CombinedSchema<Reduce<Extends>, CombinedSchema<Shared, Server, Client>>;
|
|
208
|
-
type FinalSchema<Shared extends SharedFormat, Server extends ServerFormat, Client extends ClientFormat, Extends extends ExtendsFormat> = StandardSchemaV1<object, UndefinedOptional<StandardSchemaDictionary.InferOutput<FullSchemaShape<Shared, Server, Client, Extends>>>>;
|
|
212
|
+
type FullSchemaShape<Shared extends SharedFormat, Server extends ServerFormat, Client extends ClientFormat, Extends extends ExtendsFormat, D extends Depth = DefaultDepth> = CombinedSchema<AsDictionary<Reduce<Extends, StandardSchemaDictionary<object, object>, D>>, CombinedSchema<Shared, Server, Client>>;
|
|
213
|
+
type FinalSchema<Shared extends SharedFormat, Server extends ServerFormat, Client extends ClientFormat, Extends extends ExtendsFormat, D extends Depth = DefaultDepth> = StandardSchemaV1<object, UndefinedOptional<StandardSchemaDictionary.InferOutput<FullSchemaShape<Shared, Server, Client, Extends, D>>>>;
|
|
209
214
|
type DefineEnv<FinalSchema extends Schema = Schema> = Simplify<Readonly<StandardSchemaV1.InferOutput<FinalSchema> & {
|
|
210
215
|
_schema: FinalSchema;
|
|
211
216
|
}>>;
|