@dudousxd/nestjs-durable-store-mikro-orm 0.33.8 → 0.34.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 CHANGED
@@ -1095,6 +1095,9 @@ async function alignDurableCollation(orm) {
1095
1095
  __name(alignDurableCollation, "alignDurableCollation");
1096
1096
 
1097
1097
  // src/mikro-orm-state-store.ts
1098
+ var RETENTION_EXCLUDED = [
1099
+ import_nestjs_durable_core.LIFECYCLE_REGISTRY_WORKFLOW
1100
+ ];
1098
1101
  var MikroOrmStateStore = class _MikroOrmStateStore {
1099
1102
  static {
1100
1103
  __name(this, "MikroOrmStateStore");
@@ -1322,13 +1325,16 @@ var MikroOrmStateStore = class _MikroOrmStateStore {
1322
1325
  const idCol = meta.properties.id?.fieldNames?.[0] ?? "id";
1323
1326
  const query = {
1324
1327
  ...policy.scope ?? {},
1325
- statuses
1328
+ statuses,
1329
+ excludeWorkflows: RETENTION_EXCLUDED
1326
1330
  };
1331
+ const tagsCol = meta.properties.tags?.fieldNames?.[0] ?? "tags";
1327
1332
  const scoped = /* @__PURE__ */ __name((extra) => this.runQueryBuilder(em, query, {
1328
1333
  ...this.runWhere(query),
1329
1334
  ...extra ?? {}
1330
1335
  }).select([
1331
- `r.${idCol}`
1336
+ `r.${idCol}`,
1337
+ `r.${tagsCol}`
1332
1338
  ]), "scoped");
1333
1339
  const ids = /* @__PURE__ */ new Set();
1334
1340
  if (policy.maxAge != null) {
@@ -1340,7 +1346,9 @@ var MikroOrmStateStore = class _MikroOrmStateStore {
1340
1346
  }).orderBy({
1341
1347
  "r.updatedAt": "asc"
1342
1348
  }).limit(limit).execute();
1343
- for (const r of rows) ids.add(String(r[idCol] ?? r.id));
1349
+ for (const r of rows) {
1350
+ if (!(0, import_nestjs_durable_core.retentionKeeps)(r[tagsCol] ?? r.tags)) ids.add(String(r[idCol] ?? r.id));
1351
+ }
1344
1352
  }
1345
1353
  if (policy.maxCount != null && ids.size < limit) {
1346
1354
  const rows = await scoped().orderBy({
@@ -1349,7 +1357,7 @@ var MikroOrmStateStore = class _MikroOrmStateStore {
1349
1357
  }).limit(limit).offset(policy.maxCount).execute();
1350
1358
  for (const r of rows) {
1351
1359
  if (ids.size >= limit) break;
1352
- ids.add(String(r[idCol] ?? r.id));
1360
+ if (!(0, import_nestjs_durable_core.retentionKeeps)(r[tagsCol] ?? r.tags)) ids.add(String(r[idCol] ?? r.id));
1353
1361
  }
1354
1362
  }
1355
1363
  const idList = [
@@ -1647,6 +1655,18 @@ var MikroOrmStateStore = class _MikroOrmStateStore {
1647
1655
  $in: query.workflows
1648
1656
  }
1649
1657
  });
1658
+ if (query.excludeWorkflows?.length) and.push({
1659
+ workflow: {
1660
+ $nin: query.excludeWorkflows
1661
+ }
1662
+ });
1663
+ if (query.updatedAfter !== void 0) {
1664
+ and.push({
1665
+ updatedAt: {
1666
+ $gte: new Date(query.updatedAfter)
1667
+ }
1668
+ });
1669
+ }
1650
1670
  if (query.namespace !== void 0) where.namespace = query.namespace;
1651
1671
  if (query.namespaces) and.push({
1652
1672
  namespace: {