import type { LoggerWrapper } from "./ConfigCatLogger.js"; import { SettingType } from "./ConfigJson.js"; import { EvaluateLogBuilder } from "./EvaluateLogBuilder.js"; import type { PercentageOption, ProjectConfig, Setting, SettingMap, SettingValue, SettingValueContainer, TargetingRule, UnknownSettingType, VariationIdValue } from "./ProjectConfig.js"; import type { IUser } from "./User.js"; import type { Message, PickWithType } from "./Utils.js"; export declare class EvaluateContext { readonly key: string; readonly setting: Setting; readonly user: IUser | undefined; readonly settings: SettingMap; private _settingType; get settingType(): SettingType | UnknownSettingType; private _visitedFlags; get visitedFlags(): string[]; isMissingUserObjectLogged: boolean; isMissingUserObjectAttributeLogged: boolean; logBuilder: EvaluateLogBuilder | null; constructor(key: string, setting: Setting, user: IUser | undefined, settings: SettingMap); static forPrerequisiteFlag(key: string, setting: Setting, dependentFlagContext: EvaluateContext): EvaluateContext; } export type EvaluateResult = { returnValue: NonNullable; selectedValue: SettingValueContainer; matchedTargetingRule: TargetingRule | undefined; matchedPercentageOption: PercentageOption | undefined; }; export interface IRolloutEvaluator { evaluate(defaultValue: SettingValue, context: EvaluateContext): EvaluateResult; } export declare class RolloutEvaluator implements IRolloutEvaluator { private readonly logger; constructor(logger: LoggerWrapper); evaluate(defaultValue: SettingValue, context: EvaluateContext): EvaluateResult; private evaluateSetting; private evaluateTargetingRules; private evaluatePercentageOptions; private evaluateConditions; private evaluateUserCondition; private evaluateTextEquals; private evaluateSensitiveTextEquals; private evaluateTextIsOneOf; private evaluateSensitiveTextIsOneOf; private evaluateTextSliceEqualsAnyOf; private evaluateSensitiveTextSliceEqualsAnyOf; private evaluateTextContainsAnyOf; private evaluateSemVerIsOneOf; private evaluateSemVerRelation; private evaluateNumberRelation; private evaluateDateTimeRelation; private evaluateArrayContainsAnyOf; private evaluateSensitiveArrayContainsAnyOf; private evaluatePrerequisiteFlagCondition; private evaluateSegmentCondition; } export type SettingTypeOf = T extends boolean ? boolean : T extends number ? number : T extends string ? string : T extends null ? boolean | number | string | null : T extends undefined ? boolean | number | string | undefined : any; /** Specifies the possible evaluation error codes. */ export declare enum EvaluationErrorCode { /** An unexpected error occurred during the evaluation. */ UnexpectedError = -1, /** No error occurred (the evaluation was successful). */ None = 0, /** The evaluation failed because of an error in the config model. (Most likely, invalid data was passed to the SDK via flag overrides.) */ InvalidConfigModel = 1, /** The evaluation failed because of a type mismatch between the evaluated setting value and the specified default value. */ SettingValueTypeMismatch = 2, /** The evaluation failed because the config JSON was not available locally. */ ConfigJsonNotAvailable = 1000, /** The evaluation failed because the key of the evaluated setting was not found in the config JSON. */ SettingKeyMissing = 1001 } type EvaluationDetailsProps = { /** Key of the feature flag or setting. */ readonly key: string; /** Evaluated value of the feature or setting flag. */ readonly value: TValue; /** Variation ID of the feature or setting flag (if available). */ readonly variationId?: VariationIdValue; /** Time of last successful config download (if there has been a successful download already). */ readonly fetchTime?: Date; /** The User object used for the evaluation (if available). */ readonly user?: IUser; /** * Indicates whether the default value passed to the setting evaluation methods like `IConfigCatClient.getValueAsync`, `IConfigCatClient.getValueDetailsAsync`, etc. * is used as the result of the evaluation. */ readonly isDefaultValue: boolean; /** The code identifying the reason for the error in case evaluation failed. */ readonly errorCode: EvaluationErrorCode; /** Error message in case evaluation failed. */ readonly errorMessage?: string; /** The exception object related to the error in case evaluation failed (if any). */ readonly errorException?: undefined; /** The targeting rule (if any) that matched during the evaluation and was used to return the evaluated value. */ readonly matchedTargetingRule?: TargetingRule; /** The percentage option (if any) that was used to select the evaluated value. */ readonly matchedPercentageOption?: PercentageOption; }; /** @deprecated This type is kept for backward compatibility but will be removed in a future major version. Please use the more accurate `EvaluationDetails` type instead. */ export interface IEvaluationDetails extends EvaluationDetailsProps { readonly errorException?: any; } /** The evaluated value and additional information about the evaluation of a feature flag or setting. */ export type EvaluationDetails = EvaluationDetailsProps & PickWithType, { fetchTime: Date | undefined; user: IUser | undefined; }> & (PickWithType, { value: NonNullable; variationId: VariationIdValue; isDefaultValue: false; errorCode: EvaluationErrorCode.None; errorMessage?: undefined; errorException?: undefined; matchedTargetingRule: TargetingRule | undefined; matchedPercentageOption: PercentageOption | undefined; }> | PickWithType, { variationId?: undefined; isDefaultValue: true; errorCode: Exclude; errorMessage: string; errorException?: any; matchedTargetingRule?: undefined; matchedPercentageOption?: undefined; }>); export declare function evaluationDetailsFromDefaultValue(key: string, defaultValue: T, fetchTime: Date | undefined, user: IUser | undefined, errorMessage: Message, errorException?: any, errorCode?: Exclude): EvaluationDetails>; export declare function evaluate(evaluator: IRolloutEvaluator, settings: SettingMap | null, key: string, defaultValue: T, user: IUser | undefined, remoteConfig: ProjectConfig | null, logger: LoggerWrapper): EvaluationDetails>; export declare function evaluateAll(evaluator: IRolloutEvaluator, settings: SettingMap | null, user: IUser | undefined, remoteConfig: ProjectConfig | null, logger: LoggerWrapper, defaultReturnValue: string): [EvaluationDetails[], any[] | undefined]; export declare function checkSettingsAvailable(settings: SettingMap | null, logger: LoggerWrapper, defaultReturnValue: string): settings is SettingMap; /** Setting key-value pair. */ export type SettingKeyValue = { settingKey: string; settingValue: TValue; }; export declare function findKeyAndValue(settings: SettingMap | null, variationId: string, logger: LoggerWrapper, defaultReturnValue: string): SettingKeyValue | null; export declare class EvaluationError extends Error { readonly errorCode: Exclude; readonly message: string; readonly name: string; constructor(errorCode: Exclude, message: string); } export declare function getEvaluationErrorCode(err: any): Exclude; export {};