@dudousxd/nestjs-durable 0.28.0 → 0.30.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 { StepError, WorkflowRef, SingletonConfig, StateStore, Transport, NamedTransport, ControlPlane, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowClass, WorkflowInputOf, StartOptions, RunResult, RunGateway, WorkflowEngine, EntityHandler, RunDetail, RunQuery, WorkflowRun, EngineEvent, RunRequest, RunReply, StepInvocation, TenantEvent } from '@dudousxd/nestjs-durable-core';
1
+ import { StepError, WorkflowRef, SingletonConfig, StateStore, Transport, NamedTransport, ControlPlane, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowClass, WorkflowInputOf, StartOptions, RunResult, RunGateway, WorkflowEngine, EntityHandler, DurableTopology, RunDetail, RunQuery, WorkflowRun, GroupHealth, EngineEvent, RunRequest, RunReply, StepInvocation, TenantEvent } from '@dudousxd/nestjs-durable-core';
2
2
  import { z } from 'zod';
3
3
  import { ConcurrencyOption, StartRunDeps, RunRedisWorkerOptions, RunningWorker, DurableWorkerRuntime } from '@dudousxd/durable-worker';
4
4
  import { DynamicModule, InjectionToken, OnModuleInit, OnApplicationBootstrap, OnApplicationShutdown, Provider } from '@nestjs/common';
