import type { LogContext } from '@rocicorp/logger';
import type { JWTPayload } from 'jose';
import postgres from 'postgres';
import { ErrorKind } from '../../../../zero-protocol/src/error-kind.ts';
import { type CRUDMutation, type InsertOp, type Mutation, type UpsertOp } from '../../../../zero-protocol/src/push.ts';
import { type WriteAuthorizer } from '../../auth/write-authorizer.ts';
import { type ZeroConfig } from '../../config/zero-config.ts';
import type { PostgresDB, PostgresTransaction } from '../../types/pg.ts';
import { type ShardID } from '../../types/shards.ts';
import type { RefCountedService, Service } from '../service.ts';
export type MutationError = [
    kind: ErrorKind.MutationFailed | ErrorKind.MutationRateLimited,
    desc: string
];
export interface Mutagen extends RefCountedService {
    processMutation(mutation: Mutation, authData: JWTPayload | undefined, schemaVersion: number | undefined, customMutatorsEnabled: boolean): Promise<MutationError | undefined>;
}
export declare class MutagenService implements Mutagen, Service {
    #private;
    readonly id: string;
    constructor(lc: LogContext, shard: ShardID, clientGroupID: string, upstream: PostgresDB, config: ZeroConfig);
    ref(): void;
    unref(): void;
    hasRefs(): boolean;
    processMutation(mutation: Mutation, authData: JWTPayload | undefined, schemaVersion: number | undefined, customMutatorsEnabled?: boolean): Promise<MutationError | undefined>;
    run(): Promise<void>;
    stop(): Promise<void>;
}
export declare function processMutation(lc: LogContext, authData: JWTPayload | undefined, db: PostgresDB, shard: ShardID, clientGroupID: string, mutation: Mutation, writeAuthorizer: WriteAuthorizer, schemaVersion: number | undefined, onTxStart?: () => void | Promise<void>, // for testing
customMutatorsEnabled?: boolean): Promise<MutationError | undefined>;
export declare function processMutationWithTx(lc: LogContext, tx: PostgresTransaction, authData: JWTPayload | undefined, shard: ShardID, clientGroupID: string, schemaVersion: number | undefined, mutation: CRUDMutation, errorMode: boolean, authorizer: WriteAuthorizer): Promise<void>;
export declare function getInsertSQL(tx: postgres.TransactionSql, create: InsertOp): postgres.PendingQuery<postgres.Row[]>;
export declare function getUpsertSQL(tx: postgres.TransactionSql, set: UpsertOp): postgres.PendingQuery<postgres.Row[]>;
//# sourceMappingURL=mutagen.d.ts.map