@dudousxd/nestjs-durable-store-drizzle 0.24.7 → 0.25.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 +13 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -6
- package/dist/index.js.map +1 -1
- package/dist/pg/index.cjs +13 -5
- package/dist/pg/index.cjs.map +1 -1
- package/dist/pg/index.js +14 -6
- package/dist/pg/index.js.map +1 -1
- package/package.json +3 -3
package/dist/pg/index.cjs
CHANGED
|
@@ -406,6 +406,9 @@ function durablePgManagedTables() {
|
|
|
406
406
|
__name(durablePgManagedTables, "durablePgManagedTables");
|
|
407
407
|
|
|
408
408
|
// src/pg/drizzle-pg-state-store.ts
|
|
409
|
+
var RETENTION_EXCLUDED = [
|
|
410
|
+
import_nestjs_durable_core.LIFECYCLE_REGISTRY_WORKFLOW
|
|
411
|
+
];
|
|
409
412
|
function anyOf(conditions) {
|
|
410
413
|
const present = conditions.filter((c) => c !== void 0);
|
|
411
414
|
return present.length ? (0, import_drizzle_orm4.or)(...present) : import_drizzle_orm4.sql`1 = 0`;
|
|
@@ -552,28 +555,31 @@ var DrizzlePgStateStore = class _DrizzlePgStateStore {
|
|
|
552
555
|
if (policy.maxAge == null && policy.maxCount == null) return 0;
|
|
553
556
|
const scoped = this.runFilters({
|
|
554
557
|
...policy.scope ?? {},
|
|
555
|
-
statuses
|
|
558
|
+
statuses,
|
|
559
|
+
excludeWorkflows: RETENTION_EXCLUDED
|
|
556
560
|
});
|
|
557
561
|
return this.db.transaction(async (tx) => {
|
|
558
562
|
const ids = /* @__PURE__ */ new Set();
|
|
559
563
|
if (policy.maxAge != null) {
|
|
560
564
|
const cutoff = new Date(nowMs - (0, import_nestjs_durable_core.parseDuration)(policy.maxAge));
|
|
561
565
|
const rows = await tx.select({
|
|
562
|
-
id: durableWorkflowRuns.id
|
|
566
|
+
id: durableWorkflowRuns.id,
|
|
567
|
+
tags: durableWorkflowRuns.tags
|
|
563
568
|
}).from(durableWorkflowRuns).where((0, import_drizzle_orm4.and)(...scoped, (0, import_drizzle_orm4.lt)(durableWorkflowRuns.updatedAt, cutoff))).orderBy((0, import_drizzle_orm4.asc)(durableWorkflowRuns.updatedAt)).limit(limit).for("update", {
|
|
564
569
|
skipLocked: true
|
|
565
570
|
});
|
|
566
|
-
for (const r of rows) ids.add(r.id);
|
|
571
|
+
for (const r of rows) if (!(0, import_nestjs_durable_core.retentionKeeps)(r.tags)) ids.add(r.id);
|
|
567
572
|
}
|
|
568
573
|
if (policy.maxCount != null && ids.size < limit) {
|
|
569
574
|
const rows = await tx.select({
|
|
570
|
-
id: durableWorkflowRuns.id
|
|
575
|
+
id: durableWorkflowRuns.id,
|
|
576
|
+
tags: durableWorkflowRuns.tags
|
|
571
577
|
}).from(durableWorkflowRuns).where((0, import_drizzle_orm4.and)(...scoped)).orderBy((0, import_drizzle_orm4.desc)(durableWorkflowRuns.updatedAt), (0, import_drizzle_orm4.desc)(durableWorkflowRuns.id)).limit(limit).offset(policy.maxCount).for("update", {
|
|
572
578
|
skipLocked: true
|
|
573
579
|
});
|
|
574
580
|
for (const r of rows) {
|
|
575
581
|
if (ids.size >= limit) break;
|
|
576
|
-
ids.add(r.id);
|
|
582
|
+
if (!(0, import_nestjs_durable_core.retentionKeeps)(r.tags)) ids.add(r.id);
|
|
577
583
|
}
|
|
578
584
|
}
|
|
579
585
|
if (ids.size === 0) return 0;
|
|
@@ -751,6 +757,8 @@ var DrizzlePgStateStore = class _DrizzlePgStateStore {
|
|
|
751
757
|
this.scope(),
|
|
752
758
|
query.workflow ? (0, import_drizzle_orm4.eq)(durableWorkflowRuns.workflow, query.workflow) : void 0,
|
|
753
759
|
query.workflows ? query.workflows.length ? (0, import_drizzle_orm4.inArray)(durableWorkflowRuns.workflow, query.workflows) : import_drizzle_orm4.sql`1 = 0` : void 0,
|
|
760
|
+
query.excludeWorkflows?.length ? (0, import_drizzle_orm4.notInArray)(durableWorkflowRuns.workflow, query.excludeWorkflows) : void 0,
|
|
761
|
+
query.updatedAfter !== void 0 ? (0, import_drizzle_orm4.gte)(durableWorkflowRuns.updatedAt, new Date(query.updatedAfter)) : void 0,
|
|
754
762
|
// The tenant boundary. Also the engine's execution-timeout sweep path
|
|
755
763
|
// (`listRuns({ workflow, status, namespace })`) — unscoped, it would cancel another tenant's runs.
|
|
756
764
|
namespaceFilter(query.namespace),
|