import type { StandardSchemaV1 } from '@standard-schema/spec'; /** Environment variable source read by `validateEnv()` and `validateEnvVar()`. */ export type TEnv = Record; /** Configures how a single environment value is resolved and validated. */ export interface TEnvSpec { /** Environment key to read. Defaults to the output object key. */ envKey?: string; /** Standard Schema-compatible validator for the final value. */ validator: TEnvValidator; /** Default used when the resolved value is `undefined`. */ defaultValue?: GInput | TEnvDefaultFn; /** Cleans the raw value before defaults and validation run. */ preprocess?: TEnvPreprocess; /** Extra context added to validation errors. */ description?: string; /** Valid value example added to validation errors. */ example?: string; } /** Standard Schema-compatible validator used by an env spec. */ export type TEnvValidator = StandardSchemaV1; /** Cleans a raw env value before defaults and validation run. */ export type TEnvPreprocess = (value: unknown) => GValue | undefined; /** Computes a default value from the full env source. */ export type TEnvDefaultFn = (env: TEnv) => GValue | undefined; /** Env spec object accepted by `validateEnv()`, `createEnv()`, and `createViteEnvDefine()`. */ export type TEnvSpecs> = GSpecs & TEnvSpecEntriesConstraint; type TEnvSpecEntriesConstraint> = { [Key in keyof GSpecs]: TEnvSpecEntryConstraint; }; type TEnvSpecEntryConstraint = GSpecEntry extends { validator: infer GValidator; } ? GValidator extends TEnvValidator ? TEnvSpec : never : GSpecEntry extends TEnvValidator ? TEnvValidator : GSpecEntry; /** Validated env object returned from a spec object. */ export type TEnvData> = { [Key in keyof GSpecs]: TEnvSpecEntryOutput; }; type TEnvSpecEntryOutput = GSpecEntry extends TEnvSpec ? GOutput : GSpecEntry extends TEnvValidator ? GOutput : GSpecEntry; export {}; //# sourceMappingURL=types.d.ts.map