import { FlagManager } from './engine/manager.mjs'; import { F as Flag, H as FlagRule, ad as Segment, c as AuditActor } from './types-DdEZ8iqq.mjs'; import './core/logger.mjs'; import './core/metrics.mjs'; import './core/flag-types.mjs'; interface FlagSnapshot { /** Format version — used to gate forward-compat parsing. */ version: 1; /** When this snapshot was captured (ISO-8601). */ capturedAt: string; /** Environment label this snapshot describes (informational). */ environment?: string; flags: SnapshotFlag[]; segments?: SnapshotSegment[]; } interface SnapshotFlag { key: string; type: Flag["type"]; status: Flag["status"]; defaultValue: unknown; description?: string; namespace?: string; tags?: string[]; locked?: boolean; lockedReason?: string; environments?: string[]; variants?: Flag["variants"]; rollout?: Flag["rollout"]; scheduledAt?: string | null; expiresAt?: string | null; prerequisites?: Flag["prerequisites"]; environmentDefaults?: Record; exclusionLayer?: string; clientVisible?: boolean; rules?: SnapshotRule[]; } interface SnapshotRule { name?: string; priority: number; value: unknown; conditions: FlagRule["conditions"]; enabled?: boolean; rolloutPct?: number; isHoldout?: boolean; variantId?: string; userIds?: string[]; description?: string; metadata?: Record; } interface SnapshotSegment { key: string; description?: string; rules: Segment["rules"]; } type DiffChangeType = "added" | "removed" | "modified"; interface FlagDiffEntry { key: string; change: DiffChangeType; /** Per-field deltas; populated for `modified` entries. */ fields?: Record; } interface FlagDiff { added: SnapshotFlag[]; removed: SnapshotFlag[]; modified: FlagDiffEntry[]; unchanged: number; } interface ExportOptions { format?: "json" | "yaml"; /** Limit to a specific namespace. */ namespace?: string; /** Limit to flags with these tags. */ tags?: string[]; /** Include flag rules in the snapshot. Default: true. */ includeRules?: boolean; /** Include segments in the snapshot. Default: true. */ includeSegments?: boolean; /** Pretty-print output. Default: true. */ pretty?: boolean; } /** * Capture a snapshot of every active flag (and optionally segments) for the * given environment. Returns the snapshot object — pair with * `serializeSnapshot` to get a string for disk. */ declare function exportFlags(manager: FlagManager, opts?: ExportOptions): Promise; /** Serialize a snapshot to JSON or YAML. */ declare function serializeSnapshot(snapshot: FlagSnapshot, format?: "json" | "yaml", pretty?: boolean): string; /** Parse a serialized snapshot. Accepts JSON or YAML (auto-detected). */ declare function parseSnapshot(raw: string): FlagSnapshot; /** * Produce a structural diff between two snapshots. The diff lists flags added * in `next`, flags removed from `prev`, and per-field deltas for modified * flags. Useful for code-review style flag PRs. */ declare function diffFlags(prev: FlagSnapshot, next: FlagSnapshot): FlagDiff; interface PromoteOptions { /** Source snapshot (e.g. captured from staging). */ source: FlagSnapshot; /** Limit promotion to these flag keys. Promotes all when omitted. */ keys?: string[]; /** * Dry-run: compute the plan without applying it. Defaults to false. * Returns the same shape as a live promote — apply later by calling * `applyPromotionPlan(manager, plan)`. */ dryRun?: boolean; /** Actor for audit history. */ actor?: AuditActor; /** Bail out on the first error. Defaults to false (collect + continue). */ failFast?: boolean; /** Whether to also create/update rules on promoted flags. Default: true. */ includeRules?: boolean; } interface PromotionPlanItem { key: string; action: "create" | "update" | "skip"; reason?: string; } interface PromotionResult { plan: PromotionPlanItem[]; applied: number; errors: Array<{ key: string; error: string; }>; } /** * Promote a flag (or set of flags) from a source snapshot into a live * manager. The promoted flag's identity (key) is preserved; ownership * fields like createdAt are not touched. * * Use this to ship a staging flag config to production after review: * const staging = await exportFlags(stagingRl) * await promoteEnvironment(prodRl, { source: staging, keys: ['checkout_v2'] }) */ declare function promoteEnvironment(manager: FlagManager, opts: PromoteOptions): Promise; export { type DiffChangeType, type ExportOptions, type FlagDiff, type FlagDiffEntry, type FlagSnapshot, type PromoteOptions, type PromotionPlanItem, type PromotionResult, type SnapshotFlag, type SnapshotRule, type SnapshotSegment, diffFlags, exportFlags, parseSnapshot, promoteEnvironment, serializeSnapshot };