@xtandard/flags/openfeature
The OpenFeature provider for @xtandard/flags — the single most important
runtime component.
Promise: applications evaluate flags from in-memory snapshots. The admin /
control plane, and even the storage backend, can be DOWN and the app keeps
serving last-known-good values. Storage is touched only on initialize, on a
background refresh timer, and (best-effort) on watch notifications — never on
the request path. Once a snapshot is in memory, resolution is pure, synchronous
work that cannot fail because storage is unavailable.
Failure semantics (the part that must be exactly right)
Section titled “Failure semantics (the part that must be exactly right)”initialize()failing or returning no snapshot does NOT throw — the provider still constructs and serves the caller’s defaults.- A background refresh that throws KEEPS the last-known-good snapshot and marks
it
stale; it never clears memory. A later successful refresh replaces memory and clearsstale. - Resolution never reads storage and never throws; on any problem it returns the
caller’s
defaultValuewith an OpenFeature-compatible reason/errorCode.
Zero runtime dependency on @openfeature/server-sdk
Section titled “Zero runtime dependency on @openfeature/server-sdk”@openfeature/server-sdk is an optional peer dependency. OpenFeature’s
StandardResolutionReasons is a runtime const object and ErrorCode is a
runtime enum — importing either would create a hard runtime dependency. We
therefore import the SDK for types only ({@link import type}) and replicate
the exact string values as local literals (OF_REASON, OF_ERROR).
The returned object structurally satisfies the Provider interface without the
package being installed at runtime.
import { … } from "@xtandard/flags/openfeature";Functions
Section titled “Functions”| Name | Summary |
|---|---|
createOpenFeatureProvider |
Create a storage-backed, memory-first OpenFeature provider. |
toOpenFeatureReason |
Map an internal EvaluationReason to an OpenFeature reason string. Our reasons are a superset; the extra ones (CACHED, STALE, FLAG_NOT_FOUND) either map onto OF standards or, for FLAG_NOT_FOUND, are surfaced as ERROR with an errorCode per OpenFeature convention. |
Interfaces
Section titled “Interfaces”| Name | Summary |
|---|---|
OpenFeatureProviderOptions |
Options for createOpenFeatureProvider. |
ProviderLogger |
A minimal logger; compatible with OpenFeature’s OFLogger subset we use. |
XtandardOpenFeatureProvider |
The provider returned by createOpenFeatureProvider. Structurally implements OpenFeature’s server Provider interface, plus a public XtandardOpenFeatureProvider.refresh method (primarily for tests and for callers that want to force a reload). |