@dudousxd/nestjs-durable-core 0.48.0 → 0.49.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
@@ -1113,6 +1113,16 @@ interface GroupHealth {
1113
1113
  depth: number;
1114
1114
  /** Workers with a non-expired heartbeat for this group. */
1115
1115
  liveWorkers: WorkerHeartbeat[];
1116
+ /**
1117
+ * Whether this group serves a `@Workflow` body or a `@Step`/handler — route-by-handler gives each
1118
+ * its own queue, so a health list mixes both. Classified by the CONTROL PLANE from its authoritative
1119
+ * registry (`workerHealth()`): a group whose base name is a registered workflow is `'workflow'`,
1120
+ * everything else (in-process steps, remote `handle_*`) is `'step'`. `undefined` only when no
1121
+ * control-plane registry was available to classify (e.g. a transport that reports health with no
1122
+ * engine). Lets a dashboard summarise the fleet in domain terms ("N workflows · M steps") instead of
1123
+ * leaking the raw queue count.
1124
+ */
1125
+ kind?: 'workflow' | 'step';
1116
1126
  }
1117
1127
  /**
1118
1128
  * The **control plane** — a broadcast pub/sub across ALL engine instances (every pod), separate
@@ -2722,6 +2732,14 @@ declare class RemoteWorkflowExecutor implements WorkflowExecutor {
2722
2732
  dispatch(run: WorkflowRun, history: HistoryEvent[], taskId: string, pendingSignals?: WorkflowTask['pendingSignals']): Promise<void>;
2723
2733
  }
2724
2734
 
2735
+ /** Which durable topology a gateway speaks for — surfaced in the dashboard so an operator can tell a
2736
+ * control plane from a tenant at a glance (the store-backed gateway is the operator; the proxy is a
2737
+ * tenant). Cheap, synchronous, local knowledge — no round-trip. */
2738
+ interface DurableTopology {
2739
+ role: 'control-plane' | 'tenant';
2740
+ /** The tenant's isolation partition name; set only when `role` is 'tenant'. */
2741
+ tenant?: string;
2742
+ }
2725
2743
  /** A run + its timeline + child ids — the detail view. Mirrors the dashboard's `RunDetail`. */
