@lunora/workflow 1.0.0-alpha.6 → 1.0.0-alpha.61

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.
Files changed (36) hide show
  1. package/LICENSE.md +6 -0
  2. package/README.md +25 -2
  3. package/dist/do/index.d.mts +16 -16
  4. package/dist/do/index.d.ts +16 -16
  5. package/dist/do/index.mjs +1 -44
  6. package/dist/index.d.mts +191 -122
  7. package/dist/index.d.ts +191 -122
  8. package/dist/index.mjs +1 -9
  9. package/dist/packem_shared/MAX_BRANCHES-j59ZUUSu.mjs +1 -0
  10. package/dist/packem_shared/NonRetryableError-BPu01mU8.mjs +1 -0
  11. package/dist/packem_shared/WorkflowsRestError-Ccq1FUR1.mjs +1 -0
  12. package/dist/packem_shared/branch-marker-CCpWfS5k.mjs +1 -0
  13. package/dist/packem_shared/createRunStep-DITrH01N.mjs +1 -0
  14. package/dist/packem_shared/createWaitForEvent-D5Ohn2Pz.mjs +1 -0
  15. package/dist/packem_shared/createWorkflowContext-zQR_9N-v.mjs +1 -0
  16. package/dist/packem_shared/createWorkflowRunContext-Dk5nhB1e.mjs +1 -0
  17. package/dist/packem_shared/createWorkflows-LvAyUyKq.mjs +1 -0
  18. package/dist/packem_shared/defineStep-D1-9eOnA.mjs +1 -0
  19. package/dist/packem_shared/defineWorkflow-tKaIifbZ.mjs +1 -0
  20. package/dist/packem_shared/defineWorkflowEvent-suERPEEV.mjs +1 -0
  21. package/dist/packem_shared/isDuplicateInstanceError-CecnqNAa.mjs +1 -0
  22. package/dist/packem_shared/run-step-bKFJhP--.mjs +1 -0
  23. package/dist/packem_shared/types.d-DKvSidAr.d.mts +560 -0
  24. package/dist/packem_shared/types.d-DKvSidAr.d.ts +560 -0
  25. package/package.json +3 -3
  26. package/dist/packem_shared/MAX_BRANCHES-D6cQabJ1.mjs +0 -132
  27. package/dist/packem_shared/NonRetryableError-Dn2dTyBS.mjs +0 -27
  28. package/dist/packem_shared/WorkflowsRestError-zmjOxTR1.mjs +0 -117
  29. package/dist/packem_shared/createRunStep-8jOXxP2o.mjs +0 -54
  30. package/dist/packem_shared/createWorkflowContext-DfSgBq5I.mjs +0 -14
  31. package/dist/packem_shared/createWorkflowRunContext-C09mSbgk.mjs +0 -112
  32. package/dist/packem_shared/createWorkflows-BC1Mwjwe.mjs +0 -25
  33. package/dist/packem_shared/defineStep-DJQtLw7g.mjs +0 -28
  34. package/dist/packem_shared/defineWorkflow-DbUC-oCN.mjs +0 -15
  35. package/dist/packem_shared/types.d-C9W6rEWv.d.mts +0 -425
  36. package/dist/packem_shared/types.d-C9W6rEWv.d.ts +0 -425
