@dudousxd/nestjs-durable 0.40.0 → 0.42.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
@@ -488,7 +488,15 @@ var ThinWorkflowRegistrar = class {
488
488
  }
489
489
  onModuleInit() {
490
490
  if (!isPureThinWorker(this.options)) return;
491
- scanWorkflows(this.discovery, (meta, instance) => this.runtime.registerWorkflow(meta.name, (ctx, input) => instance.run(ctx, input)));
491
+ scanWorkflows(this.discovery, (meta, instance, origin) => this.runtime.registerWorkflow(meta.name, (ctx, input) => instance.run(ctx, input), {
492
+ version: meta.version,
493
+ ...meta.requires !== void 0 ? {
494
+ requires: meta.requires
495
+ } : {},
496
+ ...origin !== void 0 ? {
497
+ origin
498
+ } : {}
499
+ }));
492
500
  }
493
501
  };
494
502
  ThinWorkflowRegistrar = _ts_decorate2([
@@ -635,6 +643,9 @@ function unavailableRunGateway() {
635
643
  listRuns(_query) {
636
644
  return tenantGatewayUnavailable("listRuns");
637
645
  },
646
+ runFacets(_query) {
647
+ return tenantGatewayUnavailable("runFacets");
648
+ },
638
649
  waitingFor(_runIds) {
639
650
  return tenantGatewayUnavailable("waitingFor");
640
651
  },
@@ -882,7 +893,15 @@ var InAppWorkerBootstrap = class {
882
893
  }
883
894
  onModuleInit() {
884
895
  if (!isCoLocatedWorker(this.options)) return;
885
- scanWorkflows(this.discovery, (meta, instance) => this.runtime.registerWorkflow(meta.name, (ctx, input) => instance.run(ctx, input)));
896
+ scanWorkflows(this.discovery, (meta, instance, origin) => this.runtime.registerWorkflow(meta.name, (ctx, input) => instance.run(ctx, input), {
897
+ version: meta.version,
898
+ ...meta.requires !== void 0 ? {
899
+ requires: meta.requires
900
+ } : {},
901
+ ...origin !== void 0 ? {
902
+ origin
903
+ } : {}
904
+ }));
886
905
  scanSteps(this.discovery, this.metadataScanner, (meta, handler) => this.runtime.registerStep(meta.name, handler));
887
906
  }
888
907
  async onApplicationBootstrap() {
@@ -1049,6 +1068,13 @@ var ProxyRunGateway = class {
1049
1068
  query
1050
1069
  });
1051
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
+ }
1052
1078
  /** Round-trips to the operator, which scopes the result to this tenant's own `@<tenant>` groups. */
1053
1079
  workerHealth() {
1054
1080
  return this.request({
@@ -1265,6 +1291,19 @@ var RunRequestResponder = class {
1265
1291
  }
1266
1292
  };
1267
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
+ }
1268
1307
  if (body.kind === "workerHealth") {
1269
1308
  const all = await this.gateway.workerHealth();
1270
1309
  const data = all.filter((h) => h.group.endsWith(`@${msg.tenant}`));
@@ -1416,6 +1455,21 @@ var StoreRunGateway = class {
1416
1455
  });
1417
1456
  }
1418
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
+ /**
1419
1473
  * Bulk-resolve what each of `runIds` is currently parked on — for a consumer with its own filtered/
1420
1474
  * paginated run listing (e.g. "which of MY suspended runs are stuck at a breakpoint") without
1421
1475
  * re-deriving `listRuns`' waiter scan or querying `durable_step_checkpoints` directly. Mirrors