/** * @see https://github.com/nats-io/nats.js * * @publicApi */ export interface NatsCodec { encode(d: T): Uint8Array; decode(a: Uint8Array): T; } interface RequestOptions { timeout: number; headers?: any; noMux?: boolean; reply?: string; } interface PublishOptions { reply?: string; headers?: any; } interface SubOpts { queue?: string; max?: number; timeout?: number; callback?: (err: object | null, msg: T) => void; } declare type SubscriptionOptions = SubOpts; export interface NatsMsg { subject: string; sid: number; reply?: string; data: Uint8Array; headers?: any; respond(data?: Uint8Array, opts?: PublishOptions): boolean; } interface Sub extends AsyncIterable { unsubscribe(max?: number): void; drain(): Promise; isDraining(): boolean; isClosed(): boolean; callback(err: object | null, msg: NatsMsg): void; getSubject(): string; getReceived(): number; getProcessed(): number; getPending(): number; getID(): number; getMax(): number | undefined; } declare type Subscription = Sub; declare enum Events { Disconnect = "disconnect", Reconnect = "reconnect", Update = "update", LDM = "ldm", Error = "error" } interface Status { type: Events | DebugEvents; data: string | number; } declare enum DebugEvents { Reconnecting = "reconnecting", PingTimer = "pingTimer", StaleConnection = "staleConnection" } export declare class Client { info?: Record; closed(): Promise; close(): Promise; publish(subject: string, data?: Uint8Array, options?: PublishOptions): void; subscribe(subject: string, opts?: SubscriptionOptions): Subscription; request(subject: string, data?: Uint8Array, opts?: RequestOptions): Promise; flush(): Promise; drain(): Promise; isClosed(): boolean; isDraining(): boolean; getServer(): string; status(): AsyncIterable; stats(): Record; jetstreamManager(opts?: Record): Promise; jetstream(opts?: Record): any; } export {};