UNPKG

flagsmith-nodejs

Version:

Flagsmith lets you manage features flags and remote config across web, mobile and server side applications. Deliver true Continuous Integration. Get builds out faster. Control who has access to new features.

42 lines (41 loc) 2.13 kB
import { GenericEvaluationContext, InSegmentCondition, SegmentCondition, SegmentContext } from '../evaluation/models.js'; /** * Returns all segments that the identity belongs to based on segment rules evaluation. * * An identity belongs to a segment if it matches ALL of the segment's rules. * If the context has no identity or segments, returns an empty array. * * @param context - Evaluation context containing identity and segment definitions * @returns Array of segments that the identity matches */ export declare function getIdentitySegments(context: GenericEvaluationContext): SegmentContext[]; /** * Evaluates whether a segment condition matches the identity's traits or context values. * * Handles different types of conditions: * - PERCENTAGE_SPLIT: Deterministic percentage-based bucketing using identity key * - IS_SET/IS_NOT_SET: Checks for trait existence * - Standard operators: EQUAL, NOT_EQUAL, etc. via SegmentConditionModel * - JSONPath expressions: $.identity.identifier, $.environment.name, etc. * * @param condition - The condition to evaluate (property, operator, value) * @param segmentKey - Key of the segment (used for percentage split hashing) * @param context - Evaluation context containing identity, traits, and environment * @returns true if the condition matches */ export declare function traitsMatchSegmentCondition(condition: SegmentCondition | InSegmentCondition, segmentKey: string, context?: GenericEvaluationContext): boolean; /** * Evaluates JSONPath expressions against the evaluation context. * * Supports accessing nested context values using JSONPath syntax. * Commonly used paths: * - $.identity.identifier - User's unique identifier * - $.identity.key - User's internal key * - $.environment.name - Environment name * - $.environment.key - Environment key * * @param jsonPath - JSONPath expression starting with '$.' * @param context - Evaluation context to query against * @returns The resolved value, or undefined if path doesn't exist or is invalid */ export declare function getContextValue(jsonPath: string, context?: GenericEvaluationContext): any;