@voltro/workflow 0.80.0 → 0.81.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.
@@ -1,4 +1,4 @@
1
- import { E as e, F as t, I as n, L as r, M as i, N as a, P as o, T as s, w as c } from "./primitives-bv2JHUfk.js";
1
+ import { E as e, F as t, L as n, M as r, N as i, P as a, R as o, T as s, w as c } from "./primitives-BJBn8tiH.js";
2
2
  import { _ as l, c as u, d, f, g as p, h as m, i as h, m as g, p as _, s as v, v as ee } from "./clusterDiagnostics-Cwt-WFec.js";
3
3
  import { Activity as y, DurableClock as b, DurableDeferred as te, Workflow as ne, WorkflowEngine as re } from "@effect/workflow";
4
4
  import { Cause as x, Effect as S, Either as C, Exit as ie, Fiber as ae, FiberRef as oe, Layer as se, Schema as w } from "effect";
@@ -3836,17 +3836,17 @@ var yn = "_voltro_workflow_runs", bn = w.NullOr(w.Struct({
3836
3836
  await e.recordEvent(t);
3837
3837
  } catch {}
3838
3838
  }, $r = (e, n) => {
3839
- let i = S.gen(function* () {
3840
- let i = n.pollIntervalMs ?? 200, a = n.maxPollIntervalMs ?? 5e3, o = n.timeoutMs ?? 864e5, s = yield* S.serviceOption(Se), c;
3839
+ let r = S.gen(function* () {
3840
+ let r = n.pollIntervalMs ?? 200, i = n.maxPollIntervalMs ?? 5e3, a = n.timeoutMs ?? 864e5, s = yield* S.serviceOption(Se), c;
3841
3841
  Zr({
3842
3842
  workflowName: s._tag === "Some" ? s.value.workflow.name : void 0,
3843
3843
  signalName: n.name,
3844
- timeoutMs: o,
3844
+ timeoutMs: a,
3845
3845
  warn: (e) => {
3846
3846
  c = e;
3847
3847
  }
3848
3848
  }), c !== void 0 && (yield* S.logWarning(c));
3849
- let l = yield* t, u = yield* S.serviceOption(r), d = u._tag === "Some" ? u.value : void 0;
3849
+ let l = yield* t, u = yield* S.serviceOption(o), d = u._tag === "Some" ? u.value : void 0;
3850
3850
  if (l === void 0) return yield* S.die(/* @__PURE__ */ Error("awaitSignal: no active workflow run id in scope"));
3851
3851
  let f = l;
3852
3852
  yield* S.promise(() => Qr(d, {
@@ -3854,10 +3854,10 @@ var yn = "_voltro_workflow_runs", bn = w.NullOr(w.Struct({
3854
3854
  eventType: "signal-awaited",
3855
3855
  payload: { signalName: n.name }
3856
3856
  }));
3857
- let p = Date.now(), m = i;
3857
+ let p = Date.now(), m = r;
3858
3858
  for (;;) {
3859
3859
  let t = Date.now() - p;
3860
- if (t > o) return yield* S.die(/* @__PURE__ */ Error(`awaitSignal('${n.name}') timed out after ${t}ms`));
3860
+ if (t > a) return yield* S.die(/* @__PURE__ */ Error(`awaitSignal('${n.name}') timed out after ${t}ms`));
3861
3861
  let r = {
3862
3862
  table: "_voltro_workflow_run_events",
3863
3863
  order: [{
@@ -3868,36 +3868,36 @@ var yn = "_voltro_workflow_runs", bn = w.NullOr(w.Struct({
3868
3868
  projection: void 0,
3869
3869
  skip: void 0,
3870
3870
  take: 1e3
3871
- }, i = (yield* S.tryPromise({
3871
+ }, o = (yield* S.tryPromise({
3872
3872
  try: () => e.store.query(r),
3873
3873
  catch: (e) => e
3874
3874
  })).find((e) => e.payload?.signalName === n.name);
3875
- if (i !== void 0) {
3876
- let e = yield* w.decodeUnknown(n.schema)(i.payload?.value);
3875
+ if (o !== void 0) {
3876
+ let e = yield* w.decodeUnknown(n.schema)(o.payload?.value);
3877
3877
  return yield* S.promise(() => Qr(d, {
3878
3878
  runId: f,
3879
3879
  eventType: "signal-received",
3880
3880
  payload: {
3881
3881
  signalName: n.name,
3882
- value: i.payload?.value
3882
+ value: o.payload?.value
3883
3883
  }
3884
3884
  })), e;
3885
3885
  }
3886
- yield* S.sleep(`${m} millis`), m = Math.min(m * 2, a);
3886
+ yield* S.sleep(`${m} millis`), m = Math.min(m * 2, i);
3887
3887
  }
3888
3888
  });
3889
3889
  return y.make({
3890
3890
  name: `await-signal:${n.name}`,
3891
3891
  success: n.schema,
3892
- execute: i
3892
+ execute: r
3893
3893
  });
3894
3894
  }, ei = async (e, t) => {
3895
3895
  if (e !== void 0) try {
3896
3896
  await e.recordEvent(t);
3897
3897
  } catch {}
3898
3898
  }, ti = (e, n) => {
3899
- let i = S.gen(function* () {
3900
- let i = n.pollIntervalMs ?? 200, a = n.maxPollIntervalMs ?? 5e3, o = n.timeoutMs ?? 864e5, s = n.take ?? 500, c = yield* t, l = yield* S.serviceOption(r), u = l._tag === "Some" ? l.value : void 0;
3899
+ let r = S.gen(function* () {
3900
+ let r = n.pollIntervalMs ?? 200, i = n.maxPollIntervalMs ?? 5e3, a = n.timeoutMs ?? 864e5, s = n.take ?? 500, c = yield* t, l = yield* S.serviceOption(o), u = l._tag === "Some" ? l.value : void 0;
3901
3901
  if (c === void 0) return yield* S.die(/* @__PURE__ */ Error("awaitEvent: no active workflow run id in scope"));
3902
3902
  let d = c, f = yield* n.since === "run-start" ? ni(e, d) : S.succeed(/* @__PURE__ */ new Date());
3903
3903
  yield* S.promise(() => ei(u, {
@@ -3909,10 +3909,10 @@ var yn = "_voltro_workflow_runs", bn = w.NullOr(w.Struct({
3909
3909
  cutoff: f.toISOString()
3910
3910
  }
3911
3911
  }));
3912
- let p = Date.now(), m = i, h = 0;
3912
+ let p = Date.now(), m = r, h = 0;
3913
3913
  for (;;) {
3914
3914
  let t = Date.now() - p;
3915
- if (t > o) return yield* S.die(/* @__PURE__ */ Error(`awaitEvent('${n.event}') timed out after ${t}ms having examined ${h} candidate event(s). ${h === 0 ? "NONE were published under that name in the window — check the spelling against ctx.events.publish, and consider since: 'run-start' if the event may have arrived before this step began." : "The predicate rejected all of them — log one payload and compare it with what `match` expects."}`));
3915
+ if (t > a) return yield* S.die(/* @__PURE__ */ Error(`awaitEvent('${n.event}') timed out after ${t}ms having examined ${h} candidate event(s). ${h === 0 ? "NONE were published under that name in the window — check the spelling against ctx.events.publish, and consider since: 'run-start' if the event may have arrived before this step began." : "The predicate rejected all of them — log one payload and compare it with what `match` expects."}`));
3916
3916
  let r = {
3917
3917
  table: "_voltro_workflow_events",
3918
3918
  predicate: D(O("name", n.event), de("occurredAt", f)),
@@ -3923,12 +3923,12 @@ var yn = "_voltro_workflow_runs", bn = w.NullOr(w.Struct({
3923
3923
  take: s,
3924
3924
  skip: void 0,
3925
3925
  projection: void 0
3926
- }, i = yield* S.tryPromise({
3926
+ }, o = yield* S.tryPromise({
3927
3927
  try: () => e.store.query(r),
3928
3928
  catch: (e) => e
3929
3929
  });
3930
- h = i.length;
3931
- for (let e of i) {
3930
+ h = o.length;
3931
+ for (let e of o) {
3932
3932
  let t = yield* w.decodeUnknown(n.schema)(e.payload);
3933
3933
  if (n.match(t)) return yield* S.promise(() => ei(u, {
3934
3934
  runId: d,
@@ -3939,13 +3939,13 @@ var yn = "_voltro_workflow_runs", bn = w.NullOr(w.Struct({
3939
3939
  }
3940
3940
  })), t;
3941
3941
  }
3942
- yield* S.sleep(`${m} millis`), m = Math.min(m * 2, a);
3942
+ yield* S.sleep(`${m} millis`), m = Math.min(m * 2, i);
3943
3943
  }
3944
3944
  });
3945
3945
  return y.make({
3946
3946
  name: `awaitEvent:${n.event}`,
3947
3947
  success: n.schema,
3948
- execute: i
3948
+ execute: r
3949
3949
  });
3950
3950
  }, ni = (e, t) => S.gen(function* () {
3951
3951
  let n = (yield* S.tryPromise({
@@ -4056,18 +4056,18 @@ var yn = "_voltro_workflow_runs", bn = w.NullOr(w.Struct({
4056
4056
  await e.recordEvent(t);
4057
4057
  } catch {}
4058
4058
  }, hi = (e, n) => S.gen(function* () {
4059
- let e = n.timeoutMs ?? ui, i = yield* re.WorkflowInstance, a = pi(fi(i.workflow.name, n.name)), o = yield* t, s = yield* S.serviceOption(r), c = s._tag === "Some" ? s.value : void 0;
4060
- o !== void 0 && (yield* S.promise(() => mi(c, {
4061
- runId: o,
4059
+ let e = n.timeoutMs ?? ui, r = yield* re.WorkflowInstance, i = pi(fi(r.workflow.name, n.name)), a = yield* t, s = yield* S.serviceOption(o), c = s._tag === "Some" ? s.value : void 0;
4060
+ a !== void 0 && (yield* S.promise(() => mi(c, {
4061
+ runId: a,
4062
4062
  eventType: "signal-awaited",
4063
4063
  payload: { signalName: n.name }
4064
4064
  })));
4065
- let l = te.await(a), u = Number.isFinite(e) ? yield* S.race(l, b.sleep({
4065
+ let l = te.await(i), u = Number.isFinite(e) ? yield* S.race(l, b.sleep({
4066
4066
  name: `await-signal-timeout/${n.name}`,
4067
4067
  duration: `${e} millis`
4068
- }).pipe(S.andThen(S.die(/* @__PURE__ */ Error(`awaitSignalSuspending('${n.name}') timed out after ${e}ms`))))).pipe(S.catchAllCause((e) => i.suspended ? x.isInterruptedOnly(e) ? ne.suspend(i) : S.failCause(x.filter(e, (e) => !x.isInterruptType(e))) : S.failCause(e))) : yield* l, d = yield* w.decodeUnknown(n.schema)(u);
4069
- return o !== void 0 && (yield* S.promise(() => mi(c, {
4070
- runId: o,
4068
+ }).pipe(S.andThen(S.die(/* @__PURE__ */ Error(`awaitSignalSuspending('${n.name}') timed out after ${e}ms`))))).pipe(S.catchAllCause((e) => r.suspended ? x.isInterruptedOnly(e) ? ne.suspend(r) : S.failCause(x.filter(e, (e) => !x.isInterruptType(e))) : S.failCause(e))) : yield* l, d = yield* w.decodeUnknown(n.schema)(u);
4069
+ return a !== void 0 && (yield* S.promise(() => mi(c, {
4070
+ runId: a,
4071
4071
  eventType: "signal-received",
4072
4072
  payload: {
4073
4073
  signalName: n.name,
@@ -4235,13 +4235,13 @@ var yn = "_voltro_workflow_runs", bn = w.NullOr(w.Struct({
4235
4235
  errorMessage: r?.message ?? String(r)
4236
4236
  };
4237
4237
  }, Pi = (e, n) => {
4238
- let i = S.gen(function* () {
4239
- let i = n.pollIntervalMs ?? 200, a = n.maxPollIntervalMs ?? 5e3, o = n.timeoutMs ?? 3e4, s = yield* t, c = yield* S.serviceOption(r), l = c._tag === "Some" ? c.value : void 0;
4238
+ let r = S.gen(function* () {
4239
+ let r = n.pollIntervalMs ?? 200, i = n.maxPollIntervalMs ?? 5e3, a = n.timeoutMs ?? 3e4, s = yield* t, c = yield* S.serviceOption(o), l = c._tag === "Some" ? c.value : void 0;
4240
4240
  if (s === void 0) return yield* S.die(/* @__PURE__ */ Error("awaitUpdate: no active workflow run id in scope"));
4241
- let u = s, d = Date.now(), f = i;
4241
+ let u = s, d = Date.now(), f = r;
4242
4242
  for (;;) {
4243
4243
  let t = Date.now() - d;
4244
- if (t > o) return yield* S.die(/* @__PURE__ */ Error(`awaitUpdate('${n.name}') timed out after ${t}ms`));
4244
+ if (t > a) return yield* S.die(/* @__PURE__ */ Error(`awaitUpdate('${n.name}') timed out after ${t}ms`));
4245
4245
  let r = {
4246
4246
  table: "_voltro_workflow_run_events",
4247
4247
  order: [{
@@ -4252,10 +4252,10 @@ var yn = "_voltro_workflow_runs", bn = w.NullOr(w.Struct({
4252
4252
  projection: void 0,
4253
4253
  skip: void 0,
4254
4254
  take: 1e3
4255
- }, i = yield* S.tryPromise({
4255
+ }, o = yield* S.tryPromise({
4256
4256
  try: () => e.store.query(r),
4257
4257
  catch: (e) => e
4258
- }), s = new Set(i.filter((e) => e.eventType === "update-completed" || e.eventType === "update-failed").map((e) => e.payload?.updateId).filter((e) => typeof e == "string" && e.length > 0)), c = i.find((e) => e.eventType === "update-requested" && e.payload?.updateName === n.name && typeof e.payload.updateId == "string" && !s.has(e.payload.updateId));
4258
+ }), s = new Set(o.filter((e) => e.eventType === "update-completed" || e.eventType === "update-failed").map((e) => e.payload?.updateId).filter((e) => typeof e == "string" && e.length > 0)), c = o.find((e) => e.eventType === "update-requested" && e.payload?.updateName === n.name && typeof e.payload.updateId == "string" && !s.has(e.payload.updateId));
4259
4259
  if (c !== void 0) {
4260
4260
  let e = c.payload.updateId;
4261
4261
  yield* S.promise(() => Mi(l, {
@@ -4293,13 +4293,13 @@ var yn = "_voltro_workflow_runs", bn = w.NullOr(w.Struct({
4293
4293
  }
4294
4294
  })), r;
4295
4295
  }
4296
- yield* S.sleep(`${f} millis`), f = Math.min(f * 2, a);
4296
+ yield* S.sleep(`${f} millis`), f = Math.min(f * 2, i);
4297
4297
  }
4298
4298
  });
4299
4299
  return y.make({
4300
4300
  name: `await-update:${n.name}`,
4301
4301
  success: n.success ?? n.schema,
4302
- execute: i
4302
+ execute: r
4303
4303
  });
4304
4304
  }, Fi = (e) => {
4305
4305
  if (e == null) return null;
@@ -4366,9 +4366,9 @@ var yn = "_voltro_workflow_runs", bn = w.NullOr(w.Struct({
4366
4366
  parentClosePolicy: Li(r.parentClosePolicy)
4367
4367
  };
4368
4368
  }, Vi = () => {
4369
- let e = [], t = [], n = 0, i = 0;
4369
+ let e = [], t = [], n = 0, r = 0;
4370
4370
  return {
4371
- layer: se.succeed(r, {
4371
+ layer: se.succeed(o, {
4372
4372
  startStep: async ({ runId: t, stepName: r, attempt: i, stepInput: a, retryPolicy: o }) => {
4373
4373
  let s = `wfstep_mem_${++n}`;
4374
4374
  return e.push({
@@ -4396,13 +4396,13 @@ var yn = "_voltro_workflow_runs", bn = w.NullOr(w.Struct({
4396
4396
  let o = e.find((e) => e.id === t);
4397
4397
  o !== void 0 && (o.status = "failed", o.errorTag = n, o.errorMessage = r, o.errorCause = i ?? null, o.completedAt = /* @__PURE__ */ new Date(), o.durationMs = a);
4398
4398
  },
4399
- recordEvent: async ({ runId: e, eventType: n, payload: r, stepName: a, attempt: o }) => {
4400
- let s = `wfev_mem_${++i}`;
4399
+ recordEvent: async ({ runId: e, eventType: n, payload: i, stepName: a, attempt: o }) => {
4400
+ let s = `wfev_mem_${++r}`;
4401
4401
  return t.push({
4402
4402
  id: s,
4403
4403
  runId: e,
4404
4404
  eventType: n,
4405
- payload: r ?? null,
4405
+ payload: i ?? null,
4406
4406
  stepName: a ?? null,
4407
4407
  attempt: o ?? null,
4408
4408
  occurredAt: /* @__PURE__ */ new Date()
@@ -4644,7 +4644,7 @@ var yn = "_voltro_workflow_runs", bn = w.NullOr(w.Struct({
4644
4644
  }
4645
4645
  });
4646
4646
  return (ee, y) => S.gen(function* () {
4647
- let b = Date.now(), te = yield* oe.get(i), re = yield* oe.get(a), C = s.parentExecutionId ?? te ?? null, se = s.parentGeneration ?? (s.parentExecutionId == null ? re : void 0) ?? null, w = s.parentClosePolicy ?? null, T, E = (e, t) => t.pipe(S.catchAllCause((t) => x.isInterrupted(t) ? S.failCause(t) : S.sync(() => {
4647
+ let b = Date.now(), te = yield* oe.get(r), re = yield* oe.get(i), C = s.parentExecutionId ?? te ?? null, se = s.parentGeneration ?? (s.parentExecutionId == null ? re : void 0) ?? null, w = s.parentClosePolicy ?? null, T, E = (e, t) => t.pipe(S.catchAllCause((t) => x.isInterrupted(t) ? S.failCause(t) : S.sync(() => {
4648
4648
  let n = x.squash(t);
4649
4649
  p(e, {
4650
4650
  tag: s.name,
@@ -4804,7 +4804,7 @@ var yn = "_voltro_workflow_runs", bn = w.NullOr(w.Struct({
4804
4804
  }));
4805
4805
  }
4806
4806
  }));
4807
- let M = s.subject?.tenantId, pe = S.suspend(() => l(ee, y, D)).pipe(S.locally(t, T), S.locally(i, y), S.locally(a, D), S.locally(n, typeof M == "string" ? M : void 0), S.locally(o, j), S.locally(c, fe), S.provideService(r, f)), N = s.pluginWorkflowStepLayer ? pe.pipe(S.provide(s.pluginWorkflowStepLayer)) : pe, P = yield* ne.intoResult(S.raceWith(N, Hi({
4807
+ let M = s.subject?.tenantId, pe = S.suspend(() => l(ee, y, D)).pipe(S.locally(t, T), S.locally(r, y), S.locally(i, D), S.locally(n, typeof M == "string" ? M : void 0), S.locally(a, j), S.locally(c, fe), S.provideService(o, f)), N = s.pluginWorkflowStepLayer ? pe.pipe(S.provide(s.pluginWorkflowStepLayer)) : pe, P = yield* ne.intoResult(S.raceWith(N, Hi({
4808
4808
  runId: T,
4809
4809
  workflowName: s.name,
4810
4810
  executionId: y,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voltro/workflow",
3
- "version": "0.80.0",
3
+ "version": "0.81.0",
4
4
  "description": "Durable workflows for Voltro — the workflow() descriptor + step() / awaitSignal primitives over @effect/cluster, with a browser-safe define subpath.",
5
5
  "keywords": [
6
6
  "voltro",
@@ -51,9 +51,9 @@
51
51
  "@effect/cluster": "^0.60.2",
52
52
  "@effect/sql": "^0.52.1",
53
53
  "@effect/workflow": "^0.19.1",
54
- "@voltro/database": "0.80.0",
55
- "@voltro/logger": "0.80.0",
56
- "@voltro/protocol": "0.80.0"
54
+ "@voltro/database": "0.81.0",
55
+ "@voltro/logger": "0.81.0",
56
+ "@voltro/protocol": "0.81.0"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "effect": "^3.22.2",