From 9d53eda057472aceb5b5af9451f2cb7a0d5d033b Mon Sep 17 00:00:00 2001 From: Alberto Ricart Date: Fri, 2 Jul 2021 10:18:56 -0500 Subject: [PATCH] release 2.1.0 (#437) * [UPDATE] nbc 1.1.0 - see https://github.com/nats-io/nats.deno/releases/tag/v1.1.0 --- index.d.ts | 57 +++++++++++++++++++++++++++++++++++-------- package-lock.json | 4 +-- package.json | 4 +-- src/node_transport.ts | 2 +- 4 files changed, 52 insertions(+), 15 deletions(-) diff --git a/index.d.ts b/index.d.ts index 53472a5..9ebfa1c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -131,6 +131,7 @@ export interface ServersChanged { readonly deleted: string[]; } export interface Sub extends AsyncIterable { + closed: Promise; unsubscribe(max?: number): void; drain(): Promise; isDraining(): boolean; @@ -272,6 +273,7 @@ export declare function JSONCodec(): Codec; export interface JetStreamOptions { apiPrefix?: string; timeout?: number; + domain?: string; } export interface JetStreamManager { consumers: ConsumerAPI; @@ -299,6 +301,7 @@ export interface JetStreamPublishOptions { lastMsgID: string; streamName: string; lastSequence: number; + lastSubjectSequence: number; }>; } export interface ConsumerInfoable { @@ -364,6 +367,8 @@ export interface ConsumerOptsBuilder { maxMessages(max: number): void; queue(n: string): void; callback(fn: JsMsgCallback): void; + idleHeartbeat(millis: number): void; + flowControl(): void; } export interface Lister { next(): Promise; @@ -381,11 +386,11 @@ export interface StreamAPI { info(stream: string, opts?: StreamInfoRequestOptions): Promise; add(cfg: Partial): Promise; update(cfg: StreamConfig): Promise; - purge(stream: string): Promise; + purge(stream: string, opts?: PurgeOpts): Promise; delete(stream: string): Promise; list(): Lister; - deleteMessage(stream: string, seq: number): Promise; - getMessage(stream: string, seq: number): Promise; + deleteMessage(stream: string, seq: number, erase?: boolean): Promise; + getMessage(stream: string, query: MsgRequest): Promise; find(subject: string): Promise; } export interface JsMsg { @@ -478,16 +483,17 @@ export interface StreamConfig { "num_replicas": number; "no_ack"?: boolean; "template_owner"?: string; - "duplicate_window"?: number; + "duplicate_window"?: Nanos; placement?: Placement; mirror?: StreamSource; sources?: StreamSource[]; + "max_msgs_per_subject"?: number; } export interface StreamSource { name: string; - "opt_start_seq": number; - "opt_start_time": string; - "filter_subject": string; + "opt_start_seq"?: number; + "opt_start_time"?: string; + "filter_subject"?: string; } export interface Placement { cluster: string; @@ -557,6 +563,18 @@ export interface StreamSourceInfo { active: Nanos; error?: ApiError; } +export declare type PurgeOpts = PurgeBySeq | PurgeTrimOpts | PurgeBySubject; +export declare type PurgeBySeq = { + filter?: string; + seq: number; +}; +export declare type PurgeTrimOpts = { + filter?: string; + keep: number; +}; +export declare type PurgeBySubject = { + filter: string; +}; export interface PurgeResponse extends Success { purged: number; } @@ -600,10 +618,14 @@ export interface Success { success: boolean; } export declare type SuccessResponse = ApiResponse & Success; -export interface MsgRequest { +export interface LastForMsgRequest { + "last_by_subj": string; +} +export interface SeqMsgRequest { seq: number; } -export interface MsgDeleteRequest extends MsgRequest { +export declare type MsgRequest = SeqMsgRequest | LastForMsgRequest | number; +export interface MsgDeleteRequest extends SeqMsgRequest { "no_erase"?: boolean; } export interface JetStreamAccountStats { @@ -613,6 +635,7 @@ export interface JetStreamAccountStats { consumers: number; api: JetStreamApiStats; limits: AccountLimits; + domain?: string; } export interface JetStreamApiStats { total: number; @@ -634,7 +657,7 @@ export interface ConsumerConfig { "opt_start_seq"?: number; "opt_start_time"?: string; "ack_policy": AckPolicy; - "ack_wait"?: number; + "ack_wait"?: Nanos; "max_deliver"?: number; "filter_subject"?: string; "replay_policy": ReplayPolicy; @@ -642,6 +665,8 @@ export interface ConsumerConfig { "sample_freq"?: string; "max_waiting"?: number; "max_ack_pending"?: number; + "idle_heartbeat"?: Nanos; + "flow_control"?: boolean; } export interface Consumer { "stream_name": string; @@ -659,6 +684,12 @@ export interface NextRequest { "no_wait": boolean; } +export declare enum JsHeaders { + StreamSourceHdr = "Nats-Stream-Source", + LastConsumerSeqHdr = "Nats-Last-Consumer", + LastStreamSeqHdr = "Nats-Last-Stream" +} + export declare type MsgAdapter = ( err: NatsError | null, msg: Msg, @@ -678,3 +709,9 @@ export interface TypedSubscriptionOptions extends SubOpts { } export declare type DispatchedFn = (data: T | null) => void; + +export declare function defaultConsumer(name: string, opts?: Partial): ConsumerConfig; +export declare function nanos(millis: number): Nanos; +export declare function millis(ns: Nanos): number; +export declare function isFlowControlMsg(msg: Msg): boolean; +export declare function isHeartbeatMsg(msg: Msg): boolean; diff --git a/package-lock.json b/package-lock.json index 573eb32..412aae6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "nats", - "version": "2.0.6", + "version": "2.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "nats", - "version": "2.0.6", + "version": "2.1.0", "license": "Apache-2.0", "dependencies": { "nkeys.js": "^1.0.0-9" diff --git a/package.json b/package.json index 934acc5..f11b2f0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nats", - "version": "2.0.8", + "version": "2.1.0", "description": "Node.js client for NATS, a lightweight, high-performance cloud native messaging system", "keywords": [ "nats", @@ -41,7 +41,7 @@ "build": "tsc", "cjs": "deno run --allow-all bin/cjs-fix-imports.ts -o nats-base-client/ ./.deps/nats.deno/nats-base-client/", "clean": "shx rm -Rf ./lib/* ./nats-base-client ./.deps", - "clone-nbc": "shx mkdir -p ./.deps && cd ./.deps && git clone --branch v1.0.8 https://github.com/nats-io/nats.deno.git", + "clone-nbc": "shx mkdir -p ./.deps && cd ./.deps && git clone --branch v1.1.0 https://github.com/nats-io/nats.deno.git", "fmt": "deno fmt ./src/ ./examples/ ./test/", "prepack": "npm run clone-nbc && npm run cjs && npm run check-package && npm run build", "ava": "nyc ava --verbose -T 60000", diff --git a/src/node_transport.ts b/src/node_transport.ts index 55461a6..d37d449 100644 --- a/src/node_transport.ts +++ b/src/node_transport.ts @@ -33,7 +33,7 @@ import { connect as tlsConnect, TlsOptions, TLSSocket } from "tls"; const { resolve } = require("path"); const { readFile, existsSync } = require("fs"); -const VERSION = "2.0.8"; +const VERSION = "2.1.0"; const LANG = "nats.js"; export class NodeTransport implements Transport {