@ogygia/flags · API
@ogygia/flags/openfeature
The reference for openfeature() and ofrep(), the two bundled decision sources, and their options.
On this page
- ofrep
- openfeature
- EvaluationContextLike
- EvaluationContextLike.targetingKey
- OfrepOptions
- OfrepOptions.url
- OfrepOptions.headers
- OfrepOptions.context
- OfrepOptions.fetch
- OfrepOptions.timeout
- OpenFeatureClientLike
- OpenFeatureClientLike.getBooleanValue
- OpenFeatureClientLike.getStringValue
- OpenFeatureClientLike.getObjectValue
- OpenFeatureOptions
- OpenFeatureOptions.context
- OpenFeatureOptions.values
This page is generated from the package’s own .d.ts files on every build, so the signatures, descriptions and examples below always match the source. OpenFeature explains both sources.
Exports ofrep · openfeature · EvaluationContextLike · OfrepOptions · OpenFeatureClientLike · OpenFeatureOptions
import { … } from '@ogygia/flags/openfeature';ofrep
function
A flag source that speaks the OpenFeature Remote Evaluation Protocol (OFREP) directly, with no
vendor SDK: any OFREP endpoint works (flagd, the OpenFeature operator, a gateway). One bulk POST
per request over the app's declared flags; a boolean value reads as on / off. An error
answer, a timeout or a network failure throws, so the flags fall to their native rule and it is
said; a request that ended first stops the call and reports nothing.
import { decide } from '@ogygia/flags'; import { ofrep } from '@ogygia/flags/openfeature'; decide({ source: ofrep({ url: 'http://flagd:8016' }) });
function ofrep(opts: OfrepOptions): FlagSource;openfeature
function
A flag source over the app's own OpenFeature client (any provider; ogygia depends on no vendor
SDK). One evaluation per declared flag per request: a boolean flag asks with false as its
default (a missing key never turns a feature on), a variant flag with its first variant. One
flag whose evaluation throws falls to its native rule and is said; the others keep the answer.
After the one await, a decided flag reads like a native one.
import { OpenFeature } from '@openfeature/server-sdk'; import { decide } from '@ogygia/flags'; import { openfeature } from '@ogygia/flags/openfeature'; decide({ source: openfeature(OpenFeature.getClient()) });
function openfeature(client: OpenFeatureClientLike, opts?: OpenFeatureOptions): FlagSource;interface EvaluationContextLike {/*…*/}targetingKey?: string;OfrepOptions
interface
OfrepOptions.url
OFREP base URL (the adapter calls <url>/ofrep/v1/evaluate/flags/bulk).
OfrepOptions.headers
Static headers (auth token, tenant) sent with every evaluation.
OfrepOptions.context
Build the OFREP evaluation context from the request (default: visitor sub, else
an anonymous visitor's vid → targetingKey, plus every own key of c.visitor).
OfrepOptions.fetch
Per-request fetch (default global).
OfrepOptions.timeout
Abort the evaluation after N ms (default 800 — a flag service must not gate first byte).
interface OfrepOptions {/*…*/}url: string;headers?: Record<string, string>;context?: (c: CtxLike) => Record<string, unknown>;fetch?: typeof fetch;timeout?: number;OpenFeatureClientLike
interface
The slice of the OpenFeature server Client we use — structural, so any SDK version fits.
OpenFeatureClientLike.getBooleanValue
OpenFeatureClientLike.getStringValue
OpenFeatureClientLike.getObjectValue
Optional: variants that carry a config payload read via .value(c).
interface OpenFeatureClientLike {/*…*/}getBooleanValue(flagKey: string, defaultValue: boolean, context?: EvaluationContextLike): Promise<boolean>;getStringValue(flagKey: string, defaultValue: string, context?: EvaluationContextLike): Promise<string>;getObjectValue?<T>(flagKey: string, defaultValue: T, context?: EvaluationContextLike): Promise<T>;OpenFeatureOptions
interface
OpenFeatureOptions.context
Build the OpenFeature evaluation context from the request (default: visitor sub, else
an anonymous visitor's vid → targetingKey, plus every own key of c.visitor).
OpenFeatureOptions.values
Also pull each flag's object value as the .value(c) payload (one extra eval per flag).
Off by default — most flags are variant-only.
interface OpenFeatureOptions {/*…*/}context?: (c: CtxLike) => EvaluationContextLike;values?: boolean;