@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
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import { EngineService } from '../engine';
|
|
2
|
-
import { ILogger } from '../logger';
|
|
3
|
-
import { StoreService } from '../store';
|
|
4
|
-
import { ActivityData, ActivityLeg, ActivityMetadata, ActivityType } from '../../types/activity';
|
|
5
|
-
import { ProviderClient, ProviderTransaction, TransactionResultList } from '../../types/provider';
|
|
6
|
-
import { JobState, JobStatus } from '../../types/job';
|
|
7
|
-
import { StringAnyType } from '../../types/serializer';
|
|
8
|
-
import { StreamCode, StreamData, StreamStatus } from '../../types/stream';
|
|
9
|
-
/**
|
|
10
|
-
* Base class for all HotMesh activity types. Activities are the execution
|
|
11
|
-
* units within a YAML-defined workflow graph. Each activity represents a
|
|
12
|
-
* node in a Directed Acyclic Graph (DAG) that the engine orchestrates.
|
|
13
|
-
*
|
|
14
|
-
* ## Activity Categories
|
|
15
|
-
*
|
|
16
|
-
* Activities fall into three execution categories:
|
|
17
|
-
*
|
|
18
|
-
* - **Category A (Duplex)**: Two-phase activities with Leg 1 (dispatch) and
|
|
19
|
-
* Leg 2 (response). Used by `Worker` and `Await`. Leg 1
|
|
20
|
-
* publishes a message and waits; Leg 2 handles the response via
|
|
21
|
-
* `processEvent` and transitions to adjacent activities.
|
|
22
|
-
*
|
|
23
|
-
* - **Category B (Leg1-only with children)**: Single-phase activities that
|
|
24
|
-
* execute work and transition to children using the crash-safe
|
|
25
|
-
* `executeLeg1StepProtocol`. Used by `Hook` (passthrough mode),
|
|
26
|
-
* `Signal`, and `Interrupt` (target mode).
|
|
27
|
-
*
|
|
28
|
-
* - **Category C (Leg1-only, no children)**: Terminal activities that
|
|
29
|
-
* execute without spawning children. Used by `Interrupt` (self mode).
|
|
30
|
-
*
|
|
31
|
-
* ## Shared YAML Configuration
|
|
32
|
-
*
|
|
33
|
-
* All activity types support these base properties in the YAML descriptor:
|
|
34
|
-
*
|
|
35
|
-
* | Property | Type | Description |
|
|
36
|
-
* |----------------------|---------|-------------|
|
|
37
|
-
* | `type` | string | Activity type: `trigger`, `worker`, `await`, `hook`, `signal`, `interrupt`, `cycle` |
|
|
38
|
-
* | `title` | string | Human-readable label for the activity |
|
|
39
|
-
* | `input.schema` | object | JSON Schema for input validation |
|
|
40
|
-
* | `input.maps` | object | Maps data from other activities into this activity's input |
|
|
41
|
-
* | `output.schema` | object | JSON Schema for output validation |
|
|
42
|
-
* | `output.maps` | object | Maps/transforms the activity's own output data |
|
|
43
|
-
* | `job.maps` | object | Maps activity data to the shared job state |
|
|
44
|
-
* | `emit` | boolean | If `true`, emits a message to the graph's `publishes` topic |
|
|
45
|
-
* | `persist` | boolean | If `true`, emits the job-completed event while keeping the job active |
|
|
46
|
-
* | `expire` | number | Seconds until the job expires after completion (`-1` = forever) |
|
|
47
|
-
* | `statusThreshold` | number | Custom semaphore threshold for Dynamic Activation Control |
|
|
48
|
-
* | `cycle` | boolean | If `true`, leaves Leg 2 open so the activity can be re-entered |
|
|
49
|
-
*
|
|
50
|
-
* ## Data Mapping Syntax
|
|
51
|
-
*
|
|
52
|
-
* Mapping expressions use curly-brace references to bind data between
|
|
53
|
-
* activities and the shared job state:
|
|
54
|
-
*
|
|
55
|
-
* ```yaml
|
|
56
|
-
* input:
|
|
57
|
-
* maps:
|
|
58
|
-
* x: '{t1.output.data.fieldName}' # reference another activity's output
|
|
59
|
-
* y: '{$self.output.data.fieldName}' # reference own output
|
|
60
|
-
* z: '{$job.data.fieldName}' # reference shared job state
|
|
61
|
-
* s: '{$app.settings.configKey}' # reference app-level settings
|
|
62
|
-
* ```
|
|
63
|
-
*
|
|
64
|
-
* @see {@link https://hotmeshio.github.io/sdk-typescript/docs/quickstart | Quick Start Guide}
|
|
65
|
-
* @see [Model Driven Development](https://hotmeshio.github.io/sdk-typescript/docs/model_driven_development)
|
|
66
|
-
*/
|
|
67
|
-
declare class Activity {
|
|
68
|
-
config: ActivityType;
|
|
69
|
-
data: ActivityData;
|
|
70
|
-
hook: ActivityData;
|
|
71
|
-
metadata: ActivityMetadata;
|
|
72
|
-
/** @hidden */
|
|
73
|
-
store: StoreService<ProviderClient, ProviderTransaction>;
|
|
74
|
-
context: JobState;
|
|
75
|
-
engine: EngineService;
|
|
76
|
-
logger: ILogger;
|
|
77
|
-
status: StreamStatus;
|
|
78
|
-
code: StreamCode;
|
|
79
|
-
leg: ActivityLeg;
|
|
80
|
-
adjacencyList: StreamData[];
|
|
81
|
-
adjacentIndex: number;
|
|
82
|
-
guidLedger: number;
|
|
83
|
-
constructor(config: ActivityType, data: ActivityData, metadata: ActivityMetadata, hook: ActivityData | null, engine: EngineService, context?: JobState);
|
|
84
|
-
setLeg(leg: ActivityLeg): void;
|
|
85
|
-
/**
|
|
86
|
-
* A job is assumed to be complete when its status (a semaphore)
|
|
87
|
-
* reaches `0`. A different threshold can be set in the
|
|
88
|
-
* activity YAML, in support of Dynamic Activation Control.
|
|
89
|
-
*/
|
|
90
|
-
mapStatusThreshold(): number;
|
|
91
|
-
/**
|
|
92
|
-
* Upon entering leg 1 of a duplexed activity
|
|
93
|
-
*/
|
|
94
|
-
verifyEntry(): Promise<void>;
|
|
95
|
-
/**
|
|
96
|
-
* Upon entering leg 2 of a duplexed activity.
|
|
97
|
-
* Increments both the activity ledger (+1) and GUID ledger (+1).
|
|
98
|
-
* Stores the GUID ledger value for step-level resume decisions.
|
|
99
|
-
*/
|
|
100
|
-
verifyReentry(): Promise<number>;
|
|
101
|
-
processEvent(status?: StreamStatus, code?: StreamCode, type?: 'hook' | 'output'): Promise<void>;
|
|
102
|
-
/**
|
|
103
|
-
* Executes the 3-step Leg2 protocol using GUID ledger for
|
|
104
|
-
* crash-safe resume. Each step bundles durable writes with
|
|
105
|
-
* its concluding digit update in a single transaction.
|
|
106
|
-
*
|
|
107
|
-
* @returns true if this transition caused the job to complete
|
|
108
|
-
*/
|
|
109
|
-
executeStepProtocol(delta: number, shouldFinalize: boolean): Promise<boolean>;
|
|
110
|
-
/**
|
|
111
|
-
* Extracts the thresholdHit value from transaction results.
|
|
112
|
-
* The setStatusAndCollateGuid result is the last item.
|
|
113
|
-
*/
|
|
114
|
-
resolveThresholdHit(results: TransactionResultList): boolean;
|
|
115
|
-
/**
|
|
116
|
-
* Extracts the job status from the last result of a transaction.
|
|
117
|
-
* Used by subclass Leg1 process methods for telemetry.
|
|
118
|
-
*/
|
|
119
|
-
resolveStatus(multiResponse: TransactionResultList): number;
|
|
120
|
-
/**
|
|
121
|
-
* Leg1 entry verification for Category B activities (Leg1-only with children).
|
|
122
|
-
* Returns true if this is a resume (Leg1 already completed on a prior attempt).
|
|
123
|
-
* On resume, loads the GUID ledger for step-level resume decisions.
|
|
124
|
-
*/
|
|
125
|
-
verifyLeg1Entry(): Promise<boolean>;
|
|
126
|
-
/**
|
|
127
|
-
* Executes the 3-step Leg1 protocol for Category B activities
|
|
128
|
-
* (Leg1-only with children, e.g., Hook passthrough, Signal, Interrupt-another).
|
|
129
|
-
* Uses the incoming Leg1 message GUID as the GUID ledger key.
|
|
130
|
-
*
|
|
131
|
-
* Step A: setState + notarizeLeg1Completion + step1 markers (transaction 1)
|
|
132
|
-
* Step B: publish children + step2 markers + setStatusAndCollateGuid (transaction 2)
|
|
133
|
-
* Step C: if edge → runJobCompletionTasks + step3 markers + finalize (transaction 3)
|
|
134
|
-
*
|
|
135
|
-
* @returns true if this transition caused the job to complete
|
|
136
|
-
*/
|
|
137
|
-
executeLeg1StepProtocol(delta: number): Promise<boolean>;
|
|
138
|
-
mapJobData(): void;
|
|
139
|
-
mapInputData(): void;
|
|
140
|
-
mapOutputData(): void;
|
|
141
|
-
registerTimeout(): Promise<void>;
|
|
142
|
-
/**
|
|
143
|
-
* Any StreamMessage with a status of ERROR is bound to the activity
|
|
144
|
-
*/
|
|
145
|
-
bindActivityError(data: Record<string, unknown>): void;
|
|
146
|
-
/**
|
|
147
|
-
* unhandled activity errors (activities that return an ERROR StreamMessage
|
|
148
|
-
* status and have no adjacent children to transition to) are bound to the job
|
|
149
|
-
*/
|
|
150
|
-
bindJobError(data: Record<string, unknown>): void;
|
|
151
|
-
getTriggerConfig(): Promise<ActivityType>;
|
|
152
|
-
getJobStatus(): null | number;
|
|
153
|
-
setStatus(amount: number, transaction?: ProviderTransaction): Promise<void | any>;
|
|
154
|
-
authorizeEntry(_state: StringAnyType): string[];
|
|
155
|
-
bindDimensionalAddress(state: StringAnyType): void;
|
|
156
|
-
setState(transaction?: ProviderTransaction): Promise<string>;
|
|
157
|
-
bindJobMetadata(): void;
|
|
158
|
-
bindActivityMetadata(): void;
|
|
159
|
-
bindJobState(state: StringAnyType): Promise<void>;
|
|
160
|
-
bindActivityState(state: StringAnyType): void;
|
|
161
|
-
bindJobMetadataPaths(): string[];
|
|
162
|
-
bindActivityMetadataPaths(): string[];
|
|
163
|
-
getState(): Promise<void>;
|
|
164
|
-
/**
|
|
165
|
-
* if the job is created/deleted/created with the same key,
|
|
166
|
-
* the 'gid' ensures no stale messages (such as sleep delays)
|
|
167
|
-
* enter the workstream. Any message with a mismatched gid
|
|
168
|
-
* belongs to a prior job and can safely be ignored/dropped.
|
|
169
|
-
*/
|
|
170
|
-
assertGenerationalId(jobGID: string, msgGID?: string): void;
|
|
171
|
-
initDimensionalAddress(dad: string): void;
|
|
172
|
-
initSelf(context: StringAnyType): JobState;
|
|
173
|
-
initPolicies(context: JobState): void;
|
|
174
|
-
bindActivityData(type: 'output' | 'hook'): void;
|
|
175
|
-
resolveDad(): string;
|
|
176
|
-
resolveAdjacentDad(): string;
|
|
177
|
-
filterAdjacent(): Promise<StreamData[]>;
|
|
178
|
-
isJobComplete(jobStatus: JobStatus): boolean;
|
|
179
|
-
shouldEmit(): boolean;
|
|
180
|
-
/**
|
|
181
|
-
* emits the job completed event while leaving the job active, allowing
|
|
182
|
-
* a `main` thread to exit while other threads continue to run.
|
|
183
|
-
* @private
|
|
184
|
-
*/
|
|
185
|
-
shouldPersistJob(): boolean;
|
|
186
|
-
/**
|
|
187
|
-
* A job with a vale < -100_000_000 is considered interrupted,
|
|
188
|
-
* as the interruption event decrements the job status by 1billion.
|
|
189
|
-
*/
|
|
190
|
-
jobWasInterrupted(jobStatus: JobStatus): boolean;
|
|
191
|
-
}
|
|
192
|
-
export { Activity, ActivityType };
|