@hotmeshio/hotmesh 0.0.52 → 0.0.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -18
- package/build/index.d.ts +1 -2
- package/build/index.js +1 -3
- package/build/modules/enums.d.ts +8 -3
- package/build/modules/enums.js +16 -8
- package/build/modules/errors.d.ts +58 -20
- package/build/modules/errors.js +90 -33
- package/build/package.json +7 -2
- package/build/services/activities/activity.d.ts +8 -0
- package/build/services/activities/activity.js +63 -14
- package/build/services/activities/await.js +6 -6
- package/build/services/activities/cycle.d.ts +2 -2
- package/build/services/activities/cycle.js +5 -5
- package/build/services/activities/hook.js +9 -5
- package/build/services/activities/interrupt.d.ts +3 -3
- package/build/services/activities/interrupt.js +15 -6
- package/build/services/activities/signal.d.ts +2 -2
- package/build/services/activities/signal.js +4 -4
- package/build/services/activities/trigger.d.ts +5 -2
- package/build/services/activities/trigger.js +34 -4
- package/build/services/activities/worker.js +6 -6
- package/build/services/compiler/deployer.js +33 -5
- package/build/services/compiler/validator.d.ts +2 -0
- package/build/services/compiler/validator.js +5 -1
- package/build/services/durable/client.d.ts +7 -1
- package/build/services/durable/client.js +57 -38
- package/build/services/durable/exporter.d.ts +27 -81
- package/build/services/durable/exporter.js +153 -325
- package/build/services/durable/handle.d.ts +13 -8
- package/build/services/durable/handle.js +61 -48
- package/build/services/durable/index.d.ts +0 -2
- package/build/services/durable/index.js +0 -2
- package/build/services/durable/schemas/factory.d.ts +33 -0
- package/build/services/durable/schemas/factory.js +2356 -0
- package/build/services/durable/search.js +8 -8
- package/build/services/durable/worker.js +117 -25
- package/build/services/durable/workflow.d.ts +67 -52
- package/build/services/durable/workflow.js +322 -306
- package/build/services/engine/index.d.ts +2 -2
- package/build/services/engine/index.js +5 -2
- package/build/services/exporter/index.d.ts +2 -4
- package/build/services/exporter/index.js +4 -5
- package/build/services/hotmesh/index.d.ts +2 -2
- package/build/services/hotmesh/index.js +2 -2
- package/build/services/mapper/index.d.ts +6 -2
- package/build/services/mapper/index.js +6 -2
- package/build/services/pipe/functions/array.d.ts +2 -10
- package/build/services/pipe/functions/array.js +30 -28
- package/build/services/pipe/functions/conditional.d.ts +1 -0
- package/build/services/pipe/functions/conditional.js +3 -0
- package/build/services/pipe/functions/date.d.ts +1 -0
- package/build/services/pipe/functions/date.js +4 -0
- package/build/services/pipe/functions/index.d.ts +2 -0
- package/build/services/pipe/functions/index.js +2 -0
- package/build/services/pipe/functions/logical.d.ts +5 -0
- package/build/services/pipe/functions/logical.js +12 -0
- package/build/services/pipe/functions/object.d.ts +3 -0
- package/build/services/pipe/functions/object.js +25 -7
- package/build/services/pipe/index.d.ts +20 -3
- package/build/services/pipe/index.js +82 -16
- package/build/services/router/index.js +14 -3
- package/build/services/serializer/index.d.ts +3 -2
- package/build/services/serializer/index.js +11 -4
- package/build/services/store/clients/ioredis.js +6 -6
- package/build/services/store/clients/redis.js +7 -7
- package/build/services/store/index.d.ts +2 -0
- package/build/services/store/index.js +4 -1
- package/build/services/stream/clients/ioredis.js +8 -8
- package/build/services/stream/clients/redis.js +1 -1
- package/build/types/activity.d.ts +60 -5
- package/build/types/durable.d.ts +183 -36
- package/build/types/error.d.ts +48 -0
- package/build/types/error.js +2 -0
- package/build/types/exporter.d.ts +35 -7
- package/build/types/index.d.ts +4 -3
- package/build/types/job.d.ts +93 -6
- package/build/types/pipe.d.ts +81 -3
- package/build/types/stream.d.ts +61 -1
- package/build/types/stream.js +4 -0
- package/index.ts +1 -2
- package/modules/enums.ts +16 -8
- package/modules/errors.ts +139 -34
- package/package.json +7 -2
- package/services/activities/activity.ts +63 -14
- package/services/activities/await.ts +6 -6
- package/services/activities/cycle.ts +7 -6
- package/services/activities/hook.ts +12 -5
- package/services/activities/interrupt.ts +19 -9
- package/services/activities/signal.ts +6 -5
- package/services/activities/trigger.ts +43 -6
- package/services/activities/worker.ts +7 -7
- package/services/compiler/deployer.ts +33 -6
- package/services/compiler/validator.ts +7 -3
- package/services/durable/client.ts +49 -22
- package/services/durable/exporter.ts +162 -349
- package/services/durable/handle.ts +66 -53
- package/services/durable/index.ts +0 -2
- package/services/durable/schemas/factory.ts +2358 -0
- package/services/durable/search.ts +8 -8
- package/services/durable/worker.ts +128 -29
- package/services/durable/workflow.ts +371 -322
- package/services/engine/index.ts +8 -3
- package/services/exporter/index.ts +10 -12
- package/services/hotmesh/index.ts +4 -3
- package/services/mapper/index.ts +6 -2
- package/services/pipe/functions/array.ts +24 -37
- package/services/pipe/functions/conditional.ts +4 -0
- package/services/pipe/functions/date.ts +6 -0
- package/services/pipe/functions/index.ts +7 -5
- package/services/pipe/functions/logical.ts +11 -0
- package/services/pipe/functions/object.ts +26 -7
- package/services/pipe/index.ts +99 -21
- package/services/quorum/index.ts +1 -3
- package/services/router/index.ts +14 -3
- package/services/serializer/index.ts +12 -5
- package/services/store/clients/ioredis.ts +6 -6
- package/services/store/clients/redis.ts +7 -7
- package/services/store/index.ts +4 -1
- package/services/stream/clients/ioredis.ts +8 -8
- package/services/stream/clients/redis.ts +1 -1
- package/types/activity.ts +87 -15
- package/types/durable.ts +263 -75
- package/types/error.ts +52 -0
- package/types/exporter.ts +43 -9
- package/types/index.ts +14 -8
- package/types/job.ts +157 -36
- package/types/pipe.ts +84 -3
- package/types/stream.ts +82 -23
- package/build/services/durable/factory.d.ts +0 -17
- package/build/services/durable/factory.js +0 -817
- package/build/services/durable/meshos.d.ts +0 -127
- package/build/services/durable/meshos.js +0 -380
- package/services/durable/factory.ts +0 -818
- package/services/durable/meshos.ts +0 -441
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WorkflowHandleService = void 0;
|
|
4
|
-
const enums_1 = require("../../modules/enums");
|
|
5
4
|
const exporter_1 = require("./exporter");
|
|
6
5
|
class WorkflowHandleService {
|
|
7
6
|
constructor(hotMesh, workflowTopic, workflowId) {
|
|
@@ -10,14 +9,14 @@ class WorkflowHandleService {
|
|
|
10
9
|
this.hotMesh = hotMesh;
|
|
11
10
|
this.exporter = new exporter_1.ExporterService(this.hotMesh.appId, this.hotMesh.engine.store, this.hotMesh.engine.logger);
|
|
12
11
|
}
|
|
13
|
-
async export() {
|
|
14
|
-
return this.exporter.export(this.workflowId);
|
|
12
|
+
async export(options) {
|
|
13
|
+
return this.exporter.export(this.workflowId, options);
|
|
15
14
|
}
|
|
16
15
|
/**
|
|
17
16
|
* Sends a signal to the workflow. This is a way to send
|
|
18
17
|
* a message to a workflow that is paused due to having
|
|
19
|
-
* executed
|
|
20
|
-
*
|
|
18
|
+
* executed `Durable.workflow.waitFor`. The workflow
|
|
19
|
+
* will awaken if no other signals are pending.
|
|
21
20
|
*/
|
|
22
21
|
async signal(signalId, data) {
|
|
23
22
|
await this.hotMesh.hook(`${this.hotMesh.appId}.wfs.signal`, { id: signalId, data });
|
|
@@ -63,68 +62,82 @@ class WorkflowHandleService {
|
|
|
63
62
|
return await this.hotMesh.interrupt(`${this.hotMesh.appId}.execute`, this.workflowId, options);
|
|
64
63
|
}
|
|
65
64
|
/**
|
|
66
|
-
*
|
|
67
|
-
* the workflow
|
|
68
|
-
*
|
|
65
|
+
* Waits for the workflow to complete and returns the result. If
|
|
66
|
+
* the workflow response includes an error, this method will rethrow
|
|
67
|
+
* the error, including the stack trace if available.
|
|
68
|
+
* Wrap calls in a try/catch as necessary to avoid unhandled exceptions.
|
|
69
69
|
*/
|
|
70
|
-
async result(
|
|
71
|
-
if (loadState) {
|
|
72
|
-
const state = await this.hotMesh.getState(`${this.hotMesh.appId}.execute`, this.workflowId);
|
|
73
|
-
if (!state.data && state.metadata.err) {
|
|
74
|
-
throw new Error(JSON.parse(state.metadata.err));
|
|
75
|
-
}
|
|
76
|
-
if (state?.data?.done) {
|
|
77
|
-
//child flows are never 'done'; they use a hook
|
|
78
|
-
//that only closes upon parent flow completion.
|
|
79
|
-
return state.data.response;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
let status = await this.hotMesh.getStatus(this.workflowId);
|
|
70
|
+
async result(config) {
|
|
83
71
|
const topic = `${this.hotMesh.appId}.executed.${this.workflowId}`;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
72
|
+
let isResolved = false;
|
|
73
|
+
return new Promise(async (resolve, reject) => {
|
|
74
|
+
/**
|
|
75
|
+
* rejects/resolves the promise based on the `throwOnError`
|
|
76
|
+
* default behavior is to throw if error
|
|
77
|
+
*/
|
|
78
|
+
const safeReject = (err) => {
|
|
79
|
+
if (config?.throwOnError === false) {
|
|
80
|
+
return resolve(err);
|
|
81
|
+
}
|
|
82
|
+
reject(err);
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Common completion function that unsubscribes from the topic/returns
|
|
86
|
+
*/
|
|
87
87
|
const complete = async (response, err) => {
|
|
88
88
|
if (isResolved)
|
|
89
89
|
return;
|
|
90
90
|
isResolved = true;
|
|
91
|
-
this.hotMesh.unsub(topic);
|
|
92
91
|
if (err) {
|
|
93
|
-
return
|
|
92
|
+
return safeReject(err);
|
|
94
93
|
}
|
|
95
94
|
else if (!response) {
|
|
96
95
|
const state = await this.hotMesh.getState(`${this.hotMesh.appId}.execute`, this.workflowId);
|
|
97
|
-
if (state.
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
96
|
+
if (state.data?.done && !state.data?.$error) {
|
|
97
|
+
return resolve(state.data.response);
|
|
98
|
+
}
|
|
99
|
+
else if (state.data?.$error) {
|
|
100
|
+
return safeReject(state.data.$error);
|
|
101
|
+
}
|
|
102
|
+
else if (state.metadata.err) {
|
|
103
|
+
return safeReject(JSON.parse(state.metadata.err));
|
|
102
104
|
}
|
|
103
105
|
response = state.data?.response;
|
|
104
106
|
}
|
|
105
107
|
resolve(response);
|
|
106
108
|
};
|
|
107
|
-
//
|
|
108
|
-
if (
|
|
109
|
-
|
|
109
|
+
//more expensive; fetches the entire job, not just the `status`
|
|
110
|
+
if (config?.state) {
|
|
111
|
+
const state = await this.hotMesh.getState(`${this.hotMesh.appId}.execute`, this.workflowId);
|
|
112
|
+
if (state?.data?.done && !state.data?.$error) {
|
|
113
|
+
return complete(state.data.response);
|
|
114
|
+
}
|
|
115
|
+
else if (state.data?.$error) {
|
|
116
|
+
return complete(null, state.data.$error);
|
|
117
|
+
}
|
|
118
|
+
else if (state.metadata.err) {
|
|
119
|
+
return complete(null, JSON.parse(state.metadata.err));
|
|
120
|
+
}
|
|
110
121
|
}
|
|
111
|
-
//subscribe to topic
|
|
112
|
-
this.hotMesh.sub(topic, async (
|
|
113
|
-
|
|
122
|
+
//subscribe to 'done' topic
|
|
123
|
+
this.hotMesh.sub(topic, async (_topic, state) => {
|
|
124
|
+
this.hotMesh.unsub(topic);
|
|
125
|
+
if (state.data.done && !state.data?.$error) {
|
|
126
|
+
await complete(state.data?.response);
|
|
127
|
+
}
|
|
128
|
+
else if (state.data?.$error) {
|
|
129
|
+
return complete(null, state.data.$error);
|
|
130
|
+
}
|
|
131
|
+
else if (state.metadata.err) {
|
|
114
132
|
const error = JSON.parse(state.metadata.err);
|
|
115
|
-
|
|
116
|
-
return await complete(null, state.metadata.err);
|
|
117
|
-
}
|
|
133
|
+
return await complete(null, error);
|
|
118
134
|
}
|
|
119
|
-
await complete(state.data?.response);
|
|
120
135
|
});
|
|
121
|
-
//
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
}, 0);
|
|
136
|
+
//check state in case completed during wiring
|
|
137
|
+
const status = await this.hotMesh.getStatus(this.workflowId);
|
|
138
|
+
if (status <= 0) {
|
|
139
|
+
await complete();
|
|
140
|
+
}
|
|
128
141
|
});
|
|
129
142
|
}
|
|
130
143
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ClientService } from './client';
|
|
2
2
|
import { ConnectionService } from './connection';
|
|
3
|
-
import { MeshOSService } from './meshos';
|
|
4
3
|
import { Search } from './search';
|
|
5
4
|
import { WorkerService } from './worker';
|
|
6
5
|
import { WorkflowService } from './workflow';
|
|
@@ -9,7 +8,6 @@ export declare const Durable: {
|
|
|
9
8
|
Client: typeof ClientService;
|
|
10
9
|
Connection: typeof ConnectionService;
|
|
11
10
|
Search: typeof Search;
|
|
12
|
-
MeshOS: typeof MeshOSService;
|
|
13
11
|
Worker: typeof WorkerService;
|
|
14
12
|
workflow: typeof WorkflowService;
|
|
15
13
|
/**
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Durable = void 0;
|
|
4
4
|
const client_1 = require("./client");
|
|
5
5
|
const connection_1 = require("./connection");
|
|
6
|
-
const meshos_1 = require("./meshos");
|
|
7
6
|
const search_1 = require("./search");
|
|
8
7
|
const worker_1 = require("./worker");
|
|
9
8
|
const workflow_1 = require("./workflow");
|
|
@@ -12,7 +11,6 @@ exports.Durable = {
|
|
|
12
11
|
Client: client_1.ClientService,
|
|
13
12
|
Connection: connection_1.ConnectionService,
|
|
14
13
|
Search: search_1.Search,
|
|
15
|
-
MeshOS: meshos_1.MeshOSService,
|
|
16
14
|
Worker: worker_1.WorkerService,
|
|
17
15
|
workflow: workflow_1.WorkflowService,
|
|
18
16
|
/**
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*********** HOTMESH 'DURABLE' MODULE APPLICATION GRAPH **********
|
|
3
|
+
*
|
|
4
|
+
* This HotMesh application spec uses 50 activities and 25 transitions
|
|
5
|
+
* to model and emulate the Temporal Application & Query servers using
|
|
6
|
+
* Redis as the backend.
|
|
7
|
+
*
|
|
8
|
+
* It's particularly useful for organizations with high-speed, high-volume
|
|
9
|
+
* use cases as it uses in-memory Redis Streams for transactional,
|
|
10
|
+
* workflow processing, while adhering to Temporal's developer-friendly syntax.
|
|
11
|
+
*
|
|
12
|
+
* This YAML file can also serve as a useful starting point for building
|
|
13
|
+
* Integration/BPM/Workflow servers in general (MuleSoft, etc) without the need
|
|
14
|
+
* for a physical application server.
|
|
15
|
+
*
|
|
16
|
+
* Possible use cases include:
|
|
17
|
+
* * Orchestration servers
|
|
18
|
+
* * Integration servers
|
|
19
|
+
* * BPMN engines
|
|
20
|
+
* * Reentrant process servers
|
|
21
|
+
* * Service Meshes
|
|
22
|
+
* * Master Data Management systems
|
|
23
|
+
*/
|
|
24
|
+
declare const APP_VERSION = "1";
|
|
25
|
+
declare const APP_ID = "durable";
|
|
26
|
+
/**
|
|
27
|
+
* returns a new durable workflow schema
|
|
28
|
+
* @param {string} app - app name (e.g., 'durable')
|
|
29
|
+
* @param {string} version - number as string (e.g., '1')
|
|
30
|
+
* @returns {string} HotMesh App YAML
|
|
31
|
+
*/
|
|
32
|
+
declare const getWorkflowYAML: (app: string, version: string) => string;
|
|
33
|
+
export { getWorkflowYAML, APP_VERSION, APP_ID, };
|