import { interfaces } from "inversify";
import * as nats from "nats";
import { IBetterLogger } from "@codiac.io/codiac-common";
import { Result } from "@codiac.io/codiac-common/contracts";
import { IMessageReceivedMeta, IMessageSendMeta, IMessagingClient, MessagePayload } from "../../uilogic/i-messaging-client";
import { ApiUserCreds } from "../codiac-api";
export declare class NatsClientSettings {
    natsHost: string;
    natsPort: number;
    serializer: "json" | "yaml" | "string";
    /** The amount of time to wait for a response to a given request.  */
    requestTimeoutInSecs: number;
    constructor(natsHost: string, natsPort: number, serializer: "json" | "yaml" | "string", 
    /** The amount of time to wait for a response to a given request.  */
    requestTimeoutInSecs: number);
}
export declare class NatsClient implements IMessagingClient {
    private apiUserCreds;
    private logger;
    static bootstrap(ioc: interfaces.Container, settings?: Partial<NatsClientSettings>): void;
    static defaults: NatsClientSettings;
    /** Applied to this.tokenHeaderParam in the ctor.
     *  Typical name of the http request header that declares the authentication token for the request.  */
    static DEFAULT_TOKEN_HEADER_PARAM: string;
    constructor(apiUserCreds: ApiUserCreds | undefined, settings: Partial<NatsClientSettings>, logger: IBetterLogger);
    settings: NatsClientSettings;
    natsUrl: string;
    private cnxn;
    private listeners;
    connect(): Promise<string>;
    disconnect(): Promise<void>;
    isConnected(): boolean;
    get connectionId(): string | undefined;
    /** TODO: Expose typesafe messages instead of raw nats.Msg */
    subscribe<TMsg extends MessagePayload>(topics: string, handler: (err: Error | null, msg: TMsg, meta: IMessageReceivedMeta, raw: nats.Msg) => Promise<void>): string;
    /** Stops listening on the given topics. */
    unsubscribe(topics: string, options?: {
        force?: boolean;
        subscriptionId?: string;
    }): Promise<boolean>;
    /** THrows any errors. */
    private deserialize;
    private serialize;
    publish(msg: MessagePayload, meta?: Partial<IMessageSendMeta>): Promise<void>;
    private convertToNatsHeaders;
    request<TMsg extends MessagePayload, TRes extends Result>(msg: TMsg, meta?: Partial<IMessageSendMeta>, timeoutInSecs?: number): Promise<TRes>;
}
