@dudousxd/nestjs-durable-store-typeorm 0.25.8 → 0.26.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 +16 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -5
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1090,6 +1090,9 @@ __name(existingColumns, "existingColumns");
|
|
|
1090
1090
|
// src/typeorm-state-store.ts
|
|
1091
1091
|
var import_nestjs_durable_core = require("@dudousxd/nestjs-durable-core");
|
|
1092
1092
|
var import_typeorm2 = require("typeorm");
|
|
1093
|
+
var RETENTION_EXCLUDED = [
|
|
1094
|
+
import_nestjs_durable_core.LIFECYCLE_REGISTRY_WORKFLOW
|
|
1095
|
+
];
|
|
1093
1096
|
var CHECKPOINT_NAME_KIND_SQL = "CASE WHEN cp.name LIKE 'signal:child:%' THEN 'child' WHEN cp.name LIKE 'fan:%' THEN 'folded' WHEN cp.name LIKE 'spawn:%' THEN 'spawn' ELSE 'step' END";
|
|
1094
1097
|
var sqliteSingletonClaims = /* @__PURE__ */ new WeakMap();
|
|
1095
1098
|
var TypeOrmStateStore = class {
|
|
@@ -1297,21 +1300,22 @@ var TypeOrmStateStore = class {
|
|
|
1297
1300
|
if (policy.maxAge == null && policy.maxCount == null) return 0;
|
|
1298
1301
|
const scoped = /* @__PURE__ */ __name(() => this.runQueryBuilder({
|
|
1299
1302
|
...policy.scope ?? {},
|
|
1300
|
-
statuses
|
|
1301
|
-
|
|
1303
|
+
statuses,
|
|
1304
|
+
excludeWorkflows: RETENTION_EXCLUDED
|
|
1305
|
+
}).select("r.id", "id").addSelect("r.tags", "tags"), "scoped");
|
|
1302
1306
|
const ids = /* @__PURE__ */ new Set();
|
|
1303
1307
|
if (policy.maxAge != null) {
|
|
1304
1308
|
const cutoff = new Date(nowMs - (0, import_nestjs_durable_core.parseDuration)(policy.maxAge));
|
|
1305
1309
|
const rows = await scoped().andWhere("r.updatedAt < :cutoff", {
|
|
1306
1310
|
cutoff
|
|
1307
1311
|
}).orderBy("r.updatedAt", "ASC").limit(limit).getRawMany();
|
|
1308
|
-
for (const r of rows) ids.add(r.id);
|
|
1312
|
+
for (const r of rows) if (!(0, import_nestjs_durable_core.retentionKeeps)(r.tags)) ids.add(r.id);
|
|
1309
1313
|
}
|
|
1310
1314
|
if (policy.maxCount != null && ids.size < limit) {
|
|
1311
1315
|
const rows = await scoped().orderBy("r.updatedAt", "DESC").addOrderBy("r.id", "DESC").limit(limit).offset(policy.maxCount).getRawMany();
|
|
1312
1316
|
for (const r of rows) {
|
|
1313
1317
|
if (ids.size >= limit) break;
|
|
1314
|
-
ids.add(r.id);
|
|
1318
|
+
if (!(0, import_nestjs_durable_core.retentionKeeps)(r.tags)) ids.add(r.id);
|
|
1315
1319
|
}
|
|
1316
1320
|
}
|
|
1317
1321
|
const doomed = [
|
|
@@ -1629,6 +1633,14 @@ var TypeOrmStateStore = class {
|
|
|
1629
1633
|
if (query.workflows) qb.andWhere(query.workflows.length ? "r.workflow IN (:...workflows)" : "1 = 0", query.workflows.length ? {
|
|
1630
1634
|
workflows: query.workflows
|
|
1631
1635
|
} : {});
|
|
1636
|
+
if (query.excludeWorkflows?.length) qb.andWhere("r.workflow NOT IN (:...excludeWorkflows)", {
|
|
1637
|
+
excludeWorkflows: query.excludeWorkflows
|
|
1638
|
+
});
|
|
1639
|
+
if (query.updatedAfter !== void 0) {
|
|
1640
|
+
qb.andWhere("r.updatedAt >= :updatedAfter", {
|
|
1641
|
+
updatedAfter: new Date(query.updatedAfter)
|
|
1642
|
+
});
|
|
1643
|
+
}
|
|
1632
1644
|
if (query.namespace !== void 0) qb.andWhere("r.namespace = :namespace", {
|
|
1633
1645
|
namespace: query.namespace
|
|
1634
1646
|
});
|