import * as i0 from '@angular/core'; import { OnInit, OnDestroy, OnChanges, ChangeDetectorRef, ViewContainerRef, TemplateRef, EmbeddedViewRef, InjectionToken, ModuleWithProviders } from '@angular/core'; import { FlagValue, EvaluationDetails, Client, 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'; /** * Represents the template context provided by feature flag structural directives * (`*booleanFeatureFlag`, `*numberFeatureFlag`, `*stringFeatureFlag`, `*objectFeatureFlag`). * * This class defines the shape of the data available in your templates when using * feature flag directives. It exposes: * - **`$implicit`** — The evaluated flag value, bound via `let value` in templates. * - **`evaluationDetails`** — The full {@link EvaluationDetails} object containing * metadata such as `flagKey`, `reason`, `variant`, `flagMetadata`, and potential error info. * * @usageNotes * * If you need to reference a feature flag template programmatically (e.g. with `@ViewChild`), * use this class as the generic parameter: * * ```typescript * @ViewChild('flagTpl') * flagTpl!: TemplateRef>; * ``` * * This is also useful when building custom components or wrappers that accept * feature flag templates as inputs: * * ```typescript * @Input() customTemplate: TemplateRef>; * ``` * * @template T The type of the flag value (`boolean`, `number`, `string`, or `JsonValue`). * */ declare class FeatureFlagDirectiveContext { $implicit: T; evaluationDetails: EvaluationDetails; constructor(details: EvaluationDetails); } declare abstract class FeatureFlagDirective 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; protected _readyHandler: EventHandler | null; protected _flagChangeHandler: EventHandler | null; protected _contextChangeHandler: EventHandler | null; protected _reconcilingHandler: EventHandler | null; protected _updateOnContextChanged: boolean; protected _updateOnConfigurationChanged: boolean; protected _thenTemplateRef: TemplateRef> | null; protected _thenViewRef: EmbeddedViewRef | null; protected _elseTemplateRef: TemplateRef> | null; protected _elseViewRef: EmbeddedViewRef | null; protected _initializingTemplateRef: TemplateRef> | null; protected _initializingViewRef: EmbeddedViewRef | null; protected _reconcilingTemplateRef: TemplateRef> | null; protected _reconcilingViewRef: EmbeddedViewRef | 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; protected onFlagValue(result: EvaluationDetails, status: ClientProviderStatus): void; static ɵfac: i0.ɵɵFactoryDeclaration, never>; static ɵdir: i0.ɵɵDirectiveDeclaration, "[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: * * ``` *
{{ value }}
* ``` * ``` *
Content to render when flag is true.
* Content to render when flag is false. * ``` * * @usageNotes * * You can specify templates for other statuses such as initializing and reconciling. * * ``` *
Content to render when flag is true.
* Content to render when flag is false. * Loading... * Reconfiguring... * ``` * */ declare class BooleanFeatureFlagDirective extends FeatureFlagDirective implements OnChanges { _changeDetectorRef: ChangeDetectorRef; _viewContainerRef: ViewContainerRef; _thenTemplateRef: TemplateRef>; /** * 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>); /** * Template to be displayed when the provider is not ready. */ set booleanFeatureFlagInitializing(tpl: TemplateRef>); /** * Template to be displayed when the provider is reconciling. */ set booleanFeatureFlagReconciling(tpl: TemplateRef>); static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } /** * 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: * * ``` *
{{ value }}
* ``` * ``` *
Content to render when flag matches value.
* Content to render when flag does not match value. * ``` * * @usageNotes * * You can specify templates for other statuses such as initializing and reconciling. * * ``` *
Content to render when flag matches value.
* Content to render when flag does not match value. * Loading... * Reconfiguring... * ``` * */ declare class NumberFeatureFlagDirective extends FeatureFlagDirective implements OnChanges { _changeDetectorRef: ChangeDetectorRef; _viewContainerRef: ViewContainerRef; _thenTemplateRef: TemplateRef>; /** * 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>); /** * Template to be displayed when the feature flag is not ready. */ set numberFeatureFlagInitializing(tpl: TemplateRef>); /** * Template to be displayed when the feature flag is not ready. */ set numberFeatureFlagReconciling(tpl: TemplateRef>); static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } /** * 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: * * ``` *
{{ value }}
* ``` * ``` *
Content to render when flag matches value.
* Content to render when flag does not match value. * ``` * * @usageNotes * * You can specify templates for other statuses such as initializing and reconciling. * * ``` *
Content to render when flag matches value.
* Content to render when flag does not match value. * Loading... * Reconfiguring... * ``` * */ declare class StringFeatureFlagDirective extends FeatureFlagDirective implements OnChanges { _changeDetectorRef: ChangeDetectorRef; _viewContainerRef: ViewContainerRef; _thenTemplateRef: TemplateRef>; /** * 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>); /** * Template to be displayed when the feature flag is not ready. */ set stringFeatureFlagInitializing(tpl: TemplateRef>); /** * Template to be displayed when the feature flag is reconciling. */ set stringFeatureFlagReconciling(tpl: TemplateRef>); static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } /** * 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: * * ``` *
{{ value }}
* ``` * ``` *
Content to render when flag matches value.
* Content to render when flag does not match value. * ``` * * @usageNotes * * You can specify templates for other statuses such as initializing and reconciling. * * ``` *
Content to render when flag matches value.
* Content to render when flag does not match value. * Loading... * Reconfiguring... * ``` * */ declare class ObjectFeatureFlagDirective extends FeatureFlagDirective implements OnChanges { _changeDetectorRef: ChangeDetectorRef; _viewContainerRef: ViewContainerRef; _thenTemplateRef: TemplateRef>; /** * 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>); /** * Template to be displayed when the feature flag is not ready. */ set objectFeatureFlagInitializing(tpl: TemplateRef>); /** * Template to be displayed when the feature flag is reconciling. */ set objectFeatureFlagReconciling(tpl: TemplateRef>); static ɵfac: i0.ɵɵFactoryDeclaration, never>; static ɵdir: i0.ɵɵDirectiveDeclaration, "[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>; /** * 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>; /** * 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>; /** * 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('api-config', defaultConfig); * ``` */ getObjectDetails(flagKey: string, defaultValue: T, domain?: string, options?: AngularFlagEvaluationOptions): Observable>; private shouldEvaluateFlag; private getFlagDetails; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } 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; /** * 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; declare class OpenFeatureModule { static forRoot(config: OpenFeatureConfig): ModuleWithProviders; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } export { BooleanFeatureFlagDirective, FeatureFlagDirective, FeatureFlagDirectiveContext, FeatureFlagService, NumberFeatureFlagDirective, OPEN_FEATURE_CONFIG_TOKEN, ObjectFeatureFlagDirective, OpenFeatureModule, StringFeatureFlagDirective }; export type { AngularFlagEvaluationOptions, EvaluationContextFactory, OpenFeatureConfig };