import { ConfigProvider, Effect, type Layer } from "effect"; import { type OperationError } from "../errors/index.js"; import { ConfigFileNotFoundError, TomlParseError } from "./errors.js"; /** Options shared by the TOML provider constructors. */ export interface TomlProviderOptions { /** Label used in parse errors. Defaults to the file path, or `""`. */ readonly source?: string; /** Set to `false` to read `"a.b"` as one literal key instead of a nested path. */ readonly dotted?: boolean; } /** * Lets a provider answer dotted names (`"paths.main_clone"`) as nested paths. * A digits-only segment is tried as an array index first and as an object key * second, so both `servers.0.name` and a table literally named `0` resolve. */ export declare function withDottedPaths(provider: ConfigProvider.ConfigProvider): ConfigProvider.ConfigProvider; /** Builds a `ConfigProvider` from TOML text. Fails with `TomlParseError`. */ export declare const tomlConfigProvider: (text: string, options?: TomlProviderOptions | undefined) => Effect.Effect; /** * Reads and parses a TOML file. A missing file fails with * `ConfigFileNotFoundError` so a caller can treat it as "no config yet"; * anything else the file system raises stays an `OperationError`. */ export declare const tomlConfigProviderFromFile: (path: string, options?: TomlProviderOptions | undefined) => Effect.Effect; /** Options for the layer constructors. */ export interface TomlLayerOptions extends TomlProviderOptions { /** Treat a missing file as an empty config instead of failing the layer. */ readonly optional?: boolean; } /** * Installs a TOML file as the program's `ConfigProvider`, replacing the default * environment provider. The layer fails if the file is missing, unless * `{ optional: true }`. */ export declare function layerToml(path: string, options?: TomlLayerOptions): Layer.Layer; /** Options for {@link layerTomlWithEnv}. */ export interface TomlWithEnvOptions extends TomlLayerOptions { /** The environment to read. Defaults to the process environment. */ readonly env?: Record; /** * Read the environment in CONSTANT_CASE, so the file key `paths.main_clone` * is overridden by `PATHS_MAIN_CLONE` instead of `paths_main_clone`. * Defaults to `false`, which matches env var names to key names exactly. */ readonly constantCase?: boolean; } /** * The usual CLI shape: values come from the TOML file, and an environment * variable of the same name wins over the file. Pass `env` in tests. * * Environment lookups follow `ConfigProvider.fromEnv`: path segments are * joined with `_`, so a nested key reads `paths_main_clone` unless * `{ constantCase: true }` makes it `PATHS_MAIN_CLONE`. */ export declare function layerTomlWithEnv(path: string, options?: TomlWithEnvOptions): Layer.Layer;