import type { Logger } from '@openfeature/server-sdk'; import { type EvaluationContext, type JsonValue, type OpenFeatureEventEmitter, type ResolutionDetails } from '@openfeature/server-sdk'; import type { IEvaluator } from './evaluator'; import type { GoFeatureFlagApi } from '../service/api'; import type { GoFeatureFlagProviderOptions } from '../go-feature-flag-provider-options'; /** * InProcessEvaluator is an implementation of the IEvaluator interface that evaluates feature flags in-process. * It uses the WASM evaluation engine to perform flag evaluations locally. */ export declare class InProcessEvaluator implements IEvaluator { private readonly api; private readonly options; private readonly evaluationEngine; private readonly logger?; private readonly eventChannel?; private etag?; private lastUpdate; private flags; private evaluationContextEnrichment; private periodicRunner?; private configurationState; /** * Constructor of the InProcessEvaluator. * @param api - API to contact GO Feature Flag * @param options - Options to configure the provider * @param eventChannel - Event channel to send events to the event bus or event handler * @param logger - Logger instance */ constructor(options: GoFeatureFlagProviderOptions, api: GoFeatureFlagApi, eventChannel: OpenFeatureEventEmitter, logger?: Logger); /** * Initialize the evaluator. */ initialize(): Promise; /** * Poll the configuration from the API. */ private poll; /** * Evaluates a boolean flag. * @param flagKey - The key of the flag to evaluate. * @param defaultValue - The default value to return if the flag is not found. * @param evaluationContext - The context in which to evaluate the flag. * @returns The resolution details of the flag evaluation. */ evaluateBoolean(flagKey: string, defaultValue: boolean, evaluationContext?: EvaluationContext): Promise>; /** * Evaluates a string flag. * @param flagKey - The key of the flag to evaluate. * @param defaultValue - The default value to return if the flag is not found. * @param evaluationContext - The context in which to evaluate the flag. * @returns The resolution details of the flag evaluation. */ evaluateString(flagKey: string, defaultValue: string, evaluationContext?: EvaluationContext): Promise>; /** * Evaluates a number flag. * @param flagKey - The key of the flag to evaluate. * @param defaultValue - The default value to return if the flag is not found. * @param evaluationContext - The context in which to evaluate the flag. * @returns The resolution details of the flag evaluation. */ evaluateNumber(flagKey: string, defaultValue: number, evaluationContext?: EvaluationContext): Promise>; /** * Evaluates an object flag. * @param flagKey - The key of the flag to evaluate. * @param defaultValue - The default value to return if the flag is not found. * @param evaluationContext - The context in which to evaluate the flag. * @returns The resolution details of the flag evaluation. */ evaluateObject(flagKey: string, defaultValue: T, evaluationContext?: EvaluationContext): Promise>; /** * Check if the flag is trackable. * @param flagKey - The key of the flag to check. * @returns True if the flag is trackable. */ isFlagTrackable(flagKey: string): boolean; /** * Dispose the evaluator. */ dispose(): Promise; /** * Evaluates a flag with the given key and default value in the context of the provided evaluation context. * @param flagKey - Name of the feature flag * @param defaultValue - Default value in case of error * @param evaluationContext - Context of the evaluation * @returns An EvaluationResponse containing the output of the evaluation. */ private genericEvaluate; /** * LoadConfiguration is responsible for loading the configuration of the flags from the API. * @throws ImpossibleToRetrieveConfigurationException - In case we are not able to call the relay proxy and to get the flag values. */ private loadConfiguration; /** * HandleError is handling the error response from the evaluation API. * @param response - Response of the evaluation. * @param flagKey - Name of the feature flag. * @throws Error - When the evaluation is on error. */ private handleError; /** * PrepareResponse is preparing the response to be returned to the caller. * @param response - Response of the evaluation. * @param flagKey - Name of the feature flag. * @param value - Value of the feature flag. * @returns ResolutionDetails with the flag value and metadata. */ private prepareResponse; }