Socket
Socket
Sign inDemoInstall

@oada/client

Package Overview
Dependencies
Maintainers
8
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oada/client - npm Package Compare versions

Comparing version 3.0.5 to 3.0.7

59

dist/client.d.ts

@@ -27,9 +27,18 @@ /**

export declare type Body = Json | Buffer;
export interface ConnectionRequest {
export declare type ConnectionRequest = {
requestId?: string;
path: string;
method: 'head' | 'get' | 'put' | 'post' | 'delete' | 'watch' | 'unwatch';
/**
* @default false
*/
watch?: boolean;
method: 'head' | 'get' | 'put' | 'post' | 'delete' | 'unwatch';
headers: Record<string, string>;
data?: Body;
}
} & ({
watch?: false;
} | {
watch: true;
method: 'head' | 'get' | 'put' | 'post' | 'delete';
});
export interface ConnectionResponse {

@@ -92,7 +101,11 @@ requestId: string | string[];

}
/**
* Watch whose callback gets single changes
*/
export interface WatchRequestSingle {
type?: 'single';
export interface WatchRequestBase {
/**
* @default 'single'
*/
type?: 'tree' | 'single';
/**
* @default 'head'
*/
initialMethod?: 'get' | 'head' | 'put' | 'post' | 'delete';
path: string;

@@ -104,10 +117,12 @@ rev?: number | string;

/**
* Watch whose callback gets single changes
*/
export interface WatchRequestSingle extends WatchRequestBase {
type?: 'single';
}
/**
* @deprecated
*/
export interface WatchRequestSingleOld {
type: 'single';
path: string;
rev?: number | string;
persist?: PersistConfig;
timeout?: number;
export interface WatchRequestSingleOld extends WatchRequestBase {
type?: 'single';
watchCallback(response: Readonly<Change>): Promise<void>;

@@ -118,8 +133,4 @@ }

*/
export interface WatchRequestTree {
export interface WatchRequestTree extends WatchRequestBase {
type: 'tree';
path: string;
rev?: string;
persist?: PersistConfig;
timeout?: number;
}

@@ -129,8 +140,4 @@ /**

*/
export interface WatchRequestTreeOld {
export interface WatchRequestTreeOld extends WatchRequestBase {
type: 'tree';
path: string;
rev?: string;
persist?: PersistConfig;
timeout?: number;
watchCallback(response: ReadonlyArray<Readonly<Change>>): Promise<void>;

@@ -190,2 +197,6 @@ }

getDomain(): string;
/**
* Get the connection concurrency
*/
getConcurrency(): number;
/** Disconnect from server */

@@ -192,0 +203,0 @@ disconnect(): Promise<void>;

@@ -108,2 +108,8 @@ "use strict";

}
/**
* Get the connection concurrency
*/
getConcurrency() {
return (0, tslib_1.__classPrivateFieldGet)(this, _OADAClient_concurrency, "f");
}
/** Disconnect from server */

@@ -171,6 +177,6 @@ async disconnect() {

headers['x-oada-rev'] = lastRev.toString();
info(`Watch persist found _meta entry for [${name}]. Setting x-oada-rev header to ${lastRev}`);
trace(`Watch persist found _meta entry for [${name}]. Setting x-oada-rev header to ${lastRev}`);
}
if (!lastRev) {
info(`Watch persist found _meta entry for [${name}], but 'rev' is undefined. Writing 'rev' as ${rev}`);
trace(`Watch persist found _meta entry for [${name}], but 'rev' is undefined. Writing 'rev' as ${rev}`);
await this.put({

@@ -198,3 +204,3 @@ path: `${persistPath}/rev`,

});
info(`Watch persist did not find _meta entry for [${name}]. Current resource _rev is ${lastRev}. Not setting x-oada-rev header. _meta entry created.`);
trace(`Watch persist did not find _meta entry for [${name}]. Current resource _rev is ${lastRev}. Not setting x-oada-rev header. _meta entry created.`);
}

@@ -240,4 +246,6 @@ }

});
const { persist, path, timeout, initialMethod: method = 'head' } = request;
const [response, w] = await (0, tslib_1.__classPrivateFieldGet)(this, _OADAClient_connection, "f").request({
method: 'watch',
watch: true,
method,
headers: {

@@ -247,4 +255,4 @@ authorization: `Bearer ${(0, tslib_1.__classPrivateFieldGet)(this, _OADAClient_token, "f")}`,

},
path: request.path,
}, { timeout: request.timeout, signal: restart.signal });
path,
}, { timeout, signal: restart.signal });
if (response.status !== 200) {

@@ -262,3 +270,3 @@ throw new Error('Watch request failed!');

let parentRev;
if (request.persist) {
if (persist) {
const bod = (_a = resp === null || resp === void 0 ? void 0 : resp.change.find((c) => c.path === '')) === null || _a === void 0 ? void 0 : _a.body;

@@ -294,3 +302,3 @@ if (typeof bod === 'object' &&

// Persist the new parent rev
if (request.persist &&
if (persist &&
typeof parentRev === 'number' &&

@@ -596,3 +604,3 @@ (0, tslib_1.__classPrivateFieldGet)(this, _OADAClient_persistList, "f").has(persistPath)) {

async function _OADAClient_persistWatch(persistPath, rev) {
info(`Persisting watch for path ${persistPath} to rev ${rev}`);
trace(`Persisting watch for path ${persistPath} to rev ${rev}`);
if ((0, tslib_1.__classPrivateFieldGet)(this, _OADAClient_persistList, "f").has(persistPath)) {

@@ -626,3 +634,3 @@ let { lastRev, recorded, items, recordLapsedTimeout, lastCheck } = (0, tslib_1.__classPrivateFieldGet)(this, _OADAClient_persistList, "f").get(persistPath);

});
info('Persisted watch: path: [%s], rev: [%d]', persistPath, lastRev);
trace('Persisted watch: path: [%s], rev: [%d]', persistPath, lastRev);
}

@@ -634,3 +642,3 @@ }, _OADAClient_recordLapsedRevs =

async function _OADAClient_recordLapsedRevs(persistPath, now) {
info(`Checking for lapsed revs for path [${persistPath}] time: [${now}]`);
trace(`Checking for lapsed revs for path [${persistPath}] time: [${now}]`);
const { items, recorded, recordLapsedTimeout } = (0, tslib_1.__classPrivateFieldGet)(this, _OADAClient_persistList, "f").get(persistPath);

@@ -637,0 +645,0 @@ // Iterate over items;

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

// Check for WATCH/UNWATCH
if (request.method === 'watch' || request.method === 'unwatch') {
if (request.watch || request.method === 'unwatch') {
trace('WATCH/UNWATCH not currently supported for http(2), falling-back to ws');

@@ -111,0 +111,0 @@ if (!(0, tslib_1.__classPrivateFieldGet)(this, _HttpClient_ws, "f")) {

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

const isomorphic_timers_promises_1 = require("isomorphic-timers-promises");
const request_1 = require("@oada/types/oada/websockets/request");
const v2_1 = require("@oada/types/oada/change/v2");
const request_1 = require("@oada/types/oada/websockets/request");
const change_1 = require("@oada/types/oada/websockets/change");

@@ -125,2 +125,3 @@ const response_1 = require("@oada/types/oada/websockets/response");

var _a;
const ws = await (0, tslib_1.__classPrivateFieldGet)(this, _WebSocketClient_ws, "f");
// Send object to the server.

@@ -133,4 +134,11 @@ // eslint-disable-next-line unicorn/no-await-expression-member

const responsePs = [(0, event_iterator_1.once)((0, tslib_1.__classPrivateFieldGet)(this, _WebSocketClient_requests, "f"), `response:${requestId}`)];
// eslint-disable-next-line unicorn/no-await-expression-member
(await (0, tslib_1.__classPrivateFieldGet)(this, _WebSocketClient_ws, "f")).send(JSON.stringify(request));
const socketRequest = {
...request,
method: request.watch
? request.method === 'head'
? 'watch'
: `${request.method}-watch`
: request.method,
};
ws.send(JSON.stringify(socketRequest));
if (timeout) {

@@ -145,5 +153,5 @@ responsePs.push(

if (response.status >= 200 && response.status < 300) {
if (request.method === 'watch') {
const watch = (0, event_iterator_1.on)((0, tslib_1.__classPrivateFieldGet)(this, _WebSocketClient_requests, "f"), `change:${requestId}`, { signal });
return [response, watch];
if (request.watch) {
const changes = (0, event_iterator_1.on)((0, tslib_1.__classPrivateFieldGet)(this, _WebSocketClient_requests, "f"), `change:${requestId}`, { signal });
return [response, changes];
}

@@ -150,0 +158,0 @@ return [response];

{
"name": "@oada/client",
"version": "3.0.5",
"version": "3.0.7",
"description": "A lightweight client tool to interact with an OADA-compliant server",

@@ -51,3 +51,3 @@ "repository": "https://github.com/OADA/client",

"dependencies": {
"@oada/types": "^1.7.0",
"@oada/types": "^1.8.1",
"buffer": "^6.0.3",

@@ -73,3 +73,3 @@ "bufferutil": "^4.0.5",

"utf-8-validate": "^5.0.7",
"ws": "^8.3.0"
"ws": "^8.4.0"
},

@@ -83,8 +83,8 @@ "devDependencies": {

"@types/mocha": "^9.0.0",
"@types/node": "^16.11.14",
"@types/node": "^16.11.15",
"@types/type-is": "^1.6.3",
"@types/uuid": "^8.3.3",
"@types/ws": "^8.2.2",
"@typescript-eslint/eslint-plugin": "^5.7.0",
"@typescript-eslint/parser": "^5.7.0",
"@typescript-eslint/eslint-plugin": "^5.8.0",
"@typescript-eslint/parser": "^5.8.0",
"@yarnpkg/sdks": "2.5.1-rc.6",

@@ -114,3 +114,3 @@ "axios": "^0.24.0",

"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-promise": "^5.2.0",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-regexp": "^1.5.1",

@@ -123,5 +123,5 @@ "eslint-plugin-security": "^1.4.0",

"ts-node": "^10.4.0",
"typescript": "4.4.4"
"typescript": "4.5.4"
},
"packageManager": "yarn@3.1.1"
}

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