@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.cjs CHANGED
@@ -499,7 +499,9 @@ var PrismaStateStore = class {
499
499
  error: jsonOrNull(s.error),
500
500
  events: jsonOrNull(s.events),
501
501
  startedAt: s.startedAt,
502
- finishedAt: s.finishedAt
502
+ finishedAt: s.finishedAt,
503
+ // A settled step has no dispatch lease left.
504
+ wakeAt: null
503
505
  }
504
506
  });
505
507
  wrote[i] = count > 0;
@@ -1797,7 +1799,8 @@ var settleRowsPostgres = /* @__PURE__ */ __name(async (db, settlements, schema)
1797
1799
  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'))`;
1798
1800
  });
1799
1801
  const written = await db.$queryRawUnsafe(`UPDATE ${rawTable('"durable_step_checkpoints"', schema, "postgres")} AS c SET status = v.status, output = v.output,
1800
- error = v.error, events = v.events, started_at = v.started_at, finished_at = v.finished_at
1802
+ error = v.error, events = v.events, started_at = v.started_at, finished_at = v.finished_at,
1803
+ wake_at = NULL
1801
1804
  FROM (VALUES ${rows.join(", ")}) AS v(run_id, seq, status, output, error, events, started_at,
1802
1805
  finished_at)
1803
1806
  WHERE c.run_id = v.run_id AND c.seq = v.seq AND c.status = 'pending'
@@ -1821,7 +1824,8 @@ var settleRowsMysql = /* @__PURE__ */ __name(async (db, settlements, schema) =>
1821
1824
  const updated = await db.$executeRawUnsafe(`UPDATE ${rawTable("durable_step_checkpoints", schema, "mysql")} AS c JOIN (${rows.join(" UNION ALL ")}) AS v
1822
1825
  ON c.run_id = v.run_id AND c.seq = v.seq
1823
1826
  SET c.status = v.status, c.output = CAST(v.output AS JSON), c.error = CAST(v.error AS JSON),
1824
- c.events = CAST(v.events AS JSON), c.started_at = v.started_at, c.finished_at = v.finished_at
1827
+ c.events = CAST(v.events AS JSON), c.started_at = v.started_at, c.finished_at = v.finished_at,
1828
+ c.wake_at = NULL
1825
1829
  WHERE c.status = 'pending'`, ...values);
1826
1830
  if (updated !== won.length) {
1827
1831
  throw new Error("a checkpoint of the batch was settled while the batch was written");
@@ -1836,7 +1840,7 @@ var settleRowsSqlite = /* @__PURE__ */ __name(async (db, settlements) => {
1836
1840
  });
1837
1841
  const written = await db.$queryRawUnsafe(`WITH v(run_id, seq, status, output, error, events, started_at, finished_at) AS (VALUES ${rows.join(", ")})
1838
1842
  UPDATE durable_step_checkpoints SET status = v.status, output = v.output, error = v.error,
1839
- events = v.events, started_at = v.started_at, finished_at = v.finished_at
1843
+ events = v.events, started_at = v.started_at, finished_at = v.finished_at, wake_at = NULL
1840
1844
  FROM v
1841
1845
  WHERE durable_step_checkpoints.run_id = v.run_id AND durable_step_checkpoints.seq = v.seq
1842
1846
  AND durable_step_checkpoints.status = 'pending'
@@ -2215,7 +2219,7 @@ var PrismaRoundTrips = class PrismaRoundTrips2 {
2215
2219
  const s = results[i];
2216
2220
  const done = s.status === "completed";
2217
2221
  const at = /* @__PURE__ */ __name((d) => d.toISOString().replace("T", " ").replace("Z", ""), "at");
2218
- 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 ? [
2222
+ 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 ? [
2219
2223
  jsonText(s.output)
2220
2224
  ] : [], jsonText(s.error), jsonText(s.events), s.startedAt ? at(s.startedAt) : null, at(s.finishedAt), s.runId, s.seq);
2221
2225
  if (wrote !== 1) return out;
@@ -2236,7 +2240,7 @@ var PrismaRoundTrips = class PrismaRoundTrips2 {
2236
2240
  const p = /* @__PURE__ */ __name((k) => `$${n + k}`, "p");
2237
2241
  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'))`;
2238
2242
  });
2239
- 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);
2243
+ 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);
2240
2244
  const byKey = new Map(chunk.map((i) => {
2241
2245
  const s = results[i];
2242
2246
  return [