import type { WorkOSFeatureFlag, WorkOSFlagTarget } from './entities.js'; import type { WorkOSStore } from './store.js'; /** Same `environment_` convention Vault objects are scoped by. */ export declare function environmentIdFor(environment?: string): string; /** `{ id, name }` of the API key acting on a flag; see `apiKeyActor` for how it is resolved. */ export type FlagActor = { id: string; name: string; }; /** * The rule a new target of this type joins. Production groups a flag's targets into rules and * keys the v2 SDK poll payload by rule, so every target of one type shares an id that holds * steady from one poll to the next — the runtime client diffs rules by id, and a fresh id per * poll would report a change on every tick. The emulator has no rule entity: the first target of * a type mints the id, and later ones reuse it. Once a type's last target is removed its rule is * gone; production keeps the empty rule but omits it from the payload all the same, so the two * agree on the wire. */ export declare function flagRuleIdFor(ws: WorkOSStore, flagSlug: string, resourceType: WorkOSFlagTarget['resource_type']): string; /** * `access_type` summarizes a flag's reach in one word, the way the dashboard shows it: * `all` when the default value carries every resource, `some` when only targets are on, * `none` when the flag reaches nobody (disabled, or enabled with neither). */ export declare function flagAccessType(ws: WorkOSStore, flag: WorkOSFeatureFlag): 'none' | 'some' | 'all'; /** * The base `context` every flag webhook carries. `client_id` is the emulator's standing * placeholder — an API-key request has no client identity to report — and `source` is * always `api`, since the emulator serves no dashboard or admin portal. * * The actor is the API key that made the request when the emitting code has one (the target * routes do — see `apiKeyActor`), and the placeholder otherwise. */ export declare function flagEventContext(actor?: FlagActor): Record; /** * The targeting half of a `flag.rule_updated` context. Only that event defines `access_type` * and `configured_targets`, so the other three flag events must not carry them. * * A target whose user or organization no longer resolves is left out rather than reported * with a blank name or email: the spec marks both required, and the delete routes cascade * targets, so such a row only exists when a caller has edited the store directly. */ export declare function flagRuleState(ws: WorkOSStore, flag: WorkOSFeatureFlag): Record; /** * The full `flag.rule_updated` context. `previous_attributes` is required on this event, so * the caller has to capture `flagRuleState` before mutating the targets and hand it back here. * * Only the rule changed: a target mutation leaves the flag object's own attributes as they * were, so `previous_attributes.data` is omitted rather than restating current values as * "previous". The spec requires neither `data` nor `context` inside `previous_attributes`. */ export declare function flagRuleUpdatedContext(ws: WorkOSStore, flag: WorkOSFeatureFlag, previous: Record, actor?: FlagActor): Record;