@lunora/workflow 0.0.0 → 1.0.0-alpha.1
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/LICENSE.md +105 -0
- package/README.md +260 -9
- package/__assets__/package-og.svg +14 -0
- package/dist/do/index.d.mts +25 -0
- package/dist/do/index.d.ts +25 -0
- package/dist/do/index.mjs +32 -0
- package/dist/index.d.mts +269 -0
- package/dist/index.d.ts +269 -0
- package/dist/index.mjs +8 -0
- package/dist/packem_shared/WorkflowsRestError-b06i7K5j.mjs +118 -0
- package/dist/packem_shared/convertNonRetryableError-Dn2dTyBS.mjs +27 -0
- package/dist/packem_shared/createRunStep-BsK4LsUX.mjs +54 -0
- package/dist/packem_shared/createWorkflowContext-D6thzmlF.mjs +14 -0
- package/dist/packem_shared/createWorkflowLogger-FktqxNLe.mjs +76 -0
- package/dist/packem_shared/createWorkflows-BoSYVIXg.mjs +23 -0
- package/dist/packem_shared/defineStep-DJQtLw7g.mjs +28 -0
- package/dist/packem_shared/defineWorkflow-DbUC-oCN.mjs +15 -0
- package/dist/packem_shared/types.d-CQO_koGe.d.mts +344 -0
- package/dist/packem_shared/types.d-CQO_koGe.d.ts +344 -0
- package/package.json +42 -15
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import { ValidatorMap, InferValidatorMap, Validator } from '@lunora/values';
|
|
2
|
+
/**
|
|
3
|
+
* Opaque reference to a Lunora function. Mirrors the `FunctionReference` shape
|
|
4
|
+
* emitted by `@lunora/codegen` (and consumed by `@lunora/client`). We avoid a
|
|
5
|
+
* direct dependency to keep this package usable from the codegen pipeline
|
|
6
|
+
* itself — identical rationale to `@lunora/scheduler`'s copy.
|
|
7
|
+
*
|
|
8
|
+
* The runtime identifier lives in `__lunoraRef` — this MUST stay in lockstep
|
|
9
|
+
* with the codegen emit + `@lunora/client`'s `FunctionReference`.
|
|
10
|
+
*/
|
|
11
|
+
interface FunctionReference {
|
|
12
|
+
readonly __lunoraRef: string;
|
|
13
|
+
/** Marker phantom type — discriminates queries / mutations / actions. */
|
|
14
|
+
readonly _kind?: "query" | "mutation" | "action";
|
|
15
|
+
}
|
|
16
|
+
type ArgsOf<F extends FunctionReference> = F extends {
|
|
17
|
+
_args?: infer A;
|
|
18
|
+
} ? A : Record<string, unknown>;
|
|
19
|
+
/** A workflow instance's lifecycle status. Mirrors `WorkflowInstanceStatus`. */
|
|
20
|
+
type WorkflowInstanceStatus = "complete" | "errored" | "paused" | "queued" | "running" | "terminated" | "unknown" | "waiting" | "waitingForPause";
|
|
21
|
+
/** Result of `WorkflowInstance.status()`. Mirrors Cloudflare's `InstanceStatus`. */
|
|
22
|
+
interface WorkflowStatusResult {
|
|
23
|
+
error?: {
|
|
24
|
+
message: string;
|
|
25
|
+
name: string;
|
|
26
|
+
};
|
|
27
|
+
output?: unknown;
|
|
28
|
+
status: WorkflowInstanceStatus;
|
|
29
|
+
}
|
|
30
|
+
/** Options accepted by `Workflow.create`. Mirrors `WorkflowInstanceCreateOptions`. */
|
|
31
|
+
interface WorkflowCreateOptions<Params = Record<string, unknown>> {
|
|
32
|
+
/** Unique-within-the-workflow instance id. Generated by Cloudflare when omitted. */
|
|
33
|
+
id?: string;
|
|
34
|
+
/** The event payload the instance is triggered with — surfaced as `event.payload`. */
|
|
35
|
+
params?: Params;
|
|
36
|
+
/** Instance retention policy (defaults to the account maximum). */
|
|
37
|
+
retention?: {
|
|
38
|
+
errorRetention?: string;
|
|
39
|
+
successRetention?: string;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** A live handle to a single workflow instance. Mirrors `WorkflowInstance`. */
|
|
43
|
+
interface WorkflowInstanceLike {
|
|
44
|
+
readonly id: string;
|
|
45
|
+
pause: () => Promise<void>;
|
|
46
|
+
restart: () => Promise<void>;
|
|
47
|
+
resume: () => Promise<void>;
|
|
48
|
+
sendEvent: (event: {
|
|
49
|
+
payload: unknown;
|
|
50
|
+
type: string;
|
|
51
|
+
}) => Promise<void>;
|
|
52
|
+
status: () => Promise<WorkflowStatusResult>;
|
|
53
|
+
terminate: () => Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The subset of the Cloudflare `Workflow` binding the package consumes.
|
|
57
|
+
* `createBatch` is a non-optional method on the real binding (Cloudflare's
|
|
58
|
+
* `Workflow` class declares it unconditionally), so it is required here too —
|
|
59
|
+
* the handle never has to guard for its absence.
|
|
60
|
+
*/
|
|
61
|
+
interface WorkflowBindingLike<Params = Record<string, unknown>> {
|
|
62
|
+
create: (options?: WorkflowCreateOptions<Params>) => Promise<WorkflowInstanceLike>;
|
|
63
|
+
createBatch: (batch: ReadonlyArray<WorkflowCreateOptions<Params>>) => Promise<WorkflowInstanceLike[]>;
|
|
64
|
+
get: (id: string) => Promise<WorkflowInstanceLike>;
|
|
65
|
+
}
|
|
66
|
+
/** The `event` argument a workflow `run` receives. Mirrors `WorkflowEvent<T>`. */
|
|
67
|
+
interface WorkflowEventLike<Params = Record<string, unknown>> {
|
|
68
|
+
readonly instanceId: string;
|
|
69
|
+
readonly payload: Readonly<Params>;
|
|
70
|
+
readonly timestamp: Date;
|
|
71
|
+
readonly workflowName: string;
|
|
72
|
+
}
|
|
73
|
+
/** Per-step durability config. Mirrors the `WorkflowStepConfig.retries` shape. */
|
|
74
|
+
interface WorkflowStepConfigLike {
|
|
75
|
+
retries?: {
|
|
76
|
+
backoff?: "constant" | "exponential" | "linear";
|
|
77
|
+
delay?: number | string;
|
|
78
|
+
limit: number;
|
|
79
|
+
};
|
|
80
|
+
timeout?: number | string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The per-attempt info Cloudflare passes a `step.do` callback. Mirrors
|
|
84
|
+
* `WorkflowStepContext` — `attempt` is the 1-based retry counter (`> 1` on
|
|
85
|
+
* retries) and `step` carries the durable step's name + invocation count.
|
|
86
|
+
*/
|
|
87
|
+
interface WorkflowStepContextLike {
|
|
88
|
+
/** 1-based attempt counter — `> 1` means this is a retry. */
|
|
89
|
+
attempt: number;
|
|
90
|
+
/** The resolved per-step config for this invocation. */
|
|
91
|
+
config: WorkflowStepConfigLike;
|
|
92
|
+
/** The durable step's identity. */
|
|
93
|
+
step: {
|
|
94
|
+
count: number;
|
|
95
|
+
name: string;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/** The context a rollback handler receives. Mirrors `WorkflowRollbackContext` (`{ ctx, error, output, stepName }`). */
|
|
99
|
+
interface WorkflowRollbackContextLike<T = unknown> {
|
|
100
|
+
/** The per-attempt step context (`attempt` / `config` / `step`) for the rolled-back step. */
|
|
101
|
+
ctx: WorkflowStepContextLike;
|
|
102
|
+
/** The error that triggered the rollback. */
|
|
103
|
+
error: Error;
|
|
104
|
+
/** The step's output if it completed before a later step failed, else `undefined`. */
|
|
105
|
+
output: T | undefined;
|
|
106
|
+
/** The durable step's name. */
|
|
107
|
+
stepName: string;
|
|
108
|
+
}
|
|
109
|
+
/** A native step rollback handler. Mirrors `WorkflowRollbackHandler`. */
|
|
110
|
+
type WorkflowRollbackHandlerLike<T = unknown> = (context: WorkflowRollbackContextLike<T>) => Promise<void>;
|
|
111
|
+
/** Native rollback options accepted by `step.do`. Mirrors the Cloudflare rollback-options shape. */
|
|
112
|
+
interface WorkflowStepRollbackOptionsLike<T = unknown> {
|
|
113
|
+
rollback?: WorkflowRollbackHandlerLike<T>;
|
|
114
|
+
rollbackConfig?: WorkflowStepConfigLike;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The durable step API Cloudflare hands the workflow body. Mirrors
|
|
118
|
+
* `WorkflowStep` — `do` memoizes + retries its callback, `sleep`/`sleepUntil`
|
|
119
|
+
* are durable delays, and `waitForEvent` hibernates until an external event.
|
|
120
|
+
* `do`'s two overloads mirror Cloudflare's: an optional leading `config` and an
|
|
121
|
+
* optional trailing `rollback` (compensation run when a later step fails).
|
|
122
|
+
*
|
|
123
|
+
* Known mirror gap: Cloudflare constrains `do<T extends Rpc.Serializable<T>>` so
|
|
124
|
+
* a non-serializable step result (a function, `Map`, class instance, …) is a
|
|
125
|
+
* compile error there. `Rpc.Serializable` lives in `@cloudflare/workers-types`
|
|
126
|
+
* and is not Node-importable, so this Node-safe mirror uses a bare `<T>` and
|
|
127
|
+
* cannot enforce that — a non-serializable result type-checks here but fails at
|
|
128
|
+
* runtime on the platform. Keep step results JSON-serialisable.
|
|
129
|
+
*/
|
|
130
|
+
interface WorkflowStepLike {
|
|
131
|
+
do: {
|
|
132
|
+
<T>(name: string, callback: (context: WorkflowStepContextLike) => Promise<T>, rollback?: WorkflowStepRollbackOptionsLike<T>): Promise<T>;
|
|
133
|
+
<T>(name: string, config: WorkflowStepConfigLike, callback: (context: WorkflowStepContextLike) => Promise<T>, rollback?: WorkflowStepRollbackOptionsLike<T>): Promise<T>;
|
|
134
|
+
};
|
|
135
|
+
sleep: (name: string, duration: number | string) => Promise<void>;
|
|
136
|
+
sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
|
|
137
|
+
waitForEvent: <T = unknown>(name: string, options: {
|
|
138
|
+
timeout?: number | string;
|
|
139
|
+
type: string;
|
|
140
|
+
}) => Promise<{
|
|
141
|
+
payload: Readonly<T>;
|
|
142
|
+
type: string;
|
|
143
|
+
}>;
|
|
144
|
+
}
|
|
145
|
+
/** Minimal structured logger handed to the workflow body. */
|
|
146
|
+
interface WorkflowLogger {
|
|
147
|
+
debug: (message: string, ...rest: unknown[]) => void;
|
|
148
|
+
error: (message: string, ...rest: unknown[]) => void;
|
|
149
|
+
info: (message: string, ...rest: unknown[]) => void;
|
|
150
|
+
warn: (message: string, ...rest: unknown[]) => void;
|
|
151
|
+
}
|
|
152
|
+
/** Per-call options for {@link WorkflowRunFunction}. */
|
|
153
|
+
interface RunFunctionOptions {
|
|
154
|
+
/** Routing hint forwarded to the Worker so the call lands on the right shard. */
|
|
155
|
+
shardKey?: string;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Calls a Lunora query / mutation / action from inside a workflow and resolves
|
|
159
|
+
* with its result. Wrap it in {@link WorkflowStepLike.do} to make the call a
|
|
160
|
+
* durable, memoized, retried step:
|
|
161
|
+
*
|
|
162
|
+
* ```ts
|
|
163
|
+
* const charge = await ctx.step.do("charge", () => ctx.run(api.payments.charge, { id }));
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
type WorkflowRunFunction = <F extends FunctionReference>(function_: F, args?: ArgsOf<F>, options?: RunFunctionOptions) => Promise<unknown>;
|
|
167
|
+
/** Map of validators describing a step's args record — the same shape a Lunora function's `args` uses. Alias of `@lunora/values`' shared {@link ValidatorMap}. */
|
|
168
|
+
type StepArgsValidator = ValidatorMap;
|
|
169
|
+
/** Infer the args object type from a {@link StepArgsValidator} (optional validators → optional keys). Alias of `@lunora/values`' shared {@link InferValidatorMap}. */
|
|
170
|
+
type InferStepArgs<A extends StepArgsValidator> = InferValidatorMap<A>;
|
|
171
|
+
/**
|
|
172
|
+
* The context a {@link StepDefinition} handler receives as its first argument
|
|
173
|
+
* (the validated args are the second). Bundles the native per-attempt info
|
|
174
|
+
* (`attempt`, `config`, `step`) with the Worker `env`, the Lunora runner, and a
|
|
175
|
+
* logger.
|
|
176
|
+
*/
|
|
177
|
+
interface StepRunContext {
|
|
178
|
+
/** 1-based retry counter — `> 1` means Cloudflare is retrying the step. */
|
|
179
|
+
readonly attempt: number;
|
|
180
|
+
/** The resolved durability config for this invocation. */
|
|
181
|
+
readonly config: WorkflowStepConfigLike;
|
|
182
|
+
/** The Worker environment bindings. */
|
|
183
|
+
readonly env: Record<string, unknown>;
|
|
184
|
+
/** Structured logger surfaced in `wrangler tail` / Studio logs. */
|
|
185
|
+
readonly log: WorkflowLogger;
|
|
186
|
+
/** Invoke a Lunora query / mutation / action. */
|
|
187
|
+
readonly run: WorkflowRunFunction;
|
|
188
|
+
/** The durable step's identity (name + invocation count). */
|
|
189
|
+
readonly step: {
|
|
190
|
+
count: number;
|
|
191
|
+
name: string;
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
/** The work a step performs. Receives the {@link StepRunContext} and the validated args. */
|
|
195
|
+
type StepHandler<A extends StepArgsValidator, Result> = (context: StepRunContext, args: InferStepArgs<A>) => Promise<Result> | Result;
|
|
196
|
+
/** The context a step rollback handler receives — the Lunora-flavored mirror of `WorkflowRollbackContext`. */
|
|
197
|
+
interface StepRollbackContext<A extends StepArgsValidator, Result> {
|
|
198
|
+
/** The validated args the step ran with. */
|
|
199
|
+
readonly args: InferStepArgs<A>;
|
|
200
|
+
/** The Worker environment bindings. */
|
|
201
|
+
readonly env: Record<string, unknown>;
|
|
202
|
+
/** The error that triggered the rollback. */
|
|
203
|
+
readonly error: Error;
|
|
204
|
+
/** Structured logger. */
|
|
205
|
+
readonly log: WorkflowLogger;
|
|
206
|
+
/** The step's output if it completed before a later step failed, else `undefined`. */
|
|
207
|
+
readonly output: Result | undefined;
|
|
208
|
+
/** Invoke a Lunora function — e.g. to undo a write the step made. */
|
|
209
|
+
readonly run: WorkflowRunFunction;
|
|
210
|
+
}
|
|
211
|
+
/** A step compensation handler — runs when a later step fails after this one completed. */
|
|
212
|
+
type StepRollbackHandler<A extends StepArgsValidator, Result> = (context: StepRollbackContext<A, Result>) => Promise<void> | void;
|
|
213
|
+
/** Author-supplied config for {@link StepDefinition}, passed to `defineStep`. */
|
|
214
|
+
interface StepConfig<A extends StepArgsValidator, Result> {
|
|
215
|
+
/** Validators for the step's args — the same map shape a Lunora function uses. */
|
|
216
|
+
args: A;
|
|
217
|
+
/** Optional durability config (retries / timeout) applied to the step. */
|
|
218
|
+
config?: WorkflowStepConfigLike;
|
|
219
|
+
/** The work the step performs. */
|
|
220
|
+
handler: StepHandler<A, Result>;
|
|
221
|
+
/** Optional validator for the return value — validated before the result leaves the step. */
|
|
222
|
+
returns?: Validator<Result>;
|
|
223
|
+
/** Optional compensation run when a later step fails after this one completed. */
|
|
224
|
+
rollback?: StepRollbackHandler<A, Result>;
|
|
225
|
+
/** Optional durability config for the rollback step itself. */
|
|
226
|
+
rollbackConfig?: WorkflowStepConfigLike;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* A `defineStep` result — a reusable, schema-validated durable step. Run it from
|
|
230
|
+
* a workflow body with `ctx.runStep(step, args)`. The phantom generics carry the
|
|
231
|
+
* inferred args + result types to the call site.
|
|
232
|
+
*/
|
|
233
|
+
interface StepDefinition<A extends StepArgsValidator = StepArgsValidator, Result = unknown> {
|
|
234
|
+
/** Validators for the step's args. */
|
|
235
|
+
readonly args: A;
|
|
236
|
+
/** Optional per-step durability config. */
|
|
237
|
+
readonly config?: WorkflowStepConfigLike;
|
|
238
|
+
/** The step body. */
|
|
239
|
+
readonly handler: StepHandler<A, Result>;
|
|
240
|
+
/** Runtime brand check (see `isStepDefinition`). */
|
|
241
|
+
readonly isLunoraStep: true;
|
|
242
|
+
/** The durable step's name — also the `step.do(...)` label. */
|
|
243
|
+
readonly name: string;
|
|
244
|
+
/** Optional result validator. */
|
|
245
|
+
readonly returns?: Validator<Result>;
|
|
246
|
+
/** Optional compensation handler. */
|
|
247
|
+
readonly rollback?: StepRollbackHandler<A, Result>;
|
|
248
|
+
/** Optional rollback durability config. */
|
|
249
|
+
readonly rollbackConfig?: WorkflowStepConfigLike;
|
|
250
|
+
}
|
|
251
|
+
/** Per-call options for {@link WorkflowRunStepFunction}. */
|
|
252
|
+
interface RunStepOptions {
|
|
253
|
+
/** Override the step's declared durability config for this call. */
|
|
254
|
+
config?: WorkflowStepConfigLike;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Run a reusable {@link StepDefinition} as a durable, memoized, retried step:
|
|
258
|
+
* validates the args before the body runs and the result after (when the step
|
|
259
|
+
* declares `returns`), and forwards any rollback handler to Cloudflare.
|
|
260
|
+
*
|
|
261
|
+
* ```ts
|
|
262
|
+
* const data = await ctx.runStep(fetchImage, { imageKey });
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
type WorkflowRunStepFunction = <A extends StepArgsValidator, Result>(step: StepDefinition<A, Result>, args: InferStepArgs<A>, options?: RunStepOptions) => Promise<Result>;
|
|
266
|
+
/**
|
|
267
|
+
* The context object passed to a `defineWorkflow` handler. Bundles the native
|
|
268
|
+
* Cloudflare durability primitives (`step`, `event`) with the Lunora runner
|
|
269
|
+
* (`run`), the reusable-step runner (`runStep`), the Worker `env`, and a logger.
|
|
270
|
+
*/
|
|
271
|
+
interface WorkflowRunContext<Params = Record<string, unknown>> {
|
|
272
|
+
/** The Worker environment bindings. */
|
|
273
|
+
readonly env: Record<string, unknown>;
|
|
274
|
+
/** The triggering event (id, payload, timestamp, workflow name). */
|
|
275
|
+
readonly event: WorkflowEventLike<Params>;
|
|
276
|
+
/** Structured logger surfaced in `wrangler tail` / Studio logs. */
|
|
277
|
+
readonly log: WorkflowLogger;
|
|
278
|
+
/** Convenience alias for `event.payload`. */
|
|
279
|
+
readonly params: Readonly<Params>;
|
|
280
|
+
/** Invoke a Lunora function; wrap in `step.do(...)` for durability. */
|
|
281
|
+
readonly run: WorkflowRunFunction;
|
|
282
|
+
/** Run a reusable, schema-validated {@link StepDefinition} as a durable step. */
|
|
283
|
+
readonly runStep: WorkflowRunStepFunction;
|
|
284
|
+
/** The native Cloudflare Workflows durable-step API. */
|
|
285
|
+
readonly step: WorkflowStepLike;
|
|
286
|
+
}
|
|
287
|
+
/** The workflow body. Receives a {@link WorkflowRunContext}, returns the output. */
|
|
288
|
+
type WorkflowHandler<Params = Record<string, unknown>, Output = unknown> = (context: WorkflowRunContext<Params>) => Output | Promise<Output>;
|
|
289
|
+
/** Author-supplied config for `defineWorkflow`. */
|
|
290
|
+
interface WorkflowConfig<Params = Record<string, unknown>, Output = unknown> {
|
|
291
|
+
/** The workflow body — the multi-step durable program. */
|
|
292
|
+
handler: WorkflowHandler<Params, Output>;
|
|
293
|
+
/**
|
|
294
|
+
* Optional override for the deployed workflow name — the `workflows[].name`
|
|
295
|
+
* written to `wrangler.jsonc`. Defaults to a kebab-cased form of the
|
|
296
|
+
* `lunora/workflows.ts` export name (`orderPipeline` → `order-pipeline`).
|
|
297
|
+
* This does NOT change the binding name, which is always derived from the
|
|
298
|
+
* export name (`orderPipeline` → `WORKFLOW_ORDER_PIPELINE`).
|
|
299
|
+
*/
|
|
300
|
+
name?: string;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* A `defineWorkflow` result — the config plus the runtime brand codegen and the
|
|
304
|
+
* config layer use to discover it. The phantom `__params` / `__output` carry
|
|
305
|
+
* the inferred types to the generated `ctx.workflows` handle.
|
|
306
|
+
*/
|
|
307
|
+
interface WorkflowDefinition<Params = Record<string, unknown>, Output = unknown> extends WorkflowConfig<Params, Output> {
|
|
308
|
+
/** Phantom marker for the output type — never present at runtime. */
|
|
309
|
+
readonly __output?: Output;
|
|
310
|
+
/** Phantom marker for the params type — never present at runtime. */
|
|
311
|
+
readonly __params?: Params;
|
|
312
|
+
/** Runtime brand check (see `isWorkflowDefinition`). */
|
|
313
|
+
readonly isLunoraWorkflow: true;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* A typed handle to one declared workflow, addressable from `ctx.workflows`.
|
|
317
|
+
* Thin pass-through over the Cloudflare `Workflow` binding.
|
|
318
|
+
*/
|
|
319
|
+
interface WorkflowHandle<Params = Record<string, unknown>> {
|
|
320
|
+
/** Start a new instance (optionally with an id + params). */
|
|
321
|
+
create: (options?: WorkflowCreateOptions<Params>) => Promise<WorkflowInstanceLike>;
|
|
322
|
+
/** Start many instances in one batched RPC. */
|
|
323
|
+
createBatch: (batch: ReadonlyArray<WorkflowCreateOptions<Params>>) => Promise<WorkflowInstanceLike[]>;
|
|
324
|
+
/** Get a handle to an existing instance by id. */
|
|
325
|
+
get: (id: string) => Promise<WorkflowInstanceLike>;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* The `ctx.workflows` surface available on `MutationCtx` and `ActionCtx`. Each
|
|
329
|
+
* declared workflow is reachable by its `lunora/workflows.ts` export name.
|
|
330
|
+
*/
|
|
331
|
+
interface Workflows {
|
|
332
|
+
/** Resolve the handle for a declared workflow by export name. */
|
|
333
|
+
get: <Params = Record<string, unknown>>(name: string) => WorkflowHandle<Params>;
|
|
334
|
+
}
|
|
335
|
+
/** Options for `createWorkflows`. */
|
|
336
|
+
interface LunoraWorkflowsOptions {
|
|
337
|
+
/**
|
|
338
|
+
* Map of `lunora/workflows.ts` export name → its Cloudflare `Workflow`
|
|
339
|
+
* binding. Codegen builds this from `env` (`{ orderPipeline:
|
|
340
|
+
* env.WORKFLOW_ORDER_PIPELINE }`); for manual wiring construct it yourself.
|
|
341
|
+
*/
|
|
342
|
+
bindings: Record<string, WorkflowBindingLike>;
|
|
343
|
+
}
|
|
344
|
+
export { ArgsOf as A, WorkflowStepRollbackOptionsLike as B, FunctionReference as F, InferStepArgs as I, LunoraWorkflowsOptions as L, RunFunctionOptions as R, StepArgsValidator as S, WorkflowDefinition as W, Workflows as a, StepConfig as b, StepDefinition as c, WorkflowConfig as d, WorkflowInstanceStatus as e, WorkflowLogger as f, WorkflowEventLike as g, WorkflowStepLike as h, WorkflowRunContext as i, WorkflowRunFunction as j, WorkflowRunStepFunction as k, RunStepOptions as l, StepHandler as m, StepRollbackContext as n, StepRollbackHandler as o, StepRunContext as p, WorkflowBindingLike as q, WorkflowCreateOptions as r, WorkflowHandle as s, WorkflowHandler as t, WorkflowInstanceLike as u, WorkflowRollbackContextLike as v, WorkflowRollbackHandlerLike as w, WorkflowStatusResult as x, WorkflowStepConfigLike as y, WorkflowStepContextLike as z };
|
package/package.json
CHANGED
|
@@ -1,29 +1,56 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/workflow",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "1.0.0-alpha.1",
|
|
4
4
|
"description": "Durable workflows for Lunora: defineWorkflow over Cloudflare Workflows, generated WorkflowEntrypoint classes, and the ctx.workflows surface",
|
|
5
|
-
"
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cloudflare",
|
|
7
|
+
"durable-execution",
|
|
8
|
+
"lunora",
|
|
9
|
+
"saga",
|
|
10
|
+
"workers",
|
|
11
|
+
"workflows"
|
|
12
|
+
],
|
|
6
13
|
"homepage": "https://lunora.sh",
|
|
14
|
+
"bugs": "https://github.com/anolilab/lunora/issues",
|
|
15
|
+
"license": "FSL-1.1-Apache-2.0",
|
|
16
|
+
"author": {
|
|
17
|
+
"name": "Daniel Bannert",
|
|
18
|
+
"email": "d.bannert@anolilab.de"
|
|
19
|
+
},
|
|
7
20
|
"repository": {
|
|
8
21
|
"type": "git",
|
|
9
22
|
"url": "git+https://github.com/anolilab/lunora.git",
|
|
10
23
|
"directory": "packages/workflow"
|
|
11
24
|
},
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
"cloudflare",
|
|
18
|
-
"workers",
|
|
19
|
-
"workflows",
|
|
20
|
-
"durable-execution",
|
|
21
|
-
"saga"
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"README.md",
|
|
28
|
+
"LICENSE.md",
|
|
29
|
+
"__assets__"
|
|
22
30
|
],
|
|
31
|
+
"type": "module",
|
|
32
|
+
"sideEffects": false,
|
|
33
|
+
"main": "./dist/index.mjs",
|
|
34
|
+
"module": "./dist/index.mjs",
|
|
35
|
+
"types": "./dist/index.d.ts",
|
|
36
|
+
"exports": {
|
|
37
|
+
".": {
|
|
38
|
+
"types": "./dist/index.d.ts",
|
|
39
|
+
"import": "./dist/index.mjs"
|
|
40
|
+
},
|
|
41
|
+
"./do": {
|
|
42
|
+
"types": "./dist/do/index.d.ts",
|
|
43
|
+
"import": "./dist/do/index.mjs"
|
|
44
|
+
},
|
|
45
|
+
"./package.json": "./package.json"
|
|
46
|
+
},
|
|
23
47
|
"publishConfig": {
|
|
24
48
|
"access": "public"
|
|
25
49
|
},
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@lunora/values": "1.0.0-alpha.1"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": "^22.15.0 || >=24.11.0"
|
|
55
|
+
}
|
|
29
56
|
}
|