@dudousxd/nestjs-durable 0.61.0 → 0.63.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, StandardSchemaV1, StepError, OnEventEntry, OnErrorInput, LifecycleEventOf, WorkflowLifecycleEvent, WorkflowRef, SingletonConfig, ConcurrencyConfig, SearchAttributesSchema, EventBatchConfig, TenantVerifier, VerifiedTenant, TenantTokenSource, StateStore, Transport, NamedTransport, ControlPlane, StalledRunInfo, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowInputOf, StartOptions, RunResult, RunGateway, WorkflowEngine, EntityHandler, RunRequest, RunReply, TenantFilter as TenantFilter$1, DurableTopology, RunDetailOptions, RunDetail, FanPageQuery, FanPage, WorkflowRun, RunQuery, RunListItem, RunFacetQuery, RunFacetRow, RunValueAxis, RunValueFacetOptions, RunValueFacetRow, GroupHealth, RunWaiting, RepublishLifecycleTarget, RepublishLifecycleResult, WorkflowLifecycleLinks, EngineEvent, StepInvocation, LifecycleKind, TenantEvent, SignalOptions } from '@dudousxd/nestjs-durable-core';
1
+ import { WorkflowCtx, SearchAttributes, WorkflowClass, StandardSchemaV1, StepError, OnEventEntry, OnErrorInput, LifecycleEventOf, WorkflowLifecycleEvent, WorkflowRef, SingletonConfig, ConcurrencyConfig, SearchAttributesSchema, EventBatchConfig, TenantVerifier, VerifiedTenant, TenantTokenSource, StateStore, Transport, NamedTransport, ControlPlane, StalledRunInfo, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowInputOf, StartOptions, RunResult, WorkflowStartClient, RunGateway, WorkflowEngine, EntityHandler, DurableTopology, RunDetailOptions, RunDetail, FanPageQuery, FanPage, WorkflowRun, RunQuery, RunListItem, RunFacetQuery, RunFacetRow, RunValueAxis, RunValueFacetOptions, RunValueFacetRow, RunWaiting, WorkflowLifecycleLinks, LifecycleKind, GroupHealth, ScheduleListQuery, ScheduleDescription, RepublishLifecycleTarget, RepublishLifecycleResult, ScheduleAction, EngineEvent, RunRequest, RunReply, TenantFilter as TenantFilter$1, StepInvocation, TenantEvent, SignalOptions } from '@dudousxd/nestjs-durable-core';
2
2
  export { AttributeFilter, DuplicateDurableCopyError, DynamicWorkflowCtx, EngineEvent, EventSubscription, InferSearchAttributes, LIFECYCLE_PENDING_TAG, LifecycleEventOf, LifecycleKind, OnErrorInput, OnEventEntry, RunDetail, RunGateway, RunListItem, RunQuery, RunSchedulesOptions, RunStatus, RunWaiting, ScheduledWorkflow, SearchAttributes, SearchAttributesSchema, StepCheckpoint, StepEvent, StepLogger, TenantTokenSource, TenantVerifier, VerifiedTenant, WorkflowCtx, WorkflowEngine, WorkflowHandler, WorkflowLifecycleEvent, WorkflowRun, hmacTenantVerifier, lifecycleRunId, lifecycleSourceOf, prevCronFireMs, readSearchAttributes, runCompletedEvent, runFailedEvent, runSchedules, scheduleRunIdAt, scheduledRunId, signTenantToken, triggeredRunsOf } from '@dudousxd/nestjs-durable-core';
3
3
  import { z } from 'zod';
4
4
  import { ConcurrencyOption, StartRunDeps, RunRedisWorkerOptions, RunningWorker, DurableWorkerRuntime } from '@dudousxd/durable-worker';
@@ -823,7 +823,9 @@ interface DurableModuleSharedOptions {
823
823
  * returns a decision nor sends a run-scoped heartbeat within this window, the engine presumes it dead
824
824
  * and lets recovery re-drive; each heartbeat rearms the window so a slow-but-alive worker is never
825
825
  * re-driven. Pair with a worker SDK that emits run-scoped heartbeats (`@dudousxd/durable-worker` ≥ the
826
- * release that ships them, and the Python `durable-worker`). Omit for the prior unbounded await.
826
+ * release that ships them, and the Python `durable-worker`). Omitted, a turn dispatched over a
827
+ * broker (a tenant's worker, another SDK's) takes {@link reconcileMs} as its window, so a run whose
828
+ * worker died mid-turn is re-driven within it; `reconcileMs: 0` keeps the unbounded wait.
827
829
  * Operator only.
828
830
  */
829
831
  remoteAdvanceSilenceMs?: number;
