/** * LaunchDarkly REST API client — Phase-1 config snapshot. * * LaunchDarkly has no bulk "export everything" endpoint, so the fetcher * stitches per-resource calls: environments, context-kinds, flags (full * per-env targeting via `?summary=0&env=`), and segments (per environment). * * Auth is a raw API token in the `Authorization` header — no `Bearer` prefix. * Rate limiting is a per-account rolling 10-second window with an unpublished * limit, so we program against the headers: back off on 429 using * `X-Ratelimit-Reset` (epoch-ms), pre-throttle on `X-Ratelimit-Global-Remaining`. */ import type { LDFlag, LDMember, LDSegment, LDSnapshot } from './types.js'; export declare function setLaunchDarklyBaseUrl(url: string): void; export declare function selectLaunchDarklyBaseUrl(): string; export declare function applyLaunchDarklyBaseUrl(): void; export declare function __setSleepForTests(fn: (ms: number) => Promise): void; export declare function __resetSleepForTests(): void; export declare class LaunchDarklyApiError extends Error { readonly status: number; constructor(status: number, statusText: string, url: string, body: string); } /** * Single GET with header auth, 429 backoff against `X-Ratelimit-Reset`, and a * pre-throttle when `X-Ratelimit-Global-Remaining` runs low. Non-429 errors * throw immediately — only rate limiting is retried. * * Exported so the Phase-2 audit-log walker (`audit.ts`) reuses the exact same * rate-limit handling — `/auditlog` is account-wide and the slowest endpoint, * so it must not bypass the shared 429 backoff. */ export declare function apiFetch(path: string, apiKey: string): Promise; /** Probe used by `validateAuth` — a cheap authenticated call that 401s on a bad token. */ export declare function fetchProjectEnvironments(apiKey: string, projectKey: string): Promise; /** * Same call as `fetchProjectEnvironments` but returns the full `{key, name}` * pairs. The display `name` is needed for the MIGRATION_REPORT.md "Environment * mapping table" — the bare key alone hides the customer-facing env label * (qfg-1t7m). */ export declare function fetchProjectEnvironmentsDetailed(apiKey: string, projectKey: string): Promise>; export declare function fetchContextKinds(apiKey: string, projectKey: string): Promise; /** * Full per-environment flag targeting. `?summary=0` plus repeated `?env=` * returns rules, clauses, targets, fallthrough, offVariation, prerequisites * and rollouts for every named environment in one response — there is no * "all environments" wildcard, so env keys are templated in explicitly. * * `opts.archived` flips the list to *only* archived flags. LaunchDarkly's flag * list endpoint hides archived flags by default and has no "both" mode, so a * full picture is two calls. The migration runtime does not want archived flags * (`fetchSnapshot` omits this), but the fixture-corpus exporter needs them so * the `state-archived` edge case is in the canonical corpus. */ export declare function fetchFlags(apiKey: string, projectKey: string, envKeys: string[], opts?: { archived?: boolean; }): Promise; /** * Account-wide member list — used to resolve flag `maintainerId` hex strings * to readable emails for MIGRATION_REPORT.md (qfg-l8uz). Members live above * projects in LD's hierarchy, so this call is project-independent. * * Some API tokens (project-scoped, or accounts with member visibility * restrictions) can't read members and get a 403. Callers should treat the * member map as best-effort and downgrade gracefully — the migration must not * fail because we couldn't enrich the maintainer rollup. */ export declare function fetchMembers(apiKey: string): Promise; /** Segments are a per-environment resource — caller loops env keys and de-dupes. */ export declare function fetchSegmentsForEnv(apiKey: string, projectKey: string, envKey: string): Promise; /** * Stitches the whole Phase-1 snapshot: environments → context-kinds → flags * (one call, all envs) → segments (per env, de-duplicated by key). This is the * ~60-call "fast, lossless for current state" path; it always re-fetches * everything (decision D2 — we do not trust the LD audit cursor for deltas). */ export declare function fetchSnapshot(apiKey: string, projectKey: string): Promise;