@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.cjs
CHANGED
|
@@ -1108,6 +1108,18 @@ var MikroOrmStateStore = class _MikroOrmStateStore {
|
|
|
1108
1108
|
await em.upsert(StepCheckpointEntity, toCheckpointEntity(checkpoint));
|
|
1109
1109
|
await em.flush();
|
|
1110
1110
|
}
|
|
1111
|
+
async saveCheckpointIfPending(checkpoint) {
|
|
1112
|
+
const { runId: _runId, seq: _seq, ...data } = toCheckpointEntity(checkpoint);
|
|
1113
|
+
const affected = await this.fork().nativeUpdate(StepCheckpointEntity, {
|
|
1114
|
+
runId: checkpoint.runId,
|
|
1115
|
+
seq: checkpoint.seq,
|
|
1116
|
+
status: "pending"
|
|
1117
|
+
}, {
|
|
1118
|
+
...data,
|
|
1119
|
+
wakeAt: checkpoint.wakeAt != null ? new Date(checkpoint.wakeAt) : null
|
|
1120
|
+
});
|
|
1121
|
+
return affected > 0;
|
|
1122
|
+
}
|
|
1111
1123
|
async transaction(work) {
|
|
1112
1124
|
return this.fork().transactional(async (em) => work({
|
|
1113
1125
|
raw: em,
|
|
@@ -1146,7 +1158,7 @@ var MikroOrmStateStore = class _MikroOrmStateStore {
|
|
|
1146
1158
|
});
|
|
1147
1159
|
return rows.map(fromRunEntity);
|
|
1148
1160
|
}
|
|
1149
|
-
async listDueTimers(nowMs, namespace) {
|
|
1161
|
+
async listDueTimers(nowMs, namespace, limit) {
|
|
1150
1162
|
const em = this.fork();
|
|
1151
1163
|
const rows = await em.find(WorkflowRunEntity, {
|
|
1152
1164
|
status: "suspended",
|
|
@@ -1157,6 +1169,13 @@ var MikroOrmStateStore = class _MikroOrmStateStore {
|
|
|
1157
1169
|
...namespace !== void 0 ? {
|
|
1158
1170
|
namespace
|
|
1159
1171
|
} : {}
|
|
1172
|
+
}, {
|
|
1173
|
+
orderBy: {
|
|
1174
|
+
wakeAt: "asc"
|
|
1175
|
+
},
|
|
1176
|
+
...limit !== void 0 ? {
|
|
1177
|
+
limit
|
|
1178
|
+
} : {}
|
|
1160
1179
|
});
|
|
1161
1180
|
return rows.map(fromRunEntity);
|
|
1162
1181
|
}
|
|
@@ -1593,6 +1612,19 @@ var MikroOrmStateStore = class _MikroOrmStateStore {
|
|
|
1593
1612
|
});
|
|
1594
1613
|
return entity ? fromCheckpointEntity(entity) : void 0;
|
|
1595
1614
|
}
|
|
1615
|
+
async countCheckpoints(runId, fromSeq, toSeq, statuses) {
|
|
1616
|
+
if (statuses.length === 0) return 0;
|
|
1617
|
+
return this.fork().count(StepCheckpointEntity, {
|
|
1618
|
+
runId,
|
|
1619
|
+
seq: {
|
|
1620
|
+
$gte: fromSeq,
|
|
1621
|
+
$lte: toSeq
|
|
1622
|
+
},
|
|
1623
|
+
status: {
|
|
1624
|
+
$in: statuses
|
|
1625
|
+
}
|
|
1626
|
+
});
|
|
1627
|
+
}
|
|
1596
1628
|
async listCheckpointsByNamePrefix(runId, prefixes) {
|
|
1597
1629
|
if (prefixes.length === 0) return [];
|
|
1598
1630
|
const em = this.fork();
|