@dudousxd/nestjs-durable-store-mikro-orm 0.39.0 → 0.39.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
@@ -1780,7 +1780,9 @@ var MikroOrmStateStore = class _MikroOrmStateStore {
1780
1780
  error: s.error ?? null,
1781
1781
  events: s.events ?? null,
1782
1782
  startedAt: s.startedAt,
1783
- finishedAt: s.finishedAt
1783
+ finishedAt: s.finishedAt,
1784
+ // A settled step has no dispatch lease left.
1785
+ wakeAt: null
1784
1786
  });
1785
1787
  return [
1786
1788
  changed === 1
@@ -1815,7 +1817,8 @@ var MikroOrmStateStore = class _MikroOrmStateStore {
1815
1817
  error: s.error ?? null,
1816
1818
  events: s.events ?? null,
1817
1819
  startedAt: s.startedAt,
1818
- finishedAt: s.finishedAt
1820
+ finishedAt: s.finishedAt,
1821
+ wakeAt: null
1819
1822
  });
1820
1823
  }
1821
1824
  for (let at = 0; at < rows.length; at += 500) {
@@ -2953,7 +2956,8 @@ var SETTLED_FIELDS = [
2953
2956
  "error",
2954
2957
  "events",
2955
2958
  "startedAt",
2956
- "finishedAt"
2959
+ "finishedAt",
2960
+ "wakeAt"
2957
2961
  ];
2958
2962
  var checkpointKey = /* @__PURE__ */ __name((runId, seq) => `${runId}\0${seq}`, "checkpointKey");
2959
2963
  async function lockPendingCheckpoints(em, entries, fields) {
@@ -3025,7 +3029,7 @@ function toCheckpointEntity(cp) {
3025
3029
  e.attempts = cp.attempts;
3026
3030
  if (cp.workerGroup !== void 0) e.workerGroup = cp.workerGroup;
3027
3031
  if (cp.parallelGroup !== void 0) e.parallelGroup = cp.parallelGroup;
3028
- if (cp.wakeAt != null) e.wakeAt = new Date(cp.wakeAt);
3032
+ e.wakeAt = cp.wakeAt != null ? new Date(cp.wakeAt) : null;
3029
3033
  e.enqueuedAt = cp.enqueuedAt;
3030
3034
  e.startedAt = cp.startedAt;
3031
3035
  e.finishedAt = cp.finishedAt;
@@ -3251,7 +3255,7 @@ var MikroOrmRoundTrips = class MikroOrmRoundTrips2 {
3251
3255
  for (const i of sent) {
3252
3256
  const s = results[i];
3253
3257
  const done = s.status === "completed";
3254
- const wrote = this.affected(await this.run(em, `UPDATE ${this.table(em, K)} c SET c.${c("status")} = ?, c.${c("output")} = ${done ? "?" : `c.${c("output")}`}, c.${c("error")} = ?, c.${c("events")} = COALESCE(?, c.${c("events")}), c.${c("startedAt")} = COALESCE(?, c.${c("startedAt")}), c.${c("finishedAt")} = ? WHERE c.${c("runId")} = ? AND c.${c("seq")} = ? AND c.${c("status")} = 'pending' AND ${finished}`, [
3258
+ const wrote = this.affected(await this.run(em, `UPDATE ${this.table(em, K)} c SET c.${c("status")} = ?, c.${c("output")} = ${done ? "?" : `c.${c("output")}`}, c.${c("error")} = ?, c.${c("events")} = COALESCE(?, c.${c("events")}), c.${c("startedAt")} = COALESCE(?, c.${c("startedAt")}), c.${c("finishedAt")} = ?, c.${c("wakeAt")} = NULL WHERE c.${c("runId")} = ? AND c.${c("seq")} = ? AND c.${c("status")} = 'pending' AND ${finished}`, [
3255
3259
  s.status,
3256
3260
  ...done ? [
3257
3261
  this.bind(em, K, "output", s.output)
@@ -3294,7 +3298,7 @@ var MikroOrmRoundTrips = class MikroOrmRoundTrips2 {
3294
3298
  params.push(s.runId, s.seq, s.status, this.bind(em, K, "output", s.status === "completed" ? s.output : null), this.bind(em, K, "error", s.error), this.bind(em, K, "events", s.events), this.bind(em, K, "startedAt", s.startedAt), this.bind(em, K, "finishedAt", s.finishedAt));
3295
3299
  return `(${props.map((p) => `?::${types.get(p)}`).join(", ")})`;
3296
3300
  });
3297
- const settled = this.rows(await this.run(em, `UPDATE ${this.table(em, K)} AS c SET ${c("status")} = v.status, ${c("output")} = CASE WHEN v.status = 'completed' THEN v.output ELSE c.${c("output")} END, ${c("error")} = v.error, ${c("events")} = COALESCE(v.events, c.${c("events")}), ${c("startedAt")} = COALESCE(v.started_at, c.${c("startedAt")}), ${c("finishedAt")} = v.finished_at FROM (VALUES ${rows.join(", ")}) AS v(run_id, seq, status, output, error, events, started_at, finished_at) WHERE c.${c("runId")} = v.run_id AND c.${c("seq")} = v.seq AND c.${c("status")} = 'pending' AND ${finished} RETURNING ${this.settledColumns(em, "c.")}`, params));
3301
+ const settled = this.rows(await this.run(em, `UPDATE ${this.table(em, K)} AS c SET ${c("status")} = v.status, ${c("output")} = CASE WHEN v.status = 'completed' THEN v.output ELSE c.${c("output")} END, ${c("error")} = v.error, ${c("events")} = COALESCE(v.events, c.${c("events")}), ${c("startedAt")} = COALESCE(v.started_at, c.${c("startedAt")}), ${c("finishedAt")} = v.finished_at, ${c("wakeAt")} = NULL FROM (VALUES ${rows.join(", ")}) AS v(run_id, seq, status, output, error, events, started_at, finished_at) WHERE c.${c("runId")} = v.run_id AND c.${c("seq")} = v.seq AND c.${c("status")} = 'pending' AND ${finished} RETURNING ${this.settledColumns(em, "c.")}`, params));
3298
3302
  const byKey = new Map(chunk.map((i) => {
3299
3303
  const s = results[i];
3300
3304
  return [