@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.d.cts CHANGED
@@ -93,7 +93,7 @@ declare class StepCheckpointEntity {
93
93
  attempts: number;
94
94
  workerGroup?: string;
95
95
  parallelGroup?: string;
96
- wakeAt?: Date;
96
+ wakeAt?: Date | null;
97
97
  enqueuedAt?: Date;
98
98
  startedAt: Date;
99
99
  finishedAt: Date;
package/dist/index.d.ts CHANGED
@@ -93,7 +93,7 @@ declare class StepCheckpointEntity {
93
93
  attempts: number;
94
94
  workerGroup?: string;
95
95
  parallelGroup?: string;
96
- wakeAt?: Date;
96
+ wakeAt?: Date | null;
97
97
  enqueuedAt?: Date;
98
98
  startedAt: Date;
99
99
  finishedAt: Date;
package/dist/index.js CHANGED
@@ -1730,7 +1730,9 @@ var MikroOrmStateStore = class _MikroOrmStateStore {
1730
1730
  error: s.error ?? null,
1731
1731
  events: s.events ?? null,
1732
1732
  startedAt: s.startedAt,
1733
- finishedAt: s.finishedAt
1733
+ finishedAt: s.finishedAt,
1734
+ // A settled step has no dispatch lease left.
1735
+ wakeAt: null
1734
1736
  });
1735
1737
  return [
1736
1738
  changed === 1
@@ -1765,7 +1767,8 @@ var MikroOrmStateStore = class _MikroOrmStateStore {
1765
1767
  error: s.error ?? null,
1766
1768
  events: s.events ?? null,
1767
1769
  startedAt: s.startedAt,
1768
- finishedAt: s.finishedAt
1770
+ finishedAt: s.finishedAt,
1771
+ wakeAt: null
1769
1772
  });
1770
1773
  }
1771
1774
  for (let at = 0; at < rows.length; at += 500) {
@@ -2903,7 +2906,8 @@ var SETTLED_FIELDS = [
2903
2906
  "error",
2904
2907
  "events",
2905
2908
  "startedAt",
2906
- "finishedAt"
2909
+ "finishedAt",
2910
+ "wakeAt"
2907
2911
  ];
2908
2912
  var checkpointKey = /* @__PURE__ */ __name((runId, seq) => `${runId}\0${seq}`, "checkpointKey");
2909
2913
  async function lockPendingCheckpoints(em, entries, fields) {
@@ -2975,7 +2979,7 @@ function toCheckpointEntity(cp) {
2975
2979
  e.attempts = cp.attempts;
2976
2980
  if (cp.workerGroup !== void 0) e.workerGroup = cp.workerGroup;
2977
2981
  if (cp.parallelGroup !== void 0) e.parallelGroup = cp.parallelGroup;
2978
- if (cp.wakeAt != null) e.wakeAt = new Date(cp.wakeAt);
2982
+ e.wakeAt = cp.wakeAt != null ? new Date(cp.wakeAt) : null;
2979
2983
  e.enqueuedAt = cp.enqueuedAt;
2980
2984
  e.startedAt = cp.startedAt;
2981
2985
  e.finishedAt = cp.finishedAt;
@@ -3201,7 +3205,7 @@ var MikroOrmRoundTrips = class MikroOrmRoundTrips2 {
3201
3205
  for (const i of sent) {
3202
3206
  const s = results[i];
3203
3207
  const done = s.status === "completed";
3204
- 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}`, [
3208
+ 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}`, [
3205
3209
  s.status,
3206
3210
  ...done ? [
3207
3211
  this.bind(em, K, "output", s.output)
@@ -3244,7 +3248,7 @@ var MikroOrmRoundTrips = class MikroOrmRoundTrips2 {
3244
3248
  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));
3245
3249
  return `(${props.map((p) => `?::${types.get(p)}`).join(", ")})`;
3246
3250
  });
3247
- 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));
3251
+ 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));
3248
3252
  const byKey = new Map(chunk.map((i) => {
3249
3253
  const s = results[i];
3250
3254
  return [