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

@omotes/sdk

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@omotes/sdk - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

src/lib/handlers/AvailableWorkflowsHandler.d.ts

5

package.json
{
"name": "@omotes/sdk",
"version": "0.1.1",
"version": "0.1.2",
"license": "Apache-2.0",
"repository": {

@@ -13,3 +14,3 @@ "type": "git",

"tslib": "2.6.2",
"@omotes/proto": "^0.1.9",
"@omotes/proto": "^0.1.12",
"google-protobuf": "^3.21.2",

@@ -16,0 +17,0 @@ "influx": "^5.9.3"

4

src/index.d.ts
export * from '@omotes/proto';
export * from './lib/Job';
export * from './lib/OmotesSDK';
export * from './lib/channel';

@@ -8,2 +6,4 @@ export * from './lib/handlers/ProgressHandler';

export * from './lib/handlers/StatusHandler';
export * from './lib/Job';
export * from './lib/OmotesSDK';
export * from './lib/types';

@@ -5,4 +5,2 @@ "use strict";

tslib_1.__exportStar(require("@omotes/proto"), exports);
tslib_1.__exportStar(require("./lib/Job"), exports);
tslib_1.__exportStar(require("./lib/OmotesSDK"), exports);
tslib_1.__exportStar(require("./lib/channel"), exports);

@@ -12,3 +10,5 @@ tslib_1.__exportStar(require("./lib/handlers/ProgressHandler"), exports);

tslib_1.__exportStar(require("./lib/handlers/StatusHandler"), exports);
tslib_1.__exportStar(require("./lib/Job"), exports);
tslib_1.__exportStar(require("./lib/OmotesSDK"), exports);
tslib_1.__exportStar(require("./lib/types"), exports);
//# sourceMappingURL=index.js.map
import { Connection } from 'amqplib';
export declare function getChannel(connection: Connection, queueName: string): Promise<import("amqplib").Channel>;
export declare function getChannel(connection: Connection, queueName: string, routingKey?: string): Promise<{
channel: import("amqplib").Channel;
exchange: import("amqplib").Replies.AssertExchange;
}>;

@@ -5,7 +5,9 @@ "use strict";

const tslib_1 = require("tslib");
function getChannel(connection, queueName) {
function getChannel(connection, queueName, routingKey) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const channel = yield connection.createChannel();
yield channel.assertQueue(queueName, { durable: true });
return channel;
const exchange = yield channel.assertExchange('omotes_exchange', 'direct');
const queue = yield channel.assertQueue(queueName, { durable: true });
yield channel.bindQueue(queue.queue, exchange.exchange, routingKey !== null && routingKey !== void 0 ? routingKey : queueName);
return { channel, exchange };
});

@@ -12,0 +14,0 @@ }

import { Channel, ConsumeMessage } from 'amqplib';
import { Observable, Subject } from 'rxjs';
import { Job } from '../Job';
export declare abstract class Handler {
protected readonly job: Job;
protected readonly channel$: Observable<Channel>;
protected readonly abstract queue: string;
protected readonly close$: Subject<void>;
constructor(job: Job, channel$: Observable<Channel>);
constructor(channel$: Observable<Channel>);
protected channelToRx(): Observable<ConsumeMessage>;
close(): void;
}

@@ -6,4 +6,3 @@ "use strict";

