@suluk/env - v0.2.0
    Preparing search index...

    Interface DefinedEnv<S>

    interface DefinedEnv<S extends EnvSpec> {
        spec: S;
        keys: (keyof S & string)[];
        parse(source?: Record<string, string | undefined>): Parsed<S>;
        forSurface(surface: Surface): (keyof S & string)[];
        validate(
            source?: Record<string, string | undefined>,
            opts?: AssertOptions,
        ): EnvIssue[];
        assertEnv(
            source?: Record<string, string | undefined>,
            opts?: AssertOptions,
        ): Parsed<S>;
        manifest(
            raw?: Record<string, string | undefined>,
            runtime?: Record<string, string | undefined>,
        ): ManifestEntry[];
    }

    Type Parameters

    Index

    Properties

    spec: S
    keys: (keyof S & string)[]

    Methods

    • validate a source (process.env or a parsed .env), apply defaults, throw on a missing required var.

      Parameters

      • Optionalsource: Record<string, string | undefined>

      Returns Parsed<S>

    • the var names a given surface needs (for the deploy planner / vscode).

      Parameters

      Returns (keyof S & string)[]

    • validate VALUES (presence incl. requiredInSurface, minLength, pattern, forbidInSurface) → a graded issue list.

      Parameters

      • Optionalsource: Record<string, string | undefined>
      • Optionalopts: AssertOptions

      Returns EnvIssue[]

    • FAIL-CLOSED gate: throw on any error-severity issue (warnings go to onWarn); else return the parsed config. Call at startup so a misconfigured/short/test secret in prod stops the process instead of shipping.

      Parameters

      • Optionalsource: Record<string, string | undefined>
      • Optionalopts: AssertOptions

      Returns Parsed<S>

    • config health, computed from the RAW .env record (raw = parseEnv(fileContent), so secret values are still encrypted tokens). Pass the runtime env too if you want presence to also count vars set outside the file.

      Parameters

      • Optionalraw: Record<string, string | undefined>
      • Optionalruntime: Record<string, string | undefined>

      Returns ManifestEntry[]