@hotmeshio/hotmesh 0.13.0 → 0.14.0
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 +18 -22
- package/build/modules/enums.d.ts +60 -5
- package/build/modules/enums.js +62 -7
- package/build/modules/errors.d.ts +15 -3
- package/build/modules/errors.js +17 -2
- package/build/package.json +6 -1
- package/build/services/activities/activity/context.d.ts +22 -0
- package/build/services/activities/activity/context.js +76 -0
- package/build/services/activities/activity/index.d.ts +116 -0
- package/build/services/activities/activity/index.js +299 -0
- package/build/services/activities/activity/mapping.d.ts +12 -0
- package/build/services/activities/activity/mapping.js +63 -0
- package/build/services/activities/activity/process.d.ts +28 -0
- package/build/services/activities/activity/process.js +100 -0
- package/build/services/activities/activity/protocol.d.ts +39 -0
- package/build/services/activities/activity/protocol.js +151 -0
- package/build/services/activities/activity/state.d.ts +40 -0
- package/build/services/activities/activity/state.js +143 -0
- package/build/services/activities/activity/transition.d.ts +23 -0
- package/build/services/activities/activity/transition.js +71 -0
- package/build/services/activities/activity/verify.d.ts +22 -0
- package/build/services/activities/activity/verify.js +85 -0
- package/build/services/activities/await.d.ts +1 -4
- package/build/services/activities/await.js +2 -36
- package/build/services/activities/cycle.d.ts +1 -11
- package/build/services/activities/cycle.js +3 -46
- package/build/services/activities/hook.d.ts +2 -11
- package/build/services/activities/hook.js +30 -50
- package/build/services/activities/interrupt.d.ts +2 -4
- package/build/services/activities/interrupt.js +4 -38
- package/build/services/activities/signal.d.ts +1 -11
- package/build/services/activities/signal.js +3 -48
- package/build/services/activities/trigger.d.ts +1 -3
- package/build/services/activities/trigger.js +0 -3
- package/build/services/activities/worker.d.ts +3 -6
- package/build/services/activities/worker.js +4 -40
- package/build/services/connector/factory.d.ts +6 -0
- package/build/services/connector/factory.js +24 -0
- package/build/services/durable/activity.d.ts +1 -1
- package/build/services/durable/activity.js +2 -2
- package/build/services/durable/client.d.ts +24 -29
- package/build/services/durable/client.js +24 -29
- package/build/services/durable/connection.d.ts +13 -7
- package/build/services/durable/connection.js +13 -7
- package/build/services/durable/handle.d.ts +58 -40
- package/build/services/durable/handle.js +60 -40
- package/build/services/durable/index.d.ts +148 -286
- package/build/services/durable/index.js +157 -292
- package/build/services/durable/interceptor.d.ts +43 -33
- package/build/services/durable/interceptor.js +59 -39
- package/build/services/durable/schemas/factory.d.ts +1 -1
- package/build/services/durable/schemas/factory.js +168 -38
- package/build/services/durable/telemetry.d.ts +80 -0
- package/build/services/durable/telemetry.js +137 -0
- package/build/services/durable/worker.d.ts +100 -21
- package/build/services/durable/worker.js +304 -63
- package/build/services/durable/workflow/all.d.ts +1 -1
- package/build/services/durable/workflow/all.js +1 -1
- package/build/services/durable/workflow/cancellationScope.d.ts +104 -0
- package/build/services/durable/workflow/cancellationScope.js +139 -0
- package/build/services/durable/workflow/common.d.ts +5 -4
- package/build/services/durable/workflow/common.js +6 -1
- package/build/services/durable/workflow/{waitFor.d.ts → condition.d.ts} +9 -8
- package/build/services/durable/workflow/{waitFor.js → condition.js} +44 -11
- package/build/services/durable/workflow/continueAsNew.d.ts +65 -0
- package/build/services/durable/workflow/continueAsNew.js +92 -0
- package/build/services/durable/workflow/didRun.d.ts +1 -1
- package/build/services/durable/workflow/didRun.js +3 -3
- package/build/services/durable/workflow/enrich.d.ts +5 -0
- package/build/services/durable/workflow/enrich.js +5 -0
- package/build/services/durable/workflow/entityMethods.d.ts +7 -0
- package/build/services/durable/workflow/entityMethods.js +7 -0
- package/build/services/durable/workflow/execHook.js +3 -3
- package/build/services/durable/workflow/execHookBatch.js +2 -2
- package/build/services/durable/workflow/{execChild.d.ts → executeChild.d.ts} +4 -40
- package/build/services/durable/workflow/{execChild.js → executeChild.js} +36 -45
- package/build/services/durable/workflow/hook.d.ts +1 -1
- package/build/services/durable/workflow/hook.js +4 -3
- package/build/services/durable/workflow/index.d.ts +45 -50
- package/build/services/durable/workflow/index.js +46 -51
- package/build/services/durable/workflow/interruption.d.ts +7 -6
- package/build/services/durable/workflow/interruption.js +11 -7
- package/build/services/durable/workflow/patched.d.ts +72 -0
- package/build/services/durable/workflow/patched.js +110 -0
- package/build/services/durable/workflow/proxyActivities.d.ts +7 -7
- package/build/services/durable/workflow/proxyActivities.js +50 -15
- package/build/services/durable/workflow/searchMethods.d.ts +7 -0
- package/build/services/durable/workflow/searchMethods.js +7 -0
- package/build/services/durable/workflow/signal.d.ts +4 -4
- package/build/services/durable/workflow/signal.js +4 -4
- package/build/services/durable/workflow/{sleepFor.d.ts → sleep.d.ts} +7 -7
- package/build/services/durable/workflow/{sleepFor.js → sleep.js} +39 -10
- package/build/services/durable/workflow/terminate.d.ts +55 -0
- package/build/services/durable/workflow/{interrupt.js → terminate.js} +21 -21
- package/build/services/durable/workflow/trace.js +2 -2
- package/build/services/durable/workflow/uuid4.d.ts +14 -0
- package/build/services/durable/workflow/uuid4.js +39 -0
- package/build/services/durable/workflow/{context.d.ts → workflowInfo.d.ts} +5 -5
- package/build/services/durable/workflow/{context.js → workflowInfo.js} +7 -7
- package/build/services/engine/compiler.d.ts +19 -0
- package/build/services/engine/compiler.js +20 -0
- package/build/services/engine/completion.d.ts +46 -0
- package/build/services/engine/completion.js +145 -0
- package/build/services/engine/dispatch.d.ts +24 -0
- package/build/services/engine/dispatch.js +98 -0
- package/build/services/engine/index.d.ts +49 -81
- package/build/services/engine/index.js +175 -573
- package/build/services/engine/init.d.ts +42 -0
- package/build/services/engine/init.js +74 -0
- package/build/services/engine/pubsub.d.ts +50 -0
- package/build/services/engine/pubsub.js +118 -0
- package/build/services/engine/reporting.d.ts +20 -0
- package/build/services/engine/reporting.js +38 -0
- package/build/services/engine/schema.d.ts +23 -0
- package/build/services/engine/schema.js +62 -0
- package/build/services/engine/signal.d.ts +57 -0
- package/build/services/engine/signal.js +117 -0
- package/build/services/engine/state.d.ts +35 -0
- package/build/services/engine/state.js +61 -0
- package/build/services/engine/version.d.ts +31 -0
- package/build/services/engine/version.js +73 -0
- package/build/services/hotmesh/deployment.d.ts +21 -0
- package/build/services/hotmesh/deployment.js +25 -0
- package/build/services/hotmesh/index.d.ts +141 -532
- package/build/services/hotmesh/index.js +222 -673
- package/build/services/hotmesh/init.d.ts +42 -0
- package/build/services/hotmesh/init.js +93 -0
- package/build/services/hotmesh/jobs.d.ts +67 -0
- package/build/services/hotmesh/jobs.js +99 -0
- package/build/services/hotmesh/pubsub.d.ts +38 -0
- package/build/services/hotmesh/pubsub.js +54 -0
- package/build/services/hotmesh/quorum.d.ts +30 -0
- package/build/services/hotmesh/quorum.js +62 -0
- package/build/services/hotmesh/validation.d.ts +6 -0
- package/build/services/hotmesh/validation.js +28 -0
- package/build/services/quorum/index.js +1 -0
- package/build/services/router/consumption/index.d.ts +11 -5
- package/build/services/router/consumption/index.js +24 -17
- package/build/services/router/error-handling/index.d.ts +2 -2
- package/build/services/router/error-handling/index.js +14 -14
- package/build/services/router/index.d.ts +1 -1
- package/build/services/router/index.js +2 -2
- package/build/services/serializer/index.d.ts +22 -0
- package/build/services/serializer/index.js +39 -1
- package/build/services/store/index.d.ts +1 -0
- package/build/services/store/providers/postgres/exporter-sql.d.ts +2 -2
- package/build/services/store/providers/postgres/exporter-sql.js +4 -4
- package/build/services/store/providers/postgres/kvtables.js +7 -6
- package/build/services/store/providers/postgres/kvtypes/hash/basic.js +67 -52
- package/build/services/store/providers/postgres/kvtypes/hash/jsonb.js +87 -72
- package/build/services/store/providers/postgres/kvtypes/hash/udata.js +106 -79
- package/build/services/store/providers/postgres/kvtypes/hash/utils.d.ts +16 -0
- package/build/services/store/providers/postgres/kvtypes/hash/utils.js +29 -16
- package/build/services/store/providers/postgres/postgres.d.ts +1 -0
- package/build/services/store/providers/postgres/postgres.js +14 -4
- package/build/services/stream/factory.d.ts +3 -1
- package/build/services/stream/factory.js +2 -2
- package/build/services/stream/index.d.ts +1 -0
- package/build/services/stream/providers/nats/nats.d.ts +1 -0
- package/build/services/stream/providers/nats/nats.js +1 -0
- package/build/services/stream/providers/postgres/credentials.d.ts +56 -0
- package/build/services/stream/providers/postgres/credentials.js +129 -0
- package/build/services/stream/providers/postgres/kvtables.js +18 -0
- package/build/services/stream/providers/postgres/messages.js +7 -7
- package/build/services/stream/providers/postgres/notifications.js +16 -2
- package/build/services/stream/providers/postgres/postgres.d.ts +7 -0
- package/build/services/stream/providers/postgres/postgres.js +35 -4
- package/build/services/stream/providers/postgres/procedures.d.ts +21 -0
- package/build/services/stream/providers/postgres/procedures.js +213 -0
- package/build/services/stream/providers/postgres/secured.d.ts +34 -0
- package/build/services/stream/providers/postgres/secured.js +146 -0
- package/build/services/stream/providers/postgres/stats.d.ts +1 -0
- package/build/services/stream/providers/postgres/stats.js +1 -0
- package/build/services/stream/registry.d.ts +1 -1
- package/build/services/stream/registry.js +5 -2
- package/build/services/telemetry/index.d.ts +10 -1
- package/build/services/telemetry/index.js +40 -7
- package/build/services/worker/credentials.d.ts +51 -0
- package/build/services/worker/credentials.js +87 -0
- package/build/services/worker/index.d.ts +2 -2
- package/build/services/worker/index.js +7 -6
- package/build/types/codec.d.ts +84 -0
- package/build/types/codec.js +2 -0
- package/build/types/durable.d.ts +104 -28
- package/build/types/error.d.ts +10 -1
- package/build/types/hotmesh.d.ts +67 -4
- package/build/types/index.d.ts +2 -1
- package/build/types/provider.d.ts +2 -2
- package/build/types/quorum.d.ts +35 -1
- package/build/types/stream.d.ts +12 -6
- package/package.json +6 -1
- package/build/services/activities/activity.d.ts +0 -192
- package/build/services/activities/activity.js +0 -786
- package/build/services/durable/workflow/interrupt.d.ts +0 -55
|
@@ -3,28 +3,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.WorkflowHandleService = void 0;
|
|
4
4
|
const exporter_1 = require("./exporter");
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
* workflow.
|
|
8
|
-
* querying the state of the workflow. It is instanced/accessed via the
|
|
9
|
-
* Durable.Client class.
|
|
6
|
+
* Handle to a running or completed workflow execution. Returned by
|
|
7
|
+
* `client.workflow.start()` and `client.workflow.getHandle()`.
|
|
10
8
|
*
|
|
11
9
|
* @example
|
|
12
10
|
* ```typescript
|
|
13
|
-
* import { Client } from '@hotmeshio/hotmesh';
|
|
14
|
-
* import { Client as Postgres } from 'pg';
|
|
15
|
-
*
|
|
16
|
-
* const client = new Client({ connection: {
|
|
17
|
-
* class: Postgres,
|
|
18
|
-
* options: { connectionString: 'postgres://user:pass@localhost:5432/db' }
|
|
19
|
-
* }});
|
|
20
|
-
*
|
|
21
11
|
* const handle = await client.workflow.start({
|
|
22
|
-
*
|
|
23
|
-
*
|
|
12
|
+
* args: ['order-123'],
|
|
13
|
+
* taskQueue: 'orders',
|
|
14
|
+
* workflowName: 'orderWorkflow',
|
|
15
|
+
* workflowId: Durable.guid(),
|
|
24
16
|
* });
|
|
25
17
|
*
|
|
26
|
-
* //
|
|
27
|
-
* await handle.
|
|
18
|
+
* // Await the final result
|
|
19
|
+
* const result = await handle.result();
|
|
20
|
+
*
|
|
21
|
+
* // Or interact while running
|
|
22
|
+
* await handle.signal('approval', { approved: true });
|
|
23
|
+
* await handle.cancel();
|
|
28
24
|
* ```
|
|
29
25
|
*/
|
|
30
26
|
class WorkflowHandleService {
|
|
@@ -38,7 +34,8 @@ class WorkflowHandleService {
|
|
|
38
34
|
this.exporter = new exporter_1.ExporterService(this.hotMesh.appId, this.hotMesh.engine.store, this.hotMesh.engine.logger);
|
|
39
35
|
}
|
|
40
36
|
/**
|
|
41
|
-
* Exports the workflow state
|
|
37
|
+
* Exports the full workflow state (job hash, metadata, activity
|
|
38
|
+
* results) as a JSON object.
|
|
42
39
|
*/
|
|
43
40
|
async export(options) {
|
|
44
41
|
return this.exporter.export(this.workflowId, options);
|
|
@@ -57,10 +54,12 @@ class WorkflowHandleService {
|
|
|
57
54
|
return this.exporter.exportExecution(this.workflowId, this.workflowTopic, options);
|
|
58
55
|
}
|
|
59
56
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
57
|
+
* Delivers a named signal to the workflow. If the workflow is paused
|
|
58
|
+
* on `Durable.workflow.condition(signalId)`, it resumes with the
|
|
59
|
+
* provided data.
|
|
60
|
+
*
|
|
61
|
+
* @param signalId - Matches the `signalId` passed to `condition()`.
|
|
62
|
+
* @param data - Payload delivered to the waiting workflow.
|
|
64
63
|
*/
|
|
65
64
|
async signal(signalId, data) {
|
|
66
65
|
await this.hotMesh.signal(`${this.hotMesh.appId}.wfs.signal`, {
|
|
@@ -69,10 +68,12 @@ class WorkflowHandleService {
|
|
|
69
68
|
});
|
|
70
69
|
}
|
|
71
70
|
/**
|
|
72
|
-
* Returns the
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
71
|
+
* Returns the current workflow state. For a completed workflow this
|
|
72
|
+
* is the final output; for a running workflow it reflects the latest
|
|
73
|
+
* persisted state (may change as activities complete).
|
|
74
|
+
*
|
|
75
|
+
* @param metadata - If `true`, returns the full job envelope including
|
|
76
|
+
* internal metadata alongside the data.
|
|
76
77
|
*/
|
|
77
78
|
async state(metadata = false) {
|
|
78
79
|
const state = await this.hotMesh.getState(`${this.hotMesh.appId}.execute`, this.workflowId);
|
|
@@ -82,35 +83,54 @@ class WorkflowHandleService {
|
|
|
82
83
|
return metadata ? state : state.data;
|
|
83
84
|
}
|
|
84
85
|
/**
|
|
85
|
-
* Returns
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* to
|
|
86
|
+
* Returns key-value pairs previously written via
|
|
87
|
+
* `Durable.workflow.search()` or `Durable.workflow.enrich()`.
|
|
88
|
+
*
|
|
89
|
+
* @param fields - The field names to retrieve.
|
|
89
90
|
*/
|
|
90
91
|
async queryState(fields) {
|
|
91
92
|
return await this.hotMesh.getQueryState(this.workflowId, fields);
|
|
92
93
|
}
|
|
93
94
|
/**
|
|
94
|
-
* Returns the
|
|
95
|
-
*
|
|
96
|
-
* 0 is complete and a negative value represents that the flow was
|
|
97
|
-
* interrupted.
|
|
95
|
+
* Returns the workflow's numeric status code: `0` = completed,
|
|
96
|
+
* positive = still running, negative = interrupted/errored.
|
|
98
97
|
*/
|
|
99
98
|
async status() {
|
|
100
99
|
return await this.hotMesh.getStatus(this.workflowId);
|
|
101
100
|
}
|
|
102
101
|
/**
|
|
103
|
-
*
|
|
104
|
-
*
|
|
102
|
+
* Immediately terminates the workflow. The job is marked as interrupted,
|
|
103
|
+
* subscribers are notified, and the job hash is expired. Unlike
|
|
104
|
+
* {@link cancel}, this does **not** give the workflow a chance to
|
|
105
|
+
* run cleanup code.
|
|
105
106
|
*/
|
|
106
|
-
async
|
|
107
|
+
async terminate(options) {
|
|
107
108
|
return await this.hotMesh.interrupt(`${this.hotMesh.appId}.execute`, this.workflowId, options);
|
|
108
109
|
}
|
|
109
110
|
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
111
|
+
* Requests cooperative cancellation of the workflow. Unlike
|
|
112
|
+
* `terminate()` (which terminates immediately), `cancel()` sets
|
|
113
|
+
* a durable flag that the workflow detects at its next durable
|
|
114
|
+
* operation (`sleep`, `proxyActivities`, `executeChild`, etc.).
|
|
115
|
+
* The workflow receives a `CancelledFailure` error that it can
|
|
116
|
+
* catch to perform cleanup before exiting.
|
|
117
|
+
*
|
|
118
|
+
* ```typescript
|
|
119
|
+
* const handle = await client.workflow.start({ ... });
|
|
120
|
+
* await handle.cancel();
|
|
121
|
+
* // Workflow will throw CancelledFailure at its next durable operation
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
async cancel() {
|
|
125
|
+
await this.hotMesh.cancel(this.workflowId);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Blocks until the workflow completes and returns the result. If the
|
|
129
|
+
* workflow failed, the error is rethrown (with stack trace) unless
|
|
130
|
+
* `throwOnError: false` is set, in which case the error object is
|
|
131
|
+
* returned directly.
|
|
132
|
+
*
|
|
133
|
+
* @template T - The workflow's return type.
|
|
114
134
|
*/
|
|
115
135
|
async result(config) {
|
|
116
136
|
const topic = `${this.hotMesh.appId}.executed.${this.workflowId}`;
|