@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.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
@@ -419,7 +419,15 @@ var ThinWorkflowRegistrar = class {
419
419
  }
420
420
  onModuleInit() {
421
421
  if (!isPureThinWorker(this.options)) return;
422
- scanWorkflows(this.discovery, (meta, instance) => this.runtime.registerWorkflow(meta.name, (ctx, input) => instance.run(ctx, input)));
422
+ scanWorkflows(this.discovery, (meta, instance, origin) => this.runtime.registerWorkflow(meta.name, (ctx, input) => instance.run(ctx, input), {
423
+ version: meta.version,
424
+ ...meta.requires !== void 0 ? {
425
+ requires: meta.requires
426
+ } : {},
427
+ ...origin !== void 0 ? {
428
+ origin
429
+ } : {}
430
+ }));
423
431
  }
424
432
  };
425
433
  ThinWorkflowRegistrar = _ts_decorate2([
@@ -566,6 +574,9 @@ function unavailableRunGateway() {
566
574
  listRuns(_query) {
567
575
  return tenantGatewayUnavailable("listRuns");
568
576
  },
577
+ runFacets(_query) {
578
+ return tenantGatewayUnavailable("runFacets");
579
+ },
569
580
  waitingFor(_runIds) {
570
581
  return tenantGatewayUnavailable("waitingFor");
571
582
  },
@@ -813,7 +824,15 @@ var InAppWorkerBootstrap = class {
813
824
  }
814
825
  onModuleInit() {
815
826
  if (!isCoLocatedWorker(this.options)) return;
816
- scanWorkflows(this.discovery, (meta, instance) => this.runtime.registerWorkflow(meta.name, (ctx, input) => instance.run(ctx, input)));
827
+ scanWorkflows(this.discovery, (meta, instance, origin) => this.runtime.registerWorkflow(meta.name, (ctx, input) => instance.run(ctx, input), {
828
+ version: meta.version,
829
+ ...meta.requires !== void 0 ? {
830
+ requires: meta.requires
831
+ } : {},
832
+ ...origin !== void 0 ? {
833
+ origin
834
+ } : {}
835
+ }));
817
836
  scanSteps(this.discovery, this.metadataScanner, (meta, handler) => this.runtime.registerStep(meta.name, handler));
818
837
  }
819
838
  async onApplicationBootstrap() {
@@ -980,6 +999,13 @@ var ProxyRunGateway = class {
980
999
  query
981
1000
  });
982
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
+ }
983
1009
  /** Round-trips to the operator, which scopes the result to this tenant's own `@<tenant>` groups. */
984
1010
  workerHealth() {
985
1011
  return this.request({
@@ -1196,6 +1222,19 @@ var RunRequestResponder = class {
1196
1222
  }
1197
1223
  };
1198
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
+ }
1199
1238
  if (body.kind === "workerHealth") {
1200
1239
  const all = await this.gateway.workerHealth();
1201
1240
  const data = all.filter((h) => h.group.endsWith(`@${msg.tenant}`));
@@ -1288,7 +1327,7 @@ var RunRequestResponder = class {
1288
1327
  };
1289
1328
 
1290
1329
  // src/store-run-gateway.ts
1291
- 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";
1292
1331
  import { Inject as Inject5, Injectable as Injectable8 } from "@nestjs/common";
1293
1332
  function _ts_decorate8(decorators, target, key, desc) {
1294
1333
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -1347,6 +1386,21 @@ var StoreRunGateway = class {
1347
1386
  });
1348
1387
  }
1349
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
+ /**
1350
1404
  * Bulk-resolve what each of `runIds` is currently parked on — for a consumer with its own filtered/
1351
1405
  * paginated run listing (e.g. "which of MY suspended runs are stuck at a breakpoint") without
1352
1406
  * re-deriving `listRuns`' waiter scan or querying `durable_step_checkpoints` directly. Mirrors