/** * Flagsmith converter — Flagsmith feature/segment JSON → `QuonfigFile`-ready * objects (plain JS objects ready for `JSON.stringify`). * * Provider-specific topology collapse (plan §5, Epic 3). Calls the shared * `quonfig-target/` verb library where the structure is identical to LD * (value coercion, criterion + rule shape, report wiring) and handles the * Flagsmith-shaped bits here: synthesizing the ordered rule list from * `feature_state` + `segment_overrides` + `identity_overrides` (§5.1), * `enabled=false` disposition per D-F1, operator mapping with `:semver` * suffix detection (§5.3), multivariate weighted-values shape (§5.4), * cross-env value-type coercion per D-F5. * * This module is a pure function — no I/O, no env reads, no module-level * mutable state. Report accumulation flows through the `ConversionReport` * argument supplied by the caller (the `flagsmith.ts` source). */ import type { ConversionReport } from '../../quonfig-target/report.js'; import type { QuonfigCriterion } from '../../quonfig-target/ruleset.js'; import type { FlagsmithFeatureStateValueEnvelope, FlagsmithFeatureWithStates, FlagsmithSegment, FlagsmithSegmentCondition, FlagsmithTag } from './types.js'; /** * Operator-mapping result. A clean criterion translation OR a whole-rule drop * with a precise reason. Returned per condition; the rule is dropped if any * condition drops. */ type ConditionMapping = { criterion: QuonfigCriterion; } | { drop: true; reason: string; }; /** * Flagsmith feature names land directly under `feature-flags/` — Flagsmith * enforces a lower-case-hyphenated naming policy on most projects, so the * key is already filesystem-safe. We still defensively replace any `/` so * a name can never spawn a nested directory. */ export declare function flagOutputPath(name: string): string; export declare function segmentOutputPath(name: string): string; /** * Unwrap the `feature_state_value` field as it appears on the * `/features/featurestates/` endpoint (envelope shape on env-default and * segment-override rows; scalar on `/edge-identity-overrides` per API5). * Returns the raw JS value Flagsmith would have served before any Quonfig * type coercion. */ export declare function coerceEnvelopeOrScalar(v: FlagsmithFeatureStateValueEnvelope | boolean | null | number | string | undefined): boolean | null | number | string; /** * Map one Flagsmith condition to a Quonfig criterion, or signal a whole-rule * drop with a reason. Implements plan §5.3 verbatim. */ export declare function mapCondition(condition: FlagsmithSegmentCondition): ConditionMapping; /** * Translate one Flagsmith feature (with all its per-env state) into a Quonfig * feature-flag config object. */ export declare function translateFeature(bundle: FlagsmithFeatureWithStates, report: ConversionReport, options?: { /** Map from env api_key → user-facing env name. The converter slugifies the name for the Quonfig env id. */ envNameByApiKey?: Map; segmentNameById?: Map; tags?: FlagsmithTag[]; }): Record; /** * Translate one Flagsmith segment into a Quonfig segment config object. * * Quonfig segments are boolean ("is the context in the segment?") and have no * per-environment state, so all rules collapse into `default.rules`, * first-match-wins. A rule whose conditions all map yields a true-valued rule; * a trailing ALWAYS_TRUE serves false (not in segment). */ export declare function translateSegment(segment: FlagsmithSegment, report: ConversionReport): Record; export {};