@lunora/workflow 1.0.0-alpha.5 → 1.0.0-alpha.7

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 CHANGED
@@ -103,3 +103,9 @@ Unless required by applicable law or agreed to in writing, software distributed
103
103
  under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
104
104
  CONDITIONS OF ANY KIND, either express or implied. See the License for the
105
105
  specific language governing permissions and limitations under the License.
106
+
107
+ <!-- DEPENDENCIES -->
108
+ <!-- /DEPENDENCIES -->
109
+
110
+ <!-- TYPE_DEPENDENCIES -->
111
+ <!-- /TYPE_DEPENDENCIES -->
package/dist/do/index.mjs CHANGED
@@ -2,7 +2,7 @@ import { WorkflowEntrypoint } from 'cloudflare:workers';
2
2
  import { NonRetryableError } from 'cloudflare:workflows';
3
3
  import { convertNonRetryableError } from '../packem_shared/NonRetryableError-Dn2dTyBS.mjs';
4
4
  import { stripBranchMarker, signalBranchParent, extractBranchMarker, errorOutcome, okOutcome } from '../packem_shared/MAX_BRANCHES-D6cQabJ1.mjs';
5
- import { createWorkflowRunContext } from '../packem_shared/createWorkflowRunContext-CYI9SeI9.mjs';
5
+ import { createWorkflowRunContext } from '../packem_shared/createWorkflowRunContext-C09mSbgk.mjs';
6
6
 
