@oada/client
Advanced tools
Comparing version 2.2.2 to 2.3.0
@@ -43,3 +43,4 @@ /// <reference types="node" /> | ||
} | ||
export interface WatchRequest { | ||
export interface WatchRequestSingle { | ||
type?: "single"; | ||
path: string; | ||
@@ -50,2 +51,10 @@ rev?: string; | ||
} | ||
export interface WatchRequestTree { | ||
type: "tree"; | ||
path: string; | ||
rev?: string; | ||
watchCallback: (response: readonly Readonly<Change>[]) => void; | ||
timeout?: number; | ||
} | ||
export declare type WatchRequest = WatchRequestSingle | WatchRequestTree; | ||
export interface PUTRequest { | ||
@@ -52,0 +61,0 @@ path: string; |
@@ -117,3 +117,3 @@ "use strict"; | ||
let headers = {}; | ||
if (typeof (request.rev) !== 'undefined') { | ||
if (typeof request.rev !== "undefined") { | ||
headers["x-oada-rev"] = request.rev; | ||
@@ -127,4 +127,9 @@ } | ||
var _a; | ||
if (request.type === "tree") { | ||
request.watchCallback(resp.change); | ||
} | ||
for (const change of resp.change) { | ||
request.watchCallback(change); | ||
if (!request.type || request.type === "single") { | ||
request.watchCallback(change); | ||
} | ||
if (change.path === "") { | ||
@@ -131,0 +136,0 @@ const watchRequest = this._watchList.get(resp.requestId[0]); |
@@ -48,20 +48,23 @@ "use strict"; | ||
this._status = ConnectionStatus.Connecting; | ||
this._ws = new Promise((resolve) => { | ||
const ws = new reconnecting_websocket_1.default("wss://" + this._domain, [], { | ||
connectionTimeout: 30 * 1000, | ||
WebSocket: BetterWebSocket, | ||
}); | ||
ws.onopen = () => { | ||
trace("Connection opened."); | ||
this._status = ConnectionStatus.Connected; | ||
resolve(ws); | ||
this.emit("open"); | ||
}; | ||
ws.onclose = () => { | ||
trace("Connection closed."); | ||
this._status = ConnectionStatus.Disconnected; | ||
this.emit("close"); | ||
}; | ||
ws.onmessage = this._receive.bind(this); | ||
const ws = new reconnecting_websocket_1.default("wss://" + this._domain, [], { | ||
connectionTimeout: 30 * 1000, | ||
WebSocket: BetterWebSocket, | ||
}); | ||
const openP = events_1.once(ws, "open").then(() => ws); | ||
const errP = events_1.once(ws, "error").then((err) => Promise.reject(err)); | ||
this._ws = Promise.race([openP, errP]); | ||
ws.onopen = () => { | ||
trace("Connection opened."); | ||
this._status = ConnectionStatus.Connected; | ||
this.emit("open"); | ||
}; | ||
ws.onclose = () => { | ||
trace("Connection closed."); | ||
this._status = ConnectionStatus.Disconnected; | ||
this.emit("close"); | ||
}; | ||
ws.onerror = (err) => { | ||
trace("Connection error %O", err); | ||
}; | ||
ws.onmessage = this._receive.bind(this); | ||
this._q = new p_queue_1.default({ concurrency }); | ||
@@ -68,0 +71,0 @@ this._q.on("active", () => { |
{ | ||
"name": "@oada/client", | ||
"version": "2.2.2", | ||
"version": "2.3.0", | ||
"description": "A lightweight client tool to interact with an OADA-compliant server", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/OADA/client", |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
62707
909
0