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 4.5.0 to 4.5.2

dist/jobs.d.ts

1

dist/index.d.ts

@@ -40,1 +40,2 @@ /**

export declare type Change = ChangeArray[0];
export { JobsRequest, JobEventType, doJob } from './jobs.js';

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

export { OADAClient } from './client.js';
export { JobsRequest, doJob } from './jobs.js';
//# sourceMappingURL=index.js.map

5

dist/utils.d.ts

@@ -17,6 +17,2 @@ /**

*/
/**
* @packageDocumentation
* Some useful functions
*/
import type { Tree } from '@oada/types/oada/tree/v1.js';

@@ -46,1 +42,2 @@ export declare function toArray<E extends unknown[] | readonly unknown[]>(itemOrArray: E | E[0]): E;

}>(error: E): Promise<E & Error>;
export declare const changeSym: unique symbol;

@@ -17,2 +17,4 @@ /**

*/
import { JsonPointer } from 'json-ptr';
import objectAssignDeep from 'object-assign-deep';
// Typescript sucks at figuring out Array.isArray on its own

@@ -121,2 +123,55 @@ function isArray(value) {

}
export const changeSym = Symbol('change');
/**
* Tell TS we should never reach here (i.e., this should never be called)
* @internal
*/
export function assertNever(value, message) {
throw new Error(message ?? `Bad value: ${value}`);
}
/**
* Replace `null` values in delete changes with `undefined`
* @internal
*/
export function translateDelete(body) {
if (body === null) {
return undefined;
}
if (typeof body !== 'object') {
return body;
}
if (Array.isArray(body)) {
return body.map((item) => translateDelete(item));
}
return Object.fromEntries(Object.entries(body).map(([key, value]) => [
key,
translateDelete(value),
]));
}
/**
* Construct object representing the change tree
* @internal
*/
export function buildChangeObject(rootChange, ...children) {
const changeBody = {
[changeSym]: [rootChange],
...(rootChange.type === 'delete'
? translateDelete(rootChange.body)
: rootChange.body),
};
for (const change of children) {
const ptr = JsonPointer.create(change.path);
const old = ptr.get(changeBody);
// eslint-disable-next-line security/detect-object-injection
const changes = old?.[changeSym] ?? [];
const body = change.type === 'delete'
? translateDelete(change.body)
: change.body;
const merged = objectAssignDeep(old ?? {}, body);
// eslint-disable-next-line security/detect-object-injection
merged[changeSym] = [...changes, change];
ptr.set(changeBody, merged, true);
}
return changeBody;
}
//# sourceMappingURL=utils.js.map

@@ -91,1 +91,3 @@ /**

export type Change = ChangeArray[0];
export { JobsRequest, JobEventType, doJob } from './jobs.js';

@@ -22,4 +22,6 @@ /**

*/
import type { Change, Json, JsonObject } from './index.js';
import type { Tree, TreeKey } from '@oada/types/oada/tree/v1.js';
import { JsonPointer } from 'json-ptr';
import objectAssignDeep from 'object-assign-deep';

@@ -163,1 +165,82 @@ // Typescript sucks at figuring out Array.isArray on its own

}
export const changeSym = Symbol('change');
/**
* @internal
*/
export type ChangeBody<T> = T & {
[changeSym]?: Array<Readonly<Change>>;
};
/**
* Tell TS we should never reach here (i.e., this should never be called)
* @internal
*/
export function assertNever(value: never, message?: string): never {
throw new Error(message ?? `Bad value: ${value}`);
}
/**
* Replace `null` values in delete changes with `undefined`
* @internal
*/
export function translateDelete(body: Json): Json | undefined {
if (body === null) {
return undefined;
}
if (typeof body !== 'object') {
return body;
}
if (Array.isArray(body)) {
return body.map((item) => translateDelete(item) as Json);
}
return Object.fromEntries(
Object.entries(body).map(([key, value]) => [
key,
translateDelete(value!) as Json,
])
);
}
/**
* Construct object representing the change tree
* @internal
*/
export function buildChangeObject(rootChange: Change, ...children: Change[]) {
const changeBody: ChangeBody<unknown> = {
[changeSym]: [rootChange],
...(rootChange.type === 'delete'
? (translateDelete(rootChange.body as Json) as JsonObject)
: rootChange.body),
};
for (const change of children) {
const ptr = JsonPointer.create(change.path);
const old = ptr.get(changeBody) as ChangeBody<unknown>;
// eslint-disable-next-line security/detect-object-injection
const changes = old?.[changeSym] ?? [];
const body =
change.type === 'delete'
? translateDelete(change.body as Json)
: change.body;
const merged = objectAssignDeep(old ?? {}, body);
// eslint-disable-next-line security/detect-object-injection
merged[changeSym] = [...changes, change];
ptr.set(changeBody, merged, true);
}
return changeBody;
}
/**
* @internal
*/
export interface Result<T, P = unknown> {
value: T;
path: string;
pointer: string;
parent: P;
parentProperty: string;
}
{
"name": "@oada/client",
"version": "4.5.0",
"version": "4.5.2",
"description": "A lightweight client tool to interact with an OADA-compliant server",

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

"dependencies": {
"@oada/types": "^3.3.0",
"@oada/jobs": "^4.2.5",
"@oada/types": "^3.4.6",
"abort-controller": "^3.0.0",

@@ -101,8 +102,12 @@ "buffer": "^6.0.3",

"isomorphic-ws": "^5.0.0",
"json-ptr": "^3.1.1",
"jsonpath-plus": "^7.2.0",
"media-type": "^0.3.1",
"object-assign-deep": "^0.4.0",
"p-queue": "^7.3.0",
"reconnecting-websocket": "^4.4.0",
"resolve-alpn": "^1.2.1",
"serialize-error": "^11.0.0",
"supports-color": "^9.2.3",
"tslib": "^2.4.0",
"tslib": "^2.5.0",
"utf-8-validate": "^5.0.9",

@@ -117,2 +122,3 @@ "ws": "^8.9.0",

"@types/node": "^16.11.65",
"@types/object-assign-deep": "^0",
"@types/ws": "^8.5.3",

@@ -119,0 +125,0 @@ "@typescript-eslint/eslint-plugin": "^5.40.0",

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