2726
2744
  interface RunDetail {
2727
2745
  run: WorkflowRun;
@@ -2738,6 +2756,8 @@ interface RunDetail {
2738
2756
  * operator answers it scoped to the requester's own groups, so a tenant's Workers panel works too.
2739
2757
  */
2740
2758
  interface RunGateway {
2759
+ /** This deployment's durable role (control plane vs tenant) — synchronous local metadata. */
2760
+ topology(): DurableTopology;
2741
2761
  getRunDetail(runId: string): Promise<RunDetail | null>;
2742
2762
  listRuns(query: RunQuery): Promise<WorkflowRun[]>;
2743
2763
  /** Per-group worker health (queue backlog + live worker heartbeats). On the control plane this is
@@ -3132,4 +3152,4 @@ declare class InMemoryTransport implements Transport, ControlPlane {
3132
3152
  onControl(handler: (msg: ControlMessage) => void): void;
3133
3153
  }
3134
3154
 
3135
- export { type AccumulatorHost, type Admission, type AdmissionBackend, type AdmissionItem, type AttributeFilter, type AttributeOp, type BackoffStrategy, type ChildCallOptions, CodecStateStore, ContinueAsNew, type ControlMessage, type ControlPlane, DURABLE_OPTIONS, DURABLE_OPTIONS_CANONICAL, DURABLE_STEP_CONFIG, DURABLE_STEP_NAME, type DurableWebhook, DurableWorkflow, type EngineEvent, type EngineEventType, type EngineListener, Entities, type EntityConfig, type EntityHandler, type EntityHost, EventAccumulators, type EventBatchConfig, FatalError, GatherError, type GroupHealth, type Heartbeat, type HistoryEvent, InMemoryAdmissionBackend, InMemoryStateStore, InMemoryTransport, type MetricsCollector, type MetricsSnapshot, type NamedTransport, NonDeterminismError, type PayloadCodec, type QueueConfig, QueueController, RemoteStepError, RemoteStepTimeout, type RemoteTask, RemoteWorkflowExecutor, RemoteWorkflowTimeout, type RetentionPolicy, type RunAttributeRow, type RunDetail, type RunDispatcher, type RunGateway, type RunQuery, type RunReply, type RunReplyResult, type RunRequest, type RunRequestKind, type RunResult, type RunSchedulesOptions, type RunStatus, STATE_STORE, STATE_STORE_CANONICAL, type ScheduledWorkflow, type SearchAttributes, SignalTimeoutError, type SignalWaiter, type SingletonConfig, SingletonQueueFullError, type StartOptions, type StartRunMessage, type StateStore, type StepCheckpoint, type StepConfig, type StepDef, type StepDispatchOpts, type StepError, type StepEvent, type StepHandler, type StepInterceptor, type StepInvocation, type StepKind, type StepLogger, type StepOptions, type StepRef, type StepResult, type StepUndo, type StoreTransaction, type SubProcessHandle, TERMINAL_RUN_STATUSES, TRANSPORT, TRANSPORT_CANONICAL, type TenantEvent, type Transport, type UndoOf, type UpdateResult, type UpdateValidator, WORKFLOW_NAME_KEY, type WorkerAdjust, type WorkerConcurrencyStatus, type WorkerHeartbeat, type WorkerStatus, type WorkflowClass, type WorkflowCommand, type WorkflowCtx, type WorkflowDecision, WorkflowEngine, type WorkflowEngineDeps, type WorkflowExecutor, type WorkflowInputOf, type WorkflowOutputOf, type WorkflowRef, type WorkflowRun, type WorkflowStartClient, type WorkflowStepEvent, WorkflowSuspended, type WorkflowTask, applyAttributeQuery, attributeColumnFor, attributeOperand, bindWorkflowClass, breakpointToken, collectMetrics, createStepLogger, currentWorkflowCtx, eventMatchOf, eventMatches, eventPrefix, eventToken, matchesAttributes, normalizeAttributeRows, parseDuration, prevCronFireMs, runInWorkflowCtx, runSchedules, runStepHandler, sanitizeQueueToken, scheduledRunId, sqlComparator, stepConfigOf, stepId, stepNameOf, tenantGroup, workflowName };
3155
+ export { type AccumulatorHost, type Admission, type AdmissionBackend, type AdmissionItem, type AttributeFilter, type AttributeOp, type BackoffStrategy, type ChildCallOptions, CodecStateStore, ContinueAsNew, type ControlMessage, type ControlPlane, DURABLE_OPTIONS, DURABLE_OPTIONS_CANONICAL, DURABLE_STEP_CONFIG, DURABLE_STEP_NAME, type DurableTopology, type DurableWebhook, DurableWorkflow, type EngineEvent, type EngineEventType, type EngineListener, Entities, type EntityConfig, type EntityHandler, type EntityHost, EventAccumulators, type EventBatchConfig, FatalError, GatherError, type GroupHealth, type Heartbeat, type HistoryEvent, InMemoryAdmissionBackend, InMemoryStateStore, InMemoryTransport, type MetricsCollector, type MetricsSnapshot, type NamedTransport, NonDeterminismError, type PayloadCodec, type QueueConfig, QueueController, RemoteStepError, RemoteStepTimeout, type RemoteTask, RemoteWorkflowExecutor, RemoteWorkflowTimeout, type RetentionPolicy, type RunAttributeRow, type RunDetail, type RunDispatcher, type RunGateway, type RunQuery, type RunReply, type RunReplyResult, type RunRequest, type RunRequestKind, type RunResult, type RunSchedulesOptions, type RunStatus, STATE_STORE, STATE_STORE_CANONICAL, type ScheduledWorkflow, type SearchAttributes, SignalTimeoutError, type SignalWaiter, type SingletonConfig, SingletonQueueFullError, type StartOptions, type StartRunMessage, type StateStore, type StepCheckpoint, type StepConfig, type StepDef, type StepDispatchOpts, type StepError, type StepEvent, type StepHandler, type StepInterceptor, type StepInvocation, type StepKind, type StepLogger, type StepOptions, type StepRef, type StepResult, type StepUndo, type StoreTransaction, type SubProcessHandle, TERMINAL_RUN_STATUSES, TRANSPORT, TRANSPORT_CANONICAL, type TenantEvent, type Transport, type UndoOf, type UpdateResult, type UpdateValidator, WORKFLOW_NAME_KEY, type WorkerAdjust, type WorkerConcurrencyStatus, type WorkerHeartbeat, type WorkerStatus, type WorkflowClass, type WorkflowCommand, type WorkflowCtx, type WorkflowDecision, WorkflowEngine, type WorkflowEngineDeps, type WorkflowExecutor, type WorkflowInputOf, type WorkflowOutputOf, type WorkflowRef, type WorkflowRun, type WorkflowStartClient, type WorkflowStepEvent, WorkflowSuspended, type WorkflowTask, applyAttributeQuery, attributeColumnFor, attributeOperand, bindWorkflowClass, breakpointToken, collectMetrics, createStepLogger, currentWorkflowCtx, eventMatchOf, eventMatches, eventPrefix, eventToken, matchesAttributes, normalizeAttributeRows, parseDuration, prevCronFireMs, runInWorkflowCtx, runSchedules, runStepHandler, sanitizeQueueToken, scheduledRunId, sqlComparator, stepConfigOf, stepId, stepNameOf, tenantGroup, workflowName };
package/dist/index.d.ts CHANGED
@@ -1113,6 +1113,16 @@ interface GroupHealth {
1113
1113
  depth: number;
1114
1114
  /** Workers with a non-expired heartbeat for this group. */
1115
1115
  liveWorkers: WorkerHeartbeat[];
1116
+ /**
1117
+ * Whether this group serves a `@Workflow` body or a `@Step`/handler — route-by-handler gives each
1118
+ * its own queue, so a health list mixes both. Classified by the CONTROL PLANE from its authoritative
1119
+ * registry (`workerHealth()`): a group whose base name is a registered workflow is `'workflow'`,
1120
+ * everything else (in-process steps, remote `handle_*`) is `'step'`. `undefined` only when no
1121
+ * control-plane registry was available to classify (e.g. a transport that reports health with no
1122
+ * engine). Lets a dashboard summarise the fleet in domain terms ("N workflows · M steps") instead of
1123
+ * leaking the raw queue count.
1124
+ */
1125
+ kind?: 'workflow' | 'step';
1116
1126
  }
1117
1127
  /**
1118
1128
  * The **control plane** — a broadcast pub/sub across ALL engine instances (every pod), separate
@@ -2722,6 +2732,14 @@ declare class RemoteWorkflowExecutor implements WorkflowExecutor {
2722
2732
  dispatch(run: WorkflowRun, history: HistoryEvent[], taskId: string, pendingSignals?: WorkflowTask['pendingSignals']): Promise<void>;
2723
2733
  }
2724
2734
 
2735
+ /** Which durable topology a gateway speaks for — surfaced in the dashboard so an operator can tell a
2736
+ * control plane from a tenant at a glance (the store-backed gateway is the operator; the proxy is a
2737
+ * tenant). Cheap, synchronous, local knowledge — no round-trip. */
2738
+ interface DurableTopology {
2739
+ role: 'control-plane' | 'tenant';
2740
+ /** The tenant's isolation partition name; set only when `role` is 'tenant'. */
2741
+ tenant?: string;
2742
+ }
2725
2743
  /** A run + its timeline + child ids — the detail view. Mirrors the dashboard's `RunDetail`. */
2726
2744
  interface RunDetail {
2727
2745
  run: WorkflowRun;
@@ -2738,6 +2756,8 @@ interface RunDetail {
2738
2756
  * operator answers it scoped to the requester's own groups, so a tenant's Workers panel works too.
2739
2757
  */
2740
2758
  interface RunGateway {
2759
+ /** This deployment's durable role (control plane vs tenant) — synchronous local metadata. */
2760
+ topology(): DurableTopology;
2741
2761
  getRunDetail(runId: string): Promise<RunDetail | null>;
2742
2762
  listRuns(query: RunQuery): Promise<WorkflowRun[]>;
2743
2763
  /** Per-group worker health (queue backlog + live worker heartbeats). On the control plane this is
@@ -3132,4 +3152,4 @@ declare class InMemoryTransport implements Transport, ControlPlane {
3132
3152
  onControl(handler: (msg: ControlMessage) => void): void;
3133
3153
  }
3134
3154
 
3135
- export { type AccumulatorHost, type Admission, type AdmissionBackend, type AdmissionItem, type AttributeFilter, type AttributeOp, type BackoffStrategy, type ChildCallOptions, CodecStateStore, ContinueAsNew, type ControlMessage, type ControlPlane, DURABLE_OPTIONS, DURABLE_OPTIONS_CANONICAL, DURABLE_STEP_CONFIG, DURABLE_STEP_NAME, type DurableWebhook, DurableWorkflow, type EngineEvent, type EngineEventType, type EngineListener, Entities, type EntityConfig, type EntityHandler, type EntityHost, EventAccumulators, type EventBatchConfig, FatalError, GatherError, type GroupHealth, type Heartbeat, type HistoryEvent, InMemoryAdmissionBackend, InMemoryStateStore, InMemoryTransport, type MetricsCollector, type MetricsSnapshot, type NamedTransport, NonDeterminismError, type PayloadCodec, type QueueConfig, QueueController, RemoteStepError, RemoteStepTimeout, type RemoteTask, RemoteWorkflowExecutor, RemoteWorkflowTimeout, type RetentionPolicy, type RunAttributeRow, type RunDetail, type RunDispatcher, type RunGateway, type RunQuery, type RunReply, type RunReplyResult, type RunRequest, type RunRequestKind, type RunResult, type RunSchedulesOptions, type RunStatus, STATE_STORE, STATE_STORE_CANONICAL, type ScheduledWorkflow, type SearchAttributes, SignalTimeoutError, type SignalWaiter, type SingletonConfig, SingletonQueueFullError, type StartOptions, type StartRunMessage, type StateStore, type StepCheckpoint, type StepConfig, type StepDef, type StepDispatchOpts, type StepError, type StepEvent, type StepHandler, type StepInterceptor, type StepInvocation, type StepKind, type StepLogger, type StepOptions, type StepRef, type StepResult, type StepUndo, type StoreTransaction, type SubProcessHandle, TERMINAL_RUN_STATUSES, TRANSPORT, TRANSPORT_CANONICAL, type TenantEvent, type Transport, type UndoOf, type UpdateResult, type UpdateValidator, WORKFLOW_NAME_KEY, type WorkerAdjust, type WorkerConcurrencyStatus, type WorkerHeartbeat, type WorkerStatus, type WorkflowClass, type WorkflowCommand, type WorkflowCtx, type WorkflowDecision, WorkflowEngine, type WorkflowEngineDeps, type WorkflowExecutor, type WorkflowInputOf, type WorkflowOutputOf, type WorkflowRef, type WorkflowRun, type WorkflowStartClient, type WorkflowStepEvent, WorkflowSuspended, type WorkflowTask, applyAttributeQuery, attributeColumnFor, attributeOperand, bindWorkflowClass, breakpointToken, collectMetrics, createStepLogger, currentWorkflowCtx, eventMatchOf, eventMatches, eventPrefix, eventToken, matchesAttributes, normalizeAttributeRows, parseDuration, prevCronFireMs, runInWorkflowCtx, runSchedules, runStepHandler, sanitizeQueueToken, scheduledRunId, sqlComparator, stepConfigOf, stepId, stepNameOf, tenantGroup, workflowName };
3155
+ export { type AccumulatorHost, type Admission, type AdmissionBackend, type AdmissionItem, type AttributeFilter, type AttributeOp, type BackoffStrategy, type ChildCallOptions, CodecStateStore, ContinueAsNew, type ControlMessage, type ControlPlane, DURABLE_OPTIONS, DURABLE_OPTIONS_CANONICAL, DURABLE_STEP_CONFIG, DURABLE_STEP_NAME, type DurableTopology, type DurableWebhook, DurableWorkflow, type EngineEvent, type EngineEventType, type EngineListener, Entities, type EntityConfig, type EntityHandler, type EntityHost, EventAccumulators, type EventBatchConfig, FatalError, GatherError, type GroupHealth, type Heartbeat, type HistoryEvent, InMemoryAdmissionBackend, InMemoryStateStore, InMemoryTransport, type MetricsCollector, type MetricsSnapshot, type NamedTransport, NonDeterminismError, type PayloadCodec, type QueueConfig, QueueController, RemoteStepError, RemoteStepTimeout, type RemoteTask, RemoteWorkflowExecutor, RemoteWorkflowTimeout, type RetentionPolicy, type RunAttributeRow, type RunDetail, type RunDispatcher, type RunGateway, type RunQuery, type RunReply, type RunReplyResult, type RunRequest, type RunRequestKind, type RunResult, type RunSchedulesOptions, type RunStatus, STATE_STORE, STATE_STORE_CANONICAL, type ScheduledWorkflow, type SearchAttributes, SignalTimeoutError, type SignalWaiter, type SingletonConfig, SingletonQueueFullError, type StartOptions, type StartRunMessage, type StateStore, type StepCheckpoint, type StepConfig, type StepDef, type StepDispatchOpts, type StepError, type StepEvent, type StepHandler, type StepInterceptor, type StepInvocation, type StepKind, type StepLogger, type StepOptions, type StepRef, type StepResult, type StepUndo, type StoreTransaction, type SubProcessHandle, TERMINAL_RUN_STATUSES, TRANSPORT, TRANSPORT_CANONICAL, type TenantEvent, type Transport, type UndoOf, type UpdateResult, type UpdateValidator, WORKFLOW_NAME_KEY, type WorkerAdjust, type WorkerConcurrencyStatus, type WorkerHeartbeat, type WorkerStatus, type WorkflowClass, type WorkflowCommand, type WorkflowCtx, type WorkflowDecision, WorkflowEngine, type WorkflowEngineDeps, type WorkflowExecutor, type WorkflowInputOf, type WorkflowOutputOf, type WorkflowRef, type WorkflowRun, type WorkflowStartClient, type WorkflowStepEvent, WorkflowSuspended, type WorkflowTask, applyAttributeQuery, attributeColumnFor, attributeOperand, bindWorkflowClass, breakpointToken, collectMetrics, createStepLogger, currentWorkflowCtx, eventMatchOf, eventMatches, eventPrefix, eventToken, matchesAttributes, normalizeAttributeRows, parseDuration, prevCronFireMs, runInWorkflowCtx, runSchedules, runStepHandler, sanitizeQueueToken, scheduledRunId, sqlComparator, stepConfigOf, stepId, stepNameOf, tenantGroup, workflowName };
package/dist/index.js CHANGED
@@ -2879,10 +2879,21 @@ var WorkflowEngine = class {
2879
2879
  ...this.knownGroups(extra),
2880
2880
  ...await this.pool.listWorkerGroups()
2881
2881
  ]);
2882
+ const workflowTokens = /* @__PURE__ */ new Set();
2883
+ for (const def of this.workflows.values()) {
2884
+ workflowTokens.add(sanitizeQueueToken(def.name));
2885
+ if (def.remote?.group) workflowTokens.add(def.remote.group);
2886
+ }
2882
2887
  const out = [];
2883
2888
  for (const group of groups) {
2884
2889
  const health = await this.pool.groupHealth(group);
2885
- if (health) out.push(health);
2890
+ if (!health) continue;
2891
+ const at = group.lastIndexOf("@");
2892
+ const baseToken = at === -1 ? group : group.slice(0, at);
2893
+ out.push({
2894
+ ...health,
2895
+ kind: workflowTokens.has(baseToken) ? "workflow" : "step"
2896
+ });
2886
2897
  }
2887
2898
  return out;
2888
2899
  }