@gguf/claw
Version:
Multi-channel AI gateway with extensible messaging integrations
37 lines (36 loc) • 1.24 kB
TypeScript
/**
* Environment variable substitution for config values.
*
* Supports `${VAR_NAME}` syntax in string values, substituted at config load time.
* - Only uppercase env vars are matched: `[A-Z_][A-Z0-9_]*`
* - Escape with `$${}` to output literal `${}`
* - Missing env vars throw `MissingEnvVarError` with context
*
* @example
* ```json5
* {
* models: {
* providers: {
* "vercel-gateway": {
* apiKey: "${VERCEL_GATEWAY_API_KEY}"
* }
* }
* }
* }
* ```
*/
export declare class MissingEnvVarError extends Error {
readonly varName: string;
readonly configPath: string;
constructor(varName: string, configPath: string);
}
export declare function containsEnvVarReference(value: string): boolean;
/**
* Resolves `${VAR_NAME}` environment variable references in config values.
*
* @param obj - The parsed config object (after JSON5 parse and $include resolution)
* @param env - Environment variables to use for substitution (defaults to process.env)
* @returns The config object with env vars substituted
* @throws {MissingEnvVarError} If a referenced env var is not set or empty
*/
export declare function resolveConfigEnvVars(obj: unknown, env?: NodeJS.ProcessEnv): unknown;