@dudousxd/nestjs-durable-store-mikro-orm 0.28.0 → 0.28.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
@@ -197,6 +197,7 @@ declare class MikroOrmStateStore implements StateStore {
197
197
  pruneTerminalRuns(policy: RetentionPolicy, nowMs: number, limit: number): Promise<number>;
198
198
  getCheckpoint(runId: string, seq: number): Promise<StepCheckpoint | null>;
199
199
  saveCheckpoint(checkpoint: StepCheckpoint): Promise<void>;
200
+ saveCheckpointIfPending(checkpoint: StepCheckpoint): Promise<boolean>;
200
201
  transaction<T>(work: (tx: {
201
202
  raw: unknown;
202
203
  saveCheckpoint: (cp: StepCheckpoint) => Promise<void>;
package/dist/index.d.ts CHANGED
@@ -197,6 +197,7 @@ declare class MikroOrmStateStore implements StateStore {
197
197
  pruneTerminalRuns(policy: RetentionPolicy, nowMs: number, limit: number): Promise<number>;
198
198
  getCheckpoint(runId: string, seq: number): Promise<StepCheckpoint | null>;
199
199
  saveCheckpoint(checkpoint: StepCheckpoint): Promise<void>;
200
+ saveCheckpointIfPending(checkpoint: StepCheckpoint): Promise<boolean>;
200
201
  transaction<T>(work: (tx: {
201
202
  raw: unknown;
202
203
  saveCheckpoint: (cp: StepCheckpoint) => Promise<void>;
package/dist/index.js CHANGED
@@ -1066,6 +1066,18 @@ var MikroOrmStateStore = class _MikroOrmStateStore {
1066
1066
  await em.upsert(StepCheckpointEntity, toCheckpointEntity(checkpoint));
1067
1067
  await em.flush();
1068
1068
  }
1069
+ async saveCheckpointIfPending(checkpoint) {
1070
+ const { runId: _runId, seq: _seq, ...data } = toCheckpointEntity(checkpoint);
1071
+ const affected = await this.fork().nativeUpdate(StepCheckpointEntity, {
1072
+ runId: checkpoint.runId,
1073
+ seq: checkpoint.seq,
1074
+ status: "pending"
1075
+ }, {
1076
+ ...data,
1077
+ wakeAt: checkpoint.wakeAt != null ? new Date(checkpoint.wakeAt) : null
1078
+ });
1079
+ return affected > 0;
1080
+ }
1069
1081
  async transaction(work) {
1070
1082
  return this.fork().transactional(async (em) => work({
1071
1083
  raw: em,