7
7
  class LunoraWorkflow extends WorkflowEntrypoint {
8
8
  /** The `lunora/workflows.ts` export name, for log correlation. */
package/dist/index.d.mts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { a as Workflows, L as LunoraWorkflowsOptions, S as StepArgsValidator, b as StepConfig, c as StepDefinition, d as WorkflowConfig, W as WorkflowDefinition, e as WorkflowBranch, f as WorkflowInstanceStatus, g as WorkflowEventLike, h as WorkflowStepLike, i as WorkflowRunContext, j as WorkflowLogger, k as WorkflowRunFunction, l as WorkflowRunStepFunction } from "./packem_shared/types.d-C9W6rEWv.mjs";
2
2
  export type { A as ArgsOf, B as BranchCompensationParams, F as FunctionReference, I as InferStepArgs, R as RunFunctionOptions, m as RunStepOptions, n as StepHandler, o as StepRollbackContext, p as StepRollbackHandler, q as StepRunContext, r as WorkflowBindingLike, s as WorkflowBranchOutputs, t as WorkflowCreateOptions, u as WorkflowHandle, v as WorkflowHandler, w as WorkflowInstanceLike, x as WorkflowParallelFunction, y as WorkflowRollbackContextLike, z as WorkflowRollbackHandlerLike, C as WorkflowSpawnFunction, D as WorkflowSpawnOptions, E as WorkflowStatusResult, G as WorkflowStepConfigLike, H as WorkflowStepContextLike, J as WorkflowStepRollbackOptionsLike } from "./packem_shared/types.d-C9W6rEWv.mjs";
3
+ import { LunoraError } from '@lunora/errors';
3
4
  import '@lunora/values';
4
5
  /** Wiring info for one declared workflow, emitted by codegen into the generated shard. */
5
6
  interface WorkflowBindingSpec {
@@ -194,8 +195,7 @@ interface WorkflowInstancePage {
194
195
  totalCount?: number;
195
196
  }
196
197
  /** Thrown when the REST API responds non-2xx or `success: false`; carries the status plus body for the caller to surface. */
197
- declare class WorkflowsRestError extends Error {
198
- readonly status: number;
198
+ declare class WorkflowsRestError extends LunoraError {
199
199
  constructor(status: number, body: string);
200
200
  }
201
201
  /** The observe client: list instances, read one instance's steps, and (with Edit scope) mutate its status. */
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { a as Workflows, L as LunoraWorkflowsOptions, S as StepArgsValidator, b as StepConfig, c as StepDefinition, d as WorkflowConfig, W as WorkflowDefinition, e as WorkflowBranch, f as WorkflowInstanceStatus, g as WorkflowEventLike, h as WorkflowStepLike, i as WorkflowRunContext, j as WorkflowLogger, k as WorkflowRunFunction, l as WorkflowRunStepFunction } from "./packem_shared/types.d-C9W6rEWv.js";
2
2
  export type { A as ArgsOf, B as BranchCompensationParams, F as FunctionReference, I as InferStepArgs, R as RunFunctionOptions, m as RunStepOptions, n as StepHandler, o as StepRollbackContext, p as StepRollbackHandler, q as StepRunContext, r as WorkflowBindingLike, s as WorkflowBranchOutputs, t as WorkflowCreateOptions, u as WorkflowHandle, v as WorkflowHandler, w as WorkflowInstanceLike, x as WorkflowParallelFunction, y as WorkflowRollbackContextLike, z as WorkflowRollbackHandlerLike, C as WorkflowSpawnFunction, D as WorkflowSpawnOptions, E as WorkflowStatusResult, G as WorkflowStepConfigLike, H as WorkflowStepContextLike, J as WorkflowStepRollbackOptionsLike } from "./packem_shared/types.d-C9W6rEWv.js";
3
+ import { LunoraError } from '@lunora/errors';
3
4
  import '@lunora/values';
4
5
  /** Wiring info for one declared workflow, emitted by codegen into the generated shard. */
5
6
  interface WorkflowBindingSpec {
@@ -194,8 +195,7 @@ interface WorkflowInstancePage {
194
195
  totalCount?: number;
195
196
  }
196
197
  /** Thrown when the REST API responds non-2xx or `success: false`; carries the status plus body for the caller to surface. */
197
- declare class WorkflowsRestError extends Error {
198
- readonly status: number;
198
+ declare class WorkflowsRestError extends LunoraError {
199
199
  constructor(status: number, body: string);
200
200
  }
201
201
  /** The observe client: list instances, read one instance's steps, and (with Edit scope) mutate its status. */
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
- export { createWorkflowContext } from './packem_shared/createWorkflowContext-D6thzmlF.mjs';
2
- export { default as createWorkflows } from './packem_shared/createWorkflows-BoSYVIXg.mjs';
1
+ export { createWorkflowContext } from './packem_shared/createWorkflowContext-DfSgBq5I.mjs';
2
+ export { default as createWorkflows } from './packem_shared/createWorkflows-BC1Mwjwe.mjs';
3
3
  export { defineStep, isStepDefinition } from './packem_shared/defineStep-DJQtLw7g.mjs';
4
4
  export { defineWorkflow, isWorkflowDefinition, workflowBindingName, workflowClassName, workflowDefaultName } from './packem_shared/defineWorkflow-DbUC-oCN.mjs';
5
5
  export { NonRetryableError, convertNonRetryableError, isNonRetryableError, toNativeNonRetryableError } from './packem_shared/NonRetryableError-Dn2dTyBS.mjs';
6
6
  export { MAX_BRANCHES, branch } from './packem_shared/MAX_BRANCHES-D6cQabJ1.mjs';
7
- export { WorkflowsRestError, createWorkflowsRestClient } from './packem_shared/WorkflowsRestError-b06i7K5j.mjs';
8
- export { createWorkflowRunContext } from './packem_shared/createWorkflowRunContext-CYI9SeI9.mjs';
7
+ export { WorkflowsRestError, createWorkflowsRestClient } from './packem_shared/WorkflowsRestError-zmjOxTR1.mjs';
8
+ export { createWorkflowRunContext } from './packem_shared/createWorkflowRunContext-C09mSbgk.mjs';
9
9
  export { createRunStep, validateStepArgs } from './packem_shared/createRunStep-8jOXxP2o.mjs';
@@ -1,3 +1,5 @@
1
+ import { LunoraError } from '@lunora/errors';
2
+
1
3
  const API_BASE = "https://api.cloudflare.com/client/v4/accounts";
2
4
  const KNOWN_STATUSES = {
3
5
  complete: true,
@@ -41,12 +43,9 @@ const toStep = (raw) => {
41
43
  type: asString(raw["type"])
42
44
  };
43
45
  };
44
- class WorkflowsRestError extends Error {
45
- status;
46
+ class WorkflowsRestError extends LunoraError {
46
47
  constructor(status, body) {
47
- super(`Cloudflare Workflows REST API returned ${String(status)}: ${body}`);
48
- this.name = "WorkflowsRestError";
49
- this.status = status;
48
+ super("WORKFLOWS_REST_ERROR", `Cloudflare Workflows REST API returned ${String(status)}: ${body}`, { name: "WorkflowsRestError", status });
50
49
  }
51
50
  }
52
51
  const createWorkflowsRestClient = (config) => {
@@ -1,4 +1,4 @@
1
- import createWorkflows from './createWorkflows-BoSYVIXg.mjs';
1
+ import createWorkflows from './createWorkflows-BC1Mwjwe.mjs';
2
2
 
3
3
  const createWorkflowContext = (env, specs) => {
4
4
  const bindings = {};
@@ -1,3 +1,4 @@
1
+ import { LunoraError } from '@lunora/errors';
1
2
  import { workflowBindingName } from './defineWorkflow-DbUC-oCN.mjs';
2
3
  import { createSpawn, createParallel } from './MAX_BRANCHES-D6cQabJ1.mjs';
3
4
  import { createRunStep } from './createRunStep-8jOXxP2o.mjs';
@@ -37,11 +38,11 @@ const createDispatchRunner = (options) => {
37
38
  }
38
39
  const origin = options.env.LUNORA_ORIGIN_URL;
39
40
  if (typeof origin !== "string" || origin.length === 0) {
40
- throw new Error(`${label}: \`LUNORA_ORIGIN_URL\` must be set on the Worker env so a handler can call back into Lunora functions`);
41
+ throw new LunoraError("INTERNAL", `${label}: \`LUNORA_ORIGIN_URL\` must be set on the Worker env so a handler can call back into Lunora functions`);
41
42
  }
42
43
  const token = options.env.LUNORA_ADMIN_TOKEN;
43
44
  if (typeof token !== "string" || token.length === 0) {
44
- throw new Error(`${label}: \`LUNORA_ADMIN_TOKEN\` must be set on the Worker env to authenticate function dispatch`);
45
+ throw new LunoraError("INTERNAL", `${label}: \`LUNORA_ADMIN_TOKEN\` must be set on the Worker env to authenticate function dispatch`);
45
46
  }
46
47
  const url = `${trimTrailingSlashes(origin)}${SCHEDULER_DISPATCH_PATH}`;
47
48
  const response = await fetchImpl(url, {
@@ -50,7 +51,7 @@ const createDispatchRunner = (options) => {
50
51
  method: "POST"
51
52
  });
52
53
  if (!response.ok) {
53
- throw new Error(`${label}: function dispatch failed (${String(response.status)}): ${await response.text()}`);
54
+ throw new LunoraError("INTERNAL", `${label}: function dispatch failed (${String(response.status)}): ${await response.text()}`);
54
55
  }
55
56
  const text = await response.text();
56
57
  if (text.length === 0) {
@@ -71,7 +72,8 @@ const createWorkflowRunContext = (options) => {
71
72
  const bindingName = workflowBindingName(workflow);
72
73
  const binding = options.env[bindingName];
73
74
  if (!binding || typeof binding.create !== "function" || typeof binding.get !== "function") {
74
- throw new Error(
75
+ throw new LunoraError(
76
+ "INTERNAL",
75
77
  `@lunora/workflow: cannot spawn child workflow "${workflow}" — no Workflow binding "${bindingName}" on env (is it declared in lunora/workflows.ts?)`
76
78
  );
77
79
  }
@@ -1,3 +1,5 @@
1
+ import { LunoraError } from '@lunora/errors';
2
+
1
3
  const handleFor = (binding) => {
2
4
  return {
3
5
  create: async (options) => binding.create(options),
@@ -13,7 +15,7 @@ const createWorkflows = (options) => {
13
15
  if (binding === void 0) {
14
16
  const known = Object.keys(bindings);
15
17
  const suffix = known.length === 0 ? "no workflows are declared" : `known workflows: ${known.join(", ")}`;
16
- throw new Error(`@lunora/workflow: no workflow named "${name}" (${suffix})`);
18
+ throw new LunoraError("INTERNAL", `@lunora/workflow: no workflow named "${name}" (${suffix})`);
17
19
  }
18
20
  return handleFor(binding);
19
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/workflow",
3
- "version": "1.0.0-alpha.5",
3
+ "version": "1.0.0-alpha.7",
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",
@@ -48,7 +48,8 @@
48
48
  "access": "public"
49
49
  },
50
50
  "dependencies": {
51
- "@lunora/values": "1.0.0-alpha.3"
51
+ "@lunora/errors": "1.0.0-alpha.2",
52
+ "@lunora/values": "1.0.0-alpha.5"
52
53
  },
53
54
  "engines": {
54
55
  "node": "^22.15.0 || >=24.11.0"