@lunora/workflow 1.0.0-alpha.39 → 1.0.0-alpha.40

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.
@@ -1,5 +1,5 @@
1
1
  import { WorkflowEntrypoint, WorkflowEvent, WorkflowStep } from 'cloudflare:workers';
2
- import { W as WorkflowDefinition } from "../packem_shared/types.d-CeA8m4Iq.mjs";
2
+ import { W as WorkflowDefinition } from "../packem_shared/types.d-C7jti0tm.mjs";
3
3
  import '@lunora/values';
4
4
  /**
5
5
  * Base class for the generated `WorkflowEntrypoint` classes. Applies a
@@ -1,5 +1,5 @@
1
1
  import { WorkflowEntrypoint, WorkflowEvent, WorkflowStep } from 'cloudflare:workers';
2
- import { W as WorkflowDefinition } from "../packem_shared/types.d-CeA8m4Iq.js";
2
+ import { W as WorkflowDefinition } from "../packem_shared/types.d-C7jti0tm.js";
3
3
  import '@lunora/values';
4
4
  /**
5
5
  * Base class for the generated `WorkflowEntrypoint` classes. Applies a
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as Workflows, L as LunoraWorkflowsOptions, b as WorkflowEventDefinition, S as StepArgsValidator, c as StepConfig, d as StepDefinition, e as WorkflowConfig, W as WorkflowDefinition, f as WorkflowBranch, g as WorkflowInstanceStatus, h as WorkflowEventLike, i as WorkflowStepLike, j as WorkflowRunContext, k as WorkflowLogger, l as WorkflowRunFunction, m as WorkflowRunStepFunction, n as WorkflowWaitForEventFunction } from "./packem_shared/types.d-CeA8m4Iq.mjs";
2
- export type { A as ArgsOf, B as BranchCompensationParams, F as FunctionReference, I as InferStepArgs, R as RunFunctionOptions, o as RunStepOptions, p as StepHandler, q as StepRollbackContext, r as StepRollbackHandler, s as StepRunContext, t as WaitForEventOptions, u as WorkflowBindingLike, v as WorkflowBranchOutputs, w as WorkflowCreateOptions, x as WorkflowHandle, y as WorkflowHandler, z as WorkflowInstanceLike, C as WorkflowParallelFunction, D as WorkflowRollbackContextLike, E as WorkflowRollbackHandlerLike, G as WorkflowSpawnFunction, H as WorkflowSpawnOptions, J as WorkflowStatusResult, K as WorkflowStepConfigLike, M as WorkflowStepContextLike, N as WorkflowStepRollbackOptionsLike } from "./packem_shared/types.d-CeA8m4Iq.mjs";
1
+ import { a as Workflows, L as LunoraWorkflowsOptions, b as WorkflowEventDefinition, S as StepArgsValidator, c as StepConfig, d as StepDefinition, e as WorkflowConfig, W as WorkflowDefinition, f as WorkflowBranch, g as WorkflowInstanceStatus, h as WorkflowEventLike, i as WorkflowStepLike, j as WorkflowRunContext, k as WorkflowLogger, l as WorkflowRunFunction, m as WorkflowRunStepFunction, n as WorkflowWaitForEventFunction } from "./packem_shared/types.d-C7jti0tm.mjs";
2
+ export type { A as ArgsOf, B as BranchCompensationParams, F as FunctionKind, o as FunctionReference, I as InferStepArgs, R as RunFunctionOptions, p as RunStepOptions, q as StepHandler, r as StepRollbackContext, s as StepRollbackHandler, t as StepRunContext, u as WaitForEventOptions, v as WorkflowBindingLike, w as WorkflowBranchOutputs, x as WorkflowCreateOptions, y as WorkflowHandle, z as WorkflowHandler, C as WorkflowInstanceLike, D as WorkflowParallelFunction, E as WorkflowRollbackContextLike, G as WorkflowRollbackHandlerLike, H as WorkflowSpawnFunction, J as WorkflowSpawnOptions, K as WorkflowStatusResult, M as WorkflowStepConfigLike, N as WorkflowStepContextLike, O as WorkflowStepRollbackOptionsLike } from "./packem_shared/types.d-C7jti0tm.mjs";
3
3
  import { Validator } from '@lunora/values';
4
4
  import { LunoraError } from '@lunora/errors';
5
5
  /** Wiring info for one declared workflow, emitted by codegen into the generated shard. */
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as Workflows, L as LunoraWorkflowsOptions, b as WorkflowEventDefinition, S as StepArgsValidator, c as StepConfig, d as StepDefinition, e as WorkflowConfig, W as WorkflowDefinition, f as WorkflowBranch, g as WorkflowInstanceStatus, h as WorkflowEventLike, i as WorkflowStepLike, j as WorkflowRunContext, k as WorkflowLogger, l as WorkflowRunFunction, m as WorkflowRunStepFunction, n as WorkflowWaitForEventFunction } from "./packem_shared/types.d-CeA8m4Iq.js";
2
- export type { A as ArgsOf, B as BranchCompensationParams, F as FunctionReference, I as InferStepArgs, R as RunFunctionOptions, o as RunStepOptions, p as StepHandler, q as StepRollbackContext, r as StepRollbackHandler, s as StepRunContext, t as WaitForEventOptions, u as WorkflowBindingLike, v as WorkflowBranchOutputs, w as WorkflowCreateOptions, x as WorkflowHandle, y as WorkflowHandler, z as WorkflowInstanceLike, C as WorkflowParallelFunction, D as WorkflowRollbackContextLike, E as WorkflowRollbackHandlerLike, G as WorkflowSpawnFunction, H as WorkflowSpawnOptions, J as WorkflowStatusResult, K as WorkflowStepConfigLike, M as WorkflowStepContextLike, N as WorkflowStepRollbackOptionsLike } from "./packem_shared/types.d-CeA8m4Iq.js";
1
+ import { a as Workflows, L as LunoraWorkflowsOptions, b as WorkflowEventDefinition, S as StepArgsValidator, c as StepConfig, d as StepDefinition, e as WorkflowConfig, W as WorkflowDefinition, f as WorkflowBranch, g as WorkflowInstanceStatus, h as WorkflowEventLike, i as WorkflowStepLike, j as WorkflowRunContext, k as WorkflowLogger, l as WorkflowRunFunction, m as WorkflowRunStepFunction, n as WorkflowWaitForEventFunction } from "./packem_shared/types.d-C7jti0tm.js";
2
+ export type { A as ArgsOf, B as BranchCompensationParams, F as FunctionKind, o as FunctionReference, I as InferStepArgs, R as RunFunctionOptions, p as RunStepOptions, q as StepHandler, r as StepRollbackContext, s as StepRollbackHandler, t as StepRunContext, u as WaitForEventOptions, v as WorkflowBindingLike, w as WorkflowBranchOutputs, x as WorkflowCreateOptions, y as WorkflowHandle, z as WorkflowHandler, C as WorkflowInstanceLike, D as WorkflowParallelFunction, E as WorkflowRollbackContextLike, G as WorkflowRollbackHandlerLike, H as WorkflowSpawnFunction, J as WorkflowSpawnOptions, K as WorkflowStatusResult, M as WorkflowStepConfigLike, N as WorkflowStepContextLike, O as WorkflowStepRollbackOptionsLike } from "./packem_shared/types.d-C7jti0tm.js";
3
3
  import { Validator } from '@lunora/values';
