import { Readable, Writable, Duplex } from "stream";
import * as bridge from "@kurrent/bridge";
import { CallOptions, Channel, ChannelCredentials, Client as GRPCClient, Metadata, MethodDefinition } from "@grpc/grpc-js";
import type { NodePreference, GRPCClientConstructor, EndPoint, BasicCredentials, Credentials, BaseOptions, CredentialsProvider } from "../types";
import { ServerFeatures } from "./ServerFeatures";
interface ClientOptions {
    /**
     * The amount of time (in milliseconds) to wait after which a keepalive ping is sent on the transport.
     * Use -1 to disable.
     * @defaultValue 10_000
     */
    keepAliveInterval?: number;
    /**
     * The amount of time (in milliseconds) the sender of the keepalive ping waits for an acknowledgement.
     * If it does not receive an acknowledgement within this time, it will close the connection.
     * @defaultValue 10_000
     */
    keepAliveTimeout?: number;
    /**
     * Whether to immediately throw an exception when an append fails.
     * @defaultValue true
     */
    throwOnAppendFailure?: boolean;
    /**
     * An optional length of time (in milliseconds) to use for gRPC deadlines.
     * @defaultValue 10_000
     */
    defaultDeadline?: number;
    /**
     * The name of the connection to use in logs.
     * @defaultValue uuid
     */
    connectionName?: string;
}
interface DiscoveryOptions {
    /**
     * How many times to attempt connection before throwing.
     */
    maxDiscoverAttempts?: number;
    /**
     * How long to wait before retrying (in milliseconds).
     */
    discoveryInterval?: number;
    /**
     * How long to wait for the request to time out (in seconds).
     */
    gossipTimeout?: number;
    /**
     * Preferred node type.
     */
    nodePreference?: NodePreference;
}
export interface DNSClusterOptions extends DiscoveryOptions, ClientOptions {
    discover: EndPoint;
}
export interface GossipClusterOptions extends DiscoveryOptions, ClientOptions {
    endpoints: EndPoint[];
}
export interface SingleNodeOptions extends ClientOptions {
    endpoint: EndPoint | string;
}
export interface ChannelCredentialOptions {
    /**
     * Whether to use an insecure connection.
     */
    insecure?: boolean;
    /**
     * The root certificate data.
     */
    rootCertificate?: Buffer;
    /**
     * The file containing the user certificate’s matching private key in PEM format.
     */
    userKeyFile?: Buffer;
    /**
     * The file containing the X.509 user certificate in PEM format.
     */
    userCertFile?: Buffer;
    /**
     * Additional options to modify certificate verification.
     */
    verifyOptions?: Parameters<typeof ChannelCredentials.createSsl>[3];
}
export declare class Client {
    #private;
    /**
     * Returns a connection from a connection string.
     * @param connectionString - The connection string for your database.
     */
    static connectionString(connectionString: TemplateStringsArray | string, ...parts: Array<string | number | boolean>): Client;
    protected constructor(rustClient: bridge.RustClient, connectionSettings: DNSClusterOptions, channelCredentials?: ChannelCredentialOptions, defaultUserCredentials?: BasicCredentials);
    protected constructor(rustClient: bridge.RustClient, connectionSettings: GossipClusterOptions, channelCredentials?: ChannelCredentialOptions, defaultUserCredentials?: BasicCredentials);
    protected constructor(rustClient: bridge.RustClient, connectionSettings: SingleNodeOptions, channelCredentials?: ChannelCredentialOptions, defaultUserCredentials?: BasicCredentials);
    /**
     * The name of the connection to use in logs.
     * Can be set via {@link ClientOptions.connectionName} or `connectionName` in the connection string.
     */
    get connectionName(): string;
    /**
     * The {@link CredentialsProvider} currently in effect, if any. Read-only.
     * Use {@link setCredentialsProvider} to change it.
     */
    get credentialsProvider(): CredentialsProvider | undefined;
    /**
     * Set or clear the {@link CredentialsProvider} invoked before every request.
     * Per-call `credentials` override the provider. Otherwise the static
     * `defaultCredentials` are used.
     */
    setCredentialsProvider(provider: CredentialsProvider | undefined): void;
    private getGRPCClient;
    private disposableStreams;
    protected GRPCStreamCreator: <Client extends GRPCClient, T extends Writable | Readable | Duplex>(Client: GRPCClientConstructor<Client>, debugName: string, creator: (client: Client) => T | Promise<T>, cache?: WeakMap<Client, T | Promise<T>>) => () => Promise<T>;
    dispose: () => Promise<void>;
    protected execute: <Client extends GRPCClient, T>(Client: GRPCClientConstructor<Client>, debugName: string, action: (client: Client) => Promise<T>) => Promise<T>;
    protected get HTTPRequest(): <T = unknown>(method: "GET" | "HEAD" | "POST" | "PUT" | "DELETE" | "CONNECT" | "OPTIONS" | "TRACE" | "PATCH", path: string, { searchParams, ...options }: import("./http").HTTPRequestOptions, body?: string) => Promise<T>;
    protected getChannel: () => Promise<Channel>;
    private createGRPCClient;
    private shouldReconnect;
    protected handleError: (client: GRPCClient, error: Error) => Promise<void>;
    private createChannel;
    protected resolveUri: () => Promise<string>;
    private createMetadataGenerator;
    /**
     * Resolve the `Authorization` header value for a given request. Captures
     * the provider/default state at call time so in-flight requests are
     * unaffected by concurrent {@link setCredentialsProvider} swaps.
     */
    private resolveAuthorizationHeader;
    /**
     * Resolve the {@link Credentials} value to forward to the Rust bridge for
     * a given request. Per-call credentials win. Otherwise we invoke the
     * configured {@link CredentialsProvider}. Falls back to `undefined` so the
     * bridge uses the credentials baked into its connection string.
     */
    protected resolveBridgeCredentials: (perCallCredentials?: Credentials) => Promise<Credentials | undefined>;
    protected callArguments: ({ credentials, requiresLeader, deadline }: BaseOptions, callOptions?: CallOptions) => [Metadata, CallOptions];
    protected createDeadline(deadline?: number): Date;
    protected get capabilities(): Promise<ServerFeatures>;
    protected supports: (method: MethodDefinition<any, any>, feature?: string) => Promise<boolean>;
    protected get throwOnAppendFailure(): boolean;
    get rustClient(): bridge.RustClient;
}
export {};
