@dudousxd/nestjs-durable-store-prisma 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 +23 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +24 -6
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2,7 +2,10 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
4
|
// src/prisma-state-store.ts
|
|
5
|
-
import { RUN_VALUE_FACET_SCAN, SINGLETON_ACTIVE_STATUSES, SINGLETON_LOCK_CHUNK, TERMINAL_RUN_STATUSES, attributePredicateOperands, axisIsRunColumn, clearTerminalSingletonAdmission, mergeRunFacetRows, mergeRunValueFacetRows, normalizeAttributeRows, parseDuration, runValueFacetsFromRuns, singletonAdmissionDenialPatch, singletonAdmissionTags, singletonClaimantIds } from "@dudousxd/nestjs-durable-core";
|
|
5
|
+
import { LIFECYCLE_REGISTRY_WORKFLOW, RUN_VALUE_FACET_SCAN, SINGLETON_ACTIVE_STATUSES, SINGLETON_LOCK_CHUNK, TERMINAL_RUN_STATUSES, attributePredicateOperands, axisIsRunColumn, clearTerminalSingletonAdmission, mergeRunFacetRows, mergeRunValueFacetRows, normalizeAttributeRows, parseDuration, retentionKeeps, runValueFacetsFromRuns, singletonAdmissionDenialPatch, singletonAdmissionTags, singletonClaimantIds } from "@dudousxd/nestjs-durable-core";
|
|
6
|
+
var RETENTION_EXCLUDED = [
|
|
7
|
+
LIFECYCLE_REGISTRY_WORKFLOW
|
|
8
|
+
];
|
|
6
9
|
function namespaceWhere(namespace) {
|
|
7
10
|
if (namespace === void 0) return {};
|
|
8
11
|
return {
|
|
@@ -219,7 +222,8 @@ var PrismaStateStore = class {
|
|
|
219
222
|
if (policy.maxAge == null && policy.maxCount == null) return 0;
|
|
220
223
|
const scoped = this.runWhere({
|
|
221
224
|
...policy.scope ?? {},
|
|
222
|
-
statuses
|
|
225
|
+
statuses,
|
|
226
|
+
excludeWorkflows: RETENTION_EXCLUDED
|
|
223
227
|
});
|
|
224
228
|
const ids = /* @__PURE__ */ new Set();
|
|
225
229
|
if (policy.maxAge != null) {
|
|
@@ -236,20 +240,22 @@ var PrismaStateStore = class {
|
|
|
236
240
|
]
|
|
237
241
|
},
|
|
238
242
|
select: {
|
|
239
|
-
id: true
|
|
243
|
+
id: true,
|
|
244
|
+
tags: true
|
|
240
245
|
},
|
|
241
246
|
orderBy: {
|
|
242
247
|
updatedAt: "asc"
|
|
243
248
|
},
|
|
244
249
|
take: limit
|
|
245
250
|
});
|
|
246
|
-
for (const r of rows) ids.add(r.id);
|
|
251
|
+
for (const r of rows) if (!retentionKeeps(r.tags)) ids.add(r.id);
|
|
247
252
|
}
|
|
248
253
|
if (policy.maxCount != null && ids.size < limit) {
|
|
249
254
|
const rows = await this.db.durableWorkflowRun.findMany({
|
|
250
255
|
where: scoped,
|
|
251
256
|
select: {
|
|
252
|
-
id: true
|
|
257
|
+
id: true,
|
|
258
|
+
tags: true
|
|
253
259
|
},
|
|
254
260
|
orderBy: [
|
|
255
261
|
{
|
|
@@ -264,7 +270,7 @@ var PrismaStateStore = class {
|
|
|
264
270
|
});
|
|
265
271
|
for (const r of rows) {
|
|
266
272
|
if (ids.size >= limit) break;
|
|
267
|
-
ids.add(r.id);
|
|
273
|
+
if (!retentionKeeps(r.tags)) ids.add(r.id);
|
|
268
274
|
}
|
|
269
275
|
}
|
|
270
276
|
const doomed = [
|
|
@@ -610,6 +616,18 @@ var PrismaStateStore = class {
|
|
|
610
616
|
if (query.workflows) and.push(anyOf(query.workflows.map((w) => ({
|
|
611
617
|
workflow: w
|
|
612
618
|
}))));
|
|
619
|
+
if (query.excludeWorkflows?.length) and.push({
|
|
620
|
+
workflow: {
|
|
621
|
+
notIn: query.excludeWorkflows
|
|
622
|
+
}
|
|
623
|
+
});
|
|
624
|
+
if (query.updatedAfter !== void 0) {
|
|
625
|
+
and.push({
|
|
626
|
+
updatedAt: {
|
|
627
|
+
gte: new Date(query.updatedAfter)
|
|
628
|
+
}
|
|
629
|
+
});
|
|
630
|
+
}
|
|
613
631
|
if (query.namespaces) and.push(anyOf(query.namespaces.map((n) => ({
|
|
614
632
|
namespace: n
|
|
615
633
|
}))));
|