@dudousxd/nestjs-durable-store-mikro-orm 0.28.0 → 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.cjs +33 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +33 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -197,13 +197,14 @@ 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>;
|
|
203
204
|
}) => Promise<T>): Promise<T>;
|
|
204
205
|
listIncompleteRuns(namespace?: string): Promise<WorkflowRun[]>;
|
|
205
206
|
listPendingRuns(limit: number, namespace?: string): Promise<WorkflowRun[]>;
|
|
206
|
-
listDueTimers(nowMs: number, namespace?: string): Promise<WorkflowRun[]>;
|
|
207
|
+
listDueTimers(nowMs: number, namespace?: string, limit?: number): Promise<WorkflowRun[]>;
|
|
207
208
|
tryLockRun(runId: string, owner: string, leaseUntilMs: number, nowMs: number): Promise<boolean>;
|
|
208
209
|
releaseRunLock(runId: string): Promise<void>;
|
|
209
210
|
renewRunLock(runId: string, owner: string, leaseUntilMs: number): Promise<boolean>;
|
|
@@ -287,6 +288,7 @@ declare class MikroOrmStateStore implements StateStore {
|
|
|
287
288
|
listSchedules(query: ScheduleQuery): Promise<ScheduleRecord[]>;
|
|
288
289
|
listCheckpoints(runId: string): Promise<StepCheckpoint[]>;
|
|
289
290
|
getLatestCheckpointByName(runId: string, name: string): Promise<StepCheckpoint | undefined>;
|
|
291
|
+
countCheckpoints(runId: string, fromSeq: number, toSeq: number, statuses: StepCheckpoint['status'][]): Promise<number>;
|
|
290
292
|
listCheckpointsByNamePrefix(runId: string, prefixes: string[]): Promise<StepCheckpoint[]>;
|
|
291
293
|
putSignalWaiter(waiter: SignalWaiter): Promise<void>;
|
|
292
294
|
takeSignalWaiter(token: string): Promise<SignalWaiter | null>;
|
package/dist/index.d.ts
CHANGED
|
@@ -197,13 +197,14 @@ 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>;
|
|
203
204
|
}) => Promise<T>): Promise<T>;
|
|
204
205
|
listIncompleteRuns(namespace?: string): Promise<WorkflowRun[]>;
|
|
205
206
|
listPendingRuns(limit: number, namespace?: string): Promise<WorkflowRun[]>;
|
|
206
|
-
listDueTimers(nowMs: number, namespace?: string): Promise<WorkflowRun[]>;
|
|
207
|
+
listDueTimers(nowMs: number, namespace?: string, limit?: number): Promise<WorkflowRun[]>;
|
|
207
208
|
tryLockRun(runId: string, owner: string, leaseUntilMs: number, nowMs: number): Promise<boolean>;
|
|
208
209
|
releaseRunLock(runId: string): Promise<void>;
|
|
209
210
|
renewRunLock(runId: string, owner: string, leaseUntilMs: number): Promise<boolean>;
|
|
@@ -287,6 +288,7 @@ declare class MikroOrmStateStore implements StateStore {
|
|
|
287
288
|
listSchedules(query: ScheduleQuery): Promise<ScheduleRecord[]>;
|
|
288
289
|
listCheckpoints(runId: string): Promise<StepCheckpoint[]>;
|
|
289
290
|
getLatestCheckpointByName(runId: string, name: string): Promise<StepCheckpoint | undefined>;
|
|
291
|
+
countCheckpoints(runId: string, fromSeq: number, toSeq: number, statuses: StepCheckpoint['status'][]): Promise<number>;
|
|
290
292
|
listCheckpointsByNamePrefix(runId: string, prefixes: string[]): Promise<StepCheckpoint[]>;
|
|
291
293
|
putSignalWaiter(waiter: SignalWaiter): Promise<void>;
|
|
292
294
|
takeSignalWaiter(token: string): Promise<SignalWaiter | null>;
|
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,
|
|
@@ -1104,7 +1116,7 @@ var MikroOrmStateStore = class _MikroOrmStateStore {
|
|
|
1104
1116
|
});
|
|
1105
1117
|
return rows.map(fromRunEntity);
|
|
1106
1118
|
}
|
|
1107
|
-
async listDueTimers(nowMs, namespace) {
|
|
1119
|
+
async listDueTimers(nowMs, namespace, limit) {
|
|
1108
1120
|
const em = this.fork();
|
|
1109
1121
|
const rows = await em.find(WorkflowRunEntity, {
|
|
1110
1122
|
status: "suspended",
|
|
@@ -1115,6 +1127,13 @@ var MikroOrmStateStore = class _MikroOrmStateStore {
|
|
|
1115
1127
|
...namespace !== void 0 ? {
|
|
1116
1128
|
namespace
|
|
1117
1129
|
} : {}
|
|
1130
|
+
}, {
|
|
1131
|
+
orderBy: {
|
|
1132
|
+
wakeAt: "asc"
|
|
1133
|
+
},
|
|
1134
|
+
...limit !== void 0 ? {
|
|
1135
|
+
limit
|
|
1136
|
+
} : {}
|
|
1118
1137
|
});
|
|
1119
1138
|
return rows.map(fromRunEntity);
|
|
1120
1139
|
}
|
|
@@ -1551,6 +1570,19 @@ var MikroOrmStateStore = class _MikroOrmStateStore {
|
|
|
1551
1570
|
});
|
|
1552
1571
|
return entity ? fromCheckpointEntity(entity) : void 0;
|
|
1553
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
|
+
}
|
|
1554
1586
|
async listCheckpointsByNamePrefix(runId, prefixes) {
|
|
1555
1587
|
if (prefixes.length === 0) return [];
|
|
1556
1588
|
const em = this.fork();
|