import { a as renderOnce, t as ReferenceSyntaxError } from "./referenceSyntax-DYn3GIoP.js"; //#region src/vars/composition.d.ts declare const MAX_COMPOSITION_DEPTH = 20; interface ComposedReference { composedFrom?: ComposedReference[]; error?: string; fatal: boolean; label?: string; name: string; reason: VariableResolutionReason; value?: string; version?: number; } interface FindReferencesAndErrorsResult { errors: ReferenceSyntaxError[]; references: string[]; } declare function hasReferences(value: unknown): boolean; declare function findReferences(value: unknown): string[]; declare function findReferencesAndErrors(value: unknown): FindReferencesAndErrorsResult; //#endregion //#region src/vars/templateValidation.d.ts interface TemplateFieldIssue { fieldName: string; foundInLabel?: string; foundInVariable: string; message: string; referencePath: string[]; rootVariable: string; } //#endregion //#region src/vars/errors.d.ts declare class VariableCompositionError extends Error { override name: string; } declare class VariableCompositionCycleError extends VariableCompositionError { override name: string; } declare class VariableCompositionDepthError extends VariableCompositionError { override name: string; } declare class VariableRenderError extends Error { override name: string; } //#endregion //#region src/vars/index.d.ts type JsonSchema = Record; type ResolveFunction = (targetingKey: string | undefined, attributes: Record) => Promise | T; interface VariableCodec { jsonSchema?: JsonSchema; parse(value: unknown): T; serialize?: (value: T) => string; typeName?: string; } interface VariableOptions { codec?: VariableCodec; default: ResolveFunction | T; description?: string; templateInputsSchema?: JsonSchema; } type TemplateMismatchPolicy = "error" | "ignore" | "warn"; declare class TemplateInputsMismatchError extends Error { override name: string; } interface VariableDefinition { codec: Pick, "parse">; description: string | undefined; name: string; templateInputsSchema?: JsonSchema; toConfig(): VariableConfig; } interface VariableNameLike { name: string; } interface VariableGetOptions { attributes?: Record; label?: string; targetingKey?: string; } interface ResolvedVariableInit { composedFrom?: ComposedReference[]; deserializer?: (serializedValue: string) => T; exception?: unknown; label?: string; name: string; reason: VariableResolutionReason; serializedValue?: string; value: T; version?: number; } type VariableResolutionReason = "code_default" | "context_override" | "missing_config" | "no_provider" | "other_error" | "resolved" | "unrecognized_variable" | "validation_error"; declare class ResolvedVariable { composedFrom: ComposedReference[]; private readonly deserializer; exception: unknown; label: string | undefined; name: string; reason: VariableResolutionReason; serializedValue: string | undefined; value: T; version: number | undefined; constructor(init: ResolvedVariableInit); render(inputs?: Record): T; withContext(callback: () => Promise | R): Promise; } interface SerializedResolvedVariableInit { label?: string; name: string; reason: VariableResolutionReason; value: string | undefined; version?: number; } declare class SerializedResolvedVariable extends ResolvedVariable {} interface LabeledValue { serialized_value: string; version: number; } interface LabelRef { ref: string; version?: number | null; } interface LatestVersion { serialized_value: string; version: number; } interface Rollout { labels: Record; } type Condition = KeyIsNotPresent | KeyIsPresent | ValueDoesNotEqual | ValueDoesNotMatchRegex | ValueEquals | ValueIsIn | ValueIsNotIn | ValueMatchesRegex; interface ValueEquals { attribute: string; kind: "value-equals"; value: unknown; } interface ValueDoesNotEqual { attribute: string; kind: "value-does-not-equal"; value: unknown; } interface ValueIsIn { attribute: string; kind: "value-is-in"; values: unknown[]; } interface ValueIsNotIn { attribute: string; kind: "value-is-not-in"; values: unknown[]; } interface ValueMatchesRegex { attribute: string; kind: "value-matches-regex"; pattern: string; } interface ValueDoesNotMatchRegex { attribute: string; kind: "value-does-not-match-regex"; pattern: string; } interface KeyIsPresent { attribute: string; kind: "key-is-present"; } interface KeyIsNotPresent { attribute: string; kind: "key-is-not-present"; } interface RolloutOverride { conditions: Condition[]; rollout: Rollout; } interface VariableConfig { aliases?: string[] | null; description?: string | null; example?: string | null; json_schema?: JsonSchema | null; labels: Record; latest_version?: LatestVersion | null; name: string; overrides: RolloutOverride[]; rollout: Rollout; template_inputs_schema?: JsonSchema | null; type_name?: string | null; } interface VariablesConfig { variables: Record; } interface VariableTypeConfig { description?: string | null; json_schema: JsonSchema; name: string; source_hint?: string | null; } interface LabelValidationError { error: unknown; label: string | undefined; variableName: string; } interface DescriptionDifference { localDescription: string | undefined; serverDescription: string | undefined; variableName: string; } interface ValidationReport { descriptionDifferences: DescriptionDifference[]; errors: LabelValidationError[]; isValid: boolean; referenceCycles: string[]; referenceErrors: string[]; templateFieldIssues: TemplateFieldIssue[]; variablesChecked: number; variablesNotOnServer: string[]; } type VariablePushBlockReason = "incompatible_labels" | "incompatible_type_labels" | "reference_cycles" | "reference_errors" | "template_field_issues"; type MaybePromise = T | Promise; interface VariableProvider { batchUpdate?(updates: Record): MaybePromise; createVariable?(config: VariableConfig): MaybePromise; deleteVariable?(name: string): MaybePromise; getAllVariablesConfig?(): MaybePromise; getSerializedValue(variableName: string, targetingKey?: string, attributes?: Record): MaybePromise; getSerializedValueForLabel?(variableName: string, label: string): MaybePromise; getVariableConfig?(name: string): MaybePromise; listVariableTypes?(): MaybePromise>; refresh?(force?: boolean): MaybePromise; shutdown?(): MaybePromise; start?(): void; updateVariable?(name: string, config: VariableConfig): MaybePromise; upsertVariableType?(config: VariableTypeConfig): MaybePromise; } interface VariablesOptions { apiKey?: string; baseUrl?: string; blockBeforeFirstResolve?: boolean; fetch?: typeof fetch; includeBaggageInContext?: boolean; includeResourceAttributesInContext?: boolean; instrument?: boolean; polling?: boolean; pollingInterval?: number; sse?: boolean; timeoutMs?: number; templateMismatchPolicy?: TemplateMismatchPolicy; } interface LocalVariablesOptions { config: VariablesConfig; includeBaggageInContext?: boolean; includeResourceAttributesInContext?: boolean; instrument?: boolean; templateMismatchPolicy?: TemplateMismatchPolicy; } type VariablesConfigOptions = false | LocalVariablesOptions | VariablesOptions | undefined; interface ConfigureVariablesRuntimeOptions { apiKey?: string; baseUrl?: string; resourceAttributes?: Record; } interface VariablePushResult { blocked: boolean; blockedBy: VariablePushBlockReason[]; changes: VariablePushChange[]; dryRun: boolean; } interface VariablePushChange { action: "create" | "delete" | "update"; name: string; } declare class VariableWriteError extends Error { override name: string; } declare class VariableNotFoundError extends VariableWriteError { override name: string; } declare class VariableAlreadyExistsError extends VariableWriteError { override name: string; } declare class NoOpVariableProvider implements VariableProvider { getSerializedValue(variableName: string): SerializedResolvedVariable; getVariableConfig(): VariableConfig | undefined; getAllVariablesConfig(): VariablesConfig; } declare class LocalVariableProvider implements VariableProvider { private config; constructor(config: VariablesConfig); getSerializedValue(variableName: string, targetingKey?: string, attributes?: Record): SerializedResolvedVariable; getSerializedValueForLabel(variableName: string, label: string): SerializedResolvedVariable; getVariableConfig(name: string): VariableConfig | undefined; getAllVariablesConfig(): VariablesConfig; createVariable(config: VariableConfig): VariableConfig; updateVariable(name: string, config: VariableConfig): VariableConfig; deleteVariable(name: string): void; batchUpdate(updates: Record): void; } interface RemoteVariableProviderOptions extends VariablesOptions { apiKey: string; baseUrl: string; } declare class LogfireRemoteVariableProvider implements VariableProvider { private readonly apiKey; private readonly baseUrl; private readonly blockBeforeFirstResolve; private readonly fetchImpl; private readonly pollingEnabled; private readonly pollingIntervalMs; private readonly sseEnabled; private readonly timeoutMs; private readonly transport; private config; private hasAttemptedFetch; private lastFetchedAt; private pollingTimer; private queuedForcedRefreshPromise; private refreshPromise; private sseController; private shutdownRequested; private started; constructor(options: RemoteVariableProviderOptions); start(): void; shutdown(): void; refresh(force?: boolean): Promise; private runQueuedForcedRefresh; getSerializedValue(variableName: string, targetingKey?: string, attributes?: Record): Promise; getSerializedValueForLabel(variableName: string, label: string): Promise; getVariableConfig(name: string): VariableConfig | undefined; getAllVariablesConfig(): Promise; createVariable(config: VariableConfig): Promise; updateVariable(name: string, config: VariableConfig): Promise; deleteVariable(name: string): Promise; batchUpdate(updates: Record): Promise; listVariableTypes(): Promise>; upsertVariableType(config: VariableTypeConfig): Promise; private runSseLoop; private readSseStream; } declare class Variable { codec: VariableCodec; defaultValue: ResolveFunction | T; description: string | undefined; name: string; templateInputsSchema?: JsonSchema; constructor(name: string, options: VariableOptions); get(options?: VariableGetOptions): Promise>; refresh(force?: boolean): Promise; override(value: ResolveFunction | T, callback: () => Promise | R): Promise; toConfig(): VariableConfig; private getWithSpan; private resolve; private resolveInner; private resolveContextOverride; private lookupSerialized; private tryResolveSerialized; private resolveCodeDefaultValue; private resolveRawCodeDefault; private getDefaultCached; private getSerializedDefault; } type TemplateVariableOptions> = InputsT extends Record ? VariableOptions & { templateMismatchPolicy?: TemplateMismatchPolicy; } : never; declare class TemplateVariable> extends Variable { private readonly templateMismatchPolicy; constructor(name: string, options: TemplateVariableOptions); override get(inputs: InputsT, options?: VariableGetOptions): Promise>; private resolveRenderFallbackValue; private effectiveTemplateMismatchPolicy; private checkTemplateInputs; } declare function defineVar(name: string, options: VariableOptions): Variable; declare function defineTemplateVar = Record>(name: string, options: TemplateVariableOptions): TemplateVariable; declare function variablesClear(): void; declare function variablesGet(): VariableDefinition[]; declare function variablesBuildConfig(variables?: VariableDefinition[]): VariablesConfig; declare function variablesValidate(variables?: VariableDefinition[]): Promise; declare function variablesPush(variables?: VariableDefinition[], options?: { dryRun?: boolean; strict?: boolean; }): Promise; declare function variablesPushConfig(config: VariablesConfig, options?: { dryRun?: boolean; mode?: "merge" | "replace"; }): Promise; declare function variablesPullConfig(): Promise; declare function variablesPushTypes(types: VariableTypeConfig[], options?: { dryRun?: boolean; strict?: boolean; }): Promise; declare function configureVariables(options?: VariablesConfigOptions, runtime?: ConfigureVariablesRuntimeOptions): void; declare function shutdownVariables(): Promise; declare function getVariableProvider(): VariableProvider; declare function targetingContext(targetingKey: string, callbackOrOptions: (() => Promise | R) | { variables?: VariableNameLike[]; }, maybeCallback?: () => Promise | R): Promise; //#endregion export { type ComposedReference, Condition, ConfigureVariablesRuntimeOptions, DescriptionDifference, JsonSchema, KeyIsNotPresent, KeyIsPresent, LabelRef, LabelValidationError, LabeledValue, LatestVersion, LocalVariableProvider, LocalVariablesOptions, LogfireRemoteVariableProvider, MAX_COMPOSITION_DEPTH, MaybePromise, NoOpVariableProvider, RemoteVariableProviderOptions, ResolveFunction, ResolvedVariable, ResolvedVariableInit, Rollout, RolloutOverride, SerializedResolvedVariable, SerializedResolvedVariableInit, type TemplateFieldIssue, TemplateInputsMismatchError, TemplateMismatchPolicy, TemplateVariable, TemplateVariableOptions, ValidationReport, ValueDoesNotEqual, ValueDoesNotMatchRegex, ValueEquals, ValueIsIn, ValueIsNotIn, ValueMatchesRegex, Variable, VariableAlreadyExistsError, VariableCodec, VariableCompositionCycleError, VariableCompositionDepthError, VariableCompositionError, VariableConfig, VariableDefinition, VariableGetOptions, VariableNameLike, VariableNotFoundError, VariableOptions, VariableProvider, VariablePushBlockReason, VariablePushChange, VariablePushResult, VariableRenderError, VariableResolutionReason, VariableTypeConfig, VariableWriteError, VariablesConfig, VariablesConfigOptions, VariablesOptions, configureVariables, defineTemplateVar, defineTemplateVar as templateVar, defineVar, defineVar as var, findReferences, findReferencesAndErrors, getVariableProvider, hasReferences, renderOnce, shutdownVariables, targetingContext, variablesBuildConfig, variablesClear, variablesGet, variablesPullConfig, variablesPush, variablesPushConfig, variablesPushTypes, variablesValidate };