/** * Copyright 2019, 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 * * http://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 * as optimizely from '@optimizely/optimizely-sdk'; export type UserInfo = { id: string | null; attributes?: optimizely.UserAttributes; }; export interface OptimizelyDecision extends Omit { userContext: UserInfo; } export declare function areUsersEqual(user1: UserInfo, user2: UserInfo): boolean; /** * Equality check applied to override user attributes passed into hooks. Used to determine when we need to recompute * a decision because a new set of override attributes was passed into a hook. * @param {UserAttributes|undefined} oldAttrs * @param {UserAttributes|undefined} newAttrs * @returns boolean */ export declare function areAttributesEqual(maybeOldAttrs: unknown, maybeNewAttrs: unknown): boolean; export declare function createFailedDecision(flagKey: string, message: string, user: UserInfo): OptimizelyDecision; export declare function sprintf(format: string, ...args: any[]): string; /** * 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 Array of qualified segment names, empty array if no segments configured, * or null if ODP is not integrated or the fetch fails. * * @example * ```ts * const segments = await getQualifiedSegments('user-123', datafile); * if (segments) { * console.log('Qualified segments:', segments); * } * ``` */ export declare function getQualifiedSegments(userId: string, datafile: string | Record): Promise;