import type { AppContext } from './context'; export type DynamicConfigFetcher = (ctx: AppContext) => Promise; interface DynamicConfigBase { interval?: number; /** * Transform raw response data into the stored config value. * Use this to apply defaults, remap fields, or coerce types. */ transform?: (raw: unknown) => unknown; /** * Environment variable containing the final config as JSON. * When non-empty, skips loading from url/filePath/fetch and does not apply transform. * Defaults to NODEKIT_DYNAMIC_CONFIG_ in uppercase, replacing characters * outside A-Z, 0-9, and _ with _. An explicit envVarName is used as-is. */ envVarName?: string; } interface DynamicConfigWithUrl extends DynamicConfigBase { /** Source URL fetched via the built-in HTTP GET. */ url: string; /** Tried in order when the request to `url` fails. Headers are sent to every url. */ fallbackUrls?: string[]; /** Per-request timeout in ms. Without it a hanging host blocks fallbacks and the next poll. */ timeout?: number; /** Static headers. */ headers?: Record; /** Dynamic headers. */ dynamicHeaders?: Record Promise>; fetch?: never; filePath?: never; } interface DynamicConfigWithFetch extends DynamicConfigBase { url?: never; fallbackUrls?: never; timeout?: never; headers?: never; dynamicHeaders?: never; /** Custom fetcher for the raw config value. */ fetch: DynamicConfigFetcher; filePath?: never; } interface DynamicConfigWithFile extends DynamicConfigBase { url?: never; fallbackUrls?: never; timeout?: never; headers?: never; dynamicHeaders?: never; fetch?: never; /** Path to the file to read the config from. */ filePath: string; } export type DynamicConfigSetup = DynamicConfigWithUrl | DynamicConfigWithFetch | DynamicConfigWithFile; export declare class DynamicConfigPoller { ctx: AppContext; private namespace; private dynamicConfigSetup; constructor(ctx: AppContext, namespace: string, dynamicConfigSetup: DynamicConfigSetup); startPolling: () => Promise; private getPollTimeout; private onSuccess; private onError; } export {};