@dudousxd/nestjs-durable 0.41.0 → 0.42.1

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
@@ -643,6 +643,9 @@ function unavailableRunGateway() {
643
643
  listRuns(_query) {
644
644
  return tenantGatewayUnavailable("listRuns");
645
645
  },
646
+ runFacets(_query) {
647
+ return tenantGatewayUnavailable("runFacets");
648
+ },
646
649
  waitingFor(_runIds) {
647
650
  return tenantGatewayUnavailable("waitingFor");
648
651
  },
@@ -1065,6 +1068,13 @@ var ProxyRunGateway = class {
1065
1068
  query
1066
1069
  });
1067
1070
  }
1071
+ /** Counted on the operator, over the same tenant-scoped predicates its `listRuns` reply obeys. */
1072
+ runFacets(query) {
1073
+ return this.request({
1074
+ kind: "runFacets",
1075
+ query
1076
+ });
1077
+ }
1068
1078
  /** Round-trips to the operator, which scopes the result to this tenant's own `@<tenant>` groups. */
1069
1079
  workerHealth() {
1070
1080
  return this.request({
@@ -1281,6 +1291,19 @@ var RunRequestResponder = class {
1281
1291
  }
1282
1292
  };
1283
1293
  }
1294
+ if (body.kind === "runFacets") {
1295
+ const data = await this.gateway.runFacets({
1296
+ ...body.query,
1297
+ namespace: msg.tenant
1298
+ });
1299
+ return {
1300
+ requestId: msg.requestId,
1301
+ result: {
1302
+ ok: true,
1303
+ data
1304
+ }
1305
+ };
1306
+ }
1284
1307
  if (body.kind === "workerHealth") {
1285
1308
  const all = await this.gateway.workerHealth();
1286
1309
  const data = all.filter((h) => h.group.endsWith(`@${msg.tenant}`));
@@ -1432,6 +1455,21 @@ var StoreRunGateway = class {
1432
1455
  });
1433
1456
  }
1434
1457
  /**
1458
+ * The `(status, origin)` counts behind a console's chips, straight off the store's aggregate. The
1459
+ * console needs this precisely BECAUSE its list is paginated: the page bounds what is rendered,
1460
+ * these counts stay whole-set exact. A store with no aggregate falls back to counting a full
1461
+ * listing — correct, but the unbounded read this exists to avoid, so it is the last resort.
1462
+ */
1463
+ async runFacets(query) {
1464
+ if (this.store.runFacets) return this.store.runFacets(query);
1465
+ const runs = await this.store.listRuns(query);
1466
+ return (0, import_nestjs_durable_core9.mergeRunFacetRows)(runs.map((r) => ({
1467
+ status: r.status,
1468
+ origin: r.origin,
1469
+ count: 1
1470
+ })));
1471
+ }
1472
+ /**
1435
1473
  * Bulk-resolve what each of `runIds` is currently parked on — for a consumer with its own filtered/
1436
1474
  * paginated run listing (e.g. "which of MY suspended runs are stuck at a breakpoint") without
1437
1475
  * re-deriving `listRuns`' waiter scan or querying `durable_step_checkpoints` directly. Mirrors