import { ReadStream } from "fs"; declare namespace envex { interface Config { profiles?: ProfilesConfig; } interface ProfilesConfig { [name: string]: ProfileConfig; } interface ProfileConfig { profile?: string | string[]; imports?: string | string[]; cwd?: string; env?: EnvConfig; expose?: ExposeConfig; } /////////////////// ENV //////////////////// type EnvConfig = EnvConfigMap | EnvConfigFunction | EnvConfigList; type EnvConfigList = Array; type EnvConfigFunction = (ctx: EnvBaseContext) => EnvResolved | Promise; interface EnvBaseContext { readonly env: EnvResolved; has(name: string): boolean; } interface EnvConfigMap { [name: string]: EnvVarConfig; } type EnvVarConfig = EnvValue | EnvVarConfigExplicit; interface EnvVarConfigExplicit { required?: boolean; value?: EnvValue; } type EnvValue = T | EnvValueFunction; type EnvValueFunction = (ctx: EnvResolveContext) => T | Promise; interface EnvResolveContext extends EnvBaseContext { resolve(s: string): Promise; } interface EnvResolved { readonly [name: string]: string; } //////////////// EXPOSE ////////////////// type ExposeConfig = ExposeMap | ExposeFunction | ExposeList; type ExposeList = Array; type ExposeFunction = ExposeValueFunction; interface ExposeMap { [name: string]: ExposeVarConfig; } type ExposeVarConfig = ExposeValue | ExposeVarConfigExplicit; interface ExposeVarConfigExplicit { regex?: EnvValue; } type ExposeValue = T | ExposeValueFunction; type ExposeValueFunction = ExposeValueDirectFunction | ExposeValueIndirectFunction; type ExposeValueDirectFunction = (ctx: ExposeContext) => T | Promise; type ExposeValueIndirectFunction = (ctx: ExposeContext, expose: (value: T) => void) => void; interface ExposeContext { readonly env: EnvResolved; readonly tap: ReadStream; } interface ExposeResolved { readonly [name: string]: string; } }