@@ -715,8 +715,11 @@ declare class ProxyRunGateway implements RunGateway {
715
715
  constructor(transport: Transport, tenant: string, timeoutMs?: number);
716
716
  private handleReply;
717
717
  private request;
718
+ topology(): DurableTopology;
718
719
  getRunDetail(runId: string): Promise<RunDetail | null>;
719
720
  listRuns(query: RunQuery): Promise<WorkflowRun[]>;
721
+ /** Round-trips to the operator, which scopes the result to this tenant's own `@<tenant>` groups. */
722
+ workerHealth(): Promise<GroupHealth[]>;
720
723
  cancel(runId: string, opts?: {
721
724
  compensate?: boolean;
722
725
  }): Promise<RunResult | null>;
@@ -799,8 +802,12 @@ declare class StoreRunGateway implements RunGateway {
799
802
  private readonly store;
800
803
  private readonly engine;
801
804
  constructor(store: StateStore, engine: WorkflowEngine);
805
+ topology(): DurableTopology;
802
806
  getRunDetail(runId: string): Promise<RunDetail | null>;
803
807
  listRuns(query: RunQuery): Promise<WorkflowRun[]>;
808
+ /** Every group the engine knows about — unscoped. A tenant proxy's request is scoped by the
809
+ * `RunRequestResponder` (to the requester's `@<tenant>` groups); the operator's own UI sees all. */
810
+ workerHealth(): Promise<GroupHealth[]>;
804
811
  cancel(runId: string, opts?: {
805
812
  compensate?: boolean;
806
813
  }): Promise<RunResult | null>;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { StepError, WorkflowRef, SingletonConfig, StateStore, Transport, NamedTransport, ControlPlane, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowClass, WorkflowInputOf, StartOptions, RunResult, RunGateway, WorkflowEngine, EntityHandler, RunDetail, RunQuery, WorkflowRun, EngineEvent, RunRequest, RunReply, StepInvocation, TenantEvent } from '@dudousxd/nestjs-durable-core';
1
+ import { StepError, WorkflowRef, SingletonConfig, StateStore, Transport, NamedTransport, ControlPlane, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowClass, WorkflowInputOf, StartOptions, RunResult, RunGateway, WorkflowEngine, EntityHandler, DurableTopology, RunDetail, RunQuery, WorkflowRun, GroupHealth, EngineEvent, RunRequest, RunReply, StepInvocation, TenantEvent } from '@dudousxd/nestjs-durable-core';
2
2
  import { z } from 'zod';
3
3
  import { ConcurrencyOption, StartRunDeps, RunRedisWorkerOptions, RunningWorker, DurableWorkerRuntime } from '@dudousxd/durable-worker';
4
4
  import { DynamicModule, InjectionToken, OnModuleInit, OnApplicationBootstrap, OnApplicationShutdown, Provider } from '@nestjs/common';
@@ -715,8 +715,11 @@ declare class ProxyRunGateway implements RunGateway {
715
715
  constructor(transport: Transport, tenant: string, timeoutMs?: number);
716
716
  private handleReply;
717
717
  private request;
718
+ topology(): DurableTopology;
718
719
  getRunDetail(runId: string): Promise<RunDetail | null>;
719
720
  listRuns(query: RunQuery): Promise<WorkflowRun[]>;
721
+ /** Round-trips to the operator, which scopes the result to this tenant's own `@<tenant>` groups. */
722
+ workerHealth(): Promise<GroupHealth[]>;
720
723
  cancel(runId: string, opts?: {
721
724
  compensate?: boolean;
722
725
  }): Promise<RunResult | null>;
@@ -799,8 +802,12 @@ declare class StoreRunGateway implements RunGateway {
799
802
  private readonly store;
800
803
  private readonly engine;
801
804
  constructor(store: StateStore, engine: WorkflowEngine);
805
+ topology(): DurableTopology;
802
806
  getRunDetail(runId: string): Promise<RunDetail | null>;
803
807
  listRuns(query: RunQuery): Promise<WorkflowRun[]>;
808
+ /** Every group the engine knows about — unscoped. A tenant proxy's request is scoped by the
809
+ * `RunRequestResponder` (to the requester's `@<tenant>` groups); the operator's own UI sees all. */
810
+ workerHealth(): Promise<GroupHealth[]>;
804
811
  cancel(runId: string, opts?: {
805
812
  compensate?: boolean;
806
813
  }): Promise<RunResult | null>;
package/dist/index.js CHANGED
@@ -424,12 +424,21 @@ function tenantGatewayUnavailable(method) {
424
424
  __name(tenantGatewayUnavailable, "tenantGatewayUnavailable");
425
425
  function unavailableRunGateway() {
426
426
  return {
427
+ // Topology is local metadata, always answerable — a thin worker with no transport is still a tenant.
428
+ topology() {
429
+ return {
430
+ role: "tenant"
431
+ };
432
+ },
427
433
  getRunDetail(_runId) {
428
434
  return tenantGatewayUnavailable("getRunDetail");
429
435
  },
430
436
  listRuns(_query) {
431
437
  return tenantGatewayUnavailable("listRuns");
432
438
  },
439
+ workerHealth() {
440
+ return tenantGatewayUnavailable("workerHealth");
441
+ },
433
442
  cancel(_runId) {
434
443
  return tenantGatewayUnavailable("cancel");
435
444
  },
@@ -815,6 +824,12 @@ var ProxyRunGateway = class {
815
824
  });
816
825
  });
817
826
  }
827
+ topology() {
828
+ return {
829
+ role: "tenant",
830
+ tenant: this.tenant
831
+ };
832
+ }
818
833
  getRunDetail(runId) {
819
834
  return this.request({
820
835
  kind: "getRunDetail",
@@ -827,6 +842,12 @@ var ProxyRunGateway = class {
827
842
  query
828
843
  });
829
844
  }
845
+ /** Round-trips to the operator, which scopes the result to this tenant's own `@<tenant>` groups. */
846
+ workerHealth() {
847
+ return this.request({
848
+ kind: "workerHealth"
849
+ });
850
+ }
830
851
  cancel(runId, opts) {
831
852
  return this.request(opts === void 0 ? {
832
853
  kind: "cancel",
@@ -1023,6 +1044,17 @@ var RunRequestResponder = class {
1023
1044
  }
1024
1045
  };
1025
1046
  }
1047
+ if (body.kind === "workerHealth") {
1048
+ const all = await this.gateway.workerHealth();
1049
+ const data = all.filter((h) => h.group.endsWith(`@${msg.tenant}`));
1050
+ return {
1051
+ requestId: msg.requestId,
1052
+ result: {
1053
+ ok: true,
1054
+ data
1055
+ }
1056
+ };
1057
+ }
1026
1058
  const detail = await this.gateway.getRunDetail(body.runId);
1027
1059
  if (detail && detail.run.namespace !== msg.tenant) {
1028
1060
  return {
@@ -1110,6 +1142,11 @@ var StoreRunGateway = class {
1110
1142
  this.store = store;
1111
1143
  this.engine = engine;
1112
1144
  }
1145
+ topology() {
1146
+ return {
1147
+ role: "control-plane"
1148
+ };
1149
+ }
1113
1150
  async getRunDetail(runId) {
1114
1151
  const run = await this.store.getRun(runId);
1115
1152
  if (!run) return null;
@@ -1126,6 +1163,11 @@ var StoreRunGateway = class {
1126
1163
  listRuns(query) {
1127
1164
  return this.store.listRuns(query);
1128
1165
  }
1166
+ /** Every group the engine knows about — unscoped. A tenant proxy's request is scoped by the
1167
+ * `RunRequestResponder` (to the requester's `@<tenant>` groups); the operator's own UI sees all. */
1168
+ workerHealth() {
1169
+ return this.engine.workerHealth();
1170
+ }
1129
1171
  cancel(runId, opts) {
1130
1172
  return this.engine.cancel(runId, opts);
1131
1173
  }