import { StandardSchemaDictionary, StandardSchemaV1 } from "./standard.js"; import { Extension, MergedEnvOutput } from "./extension.js"; import { Format, Omit, Partial } from "ts-vista"; /** * The target environment. */ type Target = "client" | "server"; /** * The fields to decide how the environment should be detected. * * By default: * * - `client` - `typeof window !== "undefined" && typeof window.document !== "undefined"` * - `server` - `typeof window === "undefined"` */ type Conditions = { [x in Target]: boolean | (() => boolean) }; /** * The runtime. */ type Runtime = "node" | "deno" | "bun" | "cloudflare" | "browser"; /** * Runtime values. */ type RuntimeEnv = Record; type OnInvalidAccessContextTarget = { expected: Target; current: Target | "unknown"; }; type OnInvalidAccessContext = { target: OnInvalidAccessContextTarget; variable: string; }; /** * The complete options for `createEnv`. */ type CompleteOptions[] = readonly []> = { /** * The target environment for this call. */ target: Target; /** * The fields to decide how the environment should be detected. */ conditions: Conditions; /** * The object holding the environment variables at runtime. */ runtimeEnv: RuntimeEnv; /** * Extensions to be merged. * * Each extension contributes a `define` dictionary that is merged in * array order before validation; the user's `define` wins on key * collision. The parent call resolves `runtimeEnv` once and validates * all keys in a single pass — extension code never touches the runtime * environment. */ extends: Ext; /** * Treat empty strings as `undefined` before validation. * * Useful when a `.env` file produces `KEY=` entries that should fall back * to defaults or be flagged as missing rather than validated as `""`. * * By default, it is `true`. */ emptyStringAsUndefined: boolean; /** * Skip validation and return the raw runtime environment. * * Escape hatch for build-time or CI contexts where the variables are not * present but the module must still load. * * By default, it is `false`. */ skipValidation: boolean; /** * Called when validation fails. * * By default, the issues are bound to the error thrown. */ onValidationError: (issues: readonly StandardSchemaV1.Issue[]) => never; /** * Called when attempted to access a non-supported environment variable. */ onInvalidAccess: (context: OnInvalidAccessContext) => never; /** * The schema dictionary describing the environment variables to validate. * * Each value is a Standard Schema validator (zod, valibot, arktype etc). */ define: Define; }; /** * Options passed to `createEnv`. */ type Options[] = readonly []> = Format, "conditions">, "extends" | "emptyStringAsUndefined" | "skipValidation" | "onInvalidAccess" | "onValidationError">> & { /** * The fields to decide how the environment should be detected. */ conditions?: Partial; }; /** * The output type of `createEnv` for a given schema dictionary and extensions. */ type EnvOutput[] = readonly []> = Readonly>; export type { CompleteOptions, Conditions, EnvOutput, OnInvalidAccessContext, OnInvalidAccessContextTarget, Options, Runtime, RuntimeEnv, Target }; //# sourceMappingURL=options.d.ts.map