@nats-io/jetstream
Advanced tools
Comparing version 3.0.0-24 to 3.0.0-25
@@ -7,3 +7,3 @@ import { BaseApiClientImpl } from "./jsbaseclient_api"; | ||
constructor(nc: NatsConnection, opts?: JetStreamOptions); | ||
getMessage(stream: string, query: DirectMsgRequest): Promise<StoredMsg>; | ||
getMessage(stream: string, query: DirectMsgRequest): Promise<StoredMsg | null>; | ||
getBatch(stream: string, opts: DirectBatchOptions): Promise<QueuedIterator<StoredMsg>>; | ||
@@ -10,0 +10,0 @@ } |
@@ -45,11 +45,7 @@ "use strict"; | ||
if (status.isMessageNotFound()) { | ||
// this so to simplify things that handle a non-existing messages | ||
// as null (such as KV). | ||
return Promise.reject(new jserrors_1.JetStreamApiError({ | ||
code: status.code, | ||
err_code: jserrors_1.JetStreamApiCodes.NoMessageFound, | ||
description: status.description, | ||
})); | ||
return Promise.resolve(null); | ||
} | ||
return Promise.reject(status.toError()); | ||
else { | ||
return Promise.reject(status.toError()); | ||
} | ||
} | ||
@@ -56,0 +52,0 @@ const dm = new DirectMsgImpl(r); |
@@ -27,3 +27,3 @@ import type { Codec, MsgHdrs, NatsConnection, ReviverFn } from "@nats-io/nats-core/internal"; | ||
getPushConsumer(name?: string | Partial<OrderedPushConsumerOptions>): Promise<PushConsumer>; | ||
getMessage(query: MsgRequest): Promise<StoredMsg>; | ||
getMessage(query: MsgRequest): Promise<StoredMsg | null>; | ||
deleteMessage(seq: number, erase?: boolean): Promise<boolean>; | ||
@@ -42,3 +42,3 @@ } | ||
deleteMessage(stream: string, seq: number, erase?: boolean): Promise<boolean>; | ||
getMessage(stream: string, query: MsgRequest): Promise<StoredMsg>; | ||
getMessage(stream: string, query: MsgRequest): Promise<StoredMsg | null>; | ||
find(subject: string): Promise<string>; | ||
@@ -45,0 +45,0 @@ names(subject?: string): Lister<string>; |
@@ -28,2 +28,3 @@ "use strict"; | ||
const pushconsumer_1 = require("./pushconsumer"); | ||
const jserrors_1 = require("./jserrors"); | ||
function convertStreamSourceDomain(s) { | ||
@@ -444,5 +445,14 @@ if (s === undefined) { | ||
(0, jsutil_1.validateStreamName)(stream); | ||
const r = await this._request(`${this.prefix}.STREAM.MSG.GET.${stream}`, query); | ||
const sm = r; | ||
return new StoredMsgImpl(sm); | ||
try { | ||
const r = await this._request(`${this.prefix}.STREAM.MSG.GET.${stream}`, query); | ||
const sm = r; | ||
return new StoredMsgImpl(sm); | ||
} | ||
catch (err) { | ||
if (err instanceof jserrors_1.JetStreamApiError && | ||
err.code === jserrors_1.JetStreamApiCodes.NoMessageFound) { | ||
return null; | ||
} | ||
return Promise.reject(err); | ||
} | ||
} | ||
@@ -449,0 +459,0 @@ find(subject) { |
@@ -168,3 +168,3 @@ import type { MsgHdrs, Nanos, Payload, QueuedIterator, ReviverFn } from "@nats-io/nats-core/internal"; | ||
*/ | ||
getMessage(stream: string, query: MsgRequest): Promise<StoredMsg>; | ||
getMessage(stream: string, query: MsgRequest): Promise<StoredMsg | null>; | ||
/** | ||
@@ -585,3 +585,3 @@ * Find the stream that stores the specified subject. | ||
*/ | ||
getMessage(stream: string, query: DirectMsgRequest): Promise<StoredMsg>; | ||
getMessage(stream: string, query: DirectMsgRequest): Promise<StoredMsg | null>; | ||
/** | ||
@@ -679,3 +679,3 @@ * Retrieves all last subject messages for the specified subjects | ||
getPushConsumer(stream: string, name?: string | Partial<OrderedPushConsumerOptions>): Promise<PushConsumer>; | ||
getMessage(query: MsgRequest): Promise<StoredMsg>; | ||
getMessage(query: MsgRequest): Promise<StoredMsg | null>; | ||
deleteMessage(seq: number, erase?: boolean): Promise<boolean>; | ||
@@ -682,0 +682,0 @@ } |
{ | ||
"name": "@nats-io/jetstream", | ||
"version": "3.0.0-24", | ||
"version": "3.0.0-25", | ||
"files": [ | ||
@@ -5,0 +5,0 @@ "lib/", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
333561
5566