/** * Two-namespace interpolation for preset item config. * * Syntax: * - `${INPUT:KEY}` — placeholder value inlined into Instance.config * - `${SECRET:KEY}` — stored as credential_ref in Instance; value is handed * to SecretsRouter.setSecret separately * * The `materialize` map on a preset item defines how placeholder values fold * into the Instance config JSON. Each key is a dotted config path; each value * is a template string that may contain ${INPUT:KEY} or ${SECRET:KEY} tokens. * * Constraints: * - `${SECRET:KEY}` MUST be the sole token in a template (no mixing with * INPUT or literal text). Mixed templates would embed non-secret data * into the stored secret, breaking update semantics. * - All referenced keys MUST exist in the context. Missing keys throw * InterpolationError rather than silently producing empty strings. * * Example: * ```yaml * materialize: * host: "${INPUT:HOST}" * port: "${INPUT:PORT}" * credentials.api_key: "${SECRET:API_KEY}" * ``` * * @docLink packages/library/concepts#interpolation */ import type { SecretsRouter } from "@skaile/workspaces/secrets"; /** * Runtime context passed to {@link interpolate} containing resolved placeholder values. * * @docLink packages/library/concepts#interpolation */ export interface InterpolationContext { /** Validated placeholder values (key to value). */ inputs: Record; /** Secret values (key to plaintext value) to be stored via SecretsRouter. */ secrets: Record; } /** * Result produced by {@link interpolate}. * * @docLink packages/library/concepts#interpolation */ export interface InterpolationResult { /** The materialized config to set on the Instance. */ config: Record; /** Credential ref to set on the Instance (if any secret placeholders used). */ credentialRef?: string; /** Secret entries that need to be stored (ref to plaintext value). */ secretsToStore: Array<{ ref: string; value: string; }>; } /** * Thrown when a template references a missing key or mixes `${SECRET:...}` with other tokens. * * @docLink packages/library/concepts#interpolation */ export declare class InterpolationError extends Error { constructor(message: string); } /** * Interpolate a materialize map with placeholder values. * * @param materialize - Map of dotted config paths to template strings. * @param baseConfig - Pre-existing item config (author-prefilled values). * @param context - Validated input values and secret values. * @param credentialRefPrefix - Prefix for generated credential refs. * @returns Interpolated config and secrets to store. * @throws {InterpolationError} if a referenced key is missing or a SECRET token * is mixed with other tokens in the same template. * @docLink packages/library/concepts#interpolation */ export declare function interpolate(materialize: Record | undefined, baseConfig: Record | undefined, context: InterpolationContext, credentialRefPrefix: string): InterpolationResult; /** * Store interpolated secrets via the SecretsRouter. * * @param router - The SecretsRouter instance. * @param secretsToStore - Array of `{ref, value}` pairs from {@link InterpolationResult}. * @docLink packages/library/concepts#interpolation */ export declare function storeSecrets(router: SecretsRouter, secretsToStore: Array<{ ref: string; value: string; }>): Promise; /** * Check if a template string contains any interpolation tokens (`${INPUT:...}` or `${SECRET:...}`). * * @param template - The template string to inspect. * @returns `true` if at least one token is present. * @docLink packages/library/concepts#interpolation */ export declare function hasInterpolationTokens(template: string): boolean; /** * Extract all placeholder keys referenced in a materialize map. * * @param materialize - Map of dotted config paths to template strings. * @returns Sets of unique `INPUT` and `SECRET` key names referenced across all templates. * @docLink packages/library/concepts#interpolation */ export declare function extractReferencedKeys(materialize: Record): { inputKeys: string[]; secretKeys: string[]; }; //# sourceMappingURL=interpolate.d.ts.map