import type { MsgHdrs, Nanos, Payload, QueuedIterator, RequestOptions, ReviverFn, WithRequired } from "@nats-io/nats-core"; import type { ConsumerCreateOptions, DeliverPolicy, DirectLastFor, PrioritizedOptions, PullOptions, ReplayPolicy } from "./jsapi_types"; import type { ConsumerConfig, ConsumerInfo, ConsumerUpdateConfig, DirectBatchOptions, DirectMsgRequest, JetStreamAccountStats, MsgRequest, OverflowOptions, PurgeOpts, PurgeResponse, StreamAlternate, StreamConfig, StreamInfo, StreamInfoRequestOptions, StreamUpdateConfig } from "./jsapi_types"; import type { JsMsg } from "./jsmsg"; export type JetStreamOptions = { /** * Prefix required to interact with JetStream. Must match * server configuration. */ apiPrefix?: string; /** * Number of milliseconds to wait for a JetStream API request. * @default ConnectionOptions.timeout * @see ConnectionOptions.timeout */ timeout?: number; /** * Name of the JetStream domain. This value automatically modifies * the default JetStream apiPrefix. */ domain?: string; /** * Watcher prefix for inbox subscriptions - these are used for watchers * and push consumers. If not set, it uses ConnectionOptions#inboxPrefix */ watcherPrefix?: string; }; export type JetStreamManagerOptions = JetStreamOptions & { /** * Allows disabling a check on the account for JetStream enablement see * {@link JetStreamManager.getAccountInfo()}. */ checkAPI?: boolean; }; /** * The response returned by the JetStream server when a message is added to a stream. */ export type PubAck = { /** * The name of the stream */ stream: string; /** * The domain of the JetStream */ domain?: string; /** * The sequence number of the message as stored in JetStream */ seq: number; /** * True if the message is a duplicate */ duplicate: boolean; }; export type ScheduleOptions = { /** * The schedule specification format. * Currently only supports: * "@at " - e.g., `new Date(Date.now() + 60_000).toISOString()` * * Note: The ADR-51 specification defines additional formats that may be supported in future * server versions. */ specification: string | Date; /** * The subject the message will be delivered to */ target: string; /** * Instructs the schedule to read the last message on the given subject and publish. If the subject is empty, nothing is published. Wildcards are NOT supported. */ source?: string; /** * Sets a message TTL if the stream supports per-message TTL. */ ttl?: string; }; /** * StreamExpectations are used implement some assertions before adding a message * to the stream. */ export type StreamExpectations = { /** * The expected last msgID of the last message received by the stream. */ lastMsgID: string; /** * The expected stream capturing the message */ streamName: string; /** * The expected last sequence on the stream. */ lastSequence: number; /** * The expected last sequence on the stream for a message with this subject */ lastSubjectSequence: number; /** * This option is used in conjunction with {@link lastSubjectSequence}. It enables a * constraint on the sequence to be based on the specified subject (which can * have wildcards) rather than the subject of the message being published. * * Here's an example set of sequences for specific subjects: * * ┌─────────┬────────┐ * │ subj │ Seq │ * ├─────────┼────────┤ * │ a.1.foo │ 1 │ * │ a.1.bar │ 6 │ * │ a.2.foo │ 3 │ * │ a.3.bar │ 4 │ * │ a.1.baz │ 5 │ * │ a.2.baz │ 7 │ * └─────────┴────────┘ * * The LastSubjectSequenceSubject for wildcards in the last token * Are evaluated for to the largest sequence matching the subject: * ┌────────────────────┬────────┐ * | Last Subj Seq Subj | Seq | * ├────────────────────┼────────┤ * │ a.1.* │ 6 │ * │ a.2.* │ 7 │ * │ a.3.* │ 4 │ * └────────────────────┴────────┘ */ lastSubjectSequenceSubject: string; /** * The expected last sequence on the stream for a message with this subject * and this value. */ lastSubjectSequenceValue: number; }; /** * Options for messages published to JetStream */ export type JetStreamPublishOptions = { /** * A string identifier used to detect duplicate published messages. * If the msgID is reused within the stream's `duplicate_window`, * the message will be rejected by the stream, and the {@link PubAck} will * mark it as a `duplicate`. */ msgID: string; /** * The number of milliseconds to wait for the PubAck */ timeout: number; /** * Headers associated with the message. You can create an instance of * MsgHdrs with the headers() function. */ headers: MsgHdrs; /** * Set of constraints that when specified are verified by the server. * If the constraint(s) doesn't match, the server will reject the message. * These settings allow you to implement deduplication and consistency * strategies. */ expect: Partial; /** * Sets {@link PubHeaders.MessageTTL} this only applies to streams that enable * `StreamConfig.allow_msg_ttl`. The format of this value is "1s" or "1h", * etc, or a plain number interpreted as the number of seconds. */ ttl?: string; /** * Continue to attempt to publish if the publish fails due to a no responders error. * Default is 1. */ retries?: number; /** * Specifies the schedule for the message. */ schedule?: ScheduleOptions; }; /** * A type that reports via a promise when an object such as a connection * or subscription closes. */ export type Closed = { /** * A promise that when resolves, indicates that the object is closed. */ closed: Promise; }; export type Destroyable = { /** * Destroys a resource on the server. Returns a promise that resolves to true * whene the operation has been completed */ destroy(): Promise; }; /** * A generic type for listing. Returns a promise with typed list. */ export type Lister = { [Symbol.asyncIterator](): AsyncIterator; next(): Promise; }; export type ListerFieldFilter = (v: unknown) => T[]; export type StreamAPI = { /** * Returns the information about the specified stream * @param stream * @param opts */ info(stream: string, opts?: Partial): Promise; /** * Adds a new stream with the specified stream configuration. * @param cfg */ add(cfg: WithRequired, "name">): Promise; /** * Updates the stream configuration for the specified stream. * @param name * @param cfg */ update(name: string, cfg: Partial): Promise; /** * Purges messages from a stream that match the specified purge options. * @param stream * @param opts */ purge(stream: string, opts?: PurgeOpts): Promise; /** * Deletes the specified stream * @param stream */ delete(stream: string): Promise; /** * Lists all streams stored by JetStream * @param subject - only return streams that include the specified subject */ list(subject?: string): Lister; /** * Deletes the specified message sequence from the stream * @param stream * @param seq * @param erase - erase the message - by default true */ deleteMessage(stream: string, seq: number, erase?: boolean): Promise; /** * Retrieves the message matching the specified query. Messages can be * retrieved by sequence number or by last sequence matching a subject. * @param stream * @param query */ getMessage(stream: string, query: MsgRequest): Promise; /** * Find the stream that stores the specified subject. * @param subject */ find(subject: string): Promise; /** * Return a Lister of stream names * @param subject - if specified, the results are filtered to streams that contain the * subject (can be wildcarded) */ names(subject?: string): Lister; /** * Returns a Stream object * @param name */ get(name: string): Promise; }; export type ConsumerAPI = { /** * Returns the ConsumerInfo for the specified consumer in the specified stream. * @param stream * @param consumer */ info(stream: string, consumer: string): Promise; /** * Adds a new consumer to the specified stream with the specified consumer options. * @param stream * @param cfg * @param opts */ add(stream: string, cfg: Partial, opts?: ConsumerCreateOptions): Promise; /** * Updates the consumer configuration for the specified consumer on the specified * stream that has the specified durable name. * @param stream * @param durable * @param cfg */ update(stream: string, durable: string, cfg: Partial): Promise; /** * Deletes the specified consumer name/durable from the specified stream. * @param stream * @param consumer */ delete(stream: string, consumer: string): Promise; /** * Lists all the consumers on the specified streams * @param stream */ list(stream: string): Lister; /** * Pauses the consumer until the specified Date * @param stream * @param name * @param until */ pause(stream: string, name: string, until?: Date): Promise<{ paused: boolean; pause_until?: string; }>; /** * Resumes a paused Consumer, returning whether it is * paused and when it will resume. * @param stream * @param name */ resume(stream: string, name: string): Promise<{ paused: boolean; pause_until?: string; }>; /** * Unpins the currently pinned consumer. * @param stream * @param name * @param group */ unpin(stream: string, name: string, group: string): Promise; }; /** * The API for interacting with JetStream resources */ export type JetStreamManager = { /** * JetStream API to interact with Consumers */ consumers: ConsumerAPI; /** * JetStream API to interact with Streams */ streams: StreamAPI; /** * API for accessing messages in a stream without using a Consumer. * This API can retrieve values from any of the stream replicas, * which means that it may not reflect inflight changes to the stream. * Direct APIs require the stream to have the `direct` option * enabled. */ direct: DirectStreamAPI; /** * Returns JetStreamAccountStats for the current client account. */ getAccountInfo(): Promise; /** * Returns an async iteartor */ advisories(): AsyncIterable; /** * Returns the {@link JetStreamOptions} used to create this * JetStreamManager */ getOptions(): JetStreamOptions; /** * Returns a {@link JetStreamClient} created using the same * options as this JetStreamManager */ jetstream(): JetStreamClient; }; export type Ordered = { ordered: true; }; export type PushConsumerOptions = ConsumeCallback & AbortOnMissingResource; export type NextOptions = Expires & Bind; export type ConsumeBytes = MaxBytes & Partial & Partial & Expires & IdleHeartbeat & ConsumeCallback & AbortOnMissingResource & Bind & Partial & Partial; export type ConsumeMessages = Partial & Partial & Expires & IdleHeartbeat & ConsumeCallback & AbortOnMissingResource & Bind & Partial & Partial; export type ConsumeOptions = ConsumeBytes | ConsumeMessages; /** * Options for fetching bytes */ export type FetchBytes = MaxBytes & Partial & Expires & IdleHeartbeat & Bind & Partial & Partial; /** * Options for fetching messages */ export type FetchMessages = Partial & Expires & IdleHeartbeat & Bind & Partial & Partial; export type FetchOptions = FetchBytes | FetchMessages; export type PullConsumerOptions = FetchOptions | ConsumeOptions; export type MaxMessages = { /** * Maximum number of messages to retrieve. * @default 100 messages */ max_messages: number; }; export type MaxBytes = { /** * Maximum number of bytes to retrieve - note request must fit the entire message * to be honored (this includes, subject, headers, etc). Partial messages are not * supported. */ max_bytes: number; }; export type ThresholdMessages = { /** * Threshold message count on which the client will auto-trigger additional requests * from the server. This is only applicable to `consume`. * @default 75% of {@link MaxMessages}. */ threshold_messages: number; }; export type ThresholdBytes = { /** * Threshold bytes on which the client auto-triggers additional message requests * from the server. This is only applicable to `consume`. * @default 75% of {@link MaxBytes}. */ threshold_bytes: number; }; export type Expires = { /** * Number of milliseconds to wait for messages before issuing another request. * Note this value shouldn't be set by the user, as the default provides proper behavior. * A low value will stress the server. * * The minimum value is 1000 (1s). * @default 30_000 (30s) */ expires?: number; }; export type Bind = { /** * If set to true the client will not try to check on its consumer by issuing consumer info * requests. This means that the client may not report consumer not found, etc., and will simply * fail request for messages due to missed heartbeats. This option is exclusive of abort_on_missing_resource. * * This option is not valid on ordered consumers. */ bind?: boolean; }; export type AbortOnMissingResource = { /** * If true, consume will abort if the stream or consumer is not found. Default is to recover * once the stream/consumer is restored. This option is exclusive of bind. */ abort_on_missing_resource?: boolean; }; export type IdleHeartbeat = { /** * Number of milliseconds to wait for a server heartbeat when not actively receiving * messages. When two or more heartbeats are missed in a row, the consumer will emit * a notification. Note this value shouldn't be set by the user, as the default provides * the proper behavior. A low value will stress the server. */ idle_heartbeat?: number; }; export type ConsumerCallbackFn = (r: JsMsg) => void | Promise; export type ConsumeCallback = { /** * Process messages using a callback instead of an iterator. Note that when using callbacks, * the callback cannot be async. If you must use async functionality, process messages * using an iterator. */ callback?: ConsumerCallbackFn; }; /** * ConsumerNotifications are informational notifications emitted by ConsumerMessages * that may be of interest to a client. */ export type ConsumerNotification = HeartbeatsMissed | ConsumerNotFound | StreamNotFound | ConsumerDeleted | OrderedConsumerRecreated | ExceededLimits | Debug | Discard | Reset | Next | Heartbeat | FlowControl | NoResponders | ConsumerPinned | ConsumerUnpinned; /** * Notification that heartbeats were missed. This notification is informational. * The `data` portion of the status, is a number indicating the number of missed heartbeats. * Note that when a client disconnects, heartbeat tracking is paused while * the client is disconnected. */ export type HeartbeatsMissed = { type: "heartbeats_missed"; count: number; }; /** * Notification that the consumer was not found. Consumers that were accessible at * least once, will be retried for more messages regardless of the not being found * or timeouts etc. This notification includes a count of consecutive attempts to * find the consumer. Note that if you get this notification possibly your code should * attempt to recreate the consumer. Note that this notification is only informational * for ordered consumers, as the consumer will be created in those cases automatically. */ export type ConsumerNotFound = { type: "consumer_not_found"; name: string; stream: string; count: number; }; /** * Notification that the stream was not found. Consumers were accessible at least once, * will be retried for more messages regardless of the not being found * or timeouts etc. This notification includes a count of consecutive attempts to * find the consumer. Note that if you get this notification possibly your code should * attempt to recreate the consumer. Note that this notification is only informational * for ordered consumers, as the consumer will be created in those cases automatically. */ export type StreamNotFound = { type: "stream_not_found"; name: string; consumerCreateFails?: number; }; /** * Notification that the consumer was deleted. This notification * means the consumer will not get messages unless it is recreated. The client * will continue to attempt to pull messages. Ordered consumer will recreate it. */ export type ConsumerDeleted = { type: "consumer_deleted"; code: number; description: string; }; /** * Notification that a JetStream request didn't get a response due to a timeout * or JetStream not being available. */ export type NoResponders = { type: "no_responders"; code: number; }; /** * This notification is specific of ordered consumers and will be notified whenever * the consumer is recreated. The argument is the name of the newly created consumer. */ export type OrderedConsumerRecreated = { type: "ordered_consumer_recreated"; name: string; }; /** * This notification is specific to pull consumers and will be notified whenever * the pull request exceeds some limit such as maxwaiting, maxrequestbatch, etc. * The data component has the code (409) and the message from the server. */ export type ExceededLimits = { type: "exceeded_limits"; code: number; description: string; }; /** * DebugEvents are effectively statuses returned by the server that were ignored * by the client. The `code` and `description` indicate the server specified code and description. */ export type Debug = { type: "debug"; code: number; description: string; }; /** * Requests for messages can be terminated by the server, these notifications * provide information on the number of messages and/or bytes that couldn't * be satisfied by the consumer request. */ export type Discard = { type: "discard"; messagesLeft: number; bytesLeft: number; }; /** * Notifies that the current consumer will be reset */ export type Reset = { type: "reset"; name: string; }; /** * Notifies whenever there's a request for additional messages from the server. * This notification telegraphs the request options, which should be treated as * read-only. This notification is only useful for debugging. Data is PullOptions. */ export type Next = { type: "next"; options: PullOptions; }; /** * Notifies that the client received a server-side heartbeat. The payload the data * portion has the format `{natsLastConsumer: number, natsLastStream: number}`; */ export type Heartbeat = { type: "heartbeat"; lastConsumerSequence: number; lastStreamSequence: number; }; /** * Notifies that the client received a server-side flow control message. * The data is null. */ export type FlowControl = { type: "flow_control"; }; export type ConsumerPinned = { type: "consumer_pinned"; id: string; }; export type ConsumerUnpinned = { type: "consumer_unpinned"; }; export type PushConsumer = InfoableConsumer & DeleteableConsumer & ConsumerKind & { consume(opts?: PushConsumerOptions): Promise; }; export type ConsumerKind = { isPullConsumer(): boolean; isPushConsumer(): boolean; }; export type ExportedConsumer = ConsumerKind & { next(opts?: NextOptions): Promise; fetch(opts?: FetchOptions): Promise; consume(opts?: ConsumeOptions): Promise; }; export type InfoableConsumer = { info(cached?: boolean): Promise; }; export type DeleteableConsumer = { delete(): Promise; }; export type Consumer = ExportedConsumer & InfoableConsumer & DeleteableConsumer; export type Close = { close(): Promise; closed(): Promise; }; export type ConsumerMessages = QueuedIterator & Close & { status(): AsyncIterable; }; /** * These options are a subset of {@link ConsumerConfig} and * {@link ConsumerUpdateConfig} */ export type OrderedConsumerOptions = { name_prefix: string; filter_subjects: string[] | string; deliver_policy: DeliverPolicy; opt_start_seq: number; opt_start_time: string; replay_policy: ReplayPolicy; inactive_threshold: number; headers_only: boolean; }; export type OrderedPushConsumerOptions = OrderedConsumerOptions & { deliver_prefix: string; }; export declare function isOrderedPushConsumerOptions(v: unknown): v is OrderedPushConsumerOptions; export declare function isPullConsumer(v: PushConsumer | Consumer): v is Consumer; export declare function isPushConsumer(v: PushConsumer | Consumer): v is PushConsumer; export type BatchMessageOptions = Partial> & { expect?: Partial>; }; export type BatchMessageOptionsWithReply = { /** * Request acknowledgement of the message (only set this on some of the * messages, as this introduces a round trip to the server) */ ack: boolean; } & Partial; /** * A Batch represents a number of messages staged into a stream * atomically. The batch has several limits imposed by the server, * such as a batch may not contain more than 1000 messages (including * the message starting and ending the batch. And no more than 50 * batches on a stream can be active. Batches that are inactive for more * than 10 seconds, are abandoned by the server. * * For more information check the JetStream * documentation. */ export type Batch = { /** * The unique identifier for the batch, generated by the client when the * batch is created. */ readonly id: string; /** * The current number of messages currently added to the batch */ readonly count: number; /** * Appends the next message to the batch. * @param subj * @param payload * @param opts */ add(subj: string, payload?: Payload, opts?: Partial): void; /** * Appends the next message to the batch, but will wait for the server to * acknowledge the message. * @param subj * @param payload * @param opts */ add(subj: string, payload?: Payload, opts?: Partial): Promise; /** * Commits the batch. This will publish the last message on the batch * and will remove the batch from the client. * @param subj * @param payload * @param opts */ commit(subj: string, payload?: Payload, opts?: Partial): Promise; }; export type BatchAck = { batch: string; count: number; } & PubAck; /** * A type for interacting data stored in JetStream */ export type JetStreamClient = { /** * Publishes a message to a stream. If not stream is configured to store the message, the * request will fail with RequestError error with a nested NoRespondersError. * * @param subj - the subject for the message * @param payload - the message's data * @param options - the optional message */ publish(subj: string, payload?: Payload, options?: Partial): Promise; /** * Starts a batch publish operation on a stream by publishing this first message. * Additional messages are added to the batch using the returned Batch API and * committing the batch. * @param subj * @param payload * @param opts */ startBatch(subj: string, payload?: Payload, opts?: Partial): Promise; /** * Returns the JS API prefix as processed from the JetStream Options */ apiPrefix: string; /** * Returns an object for accessing {@link Consumers}. Consumers * allow you to process messages stored in a stream. To create a * consumer use {@link JetStreamManager}. */ consumers: Consumers; /** * Returns an object for accessing {@link Streams}. */ streams: Streams; /** * Returns a JetStreamManager that uses the same {@link JetStreamOptions} * as the current JetStream context */ jetstreamManager(checkAPI?: boolean): Promise; getOptions(): JetStreamOptions; }; export type Streams = { get(stream: string): Promise; }; export declare function isBoundPushConsumerOptions(v: unknown): v is BoundPushConsumerOptions; /** * For bound push consumers, the client must provide at least the * deliver_subject. Note that these values must match the ConsumerConfig * exactly */ export type BoundPushConsumerOptions = ConsumeCallback & { /** * The deliver_subject as specified in the ConsumerConfig */ deliver_subject: string; /** * The deliver_group as specified in the ConsumerConfig */ deliver_group?: string; /** * The idle_heartbeat in Nanos as specified in the ConsumerConfig. * This value starts a client-side timer to detect missing heartbeats. * If not specified or values don't match, there will be a skew and * the possibility of false heartbeat missed notifications. */ idle_heartbeat?: Nanos; }; export type Consumers = { /** * Returns the Consumer configured for the specified stream having the specified name. * Consumers are typically created with {@link JetStreamManager}. If no name is specified, * the Consumers API will return an ordered consumer. * * An ordered consumer expects messages to be delivered in order. If there's * any inconsistency, the ordered consumer will recreate the underlying consumer at the * correct sequence. Note that ordered consumers don't yield messages that can be acked * because the client can simply recreate the consumer. * * {@link Consumer}. * @param stream * @param name or OrderedConsumerOptions - if not specified an ordered consumer is created * with the specified options. */ get(stream: string, name?: string | Partial): Promise; /** * Returns a PullConsumer configured for the specified ConsumerInfo. * Note this API doesn't create or check that the consumer exists. It * simply returns a Consumer that you can use to process messages. * This method should only be used when avoiding extra ConsumerInfo. * If the underlying consumer doesn't exist, the consumer will raise * heartbeat_missed notifications. * @param ci */ getConsumerFromInfo(ci: ConsumerInfo): Consumer; getPushConsumer(stream: string, name?: string | Partial): Promise; getBoundPushConsumer(opts: BoundPushConsumerOptions): Promise; }; /** * The Direct stream API is a bit more performant for retrieving messages, * but requires the stream to have enabled direct access. * See {@link StreamConfig.allow_direct}. * * These APIs are intended to support other APIs in the library. * * Note that these APIs are marked as non-stable, this means that * these APIs are subject to change. * * Note that these API can retrieve values from any replica, so it is possible * for a lookup after an update to not include the message that was just added. */ export type DirectStreamAPI = { /** * Retrieves the message matching the specified query. Messages can be * retrieved by sequence number or by last sequence matching a subject, or * by looking for the next message sequence that matches a subject. * * This API is Non-Stable and subject to change. */ getMessage(stream: string, query: DirectMsgRequest): Promise; /** * Retrieves a batch of messages with an optional filter starting at a specific * sequence or start time. Note that only a single subject filter is supported. * * This API is Non-Stable and subject to change. */ getBatch(stream: string, opts: DirectBatchOptions): Promise>; /** * Retrieves the last message for each subject in the filter. * If no filter is specified, a maximum of 1024 subjects are returned. * Care should be given on the specified filters to ensure that * the results match what the client is expecting and to avoid missing * expected data. * * This API is Non-Stable and subject to change. */ getLastMessagesFor(stream: string, opts: DirectLastFor): Promise>; }; /** * A type representing a message that retrieved directly from JetStream. */ export type StoredMsg = { /** * The subject the message was originally received on */ subject: string; /** * The sequence number of the message in the Stream */ seq: number; /** * Headers for the message */ header: MsgHdrs; /** * The payload of the message body */ data: Uint8Array; /** * The time the message was received */ time: Date; /** * The raw ISO formatted date returned by the server */ timestamp: string; /** * The previous sequence delivered to the client in the current batch. * This value will be 0 if it was not from a batch request */ lastSequence: number; /** * The number of messages in the stream that are pending for a similar * batch request. if -1, the number of pending messages is unknown and * the stored message was received outside the context of a batch */ pending: number; /** * Convenience method to parse the message payload as JSON. This method * will throw an exception if there's a parsing error; * @param reviver */ json(reviver?: ReviverFn): T; /** * Convenience method to parse the message payload as string. This method * may throw an exception if there's a conversion error */ string(): string; }; export type DirectMsg = StoredMsg & { /** * The name of the Stream storing message */ stream: string; /** * Previous sequence delivered to the client */ lastSequence: number; }; /** * An advisory is an interesting event in the JetStream server */ export type Advisory = { /** * The type of the advisory */ kind: AdvisoryKind; /** * Payload associated with the advisory */ data: unknown; }; /** * The different kinds of Advisories */ export declare const AdvisoryKind: { readonly API: "api_audit"; readonly StreamAction: "stream_action"; readonly ConsumerAction: "consumer_action"; readonly SnapshotCreate: "snapshot_create"; readonly SnapshotComplete: "snapshot_complete"; readonly RestoreCreate: "restore_create"; readonly RestoreComplete: "restore_complete"; readonly MaxDeliver: "max_deliver"; readonly Terminated: "terminated"; readonly Ack: "consumer_ack"; readonly StreamLeaderElected: "stream_leader_elected"; readonly StreamQuorumLost: "stream_quorum_lost"; readonly ConsumerLeaderElected: "consumer_leader_elected"; readonly ConsumerQuorumLost: "consumer_quorum_lost"; }; export type AdvisoryKind = typeof AdvisoryKind[keyof typeof AdvisoryKind]; export type Stream = { name: string; /** * Returns the info (optionally cached) on the stream. * @param cached * @param opts */ info(cached?: boolean, opts?: Partial): Promise; /** * Returns a list of streams that are equivalent alternates to this one. */ alternates(): Promise; /** * Return the alternate (best RRT) for this stream. This is the * first alternate returned by the server. */ best(): Promise; /** * Returns the named consumer pull consumer. If instead of a name * an OrderedConsumerOptions configuration is passed, an * ordered pull consumer is created and returned. * @param name */ getConsumer(name?: string | Partial): Promise; /** * Returns the specified push consumer. * @param stream * @param name the name of the consumer, or an ordered consumer specification. */ getPushConsumer(stream: string, name?: string | Partial): Promise; /** * Retrieves the specified message using the specified query. * @param query */ getMessage(query: MsgRequest): Promise; /** * Deletes the specified message sequence * @param seq * @param erase - default is true */ deleteMessage(seq: number, erase?: boolean): Promise; }; export declare const JsHeaders: { /** * Set if message is from a stream source - format is `stream seq` */ readonly StreamSourceHdr: "Nats-Stream-Source"; /** * Set for heartbeat messages */ readonly LastConsumerSeqHdr: "Nats-Last-Consumer"; /** * Set for heartbeat messages */ readonly LastStreamSeqHdr: "Nats-Last-Stream"; /** * Set for heartbeat messages if the consumer is stalled */ readonly ConsumerStalledHdr: "Nats-Consumer-Stalled"; /** * Set for headers_only consumers indicates the number of bytes in the payload */ readonly MessageSizeHdr: "Nats-Msg-Size"; readonly RollupHdr: "Nats-Rollup"; readonly RollupValueSubject: "sub"; readonly RollupValueAll: "all"; /** * Set on protocol messages to indicate pull request message count that * was not honored. */ readonly PendingMessagesHdr: "Nats-Pending-Messages"; /** * Set on protocol messages to indicate pull request byte count that * was not honored */ readonly PendingBytesHdr: "Nats-Pending-Bytes"; }; export type JsHeaders = typeof JsHeaders[keyof typeof JsHeaders]; export declare const DirectMsgHeaders: { readonly Stream: "Nats-Stream"; readonly Sequence: "Nats-Sequence"; readonly TimeStamp: "Nats-Time-Stamp"; readonly Subject: "Nats-Subject"; readonly LastSequence: "Nats-Last-Sequence"; readonly NumPending: "Nats-Num-Pending"; }; export type DirectMsgHeaders = typeof DirectMsgHeaders[keyof typeof DirectMsgHeaders]; export declare const RepublishHeaders: { /** * The source stream of the message */ readonly Stream: "Nats-Stream"; /** * The original subject of the message */ readonly Subject: "Nats-Subject"; /** * The sequence of the republished message */ readonly Sequence: "Nats-Sequence"; /** * The stream sequence id of the last message ingested to the same original subject (or 0 if none or deleted) */ readonly LastSequence: "Nats-Last-Sequence"; /** * The size in bytes of the message's body - Only if {@link Republish#headers_only} is set. */ readonly Size: "Nats-Msg-Size"; }; export type RepublishHeaders = typeof RepublishHeaders[keyof typeof RepublishHeaders];