@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.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { WorkflowCtx, SearchAttributes, WorkflowClass, StepError, WorkflowRef, SingletonConfig, SearchAttributesSchema, StateStore, Transport, NamedTransport, ControlPlane, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowInputOf, StartOptions, RunResult, RunGateway, WorkflowEngine, EntityHandler, DurableTopology, RunDetail, RunQuery, RunListItem, GroupHealth, RunWaiting, EngineEvent, RunRequest, RunReply, StepInvocation, TenantEvent } from '@dudousxd/nestjs-durable-core';
1
+ import { WorkflowCtx, SearchAttributes, WorkflowClass, StepError, WorkflowRef, SingletonConfig, SearchAttributesSchema, StateStore, Transport, NamedTransport, ControlPlane, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowInputOf, StartOptions, RunResult, RunGateway, WorkflowEngine, EntityHandler, DurableTopology, RunDetail, RunQuery, RunListItem, RunFacetQuery, RunFacetRow, GroupHealth, RunWaiting, EngineEvent, RunRequest, RunReply, StepInvocation, TenantEvent } from '@dudousxd/nestjs-durable-core';
2
2
  export { AttributeFilter, EngineEvent, InferSearchAttributes, RunDetail, RunGateway, RunListItem, RunQuery, RunStatus, RunWaiting, SearchAttributes, SearchAttributesSchema, StepCheckpoint, StepEvent, StepLogger, WorkflowCtx, WorkflowEngine, WorkflowHandler, WorkflowRun, readSearchAttributes } from '@dudousxd/nestjs-durable-core';
3
3
  import { z } from 'zod';
4
4
  import { ConcurrencyOption, StartRunDeps, RunRedisWorkerOptions, RunningWorker, DurableWorkerRuntime } from '@dudousxd/durable-worker';
