import { default as joi } from 'joi';
import type { Serializable } from '@nhtio/serialization/types';
import type { ConnectionStatus, KyooConfigurationOptions } from '.';
import type { KyooConnectionToAdapterBus } from '../utils/connection_to_adapter_bus';
import type { KyooJob, KyooJobToEnqueue, KyooWorkable } from '../job';
import type { AMQPTlsOptions } from '@cloudamqp/amqp-client';
/**
 * @private
 */
export type AMQPAMQPUrl = `amqp://${string}`;
/**
 * @private
 */
export type AMQPAMQPSUrl = `amqps://${string}`;
/**
 * A URL using either the "amqp" or "amqps" protocol.
 */
export type AMQPUrl = AMQPAMQPUrl | AMQPAMQPSUrl;
/**
 * Values supported by AMQP queue declaration arguments.
 */
export type AMQPQueueArgumentValue = string | number | boolean;
/**
 * Describes the shape of an object used for connecting to an AMQP server.
 */
export interface AMQPClientOptionsObject {
    /**
     * The protocol to use. Either "amqp" or "amqps".
     */
    protocol: 'amqp' | 'amqps';
    /**
     * The hostname of the server.
     */
    hostname: string;
    /**
     * The port to connect to. Defaults to 5672 for "amqp" and 5671 for "amqps".
     */
    port?: number;
    /**
     * The username to use for authentication. Defaults to "guest".
     */
    username?: string;
    /**
     * The password to use for authentication. Defaults to "guest".
     */
    password?: string;
    /**
     * The name of the connection to show in the RabbitMQ management UI. Omitted by default.
     */
    name?: string;
    /**
     * The size in bytes of the maximum frame allowed over the connection. 0 means no limit. Defaults to 8192.
     */
    frameMax?: number;
    /**
     * The maximum number of channels allowed. Defaults to 0 (unlimited).
     */
    channelMax?: number;
    /**
     * The period of the connection heartbeat, in seconds. Defaults to 0 (disabled).
     * @see https://www.rabbitmq.com/docs/heartbeats
     */
    heartbeat?: number;
    /**
     * The logically isolated namespace within the server. Defaults to "/".
     * @remarks This value is URI encoded when passed to the server.
     */
    vhost?: string;
}
/**
 * Describes the shape of the object used to configure the AMQP adapter.
 */
export interface AMQPAdapterConfiguration {
    /**
     * The host to connect to. This can be a URL string or an object with connection options.
     */
    host: AMQPUrl | AMQPClientOptionsObject;
    /**
     * Name of the Exchange which will be used for publishing and receiving events.
     * @remarks Cannot be the AMQP default or reserved exchange names.
     */
    exchange: string;
    /**
     * The optional TLS options for the connection.
     */
    tlsOptions?: AMQPTlsOptions;
    /**
     * Enforce the enqueueing sequence of jobs
     * @default true
     * @remarks If true, when multiple jobs are enqueued via the same function call,
     * there will be a delay of 10ms for each job after the first one.
     * This is to ensure that the jobs are enqueued in the order they were passed.
     */
    enforceEnqueueSequence?: boolean;
    /**
     * Additional arguments used when Kyoo declares AMQP queues.
     * @remarks String values may include `{queue}` to substitute the queue name at declaration time.
     */
    queueArguments?: Record<string, AMQPQueueArgumentValue>;
}
/** @private */
export declare function makeAMQPQueueArguments(queue: string, configuredArguments?: AMQPAdapterConfiguration['queueArguments']): Record<string, AMQPQueueArgumentValue>;
export declare const amqpAdapterConfigurationSchema: joi.ObjectSchema<any>;
/** @private */
export declare class AMQPAdapter {
    #private;
    /**
     * @private
     */
    constructor(configuration: AMQPAdapterConfiguration, bus: KyooConnectionToAdapterBus, options: KyooConfigurationOptions);
    connect(signal?: AbortSignal): Promise<boolean>;
    disconnect(terminate?: boolean): Promise<void>;
    get connectionStatus(): ConnectionStatus;
    get queues(): any;
    get jobs(): {
        enqueue: (queue: string, ...jobs: KyooJobToEnqueue[]) => Promise<boolean | boolean[]>;
        purge: (queue: string) => Promise<void>;
        next: <T = Serializable>(queue: string, noAck?: boolean, rejectable?: boolean, onDispositioned?: (disposition: "ack" | "nack") => void) => Promise<KyooWorkable<T> | undefined>;
        enqueued: (queue: string) => Promise<number>;
        fetch: <T = Serializable>(queue: string, count: number) => Promise<Array<KyooJob<T>>>;
    };
}
