import type { ReadonlyJSONValue } from '../../../shared/src/json.ts';
import type { MutationOk } from '../../../zero-protocol/src/push.ts';
import type { Schema } from '../../../zero-schema/src/builder/schema-builder.ts';
import type { ClientTransaction, SchemaCRUD, SchemaQuery, Transaction } from '../../../zql/src/mutate/custom.ts';
import type { ClientID } from '../types/client-state.ts';
import type { WriteTransaction } from './replicache-types.ts';
import type { ZeroLogContext } from './zero-log-context.ts';
/**
 * The shape which a user's custom mutator definitions must conform to.
 */
export type CustomMutatorDefs = {
    [namespaceOrKey: string]: {
        [key: string]: CustomMutatorImpl<any>;
    } | CustomMutatorImpl<any>;
};
export type MutatorResult = {
    client: Promise<void>;
    server: Promise<MutationOk>;
};
export type CustomMutatorImpl<S extends Schema, TWrappedTransaction = unknown, TArgs = any> = (tx: Transaction<S, TWrappedTransaction>, args: TArgs) => Promise<void>;
/**
 * The shape exposed on the `Zero.mutate` instance.
 * The signature of a custom mutator takes a `transaction` as its first arg
 * but the user does not provide this arg when calling the mutator.
 *
 * This utility strips the `tx` arg from the user's custom mutator signatures.
 */
export type MakeCustomMutatorInterfaces<S extends Schema, MD extends CustomMutatorDefs> = {
    readonly [NamespaceOrName in keyof MD]: MD[NamespaceOrName] extends (tx: Transaction<S>, ...args: infer Args) => Promise<void> ? (...args: Args) => MutatorResult : {
        readonly [P in keyof MD[NamespaceOrName]]: MakeCustomMutatorInterface<S, MD[NamespaceOrName][P]>;
    };
};
export type MakeCustomMutatorInterface<S extends Schema, F> = F extends (tx: ClientTransaction<S>, ...args: infer Args) => Promise<void> ? (...args: Args) => MutatorResult : never;
export declare class TransactionImpl<S extends Schema> implements ClientTransaction<S> {
    constructor(lc: ZeroLogContext, repTx: WriteTransaction, schema: S);
    readonly clientID: ClientID;
    readonly mutationID: number;
    readonly reason: 'optimistic' | 'rebase';
    readonly location = "client";
    readonly mutate: SchemaCRUD<S>;
    readonly query: SchemaQuery<S>;
    readonly token: string | undefined;
}
export declare function makeReplicacheMutator<S extends Schema, TWrappedTransaction>(lc: ZeroLogContext, mutator: CustomMutatorImpl<S, TWrappedTransaction>, schema: S): (repTx: WriteTransaction, args: ReadonlyJSONValue) => Promise<void>;
//# sourceMappingURL=custom.d.ts.map