import { EvaluationContext, TargetingRule, TargetingCondition, ConditionGroup, ComparisonOperator, RuleSchedule, VariantId, JsonValue } from './types'; /** * Result of targeting rule evaluation. */ export interface TargetingResult { /** Whether any rule matched */ readonly matched: boolean; /** The variant to serve */ readonly variantId?: VariantId; /** The rule that matched */ readonly ruleId?: string; /** The rule name */ readonly ruleName?: string; /** Evaluation details for debugging */ readonly details?: TargetingDetails; } /** * Detailed evaluation information for debugging. */ export interface TargetingDetails { /** All rules that were evaluated */ readonly evaluatedRules: readonly RuleEvaluation[]; /** Total evaluation time in ms */ readonly evaluationTimeMs: number; } /** * Evaluation result for a single rule. */ export interface RuleEvaluation { readonly ruleId: string; readonly ruleName: string; readonly matched: boolean; readonly skipped: boolean; readonly skipReason?: string; readonly conditionResults?: readonly ConditionResult[]; } /** * Evaluation result for a single condition. */ export interface ConditionResult { readonly attribute: string; readonly operator: ComparisonOperator; readonly expectedValue: JsonValue | readonly JsonValue[]; readonly actualValue: JsonValue | undefined; readonly matched: boolean; } /** * Engine for evaluating targeting rules against evaluation context. */ export declare class TargetingRulesEngine { private readonly debug; constructor(options?: { debug?: boolean; }); /** * Evaluate targeting rules and return the first matching variant. */ evaluate(rules: readonly TargetingRule[], context: EvaluationContext): TargetingResult; /** * Evaluate a single targeting rule. */ evaluateRule(rule: TargetingRule, context: EvaluationContext): RuleEvaluation; /** * Evaluate a condition group (AND/OR). */ private evaluateConditionGroup; /** * Evaluate either a condition or a nested group. */ private evaluateConditionOrGroup; /** * Evaluate a single condition. */ private evaluateCondition; /** * Resolve an attribute path to a value. * Supports dot notation: "user.custom.department" */ private resolveAttributePath; /** * Compare a value using the specified operator. */ private compare; private normalizeString; private equals; private contains; private startsWith; private endsWith; private matchesRegex; private isIn; private greaterThan; private greaterThanOrEquals; private lessThan; private lessThanOrEquals; private before; private after; private parseDate; private semverCompare; private isWithinSchedule; private toTimezone; } /** * Fluent builder for creating targeting rules. */ export declare class TargetingRuleBuilder { private rule; private conditions; private groupOperator; /** * Set the rule ID. */ id(id: string): this; /** * Set the rule name. */ name(name: string): this; /** * Set the rule description. */ description(description: string): this; /** * Set the rule priority. */ priority(priority: number): this; /** * Set whether the rule is enabled. */ enabled(enabled: boolean): this; /** * Set the variant to serve when matched. */ variant(variantId: VariantId): this; /** * Use AND to combine conditions. */ and(): this; /** * Use OR to combine conditions. */ or(): this; /** * Add a condition to the rule. */ condition(condition: TargetingCondition): this; /** * Add an attribute equals condition. */ where(attribute: string, value: JsonValue): this; /** * Add an attribute in list condition. */ whereIn(attribute: string, values: readonly JsonValue[]): this; /** * Add an attribute exists condition. */ whereExists(attribute: string): this; /** * Add a nested condition group. */ group(builder: (group: ConditionGroupBuilder) => void): this; /** * Set schedule constraints. */ schedule(schedule: RuleSchedule): this; /** * Build the targeting rule. */ build(): TargetingRule; } /** * Builder for condition groups. */ export declare class ConditionGroupBuilder { private conditions; private operator; and(): this; or(): this; condition(condition: TargetingCondition): this; where(attribute: string, value: JsonValue): this; build(): ConditionGroup; } /** * Create a new targeting rule builder. */ export declare function createTargetingRule(): TargetingRuleBuilder;