@dudousxd/nestjs-durable-store-prisma 0.29.0 → 0.29.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/dist/index.js CHANGED
@@ -473,7 +473,9 @@ var PrismaStateStore = class {
473
473
  error: jsonOrNull(s.error),
474
474
  events: jsonOrNull(s.events),
475
475
  startedAt: s.startedAt,
476
- finishedAt: s.finishedAt
476
+ finishedAt: s.finishedAt,
477
+ // A settled step has no dispatch lease left.
478
+ wakeAt: null
477
479
  }
478
480
  });
479
481
  wrote[i] = count > 0;
@@ -1771,7 +1773,8 @@ var settleRowsPostgres = /* @__PURE__ */ __name(async (db, settlements, schema)
1771
1773
  return `(${p(1)}::text, ${p(2)}::integer, ${p(3)}::text, ${p(4)}::jsonb, ${p(5)}::jsonb, ${p(6)}::jsonb, (${p(7)}::timestamptz AT TIME ZONE 'UTC'), (${p(8)}::timestamptz AT TIME ZONE 'UTC'))`;
1772
1774
  });
1773
1775
  const written = await db.$queryRawUnsafe(`UPDATE ${rawTable('"durable_step_checkpoints"', schema, "postgres")} AS c SET status = v.status, output = v.output,
1774
- error = v.error, events = v.events, started_at = v.started_at, finished_at = v.finished_at
1776
+ error = v.error, events = v.events, started_at = v.started_at, finished_at = v.finished_at,
1777
+ wake_at = NULL
1775
1778
  FROM (VALUES ${rows.join(", ")}) AS v(run_id, seq, status, output, error, events, started_at,
1776
1779
  finished_at)
1777
1780
  WHERE c.run_id = v.run_id AND c.seq = v.seq AND c.status = 'pending'
@@ -1795,7 +1798,8 @@ var settleRowsMysql = /* @__PURE__ */ __name(async (db, settlements, schema) =>
1795
1798
  const updated = await db.$executeRawUnsafe(`UPDATE ${rawTable("durable_step_checkpoints", schema, "mysql")} AS c JOIN (${rows.join(" UNION ALL ")}) AS v
1796
1799
  ON c.run_id = v.run_id AND c.seq = v.seq
1797
1800
  SET c.status = v.status, c.output = CAST(v.output AS JSON), c.error = CAST(v.error AS JSON),
1798
- c.events = CAST(v.events AS JSON), c.started_at = v.started_at, c.finished_at = v.finished_at
1801
+ c.events = CAST(v.events AS JSON), c.started_at = v.started_at, c.finished_at = v.finished_at,
1802
+ c.wake_at = NULL
1799
1803
  WHERE c.status = 'pending'`, ...values);
1800
1804
  if (updated !== won.length) {
1801
1805
  throw new Error("a checkpoint of the batch was settled while the batch was written");
@@ -1810,7 +1814,7 @@ var settleRowsSqlite = /* @__PURE__ */ __name(async (db, settlements) => {
1810
1814
  });
1811
1815
  const written = await db.$queryRawUnsafe(`WITH v(run_id, seq, status, output, error, events, started_at, finished_at) AS (VALUES ${rows.join(", ")})
1812
1816
  UPDATE durable_step_checkpoints SET status = v.status, output = v.output, error = v.error,
1813
- events = v.events, started_at = v.started_at, finished_at = v.finished_at
1817
+ events = v.events, started_at = v.started_at, finished_at = v.finished_at, wake_at = NULL
1814
1818
  FROM v
1815
1819
  WHERE durable_step_checkpoints.run_id = v.run_id AND durable_step_checkpoints.seq = v.seq
1816
1820
  AND durable_step_checkpoints.status = 'pending'
@@ -2189,7 +2193,7 @@ var PrismaRoundTrips = class PrismaRoundTrips2 {
2189
2193
  const s = results[i];
2190
2194
  const done = s.status === "completed";
2191
2195
  const at = /* @__PURE__ */ __name((d) => d.toISOString().replace("T", " ").replace("Z", ""), "at");
2192
- const wrote = await this.raw.$executeRawUnsafe(`UPDATE ${this.t("durable_step_checkpoints")} c SET c.status = ?, c.output = ${done ? "CAST(? AS JSON)" : "c.output"}, c.error = CAST(? AS JSON), c.events = COALESCE(CAST(? AS JSON), c.events), c.started_at = COALESCE(?, c.started_at), c.finished_at = ? WHERE c.run_id = ? AND c.seq = ? AND c.status = 'pending' AND ${finished}`, s.status, ...done ? [
2196
+ const wrote = await this.raw.$executeRawUnsafe(`UPDATE ${this.t("durable_step_checkpoints")} c SET c.status = ?, c.output = ${done ? "CAST(? AS JSON)" : "c.output"}, c.error = CAST(? AS JSON), c.events = COALESCE(CAST(? AS JSON), c.events), c.started_at = COALESCE(?, c.started_at), c.finished_at = ?, c.wake_at = NULL WHERE c.run_id = ? AND c.seq = ? AND c.status = 'pending' AND ${finished}`, s.status, ...done ? [
2193
2197
  jsonText(s.output)
2194
2198
  ] : [], jsonText(s.error), jsonText(s.events), s.startedAt ? at(s.startedAt) : null, at(s.finishedAt), s.runId, s.seq);
2195
2199
  if (wrote !== 1) return out;
@@ -2210,7 +2214,7 @@ var PrismaRoundTrips = class PrismaRoundTrips2 {
2210
2214
  const p = /* @__PURE__ */ __name((k) => `$${n + k}`, "p");
2211
2215
  return `(${p(1)}::text, ${p(2)}::integer, ${p(3)}::text, ${p(4)}::jsonb, ${p(5)}::jsonb, ${p(6)}::jsonb, (${p(7)}::timestamptz AT TIME ZONE 'UTC'), (${p(8)}::timestamptz AT TIME ZONE 'UTC'))`;
2212
2216
  });
2213
- const settled = await this.raw.$queryRawUnsafe(`UPDATE ${this.t('"durable_step_checkpoints"')} AS c SET status = v.status, output = CASE WHEN v.status = 'completed' THEN v.output ELSE c.output END, error = v.error, events = COALESCE(v.events, c.events), started_at = COALESCE(v.started_at, c.started_at), finished_at = v.finished_at FROM (VALUES ${rows.join(", ")}) AS v(run_id, seq, status, output, error, events, started_at, finished_at) WHERE c.run_id = v.run_id AND c.seq = v.seq AND c.status = 'pending' AND ${finished} RETURNING ${SETTLED_CHECKPOINT_COLUMNS.split(", ").map((col) => `c.${col}`).join(", ")}`, ...values);
2217
+ const settled = await this.raw.$queryRawUnsafe(`UPDATE ${this.t('"durable_step_checkpoints"')} AS c SET status = v.status, output = CASE WHEN v.status = 'completed' THEN v.output ELSE c.output END, error = v.error, events = COALESCE(v.events, c.events), started_at = COALESCE(v.started_at, c.started_at), finished_at = v.finished_at, wake_at = NULL FROM (VALUES ${rows.join(", ")}) AS v(run_id, seq, status, output, error, events, started_at, finished_at) WHERE c.run_id = v.run_id AND c.seq = v.seq AND c.status = 'pending' AND ${finished} RETURNING ${SETTLED_CHECKPOINT_COLUMNS.split(", ").map((col) => `c.${col}`).join(", ")}`, ...values);
2214
2218
  const byKey = new Map(chunk.map((i) => {
2215
2219
  const s = results[i];
2216
2220
  return [