@omotes/sdk
Advanced tools
Comparing version 0.1.3 to 0.1.4
{ | ||
"name": "@omotes/sdk", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -31,3 +31,5 @@ "use strict"; | ||
}); | ||
this.workflows = yield (0, workflow_1.setupAvailableWorkflows)(this.connection, this.options.id); | ||
const { trigger, workflows } = yield (0, workflow_1.setupAvailableWorkflows)(this.connection, this.options.id); | ||
this.workflows = workflows; | ||
trigger(); | ||
}); | ||
@@ -34,0 +36,0 @@ } |
import { Connection } from 'amqplib'; | ||
export declare function setupAvailableWorkflows(connection: Connection, clientId: string): Promise<import("rxjs").Observable<import("@omotes/proto").Workflow.AsObject[]>>; | ||
export declare function setupAvailableWorkflows(connection: Connection, clientId: string): Promise<{ | ||
workflows: import("rxjs").Observable<import("@omotes/proto").Workflow.AsObject[]>; | ||
trigger: () => boolean; | ||
}>; |
@@ -5,14 +5,15 @@ "use strict"; | ||
const tslib_1 = require("tslib"); | ||
const proto_1 = require("@omotes/proto"); | ||
const rxjs_1 = require("rxjs"); | ||
const channel_1 = require("./channel"); | ||
const AvailableWorkflowsHandler_1 = require("./handlers/AvailableWorkflowsHandler"); | ||
const RequestAvailableWorkflowsHandler_1 = require("./handlers/RequestAvailableWorkflowsHandler"); | ||
function setupAvailableWorkflows(connection, clientId) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const availableChannel$ = (0, rxjs_1.from)((0, channel_1.getChannel)(connection, `available_workflows.${clientId}`, 'available_workflows')).pipe((0, rxjs_1.map)(({ channel }) => channel)); | ||
const { channel: requestChannel } = yield (0, channel_1.getChannel)(connection, 'request_available_workflows'); | ||
const requestHandler = new RequestAvailableWorkflowsHandler_1.RequestAvailableWorkflowsHandler(); | ||
const workflowsHandler = new AvailableWorkflowsHandler_1.AvailableWorkflowsHandler(availableChannel$, clientId); | ||
requestHandler.start(requestChannel); | ||
return workflowsHandler.getWorkflows().pipe((0, rxjs_1.shareReplay)(1)); | ||
const requestChannel = yield connection.createChannel(); | ||
return { | ||
workflows: workflowsHandler.getWorkflows().pipe((0, rxjs_1.shareReplay)(1)), | ||
trigger: () => requestChannel.sendToQueue('request_available_workflows', Buffer.from(new proto_1.RequestAvailableWorkflows().serializeBinary())) | ||
}; | ||
}); | ||
@@ -19,0 +20,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
34434
501