@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/index.cjs
CHANGED
|
@@ -250,6 +250,9 @@ function durableManagedTables() {
|
|
|
250
250
|
__name(durableManagedTables, "durableManagedTables");
|
|
251
251
|
|
|
252
252
|
// src/drizzle-state-store.ts
|
|
253
|
+
var RETENTION_EXCLUDED = [
|
|
254
|
+
import_nestjs_durable_core.LIFECYCLE_REGISTRY_WORKFLOW
|
|
255
|
+
];
|
|
253
256
|
function anyOf(conditions) {
|
|
254
257
|
const present = conditions.filter((c) => c !== void 0);
|
|
255
258
|
return present.length ? (0, import_drizzle_orm2.or)(...present) : import_drizzle_orm2.sql`1 = 0`;
|
|
@@ -358,23 +361,26 @@ var DrizzleStateStore = class {
|
|
|
358
361
|
if (policy.maxAge == null && policy.maxCount == null) return 0;
|
|
359
362
|
const scoped = this.runFilters({
|
|
360
363
|
...policy.scope ?? {},
|
|
361
|
-
statuses
|
|
364
|
+
statuses,
|
|
365
|
+
excludeWorkflows: RETENTION_EXCLUDED
|
|
362
366
|
});
|
|
363
367
|
const ids = /* @__PURE__ */ new Set();
|
|
364
368
|
if (policy.maxAge != null) {
|
|
365
369
|
const cutoff = nowMs - (0, import_nestjs_durable_core.parseDuration)(policy.maxAge);
|
|
366
370
|
const rows = await this.db.select({
|
|
367
|
-
id: workflowRuns.id
|
|
371
|
+
id: workflowRuns.id,
|
|
372
|
+
tags: workflowRuns.tags
|
|
368
373
|
}).from(workflowRuns).where((0, import_drizzle_orm2.and)(...scoped, (0, import_drizzle_orm2.lt)(workflowRuns.updatedAt, cutoff))).orderBy((0, import_drizzle_orm2.asc)(workflowRuns.updatedAt)).limit(limit);
|
|
369
|
-
for (const r of rows) ids.add(r.id);
|
|
374
|
+
for (const r of rows) if (!(0, import_nestjs_durable_core.retentionKeeps)(r.tags)) ids.add(r.id);
|
|
370
375
|
}
|
|
371
376
|
if (policy.maxCount != null && ids.size < limit) {
|
|
372
377
|
const rows = await this.db.select({
|
|
373
|
-
id: workflowRuns.id
|
|
378
|
+
id: workflowRuns.id,
|
|
379
|
+
tags: workflowRuns.tags
|
|
374
380
|
}).from(workflowRuns).where((0, import_drizzle_orm2.and)(...scoped)).orderBy((0, import_drizzle_orm2.desc)(workflowRuns.updatedAt), (0, import_drizzle_orm2.desc)(workflowRuns.id)).limit(limit).offset(policy.maxCount);
|
|
375
381
|
for (const r of rows) {
|
|
376
382
|
if (ids.size >= limit) break;
|
|
377
|
-
ids.add(r.id);
|
|
383
|
+
if (!(0, import_nestjs_durable_core.retentionKeeps)(r.tags)) ids.add(r.id);
|
|
378
384
|
}
|
|
379
385
|
}
|
|
380
386
|
const doomed = [
|
|
@@ -623,6 +629,8 @@ var DrizzleStateStore = class {
|
|
|
623
629
|
// The plural form of each axis below: ORed within itself, ANDed with everything else, and an
|
|
624
630
|
// empty set matches nothing — the same contract `statuses` already had.
|
|
625
631
|
query.workflows ? anyOf(query.workflows.map((w) => (0, import_drizzle_orm2.eq)(workflowRuns.workflow, w))) : void 0,
|
|
632
|
+
query.excludeWorkflows?.length ? (0, import_drizzle_orm2.notInArray)(workflowRuns.workflow, query.excludeWorkflows) : void 0,
|
|
633
|
+
query.updatedAfter !== void 0 ? (0, import_drizzle_orm2.gte)(workflowRuns.updatedAt, query.updatedAfter) : void 0,
|
|
626
634
|
// The tenant boundary, ANDed with everything else. This is not only a dashboard facet: it is
|
|
627
635
|
// the fourth namespace-scoped worker path, because `engine.sweepTimeouts` cancels runs past
|
|
628
636
|
// their `executionTimeout` via `listRuns({ workflow, status, namespace })` — unscoped here, a
|