Immutable config-backed flag provider.
-
isEnabled(): booleanflag: string,context?: FlagContext
Evaluates the flag against the immutable flag map.
-
start(): Promise<void>
No-op — flags are immutable.
-
stop(): Promise<void>
No-op — flags are immutable.
-
type: "config"
Provider type identifier.
Database-backed flag provider that polls an injected IFlagStore.
-
isEnabled(): booleanflag: string,context?: FlagContext
Evaluates the flag against the current snapshot.
-
start(): Promise<void>
Loads initial state ONCE and arms the poll interval ONCE.
-
status(): FlagProviderStatus
Returns status: healthy when the last poll succeeded; degraded when it failed.
-
stop(): Promise<void>
Stops the poll timer. Guards against stop()-before-arm (no-op if start was never called or the timer is already cleared).
-
type: "database"
Provider type identifier.
Feature flag service that delegates to a single FlagProvider.
-
isEnabled(): booleanflag: string,context?: FlagContext
Evaluates whether a flag is enabled.
-
isEnabledAsync(): Promise<boolean>flag: string,context?: FlagContext
Evaluates a flag, awaiting the provider when it can answer asynchronously.
-
start(): Promise<void>
Starts the underlying provider (pulls initial state).
-
status(): FlagProviderStatus | undefined
Forwards the provider's optional health status.
-
stop(): Promise<void>
Stops the underlying provider (releases timers / connections).
Thrown when a supplied module does not look like the LaunchDarkly SDK.
A FlagProvider backed by LaunchDarkly.
-
isEnabled(): booleanflag: string,context?: FlagContext
Evaluates a flag against the cached snapshot for this context.
-
isEnabledAsync(): Promise<boolean>flag: string,context?: FlagContext
Evaluates a flag by awaiting LaunchDarkly directly.
-
start(): Promise<void>
Builds the client (unless one was injected), waits for its initial connection, subscribes to flag updates, and prewarms the anonymous snapshot.
-
status(): FlagProviderStatus
Reports whether the client is connected.
-
stop(): Promise<void>
Closes the client and drops every cached snapshot.
-
type: "launchdarkly"
Provider type identifier.
Mutable in-memory flag provider.
-
isEnabled(): booleanflag: string,context?: FlagContext
Evaluates the flag against the current flag map.
-
removeFlag(name: string): void
Removes a flag by name.
-
replaceFlags(flags: Readonly<Record<string, FlagDefinition>>): void
Replaces all flags with a new set.
-
setFlag(): voidname: string,def: FlagDefinition
Sets or updates a flag definition.
-
start(): Promise<void>
No-op — in-memory store needs no startup.
-
stop(): Promise<void>
No-op — in-memory store needs no shutdown.
-
type: "memory"
Provider type identifier.
Narrows an arbitrary module object to ILaunchDarklyModule.
Creates a middleware function that guards a route based on a feature flag.
Creates a flag provider from plugin options.
FeatureFlagsPlugin factory.
Lazily imports the LaunchDarkly Node server SDK.
Builds the LaunchDarkly evaluation context for a framework
FlagContext.
Options for the 'config' provider arm.
-
options: { readonly flags: Readonly<Record<string, FlagDefinition>>; }
Static flag map.
-
provider: "config"
Provider type discriminant.
Options for the 'custom' provider arm.
-
options: { readonly instance: FlagProvider; }
A pre-built
FlagProviderinstance. -
provider: "custom"
Provider type discriminant.
Options for the 'database' provider arm.
-
options: { readonly store: IFlagStore; readonly refreshIntervalMs?: number; }
Injected flag store.
-
provider: "database"
Provider type discriminant.
Evaluation context for targeting rules.
-
attributes: Readonly<Record<string, string | number | boolean>>
Additional targeting attributes.
-
tenantId: string
The tenant the flag is evaluated for, when the request resolves one.
-
userId: string
The user the flag is evaluated for.
Definition of a single feature flag.
-
enabled: boolean
Whether the flag is enabled by default.
-
percentage: number
Optional percentage rollout (0-100).
-
tenants: readonly string[]
Optional tenant restriction. When present and non-empty, the flag is
falsefor any context whosetenantIdis not in this list — including a context with no tenant — and this restriction is evaluated ahead of every other rule (it is not an allowlist: it cannot be overridden byusers). When absent, evaluation is unchanged. -
users: readonly string[]
Optional user allowlist — overrides
enabled: false.
Options for the createFlagGuard factory.
-
context: FlagContext
Static context override for the flag evaluation.
-
fallback: string
Fallback URL for a 302 redirect when the flag is off.
-
statusCode: number
HTTP status code when no fallback is provided (default 404).
Port that all flag providers implement.
-
isEnabled(): booleanflag: string,context?: FlagContext
Evaluate whether a flag is enabled.
-
isEnabledAsync(): Promise<boolean>flag: string,context?: FlagContext
Optionally evaluate a flag asynchronously, when the backing source can produce a more accurate answer than the cached snapshot.
-
start(): Promise<void>
Pull initial state into the cache.
-
status(): FlagProviderStatus
Optional status — absent when the provider has no health signal.
-
stop(): Promise<void>
Release timers / connections.
-
type: FlagProviderType
Provider type identifier.
Status reported by a flag provider.
-
detail: string
Optional human-readable detail.
-
healthy: boolean
Whether the provider is healthy.
Feature flag evaluator. Evaluation is synchronous against the provider's cached state; providers refresh their state out of band.
-
isEnabled(): booleanflag: string,context?: FlagContext
Evaluates a flag.
-
isEnabledAsync(): Promise<boolean>flag: string,context?: FlagContext
Evaluates a flag, awaiting the backing provider when it can produce a more accurate answer asynchronously.
Structural facade injected into DatabaseProvider.
-
loadFlags(): Promise<Readonly<Record<string, FlagDefinition>>>
Load the current flag definitions from the backing store.
The subset of LaunchDarkly's LDClient this provider uses.
-
allFlagsState(context: LaunchDarklyContext): Promise<ILaunchDarklyFlagsState>
Fetches a synchronously-queryable snapshot of every flag for a context.
-
boolVariation(): Promise<boolean>key: string,context: LaunchDarklyContext,defaultValue: boolean
Evaluates a boolean flag for a context.
-
close(): void
Shuts the client down and flushes pending events. Synchronous.
-
initialized(): boolean
Whether the client has completed initialization. Synchronous.
-
on(): voidevent: string,listener: () => void
Registers an event listener. The provider listens for
'update', which fires whenever any flag's configuration changes. -
waitForInitialization(options?: { readonly timeoutSeconds?: number; }): Promise<unknown>
Resolves once the client has connected, or rejects on permanent failure.
The subset of LaunchDarkly's LDFlagsState this provider reads.
-
getFlagValue(key: string): unknown
Reads one flag's value from the recorded snapshot.
-
valid: boolean
False when the snapshot could not be computed (client offline, no context).
The subset of the SDK module surface this provider uses.
-
init(): ILaunchDarklyClientsdkKey: string,options?: Readonly<Record<string, unknown>>
Creates a client. Synchronous — it returns immediately and connects in the background, which is why
ILaunchDarklyClient.waitForInitializationexists.
The LaunchDarkly evaluation context.
-
anonymous: boolean
True when no
userIdwas supplied. -
key: string
The context key; the anonymous key when no
userIdwas supplied. -
kind: "user"
Context kind — always
'user'for the contexts this provider builds.
Configuration for the 'launchdarkly' provider arm.
-
client: ILaunchDarklyClient
A prebuilt client. When present the SDK module is never loaded and
sdkKeyis not read. -
fallbackValue: boolean
Value returned by the synchronous
isEnabledfor a context whose snapshot has not loaded yet, and used as the SDK default inisEnabledAsync. Defaults tofalse. -
initTimeoutSeconds: number
Seconds to wait for the client's initial connection. Defaults to
5. A timeout is logged and tolerated, leaving the provider degraded rather than failing application startup. -
ldOptions: Readonly<Record<string, unknown>>
Options forwarded verbatim as the SDK
init()second argument. -
module: unknown
The SDK module, adapted rather than imported. Lets a test drive the whole construction path without the real package installed.
-
sdkKey: string
The LaunchDarkly SDK key. Required unless
clientis injected; a missing key with no client throws duringregister().
Options for the 'launchdarkly' provider arm.
-
options: LaunchDarklyProviderConfig
LaunchDarkly configuration.
-
provider: "launchdarkly"
Provider type discriminant.
Options for the 'memory' provider arm.
-
options: { readonly flags?: Readonly<Record<string, FlagDefinition>>; }
Optional initial flag map — defaults to empty.
-
provider: "memory"
Provider type discriminant.
| MemoryProviderOptions
| DatabaseProviderOptions
| LaunchDarklyProviderOptions
| CustomProviderOptions
Discriminated union of all plugin option shapes.
Provider identity reported by FlagProvider.type, and surfaced as
data.provider by the plugin's feature-flags health indicator.
Usage
import * as __setu_ts_feature_flags_plugin____feature_flag_evaluation_with_pluggable_backends__config__memory__database__and_a_free_function_route_guard___Registers___linkcode_IFeatureFlags__under__CAPABILITIES_FEATURE_FLAGS__ from "feature-flags-plugin/src/index.ts";