import { KeyValuePair, FieldSchema, SparseFloatVector, FieldData } from '../';
import { Pool } from 'generic-pool';
/**
 * Failover handler type for global cluster support.
 * When attached to a pool, promisify will call this on UNAVAILABLE errors
 * after all interceptor retries are exhausted.
 * Should return a new pool to retry with, or null if no failover occurred.
 */
export type FailoverHandler = (error: any) => Promise<Pool<any> | null>;
/** Well-known property key for attaching a failover handler to a pool. */
export declare const FAILOVER_HANDLER_KEY = "__failoverHandler";
export declare const TELEMETRY_MANAGER_KEY = "__telemetryManager";
type TelemetryRecorder = {
    recordOperation(record: {
        operation: string;
        collection: string;
        startTime: number;
        error?: unknown;
        requestId?: string;
    }): void;
};
/** Attach the telemetry recorder used by the common RPC path. */
export declare function setPoolTelemetryManager(pool: Pool<any>, manager: TelemetryRecorder): void;
/**
 * Attach a failover handler to a pool for global cluster support.
 */
export declare function setPoolFailoverHandler(pool: Pool<any>, handler: FailoverHandler): void;
/**
 * Measure one complete public SDK operation, including validation, request
 * preprocessing, retries, response formatting, and postprocessing.
 *
 * promisify remains instrumented as a fallback for direct/internal callers, but
 * suppresses its RPC-level measurement while the same logical operation is active.
 */
export declare function withTelemetryLogicalOperation<T>(pool: Pool<any> | undefined, operation: string, params: any, call: () => Promise<T>): Promise<T>;
/**
 * Run internal SDK machinery without emitting telemetry. Iterators are not
 * logical operations, so neither their setup queries nor their per-page
 * internal RPCs may be measured: wrapping them here suppresses both the
 * logical-operation wrapper and the promisify RPC-level fallback.
 */
export declare function withTelemetrySuppressed<T>(call: () => Promise<T>): Promise<T>;
/**
 * Promisify a function call with optional timeout, metadata, and global cluster failover.
 * @param pool - The pool of gRPC clients
 * @param target - The name of the target function to call
 * @param params - The parameters to pass to the target function (may contain client_request_id or client-request-id)
 * @param timeout - Optional timeout in milliseconds
 * @param requestMetadata - Optional metadata to include in the request (e.g., client-request-id). If not provided, will be extracted from params automatically.
 * @returns A Promise that resolves with the result of the target function call
 */
export declare function promisify(pool: Pool<any>, target: string, params: any, timeout: number, requestMetadata?: {
    'client-request-id'?: string;
    client_request_id?: string;
}): Promise<any>;
export declare const findKeyValue: (obj: KeyValuePair[], key: string) => string | number | undefined;
export declare const sleep: (time: number) => Promise<unknown>;
/**
 * Returns the query iterator expression based on the provided parameters.
 *
 * @param params - The parameters for generating the query iterator expression.
 * @param params.expr - The expression to be combined with the iterator expression.
 * @param params.pkField - The primary key field schema.
 * @param params.lastPKId - The primary key cursor from the previous batch.
 * @param params.lastElementOffset - The struct element cursor from the previous batch.
 * @returns The query iterator expression.
 */
export declare const getQueryIteratorExpr: (params: {
    expr: string;
    pkField: FieldSchema;
    lastPKId?: string | number;
    lastElementOffset?: string | number;
}) => string;
export declare const getPKFieldExpr: (data: {
    pkField: FieldSchema;
    value: string | number;
    condition?: string;
    expr?: string;
}) => string;
export declare const getSparseDim: (data: SparseFloatVector[]) => number;
export declare const getValidDataArray: (data: FieldData[], length: number) => boolean[];
/** Returns whether value is a non-zero lowercase 128-bit OpenTelemetry trace ID. */
export declare const isValidClientRequestId: (value: unknown) => value is string;
/**
 * Extracts request metadata (traceid) from request data.
 * Supports both client_request_id and client-request-id formats.
 * Priority: client_request_id > client-request-id (JavaScript/TypeScript convention)
 * @param data - Request data that may contain traceid
 * @returns Request metadata object or undefined if no traceid provided
 */
export declare const extractRequestMetadata: (data: any) => {
    'client-request-id': string;
} | undefined;
export {};
