Skip to content

Commit

Permalink
2.0.4 release (#423)
Browse files Browse the repository at this point in the history
* [update] nbc bumped to v1.0.4
[update] tooling deno deps on `1.9.2` and `[email protected]`
* updated types
  • Loading branch information
aricart authored May 10, 2021
1 parent 18824e7 commit e50979b
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 57 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/natsjs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
test:
strategy:
matrix:
node-version: [15.x, 14.x, 12.x, 10.x]
node-version: [16.x, 14.x, 12.x]

runs-on: ubuntu-latest

Expand All @@ -29,9 +29,9 @@ jobs:
- name: Use Deno Version ${{ matrix.deno-version }}
uses: denolib/setup-deno@master
with:
deno-version: 1.8.1
deno-version: 1.9.2
- name: Set NATS Server Version
run: echo "NATS_VERSION=v2.2.0" >> $GITHUB_ENV
run: echo "NATS_VERSION=v2.2.3" >> $GITHUB_ENV
- name: Get nats-server
run: |
wget "https://github.com/nats-io/nats-server/releases/download/$NATS_VERSION/nats-server-$NATS_VERSION-linux-amd64.zip" -O tmp.zip
Expand All @@ -43,11 +43,11 @@ jobs:
env:
CI: true
- name: Gather coverage
if: matrix.node-version == '15.x'
if: matrix.node-version == '16.x'
run: npm run coveralls
- name: Upload coverage
uses: coverallsapp/[email protected]
if: matrix.node-version == '15.x'
if: matrix.node-version == '16.x'
with:
github-token: ${{ secrets.github_token }}
path-to-lcov: ./coverage/lcov.info
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ coverage/
lib/
nats-base-client/
node_modules/
debug/
4 changes: 2 additions & 2 deletions bin/cjs-fix-imports.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { parse } from "https://deno.land/std@0.61.0/flags/mod.ts";
import { parse } from "https://deno.land/std@0.95.0/flags/mod.ts";
import {
basename,
extname,
join,
resolve,
} from "https://deno.land/std@0.61.0/path/mod.ts";
} from "https://deno.land/std@0.95.0/path/mod.ts";

