import type { LogContext } from '@rocicorp/logger';
import { type ErroredQuery } from '../../../zero-protocol/src/custom-queries.ts';
import { type TransformFailedBody } from '../../../zero-protocol/src/error.ts';
import type { TransformedAndHashed } from '../auth/read-authorizer.ts';
import { type HeaderOptions } from '../custom/fetch.ts';
import type { CustomQueryRecord } from '../services/view-syncer/schema/types.ts';
import type { ShardID } from '../types/shards.ts';
/**
 * Transforms a custom query by calling the user's API server.
 * Caches the transformed queries for 5 seconds to avoid unnecessary API calls.
 *
 * Error responses are not cached as the user may want to retry the query
 * and the error may be transient.
 *
 * The TTL was chosen to be 5 seconds since custom query requests come with
 * a token which itself may have a short TTL (e.g., 10 seconds).
 *
 * Token expiration isn't expected to be exact so this 5 second
 * caching shouldn't cause unexpected behavior. E.g., many JWT libraries
 * implement leeway for expiration checks: https://github.com/panva/jose/blob/main/docs/jwt/verify/interfaces/JWTVerifyOptions.md#clocktolerance
 *
 * The ViewSyncer will call the API server 3-4 times with the exact same queries
 * if we do not cache requests.
 *
 * Caching is safe here because the cache key encodes both
 * the user's cookies and auth token. A user cannot see another user's
 * transformed queries unless they share the same token and cookies.
 */
export declare class CustomQueryTransformer {
    #private;
    constructor(lc: LogContext, config: {
        url: string[];
        forwardCookies: boolean;
    }, shard: ShardID);
    transform(headerOptions: HeaderOptions, queries: Iterable<CustomQueryRecord>, userQueryURL: string | undefined): Promise<(TransformedAndHashed | ErroredQuery)[] | TransformFailedBody>;
}
//# sourceMappingURL=transform-query.d.ts.map