@dudousxd/nestjs-durable-store-mikro-orm 0.28.1 → 0.29.0

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
@@ -204,7 +204,7 @@ declare class MikroOrmStateStore implements StateStore {
204
204
  }) => Promise<T>): Promise<T>;
205
205
  listIncompleteRuns(namespace?: string): Promise<WorkflowRun[]>;
206
206
  listPendingRuns(limit: number, namespace?: string): Promise<WorkflowRun[]>;
207
- listDueTimers(nowMs: number, namespace?: string): Promise<WorkflowRun[]>;
207
+ listDueTimers(nowMs: number, namespace?: string, limit?: number): Promise<WorkflowRun[]>;
208
208
  tryLockRun(runId: string, owner: string, leaseUntilMs: number, nowMs: number): Promise<boolean>;
209
209
  releaseRunLock(runId: string): Promise<void>;
210
210
  renewRunLock(runId: string, owner: string, leaseUntilMs: number): Promise<boolean>;
@@ -288,6 +288,7 @@ declare class MikroOrmStateStore implements StateStore {
288
288
  listSchedules(query: ScheduleQuery): Promise<ScheduleRecord[]>;
289
289
  listCheckpoints(runId: string): Promise<StepCheckpoint[]>;
290
290
  getLatestCheckpointByName(runId: string, name: string): Promise<StepCheckpoint | undefined>;
291
+ countCheckpoints(runId: string, fromSeq: number, toSeq: number, statuses: StepCheckpoint['status'][]): Promise<number>;
291
292
  listCheckpointsByNamePrefix(runId: string, prefixes: string[]): Promise<StepCheckpoint[]>;
292
293
  putSignalWaiter(waiter: SignalWaiter): Promise<void>;
293
294
  takeSignalWaiter(token: string): Promise<SignalWaiter | null>;
package/dist/index.d.ts CHANGED
@@ -204,7 +204,7 @@ declare class MikroOrmStateStore implements StateStore {
204
204
  }) => Promise<T>): Promise<T>;
205
205
  listIncompleteRuns(namespace?: string): Promise<WorkflowRun[]>;
206
206
  listPendingRuns(limit: number, namespace?: string): Promise<WorkflowRun[]>;
207
- listDueTimers(nowMs: number, namespace?: string): Promise<WorkflowRun[]>;
207
+ listDueTimers(nowMs: number, namespace?: string, limit?: number): Promise<WorkflowRun[]>;
208
208
  tryLockRun(runId: string, owner: string, leaseUntilMs: number, nowMs: number): Promise<boolean>;
209
209
  releaseRunLock(runId: string): Promise<void>;
210
210
  renewRunLock(runId: string, owner: string, leaseUntilMs: number): Promise<boolean>;
@@ -288,6 +288,7 @@ declare class MikroOrmStateStore implements StateStore {
288
288
  listSchedules(query: ScheduleQuery): Promise<ScheduleRecord[]>;
289
289
  listCheckpoints(runId: string): Promise<StepCheckpoint[]>;
290
290
  getLatestCheckpointByName(runId: string, name: string): Promise<StepCheckpoint | undefined>;
291
+ countCheckpoints(runId: string, fromSeq: number, toSeq: number, statuses: StepCheckpoint['status'][]): Promise<number>;
291
292
  listCheckpointsByNamePrefix(runId: string, prefixes: string[]): Promise<StepCheckpoint[]>;
292
293
  putSignalWaiter(waiter: SignalWaiter): Promise<void>;
293
294
  takeSignalWaiter(token: string): Promise<SignalWaiter | null>;
package/dist/index.js CHANGED
@@ -1116,7 +1116,7 @@ var MikroOrmStateStore = class _MikroOrmStateStore {
1116
1116
  });
1117
1117
  return rows.map(fromRunEntity);
1118
1118
  }
1119
- async listDueTimers(nowMs, namespace) {
1119
+ async listDueTimers(nowMs, namespace, limit) {
1120
1120
  const em = this.fork();
1121
1121
  const rows = await em.find(WorkflowRunEntity, {
1122
1122
  status: "suspended",
@@ -1127,6 +1127,13 @@ var MikroOrmStateStore = class _MikroOrmStateStore {
1127
1127
  ...namespace !== void 0 ? {
1128
1128
  namespace
1129
1129
  } : {}
1130
+ }, {
1131
+ orderBy: {
1132
+ wakeAt: "asc"
1133
+ },
1134
+ ...limit !== void 0 ? {
1135
+ limit
1136
+ } : {}
1130
1137
  });
1131
1138
  return rows.map(fromRunEntity);
1132
1139
  }
@@ -1563,6 +1570,19 @@ var MikroOrmStateStore = class _MikroOrmStateStore {
1563
1570
  });
1564
1571
  return entity ? fromCheckpointEntity(entity) : void 0;
1565
1572
  }
1573
+ async countCheckpoints(runId, fromSeq, toSeq, statuses) {
1574
+ if (statuses.length === 0) return 0;
1575
+ return this.fork().count(StepCheckpointEntity, {
1576
+ runId,
1577
+ seq: {
1578
+ $gte: fromSeq,
1579
+ $lte: toSeq
1580
+ },
1581
+ status: {
1582
+ $in: statuses
1583
+ }
1584
+ });
1585
+ }
1566
1586
  async listCheckpointsByNamePrefix(runId, prefixes) {
1567
1587
  if (prefixes.length === 0) return [];
1568
1588
  const em = this.fork();