import { FlagDefinition, SegmentDefinition, EvalContext, EvaluationDetail } from '@customyai/access/flags'; /** * @customyai/customy-access/flags — flags de Customy Access evaluadas en local. * * @deprecated Usa `createFlagsClient` de `@customyai/access/flags`. Este módulo * es su adaptador: la lectura de la instantánea (API o CDN), la firma, la * evaluación, las impresiones, las conversiones y el tiempo real son los de * `@customyai/access/flags`. Aquí se conserva la configuración de 0.x * (`bearerToken`, cabeceras de ámbito y rutas propias). */ type CustomyFlagsSnapshot = { schemaVersion: "2026-06-fme"; organizationId: string; projectId: string; environmentId: string; version: number; etag?: string; generatedAt: string; flags: FlagDefinition[]; segments?: SegmentDefinition[]; signature?: string; }; type CustomyFlagsClientConfig = { baseUrl: string; publishableKey?: string; bearerToken?: string; organizationId?: string; projectId?: string; environmentId?: string; snapshotPath?: string; impressionsPath?: string; conversionsPath?: string; realtimeTicketPath?: string; fetch?: typeof fetch; snapshot?: CustomyFlagsSnapshot; flushIntervalMs?: number; maxBatchSize?: number; sdkName?: string; sdkVersion?: string; /** * `optimized` (por defecto): una impresión por flag, clave y tratamiento y * hora; el resto de evaluaciones no viaja. `debug`: todas (solo para * depurar, nunca en producción con tráfico). */ impressionsMode?: "optimized" | "debug"; /** * Exige que cada instantánea venga firmada por el emisor de Access y que su * contenido coincida con lo firmado; si no, se rechaza y se conserva la * anterior. `true` usa `${baseUrl}/oauth/jwks.json`. */ verifySignature?: boolean | { jwksUrl: string; }; /** * Lee la instantánea pública por CDN en vez de por la API (necesita * `publishableKey`). `true` usa `baseUrl`; `{ baseUrl }`, otro origen. */ cdn?: boolean | { baseUrl: string; }; }; type CustomyFlagsSubscribeOptions = { /** Origen de customy-realtime, p. ej. `https://realtime.customy.ai`. */ realtimeUrl: string; /** Implementación de WebSocket si el entorno no la trae global (Node < 22). */ WebSocket?: new (url: string) => CustomyWebSocketLike; onError?: (error: Error) => void; /** Llamado tras aplicar una versión nueva recibida en vivo. */ onUpdate?: (snapshot: CustomyFlagsSnapshot) => void; }; type CustomyWebSocketLike = { onopen: ((event: unknown) => void) | null; onmessage: ((event: { data: unknown; }) => void) | null; onclose: ((event: unknown) => void) | null; onerror: ((event: unknown) => void) | null; close(): void; }; type CustomyFlagEvaluationOptions = { track?: boolean; }; type CustomyFlagImpression = { flagKey: string; contextKey: string; treatment: string; value?: unknown; reason: string; ruleId?: string; bucket?: number; occurredAt: string; attributes?: Record; }; type CustomyFlagConversion = { id: string; flagKey: string; contextKey: string; treatment: string; metric: string; value: number; occurredAt: string; }; type CustomyFlagConversionOptions = { /** Importe o cantidad de la conversión (0 por defecto). */ value?: number; /** Nombre de la métrica, p. ej. `purchase` (por defecto `conversion`). */ metric?: string; /** Identificador propio para que un reintento cuente una sola vez; si falta, se genera. */ id?: string; }; /** @deprecated Usa `CustomyFlagsClient` de `@customyai/access/flags`. */ declare class CustomyFlagsClient { private readonly inner; constructor(config: CustomyFlagsClientConfig); ready(): Promise; refresh(version?: number): Promise; getTreatment(flagKey: string, context: EvalContext, options?: CustomyFlagEvaluationOptions): EvaluationDetail; getBooleanValue(flagKey: string, defaultValue: boolean, context: EvalContext, options?: CustomyFlagEvaluationOptions): boolean; getStringValue(flagKey: string, defaultValue: string, context: EvalContext, options?: CustomyFlagEvaluationOptions): string; getNumberValue(flagKey: string, defaultValue: number, context: EvalContext, options?: CustomyFlagEvaluationOptions): number; getObjectValue(flagKey: string, defaultValue: T, context: EvalContext, options?: CustomyFlagEvaluationOptions): T; startPolling(intervalMs?: number): void; stopPolling(): void; subscribe(options: CustomyFlagsSubscribeOptions): () => void; track(detail: EvaluationDetail, context: EvalContext): void; trackConversion(flagKey: string, context: EvalContext, options?: CustomyFlagConversionOptions): boolean; startAutoFlush(): void; stopAutoFlush(): void; flush(): Promise; } declare function createFlagsClient(config: CustomyFlagsClientConfig): CustomyFlagsClient; export { type CustomyFlagConversion, type CustomyFlagConversionOptions, type CustomyFlagEvaluationOptions, type CustomyFlagImpression, CustomyFlagsClient, type CustomyFlagsClientConfig, type CustomyFlagsSnapshot, type CustomyFlagsSubscribeOptions, type CustomyWebSocketLike, createFlagsClient };