@dudousxd/nestjs-durable-store-typeorm 0.20.0 → 0.21.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 +39 -6
- 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 +39 -6
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1104,6 +1104,22 @@ var TypeOrmStateStore = class {
|
|
|
1104
1104
|
"seq"
|
|
1105
1105
|
]);
|
|
1106
1106
|
}
|
|
1107
|
+
async saveCheckpointIfPending(checkpoint) {
|
|
1108
|
+
const { runId, seq, ...data } = toCheckpointEntity(checkpoint);
|
|
1109
|
+
const set = {
|
|
1110
|
+
...data,
|
|
1111
|
+
wakeAt: checkpoint.wakeAt != null ? new Date(checkpoint.wakeAt) : () => "NULL"
|
|
1112
|
+
};
|
|
1113
|
+
for (const key of Object.keys(set)) {
|
|
1114
|
+
if (set[key] === void 0) delete set[key];
|
|
1115
|
+
}
|
|
1116
|
+
const result = await this.checkpoints().createQueryBuilder().update().set(set).where({
|
|
1117
|
+
runId,
|
|
1118
|
+
seq,
|
|
1119
|
+
status: "pending"
|
|
1120
|
+
}).execute();
|
|
1121
|
+
return (result.affected ?? 0) > 0;
|
|
1122
|
+
}
|
|
1107
1123
|
async transaction(work) {
|
|
1108
1124
|
return this.dataSource.transaction(async (em) => work({
|
|
1109
1125
|
raw: em,
|
|
@@ -1146,12 +1162,20 @@ var TypeOrmStateStore = class {
|
|
|
1146
1162
|
});
|
|
1147
1163
|
return rows.map(fromRunEntity);
|
|
1148
1164
|
}
|
|
1149
|
-
async listDueTimers(nowMs, namespace) {
|
|
1150
|
-
const rows = await this.runs().
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
namespace
|
|
1165
|
+
async listDueTimers(nowMs, namespace, limit) {
|
|
1166
|
+
const rows = await this.runs().find({
|
|
1167
|
+
where: {
|
|
1168
|
+
status: "suspended",
|
|
1169
|
+
wakeAt: (0, import_typeorm2.LessThanOrEqual)(new Date(nowMs)),
|
|
1170
|
+
...namespace !== void 0 ? {
|
|
1171
|
+
namespace
|
|
1172
|
+
} : {}
|
|
1173
|
+
},
|
|
1174
|
+
order: {
|
|
1175
|
+
wakeAt: "ASC"
|
|
1176
|
+
},
|
|
1177
|
+
...limit !== void 0 ? {
|
|
1178
|
+
take: limit
|
|
1155
1179
|
} : {}
|
|
1156
1180
|
});
|
|
1157
1181
|
return rows.map(fromRunEntity);
|
|
@@ -1396,6 +1420,15 @@ var TypeOrmStateStore = class {
|
|
|
1396
1420
|
});
|
|
1397
1421
|
return e ? fromCheckpointEntity(e) : void 0;
|
|
1398
1422
|
}
|
|
1423
|
+
async countCheckpoints(runId, fromSeq, toSeq, statuses) {
|
|
1424
|
+
if (statuses.length === 0) return 0;
|
|
1425
|
+
const row = await this.checkpoints().createQueryBuilder("cp").select("COUNT(*)", "count").where({
|
|
1426
|
+
runId,
|
|
1427
|
+
seq: (0, import_typeorm2.Between)(fromSeq, toSeq),
|
|
1428
|
+
status: (0, import_typeorm2.In)(statuses)
|
|
1429
|
+
}).getRawOne();
|
|
1430
|
+
return Number(row?.count ?? 0);
|
|
1431
|
+
}
|
|
1399
1432
|
async listCheckpointsByNamePrefix(runId, prefixes) {
|
|
1400
1433
|
if (prefixes.length === 0) return [];
|
|
1401
1434
|
const rows = await this.checkpoints().find({
|