Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@etclabscore/jade-service-runner-client

Package Overview
Dependencies
Maintainers
4
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@etclabscore/jade-service-runner-client - npm Package Compare versions

Comparing version 1.4.14 to 1.5.0

28

build/index.d.ts

@@ -1,2 +0,3 @@

import { Client } from "@open-rpc/client-js";
import { WebSocketTransport, HTTPTransport, Client, JSONRPCError } from "@open-rpc/client-js";
import { OpenRPC } from "@open-rpc/meta-schema";
export declare type StringWxzVcTo3 = string;

@@ -69,7 +70,30 @@ export declare type StringFek9G2ZM = "all" | "running" | "available" | "installed";

export declare class ServiceRunner {
static openrpcDocument: OpenRPC;
rpc: Client;
transport: HTTPTransport | WebSocketTransport;
private validator;
private openrpcDocument;
private timeout;
constructor(options: Options);
/**
* Adds a JSONRPC notification handler to handle receiving notifications.
* @example
* myClient.onNotification((data)=>console.log(data));
*/
onNotification(callback: (data: any) => void): void;
/**
* Adds an optional JSONRPCError handler to handle receiving errors that cannot be resolved to a specific request
* @example
* myClient.onError((err: JSONRPCError)=>console.log(err.message));
*/
onError(callback: (data: JSONRPCError) => void): void;
/**
* Sets a default timeout in ms for all requests excluding notifications.
* @example
* // 20s timeout
* myClient.setDefaultTimeout(20000);
* // Removes timeout from request
* myClient.setDefaultTimeout(undefined);
*/
setDefaultTimeout(ms?: number): void;
/**
* Initiates [[ServiceRunner.startBatch]] in order to build a batch call.

@@ -76,0 +100,0 @@ *

@@ -15,2 +15,3 @@ "use strict";

*/
// tslint:disable-next-line:max-line-length
this.installService = (...params) => {

@@ -22,2 +23,3 @@ return this.request("installService", params);

*/
// tslint:disable-next-line:max-line-length
this.listServices = (...params) => {

@@ -29,2 +31,3 @@ return this.request("listServices", params);

*/
// tslint:disable-next-line:max-line-length
this.listInstalledServices = (...params) => {

@@ -36,2 +39,3 @@ return this.request("listInstalledServices", params);

*/
// tslint:disable-next-line:max-line-length
this.listRunningServices = (...params) => {

@@ -43,6 +47,6 @@ return this.request("listRunningServices", params);

*/
// tslint:disable-next-line:max-line-length
this.startService = (...params) => {
return this.request("startService", params);
};
this.openrpcDocument = { "info": { "title": "ServiceRunner", "version": "1.4.14" }, "methods": [{ "name": "installService", "params": [{ "name": "serviceName", "schema": { "type": "string" }, "required": true }, { "name": "version", "schema": { "type": "string" }, "required": true }], "result": { "name": "installSuccess", "schema": { "type": "boolean" } } }, { "name": "listServices", "params": [{ "name": "filter", "schema": { "type": "string", "enum": ["all", "running", "available", "installed"] }, "required": true }], "result": { "name": "listedServices", "schema": { "type": "array", "items": { "type": "object", "properties": { "name": { "type": "string" }, "version": { "type": "string" }, "enviornments": { "type": "array", "items": { "type": "string" } }, "state": { "type": "string", "enum": ["active", "available", "installed"] } } } } } }, { "name": "listInstalledServices", "params": [], "result": { "name": "installedServices", "schema": { "type": "array", "items": { "type": "object", "properties": { "name": { "type": "string" }, "version": { "type": "string" } } } } } }, { "name": "listRunningServices", "params": [], "result": { "name": "runningServices", "schema": { "type": "array", "items": { "description": "An object that describes an instance of a service", "type": "object", "properties": { "env": { "type": "string" }, "rpcPort": { "type": "string" }, "name": { "type": "string" }, "version": { "type": "string" }, "path": { "type": "string" }, "commands": { "type": "object", "properties": { "setup": { "type": "array", "items": { "type": "object", "properties": { "cmd": { "type": "string" }, "args": { "type": "array", "items": { "type": "string" } } }, "required": ["cmd", "args"] } }, "start": { "type": "string" }, "stop": { "type": "string" }, "teardown": { "type": "string" } }, "required": ["setup", "start", "stop", "teardown"] }, "args": { "type": "object", "properties": { "start": { "type": "array", "items": { "type": "string" } }, "stop": { "type": "array", "items": { "type": "string" } }, "teardown": { "type": "array", "items": { "type": "string" } } }, "required": ["start", "stop", "teardown"] }, "state": { "type": "string" } }, "required": ["env", "rpcPort", "name", "version", "path", "commands", "args", "running"] } } } }, { "name": "startService", "params": [{ "name": "name", "schema": { "type": "string" }, "required": true }, { "name": "version", "schema": { "type": "string" }, "required": true }, { "name": "environment", "schema": { "type": "string" }, "required": true }], "result": { "name": "serviceConfig", "schema": { "description": "An object that describes an instance of a service", "type": "object", "properties": { "env": { "type": "string" }, "rpcPort": { "type": "string" }, "name": { "type": "string" }, "version": { "type": "string" }, "path": { "type": "string" }, "commands": { "type": "object", "properties": { "setup": { "type": "array", "items": { "type": "object", "properties": { "cmd": { "type": "string" }, "args": { "type": "array", "items": { "type": "string" } } }, "required": ["cmd", "args"] } }, "start": { "type": "string" }, "stop": { "type": "string" }, "teardown": { "type": "string" } }, "required": ["setup", "start", "stop", "teardown"] }, "args": { "type": "object", "properties": { "start": { "type": "array", "items": { "type": "string" } }, "stop": { "type": "array", "items": { "type": "string" } }, "teardown": { "type": "array", "items": { "type": "string" } } }, "required": ["start", "stop", "teardown"] }, "state": { "type": "string" } }, "required": ["env", "rpcPort", "name", "version", "path", "commands", "args", "running"] }, "required": true } }], "components": { "schemas": { "StringArray": { "type": "array", "items": { "type": "string" } }, "SeqCommand": { "type": "object", "properties": { "cmd": { "type": "string" }, "args": { "type": "array", "items": { "type": "string" } } }, "required": ["cmd", "args"] }, "EnvArgs": { "type": "object", "properties": { "start": { "type": "array", "items": { "type": "string" } }, "stop": { "type": "array", "items": { "type": "string" } }, "teardown": { "type": "array", "items": { "type": "string" } } }, "required": ["start", "stop", "teardown"] }, "Commands": { "type": "object", "properties": { "setup": { "type": "array", "items": { "type": "object", "properties": { "cmd": { "type": "string" }, "args": { "type": "array", "items": { "type": "string" } } }, "required": ["cmd", "args"] } }, "start": { "type": "string" }, "stop": { "type": "string" }, "teardown": { "type": "string" } }, "required": ["setup", "start", "stop", "teardown"] }, "Service": { "description": "An object that describes an instance of a service", "type": "object", "properties": { "env": { "type": "string" }, "rpcPort": { "type": "string" }, "name": { "type": "string" }, "version": { "type": "string" }, "path": { "type": "string" }, "commands": { "type": "object", "properties": { "setup": { "type": "array", "items": { "type": "object", "properties": { "cmd": { "type": "string" }, "args": { "type": "array", "items": { "type": "string" } } }, "required": ["cmd", "args"] } }, "start": { "type": "string" }, "stop": { "type": "string" }, "teardown": { "type": "string" } }, "required": ["setup", "start", "stop", "teardown"] }, "args": { "type": "object", "properties": { "start": { "type": "array", "items": { "type": "string" } }, "stop": { "type": "array", "items": { "type": "string" } }, "teardown": { "type": "array", "items": { "type": "string" } } }, "required": ["start", "stop", "teardown"] }, "state": { "type": "string" } }, "required": ["env", "rpcPort", "name", "version", "path", "commands", "args", "running"] } } }, "openrpc": "1.0.0-rc0" };
if (options.transport === undefined || options.transport.type === undefined) {

@@ -56,10 +60,9 @@ throw new Error("Invalid constructor params");

}
let transport;
switch (type) {
case "http":
case "https":
transport = new client_js_1.HTTPTransport(type + "://" + host + ":" + port + path);
this.transport = new client_js_1.HTTPTransport(type + "://" + host + ":" + port + path);
break;
case "websocket":
transport = new client_js_1.WebSocketTransport("ws://" + host + ":" + port + path);
this.transport = new client_js_1.WebSocketTransport("ws://" + host + ":" + port + path);
break;

@@ -70,6 +73,33 @@ default:

}
this.rpc = new client_js_1.Client(new client_js_1.RequestManager([transport]));
this.validator = new schema_utils_js_1.MethodCallValidator(this.openrpcDocument);
this.rpc = new client_js_1.Client(new client_js_1.RequestManager([this.transport]));
this.validator = new schema_utils_js_1.MethodCallValidator(ServiceRunner.openrpcDocument);
}
/**
* Adds a JSONRPC notification handler to handle receiving notifications.
* @example
* myClient.onNotification((data)=>console.log(data));
*/
onNotification(callback) {
this.rpc.onNotification(callback);
}
/**
* Adds an optional JSONRPCError handler to handle receiving errors that cannot be resolved to a specific request
* @example
* myClient.onError((err: JSONRPCError)=>console.log(err.message));
*/
onError(callback) {
this.rpc.onError(callback);
}
/**
* Sets a default timeout in ms for all requests excluding notifications.
* @example
* // 20s timeout
* myClient.setDefaultTimeout(20000);
* // Removes timeout from request
* myClient.setDefaultTimeout(undefined);
*/
setDefaultTimeout(ms) {
this.timeout = ms;
}
/**
* Initiates [[ServiceRunner.startBatch]] in order to build a batch call.

@@ -106,5 +136,6 @@ *

request(methodName, params) {
const methodObject = lodash_1.default.find(this.openrpcDocument.methods, ({ name }) => name === methodName);
const methodObject = lodash_1.default.find(ServiceRunner.openrpcDocument.methods, ({ name }) => name === methodName);
const notification = methodObject.result ? false : true;
const openRpcMethodValidationErrors = this.validator.validate(methodName, params);
if (openRpcMethodValidationErrors.length > 0) {
if (openRpcMethodValidationErrors instanceof schema_utils_js_1.MethodNotFoundError || openRpcMethodValidationErrors.length > 0) {
return Promise.reject(openRpcMethodValidationErrors);

@@ -119,7 +150,11 @@ }

}
return this.rpc.request(methodName, rpcParams);
if (notification) {
return this.rpc.notify(methodName, rpcParams);
}
return this.rpc.request(methodName, rpcParams, this.timeout);
}
}
ServiceRunner.openrpcDocument = { "info": { "title": "ServiceRunner", "version": "1.5.0" }, "methods": [{ "name": "installService", "params": [{ "name": "serviceName", "schema": { "type": "string" }, "required": true }, { "name": "version", "schema": { "type": "string" }, "required": true }], "result": { "name": "installSuccess", "schema": { "type": "boolean" } } }, { "name": "listServices", "params": [{ "name": "filter", "schema": { "type": "string", "enum": ["all", "running", "available", "installed"] }, "required": true }], "result": { "name": "listedServices", "schema": { "type": "array", "items": { "type": "object", "properties": { "name": { "type": "string" }, "version": { "type": "string" }, "enviornments": { "type": "array", "items": { "type": "string" } }, "state": { "type": "string", "enum": ["active", "available", "installed"] } } } } } }, { "name": "listInstalledServices", "params": [], "result": { "name": "installedServices", "schema": { "type": "array", "items": { "type": "object", "properties": { "name": { "type": "string" }, "version": { "type": "string" } } } } } }, { "name": "listRunningServices", "params": [], "result": { "name": "runningServices", "schema": { "type": "array", "items": { "description": "An object that describes an instance of a service", "type": "object", "properties": { "env": { "type": "string" }, "rpcPort": { "type": "string" }, "name": { "type": "string" }, "version": { "type": "string" }, "path": { "type": "string" }, "commands": { "type": "object", "properties": { "setup": { "type": "array", "items": { "type": "object", "properties": { "cmd": { "type": "string" }, "args": { "type": "array", "items": { "type": "string" } } }, "required": ["cmd", "args"] } }, "start": { "type": "string" }, "stop": { "type": "string" }, "teardown": { "type": "string" } }, "required": ["setup", "start", "stop", "teardown"] }, "args": { "type": "object", "properties": { "start": { "type": "array", "items": { "type": "string" } }, "stop": { "type": "array", "items": { "type": "string" } }, "teardown": { "type": "array", "items": { "type": "string" } } }, "required": ["start", "stop", "teardown"] }, "state": { "type": "string" } }, "required": ["env", "rpcPort", "name", "version", "path", "commands", "args", "running"] } } } }, { "name": "startService", "params": [{ "name": "name", "schema": { "type": "string" }, "required": true }, { "name": "version", "schema": { "type": "string" }, "required": true }, { "name": "environment", "schema": { "type": "string" }, "required": true }], "result": { "name": "serviceConfig", "schema": { "description": "An object that describes an instance of a service", "type": "object", "properties": { "env": { "type": "string" }, "rpcPort": { "type": "string" }, "name": { "type": "string" }, "version": { "type": "string" }, "path": { "type": "string" }, "commands": { "type": "object", "properties": { "setup": { "type": "array", "items": { "type": "object", "properties": { "cmd": { "type": "string" }, "args": { "type": "array", "items": { "type": "string" } } }, "required": ["cmd", "args"] } }, "start": { "type": "string" }, "stop": { "type": "string" }, "teardown": { "type": "string" } }, "required": ["setup", "start", "stop", "teardown"] }, "args": { "type": "object", "properties": { "start": { "type": "array", "items": { "type": "string" } }, "stop": { "type": "array", "items": { "type": "string" } }, "teardown": { "type": "array", "items": { "type": "string" } } }, "required": ["start", "stop", "teardown"] }, "state": { "type": "string" } }, "required": ["env", "rpcPort", "name", "version", "path", "commands", "args", "running"] }, "required": true } }], "components": { "schemas": { "StringArray": { "type": "array", "items": { "type": "string" } }, "SeqCommand": { "type": "object", "properties": { "cmd": { "type": "string" }, "args": { "type": "array", "items": { "type": "string" } } }, "required": ["cmd", "args"] }, "EnvArgs": { "type": "object", "properties": { "start": { "type": "array", "items": { "type": "string" } }, "stop": { "type": "array", "items": { "type": "string" } }, "teardown": { "type": "array", "items": { "type": "string" } } }, "required": ["start", "stop", "teardown"] }, "Commands": { "type": "object", "properties": { "setup": { "type": "array", "items": { "type": "object", "properties": { "cmd": { "type": "string" }, "args": { "type": "array", "items": { "type": "string" } } }, "required": ["cmd", "args"] } }, "start": { "type": "string" }, "stop": { "type": "string" }, "teardown": { "type": "string" } }, "required": ["setup", "start", "stop", "teardown"] }, "Service": { "description": "An object that describes an instance of a service", "type": "object", "properties": { "env": { "type": "string" }, "rpcPort": { "type": "string" }, "name": { "type": "string" }, "version": { "type": "string" }, "path": { "type": "string" }, "commands": { "type": "object", "properties": { "setup": { "type": "array", "items": { "type": "object", "properties": { "cmd": { "type": "string" }, "args": { "type": "array", "items": { "type": "string" } } }, "required": ["cmd", "args"] } }, "start": { "type": "string" }, "stop": { "type": "string" }, "teardown": { "type": "string" } }, "required": ["setup", "start", "stop", "teardown"] }, "args": { "type": "object", "properties": { "start": { "type": "array", "items": { "type": "string" } }, "stop": { "type": "array", "items": { "type": "string" } }, "teardown": { "type": "array", "items": { "type": "string" } } }, "required": ["start", "stop", "teardown"] }, "state": { "type": "string" } }, "required": ["env", "rpcPort", "name", "version", "path", "commands", "args", "running"] } } }, "openrpc": "1.0.0-rc0" };
exports.ServiceRunner = ServiceRunner;
exports.default = ServiceRunner;
//# sourceMappingURL=index.js.map

8

package.json
{
"name": "@etclabscore/jade-service-runner-client",
"version": "1.4.14",
"version": "1.5.0",
"description": "",

@@ -16,5 +16,5 @@ "main": "build/index.js",

"dependencies": {
"@open-rpc/client-js": "^1.1.0",
"@open-rpc/meta-schema": "^1.3.1",
"@open-rpc/schema-utils-js": "^1.10.2",
"@open-rpc/client-js": "^1.2.3",
"@open-rpc/meta-schema": "^1.5.3",
"@open-rpc/schema-utils-js": "^1.11.5",
"lodash": "^4.17.15"

@@ -21,0 +21,0 @@ },

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