envin 1.1.7 → 1.1.9

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.
@@ -154,7 +154,7 @@ declare const netlify: {
154
154
  readonly server: {
155
155
  readonly NETLIFY: arktype.BaseType<string | undefined, {}>;
156
156
  readonly BUILD_ID: arktype.BaseType<string | undefined, {}>;
157
- readonly CONTEXT: arktype.BaseType<"dev" | "production" | "deploy-preview" | "branch-deploy" | undefined, {}>;
157
+ readonly CONTEXT: arktype.BaseType<"production" | "deploy-preview" | "branch-deploy" | "dev" | undefined, {}>;
158
158
  readonly REPOSITORY_URL: arktype.BaseType<string | undefined, {}>;
159
159
  readonly BRANCH: arktype.BaseType<string | undefined, {}>;
160
160
  readonly URL: arktype.BaseType<string | undefined, {}>;
@@ -169,10 +169,10 @@ declare const netlify: {
169
169
  readonly NETLIFY: z.ZodOptional<z.ZodString>;
170
170
  readonly BUILD_ID: z.ZodOptional<z.ZodString>;
171
171
  readonly CONTEXT: z.ZodOptional<z.ZodEnum<{
172
- dev: "dev";
173
172
  production: "production";
174
173
  "deploy-preview": "deploy-preview";
175
174
  "branch-deploy": "branch-deploy";
175
+ dev: "dev";
176
176
  }>>;
177
177
  readonly REPOSITORY_URL: z.ZodOptional<z.ZodString>;
178
178
  readonly BRANCH: z.ZodOptional<z.ZodString>;
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 ExtractCombinedSchema<T> = T extends ValidationOptions<PrefixFormat, infer Shared, infer Server, infer Client> ? CombinedSchema<Reduce<ExtractExtendsArray<T>>, CombinedSchema<Shared, Server, Client>> : T extends Readonly<ValidationOptions<PrefixFormat, infer Shared, infer Server, infer Client>> ? CombinedSchema<Reduce<ExtractExtendsArray<T>>, CombinedSchema<Shared, Server, Client>> : CombinedSchema<Reduce<ExtractExtendsArray<T>>, CombinedSchema<T extends {
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>> = Arr extends readonly [] | [] ? Acc : Arr extends readonly [infer Head, ...infer Tail] | [infer Head, ...infer Tail] ? Tail extends readonly unknown[] | unknown[] ? Mutable<Reduce<Tail, CombinedSchema<Acc, ExtractCombinedSchema<Head>>>> : never : never;
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>;
@@ -160,7 +165,7 @@ interface StrictOptions<Prefix extends PrefixFormat, Server extends ServerFormat
160
165
  [Key in keyof Server]: Prefix extends undefined ? Key : Key extends `${Prefix}${string}` ? never : Key;
161
166
  }[keyof Server] | {
162
167
  [Key in keyof Shared]: Key extends string ? Key : never;
163
- }[keyof Shared], string | boolean | number | undefined>;
168
+ }[keyof Shared] | keyof StandardSchemaDictionary.InferOutput<FullSchemaShape<Shared, Server, Client, Extends>>, string | boolean | number | undefined>;
164
169
  /**
165
170
  * Must be undefined when using strict options. Use `envStrict` instead.
166
171
  */
@@ -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
  }>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "envin",
3
- "version": "1.1.7",
3
+ "version": "1.1.9",
4
4
  "description": "Type-safe env validation with live previews",
5
5
  "keywords": [
6
6
  "turbostarter",