import type { LogLevel } from '@rocicorp/logger';
import type { ReadonlyJSONValue } from '../../shared/src/json.ts';
import type { MaybePromise } from '../../shared/src/types.ts';
import * as v from '../../shared/src/valita.ts';
import { pushParamsSchema, type CleanupResultsArg, type CustomMutation, type MutationResponse, type PushResponse } from '../../zero-protocol/src/push.ts';
import type { AnyMutatorRegistry } from '../../zql/src/mutate/mutator-registry.ts';
import type { CustomMutatorDefs, CustomMutatorImpl } from './custom.ts';
export interface TransactionProviderHooks {
    updateClientMutationID: () => Promise<{
        lastMutationID: number | bigint;
    }>;
    writeMutationResult: (result: MutationResponse) => Promise<void>;
    deleteMutationResults: (args: CleanupResultsArg) => Promise<void>;
}
export interface TransactionProviderInput {
    upstreamSchema: string;
    clientGroupID: string;
    clientID: string;
    mutationID: number;
}
/**
 * Defines the abstract interface for a database that PushProcessor can execute
 * transactions against.
 */
export interface Database<T> {
    transaction: <R>(callback: (tx: T, transactionHooks: TransactionProviderHooks) => MaybePromise<R>, transactionInput?: TransactionProviderInput) => Promise<R>;
}
export type ExtractTransactionType<D> = D extends Database<infer T> ? T : never;
export type Params = v.Infer<typeof pushParamsSchema>;
export type TransactFn<D extends Database<ExtractTransactionType<D>>> = (cb: TransactFnCallback<D>) => Promise<MutationResponse>;
export type TransactFnCallback<D extends Database<ExtractTransactionType<D>>> = (tx: ExtractTransactionType<D>, mutatorName: string, mutatorArgs: ReadonlyJSONValue | undefined) => Promise<void>;
export type Parsed<D extends Database<ExtractTransactionType<D>>> = {
    transact: TransactFn<D>;
    mutations: CustomMutation[];
};
/**
 * @deprecated Use {@linkcode handleMutateRequest} instead.
 */
export declare const handleMutationRequest: typeof handleMutateRequest;
export declare function handleMutateRequest<D extends Database<ExtractTransactionType<D>>>(dbProvider: D, cb: (transact: TransactFn<D>, mutation: CustomMutation) => Promise<MutationResponse>, queryString: URLSearchParams | Record<string, string>, body: ReadonlyJSONValue, logLevel?: LogLevel): Promise<PushResponse>;
export declare function handleMutateRequest<D extends Database<ExtractTransactionType<D>>>(dbProvider: D, cb: (transact: TransactFn<D>, mutation: CustomMutation) => Promise<MutationResponse>, request: Request, logLevel?: LogLevel): Promise<PushResponse>;
export declare class OutOfOrderMutation extends Error {
    constructor(clientID: string, receivedMutationID: number, lastMutationID: number | bigint);
}
/** @deprecated Use getMutator instead */
export declare function getMutation(mutators: AnyMutatorRegistry | CustomMutatorDefs<any>, name: string): CustomMutatorImpl<any>;
//# sourceMappingURL=process-mutations.d.ts.map