/** * Copyright 2026, Optimizely * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import type { UserInfo } from '../provider/types'; /** * Compares two string arrays for value equality (order-insensitive). * Used to prevent redundant user context creation when the segments prop * is referentially different but value-equal. */ export declare function areSegmentsEqual(a?: string[], b?: string[]): boolean; /** * Compares two UserInfo objects for value equality. * Used to prevent redundant user context creation when the user prop * is referentially different but value-equal. */ export declare function areUsersEqual(user1?: UserInfo | null, user2?: UserInfo | null): boolean; export interface QualifiedSegmentsResult { segments: string[]; error: Error | null; } /** * Fetches qualified ODP segments for a user given a datafile and user ID. * * This is a standalone, self-contained utility that: * 1. Parses the datafile to extract ODP configuration (apiKey, apiHost) * 2. Collects all ODP segments referenced in audience conditions * 3. Queries the ODP GraphQL API * 4. Returns only the segments where the user is qualified * * @param userId - The user ID to fetch qualified segments for * @param datafile - The Optimizely datafile (JSON object or string) * @returns Object with `segments` (qualified segment names) and `error` (null on success). * * @example * ```ts * const { segments, error } = await getQualifiedSegments('user-123', datafile); * if (!error) { * console.log('Qualified segments:', segments); * } * ``` */ export declare function getQualifiedSegments(userId: string, datafile: string | Record): Promise;