@@ -850,7 +852,8 @@ interface DurableModuleSharedOptions {
850
852
  /**
851
853
  * Fallback wake-up (ms) for a run suspended on an event (child, signal, `waitForEvent`, remote
852
854
  * result) whose wake-up was lost: the reconcile pass re-drives it after this window, an idempotent
853
- * replay that re-suspends a still-pending wait. Defaults to 300000 (5min); `0` disables it.
855
+ * replay that re-suspends a still-pending wait. Defaults to 300000 (5min); `0` disables it. Also
856
+ * the re-drive window of a dispatched workflow turn when {@link remoteAdvanceSilenceMs} is unset.
854
857
  * See `WorkflowEngineDeps.reconcileMs`. Operator only.
855
858
  */
856
859
  reconcileMs?: number;
@@ -1267,7 +1270,11 @@ declare class ThinWorkflowRegistrar implements OnModuleInit {
1267
1270
  private readonly metadataScanner;
1268
1271
  private readonly runtime;
1269
1272
  private readonly options;
1270
- constructor(discovery: DiscoveryService, metadataScanner: MetadataScanner, runtime: DurableWorkerRuntime | null, options: DurableModuleOptions);
1273
+ /** In this role the store-less `DurableStartClient` facade the module binds under this token. */
1274
+ private readonly starter;
1275
+ constructor(discovery: DiscoveryService, metadataScanner: MetadataScanner, runtime: DurableWorkerRuntime | null, options: DurableModuleOptions,
1276
+ /** In this role the store-less `DurableStartClient` facade the module binds under this token. */
1277
+ starter: WorkflowStartClient);
1271
1278
  onModuleInit(): void;
1272
1279
  }
1273
1280
  /**
@@ -1363,6 +1370,116 @@ declare class EntityService {
1363
1370
  getState<S = unknown>(name: string, key: string): Promise<S | undefined>;
1364
1371
  }
1365
1372
 
1373
+ /** Options for {@link federatedAppGateway}. */
1374
+ interface FederatedAppGatewayOptions {
1375
+ /**
1376
+ * A handle on the app's state store, used for READS only (runs, timelines, facets, schedules).
1377
+ * Typically a store adapter over the app's schema with a database user granted `SELECT` on it.
1378
+ * Nothing on this handle is written: actions go to the app (see {@link transport}).
1379
+ */
1380
+ store: StateStore;
1381
+ /**
1382
+ * A transport on the app's broker and prefix (e.g. `new BullMQTransport({ connection, prefix })`
1383
+ * with the app's own `prefix`), dedicated to this gateway. It carries the actions to the app as run
1384
+ * requests, which the app's own engine answers and executes, plus its live run events and worker
1385
+ * health. The gateway consumes no queue on it: the app's work is never taken by the console.
1386
+ */
1387
+ transport: Transport;
1388
+ /**
1389
+ * The token presented as the requester of each action, for an app whose engine verifies tenants
1390
+ * (`verifyTenant`, e.g. `hmacTenantVerifier(secret)`): `(namespace) => signTenantToken(namespace,
1391
+ * secret)`. Called with the namespace of the run or schedule acted on. Omitted: the namespace
1392
+ * itself is sent, which an app without `verifyTenant` trusts.
1393
+ */
1394
+ tenantToken?: (namespace: string) => string | Promise<string>;
1395
+ /**
1396
+ * Where the app's engines broadcast their lifecycle events (its `controlPlane`): what the console's
1397
+ * live tail of an app run listens on. Default: {@link transport} when it can broadcast (BullMQ
1398
+ * can), which is also the app's default. Only listened to, never published on.
1399
+ */
1400
+ controlPlane?: ControlPlane;
1401
+ /** How long an action waits for the app to answer. Default 10000 ms. */
1402
+ timeoutMs?: number;
1403
+ }
1404
+ /**
1405
+ * A `RunGateway` for ANOTHER app, for a federated console (the dashboard's `federation` option).
1406
+ * Reads come from the app's store; every action (cancel, retry, continue, signal, schedule
1407
+ * pause/resume/trigger, …) is published to the app over its broker as a run request, and the app's
1408
+ * own engine executes it, through the run-request responder every operator with a broker transport
1409
+ * already runs. The console process never drives, recovers or executes the app's runs.
1410
+ *
1411
+ * Each action names the namespace of the run (or schedule) it acts on as the requester, which the
1412
+ * app's responder checks the run against, exactly as it checks a tenant's request.
1413
+ */
1414
+ declare class FederatedAppGateway implements RunGateway {
1415
+ private readonly options;
1416
+ private readonly reads;
1417
+ private readonly pending;
1418
+ private listening;
1419
+ private readonly timeoutMs;
1420
+ /** Live-tail listeners by run id, fed by ONE subscription to the app's control channel. */
1421
+ private readonly tails;
1422
+ private tailing;
1423
+ constructor(options: FederatedAppGatewayOptions);
1424
+ topology(): DurableTopology;
1425
+ getRunDetail(runId: string, options?: RunDetailOptions): Promise<RunDetail | null>;
1426
+ getFanMembers(runId: string, group: string, query: FanPageQuery): Promise<FanPage | null>;
1427
+ getRun(runId: string): Promise<WorkflowRun | null>;
1428
+ listRuns(query: RunQuery): Promise<RunListItem[]>;
1429
+ runFacets(query: RunFacetQuery): Promise<RunFacetRow[]>;
1430
+ runValueFacets(axis: RunValueAxis, query: RunFacetQuery, opts?: RunValueFacetOptions): Promise<RunValueFacetRow[]>;
1431
+ waitingFor(runIds: string[]): Promise<Record<string, RunWaiting>>;
1432
+ workflowLifecycle(workflow: string, opts?: {
1433
+ namespace?: string | undefined;
1434
+ }): Promise<WorkflowLifecycleLinks>;
1435
+ lifecycleSubscribers(workflow: string, kind: LifecycleKind, namespace: string): Promise<string[]>;
1436
+ /** The app's worker groups, read from its broker (read-only). `[]` when the transport can't. */
1437
+ workerHealth(): Promise<GroupHealth[]>;
1438
+ listSchedules(query: ScheduleListQuery): Promise<ScheduleDescription[]>;
1439
+ getSchedule(id: string): Promise<ScheduleDescription | null>;
1440
+ signalWaiter(token: string): Promise<string | null>;
1441
+ cancel(runId: string, opts?: {
1442
+ compensate?: boolean;
1443
+ }): Promise<RunResult | null>;
1444
+ retry(runId: string): Promise<RunResult | null>;
1445
+ continue(runId: string): Promise<RunResult | null>;
1446
+ retryWithInput(runId: string, input: unknown): Promise<{
1447
+ runId: string;
1448
+ } | null>;
1449
+ redispatchPending(runId: string): Promise<(RunResult & {
1450
+ redispatched: number;
1451
+ }) | null>;
1452
+ republishLifecycle(target: RepublishLifecycleTarget): Promise<RepublishLifecycleResult>;
1453
+ /**
1454
+ * Pause, resume or trigger one of the app's persisted schedules, executed by the app. A schedule
1455
+ * that does not exist rejects with a `ScheduleNotFoundError`, as the engine's own client does.
1456
+ */
1457
+ scheduleAction(id: string, action: ScheduleAction): Promise<ScheduleDescription | RunResult>;
1458
+ /**
1459
+ * Deliver `payload` to the app's run waiting on `token`, by the app. Null when no run of the app
1460
+ * waits on it yet: unlike the engine's own `signal`, nothing is buffered for a later wait.
1461
+ */
1462
+ signal(token: string, payload: unknown): Promise<RunResult | null>;
1463
+ /**
1464
+ * The app's live events for `runId`, from the control channel its engines broadcast every event on
1465
+ * (see {@link FederatedAppGatewayOptions.controlPlane}). Nothing when there is none.
1466
+ */
1467
+ subscribe(runId: string, onEvent: (event: EngineEvent) => void): () => void;
1468
+ private controlPlane;
1469
+ private deliver;
1470
+ /** `act` with the namespace of `runId`, or null when the app has no such run. */
1471
+ private onRun;
1472
+ /** Send `body` to the app as a run request from `namespace`, and wait for its reply. */
1473
+ private request;
1474
+ private listen;
1475
+ private handleReply;
1476
+ }
1477
+ /**
1478
+ * A `RunGateway` over another app's store (reads) and broker (actions, executed by that app), for
1479
+ * the dashboard's `federation.apps`. See {@link FederatedAppGateway}.
1480
+ */
1481
+ declare function federatedAppGateway(options: FederatedAppGatewayOptions): FederatedAppGateway;
1482
+
1366
1483
  /**
1367
1484
  * The **co-located in-app worker** (uniform dispatch): active whenever an app supplies BOTH `store`
1368
1485
  * AND `connection` (`DurableModule.forRoot({ store, transport, connection, partition? })`) — the same
@@ -1463,6 +1580,10 @@ declare class RunRequestResponder {
1463
1580
  * failure never throws back into the transport (errors are captured into an error reply). */
1464
1581
  start(): void;
1465
1582
  private handle;
1583
+ /** The run alone (`getRun`, else from its detail), or null when it does not exist. */
1584
+ private runOf;
1585
+ /** `call`'s result as an `ok` reply, or its rejection as an error reply. */
1586
+ private answer;
1466
1587
  /**
1467
1588
  * `detail` scoped to `tenant` (see {@link scopeRunLinks}), with its lifecycle links
1468
1589
  * (`workflowLifecycle`, `lifecycleSubscribers`) narrowed to the subscriptions of `tenant`'s
@@ -1727,6 +1848,12 @@ declare class StoreRunGateway implements RunGateway {
1727
1848
  redispatched: number;
1728
1849
  }) | null>;
1729
1850
  republishLifecycle(target: RepublishLifecycleTarget): Promise<RepublishLifecycleResult>;
1851
+ /** The persisted schedules (`[]` when the store does not persist them). */
1852
+ listSchedules(query: ScheduleListQuery): Promise<ScheduleDescription[]>;
1853
+ getSchedule(id: string): Promise<ScheduleDescription | null>;
1854
+ scheduleAction(id: string, action: ScheduleAction): Promise<ScheduleDescription | RunResult>;
1855
+ signal(token: string, payload: unknown): Promise<RunResult | null>;
1856
+ signalWaiter(token: string): Promise<string | null>;
1730
1857
  /**
1731
1858
  * Stream `runId`'s events. With tenancy, a run the caller may not see streams nothing; events of a
1732
1859
  * run that does not exist yet are held until its row shows whose it is.
@@ -1859,4 +1986,4 @@ declare class WorkflowService {
1859
1986
  republishLifecycle(target: RepublishLifecycleTarget): Promise<RepublishLifecycleResult>;
1860
1987
  }
1861
1988
 
1862
- export { BAD_RUN_REQUEST, CONTEXT_ACCESSOR, type ContextAccessor, type ContextStore, type ContractClass, type ControlPlaneDurableOptions, DEAD_LETTER_METADATA, DURABLE_STEP_METADATA, DURABLE_WORKER_RUNNERS, DURABLE_WORKER_RUNTIME, DeadLetter, type DtoClass, DurableModule, type DurableModuleAsyncOptions, type DurableModuleOptions, type DurableModuleSharedOptions, type DurableRetentionOptions, DurableStartClient, type DurableStepInterceptor, type DurableStepMeta, type DurableTopologyName, ENTITY_METADATA, ENTITY_ON_METADATA, Entity, EntityService, type ErrorClassWithCode, IN_APP_RUN_REDIS_WORKER, IN_APP_WORKER_BINDING, IN_APP_WORKER_RUNNERS, IN_APP_WORKER_RUNTIME, type InAppWorkerBinding, InAppWorkerBootstrap, type IoSchema, type LazyContract, ON_ERROR_METADATA, ON_EVENT_BATCH_METADATA, ON_EVENT_METADATA, On, OnDurableEvent, OnError, type OnErrorMethod, OnWorkflowCompleted, OnWorkflowFailed, type OnWorkflowFailedOptions, type OnWorkflowSettledOptions, ProxyRunGateway, RUN_GATEWAY, RUN_REDIS_WORKER, RunGatewayError, type RunGatewayErrorCode, type RunLookupStore, type RunRedisWorkerFn, RunRequestResponder, type RunRequestResponderOptions, type RunRequestTransport, STEP_INTERCEPTOR_METADATA, type StandaloneDurableOptions, Step, StepInterceptor, type StepOptions, StoreRunGateway, type SubscriberBatch, type SubscriberDebounce, type SubscriberDecorator, TENANT_REPUBLISH_MAX_LIMIT, type TenantCredentialsContract, type TenantDurableOptions, TenantEventRepublisher, type TenantFilter, type TenantLevel, type TenantRef, type TenantTokenOption, type TenantVerifierContract, type TenantVerifierInput, type TenantVerifierOption, ThinStepRegistrar, ThinWorkerBootstrap, ThinWorkflowRegistrar, UNSUPPORTED_RUN_REQUEST, type UserRef, WORKFLOW_METADATA, Workflow, type WorkflowAttributesOf, type WorkflowMeta, type WorkflowOptions, WorkflowService, attributesOf, entityConfigFor, eventBatchOf, getDurableStepMeta, getEntityMeta, getOnEvents, getWorkflowMeta, inAppWorkerProviders, isDeadLetterHandler, isDrivingOperator, isOperatorRole, isStepInterceptor, onErrorCodesOf, thinWorkerProviders, unavailableRunGateway };
1989
+ export { BAD_RUN_REQUEST, CONTEXT_ACCESSOR, type ContextAccessor, type ContextStore, type ContractClass, type ControlPlaneDurableOptions, DEAD_LETTER_METADATA, DURABLE_STEP_METADATA, DURABLE_WORKER_RUNNERS, DURABLE_WORKER_RUNTIME, DeadLetter, type DtoClass, DurableModule, type DurableModuleAsyncOptions, type DurableModuleOptions, type DurableModuleSharedOptions, type DurableRetentionOptions, DurableStartClient, type DurableStepInterceptor, type DurableStepMeta, type DurableTopologyName, ENTITY_METADATA, ENTITY_ON_METADATA, Entity, EntityService, type ErrorClassWithCode, FederatedAppGateway, type FederatedAppGatewayOptions, IN_APP_RUN_REDIS_WORKER, IN_APP_WORKER_BINDING, IN_APP_WORKER_RUNNERS, IN_APP_WORKER_RUNTIME, type InAppWorkerBinding, InAppWorkerBootstrap, type IoSchema, type LazyContract, ON_ERROR_METADATA, ON_EVENT_BATCH_METADATA, ON_EVENT_METADATA, On, OnDurableEvent, OnError, type OnErrorMethod, OnWorkflowCompleted, OnWorkflowFailed, type OnWorkflowFailedOptions, type OnWorkflowSettledOptions, ProxyRunGateway, RUN_GATEWAY, RUN_REDIS_WORKER, RunGatewayError, type RunGatewayErrorCode, type RunLookupStore, type RunRedisWorkerFn, RunRequestResponder, type RunRequestResponderOptions, type RunRequestTransport, STEP_INTERCEPTOR_METADATA, type StandaloneDurableOptions, Step, StepInterceptor, type StepOptions, StoreRunGateway, type SubscriberBatch, type SubscriberDebounce, type SubscriberDecorator, TENANT_REPUBLISH_MAX_LIMIT, type TenantCredentialsContract, type TenantDurableOptions, TenantEventRepublisher, type TenantFilter, type TenantLevel, type TenantRef, type TenantTokenOption, type TenantVerifierContract, type TenantVerifierInput, type TenantVerifierOption, ThinStepRegistrar, ThinWorkerBootstrap, ThinWorkflowRegistrar, UNSUPPORTED_RUN_REQUEST, type UserRef, WORKFLOW_METADATA, Workflow, type WorkflowAttributesOf, type WorkflowMeta, type WorkflowOptions, WorkflowService, attributesOf, entityConfigFor, eventBatchOf, federatedAppGateway, getDurableStepMeta, getEntityMeta, getOnEvents, getWorkflowMeta, inAppWorkerProviders, isDeadLetterHandler, isDrivingOperator, isOperatorRole, isStepInterceptor, onErrorCodesOf, thinWorkerProviders, unavailableRunGateway };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { WorkflowCtx, SearchAttributes, WorkflowClass, StandardSchemaV1, StepError, OnEventEntry, OnErrorInput, LifecycleEventOf, WorkflowLifecycleEvent, WorkflowRef, SingletonConfig, ConcurrencyConfig, SearchAttributesSchema, EventBatchConfig, TenantVerifier, VerifiedTenant, TenantTokenSource, StateStore, Transport, NamedTransport, ControlPlane, StalledRunInfo, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowInputOf, StartOptions, RunResult, RunGateway, WorkflowEngine, EntityHandler, RunRequest, RunReply, TenantFilter as TenantFilter$1, DurableTopology, RunDetailOptions, RunDetail, FanPageQuery, FanPage, WorkflowRun, RunQuery, RunListItem, RunFacetQuery, RunFacetRow, RunValueAxis, RunValueFacetOptions, RunValueFacetRow, GroupHealth, RunWaiting, RepublishLifecycleTarget, RepublishLifecycleResult, WorkflowLifecycleLinks, EngineEvent, StepInvocation, LifecycleKind, TenantEvent, SignalOptions } from '@dudousxd/nestjs-durable-core';
1
+ import { WorkflowCtx, SearchAttributes, WorkflowClass, StandardSchemaV1, StepError, OnEventEntry, OnErrorInput, LifecycleEventOf, WorkflowLifecycleEvent, WorkflowRef, SingletonConfig, ConcurrencyConfig, SearchAttributesSchema, EventBatchConfig, TenantVerifier, VerifiedTenant, TenantTokenSource, StateStore, Transport, NamedTransport, ControlPlane, StalledRunInfo, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowInputOf, StartOptions, RunResult, WorkflowStartClient, RunGateway, WorkflowEngine, EntityHandler, DurableTopology, RunDetailOptions, RunDetail, FanPageQuery, FanPage, WorkflowRun, RunQuery, RunListItem, RunFacetQuery, RunFacetRow, RunValueAxis, RunValueFacetOptions, RunValueFacetRow, RunWaiting, WorkflowLifecycleLinks, LifecycleKind, GroupHealth, ScheduleListQuery, ScheduleDescription, RepublishLifecycleTarget, RepublishLifecycleResult, ScheduleAction, EngineEvent, RunRequest, RunReply, TenantFilter as TenantFilter$1, StepInvocation, TenantEvent, SignalOptions } from '@dudousxd/nestjs-durable-core';
2
2
  export { AttributeFilter, DuplicateDurableCopyError, DynamicWorkflowCtx, EngineEvent, EventSubscription, InferSearchAttributes, LIFECYCLE_PENDING_TAG, LifecycleEventOf, LifecycleKind, OnErrorInput, OnEventEntry, RunDetail, RunGateway, RunListItem, RunQuery, RunSchedulesOptions, RunStatus, RunWaiting, ScheduledWorkflow, SearchAttributes, SearchAttributesSchema, StepCheckpoint, StepEvent, StepLogger, TenantTokenSource, TenantVerifier, VerifiedTenant, WorkflowCtx, WorkflowEngine, WorkflowHandler, WorkflowLifecycleEvent, WorkflowRun, hmacTenantVerifier, lifecycleRunId, lifecycleSourceOf, prevCronFireMs, readSearchAttributes, runCompletedEvent, runFailedEvent, runSchedules, scheduleRunIdAt, scheduledRunId, signTenantToken, triggeredRunsOf } from '@dudousxd/nestjs-durable-core';
3
3
  import { z } from 'zod';
4
4
  import { ConcurrencyOption, StartRunDeps, RunRedisWorkerOptions, RunningWorker, DurableWorkerRuntime } from '@dudousxd/durable-worker';
@@ -823,7 +823,9 @@ interface DurableModuleSharedOptions {
823
823
  * returns a decision nor sends a run-scoped heartbeat within this window, the engine presumes it dead
824
824
  * and lets recovery re-drive; each heartbeat rearms the window so a slow-but-alive worker is never
825
825
  * re-driven. Pair with a worker SDK that emits run-scoped heartbeats (`@dudousxd/durable-worker` ≥ the
826
- * release that ships them, and the Python `durable-worker`). Omit for the prior unbounded await.
826
+ * release that ships them, and the Python `durable-worker`). Omitted, a turn dispatched over a
827
+ * broker (a tenant's worker, another SDK's) takes {@link reconcileMs} as its window, so a run whose
828
+ * worker died mid-turn is re-driven within it; `reconcileMs: 0` keeps the unbounded wait.
827
829
  * Operator only.
828
830
  */
829
831
  remoteAdvanceSilenceMs?: number;
@@ -850,7 +852,8 @@ interface DurableModuleSharedOptions {
850
852
  /**
851
853
  * Fallback wake-up (ms) for a run suspended on an event (child, signal, `waitForEvent`, remote
852
854
  * result) whose wake-up was lost: the reconcile pass re-drives it after this window, an idempotent
853
- * replay that re-suspends a still-pending wait. Defaults to 300000 (5min); `0` disables it.
855
+ * replay that re-suspends a still-pending wait. Defaults to 300000 (5min); `0` disables it. Also
856
+ * the re-drive window of a dispatched workflow turn when {@link remoteAdvanceSilenceMs} is unset.
854
857
  * See `WorkflowEngineDeps.reconcileMs`. Operator only.
855
858
  */
856
859
  reconcileMs?: number;
@@ -1267,7 +1270,11 @@ declare class ThinWorkflowRegistrar implements OnModuleInit {
1267
1270
  private readonly metadataScanner;
1268
1271
  private readonly runtime;
1269
1272
  private readonly options;
1270
- constructor(discovery: DiscoveryService, metadataScanner: MetadataScanner, runtime: DurableWorkerRuntime | null, options: DurableModuleOptions);
1273
+ /** In this role the store-less `DurableStartClient` facade the module binds under this token. */
1274
+ private readonly starter;
1275
+ constructor(discovery: DiscoveryService, metadataScanner: MetadataScanner, runtime: DurableWorkerRuntime | null, options: DurableModuleOptions,
1276
+ /** In this role the store-less `DurableStartClient` facade the module binds under this token. */
1277
+ starter: WorkflowStartClient);
1271
1278
  onModuleInit(): void;
1272
1279
  }
1273
1280
  /**
@@ -1363,6 +1370,116 @@ declare class EntityService {
1363
1370
  getState<S = unknown>(name: string, key: string): Promise<S | undefined>;
1364
1371
  }
1365
1372
 
1373
+ /** Options for {@link federatedAppGateway}. */
1374
+ interface FederatedAppGatewayOptions {
1375
+ /**
1376
+ * A handle on the app's state store, used for READS only (runs, timelines, facets, schedules).
1377
+ * Typically a store adapter over the app's schema with a database user granted `SELECT` on it.
1378
+ * Nothing on this handle is written: actions go to the app (see {@link transport}).
1379
+ */
1380
+ store: StateStore;
1381
+ /**
1382
+ * A transport on the app's broker and prefix (e.g. `new BullMQTransport({ connection, prefix })`
1383
+ * with the app's own `prefix`), dedicated to this gateway. It carries the actions to the app as run
1384
+ * requests, which the app's own engine answers and executes, plus its live run events and worker
1385
+ * health. The gateway consumes no queue on it: the app's work is never taken by the console.
1386
+ */
1387
+ transport: Transport;
1388
+ /**
1389
+ * The token presented as the requester of each action, for an app whose engine verifies tenants
1390
+ * (`verifyTenant`, e.g. `hmacTenantVerifier(secret)`): `(namespace) => signTenantToken(namespace,
1391
+ * secret)`. Called with the namespace of the run or schedule acted on. Omitted: the namespace
1392
+ * itself is sent, which an app without `verifyTenant` trusts.
1393
+ */
1394
+ tenantToken?: (namespace: string) => string | Promise<string>;
1395
+ /**
1396
+ * Where the app's engines broadcast their lifecycle events (its `controlPlane`): what the console's
1397
+ * live tail of an app run listens on. Default: {@link transport} when it can broadcast (BullMQ
1398
+ * can), which is also the app's default. Only listened to, never published on.
1399
+ */
1400
+ controlPlane?: ControlPlane;
1401
+ /** How long an action waits for the app to answer. Default 10000 ms. */
1402
+ timeoutMs?: number;
1403
+ }
1404
+ /**
1405
+ * A `RunGateway` for ANOTHER app, for a federated console (the dashboard's `federation` option).
1406
+ * Reads come from the app's store; every action (cancel, retry, continue, signal, schedule
1407
+ * pause/resume/trigger, …) is published to the app over its broker as a run request, and the app's
1408
+ * own engine executes it, through the run-request responder every operator with a broker transport
1409
+ * already runs. The console process never drives, recovers or executes the app's runs.
1410
+ *
1411
+ * Each action names the namespace of the run (or schedule) it acts on as the requester, which the
1412
+ * app's responder checks the run against, exactly as it checks a tenant's request.
1413
+ */
1414
+ declare class FederatedAppGateway implements RunGateway {
1415
+ private readonly options;
1416
+ private readonly reads;
1417
+ private readonly pending;
1418
+ private listening;
1419
+ private readonly timeoutMs;
1420
+ /** Live-tail listeners by run id, fed by ONE subscription to the app's control channel. */
1421
+ private readonly tails;
1422
+ private tailing;
1423
+ constructor(options: FederatedAppGatewayOptions);
1424
+ topology(): DurableTopology;
1425
+ getRunDetail(runId: string, options?: RunDetailOptions): Promise<RunDetail | null>;
1426
+ getFanMembers(runId: string, group: string, query: FanPageQuery): Promise<FanPage | null>;
1427
+ getRun(runId: string): Promise<WorkflowRun | null>;
1428
+ listRuns(query: RunQuery): Promise<RunListItem[]>;
1429
+ runFacets(query: RunFacetQuery): Promise<RunFacetRow[]>;
1430
+ runValueFacets(axis: RunValueAxis, query: RunFacetQuery, opts?: RunValueFacetOptions): Promise<RunValueFacetRow[]>;
1431
+ waitingFor(runIds: string[]): Promise<Record<string, RunWaiting>>;
1432
+ workflowLifecycle(workflow: string, opts?: {
1433
+ namespace?: string | undefined;
1434
+ }): Promise<WorkflowLifecycleLinks>;
1435
+ lifecycleSubscribers(workflow: string, kind: LifecycleKind, namespace: string): Promise<string[]>;
1436
+ /** The app's worker groups, read from its broker (read-only). `[]` when the transport can't. */
1437
+ workerHealth(): Promise<GroupHealth[]>;
1438
+ listSchedules(query: ScheduleListQuery): Promise<ScheduleDescription[]>;
1439
+ getSchedule(id: string): Promise<ScheduleDescription | null>;
1440
+ signalWaiter(token: string): Promise<string | null>;
1441
+ cancel(runId: string, opts?: {
1442
+ compensate?: boolean;
1443
+ }): Promise<RunResult | null>;
1444
+ retry(runId: string): Promise<RunResult | null>;
1445
+ continue(runId: string): Promise<RunResult | null>;
1446
+ retryWithInput(runId: string, input: unknown): Promise<{
1447
+ runId: string;
1448
+ } | null>;
1449
+ redispatchPending(runId: string): Promise<(RunResult & {
1450
+ redispatched: number;
1451
+ }) | null>;
1452
+ republishLifecycle(target: RepublishLifecycleTarget): Promise<RepublishLifecycleResult>;
1453
+ /**
1454
+ * Pause, resume or trigger one of the app's persisted schedules, executed by the app. A schedule
1455
+ * that does not exist rejects with a `ScheduleNotFoundError`, as the engine's own client does.
1456
+ */
1457
+ scheduleAction(id: string, action: ScheduleAction): Promise<ScheduleDescription | RunResult>;
1458
+ /**
1459
+ * Deliver `payload` to the app's run waiting on `token`, by the app. Null when no run of the app
1460
+ * waits on it yet: unlike the engine's own `signal`, nothing is buffered for a later wait.
1461
+ */
1462
+ signal(token: string, payload: unknown): Promise<RunResult | null>;
1463
+ /**
1464
+ * The app's live events for `runId`, from the control channel its engines broadcast every event on
1465
+ * (see {@link FederatedAppGatewayOptions.controlPlane}). Nothing when there is none.
1466
+ */
1467
+ subscribe(runId: string, onEvent: (event: EngineEvent) => void): () => void;
1468
+ private controlPlane;
1469
+ private deliver;
1470
+ /** `act` with the namespace of `runId`, or null when the app has no such run. */
1471
+ private onRun;
1472
+ /** Send `body` to the app as a run request from `namespace`, and wait for its reply. */
1473
+ private request;
1474
+ private listen;
1475
+ private handleReply;
1476
+ }
1477
+ /**
1478
+ * A `RunGateway` over another app's store (reads) and broker (actions, executed by that app), for
1479
+ * the dashboard's `federation.apps`. See {@link FederatedAppGateway}.
1480
+ */
1481
+ declare function federatedAppGateway(options: FederatedAppGatewayOptions): FederatedAppGateway;
1482
+
1366
1483
  /**
1367
1484
  * The **co-located in-app worker** (uniform dispatch): active whenever an app supplies BOTH `store`
1368
1485
  * AND `connection` (`DurableModule.forRoot({ store, transport, connection, partition? })`) — the same
@@ -1463,6 +1580,10 @@ declare class RunRequestResponder {
1463
1580
  * failure never throws back into the transport (errors are captured into an error reply). */
1464
1581
  start(): void;
1465
1582
  private handle;
1583
+ /** The run alone (`getRun`, else from its detail), or null when it does not exist. */
1584
+ private runOf;
1585
+ /** `call`'s result as an `ok` reply, or its rejection as an error reply. */
1586
+ private answer;
1466
1587
  /**
1467
1588
  * `detail` scoped to `tenant` (see {@link scopeRunLinks}), with its lifecycle links
1468
1589
  * (`workflowLifecycle`, `lifecycleSubscribers`) narrowed to the subscriptions of `tenant`'s
@@ -1727,6 +1848,12 @@ declare class StoreRunGateway implements RunGateway {
1727
1848
  redispatched: number;
1728
1849
  }) | null>;
1729
1850
  republishLifecycle(target: RepublishLifecycleTarget): Promise<RepublishLifecycleResult>;
1851
+ /** The persisted schedules (`[]` when the store does not persist them). */
1852
+ listSchedules(query: ScheduleListQuery): Promise<ScheduleDescription[]>;
1853
+ getSchedule(id: string): Promise<ScheduleDescription | null>;
1854
+ scheduleAction(id: string, action: ScheduleAction): Promise<ScheduleDescription | RunResult>;
1855
+ signal(token: string, payload: unknown): Promise<RunResult | null>;
1856
+ signalWaiter(token: string): Promise<string | null>;
1730
1857
  /**
1731
1858
  * Stream `runId`'s events. With tenancy, a run the caller may not see streams nothing; events of a
1732
1859
  * run that does not exist yet are held until its row shows whose it is.
@@ -1859,4 +1986,4 @@ declare class WorkflowService {
1859
1986
  republishLifecycle(target: RepublishLifecycleTarget): Promise<RepublishLifecycleResult>;
1860
1987
  }
1861
1988
 
1862
- export { BAD_RUN_REQUEST, CONTEXT_ACCESSOR, type ContextAccessor, type ContextStore, type ContractClass, type ControlPlaneDurableOptions, DEAD_LETTER_METADATA, DURABLE_STEP_METADATA, DURABLE_WORKER_RUNNERS, DURABLE_WORKER_RUNTIME, DeadLetter, type DtoClass, DurableModule, type DurableModuleAsyncOptions, type DurableModuleOptions, type DurableModuleSharedOptions, type DurableRetentionOptions, DurableStartClient, type DurableStepInterceptor, type DurableStepMeta, type DurableTopologyName, ENTITY_METADATA, ENTITY_ON_METADATA, Entity, EntityService, type ErrorClassWithCode, IN_APP_RUN_REDIS_WORKER, IN_APP_WORKER_BINDING, IN_APP_WORKER_RUNNERS, IN_APP_WORKER_RUNTIME, type InAppWorkerBinding, InAppWorkerBootstrap, type IoSchema, type LazyContract, ON_ERROR_METADATA, ON_EVENT_BATCH_METADATA, ON_EVENT_METADATA, On, OnDurableEvent, OnError, type OnErrorMethod, OnWorkflowCompleted, OnWorkflowFailed, type OnWorkflowFailedOptions, type OnWorkflowSettledOptions, ProxyRunGateway, RUN_GATEWAY, RUN_REDIS_WORKER, RunGatewayError, type RunGatewayErrorCode, type RunLookupStore, type RunRedisWorkerFn, RunRequestResponder, type RunRequestResponderOptions, type RunRequestTransport, STEP_INTERCEPTOR_METADATA, type StandaloneDurableOptions, Step, StepInterceptor, type StepOptions, StoreRunGateway, type SubscriberBatch, type SubscriberDebounce, type SubscriberDecorator, TENANT_REPUBLISH_MAX_LIMIT, type TenantCredentialsContract, type TenantDurableOptions, TenantEventRepublisher, type TenantFilter, type TenantLevel, type TenantRef, type TenantTokenOption, type TenantVerifierContract, type TenantVerifierInput, type TenantVerifierOption, ThinStepRegistrar, ThinWorkerBootstrap, ThinWorkflowRegistrar, UNSUPPORTED_RUN_REQUEST, type UserRef, WORKFLOW_METADATA, Workflow, type WorkflowAttributesOf, type WorkflowMeta, type WorkflowOptions, WorkflowService, attributesOf, entityConfigFor, eventBatchOf, getDurableStepMeta, getEntityMeta, getOnEvents, getWorkflowMeta, inAppWorkerProviders, isDeadLetterHandler, isDrivingOperator, isOperatorRole, isStepInterceptor, onErrorCodesOf, thinWorkerProviders, unavailableRunGateway };
1989
+ export { BAD_RUN_REQUEST, CONTEXT_ACCESSOR, type ContextAccessor, type ContextStore, type ContractClass, type ControlPlaneDurableOptions, DEAD_LETTER_METADATA, DURABLE_STEP_METADATA, DURABLE_WORKER_RUNNERS, DURABLE_WORKER_RUNTIME, DeadLetter, type DtoClass, DurableModule, type DurableModuleAsyncOptions, type DurableModuleOptions, type DurableModuleSharedOptions, type DurableRetentionOptions, DurableStartClient, type DurableStepInterceptor, type DurableStepMeta, type DurableTopologyName, ENTITY_METADATA, ENTITY_ON_METADATA, Entity, EntityService, type ErrorClassWithCode, FederatedAppGateway, type FederatedAppGatewayOptions, IN_APP_RUN_REDIS_WORKER, IN_APP_WORKER_BINDING, IN_APP_WORKER_RUNNERS, IN_APP_WORKER_RUNTIME, type InAppWorkerBinding, InAppWorkerBootstrap, type IoSchema, type LazyContract, ON_ERROR_METADATA, ON_EVENT_BATCH_METADATA, ON_EVENT_METADATA, On, OnDurableEvent, OnError, type OnErrorMethod, OnWorkflowCompleted, OnWorkflowFailed, type OnWorkflowFailedOptions, type OnWorkflowSettledOptions, ProxyRunGateway, RUN_GATEWAY, RUN_REDIS_WORKER, RunGatewayError, type RunGatewayErrorCode, type RunLookupStore, type RunRedisWorkerFn, RunRequestResponder, type RunRequestResponderOptions, type RunRequestTransport, STEP_INTERCEPTOR_METADATA, type StandaloneDurableOptions, Step, StepInterceptor, type StepOptions, StoreRunGateway, type SubscriberBatch, type SubscriberDebounce, type SubscriberDecorator, TENANT_REPUBLISH_MAX_LIMIT, type TenantCredentialsContract, type TenantDurableOptions, TenantEventRepublisher, type TenantFilter, type TenantLevel, type TenantRef, type TenantTokenOption, type TenantVerifierContract, type TenantVerifierInput, type TenantVerifierOption, ThinStepRegistrar, ThinWorkerBootstrap, ThinWorkflowRegistrar, UNSUPPORTED_RUN_REQUEST, type UserRef, WORKFLOW_METADATA, Workflow, type WorkflowAttributesOf, type WorkflowMeta, type WorkflowOptions, WorkflowService, attributesOf, entityConfigFor, eventBatchOf, federatedAppGateway, getDurableStepMeta, getEntityMeta, getOnEvents, getWorkflowMeta, inAppWorkerProviders, isDeadLetterHandler, isDrivingOperator, isOperatorRole, isStepInterceptor, onErrorCodesOf, thinWorkerProviders, unavailableRunGateway };