@openfeature/angular-sdk
Version:
OpenFeature Angular SDK
557 lines (552 loc) • 29.1 kB
TypeScript
import * as i0 from '@angular/core';
import { OnInit, OnDestroy, OnChanges, ChangeDetectorRef, ViewContainerRef, TemplateRef, EmbeddedViewRef, InjectionToken, ModuleWithProviders } from '@angular/core';
import { FlagValue, Client, EvaluationDetails, EventHandler, ClientProviderEvents, ClientProviderStatus, JsonValue, FlagEvaluationOptions, EvaluationContext, Provider } from '@openfeature/web-sdk';
export * from '@openfeature/web-sdk';
import { Observable } from 'rxjs';
import * as i1 from '@angular/common';
declare class FeatureFlagDirectiveContext<T extends FlagValue> {
$implicit: T;
evaluationDetails: EvaluationDetails<T>;
constructor(details: EvaluationDetails<T>);
}
declare abstract class FeatureFlagDirective<T extends FlagValue> implements OnInit, OnDestroy, OnChanges {
protected _changeDetectorRef: ChangeDetectorRef;
protected _viewContainerRef: ViewContainerRef;
protected _featureFlagDefault: T;
protected _featureFlagDomain: string | undefined;
protected _featureFlagKey: string;
protected _featureFlagValue?: T;
protected _client: Client;
protected _lastEvaluationResult: EvaluationDetails<T>;
protected _readyHandler: EventHandler<ClientProviderEvents.Ready> | null;
protected _flagChangeHandler: EventHandler<ClientProviderEvents.ConfigurationChanged> | null;
protected _contextChangeHandler: EventHandler<ClientProviderEvents.Error> | null;
protected _reconcilingHandler: EventHandler<ClientProviderEvents.Reconciling> | null;
protected _updateOnContextChanged: boolean;
protected _updateOnConfigurationChanged: boolean;
protected _thenTemplateRef: TemplateRef<FeatureFlagDirectiveContext<T>> | null;
protected _thenViewRef: EmbeddedViewRef<unknown> | null;
protected _elseTemplateRef: TemplateRef<FeatureFlagDirectiveContext<T>> | null;
protected _elseViewRef: EmbeddedViewRef<unknown> | null;
protected _initializingTemplateRef: TemplateRef<FeatureFlagDirectiveContext<T>> | null;
protected _initializingViewRef: EmbeddedViewRef<unknown> | null;
protected _reconcilingTemplateRef: TemplateRef<FeatureFlagDirectiveContext<T>> | null;
protected _reconcilingViewRef: EmbeddedViewRef<unknown> | null;
protected constructor();
set featureFlagDomain(domain: string | undefined);
ngOnInit(): void;
ngOnChanges(): void;
ngOnDestroy(): void;
private initClient;
private disposeClient;
protected getFlagDetails(flagKey: string, defaultValue: T): EvaluationDetails<T>;
protected onFlagValue(result: EvaluationDetails<T>, status: ClientProviderStatus): void;
static ɵfac: i0.ɵɵFactoryDeclaration<FeatureFlagDirective<any>, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<FeatureFlagDirective<any>, "[featureFlag]", never, {}, {}, never, never, true, never>;
}
/**
* A structural directive that conditionally includes a template based on the evaluation
* of a boolean feature flag.
* When the flag evaluates to true, Angular renders the template provided in a `then` clause,
* and when false, Angular renders the template provided in an optional `else` clause.
* The default template for the `else` clause is blank.
*
* Usage examples:
*
* ```
* <div *booleanFeatureFlag="'flagKey'; default: false; let value">{{ value }}</div>
* ```
* ```
* <div *booleanFeatureFlag="flagKey; default: false; else: elseTemplate">Content to render when flag is true.</div>
* <ng-template #elseTemplate>Content to render when flag is false.</ng-template>
* ```
*
* @usageNotes
*
* You can specify templates for other statuses such as initializing and reconciling.
*
* ```
* <div *booleanFeatureFlag="flagKey; default:true; else: elseTemplate; initializing: initializingTemplate; reconciling: reconcilingTemplate">Content to render when flag is true.</div>
* <ng-template #elseTemplate>Content to render when flag is false.</ng-template>
* <ng-template #initializingTemplate>Loading...</ng-template>
* <ng-template #reconcilingTemplate>Reconfiguring...</ng-template>
* ```
*
*/
declare class BooleanFeatureFlagDirective extends FeatureFlagDirective<boolean> implements OnChanges {
_changeDetectorRef: ChangeDetectorRef;
_viewContainerRef: ViewContainerRef;
_thenTemplateRef: TemplateRef<FeatureFlagDirectiveContext<boolean>>;
/**
* The key of the boolean feature flag.
*/
booleanFeatureFlag: string;
/**
* The default value for the boolean feature flag.
*/
booleanFeatureFlagDefault: boolean;
constructor();
ngOnChanges(): void;
/**
* The domain of the boolean feature flag.
*/
set booleanFeatureFlagDomain(domain: string | undefined);
/**
* Update the component if the provider emits a ConfigurationChanged event.
* Set to false to prevent components from re-rendering when flag value changes
* are received by the associated provider.
* Defaults to true.
*/
set booleanFeatureFlagUpdateOnConfigurationChanged(enabled: boolean | undefined);
/**
* Update the component when the OpenFeature context changes.
* Set to false to prevent components from re-rendering when attributes which
* may be factors in flag evaluation change.
* Defaults to true.
*/
set booleanFeatureFlagUpdateOnContextChanged(enabled: boolean | undefined);
/**
* Template to be displayed when the feature flag is false.
*/
set booleanFeatureFlagElse(tpl: TemplateRef<FeatureFlagDirectiveContext<boolean>>);
/**
* Template to be displayed when the provider is not ready.
*/
set booleanFeatureFlagInitializing(tpl: TemplateRef<FeatureFlagDirectiveContext<boolean>>);
/**
* Template to be displayed when the provider is reconciling.
*/
set booleanFeatureFlagReconciling(tpl: TemplateRef<FeatureFlagDirectiveContext<boolean>>);
static ɵfac: i0.ɵɵFactoryDeclaration<BooleanFeatureFlagDirective, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<BooleanFeatureFlagDirective, "[booleanFeatureFlag]", never, { "booleanFeatureFlag": { "alias": "booleanFeatureFlag"; "required": true; }; "booleanFeatureFlagDefault": { "alias": "booleanFeatureFlagDefault"; "required": true; }; "booleanFeatureFlagDomain": { "alias": "booleanFeatureFlagDomain"; "required": false; }; "booleanFeatureFlagUpdateOnConfigurationChanged": { "alias": "booleanFeatureFlagUpdateOnConfigurationChanged"; "required": false; }; "booleanFeatureFlagUpdateOnContextChanged": { "alias": "booleanFeatureFlagUpdateOnContextChanged"; "required": false; }; "booleanFeatureFlagElse": { "alias": "booleanFeatureFlagElse"; "required": false; }; "booleanFeatureFlagInitializing": { "alias": "booleanFeatureFlagInitializing"; "required": false; }; "booleanFeatureFlagReconciling": { "alias": "booleanFeatureFlagReconciling"; "required": false; }; }, {}, never, never, true, never>;
}
/**
* A structural directive that conditionally includes a template based on the evaluation
* of a number feature flag.
* When the flag matches the provided value or no expected value is given, Angular renders the template provided
* in a `then` clause, and when it doesn't match, Angular renders the template provided
* in an optional `else` clause.
* The default template for the `else` clause is blank.
*
* Usage examples:
*
* ```
* <div *numberFeatureFlag="'flagKey'; default: 0; let value">{{ value }}</div>
* ```
* ```
* <div *numberFeatureFlag="'flagKey'; value: 1; default: 0; else: elseTemplate">Content to render when flag matches value.</div>
* <ng-template #elseTemplate>Content to render when flag does not match value.</ng-template>
* ```
*
* @usageNotes
*
* You can specify templates for other statuses such as initializing and reconciling.
*
* ```
* <div *numberFeatureFlag="flagKey; default: 0; value: flagValue; else: elseTemplate; initializing: initializingTemplate; reconciling: reconcilingTemplate">Content to render when flag matches value.</div>
* <ng-template #elseTemplate>Content to render when flag does not match value.</ng-template>
* <ng-template #initializingTemplate>Loading...</ng-template>
* <ng-template #reconcilingTemplate>Reconfiguring...</ng-template>
* ```
*
*/
declare class NumberFeatureFlagDirective extends FeatureFlagDirective<number> implements OnChanges {
_changeDetectorRef: ChangeDetectorRef;
_viewContainerRef: ViewContainerRef;
_thenTemplateRef: TemplateRef<FeatureFlagDirectiveContext<number>>;
/**
* The key of the number feature flag.
*/
numberFeatureFlag: string;
/**
* The default value for the number feature flag.
*/
numberFeatureFlagDefault: number;
/**
* The expected value of this number feature flag, for which the `then` template should be rendered.
*/
numberFeatureFlagValue?: number;
constructor();
ngOnChanges(): void;
/**
* The domain of the number feature flag.
*/
set numberFeatureFlagDomain(domain: string | undefined);
/**
* Update the component if the provider emits a ConfigurationChanged event.
* Set to false to prevent components from re-rendering when flag value changes
* are received by the associated provider.
* Defaults to true.
*/
set numberFeatureFlagUpdateOnConfigurationChanged(enabled: boolean | undefined);
/**
* Update the component when the OpenFeature context changes.
* Set to false to prevent components from re-rendering when attributes which
* may be factors in flag evaluation change.
* Defaults to true.
*/
set numberFeatureFlagUpdateOnContextChanged(enabled: boolean | undefined);
/**
* Template to be displayed when the feature flag does not match value.
*/
set numberFeatureFlagElse(tpl: TemplateRef<FeatureFlagDirectiveContext<number>>);
/**
* Template to be displayed when the feature flag is not ready.
*/
set numberFeatureFlagInitializing(tpl: TemplateRef<FeatureFlagDirectiveContext<number>>);
/**
* Template to be displayed when the feature flag is not ready.
*/
set numberFeatureFlagReconciling(tpl: TemplateRef<FeatureFlagDirectiveContext<number>>);
static ɵfac: i0.ɵɵFactoryDeclaration<NumberFeatureFlagDirective, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<NumberFeatureFlagDirective, "[numberFeatureFlag]", never, { "numberFeatureFlag": { "alias": "numberFeatureFlag"; "required": true; }; "numberFeatureFlagDefault": { "alias": "numberFeatureFlagDefault"; "required": true; }; "numberFeatureFlagValue": { "alias": "numberFeatureFlagValue"; "required": false; }; "numberFeatureFlagDomain": { "alias": "numberFeatureFlagDomain"; "required": false; }; "numberFeatureFlagUpdateOnConfigurationChanged": { "alias": "numberFeatureFlagUpdateOnConfigurationChanged"; "required": false; }; "numberFeatureFlagUpdateOnContextChanged": { "alias": "numberFeatureFlagUpdateOnContextChanged"; "required": false; }; "numberFeatureFlagElse": { "alias": "numberFeatureFlagElse"; "required": false; }; "numberFeatureFlagInitializing": { "alias": "numberFeatureFlagInitializing"; "required": false; }; "numberFeatureFlagReconciling": { "alias": "numberFeatureFlagReconciling"; "required": false; }; }, {}, never, never, true, never>;
}
/**
* A structural directive that conditionally includes a template based on the evaluation
* of a string feature flag.
* When the flag matches the provided value or no expected value is given, Angular renders the template provided
* in a `then` clause, and when it doesn't match, Angular renders the template provided
* in an optional `else` clause.
* The default template for the `else` clause is blank.
*
* Usage examples:
*
* ```
* <div *stringFeatureFlag="'flagKey'; default: 'default'; let value">{{ value }}</div>
* ```
* ```
* <div *stringFeatureFlag="flagKey; default: 'default'; value: flagValue; else: elseTemplate">Content to render when flag matches value.</div>
* <ng-template #elseTemplate>Content to render when flag does not match value.</ng-template>
* ```
*
* @usageNotes
*
* You can specify templates for other statuses such as initializing and reconciling.
*
* ```
* <div *stringFeatureFlag="flagKey; default: 'default'; value: flagValue; else: elseTemplate; initializing: initializingTemplate; reconciling: reconcilingTemplate">Content to render when flag matches value.</div>
* <ng-template #elseTemplate>Content to render when flag does not match value.</ng-template>
* <ng-template #initializingTemplate>Loading...</ng-template>
* <ng-template #reconcilingTemplate>Reconfiguring...</ng-template>
* ```
*
*/
declare class StringFeatureFlagDirective extends FeatureFlagDirective<string> implements OnChanges {
_changeDetectorRef: ChangeDetectorRef;
_viewContainerRef: ViewContainerRef;
_thenTemplateRef: TemplateRef<FeatureFlagDirectiveContext<string>>;
/**
* The key of the string feature flag.
*/
stringFeatureFlag: string;
/**
* The default value for the string feature flag.
*/
stringFeatureFlagDefault: string;
/**
* The expected value of this string feature flag, for which the `then` template should be rendered.
*/
stringFeatureFlagValue?: string;
constructor();
ngOnChanges(): void;
/**
* The domain for the string feature flag.
*/
set stringFeatureFlagDomain(domain: string | undefined);
/**
* Update the component if the provider emits a ConfigurationChanged event.
* Set to false to prevent components from re-rendering when flag value changes
* are received by the associated provider.
* Defaults to true.
*/
set stringFeatureFlagUpdateOnConfigurationChanged(enabled: boolean | undefined);
/**
* Update the component when the OpenFeature context changes.
* Set to false to prevent components from re-rendering when attributes which
* may be factors in flag evaluation change.
* Defaults to true.
*/
set stringFeatureFlagUpdateOnContextChanged(enabled: boolean | undefined);
/**
* Template to be displayed when the feature flag does not match value.
*/
set stringFeatureFlagElse(tpl: TemplateRef<FeatureFlagDirectiveContext<string>>);
/**
* Template to be displayed when the feature flag is not ready.
*/
set stringFeatureFlagInitializing(tpl: TemplateRef<FeatureFlagDirectiveContext<string>>);
/**
* Template to be displayed when the feature flag is reconciling.
*/
set stringFeatureFlagReconciling(tpl: TemplateRef<FeatureFlagDirectiveContext<string>>);
static ɵfac: i0.ɵɵFactoryDeclaration<StringFeatureFlagDirective, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<StringFeatureFlagDirective, "[stringFeatureFlag]", never, { "stringFeatureFlag": { "alias": "stringFeatureFlag"; "required": true; }; "stringFeatureFlagDefault": { "alias": "stringFeatureFlagDefault"; "required": true; }; "stringFeatureFlagValue": { "alias": "stringFeatureFlagValue"; "required": false; }; "stringFeatureFlagDomain": { "alias": "stringFeatureFlagDomain"; "required": false; }; "stringFeatureFlagUpdateOnConfigurationChanged": { "alias": "stringFeatureFlagUpdateOnConfigurationChanged"; "required": false; }; "stringFeatureFlagUpdateOnContextChanged": { "alias": "stringFeatureFlagUpdateOnContextChanged"; "required": false; }; "stringFeatureFlagElse": { "alias": "stringFeatureFlagElse"; "required": false; }; "stringFeatureFlagInitializing": { "alias": "stringFeatureFlagInitializing"; "required": false; }; "stringFeatureFlagReconciling": { "alias": "stringFeatureFlagReconciling"; "required": false; }; }, {}, never, never, true, never>;
}
/**
* A structural directive that conditionally includes a template based on the evaluation
* of an object feature flag.
* When the flag matches the provided value or no expected value is given, Angular renders the template provided
* in a `then` clause, and when it doesn't match, Angular renders the template provided
* in an optional `else` clause.
* The default template for the `else` clause is blank.
*
* Usage examples:
*
* ```
* <div *objectFeatureFlag="'flagKey'; default: {}; let value">{{ value }}</div>
* ```
* ```
* <div *objectFeatureFlag="flagKey; default: {}; value: flagValue; else: elseTemplate">Content to render when flag matches value.</div>
* <ng-template #elseTemplate>Content to render when flag does not match value.</ng-template>
* ```
*
* @usageNotes
*
* You can specify templates for other statuses such as initializing and reconciling.
*
* ```
* <div *objectFeatureFlag="flagKey; default: {}; value: flagValue; else: elseTemplate; initializing: initializingTemplate; reconciling: reconcilingTemplate">Content to render when flag matches value.</div>
* <ng-template #elseTemplate>Content to render when flag does not match value.</ng-template>
* <ng-template #initializingTemplate>Loading...</ng-template>
* <ng-template #reconcilingTemplate>Reconfiguring...</ng-template>
* ```
*
*/
declare class ObjectFeatureFlagDirective<T extends JsonValue> extends FeatureFlagDirective<T> implements OnChanges {
_changeDetectorRef: ChangeDetectorRef;
_viewContainerRef: ViewContainerRef;
_thenTemplateRef: TemplateRef<FeatureFlagDirectiveContext<T>>;
/**
* The key of the object feature flag.
*/
objectFeatureFlag: string;
/**
* The default value for the object feature flag.
*/
objectFeatureFlagDefault: T;
/**
* The expected value of this object feature flag, for which the `then` template should be rendered.
*/
objectFeatureFlagValue?: T;
constructor();
ngOnChanges(): void;
/**
* The domain for the object feature flag.
*/
set objectFeatureFlagDomain(domain: string | undefined);
/**
* Update the component if the provider emits a ConfigurationChanged event.
* Set to false to prevent components from re-rendering when flag value changes
* are received by the associated provider.
* Defaults to true.
*/
set objectFeatureFlagUpdateOnConfigurationChanged(enabled: boolean | undefined);
/**
* Update the component when the OpenFeature context changes.
* Set to false to prevent components from re-rendering when attributes which
* may be factors in flag evaluation change.
* Defaults to true.
*/
set objectFeatureFlagUpdateOnContextChanged(enabled: boolean | undefined);
/**
* Template to be displayed when the feature flag does not match value.
*/
set objectFeatureFlagElse(tpl: TemplateRef<FeatureFlagDirectiveContext<T>>);
/**
* Template to be displayed when the feature flag is not ready.
*/
set objectFeatureFlagInitializing(tpl: TemplateRef<FeatureFlagDirectiveContext<T>>);
/**
* Template to be displayed when the feature flag is reconciling.
*/
set objectFeatureFlagReconciling(tpl: TemplateRef<FeatureFlagDirectiveContext<T>>);
static ɵfac: i0.ɵɵFactoryDeclaration<ObjectFeatureFlagDirective<any>, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<ObjectFeatureFlagDirective<any>, "[objectFeatureFlag]", never, { "objectFeatureFlag": { "alias": "objectFeatureFlag"; "required": true; }; "objectFeatureFlagDefault": { "alias": "objectFeatureFlagDefault"; "required": true; }; "objectFeatureFlagValue": { "alias": "objectFeatureFlagValue"; "required": false; }; "objectFeatureFlagDomain": { "alias": "objectFeatureFlagDomain"; "required": false; }; "objectFeatureFlagUpdateOnConfigurationChanged": { "alias": "objectFeatureFlagUpdateOnConfigurationChanged"; "required": false; }; "objectFeatureFlagUpdateOnContextChanged": { "alias": "objectFeatureFlagUpdateOnContextChanged"; "required": false; }; "objectFeatureFlagElse": { "alias": "objectFeatureFlagElse"; "required": false; }; "objectFeatureFlagInitializing": { "alias": "objectFeatureFlagInitializing"; "required": false; }; "objectFeatureFlagReconciling": { "alias": "objectFeatureFlagReconciling"; "required": false; }; }, {}, never, never, true, never>;
}
type AngularFlagEvaluationOptions = {
/**
* Update the component if the provider emits a ConfigurationChanged event.
* Set to false to prevent updating the value when flag value changes
* are received by the associated provider.
* Defaults to true.
*/
updateOnConfigurationChanged?: boolean;
/**
* Emit a new value when the OpenFeature context changes.
* Set to false to prevent updating the value when attributes which
* may be factors in flag evaluation change.
* Defaults to true.
*/
updateOnContextChanged?: boolean;
} & FlagEvaluationOptions;
/**
* Angular service for evaluating feature flags using OpenFeature.
*
* This service provides reactive methods to evaluate feature flags that automatically
* update when flag values or evaluation context changes. All methods return Observables
* that emit new values when the underlying flag configuration changes.
*
* @example
* ```typescript
* @Component({
* standalone: true,
* })
* export class MyComponent {
* private flagService = inject(FeatureFlagService);
*
* // Boolean flag evaluation
* isEnabled$ = this.flagService.getBooleanDetails('my-flag', false);
*
* // Using with signals
* isEnabledSignal = toSignal(this.isEnabled$);
* }
* ```
*/
declare class FeatureFlagService {
constructor();
/**
* Evaluates a boolean feature flag and returns an Observable of evaluation details.
*
* The returned Observable will emit new values when:
* - The provider becomes ready (if it wasn't already)
* - The flag configuration changes (if updateOnConfigurationChanged is true)
* - The evaluation context changes (if updateOnContextChanged is true)
*
* @param flagKey - The key of the feature flag to evaluate
* @param defaultValue - The default value to return if the flag cannot be evaluated
* @param domain - Optional domain for the OpenFeature client. If not provided, uses the global client
* @param options - Optional evaluation options including update behavior configuration
* @returns Observable that emits EvaluationDetails containing the boolean flag value and metadata
*
* @example
* ```typescript
* // Basic usage
* const isFeatureEnabled$ = flagService.getBooleanDetails('feature-toggle', false);
*
* // With domain
* const isDomainFeatureEnabled$ = flagService.getBooleanDetails('feature-toggle', false, 'my-domain');
*
* // With options to disable automatic updates
* const isStaticFeatureEnabled$ = flagService.getBooleanDetails('feature-toggle', false, undefined, {
* updateOnConfigurationChanged: false,
* updateOnContextChanged: false
* });
* ```
*/
getBooleanDetails(flagKey: string, defaultValue: boolean, domain?: string, options?: AngularFlagEvaluationOptions): Observable<EvaluationDetails<boolean>>;
/**
* Evaluates a string feature flag and returns an Observable of evaluation details.
*
* The returned Observable will emit new values when:
* - The provider becomes ready (if it wasn't already)
* - The flag configuration changes (if updateOnConfigurationChanged is true)
* - The evaluation context changes (if updateOnContextChanged is true)
*
* @param flagKey - The key of the feature flag to evaluate
* @param defaultValue - The default value to return if the flag cannot be evaluated
* @param domain - Optional domain for the OpenFeature client. If not provided, uses the global client
* @param options - Optional evaluation options including update behavior configuration
* @returns Observable that emits EvaluationDetails containing the string flag value and metadata
*
* @example
* ```typescript
* // Theme selection
* const theme$ = flagService.getStringDetails('theme', 'light');
*
* // API endpoint selection with domain
* const apiEndpoint$ = flagService.getStringDetails('api-endpoint', 'https://api.example.com', 'config-domain');
* ```
*/
getStringDetails(flagKey: string, defaultValue: string, domain?: string, options?: AngularFlagEvaluationOptions): Observable<EvaluationDetails<string>>;
/**
* Evaluates a number feature flag and returns an Observable of evaluation details.
*
* The returned Observable will emit new values when:
* - The provider becomes ready (if it wasn't already)
* - The flag configuration changes (if updateOnConfigurationChanged is true)
* - The evaluation context changes (if updateOnContextChanged is true)
*
* @param flagKey - The key of the feature flag to evaluate
* @param defaultValue - The default value to return if the flag cannot be evaluated
* @param domain - Optional domain for the OpenFeature client. If not provided, uses the global client
* @param options - Optional evaluation options including update behavior configuration
* @returns Observable that emits EvaluationDetails containing the number flag value and metadata
*
* @example
* ```typescript
* // Timeout configuration
* const timeout$ = flagService.getNumberDetails('request-timeout', 5000);
* ```
*/
getNumberDetails(flagKey: string, defaultValue: number, domain?: string, options?: AngularFlagEvaluationOptions): Observable<EvaluationDetails<number>>;
/**
* Evaluates an object feature flag and returns an Observable of evaluation details.
*
* The returned Observable will emit new values when:
* - The provider becomes ready (if it wasn't already)
* - The flag configuration changes (if updateOnConfigurationChanged is true)
* - The evaluation context changes (if updateOnContextChanged is true)
*
* @template T - The type of the JSON object, must extend JsonValue
* @param flagKey - The key of the feature flag to evaluate
* @param defaultValue - The default value to return if the flag cannot be evaluated
* @param domain - Optional domain for the OpenFeature client. If not provided, uses the global client
* @param options - Optional evaluation options including update behavior configuration
* @returns Observable that emits EvaluationDetails containing the object flag value and metadata
*
* @example
* ```typescript
* interface FeatureConfig {
* maxRetries: number;
* retryDelay: number;
* enableLogging: boolean;
* }
*
* // Configuration object
* const defaultConfig: FeatureConfig = {
* maxRetries: 3,
* retryDelay: 1000,
* enableLogging: false
* };
*
* const config$ = flagService.getObjectDetails<FeatureConfig>('api-config', defaultConfig);
* ```
*/
getObjectDetails<T extends JsonValue = JsonValue>(flagKey: string, defaultValue: T, domain?: string, options?: AngularFlagEvaluationOptions): Observable<EvaluationDetails<T>>;
private shouldEvaluateFlag;
private getFlagDetails;
static ɵfac: i0.ɵɵFactoryDeclaration<FeatureFlagService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<FeatureFlagService>;
}
type EvaluationContextFactory = () => EvaluationContext;
interface OpenFeatureConfig {
/**
* The default provider to be used by OpenFeature.
* If not provided, the provider can be set later using {@link OpenFeature.setProvider}
* or {@link OpenFeature.setProviderAndWait}.
*/
provider?: Provider;
/**
* A map of domain-bound providers to be registered with OpenFeature.
* The key is the domain name, and the value is the provider instance.
* Providers can also be registered later using {@link OpenFeature.setProvider}
* or {@link OpenFeature.setProviderAndWait}.
*/
domainBoundProviders?: Record<string, Provider>;
/**
* An optional evaluation context or a factory function that returns an {@link EvaluationContext}.
* This context will be used as the context for all providers registered by the module.
* If a factory function is provided, it will be invoked to obtain the context.
* This allows for dynamic context generation at runtime.
*/
context?: EvaluationContext | EvaluationContextFactory;
}
declare const OPEN_FEATURE_CONFIG_TOKEN: InjectionToken<OpenFeatureConfig>;
declare class OpenFeatureModule {
static forRoot(config: OpenFeatureConfig): ModuleWithProviders<OpenFeatureModule>;
static ɵfac: i0.ɵɵFactoryDeclaration<OpenFeatureModule, never>;
static ɵmod: i0.ɵɵNgModuleDeclaration<OpenFeatureModule, never, [typeof i1.CommonModule], never>;
static ɵinj: i0.ɵɵInjectorDeclaration<OpenFeatureModule>;
}
export { BooleanFeatureFlagDirective, FeatureFlagDirective, FeatureFlagService, NumberFeatureFlagDirective, OPEN_FEATURE_CONFIG_TOKEN, ObjectFeatureFlagDirective, OpenFeatureModule, StringFeatureFlagDirective };
export type { AngularFlagEvaluationOptions, EvaluationContextFactory, OpenFeatureConfig };