@@ -898,6 +898,8 @@ declare class ProxyRunGateway implements RunGateway {
898
898
  /** The control plane's `StoreRunGateway` resolves each run's `waiting` descriptor; the reply carries
899
899
  * it through as plain JSON, so a tenant's list rows name the wait too. */
900
900
  listRuns(query: RunQuery): Promise<RunListItem[]>;
901
+ /** Counted on the operator, over the same tenant-scoped predicates its `listRuns` reply obeys. */
902
+ runFacets(query: RunFacetQuery): Promise<RunFacetRow[]>;
901
903
  /** Round-trips to the operator, which scopes the result to this tenant's own `@<tenant>` groups. */
902
904
  workerHealth(): Promise<GroupHealth[]>;
903
905
  /** Bulk, one request for the whole id list (like `listRuns`, not one request per id). The operator
@@ -991,6 +993,13 @@ declare class StoreRunGateway implements RunGateway {
991
993
  topology(): DurableTopology;
992
994
  getRunDetail(runId: string): Promise<RunDetail | null>;
993
995
  listRuns(query: RunQuery): Promise<RunListItem[]>;
996
+ /**
997
+ * The `(status, origin)` counts behind a console's chips, straight off the store's aggregate. The
998
+ * console needs this precisely BECAUSE its list is paginated: the page bounds what is rendered,
999
+ * these counts stay whole-set exact. A store with no aggregate falls back to counting a full
1000
+ * listing — correct, but the unbounded read this exists to avoid, so it is the last resort.
1001
+ */
1002
+ runFacets(query: RunFacetQuery): Promise<RunFacetRow[]>;
994
1003
  /**
995
1004
  * Bulk-resolve what each of `runIds` is currently parked on — for a consumer with its own filtered/
996
1005
  * paginated run listing (e.g. "which of MY suspended runs are stuck at a breakpoint") without
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { WorkflowCtx, SearchAttributes, WorkflowClass, StepError, WorkflowRef, SingletonConfig, SearchAttributesSchema, StateStore, Transport, NamedTransport, ControlPlane, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowInputOf, StartOptions, RunResult, RunGateway, WorkflowEngine, EntityHandler, DurableTopology, RunDetail, RunQuery, RunListItem, GroupHealth, RunWaiting, EngineEvent, RunRequest, RunReply, StepInvocation, TenantEvent } from '@dudousxd/nestjs-durable-core';
1
+ import { WorkflowCtx, SearchAttributes, WorkflowClass, StepError, WorkflowRef, SingletonConfig, SearchAttributesSchema, StateStore, Transport, NamedTransport, ControlPlane, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowInputOf, StartOptions, RunResult, RunGateway, WorkflowEngine, EntityHandler, DurableTopology, RunDetail, RunQuery, RunListItem, RunFacetQuery, RunFacetRow, GroupHealth, RunWaiting, EngineEvent, RunRequest, RunReply, StepInvocation, TenantEvent } from '@dudousxd/nestjs-durable-core';
2
2
  export { AttributeFilter, EngineEvent, InferSearchAttributes, RunDetail, RunGateway, RunListItem, RunQuery, RunStatus, RunWaiting, SearchAttributes, SearchAttributesSchema, StepCheckpoint, StepEvent, StepLogger, WorkflowCtx, WorkflowEngine, WorkflowHandler, WorkflowRun, readSearchAttributes } from '@dudousxd/nestjs-durable-core';
3
3
  import { z } from 'zod';
4
4
  import { ConcurrencyOption, StartRunDeps, RunRedisWorkerOptions, RunningWorker, DurableWorkerRuntime } from '@dudousxd/durable-worker';
@@ -898,6 +898,8 @@ declare class ProxyRunGateway implements RunGateway {
898
898
  /** The control plane's `StoreRunGateway` resolves each run's `waiting` descriptor; the reply carries
899
899
  * it through as plain JSON, so a tenant's list rows name the wait too. */
900
900
  listRuns(query: RunQuery): Promise<RunListItem[]>;
901
+ /** Counted on the operator, over the same tenant-scoped predicates its `listRuns` reply obeys. */
902
+ runFacets(query: RunFacetQuery): Promise<RunFacetRow[]>;
901
903
  /** Round-trips to the operator, which scopes the result to this tenant's own `@<tenant>` groups. */
902
904
  workerHealth(): Promise<GroupHealth[]>;
903
905
  /** Bulk, one request for the whole id list (like `listRuns`, not one request per id). The operator
@@ -991,6 +993,13 @@ declare class StoreRunGateway implements RunGateway {
991
993
  topology(): DurableTopology;
992
994
  getRunDetail(runId: string): Promise<RunDetail | null>;
993
995
  listRuns(query: RunQuery): Promise<RunListItem[]>;
996
+ /**
997
+ * The `(status, origin)` counts behind a console's chips, straight off the store's aggregate. The
998
+ * console needs this precisely BECAUSE its list is paginated: the page bounds what is rendered,
999
+ * these counts stay whole-set exact. A store with no aggregate falls back to counting a full
1000
+ * listing — correct, but the unbounded read this exists to avoid, so it is the last resort.
1001
+ */
1002
+ runFacets(query: RunFacetQuery): Promise<RunFacetRow[]>;
994
1003
  /**
995
1004
  * Bulk-resolve what each of `runIds` is currently parked on — for a consumer with its own filtered/
996
1005
  * paginated run listing (e.g. "which of MY suspended runs are stuck at a breakpoint") without
package/dist/index.js CHANGED
@@ -574,6 +574,9 @@ function unavailableRunGateway() {
574
574
  listRuns(_query) {
575
575
  return tenantGatewayUnavailable("listRuns");
576
576
  },
577
+ runFacets(_query) {
578
+ return tenantGatewayUnavailable("runFacets");
579
+ },
577
580
  waitingFor(_runIds) {
578
581
  return tenantGatewayUnavailable("waitingFor");
579
582
  },
@@ -996,6 +999,13 @@ var ProxyRunGateway = class {
996
999
  query
997
1000
  });
998
1001
  }
1002
+ /** Counted on the operator, over the same tenant-scoped predicates its `listRuns` reply obeys. */
1003
+ runFacets(query) {
1004
+ return this.request({
1005
+ kind: "runFacets",
1006
+ query
1007
+ });
1008
+ }
999
1009
  /** Round-trips to the operator, which scopes the result to this tenant's own `@<tenant>` groups. */
1000
1010
  workerHealth() {
1001
1011
  return this.request({
@@ -1212,6 +1222,19 @@ var RunRequestResponder = class {
1212
1222
  }
1213
1223
  };
1214
1224
  }
1225
+ if (body.kind === "runFacets") {
1226
+ const data = await this.gateway.runFacets({
1227
+ ...body.query,
1228
+ namespace: msg.tenant
1229
+ });
1230
+ return {
1231
+ requestId: msg.requestId,
1232
+ result: {
1233
+ ok: true,
1234
+ data
1235
+ }
1236
+ };
1237
+ }
1215
1238
  if (body.kind === "workerHealth") {
1216
1239
  const all = await this.gateway.workerHealth();
1217
1240
  const data = all.filter((h) => h.group.endsWith(`@${msg.tenant}`));
@@ -1304,7 +1327,7 @@ var RunRequestResponder = class {
1304
1327
  };
1305
1328
 
1306
1329
  // src/store-run-gateway.ts
1307
- import { STATE_STORE_CANONICAL as STATE_STORE_CANONICAL2, WorkflowEngine as WorkflowEngine2, indexWaitersByRun, resolveRunWaiting } from "@dudousxd/nestjs-durable-core";
1330
+ import { STATE_STORE_CANONICAL as STATE_STORE_CANONICAL2, WorkflowEngine as WorkflowEngine2, indexWaitersByRun, mergeRunFacetRows, resolveRunWaiting } from "@dudousxd/nestjs-durable-core";
1308
1331
  import { Inject as Inject5, Injectable as Injectable8 } from "@nestjs/common";
1309
1332
  function _ts_decorate8(decorators, target, key, desc) {
1310
1333
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -1363,6 +1386,21 @@ var StoreRunGateway = class {
1363
1386
  });
1364
1387
  }
1365
1388
  /**
1389
+ * The `(status, origin)` counts behind a console's chips, straight off the store's aggregate. The
1390
+ * console needs this precisely BECAUSE its list is paginated: the page bounds what is rendered,
1391
+ * these counts stay whole-set exact. A store with no aggregate falls back to counting a full
1392
+ * listing — correct, but the unbounded read this exists to avoid, so it is the last resort.
1393
+ */
1394
+ async runFacets(query) {
1395
+ if (this.store.runFacets) return this.store.runFacets(query);
1396
+ const runs = await this.store.listRuns(query);
1397
+ return mergeRunFacetRows(runs.map((r) => ({
1398
+ status: r.status,
1399
+ origin: r.origin,
1400
+ count: 1
1401
+ })));
1402
+ }
1403
+ /**
1366
1404
  * Bulk-resolve what each of `runIds` is currently parked on — for a consumer with its own filtered/
1367
1405
  * paginated run listing (e.g. "which of MY suspended runs are stuck at a breakpoint") without
1368
1406
  * re-deriving `listRuns`' waiter scan or querying `durable_step_checkpoints` directly. Mirrors