4
4
  import { LunoraError } from '@lunora/errors';
5
5
  /** Wiring info for one declared workflow, emitted by codegen into the generated shard. */
@@ -1,21 +1,46 @@
1
1
  import { ValidatorMap, InferValidatorMap, Validator } from '@lunora/values';
2
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.
3
+ * The generated function-reference type, shared by every package that needs to
4
+ * infer a call's args or return from `api.<file>.<fn>`.
7
5
  *
8
- * The runtime identifier lives in `__lunoraRef` this MUST stay in lockstep
9
- * with the codegen emit + `@lunora/client`'s `FunctionReference`.
6
+ * This lives in `shared/` rather than in one package because the consumers span
7
+ * a dependency boundary they must not cross: `@lunora/scheduler` and
8
+ * `@lunora/workflow` accept a reference in `runAfter`/`runAt`/`step.run*` but
9
+ * cannot depend on `@lunora/client`, which is a browser package. Each of them
10
+ * previously hand-copied this declaration, and both copies silently rotted when
11
+ * the phantom carrier was renamed — the conditional matched an OPTIONAL property
12
+ * that no longer existed, so `ArgsOf<F>` quietly resolved to `unknown` and every
13
+ * `step.run(ref, args)` in the repo lost its arg checking without a single error.
14
+ *
15
+ * `shared/` is the repo's answer to exactly that shape: bundler-inlined,
16
+ * zero-dependency source imported by relative path, so it creates no runtime
17
+ * edge between the packages that inline it. Being ONE declaration, there is
18
+ * nothing to keep in lockstep and no drift test to write.
19
+ */
20
+ /** The registered function kinds a {@link FunctionReference} can describe. `stream` is a query that yields multiple frames over the WS. */
21
+ type FunctionKind = "action" | "mutation" | "query" | "stream";
22
+ /**
23
+ * Opaque reference to a registered function emitted by `@lunora/codegen`.
24
+ *
25
+ * At runtime it carries the `<file>:<function>` identifier in `__lunoraRef`.
26
+ * Generated declarations decorate this with phantom type parameters so callers
27
+ * can infer args / return values per call site.
10
28
  */
