@voltro/workflow 0.84.0 → 0.85.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/CHANGELOG.md +549 -0
- package/THIRD-PARTY-NOTICES.md +1 -119
- package/dist/cluster-F_bhqVP7.js +679 -0
- package/dist/cluster.d.ts +304 -280
- package/dist/cluster.js +2 -2
- package/dist/clusterTestSuite.d.ts +11 -11
- package/dist/clusterTestSuite.js +256 -256
- package/dist/index.d.ts +376 -354
- package/dist/index.js +5 -5
- package/dist/journalEncryption-DTyhUzaS.js +154 -0
- package/dist/{primitives-Btjhjm8P.js → primitives-DX04WTWh.js} +223 -199
- package/dist/primitives.d.ts +56 -31
- package/dist/primitives.js +2 -2
- package/dist/{src-DP-lKqaG.js → src-C2NEyUM8.js} +1111 -1053
- package/dist/{clusterDiagnostics-CGUtnJkX.js → workflowReadSelections-CZAUjP7f.js} +58 -46
- package/package.json +6 -9
- package/dist/cluster-i3frC3Da.js +0 -646
- package/dist/journalEncryption--n5VDdYO.js +0 -148
package/dist/primitives.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { Context } from 'effect';
|
|
2
|
+
import { DurableClock as durableClock } from 'effect/workflow';
|
|
3
|
+
import { DurableQueue as durableQueueModule } from 'effect/workflow';
|
|
4
4
|
import { Duration } from 'effect';
|
|
5
5
|
import { Effect } from 'effect';
|
|
6
|
-
import {
|
|
6
|
+
import { RateLimiter } from 'effect/persistence';
|
|
7
7
|
import { Schema } from 'effect';
|
|
8
|
-
import { Activity as stepModule } from '
|
|
8
|
+
import { Activity as stepModule } from 'effect/workflow';
|
|
9
9
|
import { WorkflowAccessOptions } from '@voltro/protocol';
|
|
10
|
-
import {
|
|
10
|
+
import { WorkflowEngine } from 'effect/workflow';
|
|
11
|
+
import { Workflow as workflowModule } from 'effect/workflow';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Assert every workflow sharing a `concurrency.pool` declares the SAME limit.
|
|
@@ -34,7 +35,7 @@ export declare const assertConsistentPools: (controls: ReadonlyArray<ResolvedFlo
|
|
|
34
35
|
* whose row already exists). A first entry has no prior shape, so the whole
|
|
35
36
|
* mechanism costs one `FiberRef` read per step and nothing else.
|
|
36
37
|
*/
|
|
37
|
-
export declare const CurrentWorkflowReplayShape:
|
|
38
|
+
export declare const CurrentWorkflowReplayShape: Context.Reference<ReplayShapeTracker | undefined>;
|
|
38
39
|
|
|
39
40
|
/** The DECODED payload type. Mirrors `Workflow.make`'s own `idempotencyKey`
|
|
40
41
|
* parameter, so the two never disagree about what a payload is. */
|
|
@@ -65,18 +66,16 @@ export declare const deferringControlsOf: (control: ResolvedFlowControl | undefi
|
|
|
65
66
|
export { durableClock }
|
|
66
67
|
|
|
67
68
|
/** Define a durable queue for concurrency-controlled side work. */
|
|
68
|
-
export declare const durableQueue: typeof
|
|
69
|
+
export declare const durableQueue: <Payload extends Schema.Top | Schema.Struct.Fields, Success extends Schema.Top = typeof Schema.Void, Error extends Schema.Top = typeof Schema.Never>(options: Parameters<typeof durableQueueModule.make<Payload, Success, Error>>[0] & {
|
|
69
70
|
readonly encrypted?: boolean;
|
|
70
|
-
}
|
|
71
|
+
}) => ReturnType<typeof durableQueueModule.make<Payload, Success, Error>>;
|
|
71
72
|
|
|
72
73
|
export { durableQueueModule }
|
|
73
74
|
|
|
74
|
-
export { durableRateLimiterModule }
|
|
75
|
-
|
|
76
75
|
/** A duration in any shape Effect accepts: `'15 minutes'`, `900_000`,
|
|
77
76
|
* `Duration.minutes(15)`. Same input type `sleep({ duration })` takes, so
|
|
78
77
|
* there is one duration vocabulary in the whole workflow surface. */
|
|
79
|
-
export declare type FlowDuration = Duration.
|
|
78
|
+
export declare type FlowDuration = Duration.Input;
|
|
80
79
|
|
|
81
80
|
/** The resolved flow-control declaration attached to a workflow definition, or
|
|
82
81
|
* `undefined` when it declares none — in which case every start takes exactly
|
|
@@ -102,6 +101,10 @@ export declare const hasCancelOn: (control: ResolvedFlowControl | undefined) =>
|
|
|
102
101
|
* two writes per start for a decision that is always "admit". */
|
|
103
102
|
export declare const hasFlowControl: (control: ResolvedFlowControl | undefined) => boolean;
|
|
104
103
|
|
|
104
|
+
/** A value that can carry definition metadata: a workflow definition is a
|
|
105
|
+
* callable in v4 (`Workflow.make` returns a function), a queue is an object. */
|
|
106
|
+
export declare const isCarrier: (value: unknown) => value is object;
|
|
107
|
+
|
|
105
108
|
export declare const isWorkflowWorkerLayer: (value: unknown) => value is WorkflowWorkerLayerBrand;
|
|
106
109
|
|
|
107
110
|
/**
|
|
@@ -135,7 +138,7 @@ export declare type NondeterminismKind = 'unreached-step' | 'extra-step-occurren
|
|
|
135
138
|
declare type NormaliseWorkflowMessages<M extends WorkflowMessageSchemas | undefined> = {
|
|
136
139
|
readonly signals: M extends {
|
|
137
140
|
readonly signals: infer Signals;
|
|
138
|
-
} ? NonNullable<Signals> & Readonly<Record<string, Schema.
|
|
141
|
+
} ? NonNullable<Signals> & Readonly<Record<string, Schema.Top>> : {};
|
|
139
142
|
readonly updates: M extends {
|
|
140
143
|
readonly updates: infer Updates;
|
|
141
144
|
} ? NonNullable<Updates> & Readonly<Record<string, WorkflowMessagePairSchemas>> : {};
|
|
@@ -176,7 +179,7 @@ declare type NormaliseWorkflowMessages<M extends WorkflowMessageSchemas | undefi
|
|
|
176
179
|
* however many times it replays and whatever the deployed code says — which is
|
|
177
180
|
* the property that makes the branch deterministic across a redeploy.
|
|
178
181
|
*
|
|
179
|
-
* Under
|
|
182
|
+
* Under `effect/workflow` the naive implementation does the opposite: an
|
|
180
183
|
* activity that is ABSENT from an old run's journal EXECUTES on replay (the
|
|
181
184
|
* journal is keyed name/attempt), so a marker journaled by an activity would
|
|
182
185
|
* answer `true` for exactly the old runs it must answer `false` for. Reading
|
|
@@ -214,8 +217,26 @@ export declare const processQueue: typeof durableQueueModule.process;
|
|
|
214
217
|
* inferred type) is what emits in the `.d.ts`, so it stays portable. */
|
|
215
218
|
export declare const queueWorker: typeof durableQueueModule.worker;
|
|
216
219
|
|
|
217
|
-
/**
|
|
218
|
-
|
|
220
|
+
/**
|
|
221
|
+
* Durable rate limit. Consumes from the shared limiter; when the window is
|
|
222
|
+
* exhausted the wait is a durable clock sleep under `name`, so a deploy or a
|
|
223
|
+
* worker crash does not lose the delay and a replay does not consume twice.
|
|
224
|
+
*/
|
|
225
|
+
export declare const rateLimit: (options: RateLimitOptions) => Effect.Effect<void, RateLimiter.RateLimiterError, RateLimiter.RateLimiter | WorkflowEngine.WorkflowEngine | WorkflowEngine.WorkflowInstance>;
|
|
226
|
+
|
|
227
|
+
/** What `rateLimit` admits: one unit of work under `limit` per `window` for
|
|
228
|
+
* `key`, counted by the `RateLimiter` service the boot provides. */
|
|
229
|
+
export declare interface RateLimitOptions {
|
|
230
|
+
/** Names this ADMISSION within the run: the decision is journaled under it, so a
|
|
231
|
+
* replay reads it back instead of consuming again. Two calls with the same name
|
|
232
|
+
* in one run share one decision — give each call its own (`send/${i}` in a loop). */
|
|
233
|
+
readonly name: string;
|
|
234
|
+
readonly window: Duration.Input;
|
|
235
|
+
readonly limit: number;
|
|
236
|
+
readonly key: string;
|
|
237
|
+
readonly algorithm?: 'fixed-window' | 'token-bucket' | undefined;
|
|
238
|
+
readonly tokens?: number | undefined;
|
|
239
|
+
}
|
|
219
240
|
|
|
220
241
|
/** The slice of a `_voltro_workflow_run_steps` row this needs. */
|
|
221
242
|
export declare interface RecordedStepShape {
|
|
@@ -256,7 +277,7 @@ export declare const reportNondeterminism: (findings: ReadonlyArray<Nondetermini
|
|
|
256
277
|
* event at all". */
|
|
257
278
|
export declare interface ResolvedCancelOn {
|
|
258
279
|
readonly event: string;
|
|
259
|
-
readonly schema: Schema.
|
|
280
|
+
readonly schema: Schema.Top;
|
|
260
281
|
readonly match: (event: unknown, payload: unknown) => boolean;
|
|
261
282
|
readonly withinMs?: number;
|
|
262
283
|
readonly reason: string;
|
|
@@ -370,7 +391,7 @@ export declare const sleepUntil: (options: {
|
|
|
370
391
|
readonly until: Date | number;
|
|
371
392
|
}) => Effect.Effect<void, never, never>;
|
|
372
393
|
|
|
373
|
-
export declare const step: <R, Success extends Schema.
|
|
394
|
+
export declare const step: <R, Success extends Schema.Top = typeof Schema.Void, Error extends Schema.Top = typeof Schema.Never>(options: StepOptions<R, Success, Error>) => ReturnType<typeof stepModule.make<R, Success, Error>>;
|
|
374
395
|
|
|
375
396
|
/**
|
|
376
397
|
* Derive a deterministic idempotency key for the current workflow run,
|
|
@@ -389,7 +410,7 @@ export { stepModule }
|
|
|
389
410
|
/**
|
|
390
411
|
* Define a checkpointed step (activity) inside a workflow body.
|
|
391
412
|
*
|
|
392
|
-
* Wraps
|
|
413
|
+
* Wraps `effect/workflow`'s `Activity.make` to record every
|
|
393
414
|
* invocation in `_voltro_workflow_run_steps`. The wrapping is
|
|
394
415
|
* transparent — accepts everything `Activity.make` accepts, plus an
|
|
395
416
|
* optional `input` field whose value is persisted to the step row
|
|
@@ -408,7 +429,7 @@ export { stepModule }
|
|
|
408
429
|
* Without the recorder service in scope (unit tests, etc.) the input
|
|
409
430
|
* is dropped and the wrap is a no-op.
|
|
410
431
|
*/
|
|
411
|
-
declare type StepOptions<R, Success extends Schema.
|
|
432
|
+
declare type StepOptions<R, Success extends Schema.Top, Error extends Schema.Top> = {
|
|
412
433
|
readonly name: string;
|
|
413
434
|
readonly success?: Success | undefined;
|
|
414
435
|
readonly error?: Error | undefined;
|
|
@@ -518,7 +539,9 @@ export declare const withCompensation: typeof workflowModule.withCompensation;
|
|
|
518
539
|
|
|
519
540
|
export declare const workflow: WorkflowFn;
|
|
520
541
|
|
|
521
|
-
declare type WorkflowBaseOptions = Parameters<WorkflowMake>[
|
|
542
|
+
declare type WorkflowBaseOptions = Parameters<WorkflowMake>[1] & {
|
|
543
|
+
readonly name: Parameters<WorkflowMake>[0];
|
|
544
|
+
};
|
|
522
545
|
|
|
523
546
|
/**
|
|
524
547
|
* Collect many starts into ONE run over an array of items.
|
|
@@ -577,7 +600,7 @@ export declare interface WorkflowBatch<Item> {
|
|
|
577
600
|
* }],
|
|
578
601
|
* ```
|
|
579
602
|
*/
|
|
580
|
-
export declare interface WorkflowCancelOn<EventSchema extends Schema.
|
|
603
|
+
export declare interface WorkflowCancelOn<EventSchema extends Schema.Top, Payload> {
|
|
581
604
|
/** The event NAME, exactly as `ctx.events.publish` writes it. */
|
|
582
605
|
readonly event: string;
|
|
583
606
|
/** Decoded before `match` sees it, so the predicate reads the domain type
|
|
@@ -611,7 +634,7 @@ export declare interface WorkflowCancelOn<EventSchema extends Schema.Schema.Any,
|
|
|
611
634
|
* the per-entry-inferred {@link WorkflowCancelOnList}; this is what survives
|
|
612
635
|
* erasure, and it is deliberately not the public spelling. */
|
|
613
636
|
export declare interface WorkflowCancelOnDeclared {
|
|
614
|
-
readonly cancelOn?: ReadonlyArray<WorkflowCancelOn<Schema.
|
|
637
|
+
readonly cancelOn?: ReadonlyArray<WorkflowCancelOn<Schema.Top, never>>;
|
|
615
638
|
}
|
|
616
639
|
|
|
617
640
|
/** The `cancelOn` array as declared, with each entry's event type inferred
|
|
@@ -619,7 +642,7 @@ export declare interface WorkflowCancelOnDeclared {
|
|
|
619
642
|
* per-entry inference work — a plain `ReadonlyArray<WorkflowCancelOn<…>>`
|
|
620
643
|
* collapses every entry's event to the constraint (`any`), which is how the
|
|
621
644
|
* predicate silently stops being checked. */
|
|
622
|
-
export declare type WorkflowCancelOnList<Cancels extends ReadonlyArray<Schema.
|
|
645
|
+
export declare type WorkflowCancelOnList<Cancels extends ReadonlyArray<Schema.Top>, Payload> = {
|
|
623
646
|
readonly [I in keyof Cancels]: WorkflowCancelOn<Cancels[I], Payload>;
|
|
624
647
|
};
|
|
625
648
|
|
|
@@ -820,7 +843,7 @@ export declare const WorkflowFlowControlProperty = "__voltroWorkflowFlowControl"
|
|
|
820
843
|
* meaning anything if this ever regresses to `any` — which is precisely what
|
|
821
844
|
* all three failed attempts did.
|
|
822
845
|
*/
|
|
823
|
-
declare type WorkflowFn = <const Name extends string, Payload extends WorkflowPayloadInput, Success extends Schema.
|
|
846
|
+
declare type WorkflowFn = <const Name extends string, Payload extends WorkflowPayloadInput, Success extends Schema.Top = typeof Schema.Void, Error extends Schema.Top = typeof Schema.Never, const Messages extends WorkflowMessageSchemas | undefined = undefined, Cancels extends ReadonlyArray<Schema.Top> = readonly []>(options: {
|
|
824
847
|
readonly name: Name;
|
|
825
848
|
readonly payload: Payload;
|
|
826
849
|
readonly idempotencyKey: (payload: DecodedPayload<Payload>) => string;
|
|
@@ -838,13 +861,15 @@ declare type WorkflowFn = <const Name extends string, Payload extends WorkflowPa
|
|
|
838
861
|
readonly schedule?: WorkflowScheduleDeclaration<DecodedPayload<Payload>>;
|
|
839
862
|
} & Omit<WorkflowBaseOptions, 'name' | 'payload' | 'idempotencyKey' | 'success' | 'error'> & WorkflowVersionOptions & {
|
|
840
863
|
readonly messages?: Messages;
|
|
841
|
-
} & WorkflowFlowControl<DecodedPayload<Payload>> & WorkflowAccessOptions<DecodedPayload<Payload>>) => workflowModule.Workflow<Name, PayloadSchemaOf<Payload>, Success, Error> &
|
|
864
|
+
} & WorkflowFlowControl<DecodedPayload<Payload>> & WorkflowAccessOptions<DecodedPayload<Payload>>) => workflowModule.Workflow<Name, PayloadSchemaOf<Payload>, Success, Error> & {
|
|
865
|
+
readonly name: Name;
|
|
866
|
+
} & WorkflowMessagesCarrier<NormaliseWorkflowMessages<Messages>>;
|
|
842
867
|
|
|
843
868
|
declare type WorkflowMake = typeof workflowModule.make;
|
|
844
869
|
|
|
845
870
|
export declare interface WorkflowMessagePairSchemas {
|
|
846
|
-
readonly payload: Schema.
|
|
847
|
-
readonly success: Schema.
|
|
871
|
+
readonly payload: Schema.Top;
|
|
872
|
+
readonly success: Schema.Top;
|
|
848
873
|
}
|
|
849
874
|
|
|
850
875
|
export declare interface WorkflowMessagesCarrier<M extends WorkflowMessagesMetadata = WorkflowMessagesMetadata> {
|
|
@@ -862,12 +887,12 @@ export declare interface WorkflowMessagesCarrier<M extends WorkflowMessagesMetad
|
|
|
862
887
|
* and updates (synchronous, with a result) are the channels that exist.
|
|
863
888
|
*/
|
|
864
889
|
export declare interface WorkflowMessageSchemas {
|
|
865
|
-
readonly signals?: Readonly<Record<string, Schema.
|
|
890
|
+
readonly signals?: Readonly<Record<string, Schema.Top>>;
|
|
866
891
|
readonly updates?: Readonly<Record<string, WorkflowMessagePairSchemas>>;
|
|
867
892
|
}
|
|
868
893
|
|
|
869
894
|
export declare interface WorkflowMessagesMetadata {
|
|
870
|
-
readonly signals: Readonly<Record<string, Schema.
|
|
895
|
+
readonly signals: Readonly<Record<string, Schema.Top>>;
|
|
871
896
|
readonly updates: Readonly<Record<string, WorkflowMessagePairSchemas>>;
|
|
872
897
|
}
|
|
873
898
|
|
|
@@ -1049,7 +1074,7 @@ export declare interface WorkflowVersionOptions {
|
|
|
1049
1074
|
* suspended-on-failure run shows up under `--status suspended`, NOT in the
|
|
1050
1075
|
* dead-letter view — it is recoverable, not dead.
|
|
1051
1076
|
*
|
|
1052
|
-
* Maps to
|
|
1077
|
+
* Maps to `effect/workflow`'s `SuspendOnFailure` annotation.
|
|
1053
1078
|
*/
|
|
1054
1079
|
readonly suspendOnFailure?: boolean;
|
|
1055
1080
|
}
|
package/dist/primitives.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as e, C as t, D as n, E as r, G as i, J as a, K as o, O as s, S as c, T as l, U as u, W as d, _ as f, a as p, b as m, c as h, d as g, f as _, g as v, h as y, i as b, j as x, k as S, l as C, m as w, n as T, o as E, p as D, q as O, r as k, s as A, t as j, u as M, v as N, w as P, x as F, y as I } from "./primitives-
|
|
2
|
-
export { P as CurrentWorkflowReplayShape, s as DEFAULT_WORKFLOW_SCHEDULE_MAX_RUNTIME_MS, u as DEFERRING_CONTROLS, j as WorkflowFlowControlProperty, T as WorkflowMessagesProperty, S as WorkflowScheduleProperty, k as WorkflowVersionTypeId, b as WorkflowWorkerLayerTypeId, d as assertConsistentPools, i as deferringControlsOf, p as durableClock, E as durableQueue, A as durableQueueModule, h as
|
|
1
|
+
import { A as e, C as t, D as n, E as r, G as i, J as a, K as o, O as s, S as c, T as l, U as u, W as d, _ as f, a as p, b as m, c as h, d as g, f as _, g as v, h as y, i as b, j as x, k as S, l as C, m as w, n as T, o as E, p as D, q as O, r as k, s as A, t as j, u as M, v as N, w as P, x as F, y as I } from "./primitives-DX04WTWh.js";
|
|
2
|
+
export { P as CurrentWorkflowReplayShape, s as DEFAULT_WORKFLOW_SCHEDULE_MAX_RUNTIME_MS, u as DEFERRING_CONTROLS, j as WorkflowFlowControlProperty, T as WorkflowMessagesProperty, S as WorkflowScheduleProperty, k as WorkflowVersionTypeId, b as WorkflowWorkerLayerTypeId, d as assertConsistentPools, i as deferringControlsOf, p as durableClock, E as durableQueue, A as durableQueueModule, h as getWorkflowFlowControl, e as getWorkflowSchedule, C as getWorkflowVersionMetadata, o as hasCancelOn, O as hasFlowControl, M as isCarrier, g as isWorkflowWorkerLayer, l as makeReplayShapeTracker, r as nondeterminismEventPayload, _ as patch, D as processQueue, w as queueWorker, y as rateLimit, n as reportNondeterminism, v as sleep, f as sleepUntil, N as step, I as stepIdempotencyKey, m as stepModule, a as validateFlowControl, x as validateWorkflowSchedule, F as withCompensation, c as workflow, t as workflowModule };
|