import * as Context from "../../Context.ts";
import * as Effect from "../../Effect.ts";
import type * as Queue from "../../Queue.ts";
import type { ReadonlyRecord } from "../../Record.ts";
import * as Scope from "../../Scope.ts";
import * as Stream from "../../Stream.ts";
import type { NoInfer } from "../../Types.ts";
import { Reactivity } from "../reactivity/Reactivity.ts";
import type * as Connection from "./SqlConnection.ts";
import type { SqlError } from "./SqlError.ts";
import type { Compiler, Constructor } from "./Statement.ts";
declare const TypeId = "~effect/sql/SqlClient";
/**
 * @category models
 * @since 4.0.0
 */
export interface SqlClient extends Constructor {
    readonly [TypeId]: typeof TypeId;
    /**
     * Copy of the client for safeql etc.
     */
    readonly safe: this;
    /**
     * Copy of the client without transformations.
     */
    readonly withoutTransforms: () => this;
    readonly reserve: Effect.Effect<Connection.Connection, SqlError, Scope.Scope>;
    /**
     * With the given effect, ensure all sql queries are run in a transaction.
     */
    readonly withTransaction: <R, E, A>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E | SqlError, R>;
    /**
     * The transaction service for this client.
     */
    readonly transactionService: Context.Service<TransactionConnection, TransactionConnection.Service>;
    /**
     * Use the Reactivity service from @effect/experimental to create a reactive
     * query.
     */
    readonly reactive: <A, E, R>(keys: ReadonlyArray<unknown> | ReadonlyRecord<string, ReadonlyArray<unknown>>, effect: Effect.Effect<A, E, R>) => Stream.Stream<A, E, R>;
    /**
     * Use the Reactivity service to create a reactive
     * query.
     */
    readonly reactiveMailbox: <A, E, R>(keys: ReadonlyArray<unknown> | ReadonlyRecord<string, ReadonlyArray<unknown>>, effect: Effect.Effect<A, E, R>) => Effect.Effect<Queue.Dequeue<A, E>, never, R | Scope.Scope>;
}
/**
 * @category models
 * @since 4.0.0
 */
export declare const SqlClient: Context.Service<SqlClient, SqlClient>;
/**
 * @category models
 * @since 4.0.0
 */
export declare namespace SqlClient {
    /**
     * @category models
     * @since 4.0.0
     */
    interface MakeOptions {
        readonly acquirer: Connection.Acquirer;
        readonly compiler: Compiler;
        readonly transactionAcquirer?: Connection.Acquirer;
        readonly spanAttributes: ReadonlyArray<readonly [string, unknown]>;
        readonly transactionService?: Context.Service<TransactionConnection, TransactionConnection.Service>;
        readonly beginTransaction?: string | undefined;
        readonly rollback?: string | undefined;
        readonly commit?: string | undefined;
        readonly savepoint?: ((name: string) => string) | undefined;
        readonly rollbackSavepoint?: ((name: string) => string) | undefined;
        readonly transformRows?: (<A extends object>(row: ReadonlyArray<A>) => ReadonlyArray<A>) | undefined;
        readonly reactiveQueue?: <A, E, R>(keys: ReadonlyArray<unknown> | ReadonlyRecord<string, ReadonlyArray<unknown>>, effect: Effect.Effect<A, E, R>) => Effect.Effect<Queue.Dequeue<A, E>, never, R | Scope.Scope>;
    }
}
/**
 * @category constructors
 * @since 4.0.0
 */
export declare const make: (options: SqlClient.MakeOptions) => Effect.Effect<SqlClient, never, Reactivity>;
/**
 * @since 4.0.0
 * @category transactions
 */
export declare const makeWithTransaction: <I, S>(options: {
    readonly transactionService: Context.Key<I, readonly [conn: S, counter: number]>;
    readonly spanAttributes: ReadonlyArray<readonly [string, unknown]>;
    readonly acquireConnection: Effect.Effect<readonly [Scope.Closeable | undefined, S], SqlError>;
    readonly begin: (conn: NoInfer<S>) => Effect.Effect<void, SqlError>;
    readonly savepoint: (conn: NoInfer<S>, id: number) => Effect.Effect<void, SqlError>;
    readonly commit: (conn: NoInfer<S>) => Effect.Effect<void, SqlError>;
    readonly rollback: (conn: NoInfer<S>) => Effect.Effect<void, SqlError>;
    readonly rollbackSavepoint: (conn: NoInfer<S>, id: number) => Effect.Effect<void, SqlError>;
}) => <R, E, A>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E | SqlError, R>;
/**
 * @since 4.0.0
 */
export interface TransactionConnection {
    readonly _: unique symbol;
}
/**
 * @since 4.0.0
 */
export declare namespace TransactionConnection {
    /**
     * @since 4.0.0
     */
    type Service = readonly [conn: Connection.Connection, depth: number];
}
/**
 * @since 4.0.0
 */
export declare const TransactionConnection: (clientId: number) => Context.Service<TransactionConnection, TransactionConnection.Service>;
/**
 * @since 4.0.0
 */
export declare const SafeIntegers: Context.Reference<boolean>;
export {};
//# sourceMappingURL=SqlClient.d.ts.map