11
- interface FunctionReference {
29
+ interface FunctionReference<Kind extends FunctionKind = FunctionKind, Args = unknown, Return = unknown> {
30
+ /**
31
+ * Phantom marker carrying the `Kind`/`Args`/`Return` type parameters for
32
+ * inference. Never present at runtime; declared as a covariant (output)
33
+ * position so a concrete reference stays assignable to a widened one.
34
+ */
35
+ readonly __lunoraPhantom?: {
36
+ args: Args;
37
+ kind: Kind;
38
+ returns: Return;
39
+ };
12
40
  readonly __lunoraRef: string;
13
- /** Marker phantom type — discriminates queries / mutations / actions. */
14
- readonly _kind?: "query" | "mutation" | "action";
15
41
  }
16
- type ArgsOf<F extends FunctionReference> = F extends {
17
- _args?: infer A;
18
- } ? A : Record<string, unknown>;
42
+ /** Extract the args type from a {@link FunctionReference}. */
43
+ type ArgsOf<F> = F extends FunctionReference<infer _K, infer A, infer _R> ? A : never;
19
44
  /** A workflow instance's lifecycle status. Mirrors `WorkflowInstanceStatus`. */
20
45
  type WorkflowInstanceStatus = "complete" | "errored" | "paused" | "queued" | "running" | "terminated" | "unknown" | "waiting" | "waitingForPause";
21
46
  /** Result of `WorkflowInstance.status()`. Mirrors Cloudflare's `InstanceStatus`. */
@@ -494,4 +519,4 @@ interface LunoraWorkflowsOptions {
494
519
  */
495
520
  bindings: Record<string, WorkflowBindingLike>;
496
521
  }
497
- export { ArgsOf as A, BranchCompensationParams as B, WorkflowParallelFunction as C, WorkflowRollbackContextLike as D, WorkflowRollbackHandlerLike as E, FunctionReference as F, WorkflowSpawnFunction as G, WorkflowSpawnOptions as H, InferStepArgs as I, WorkflowStatusResult as J, WorkflowStepConfigLike as K, LunoraWorkflowsOptions as L, WorkflowStepContextLike as M, WorkflowStepRollbackOptionsLike as N, RunFunctionOptions as R, StepArgsValidator as S, WorkflowDefinition as W, Workflows as a, WorkflowEventDefinition as b, StepConfig as c, StepDefinition as d, WorkflowConfig as e, WorkflowBranch as f, WorkflowInstanceStatus as g, WorkflowEventLike as h, WorkflowStepLike as i, WorkflowRunContext as j, WorkflowLogger as k, WorkflowRunFunction as l, WorkflowRunStepFunction as m, WorkflowWaitForEventFunction as n, RunStepOptions as o, StepHandler as p, StepRollbackContext as q, StepRollbackHandler as r, StepRunContext as s, WaitForEventOptions as t, WorkflowBindingLike as u, WorkflowBranchOutputs as v, WorkflowCreateOptions as w, WorkflowHandle as x, WorkflowHandler as y, WorkflowInstanceLike as z };
522
+ export { ArgsOf as A, BranchCompensationParams as B, WorkflowInstanceLike as C, WorkflowParallelFunction as D, WorkflowRollbackContextLike as E, FunctionKind as F, WorkflowRollbackHandlerLike as G, WorkflowSpawnFunction as H, InferStepArgs as I, WorkflowSpawnOptions as J, WorkflowStatusResult as K, LunoraWorkflowsOptions as L, WorkflowStepConfigLike as M, WorkflowStepContextLike as N, WorkflowStepRollbackOptionsLike as O, RunFunctionOptions as R, StepArgsValidator as S, WorkflowDefinition as W, Workflows as a, WorkflowEventDefinition as b, StepConfig as c, StepDefinition as d, WorkflowConfig as e, WorkflowBranch as f, WorkflowInstanceStatus as g, WorkflowEventLike as h, WorkflowStepLike as i, WorkflowRunContext as j, WorkflowLogger as k, WorkflowRunFunction as l, WorkflowRunStepFunction as m, WorkflowWaitForEventFunction as n, FunctionReference as o, RunStepOptions as p, StepHandler as q, StepRollbackContext as r, StepRollbackHandler as s, StepRunContext as t, WaitForEventOptions as u, WorkflowBindingLike as v, WorkflowBranchOutputs as w, WorkflowCreateOptions as x, WorkflowHandle as y, WorkflowHandler as z };
@@ -1,21 +1,46 @@
1
1
  import { ValidatorMap, InferValidatorMap, Validator } from '@lunora/values';
2
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.
3
+ * The generated function-reference type, shared by every package that needs to
4
+ * infer a call's args or return from `api.<file>.<fn>`.
7
5
  *
8
- * The runtime identifier lives in `__lunoraRef` this MUST stay in lockstep
9
- * with the codegen emit + `@lunora/client`'s `FunctionReference`.
6
+ * This lives in `shared/` rather than in one package because the consumers span
7
+ * a dependency boundary they must not cross: `@lunora/scheduler` and
8
+ * `@lunora/workflow` accept a reference in `runAfter`/`runAt`/`step.run*` but
9
+ * cannot depend on `@lunora/client`, which is a browser package. Each of them
10
+ * previously hand-copied this declaration, and both copies silently rotted when
11
+ * the phantom carrier was renamed — the conditional matched an OPTIONAL property
12
+ * that no longer existed, so `ArgsOf<F>` quietly resolved to `unknown` and every
13
+ * `step.run(ref, args)` in the repo lost its arg checking without a single error.
14
+ *
15
+ * `shared/` is the repo's answer to exactly that shape: bundler-inlined,
16
+ * zero-dependency source imported by relative path, so it creates no runtime
17
+ * edge between the packages that inline it. Being ONE declaration, there is
18
+ * nothing to keep in lockstep and no drift test to write.
19
+ */
20
+ /** The registered function kinds a {@link FunctionReference} can describe. `stream` is a query that yields multiple frames over the WS. */
21
+ type FunctionKind = "action" | "mutation" | "query" | "stream";
22
+ /**
23
+ * Opaque reference to a registered function emitted by `@lunora/codegen`.
24
+ *
25
+ * At runtime it carries the `<file>:<function>` identifier in `__lunoraRef`.
26
+ * Generated declarations decorate this with phantom type parameters so callers
27
+ * can infer args / return values per call site.
10
28
  */
11
- interface FunctionReference {
29
+ interface FunctionReference<Kind extends FunctionKind = FunctionKind, Args = unknown, Return = unknown> {
30
+ /**
31
+ * Phantom marker carrying the `Kind`/`Args`/`Return` type parameters for
32
+ * inference. Never present at runtime; declared as a covariant (output)
33
+ * position so a concrete reference stays assignable to a widened one.
34
+ */
35
+ readonly __lunoraPhantom?: {
36
+ args: Args;
37
+ kind: Kind;
38
+ returns: Return;
39
+ };
12
40
  readonly __lunoraRef: string;
13
- /** Marker phantom type — discriminates queries / mutations / actions. */
14
- readonly _kind?: "query" | "mutation" | "action";
15
41
  }
16
- type ArgsOf<F extends FunctionReference> = F extends {
17
- _args?: infer A;
18
- } ? A : Record<string, unknown>;
42
+ /** Extract the args type from a {@link FunctionReference}. */
43
+ type ArgsOf<F> = F extends FunctionReference<infer _K, infer A, infer _R> ? A : never;
19
44
  /** A workflow instance's lifecycle status. Mirrors `WorkflowInstanceStatus`. */
20
45
  type WorkflowInstanceStatus = "complete" | "errored" | "paused" | "queued" | "running" | "terminated" | "unknown" | "waiting" | "waitingForPause";
21
46
  /** Result of `WorkflowInstance.status()`. Mirrors Cloudflare's `InstanceStatus`. */
@@ -494,4 +519,4 @@ interface LunoraWorkflowsOptions {
494
519
  */
495
520
  bindings: Record<string, WorkflowBindingLike>;
496
521
  }
497
- export { ArgsOf as A, BranchCompensationParams as B, WorkflowParallelFunction as C, WorkflowRollbackContextLike as D, WorkflowRollbackHandlerLike as E, FunctionReference as F, WorkflowSpawnFunction as G, WorkflowSpawnOptions as H, InferStepArgs as I, WorkflowStatusResult as J, WorkflowStepConfigLike as K, LunoraWorkflowsOptions as L, WorkflowStepContextLike as M, WorkflowStepRollbackOptionsLike as N, RunFunctionOptions as R, StepArgsValidator as S, WorkflowDefinition as W, Workflows as a, WorkflowEventDefinition as b, StepConfig as c, StepDefinition as d, WorkflowConfig as e, WorkflowBranch as f, WorkflowInstanceStatus as g, WorkflowEventLike as h, WorkflowStepLike as i, WorkflowRunContext as j, WorkflowLogger as k, WorkflowRunFunction as l, WorkflowRunStepFunction as m, WorkflowWaitForEventFunction as n, RunStepOptions as o, StepHandler as p, StepRollbackContext as q, StepRollbackHandler as r, StepRunContext as s, WaitForEventOptions as t, WorkflowBindingLike as u, WorkflowBranchOutputs as v, WorkflowCreateOptions as w, WorkflowHandle as x, WorkflowHandler as y, WorkflowInstanceLike as z };
522
+ export { ArgsOf as A, BranchCompensationParams as B, WorkflowInstanceLike as C, WorkflowParallelFunction as D, WorkflowRollbackContextLike as E, FunctionKind as F, WorkflowRollbackHandlerLike as G, WorkflowSpawnFunction as H, InferStepArgs as I, WorkflowSpawnOptions as J, WorkflowStatusResult as K, LunoraWorkflowsOptions as L, WorkflowStepConfigLike as M, WorkflowStepContextLike as N, WorkflowStepRollbackOptionsLike as O, RunFunctionOptions as R, StepArgsValidator as S, WorkflowDefinition as W, Workflows as a, WorkflowEventDefinition as b, StepConfig as c, StepDefinition as d, WorkflowConfig as e, WorkflowBranch as f, WorkflowInstanceStatus as g, WorkflowEventLike as h, WorkflowStepLike as i, WorkflowRunContext as j, WorkflowLogger as k, WorkflowRunFunction as l, WorkflowRunStepFunction as m, WorkflowWaitForEventFunction as n, FunctionReference as o, RunStepOptions as p, StepHandler as q, StepRollbackContext as r, StepRollbackHandler as s, StepRunContext as t, WaitForEventOptions as u, WorkflowBindingLike as v, WorkflowBranchOutputs as w, WorkflowCreateOptions as x, WorkflowHandle as y, WorkflowHandler as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/workflow",
3
- "version": "1.0.0-alpha.39",
3
+ "version": "1.0.0-alpha.40",
4
4
  "description": "Durable workflows for Lunora: defineWorkflow over Cloudflare Workflows, generated WorkflowEntrypoint classes, and the ctx.workflows surface",
5
5
  "keywords": [
6
6
  "cloudflare",