class Handler {
constructor(job, channel$) {
this.job = job;
constructor(channel$) {
this.channel$ = channel$;

@@ -10,0 +9,0 @@ this.close$ = new rxjs_1.Subject();

@@ -1,5 +0,5 @@

import { Handler } from './Handler';
export declare class ProgressHandler extends Handler {
import { JobHandler } from './JobHandler';
export declare class ProgressHandler extends JobHandler {
protected queue: string;
getProgress(): import("rxjs").Observable<number>;
}

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

const queue_1 = require("../queue");
const Handler_1 = require("./Handler");
class ProgressHandler extends Handler_1.Handler {
const JobHandler_1 = require("./JobHandler");
class ProgressHandler extends JobHandler_1.JobHandler {
constructor() {

@@ -11,0 +11,0 @@ super(...arguments);

import { JobResult } from '@omotes/proto';
import { Handler } from './Handler';
export declare class ResultHandler extends Handler {
import { JobHandler } from './JobHandler';
export declare class ResultHandler extends JobHandler {
protected queue: string;
getResult(): import("rxjs").Observable<JobResult.AsObject>;
}

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

const queue_1 = require("../queue");
const Handler_1 = require("./Handler");
class ResultHandler extends Handler_1.Handler {
const JobHandler_1 = require("./JobHandler");
class ResultHandler extends JobHandler_1.JobHandler {
constructor() {

@@ -11,0 +11,0 @@ super(...arguments);

import { JobStatusUpdate } from '@omotes/proto';
import { Observable } from 'rxjs';
import { Handler } from './Handler';
export declare class StatusHandler extends Handler {
import { JobHandler } from './JobHandler';
export declare class StatusHandler extends JobHandler {
protected queue: string;
getStatus(): Observable<JobStatusUpdate.JobStatusMap[keyof JobStatusUpdate.JobStatusMap]>;
}

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

const queue_1 = require("../queue");
const Handler_1 = require("./Handler");
class StatusHandler extends Handler_1.Handler {
const JobHandler_1 = require("./JobHandler");
class StatusHandler extends JobHandler_1.JobHandler {
constructor() {

@@ -11,0 +11,0 @@ super(...arguments);

@@ -0,8 +1,12 @@

import { Workflow } from '@omotes/proto';
import { Channel, Connection } from 'amqplib';
import { JavaScriptValue } from 'google-protobuf/google/protobuf/struct_pb';
import { ProgressHandler } from './handlers/ProgressHandler';
import { ResultHandler } from './handlers/ResultHandler';
import { StatusHandler } from './handlers/StatusHandler';
import { JobTypeName } from './types';
export type ParamsDict = {
[key: string]: JavaScriptValue;
};
export declare class Job {
readonly type: JobTypeName;
readonly type: Workflow.AsObject['typeName'];
private readonly esdl;

@@ -13,9 +17,12 @@ private readonly conn;

private readonly jobSubmission;
constructor(type: JobTypeName, esdl: string, conn: Connection, channel: Channel);
start(): void;
cancel(): void;
constructor(type: Workflow.AsObject['typeName'], esdl: string, conn: Connection, channel: Channel);
start(): this;
cancel(): this;
setParams(params: ParamsDict): this;
setJobReference(reference: string): this;
getProgressHandler(): ProgressHandler;
getStatusHandler(): StatusHandler;
getResultHandler(): ResultHandler;
private getChannelInstance;
private toBuffer;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Job = void 0;
const tslib_1 = require("tslib");
const proto_1 = require("@omotes/proto");
const struct_pb_1 = require("google-protobuf/google/protobuf/struct_pb");
const rxjs_1 = require("rxjs");

@@ -26,3 +28,4 @@ const uuidv7_1 = require("uuidv7");

start() {
this.channel.sendToQueue(`job_submissions.${this.type}`, this.toBuffer(this.jobSubmission));
this.channel.sendToQueue((0, queue_1.getSubmissionsQueue)(), this.toBuffer(this.jobSubmission), { persistent: true });
return this;
}

@@ -32,13 +35,28 @@ cancel() {

cancel.setUuid(this.uuid);
this.channel.sendToQueue(`job_submissions.${this.type}`, this.toBuffer(cancel));
this.channel.sendToQueue((0, queue_1.getCancellationsQueue)(), this.toBuffer(cancel), { persistent: true });
return this;
}
setParams(params) {
this.jobSubmission.setParamsDict(struct_pb_1.Struct.fromJavaScript(params));
return this;
}
setJobReference(reference) {
this.jobSubmission.setJobReference(reference);
return this;
}
getProgressHandler() {
return new ProgressHandler_1.ProgressHandler(this, (0, rxjs_1.from)((0, channel_1.getChannel)(this.conn, (0, queue_1.getProgressQueue)(this))));
return new ProgressHandler_1.ProgressHandler(this, (0, rxjs_1.from)(this.getChannelInstance(this.conn, (0, queue_1.getProgressQueue)(this))));
}
getStatusHandler() {
return new StatusHandler_1.StatusHandler(this, (0, rxjs_1.from)((0, channel_1.getChannel)(this.conn, (0, queue_1.getProgressQueue)(this))));
return new StatusHandler_1.StatusHandler(this, (0, rxjs_1.from)(this.getChannelInstance(this.conn, (0, queue_1.getStatusQueue)(this))));
}
getResultHandler() {
return new ResultHandler_1.ResultHandler(this, (0, rxjs_1.from)((0, channel_1.getChannel)(this.conn, (0, queue_1.getResultQueue)(this))));
return new ResultHandler_1.ResultHandler(this, (0, rxjs_1.from)(this.getChannelInstance(this.conn, (0, queue_1.getResultQueue)(this))));
}
getChannelInstance(connection, channelName) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const { channel } = yield (0, channel_1.getChannel)(connection, channelName);
return channel;
});
}
toBuffer(message) {

@@ -45,0 +63,0 @@ return Buffer.from(message.serializeBinary());

@@ -0,11 +1,14 @@

import { Workflow } from '@omotes/proto';
import { Observable } from 'rxjs';
import { Job } from './Job';
import { JobTypeName, OmotesSDKOptions } from './types';
import { OmotesSDKOptions } from './types';
export declare class OmotesSDK {
private readonly options;
private _connection;
workflows: Observable<Workflow.AsObject[]>;
private get connection();
constructor(options: OmotesSDKOptions);
connect(): Promise<void>;
createJob(type: JobTypeName, esdl: string): Promise<Job>;
getProfile(dbName: string, host: string, port: number, measurement: string, field: string, filterId: string): Promise<import("influx").IResults<{
createJob(type: Workflow.AsObject['typeName'], esdl: string): Promise<Job>;
getProfile(dbName: string, host: string, port: number, measurement: string, field: string): Promise<import("influx").IResults<{
value: number;

@@ -12,0 +15,0 @@ time: import("influx").INanoDate;

@@ -6,6 +6,7 @@ "use strict";

const amqplib_1 = require("amqplib");
const channel_1 = require("./channel");
const Job_1 = require("./Job");
const channel_1 = require("./channel");
const profiles_1 = require("./profiles");
const queue_1 = require("./queue");
const workflow_1 = require("./workflow");
class OmotesSDK {

@@ -31,2 +32,3 @@ get connection() {

});
this.workflows = yield (0, workflow_1.setupAvailableWorkflows)(this.connection, this.options.id);
});

@@ -36,4 +38,4 @@ }

return tslib_1.__awaiter(this, void 0, void 0, function* () {
const queue = (0, queue_1.getSubmissionQueue)(type);
const channel = yield (0, channel_1.getChannel)(this.connection, queue);
const queue = (0, queue_1.getSubmissionsQueue)();
const { channel } = yield (0, channel_1.getChannel)(this.connection, queue);
const job = new Job_1.Job(type, esdl, this.connection, channel);

@@ -43,5 +45,5 @@ return job;

}
getProfile(dbName, host, port, measurement, field, filterId) {
getProfile(dbName, host, port, measurement, field) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return (0, profiles_1.getProfile)(dbName, host, port, measurement, field, filterId, this.options.influxUser, this.options.influxPassword);
return (0, profiles_1.getProfile)(dbName, host, port, measurement, field, this.options.influxUser, this.options.influxPassword);
});

@@ -48,0 +50,0 @@ }

import { INanoDate } from 'influx';
export declare function getProfile(dbName: string, host: string, port: number, measurement: string, field: string, filterId: string, username: string, password: string): Promise<import("influx").IResults<{
export declare function getProfile(dbName: string, host: string, port: number, measurement: string, field: string, username: string, password: string): Promise<import("influx").IResults<{
value: number;
time: INanoDate;
}>>;

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

const influx_1 = require("influx");
function getProfile(dbName, host, port, measurement, field, filterId, username, password) {
function getProfile(dbName, host, port, measurement, field, username, password) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {

@@ -21,9 +21,8 @@ const db = new influx_1.InfluxDB({

},
tags: ['output_esdl_id']
tags: []
}
]
});
// @TODO: Filter on column assetId
const query = `select ${influx_1.escape.quoted(field)} as value, output_esdl_id from ${influx_1.escape.quoted(measurement)} where output_esdl_id = $filterId;`;
return db.query(query, { placeholders: { filterId } });
const query = `select ${influx_1.escape.quoted(field)} as value from ${influx_1.escape.quoted(measurement)};`;
return db.query(query);
});

@@ -30,0 +29,0 @@ }

import { Job } from './Job';
import { JobTypeName } from './types';
export declare function getSubmissionQueue(forType: JobTypeName): string;
export declare function getSubmissionsQueue(): string;
export declare function getProgressQueue(job: Job): string;
export declare function getResultQueue(job: Job): string;
export declare function getStatusQueue(job: Job): string;
export declare function getCancelQueue(job: Job): string;
export declare function getCancellationsQueue(): string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCancelQueue = exports.getStatusQueue = exports.getResultQueue = exports.getProgressQueue = exports.getSubmissionQueue = void 0;
function getSubmissionQueue(forType) {
return `job_submissions.${forType}`;
exports.getCancellationsQueue = exports.getStatusQueue = exports.getResultQueue = exports.getProgressQueue = exports.getSubmissionsQueue = void 0;
function getSubmissionsQueue() {
return `job_submissions`;
}
exports.getSubmissionQueue = getSubmissionQueue;
exports.getSubmissionsQueue = getSubmissionsQueue;
function getProgressQueue(job) {

@@ -20,6 +20,6 @@ return `jobs.${job.uuid}.progress`;

exports.getStatusQueue = getStatusQueue;
function getCancelQueue(job) {
return `jobs.${job.uuid}.cancel`;
function getCancellationsQueue() {
return `job_cancellations`;
}
exports.getCancelQueue = getCancelQueue;
exports.getCancellationsQueue = getCancellationsQueue;
//# sourceMappingURL=queue.js.map

@@ -8,3 +8,3 @@ export type OmotesSDKOptions = {

influxPassword: string;
id: string;
};
export type JobTypeName = 'grow_simulator' | 'simulator' | 'grow_optimizer_default' | 'grow_optimizer_no_heat_losses' | 'grow_optimizer_with_pressure';

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

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

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

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