Skip to content

API

@ogygia/flags/openfeature

Decisions from an OpenFeature provider.

On this page

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.

import { … } from '@ogygia/flags/openfeature';

Exports ofrep · openfeature · EvaluationContextLike · OfrepOptions · OpenFeatureClientLike · OpenFeatureOptions

ofrep

function

function ofrep(opts: OfrepOptions): FlagSource;

openfeature

function

function openfeature(client: OpenFeatureClientLike, opts?: OpenFeatureOptions): FlagSource;

EvaluationContextLike

interface

interface EvaluationContextLike {/*…*/}

EvaluationContextLike.targetingKey

targetingKey?: string;

OfrepOptions

interface

interface OfrepOptions {/*…*/}

OfrepOptions.url

OFREP base URL (the adapter calls <url>/ofrep/v1/evaluate/flags/bulk).

url: string;

OfrepOptions.headers

Static headers (auth token, tenant) sent with every evaluation.

headers?: Record<string, string>;

OfrepOptions.context

Build the OFREP evaluation context from the request (default: visitor sub → targetingKey plus every own key of c.visitor).

context?: (c: CtxLike) => Record<string, unknown>;

OfrepOptions.fetch

Per-request fetch (default global).

fetch?: typeof fetch;

OfrepOptions.timeout

Abort the evaluation after N ms (default 800 — a flag service must not gate first byte).

timeout?: number;

OpenFeatureClientLike

interface

The slice of the OpenFeature server Client we use — structural, so any SDK version fits.

interface OpenFeatureClientLike {/*…*/}

OpenFeatureClientLike.getBooleanValue

getBooleanValue(flagKey: string, defaultValue: boolean, context?: EvaluationContextLike): Promise<boolean>;

OpenFeatureClientLike.getStringValue

getStringValue(flagKey: string, defaultValue: string, context?: EvaluationContextLike): Promise<string>;

OpenFeatureClientLike.getObjectValue

Optional: variants that carry a config payload read via .value(c).

getObjectValue?<T>(flagKey: string, defaultValue: T, context?: EvaluationContextLike): Promise<T>;

OpenFeatureOptions

interface

interface OpenFeatureOptions {/*…*/}

OpenFeatureOptions.context

Build the OpenFeature evaluation context from the request (default: visitor sub → targetingKey, plus every own key of c.visitor).

context?: (c: CtxLike) => EvaluationContextLike;

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.

values?: boolean;