const argv = parse(
Deno.args,
Expand Down
40 changes: 23 additions & 17 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ export interface NatsConnection {
export interface ConnectionOptions {
authenticator?: Authenticator;
debug?: boolean;
ignoreClusterUpdates?: boolean;
inboxPrefix?: string;
maxPingOut?: number;
maxReconnectAttempts?: number;
name?: string;
Expand All @@ -77,6 +75,8 @@ export interface ConnectionOptions {
user?: string;
verbose?: boolean;
waitOnFirstConnect?: boolean;
ignoreClusterUpdates?: boolean;
inboxPrefix?: string;
}
export interface TlsOptions {
certFile?: string;
Expand Down Expand Up @@ -155,16 +155,23 @@ export interface PublishOptions {
headers?: MsgHdrs;
}

export declare function canonicalMIMEHeaderKey(k: string): string;
export declare enum Match {
Exact = 0,
CanonicalMIME = 1,
IgnoreCase = 2
}
export interface MsgHdrs extends Iterable<[string, string[]]> {
hasError: boolean;
status: string;
code: number;
get(k: string): string;
set(k: string, v: string): void;
append(k: string, v: string): void;
has(k: string): boolean;
values(k: string): string[];
delete(k: string): void;
hasError: boolean;
status: string;
code: number;
description: string;
get(k: string, match?: Match): string;
set(k: string, v: string, match?: Match): void;
append(k: string, v: string, match?: Match): void;
has(k: string, match?: Match): boolean;
values(k: string, match?: Match): string[];
delete(k: string, match?: Match): void;
}
export declare function headers(): MsgHdrs;

Expand Down Expand Up @@ -243,21 +250,18 @@ export declare enum ErrorCode {
ProtocolError = "NATS_PROTOCOL_ERR",
PermissionsViolation = "PERMISSIONS_VIOLATION",
}

export declare interface NatsError extends Error {
name: string;
message: string;
code: string;
chainedError?: Error;
}

export interface Stats {
inBytes: number;
outBytes: number;
inMsgs: number;
outMsgs: number;
}

export interface Codec<T> {
encode(d: T): Uint8Array;
decode(a: Uint8Array): T;
Expand Down Expand Up @@ -311,7 +315,6 @@ export interface Pullable {
export interface Destroyable {
destroy(): Promise<void>;
}

export interface Dispatcher<T> {
push(v: T): void;
}
Expand All @@ -322,7 +325,6 @@ export interface QueuedIterator<T> extends Dispatcher<T> {
getPending(): number;
getReceived(): number;
}

export declare type JetStreamPullSubscription = JetStreamSubscription & Pullable;
export declare type JsMsgCallback = (err: NatsError | null, msg: JsMsg | null) => void;
export interface JetStreamClient {
Expand Down Expand Up @@ -371,8 +373,11 @@ export interface ConsumerAPI {
delete(stream: string, consumer: string): Promise<boolean>;
list(stream: string): Lister<ConsumerInfo>;
}
export declare type StreamInfoRequestOptions = {
"deleted_details": boolean;
};
export interface StreamAPI {
info(stream: string): Promise<StreamInfo>;
info(stream: string, opts?: StreamInfoRequestOptions): Promise<StreamInfo>;
add(cfg: Partial<StreamConfig>): Promise<StreamInfo>;
update(cfg: StreamConfig): Promise<StreamInfo>;
purge(stream: string): Promise<PurgeResponse>;
Expand Down Expand Up @@ -524,6 +529,7 @@ export interface StreamState {
"first_ts": number;
"last_seq": number;
"last_ts": string;
"num_deleted": number;
deleted: number[];
lost: LostStreamData;
"consumer_count": number;
Expand Down
30 changes: 15 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nats",
"version": "2.0.2",
"version": "2.0.4",
"description": "Node.js client for NATS, a lightweight, high-performance cloud native messaging system",
"keywords": [
"nats",
Expand Down Expand Up @@ -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.2 https://github.com/nats-io/nats.deno.git",
"clone-nbc": "shx mkdir -p ./.deps && cd ./.deps && git clone --branch v1.0.4 https://github.com/nats-io/nats.deno.git",
"fmt": "deno fmt ./src/ ./examples/ ./test/",
"prepack": "npm run clone-nbc && npm run cjs && npm run build",
"ava": "nyc ava --verbose -T 60000",
Expand All @@ -60,7 +60,7 @@
"nkeys.js": "^1.0.0-9"
},
"devDependencies": {
"@types/node": "^14.14.25",
"@types/node": "^14.14.34",
"ava": "^3.15.0",
"minimist": "^1.2.5",
"nyc": "^15.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/node_transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.2";
const VERSION = "2.0.4";
const LANG = "nats.js";

export class NodeTransport implements Transport {
Expand Down
29 changes: 15 additions & 14 deletions test/msgheaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
const test = require("ava");
// install globals
require("../lib/src/mod");
const { NatsError, MsgHdrsImpl } = require(
const { NatsError, MsgHdrsImpl, canonicalMIMEHeaderKey } = require(
"../lib/nats-base-client/internal_mod",
);

Expand All @@ -27,31 +27,32 @@ test("msgheaders - basics", (t) => {
h.append("foo", "bam");
h.append("foo-bar", "baz");

t.is(h.size(), 3);
t.is(h.size(), 2);
h.set("bar-foo", "foo");
t.is(h.size(), 4);
h.delete("bar-foo");
t.is(h.size(), 3);
h.delete("bar-foo");
t.is(h.size(), 2);

let header = MsgHdrsImpl.canonicalMIMEHeaderKey("foo");
let header = canonicalMIMEHeaderKey("foo");
t.is("Foo", header);
t.true(h.has("Foo"));
t.false(h.has("Foo"));
t.true(h.has("foo"));
const foos = h.values(header);
t.is(2, foos.length);
// we are case sensitive
let foos = h.values(header);
t.is(foos.length, 0);

foos = h.values("foo");
t.is(foos.length, 2);
t.true(foos.indexOf("bar") > -1);
t.true(foos.indexOf("bam") > -1);
t.is(foos.indexOf("baz"), -1);

header = MsgHdrsImpl.canonicalMIMEHeaderKey("foo-bar");
t.is("Foo-Bar", header);
const foobars = h.values(header);
t.is(1, foobars.length);
t.true(foobars.indexOf("baz") > -1);

const a = h.encode();
const hh = MsgHdrsImpl.decode(a);
t.true(h.equals(hh));
t.is(hh.size(), 2);
t.true(hh.has("foo"));
t.false(hh.has("bar-foo"));

hh.set("foo-bar-baz", "fbb");
t.false(h.equals(hh));
Expand Down

0 comments on commit e50979b

Please sign in to comment.