@@ -1,132 +0,0 @@
1
- import { NonRetryableError } from './NonRetryableError-Dn2dTyBS.mjs';
2
-
3
- const MAX_BRANCHES = 100;
4
- const BRANCH_MARKER_KEY = "__lunoraBranch";
5
- const SPAWN_STEP_PREFIX = "lunora:spawn:";
6
- const AWAIT_STEP_PREFIX = "lunora:await:";
7
- const SIGNAL_STEP_PREFIX = "lunora:signal:";
8
- const COMPENSATE_STEP_PREFIX = "lunora:compensate:";
9
- const BRANCH_EVENT_PREFIX = "lunora:branch:";
10
- const branch = (workflow, params, options) => {
11
- return { compensateWith: options?.compensateWith, id: options?.id, params, timeout: options?.timeout, workflow };
12
- };
13
- const serializeError = (error) => {
14
- if (error instanceof Error) {
15
- return { message: error.message, name: error.name };
16
- }
17
- return { message: String(error), name: "Error" };
18
- };
19
- const okOutcome = (value) => {
20
- return { status: "ok", value };
21
- };
22
- const errorOutcome = (error) => {
23
- return { error: serializeError(error), status: "error" };
24
- };
25
- const compensateCompleted = async (deps, completed, error) => {
26
- for (let cursor = completed.length - 1; cursor >= 0; cursor -= 1) {
27
- const done = completed[cursor];
28
- const compensateWith = done?.plan.item.compensateWith;
29
- if (done === void 0 || compensateWith === void 0) {
30
- continue;
31
- }
32
- await deps.step.do(`${COMPENSATE_STEP_PREFIX}${done.plan.childId}`, async () => {
33
- const compensateId = `${done.plan.childId}:compensate`;
34
- const compensationParams = {
35
- branch: done.plan.item.workflow,
36
- error,
37
- index: done.plan.index,
38
- output: done.output
39
- };
40
- await deps.resolveBinding(compensateWith).create({ id: compensateId, params: compensationParams });
41
- return compensateId;
42
- });
43
- }
44
- };
45
- const createParallel = (deps) => {
46
- const run = async (branches) => {
47
- if (branches.length === 0) {
48
- return [];
49
- }
50
- if (branches.length > MAX_BRANCHES) {
51
- throw new NonRetryableError(
52
- `ctx.parallel: ${String(branches.length)} branches exceeds the cap of ${String(MAX_BRANCHES)} — split the fan-out or raise the work into fewer child workflows`
53
- );
54
- }
55
- const planned = branches.map((item, index) => {
56
- const childId = deps.nextChildId(item.id);
57
- return { childId, eventType: `${BRANCH_EVENT_PREFIX}${childId}`, index, item };
58
- });
59
- await Promise.all(
60
- planned.map(
61
- (plan) => deps.step.do(`${SPAWN_STEP_PREFIX}${plan.childId}`, async () => {
62
- const binding = deps.resolveBinding(plan.item.workflow);
63
- const marker = { eventType: plan.eventType, index: plan.index, parentBinding: deps.parentBinding, parentId: deps.instanceId };
64
- await binding.create({ id: plan.childId, params: { ...plan.item.params, [BRANCH_MARKER_KEY]: marker } });
65
- return plan.childId;
66
- })
67
- )
68
- );
69
- const results = [];
70
- const completed = [];
71
- for (const plan of planned) {
72
- const event = await deps.step.waitForEvent(`${AWAIT_STEP_PREFIX}${plan.childId}`, {
73
- timeout: plan.item.timeout,
74
- type: plan.eventType
75
- });
76
- const outcome = event.payload;
77
- if (outcome.status === "error") {
78
- await compensateCompleted(deps, completed, outcome.error);
79
- throw new NonRetryableError(`ctx.parallel: branch "${plan.item.workflow}" (#${String(plan.index)}) failed: ${outcome.error.message}`);
80
- }
81
- completed.push({ output: outcome.value, plan });
82
- results.push(outcome.value);
83
- }
84
- return results;
85
- };
86
- return run;
87
- };
88
- const createSpawn = (deps) => async (workflow, params, options) => {
89
- const childId = deps.nextChildId(options?.id);
90
- await deps.step.do(`${SPAWN_STEP_PREFIX}${childId}`, async () => {
91
- const binding = deps.resolveBinding(workflow);
92
- await binding.create({ id: childId, params });
93
- return childId;
94
- });
95
- return deps.resolveBinding(workflow).get(childId);
96
- };
97
- const extractBranchMarker = (payload) => {
98
- if (typeof payload !== "object" || payload === null) {
99
- return void 0;
100
- }
101
- const marker = payload[BRANCH_MARKER_KEY];
102
- if (typeof marker !== "object" || marker === null) {
103
- return void 0;
104
- }
105
- const candidate = marker;
106
- if (typeof candidate.eventType !== "string" || typeof candidate.parentBinding !== "string" || typeof candidate.parentId !== "string" || typeof candidate.index !== "number") {
107
- return void 0;
108
- }
109
- return { eventType: candidate.eventType, index: candidate.index, parentBinding: candidate.parentBinding, parentId: candidate.parentId };
110
- };
111
- const stripBranchMarker = (payload) => {
112
- if (typeof payload !== "object" || payload === null) {
113
- return payload;
114
- }
115
- const rest = { ...payload };
116
- Reflect.deleteProperty(rest, BRANCH_MARKER_KEY);
117
- return rest;
118
- };
119
- const signalBranchParent = async (deps, marker, outcome) => {
120
- const binding = deps.env[marker.parentBinding];
121
- if (!binding || typeof binding.get !== "function") {
122
- return;
123
- }
124
- const getParent = binding.get.bind(binding);
125
- await deps.step.do(`${SIGNAL_STEP_PREFIX}${String(marker.index)}`, async () => {
126
- const parent = await getParent(marker.parentId);
127
- await parent.sendEvent({ payload: outcome, type: marker.eventType });
128
- return marker.eventType;
129
- });
130
- };
131
-
132
- export { BRANCH_MARKER_KEY, MAX_BRANCHES, branch, createParallel, createSpawn, errorOutcome, extractBranchMarker, okOutcome, signalBranchParent, stripBranchMarker };
@@ -1,27 +0,0 @@
1
- const NON_RETRYABLE_BRAND = "__lunoraNonRetryable";
2
- class NonRetryableError extends Error {
3
- constructor(message, name = "NonRetryableError") {
4
- super(message);
5
- this.name = name;
6
- this[NON_RETRYABLE_BRAND] = true;
7
- }
8
- }
9
- const isNonRetryableError = (value) => value instanceof Error && value[NON_RETRYABLE_BRAND] === true;
10
- const toNativeNonRetryableError = (error, NativeNonRetryableError) => {
11
- const native = new NativeNonRetryableError(error.message, error.name);
12
- if (error.stack !== void 0) {
13
- native.stack = error.stack;
14
- }
15
- if (error.cause !== void 0 && native.cause === void 0) {
16
- native.cause = error.cause;
17
- }
18
- return native;
19
- };
20
- const convertNonRetryableError = (error, NativeNonRetryableError) => {
21
- if (NativeNonRetryableError !== void 0 && isNonRetryableError(error)) {
22
- throw toNativeNonRetryableError(error, NativeNonRetryableError);
23
- }
24
- throw error;
25
- };
26
-
27
- export { NonRetryableError, convertNonRetryableError, isNonRetryableError, toNativeNonRetryableError };
@@ -1,117 +0,0 @@
1
- import { LunoraError } from '@lunora/errors';
2
-
3
- const API_BASE = "https://api.cloudflare.com/client/v4/accounts";
4
- const KNOWN_STATUSES = {
5
- complete: true,
6
- errored: true,
7
- paused: true,
8
- queued: true,
9
- running: true,
10
- terminated: true,
11
- unknown: true,
12
- waiting: true,
13
- waitingForPause: true
14
- };
15
- const toStatus = (value) => typeof value === "string" && Object.hasOwn(KNOWN_STATUSES, value) ? value : "unknown";
16
- const asString = (value) => typeof value === "string" && value !== "" ? value : void 0;
17
- const stringOr = (value, fallback) => typeof value === "string" ? value : fallback;
18
- const asBoolean = (value) => typeof value === "boolean" ? value : void 0;
19
- const countAttempts = (value) => {
20
- if (Array.isArray(value)) {
21
- return value.length;
22
- }
23
- return typeof value === "number" ? value : void 0;
24
- };
25
- const toSummary = (raw) => {
26
- return {
27
- createdOn: asString(raw["created_on"]),
28
- endedOn: asString(raw["ended_on"]),
29
- id: stringOr(raw["id"], ""),
30
- startedOn: asString(raw["started_on"]),
31
- status: toStatus(raw["status"])
32
- };
33
- };
34
- const toStep = (raw) => {
35
- return {
36
- attempts: countAttempts(raw["attempts"]),
37
- end: asString(raw["end"]),
38
- error: raw["error"],
39
- name: stringOr(raw["name"], ""),
40
- output: raw["output"],
41
- start: asString(raw["start"]),
42
- success: asBoolean(raw["success"]),
43
- type: asString(raw["type"])
44
- };
45
- };
46
- class WorkflowsRestError extends LunoraError {
47
- constructor(status, body) {
48
- super("WORKFLOWS_REST_ERROR", `Cloudflare Workflows REST API returned ${String(status)}: ${body}`, { name: "WorkflowsRestError", status });
49
- }
50
- }
51
- const createWorkflowsRestClient = (config) => {
52
- const fetchImpl = config.fetch ?? globalThis.fetch.bind(globalThis);
53
- const base = `${API_BASE}/${config.accountId}/workflows`;
54
- const request = async (path, init) => {
55
- const response = await fetchImpl(`${base}${path}`, {
56
- ...init,
57
- headers: { Authorization: `Bearer ${config.apiToken}`, "Content-Type": "application/json" }
58
- });
59
- const text = await response.text();
60
- let body;
61
- try {
62
- body = JSON.parse(text);
63
- } catch {
64
- throw new WorkflowsRestError(response.status, text);
65
- }
66
- if (!response.ok || body["success"] === false) {
67
- throw new WorkflowsRestError(response.status, text);
68
- }
69
- return body;
70
- };
71
- return {
72
- getInstance: async ({ instanceId, workflowName }) => {
73
- const body = await request(`/${encodeURIComponent(workflowName)}/instances/${encodeURIComponent(instanceId)}`);
74
- const result = body["result"] ?? {};
75
- const steps = Array.isArray(result["steps"]) ? result["steps"] : [];
76
- return {
77
- ...toSummary(result),
78
- error: result["error"],
79
- output: result["output"],
80
- params: result["params"],
81
- steps: steps.map((step) => toStep(step))
82
- };
83
- },
84
- listInstances: async ({ page, perPage, status, workflowName }) => {
85
- const query = new URLSearchParams();
86
- if (status !== void 0) {
87
- query.set("status", status);
88
- }
89
- if (page !== void 0) {
90
- query.set("page", String(page));
91
- }
92
- if (perPage !== void 0) {
93
- query.set("per_page", String(perPage));
94
- }
95
- const suffix = query.toString() === "" ? "" : `?${query.toString()}`;
96
- const body = await request(`/${encodeURIComponent(workflowName)}/instances${suffix}`);
97
- const result = Array.isArray(body["result"]) ? body["result"] : [];
98
- const info = body["result_info"] ?? {};
99
- return {
100
- instances: result.map((instance) => toSummary(instance)),
101
- page: typeof info["page"] === "number" ? info["page"] : page ?? 1,
102
- perPage: typeof info["per_page"] === "number" ? info["per_page"] : perPage ?? result.length,
103
- totalCount: typeof info["total_count"] === "number" ? info["total_count"] : void 0
104
- };
105
- },
106
- setInstanceStatus: async ({ action, instanceId, workflowName }) => {
107
- const body = await request(`/${encodeURIComponent(workflowName)}/instances/${encodeURIComponent(instanceId)}`, {
108
- body: JSON.stringify({ status: action }),
109
- method: "PATCH"
110
- });
111
- const result = body["result"] ?? {};
112
- return { status: toStatus(result["status"]) };
113
- }
114
- };
115
- };
116
-
117
- export { WorkflowsRestError, createWorkflowsRestClient };
@@ -1,54 +0,0 @@
1
- import { parseValidatorMap } from '@lunora/values';
2
- import { convertNonRetryableError, NonRetryableError } from './NonRetryableError-Dn2dTyBS.mjs';
3
-
4
- const validateStepArgs = (validators, source) => parseValidatorMap(validators, source, "step args");
5
- const createRunStep = (deps) => async (step, args, options) => {
6
- const config = options?.config ?? step.config;
7
- const validatedArgs = validateStepArgs(step.args, args);
8
- const callback = async (nativeContext) => {
9
- const stepContext = {
10
- attempt: nativeContext.attempt,
11
- config: nativeContext.config,
12
- env: deps.env,
13
- log: deps.log,
14
- run: deps.run,
15
- step: nativeContext.step
16
- };
17
- let result;
18
- try {
19
- result = await step.handler(stepContext, validatedArgs);
20
- } catch (error) {
21
- return convertNonRetryableError(error, deps.nonRetryableErrorClass);
22
- }
23
- if (!step.returns) {
24
- return result;
25
- }
26
- try {
27
- return step.returns.parse(result);
28
- } catch (error) {
29
- const message = error instanceof Error ? error.message : String(error);
30
- const nonRetryable = new NonRetryableError(`step "${step.name}" returns validation failed: ${message}`);
31
- if (error !== void 0) {
32
- nonRetryable.cause = error;
33
- }
34
- return convertNonRetryableError(nonRetryable, deps.nonRetryableErrorClass);
35
- }
36
- };
37
- const rollbackHandler = step.rollback;
38
- const rollbackOptions = rollbackHandler ? {
39
- rollback: async (rollbackContext) => {
40
- await rollbackHandler({
41
- args: validatedArgs,
42
- env: deps.env,
43
- error: rollbackContext.error,
44
- log: deps.log,
45
- output: rollbackContext.output,
46
- run: deps.run
47
- });
48
- },
49
- rollbackConfig: step.rollbackConfig
50
- } : void 0;
51
- return config === void 0 ? deps.step.do(step.name, callback, rollbackOptions) : deps.step.do(step.name, config, callback, rollbackOptions);
52
- };
53
-
54
- export { createRunStep, validateStepArgs };
@@ -1,14 +0,0 @@
1
- import createWorkflows from './createWorkflows-BC1Mwjwe.mjs';
2
-
3
- const createWorkflowContext = (env, specs) => {
4
- const bindings = {};
5
- for (const spec of specs) {
6
- const binding = env[spec.binding];
7
- if (binding && typeof binding.create === "function" && typeof binding.createBatch === "function" && typeof binding.get === "function") {
8
- bindings[spec.exportName] = binding;
9
- }
10
- }
11
- return createWorkflows({ bindings });
12
- };
13
-
14
- export { createWorkflowContext };
@@ -1,112 +0,0 @@
1
- import { LunoraError } from '@lunora/errors';
2
- import { workflowBindingName } from './defineWorkflow-DbUC-oCN.mjs';
3
- import { createSpawn, createParallel } from './MAX_BRANCHES-D6cQabJ1.mjs';
4
- import { createRunStep } from './createRunStep-8jOXxP2o.mjs';
5
-
6
- const createDispatchLogger = (prefix) => {
7
- return {
8
- debug: (message, ...rest) => {
9
- console.debug(prefix, message, ...rest);
10
- },
11
- error: (message, ...rest) => {
12
- console.error(prefix, message, ...rest);
13
- },
14
- info: (message, ...rest) => {
15
- console.info(prefix, message, ...rest);
16
- },
17
- warn: (message, ...rest) => {
18
- console.warn(prefix, message, ...rest);
19
- }
20
- };
21
- };
22
-
23
- const SCHEDULER_DISPATCH_PATH = "/_lunora/scheduler/dispatch";
24
- const trimTrailingSlashes = (value) => {
25
- let end = value.length;
26
- while (end > 0 && value[end - 1] === "/") {
27
- end -= 1;
28
- }
29
- return value.slice(0, end);
30
- };
31
- const createDispatchRunner = (options) => {
32
- const { label } = options;
33
- const globalFetch = globalThis.fetch;
34
- const fetchImpl = options.fetchImpl ?? (typeof globalFetch === "function" ? globalFetch.bind(globalThis) : void 0);
35
- return async (function_, args, runOptions = {}) => {
36
- if (typeof fetchImpl !== "function") {
37
- throw new TypeError(`${label}: no fetch implementation available — pass fetchImpl or run on a platform with global fetch`);
38
- }
39
- const origin = options.env.LUNORA_ORIGIN_URL;
40
- if (typeof origin !== "string" || origin.length === 0) {
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`);
42
- }
43
- const token = options.env.LUNORA_ADMIN_TOKEN;
44
- if (typeof token !== "string" || token.length === 0) {
45
- throw new LunoraError("INTERNAL", `${label}: \`LUNORA_ADMIN_TOKEN\` must be set on the Worker env to authenticate function dispatch`);
46
- }
47
- const url = `${trimTrailingSlashes(origin)}${SCHEDULER_DISPATCH_PATH}`;
48
- const response = await fetchImpl(url, {
49
- body: JSON.stringify({ args: args ?? {}, functionPath: function_.__lunoraRef, shardKey: runOptions.shardKey }),
50
- headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
51
- method: "POST"
52
- });
53
- if (!response.ok) {
54
- throw new LunoraError("INTERNAL", `${label}: function dispatch failed (${String(response.status)}): ${await response.text()}`);
55
- }
56
- const text = await response.text();
57
- if (text.length === 0) {
58
- return void 0;
59
- }
60
- try {
61
- return JSON.parse(text);
62
- } catch {
63
- return text;
64
- }
65
- };
66
- };
67
-
68
- const createWorkflowRunContext = (options) => {
69
- const log = createDispatchLogger(`[workflow:${options.exportName}]`);
70
- const run = createDispatchRunner({ env: options.env, fetchImpl: options.fetchImpl, label: "@lunora/workflow" });
71
- const resolveBinding = (workflow) => {
72
- const bindingName = workflowBindingName(workflow);
73
- const binding = options.env[bindingName];
74
- if (!binding || typeof binding.create !== "function" || typeof binding.get !== "function") {
75
- throw new LunoraError(
76
- "INTERNAL",
77
- `@lunora/workflow: cannot spawn child workflow "${workflow}" — no Workflow binding "${bindingName}" on env (is it declared in lunora/workflows.ts?)`
78
- );
79
- }
80
- return binding;
81
- };
82
- let childCounter = 0;
83
- const nextChildId = (explicit) => {
84
- if (explicit !== void 0) {
85
- return explicit;
86
- }
87
- const id = `${options.event.instanceId}-c${String(childCounter)}`;
88
- childCounter += 1;
89
- return id;
90
- };
91
- const fanOutDeps = {
92
- env: options.env,
93
- instanceId: options.event.instanceId,
94
- nextChildId,
95
- parentBinding: workflowBindingName(options.exportName),
96
- resolveBinding,
97
- step: options.step
98
- };
99
- return {
100
- env: options.env,
101
- event: options.event,
102
- log,
103
- parallel: createParallel(fanOutDeps),
104
- params: options.event.payload,
105
- run,
106
- runStep: createRunStep({ env: options.env, log, nonRetryableErrorClass: options.nonRetryableErrorClass, run, step: options.step }),
107
- spawn: createSpawn(fanOutDeps),
108
- step: options.step
109
- };
110
- };
111
-
112
- export { createWorkflowRunContext };
@@ -1,25 +0,0 @@
1
- import { LunoraError } from '@lunora/errors';
2
-
3
- const handleFor = (binding) => {
4
- return {
5
- create: async (options) => binding.create(options),
6
- createBatch: async (batch) => binding.createBatch(batch),
7
- get: async (id) => binding.get(id)
8
- };
9
- };
10
- const createWorkflows = (options) => {
11
- const bindings = options.bindings ?? {};
12
- return {
13
- get: (name) => {
14
- const binding = bindings[name];
15
- if (binding === void 0) {
16
- const known = Object.keys(bindings);
17
- const suffix = known.length === 0 ? "no workflows are declared" : `known workflows: ${known.join(", ")}`;
18
- throw new LunoraError("INTERNAL", `@lunora/workflow: no workflow named "${name}" (${suffix})`);
19
- }
20
- return handleFor(binding);
21
- }
22
- };
23
- };
24
-
25
- export { createWorkflows as default };
@@ -1,28 +0,0 @@
1
- const defineStep = (name, config) => {
2
- if (typeof name !== "string" || name.length === 0) {
3
- throw new TypeError("defineStep: `name` must be a non-empty string (the durable step label)");
4
- }
5
- const declaredArgs = config.args;
6
- if (typeof declaredArgs !== "object" || declaredArgs === null) {
7
- throw new TypeError("defineStep: `args` must be a validator map (e.g. `{ id: v.string() }`)");
8
- }
9
- if (typeof config.handler !== "function") {
10
- throw new TypeError("defineStep: `handler` must be a function (the step body)");
11
- }
12
- if (config.rollback !== void 0 && typeof config.rollback !== "function") {
13
- throw new TypeError("defineStep: `rollback` must be a function when provided");
14
- }
15
- return {
16
- args: config.args,
17
- config: config.config,
18
- handler: config.handler,
19
- isLunoraStep: true,
20
- name,
21
- returns: config.returns,
22
- rollback: config.rollback,
23
- rollbackConfig: config.rollbackConfig
24
- };
25
- };
26
- const isStepDefinition = (value) => typeof value === "object" && value !== null && value.isLunoraStep === true;
27
-
28
- export { defineStep, isStepDefinition };
@@ -1,15 +0,0 @@
1
- const workflowClassName = (exportName) => `${exportName.charAt(0).toUpperCase()}${exportName.slice(1)}Workflow`;
2
- const workflowBindingName = (exportName) => `WORKFLOW_${exportName.replaceAll(/(?<=[a-z0-9])(?=[A-Z])/g, "_").toUpperCase()}`;
3
- const workflowDefaultName = (exportName) => exportName.replaceAll(/(?<=[a-z0-9])(?=[A-Z])/g, "-").toLowerCase();
4
- const defineWorkflow = (config) => {
5
- if (typeof config.handler !== "function") {
6
- throw new TypeError("defineWorkflow: `handler` must be a function (the workflow body)");
7
- }
8
- if (config.name !== void 0 && (typeof config.name !== "string" || config.name.length === 0)) {
9
- throw new TypeError("defineWorkflow: `name` must be a non-empty string when provided");
10
- }
11
- return { ...config, isLunoraWorkflow: true };
12
- };
13
- const isWorkflowDefinition = (value) => typeof value === "object" && value !== null && value.isLunoraWorkflow === true;
14
-
15
- export { defineWorkflow, isWorkflowDefinition, workflowBindingName, workflowClassName, workflowDefaultName };