Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nats

Package Overview
Dependencies
Maintainers
3
Versions
195
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nats - npm Package Compare versions

Comparing version 2.19.0 to 2.20.0

23

lib/jetstream/consumer.js

@@ -731,2 +731,5 @@ "use strict";

}
if (this.consumerOpts.replay_policy) {
config.replay_policy = this.consumerOpts.replay_policy;
}
// this is the initial request - tweak some options

@@ -761,5 +764,5 @@ if (seq === this.startSeq + 1) {

}
resetConsumer(seq = 0) {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {
resetConsumer() {
return __awaiter(this, arguments, void 0, function* (seq = 0) {
var _a, _b;
// try to delete the consumer

@@ -816,7 +819,7 @@ (_a = this.consumer) === null || _a === void 0 ? void 0 : _a.delete().catch(() => { });

}
reset(opts = {
max_messages: 100,
expires: 30000,
}, fromFetch = false) {
return __awaiter(this, void 0, void 0, function* () {
reset() {
return __awaiter(this, arguments, void 0, function* (opts = {
max_messages: 100,
expires: 30000,
}, fromFetch = false) {
this.currentConsumer = yield this.resetConsumer(this.cursor.stream_seq + 1);

@@ -886,4 +889,4 @@ if (this.iter === null) {

}
next(opts = { expires: 30000 }) {
return __awaiter(this, void 0, void 0, function* () {
next() {
return __awaiter(this, arguments, void 0, function* (opts = { expires: 30000 }) {
const d = (0, util_1.deferred)();

@@ -890,0 +893,0 @@ const copts = opts;

export { checkJsError, isFlowControlMsg, isHeartbeatMsg, millis, nanos, } from "./jsutil";
export { AdvisoryKind, consumerOpts, DirectMsgHeaders, isConsumerOptsBuilder, JsHeaders, RepublishHeaders, } from "./types";
export type { Advisory, Closed, ConsumerInfoable, ConsumerOpts, ConsumerOptsBuilder, Consumers, Destroyable, JetStreamClient, JetStreamManager, JetStreamManagerOptions, JetStreamOptions, JetStreamPublishOptions, JetStreamPullSubscription, JetStreamSubscription, JetStreamSubscriptionInfoable, JetStreamSubscriptionOptions, JsMsgCallback, KV, KvCodec, KvCodecs, KvEntry, KvLimits, KvOptions, KvPutOptions, KvStatus, KvWatchInclude, KvWatchOptions, ObjectInfo, ObjectResult, ObjectStore, ObjectStoreLink, ObjectStoreMeta, ObjectStoreMetaOptions, ObjectStoreOptions, ObjectStorePutOpts, ObjectStoreStatus, PubAck, Pullable, RoKV, StoredMsg, Stream, StreamAPI, Streams, Views, } from "./types";
export { AdvisoryKind, consumerOpts, DirectMsgHeaders, isConsumerOptsBuilder, JsHeaders, KvWatchInclude, RepublishHeaders, } from "./types";
export type { Advisory, Closed, ConsumerInfoable, ConsumerOpts, ConsumerOptsBuilder, Consumers, Destroyable, JetStreamClient, JetStreamManager, JetStreamManagerOptions, JetStreamOptions, JetStreamPublishOptions, JetStreamPullSubscription, JetStreamSubscription, JetStreamSubscriptionInfoable, JetStreamSubscriptionOptions, JsMsgCallback, KV, KvCodec, KvCodecs, KvEntry, KvLimits, KvOptions, KvPutOptions, KvStatus, KvWatchOptions, ObjectInfo, ObjectResult, ObjectStore, ObjectStoreLink, ObjectStoreMeta, ObjectStoreMetaOptions, ObjectStoreOptions, ObjectStorePutOpts, ObjectStoreStatus, PubAck, Pullable, RoKV, StoredMsg, Stream, StreamAPI, Streams, Views, } from "./types";
export type { StreamNames } from "./jsbaseclient_api";

@@ -5,0 +5,0 @@ export type { AccountLimits, ApiPagedRequest, ClusterInfo, ConsumerConfig, ConsumerInfo, ConsumerUpdateConfig, ExternalStream, JetStreamAccountStats, JetStreamApiStats, JetStreamUsageAccountLimits, LastForMsgRequest, LostStreamData, MsgDeleteRequest, MsgRequest, PeerInfo, Placement, PullOptions, PurgeBySeq, PurgeBySubject, PurgeOpts, PurgeResponse, PurgeTrimOpts, Republish, SeqMsgRequest, SequenceInfo, StreamAlternate, StreamConfig, StreamConsumerLimits, StreamInfo, StreamSource, StreamSourceInfo, StreamState, StreamUpdateConfig, SubjectTransformConfig, } from "./jsapi_types";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConsumerEvents = exports.ConsumerDebugEvents = exports.StoreCompression = exports.StorageType = exports.RetentionPolicy = exports.ReplayPolicy = exports.DiscardPolicy = exports.DeliverPolicy = exports.AckPolicy = exports.RepublishHeaders = exports.JsHeaders = exports.isConsumerOptsBuilder = exports.DirectMsgHeaders = exports.consumerOpts = exports.AdvisoryKind = exports.nanos = exports.millis = exports.isHeartbeatMsg = exports.isFlowControlMsg = exports.checkJsError = void 0;
exports.ConsumerEvents = exports.ConsumerDebugEvents = exports.StoreCompression = exports.StorageType = exports.RetentionPolicy = exports.ReplayPolicy = exports.DiscardPolicy = exports.DeliverPolicy = exports.AckPolicy = exports.RepublishHeaders = exports.KvWatchInclude = exports.JsHeaders = exports.isConsumerOptsBuilder = exports.DirectMsgHeaders = exports.consumerOpts = exports.AdvisoryKind = exports.nanos = exports.millis = exports.isHeartbeatMsg = exports.isFlowControlMsg = exports.checkJsError = void 0;
/*

@@ -30,2 +30,3 @@ * Copyright 2023 The NATS Authors

Object.defineProperty(exports, "JsHeaders", { enumerable: true, get: function () { return types_1.JsHeaders; } });
Object.defineProperty(exports, "KvWatchInclude", { enumerable: true, get: function () { return types_1.KvWatchInclude; } });
Object.defineProperty(exports, "RepublishHeaders", { enumerable: true, get: function () { return types_1.RepublishHeaders; } });

@@ -32,0 +33,0 @@ var jsapi_types_1 = require("./jsapi_types");

@@ -443,2 +443,9 @@ import { ApiError, Nanos } from "../nats-base-client/core";

export type DirectMsgRequest = SeqMsgRequest | LastForMsgRequest | NextMsgRequest;
export type DirectBatchOptions = {
batch?: number;
max_bytes?: number;
multi_last: string[];
up_to_seq?: number;
up_to_time?: Date | string;
};
export interface StreamState {

@@ -683,2 +690,13 @@ /**

"ts"?: string;
/**
* Set to true if the consumer is paused.
* This field is only available on servers 2.11.x or better
*/
paused?: boolean;
/**
* If the consumer was paused with a resume date, this field specifies the amount of time
* in nanoseconds remaining until the consumer will be automatically resumed. This field
* is only available on servers 2.11.x or better
*/
"pause_remaining": Nanos;
}

@@ -845,2 +863,7 @@ export interface ConsumerListResponse extends ApiResponse, ApiPaged {

"replay_policy": ReplayPolicy;
/**
* Creates a consumer that is initially paused, but will resume at the specified Date and time.
* Specified as an ISO date time string (Date#toISOString()).
*/
"pause_until"?: string;
}

@@ -847,0 +870,0 @@ export interface ConsumerUpdateConfig {

@@ -65,4 +65,4 @@ "use strict";

}
_request(subj, data = null, opts) {
return __awaiter(this, void 0, void 0, function* () {
_request(subj_1) {
return __awaiter(this, arguments, void 0, function* (subj, data = null, opts) {
opts = opts || {};

@@ -69,0 +69,0 @@ opts.timeout = this.timeout;

@@ -63,3 +63,3 @@ "use strict";

if (opts.bindOnly) {
return kv_1.Bucket.bind(this.js, name);
return kv_1.Bucket.bind(this.js, name, opts);
}

@@ -99,4 +99,4 @@ return kv_1.Bucket.create(this.js, name, opts);

}
publish(subj, data = types_1.Empty, opts) {
return __awaiter(this, void 0, void 0, function* () {
publish(subj_1) {
return __awaiter(this, arguments, void 0, function* (subj, data = types_1.Empty, opts) {
opts = opts || {};

@@ -158,4 +158,4 @@ opts.expect = opts.expect || {};

}
pull(stream, durable, expires = 0) {
return __awaiter(this, void 0, void 0, function* () {
pull(stream_1, durable_1) {
return __awaiter(this, arguments, void 0, function* (stream, durable, expires = 0) {
(0, jsutil_1.validateStreamName)(stream);

@@ -332,4 +332,4 @@ (0, jsutil_1.validateDurableName)(durable);

}
pullSubscribe(subject, opts = (0, types_2.consumerOpts)()) {
return __awaiter(this, void 0, void 0, function* () {
pullSubscribe(subject_1) {
return __awaiter(this, arguments, void 0, function* (subject, opts = (0, types_2.consumerOpts)()) {
const cso = yield this._processOptions(subject, opts);

@@ -359,4 +359,4 @@ if (cso.ordered) {

}
subscribe(subject, opts = (0, types_2.consumerOpts)()) {
return __awaiter(this, void 0, void 0, function* () {
subscribe(subject_1) {
return __awaiter(this, arguments, void 0, function* (subject, opts = (0, types_2.consumerOpts)()) {
const cso = yield this._processOptions(subject, opts);

@@ -382,5 +382,5 @@ // this effectively requires deliver subject to be specified

}
_processOptions(subject, opts = (0, types_2.consumerOpts)()) {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {
_processOptions(subject_1) {
return __awaiter(this, arguments, void 0, function* (subject, opts = (0, types_2.consumerOpts)()) {
var _a, _b;
const jsi = ((0, types_2.isConsumerOptsBuilder)(opts)

@@ -387,0 +387,0 @@ ? opts.getOpts()

import { BaseApiClient } from "./jsbaseclient_api";
import { ConsumerAPI } from "./jsmconsumer_api";
import { Advisory, DirectMsg, DirectStreamAPI, JetStreamClient, JetStreamManager, StoredMsg, StreamAPI } from "./types";
import { JetStreamOptions, Msg, MsgHdrs, NatsConnection, ReviverFn } from "../nats-base-client/core";
import { DirectMsgRequest, JetStreamAccountStats } from "./jsapi_types";
import { JetStreamOptions, Msg, MsgHdrs, NatsConnection, QueuedIterator, ReviverFn } from "../nats-base-client/core";
import { DirectBatchOptions, DirectMsgRequest, JetStreamAccountStats } from "./jsapi_types";
import { Codec } from "../nats-base-client/codec";

@@ -10,2 +10,3 @@ export declare class DirectStreamAPIImpl extends BaseApiClient implements DirectStreamAPI {

getMessage(stream: string, query: DirectMsgRequest): Promise<StoredMsg>;
getBatch(stream: string, opts: DirectBatchOptions): Promise<QueuedIterator<StoredMsg>>;
}

@@ -12,0 +13,0 @@ export declare class DirectMsgImpl implements DirectMsg {

@@ -25,2 +25,9 @@ "use strict";

};
var __asyncValues = (this && this.__asyncValues) || function (o) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -33,2 +40,3 @@ exports.JetStreamManagerImpl = exports.DirectMsgImpl = exports.DirectStreamAPIImpl = void 0;

const types_1 = require("./types");
const core_1 = require("../nats-base-client/core");
const jsutil_1 = require("./jsutil");

@@ -66,2 +74,72 @@ const encoders_1 = require("../nats-base-client/encoders");

}
getBatch(stream, opts) {
return __awaiter(this, void 0, void 0, function* () {
(0, jsutil_1.validateStreamName)(stream);
const pre = this.opts.apiPrefix || "$JS.API";
const subj = `${pre}.DIRECT.GET.${stream}`;
if (!Array.isArray(opts.multi_last) || opts.multi_last.length === 0) {
return Promise.reject("multi_last is required");
}
const payload = JSON.stringify(opts, (key, value) => {
if (key === "up_to_time" && value instanceof Date) {
return value.toISOString();
}
return value;
});
const iter = new queued_iterator_1.QueuedIteratorImpl();
const raw = yield this.nc.requestMany(subj, payload, {
strategy: core_1.RequestStrategy.SentinelMsg,
});
(() => __awaiter(this, void 0, void 0, function* () {
var _a, e_1, _b, _c;
var _d, _e, _f;
let gotFirst = false;
let badServer = false;
let badRequest;
try {
for (var _g = true, raw_1 = __asyncValues(raw), raw_1_1; raw_1_1 = yield raw_1.next(), _a = raw_1_1.done, !_a; _g = true) {
_c = raw_1_1.value;
_g = false;
const m = _c;
if (!gotFirst) {
gotFirst = true;
const code = ((_d = m.headers) === null || _d === void 0 ? void 0 : _d.code) || 0;
if (code !== 0 && code < 200 || code > 299) {
badRequest = (_e = m.headers) === null || _e === void 0 ? void 0 : _e.description.toLowerCase();
break;
}
// inspect the message and make sure that we have a supported server
const v = (_f = m.headers) === null || _f === void 0 ? void 0 : _f.get("Nats-Num-Pending");
if (v === "") {
badServer = true;
break;
}
}
if (m.data.length === 0) {
break;
}
iter.push(new DirectMsgImpl(m));
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (!_g && !_a && (_b = raw_1.return)) yield _b.call(raw_1);
}
finally { if (e_1) throw e_1.error; }
}
//@ts-ignore: term function
iter.push(() => {
if (badServer) {
throw new Error("batch direct get not supported by the server");
}
if (badRequest) {
throw new Error(`bad request: ${badRequest}`);
}
iter.stop();
});
}))();
return Promise.resolve(iter);
});
}
}

@@ -68,0 +146,0 @@ exports.DirectStreamAPIImpl = DirectStreamAPIImpl;

import { BaseApiClient } from "./jsbaseclient_api";
import { Lister } from "./jslister";
import { JetStreamOptions, NatsConnection } from "../nats-base-client/core";
import { JetStreamOptions, Nanos, NatsConnection } from "../nats-base-client/core";
import { ConsumerApiAction, ConsumerConfig, ConsumerInfo, ConsumerUpdateConfig } from "./jsapi_types";

@@ -37,2 +37,10 @@ export interface ConsumerAPI {

list(stream: string): Lister<ConsumerInfo>;
pause(stream: string, name: string, until?: Date): Promise<{
paused: boolean;
pause_until?: string;
}>;
resume(stream: string, name: string): Promise<{
paused: boolean;
pause_until?: string;
}>;
}

@@ -46,2 +54,11 @@ export declare class ConsumerAPIImpl extends BaseApiClient implements ConsumerAPI {

list(stream: string): Lister<ConsumerInfo>;
pause(stream: string, name: string, until: Date): Promise<{
paused: boolean;
pause_until: string;
pause_remaining: Nanos;
}>;
resume(stream: string, name: string): Promise<{
paused: boolean;
pause_until?: string;
}>;
}

@@ -36,5 +36,5 @@ "use strict";

}
add(stream, cfg, action = jsapi_types_1.ConsumerApiAction.Create) {
var _a, _b, _c;
return __awaiter(this, void 0, void 0, function* () {
add(stream_1, cfg_1) {
return __awaiter(this, arguments, void 0, function* (stream, cfg, action = jsapi_types_1.ConsumerApiAction.Create) {
var _a, _b, _c;
(0, jsutil_1.validateStreamName)(stream);

@@ -146,4 +146,14 @@ if (cfg.deliver_group && cfg.flow_control) {

}
pause(stream, name, until) {
const subj = `${this.prefix}.CONSUMER.PAUSE.${stream}.${name}`;
const opts = {
pause_until: until.toISOString(),
};
return this._request(subj, opts);
}
resume(stream, name) {
return this.pause(stream, name, new Date(0));
}
}
exports.ConsumerAPIImpl = ConsumerAPIImpl;
//# sourceMappingURL=jsmconsumer_api.js.map

@@ -114,4 +114,4 @@ "use strict";

ackAck() {
var _a;
return __awaiter(this, void 0, void 0, function* () {
var _a;
if (!this.didAck) {

@@ -118,0 +118,0 @@ this.didAck = true;

@@ -72,4 +72,4 @@ "use strict";

}
get(stream, name = {}) {
return __awaiter(this, void 0, void 0, function* () {
get(stream_1) {
return __awaiter(this, arguments, void 0, function* (stream, name = {}) {
if (typeof name === "object") {

@@ -211,5 +211,5 @@ return this.ordered(stream, name);

}
add(cfg = {}) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
add() {
return __awaiter(this, arguments, void 0, function* (cfg = {}) {
var _a;
this.checkStreamConfigVersions(cfg);

@@ -234,5 +234,5 @@ (0, jsutil_1.validateStreamName)(cfg.name);

}
update(name, cfg = {}) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
update(name_1) {
return __awaiter(this, arguments, void 0, function* (name, cfg = {}) {
var _a;
if (typeof name === "object") {

@@ -342,4 +342,4 @@ const sc = name;

}
deleteMessage(stream, seq, erase = true) {
return __awaiter(this, void 0, void 0, function* () {
deleteMessage(stream_1, seq_1) {
return __awaiter(this, arguments, void 0, function* (stream, seq, erase = true) {
(0, jsutil_1.validateStreamName)(stream);

@@ -346,0 +346,0 @@ const dr = { seq };

import { MsgHdrs, Payload, QueuedIterator } from "../nats-base-client/core";
import { JetStreamClient, JetStreamManager, KV, KvCodec, KvCodecs, KvEntry, KvOptions, KvPutOptions, KvRemove, KvStatus, KvWatchInclude, KvWatchOptions, StoredMsg } from "./types";
import { JetStreamClient, JetStreamManager, KV, KvCodec, KvCodecs, KvDeleteOptions, KvEntry, KvOptions, KvPutOptions, KvRemove, KvStatus, KvWatchInclude, KvWatchOptions, StoredMsg } from "./types";
import { ConsumerConfig, Placement, PurgeOpts, PurgeResponse, Republish, StorageType, StreamInfo } from "./jsapi_types";

@@ -26,5 +26,3 @@ import { JsMsg } from "./jsmsg";

static create(js: JetStreamClient, name: string, opts?: Partial<KvOptions>): Promise<KV>;
static bind(js: JetStreamClient, name: string, opts?: Partial<{
codec: KvCodecs;
}>): Promise<KV>;
static bind(js: JetStreamClient, name: string, opts?: Partial<KvOptions>): Promise<KV>;
init(opts?: Partial<KvOptions>): Promise<void>;

@@ -52,7 +50,7 @@ initializePrefixes(info: StreamInfo): void;

}): Promise<KvEntry | null>;
purge(k: string): Promise<void>;
delete(k: string): Promise<void>;
purge(k: string, opts?: Partial<KvDeleteOptions>): Promise<void>;
delete(k: string, opts?: Partial<KvDeleteOptions>): Promise<void>;
purgeDeletes(olderMillis?: number): Promise<PurgeResponse>;
_deleteOrPurge(k: string, op: "DEL" | "PURGE"): Promise<void>;
_doDeleteOrPurge(k: string, op: "DEL" | "PURGE"): Promise<void>;
_deleteOrPurge(k: string, op: "DEL" | "PURGE", opts?: Partial<KvDeleteOptions>): Promise<void>;
_doDeleteOrPurge(k: string, op: "DEL" | "PURGE", opts?: Partial<KvDeleteOptions>): Promise<void>;
_buildCC(k: string, content: KvWatchInclude, opts?: Partial<ConsumerConfig>): Partial<ConsumerConfig>;

@@ -59,0 +57,0 @@ remove(k: string): Promise<void>;

@@ -151,4 +151,4 @@ "use strict";

}
static create(js, name, opts = {}) {
return __awaiter(this, void 0, void 0, function* () {
static create(js_1, name_1) {
return __awaiter(this, arguments, void 0, function* (js, name, opts = {}) {
validateBucket(name);

@@ -161,12 +161,18 @@ const jsm = yield js.jetstreamManager();

}
static bind(js, name, opts = {}) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
static bind(js_1, name_1) {
return __awaiter(this, arguments, void 0, function* (js, name, opts = {}) {
var _a, _b;
const jsm = yield js.jetstreamManager();
const info = yield jsm.streams.info(`${types_1.kvPrefix}${name}`);
validateBucket(info.config.name);
const info = {
config: {
allow_direct: opts.allow_direct,
},
};
validateBucket(name);
const bucket = new Bucket(name, js, jsm);
info.config.name = (_a = opts.streamName) !== null && _a !== void 0 ? _a : bucket.bucketName();
Object.assign(bucket, info);
bucket.stream = info.config.name;
bucket.codec = opts.codec || NoopKvCodecs();
bucket.direct = (_a = info.config.allow_direct) !== null && _a !== void 0 ? _a : false;
bucket.direct = (_b = info.config.allow_direct) !== null && _b !== void 0 ? _b : false;
bucket.initializePrefixes(info);

@@ -176,5 +182,5 @@ return bucket;

}
init(opts = {}) {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {
init() {
return __awaiter(this, arguments, void 0, function* (opts = {}) {
var _a, _b;
const bo = Object.assign(defaultBucketOpts(), opts);

@@ -389,4 +395,4 @@ this.codec = bo.codec;

create(k, data) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
var _a;
let firstErr;

@@ -425,5 +431,5 @@ try {

}
put(k, data, opts = {}) {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {
put(k_1, data_1) {
return __awaiter(this, arguments, void 0, function* (k, data, opts = {}) {
var _a, _b;
const ek = this.encodeKey(k);

@@ -483,10 +489,10 @@ this.validateKey(ek);

}
purge(k) {
return this._deleteOrPurge(k, "PURGE");
purge(k, opts) {
return this._deleteOrPurge(k, "PURGE", opts);
}
delete(k) {
return this._deleteOrPurge(k, "DEL");
delete(k, opts) {
return this._deleteOrPurge(k, "DEL", opts);
}
purgeDeletes(olderMillis = 30 * 60 * 1000) {
return __awaiter(this, void 0, void 0, function* () {
purgeDeletes() {
return __awaiter(this, arguments, void 0, function* (olderMillis = 30 * 60 * 1000) {
const done = (0, util_1.deferred)();

@@ -540,7 +546,7 @@ const buf = [];

}
_deleteOrPurge(k, op) {
var _a, e_2, _b, _c;
_deleteOrPurge(k, op, opts) {
return __awaiter(this, void 0, void 0, function* () {
var _a, e_2, _b, _c;
if (!this.hasWildcards(k)) {
return this._doDeleteOrPurge(k, op);
return this._doDeleteOrPurge(k, op, opts);
}

@@ -573,3 +579,3 @@ const iter = yield this.keys(k);

}
_doDeleteOrPurge(k, op) {
_doDeleteOrPurge(k, op, opts) {
return __awaiter(this, void 0, void 0, function* () {

@@ -583,2 +589,5 @@ const ek = this.encodeKey(k);

}
if (opts === null || opts === void 0 ? void 0 : opts.previousSeq) {
h.set(jsclient_1.PubHeaders.ExpectedLastSubjectSequenceHdr, `${opts.previousSeq}`);
}
yield this.js.publish(this.subjectForKey(ek, true), encoders_1.Empty, { headers: h });

@@ -608,5 +617,5 @@ });

}
history(opts = {}) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
history() {
return __awaiter(this, arguments, void 0, function* (opts = {}) {
var _a;
const k = (_a = opts.key) !== null && _a !== void 0 ? _a : ">";

@@ -683,5 +692,5 @@ const qi = new queued_iterator_1.QueuedIteratorImpl();

}
watch(opts = {}) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
watch() {
return __awaiter(this, arguments, void 0, function* (opts = {}) {
var _a;
const k = (_a = opts.key) !== null && _a !== void 0 ? _a : ">";

@@ -705,2 +714,5 @@ const qi = new queued_iterator_1.QueuedIteratorImpl();

copts.bindStream(this.stream);
if (opts.resumeFromRevision && opts.resumeFromRevision > 0) {
copts.startSequence(opts.resumeFromRevision);
}
copts.orderedConsumer();

@@ -767,4 +779,4 @@ copts.callback((err, jm) => {

}
keys(k = ">") {
return __awaiter(this, void 0, void 0, function* () {
keys() {
return __awaiter(this, arguments, void 0, function* (k = ">") {
const keys = new queued_iterator_1.QueuedIteratorImpl();

@@ -825,4 +837,4 @@ const cc = this._buildCC(k, types_1.KvWatchInclude.LastValue, {

status() {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {
var _a, _b;
const nc = this.js.nc;

@@ -829,0 +841,0 @@ const cluster = (_b = (_a = nc.info) === null || _a === void 0 ? void 0 : _a.cluster) !== null && _b !== void 0 ? _b : "";

export { checkJsError, isFlowControlMsg, isHeartbeatMsg, millis, nanos, } from "./internal_mod";
export { AckPolicy, AdvisoryKind, ConsumerDebugEvents, ConsumerEvents, DeliverPolicy, DirectMsgHeaders, DiscardPolicy, JsHeaders, ReplayPolicy, RepublishHeaders, RetentionPolicy, StorageType, StoreCompression, } from "./internal_mod";
export type { AccountLimits, Advisory, ApiPagedRequest, Closed, ClusterInfo, ConsumeBytes, ConsumeCallback, ConsumeMessages, ConsumeOptions, Consumer, ConsumerAPI, ConsumerCallbackFn, ConsumerConfig, ConsumerInfo, ConsumerInfoable, ConsumerMessages, ConsumerOpts, ConsumerOptsBuilder, Consumers, ConsumerStatus, ConsumerUpdateConfig, DeliveryInfo, Destroyable, Expires, ExternalStream, FetchBytes, FetchMessages, FetchOptions, IdleHeartbeat, JetStreamAccountStats, JetStreamApiStats, JetStreamClient, JetStreamManager, JetStreamManagerOptions, JetStreamOptions, JetStreamPublishOptions, JetStreamPullSubscription, JetStreamSubscription, JetStreamSubscriptionOptions, JetStreamUsageAccountLimits, JsMsg, JsMsgCallback, KV, KvCodec, KvCodecs, KvEntry, KvLimits, KvOptions, KvPutOptions, KvStatus, KvWatchInclude, KvWatchOptions, LastForMsgRequest, Lister, LostStreamData, MaxBytes, MaxMessages, MsgDeleteRequest, MsgRequest, ObjectInfo, ObjectResult, ObjectStore, ObjectStoreLink, ObjectStoreMeta, ObjectStoreMetaOptions, ObjectStoreOptions, ObjectStorePutOpts, ObjectStoreStatus, OrderedConsumerOptions, PeerInfo, Placement, PubAck, Pullable, PullOptions, PurgeBySeq, PurgeBySubject, PurgeOpts, PurgeResponse, PurgeTrimOpts, Republish, RoKV, SeqMsgRequest, SequenceInfo, StoredMsg, Stream, StreamAlternate, StreamAPI, StreamConfig, StreamConsumerLimits, StreamInfo, StreamInfoRequestOptions, StreamNames, Streams, StreamSource, StreamSourceInfo, StreamState, StreamUpdateConfig, SubjectTransformConfig, ThresholdBytes, ThresholdMessages, Views, } from "./internal_mod";
export { AckPolicy, AdvisoryKind, ConsumerDebugEvents, ConsumerEvents, DeliverPolicy, DirectMsgHeaders, DiscardPolicy, JsHeaders, KvWatchInclude, ReplayPolicy, RepublishHeaders, RetentionPolicy, StorageType, StoreCompression, } from "./internal_mod";
export type { AccountLimits, Advisory, ApiPagedRequest, Closed, ClusterInfo, ConsumeBytes, ConsumeCallback, ConsumeMessages, ConsumeOptions, Consumer, ConsumerAPI, ConsumerCallbackFn, ConsumerConfig, ConsumerInfo, ConsumerInfoable, ConsumerMessages, ConsumerOpts, ConsumerOptsBuilder, Consumers, ConsumerStatus, ConsumerUpdateConfig, DeliveryInfo, Destroyable, Expires, ExternalStream, FetchBytes, FetchMessages, FetchOptions, IdleHeartbeat, JetStreamAccountStats, JetStreamApiStats, JetStreamClient, JetStreamManager, JetStreamManagerOptions, JetStreamOptions, JetStreamPublishOptions, JetStreamPullSubscription, JetStreamSubscription, JetStreamSubscriptionOptions, JetStreamUsageAccountLimits, JsMsg, JsMsgCallback, KV, KvCodec, KvCodecs, KvEntry, KvLimits, KvOptions, KvPutOptions, KvStatus, KvWatchOptions, LastForMsgRequest, Lister, LostStreamData, MaxBytes, MaxMessages, MsgDeleteRequest, MsgRequest, ObjectInfo, ObjectResult, ObjectStore, ObjectStoreLink, ObjectStoreMeta, ObjectStoreMetaOptions, ObjectStoreOptions, ObjectStorePutOpts, ObjectStoreStatus, OrderedConsumerOptions, PeerInfo, Placement, PubAck, Pullable, PullOptions, PurgeBySeq, PurgeBySubject, PurgeOpts, PurgeResponse, PurgeTrimOpts, Republish, RoKV, SeqMsgRequest, SequenceInfo, StoredMsg, Stream, StreamAlternate, StreamAPI, StreamConfig, StreamConsumerLimits, StreamInfo, StreamInfoRequestOptions, StreamNames, Streams, StreamSource, StreamSourceInfo, StreamState, StreamUpdateConfig, SubjectTransformConfig, ThresholdBytes, ThresholdMessages, Views, } from "./internal_mod";
export { consumerOpts } from "./types";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.consumerOpts = exports.StoreCompression = exports.StorageType = exports.RetentionPolicy = exports.RepublishHeaders = exports.ReplayPolicy = exports.JsHeaders = exports.DiscardPolicy = exports.DirectMsgHeaders = exports.DeliverPolicy = exports.ConsumerEvents = exports.ConsumerDebugEvents = exports.AdvisoryKind = exports.AckPolicy = exports.nanos = exports.millis = exports.isHeartbeatMsg = exports.isFlowControlMsg = exports.checkJsError = void 0;
exports.consumerOpts = exports.StoreCompression = exports.StorageType = exports.RetentionPolicy = exports.RepublishHeaders = exports.ReplayPolicy = exports.KvWatchInclude = exports.JsHeaders = exports.DiscardPolicy = exports.DirectMsgHeaders = exports.DeliverPolicy = exports.ConsumerEvents = exports.ConsumerDebugEvents = exports.AdvisoryKind = exports.AckPolicy = exports.nanos = exports.millis = exports.isHeartbeatMsg = exports.isFlowControlMsg = exports.checkJsError = void 0;
/*

@@ -33,2 +33,3 @@ * Copyright 2023 The NATS Authors

Object.defineProperty(exports, "JsHeaders", { enumerable: true, get: function () { return internal_mod_2.JsHeaders; } });
Object.defineProperty(exports, "KvWatchInclude", { enumerable: true, get: function () { return internal_mod_2.KvWatchInclude; } });
Object.defineProperty(exports, "ReplayPolicy", { enumerable: true, get: function () { return internal_mod_2.ReplayPolicy; } });

@@ -35,0 +36,0 @@ Object.defineProperty(exports, "RepublishHeaders", { enumerable: true, get: function () { return internal_mod_2.RepublishHeaders; } });

@@ -196,4 +196,4 @@ "use strict";

list() {
var _a, e_1, _b, _c;
return __awaiter(this, void 0, void 0, function* () {
var _a, e_1, _b, _c;
const buf = [];

@@ -289,4 +289,4 @@ const iter = yield this.watch({

_put(meta, rs, opts) {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {
var _a, _b;
const jsopts = this.js.getOptions();

@@ -599,5 +599,5 @@ opts = opts || { timeout: jsopts.timeout };

}
update(name, meta = {}) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
update(name_1) {
return __awaiter(this, arguments, void 0, function* (name, meta = {}) {
var _a;
const info = yield this.rawInfo(name);

@@ -633,5 +633,5 @@ if (info === null) {

}
watch(opts = {}) {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {
watch() {
return __awaiter(this, arguments, void 0, function* (opts = {}) {
var _a, _b;
opts.includeHistory = (_a = opts.includeHistory) !== null && _a !== void 0 ? _a : false;

@@ -708,4 +708,4 @@ opts.ignoreDeletes = (_b = opts.ignoreDeletes) !== null && _b !== void 0 ? _b : false;

}
init(opts = {}) {
return __awaiter(this, void 0, void 0, function* () {
init() {
return __awaiter(this, arguments, void 0, function* (opts = {}) {
try {

@@ -747,4 +747,4 @@ this.stream = objectStoreStreamName(this.name);

}
static create(js, name, opts = {}) {
return __awaiter(this, void 0, void 0, function* () {
static create(js_1, name_1) {
return __awaiter(this, arguments, void 0, function* (js, name, opts = {}) {
const jsm = yield js.jetstreamManager();

@@ -751,0 +751,0 @@ const os = new ObjectStoreImpl(name, jsm, js);

@@ -5,3 +5,3 @@ import { Consumer, OrderedConsumerOptions } from "./consumer";

import { TypedSubscriptionOptions } from "../nats-base-client/typedsub";
import { ConsumerConfig, ConsumerInfo, DirectMsgRequest, JetStreamAccountStats, MsgRequest, Placement, PullOptions, PurgeOpts, PurgeResponse, Republish, StorageType, StreamAlternate, StreamConfig, StreamInfo, StreamInfoRequestOptions, StreamSource, StreamUpdateConfig } from "./jsapi_types";
import { ConsumerConfig, ConsumerInfo, DirectBatchOptions, DirectMsgRequest, JetStreamAccountStats, MsgRequest, Placement, PullOptions, PurgeOpts, PurgeResponse, Republish, StorageType, StreamAlternate, StreamConfig, StreamInfo, StreamInfoRequestOptions, StreamSource, StreamUpdateConfig } from "./jsapi_types";
import { JsMsg } from "./jsmsg";

@@ -608,2 +608,8 @@ import { BaseApiClient } from "./jsbaseclient_api";

getMessage(stream: string, query: DirectMsgRequest): Promise<StoredMsg>;
/**
* Retrieves all last subject messages for the specified subjects
* @param stream
* @param opts
*/
getBatch(stream: string, opts: DirectBatchOptions): Promise<QueuedIterator<StoredMsg>>;
}

@@ -940,2 +946,8 @@ /**

include?: KvWatchInclude;
/**
* Starts watching at the specified revision. This is intended for watchers
* that have restarted watching and have maintained some state of where they are
* in the watch.
*/
resumeFromRevision?: number;
};

@@ -1015,4 +1027,5 @@ export interface RoKV {

* @param k
* @param opts
*/
delete(k: string): Promise<void>;
delete(k: string, opts?: Partial<KvDeleteOptions>): Promise<void>;
/**

@@ -1022,4 +1035,5 @@ * Deletes and purges the specified key and any value

* @param k
* @param opts
*/
purge(k: string): Promise<void>;
purge(k: string, opts?: Partial<KvDeleteOptions>): Promise<void>;
/**

@@ -1038,2 +1052,9 @@ * Destroys the underlying stream used by the KV. This

}
export interface KvDeleteOptions {
/**
* If set the KV must be at the current sequence or the
* put will fail.
*/
previousSeq: number;
}
export type ObjectStoreLink = {

@@ -1040,0 +1061,0 @@ /**

@@ -61,4 +61,4 @@ "use strict";

(function () {
var _a, e_1, _b, _c;
return __awaiter(this, void 0, void 0, function* () {
var _a, e_1, _b, _c;
try {

@@ -418,4 +418,4 @@ for (var _d = true, _e = __asyncValues(ph.status()), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {

}
jetstreamManager(opts = {}) {
return __awaiter(this, void 0, void 0, function* () {
jetstreamManager() {
return __awaiter(this, arguments, void 0, function* (opts = {}) {
const adm = new jsm_1.JetStreamManagerImpl(this, opts);

@@ -422,0 +422,0 @@ if (opts.checkAPI !== false) {

@@ -10,2 +10,3 @@ /**

inc: number;
inited: boolean;
constructor();

@@ -12,0 +13,0 @@ /**

@@ -48,3 +48,3 @@ /*

this.buf = new Uint8Array(totalLen);
this.init();
this.inited = false;
}

@@ -58,2 +58,3 @@ /**

init() {
this.inited = true;
this.setPre();

@@ -103,2 +104,5 @@ this.initSeqAndInc();

next() {
if (!this.inited) {
this.init();
}
this.seq += this.inc;

@@ -105,0 +109,0 @@ if (this.seq > maxSeq) {

@@ -22,3 +22,4 @@ export type SemVer = {

JS_STREAM_COMPRESSION = "js_stream_compression",
JS_DEFAULT_CONSUMER_LIMITS = "js_default_consumer_limits"
JS_DEFAULT_CONSUMER_LIMITS = "js_default_consumer_limits",
JS_BATCH_DIRECT_GET = "js_batch_direct_get"
}

@@ -25,0 +26,0 @@ type FeatureVersion = {

@@ -62,2 +62,3 @@ "use strict";

Feature["JS_DEFAULT_CONSUMER_LIMITS"] = "js_default_consumer_limits";
Feature["JS_BATCH_DIRECT_GET"] = "js_batch_direct_get";
})(Feature || (exports.Feature = Feature = {}));

@@ -107,2 +108,3 @@ class Features {

this.set(Feature.JS_DEFAULT_CONSUMER_LIMITS, "2.10.0");
this.set(Feature.JS_BATCH_DIRECT_GET, "2.11.0");
this.disabled.forEach((f) => {

@@ -109,0 +111,0 @@ this.features.delete(f);

@@ -58,4 +58,4 @@ "use strict";

}
q(v, name = "", id = "") {
return __awaiter(this, void 0, void 0, function* () {
q(v_1) {
return __awaiter(this, arguments, void 0, function* (v, name = "", id = "") {
const iter = new queued_iterator_1.QueuedIteratorImpl();

@@ -62,0 +62,0 @@ const jc = (0, codec_1.JSONCodec)();

@@ -134,5 +134,5 @@ "use strict";

function collect(iter) {
var _a, iter_1, iter_1_1;
var _b, e_1, _c, _d;
return __awaiter(this, void 0, void 0, function* () {
var _a, iter_1, iter_1_1;
var _b, e_1, _c, _d;
const buf = [];

@@ -139,0 +139,0 @@ try {

@@ -47,3 +47,3 @@ "use strict";

const dns = require("dns");
const VERSION = "2.19.0";
const VERSION = "2.20.0";
const LANG = "nats.js";

@@ -364,4 +364,4 @@ class NodeTransport {

}
_closed(err, internal = true) {
return __awaiter(this, void 0, void 0, function* () {
_closed(err_1) {
return __awaiter(this, arguments, void 0, function* (err, internal = true) {
// if this connection didn't succeed, then ignore it.

@@ -368,0 +368,0 @@ if (!this.connected)

{
"name": "nats",
"version": "2.19.0",
"version": "2.20.0",
"description": "Node.js client for NATS, a lightweight, high-performance cloud native messaging system",

@@ -45,3 +45,3 @@ "keywords": [

"clean": "shx rm -Rf ./lib/* ./nats-base-client ./.deps",
"clone-nbc": "shx mkdir -p ./.deps && cd ./.deps && git clone --branch v1.19.0 https://github.com/nats-io/nats.deno.git",
"clone-nbc": "shx mkdir -p ./.deps && cd ./.deps && git clone --branch v1.20.1 https://github.com/nats-io/nats.deno.git",
"fmt": "deno fmt ./src/ ./examples/ ./test/",

@@ -67,6 +67,6 @@ "prepack": "npm run clone-nbc && npm run cjs && npm run check-package && npm run build",

"dependencies": {
"nkeys.js": "1.0.5"
"nkeys.js": "1.1.0"
},
"devDependencies": {
"@types/node": "^20.8.x",
"@types/node": "^20.11.26",
"ava": "^5.3.x",

@@ -77,3 +77,3 @@ "minimist": "^1.2.8",

"shx": "^0.3.3",
"typescript": "5.3.2"
"typescript": "5.4.2"
},

@@ -80,0 +80,0 @@ "typings": "./lib/src/mod.d.ts",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc