@dudousxd/nestjs-durable 0.63.0 → 0.65.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, 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';
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, SignalOptions, RunResult, StartRunMessage, WorkflowInputOf, StartOptions, WorkflowStartClient, ScheduleAnnouncement, 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 } 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';
@@ -970,6 +970,21 @@ interface DurableModuleSharedOptions {
970
970
  * deterministic and advancing a schedule is a compare-and-set. Operator only.
971
971
  */
972
972
  persistedSchedules?: boolean;
973
+ /**
974
+ * Adopt the `schedules` that TENANT apps declare and fire them here (a tenant has no store to fire
975
+ * them from). Each tenant worker announces its app's schedules on its descriptor; every `syncMs`
976
+ * (default 15 s) a driving instance turns them into persisted schedules (id
977
+ * `app:<partition>:<key>`, tagged `schedule:announced`), applies a changed definition, and pauses
978
+ * one that no live worker of its app has announced for `graceMs` (default 10 minutes). It then
979
+ * fires them on every tick, through the tenant start path: with no live worker of the app, a run
980
+ * waits `blocked` (`no_live_worker`) for one. On by default for a driving instance with a store
981
+ * that persists schedules and a transport that reads worker descriptors (BullMQ); `false` turns it
982
+ * off. Operator only.
983
+ */
984
+ announcedSchedules?: boolean | {
985
+ syncMs?: number;
986
+ graceMs?: number;
987
+ };
973
988
  /**
974
989
  * Hard-prune terminal run history on an interval so `durable_workflow_runs` (and its child tables)
975
990
  * stays bounded — without it, completed/failed/cancelled runs accumulate forever and the timer
@@ -1184,6 +1199,11 @@ interface DurableModuleAsyncOptions {
1184
1199
  useFactory: (...args: never[]) => DurableModuleOptions | Promise<DurableModuleOptions>;
1185
1200
  inject?: InjectionToken[];
1186
1201
  }
1202
+ /** The `verifyTenant` / `tenantToken` options, resolved to the plain functions the wire layer calls. */
1203
+ interface ResolvedTenantAuth {
1204
+ verifyTenant: TenantVerifier | undefined;
1205
+ tenantToken: TenantTokenSource | undefined;
1206
+ }
1187
1207
  /**
1188
1208
  * `forRoot` / `forRootAsync` first refuse to boot when two different installs of
1189
1209
  * `@dudousxd/nestjs-durable-core` are loaded in this process (a pnpm peer-variant split): each copy
@@ -1199,6 +1219,42 @@ declare class DurableModule {
1199
1219
  private static build;
1200
1220
  }
1201
1221
 
1222
+ /**
1223
+ * The `@Workflow` options a tenant's start applies itself, before it publishes the start-run: the
1224
+ * ones that are functions of the input, which the control plane (knowing the workflow by name
1225
+ * alone) cannot evaluate. Declared by `ThinWorkflowRegistrar` for every `@Workflow` it discovers.
1226
+ */
1227
+ interface TenantWorkflowStartPolicy {
1228
+ /** `@Workflow({ input, validateInput })`: rejects the start (throws) before anything is published. */
1229
+ validateInput?: ((input: unknown) => void | Promise<void>) | undefined;
1230
+ /** `@Workflow({ singleton })`: its key is evaluated here and carried on the start-run. */
1231
+ singleton?: SingletonConfig | undefined;
1232
+ /** `@Workflow({ concurrency })`: the default quota, evaluated here unless the start passes one. */
1233
+ concurrency?: ConcurrencyConfig | undefined;
1234
+ /** `@Workflow({ onEvent })` / `@OnDurableEvent`: started by this app's own `publishEvent`. */
1235
+ onEvent?: OnEventEntry[] | undefined;
1236
+ /** The workflow coalesces its event triggers (`debounce`/`batch`), which a tenant cannot apply. */
1237
+ coalesces?: boolean | undefined;
1238
+ }
1239
+ /**
1240
+ * Where a tenant's `signal`/`signalWithStart`/`publishEvent` go: run requests to the control plane
1241
+ * (the module's `ProxyRunGateway` over `transport`).
1242
+ */
1243
+ interface TenantRunRequests {
1244
+ signal(token: string, payload: unknown, opts?: SignalOptions): Promise<RunResult | null>;
1245
+ signalWithStart(start: Omit<StartRunMessage, 'tenant'> & {
1246
+ runId: string;
1247
+ }, signal: {
1248
+ token: string;
1249
+ payload?: unknown;
1250
+ }): Promise<{
1251
+ runId: string;
1252
+ signalled: boolean;
1253
+ }>;
1254
+ publishEvent(name: string, payload: unknown, opts?: {
1255
+ id?: string;
1256
+ }): Promise<number>;
1257
+ }
1202
1258
  /**
1203
1259
  * The **store-less `engine.start` facade** for a tenant worker. Provided under the `WorkflowEngine`
1204
1260
  * DI token by {@link import('./durable.module').DurableModule} (`forRoot({ connection })`, no
@@ -1216,13 +1272,91 @@ declare class DurableStartClient {
1216
1272
  private readonly deps?;
1217
1273
  /** The context accessor, for the customer tenant a start claims (else the global slot). */
1218
1274
  private readonly accessor?;
1275
+ /**
1276
+ * Sends `signal`/`signalWithStart`/`publishEvent` to the control plane as run requests (the
1277
+ * module's `ProxyRunGateway` over `transport`). Absent (no `transport`): they reject, naming it.
1278
+ */
1279
+ private readonly requests?;
1219
1280
  private readonly tenant;
1220
1281
  private readonly tenantToken;
1282
+ private readonly policies;
1283
+ private readonly warnedCoalescing;
1221
1284
  constructor(options: DurableModuleOptions, deps?: StartRunDeps | undefined,
1222
1285
  /** The context accessor, for the customer tenant a start claims (else the global slot). */
1223
- accessor?: ContextAccessor | undefined);
1286
+ accessor?: ContextAccessor | undefined,
1287
+ /**
1288
+ * Sends `signal`/`signalWithStart`/`publishEvent` to the control plane as run requests (the
1289
+ * module's `ProxyRunGateway` over `transport`). Absent (no `transport`): they reject, naming it.
1290
+ */
1291
+ requests?: (() => TenantRunRequests | undefined) | undefined);
1292
+ /**
1293
+ * Apply `policy` to every start of `workflow` from this process (see
1294
+ * {@link TenantWorkflowStartPolicy}). Called by `ThinWorkflowRegistrar` at boot.
1295
+ */
1296
+ declareWorkflow(workflow: string, policy: TenantWorkflowStartPolicy): void;
1297
+ /**
1298
+ * The start-run fields a declared policy adds for `input`: it validates the input (throwing), and
1299
+ * evaluates the singleton key and the default quota. A per-start `concurrency` wins over the
1300
+ * workflow's.
1301
+ */
1302
+ private applyPolicy;
1303
+ /** The wire `tenant`: the signed token when configured, else the partition. */
1304
+ private wireTenant;
1305
+ /**
1306
+ * The customer tenant a start claims: an explicit `tenantId` (`null` = none), else the request's
1307
+ * tenant when tenancy is on.
1308
+ */
1309
+ private claimedTenant;
1224
1310
  start<C extends WorkflowClass>(workflow: C, input: WorkflowInputOf<C>, runId?: string, opts?: StartOptions): Promise<RunResult>;
1225
1311
  start(workflow: string, input: unknown, runId?: string, opts?: StartOptions): Promise<RunResult>;
1312
+ /**
1313
+ * The start-run a start of `name` sends (everything but the wire `tenant`): the start options the
1314
+ * control plane applies (version pin, priority, delayed start, quota), the singleton key and the
1315
+ * customer tenant this run claims. Applies the workflow's declared policy first, so a rejected
1316
+ * input throws before anything is published, as `engine.start` does.
1317
+ */
1318
+ private startMessage;
1319
+ /** The control plane's run requests, or a clear error naming what is missing. */
1320
+ private runRequests;
1321
+ /**
1322
+ * Signal the run of this tenant's partition waiting on `token`, through the control plane.
1323
+ * Resolves the resumed run, or null when no run of this partition waits on it: unlike
1324
+ * `engine.signal` on a control plane, a tenant's signal is NOT buffered for a wait opened later
1325
+ * (another partition's run could open it). Use `signalWithStart` to signal a run that may not wait
1326
+ * yet. `opts.id` deduplicates like `engine.signal`.
1327
+ */
1328
+ signal(token: string, payload: unknown, opts?: SignalOptions): Promise<RunResult | null>;
1329
+ /**
1330
+ * Ensure the run `runId` of `workflow` exists in this tenant's partition (started like
1331
+ * {@link start}, with the same options and policy), then signal it. The control plane buffers the
1332
+ * signal until the run waits on `signal.token` only when the token contains `runId` (a run-scoped
1333
+ * token, the pattern `signalWithStart` is for): a token that does not is delivered only to a run
1334
+ * of this partition already waiting on it, and refused otherwise.
1335
+ */
1336
+ signalWithStart<C extends WorkflowClass>(workflow: C, input: WorkflowInputOf<C>, runId: string, signal: {
1337
+ token: string;
1338
+ payload?: unknown;
1339
+ }, opts?: StartOptions): Promise<{
1340
+ runId: string;
1341
+ }>;
1342
+ signalWithStart(workflow: string, input: unknown, runId: string, signal: {
1343
+ token: string;
1344
+ payload?: unknown;
1345
+ }, opts?: StartOptions): Promise<{
1346
+ runId: string;
1347
+ }>;
1348
+ /**
1349
+ * Publish event `name` from this tenant. Starts this app's own `onEvent` subscribers (each one
1350
+ * whose `where` accepts the payload, with its `input` mapping) as runs of this partition, by the
1351
+ * start path ({@link start}, run id `evt:<id>:<workflow>`), and has the control plane resume the
1352
+ * runs of this partition waiting on it (`ctx.waitForEvent`). Resolves how many runs it started or
1353
+ * resumed; a subscriber that throws is warned about and skipped. Unlike a control plane's
1354
+ * `publishEvent`, an event nobody received is not buffered (there is no `buffer` option), and
1355
+ * a subscriber's `debounce`/`batch` is not applied (it starts once per event, with a warning).
1356
+ */
1357
+ publishEvent(name: string, payload: unknown, opts?: {
1358
+ id?: string;
1359
+ }): Promise<number>;
1226
1360
  cancel(_runId: string): Promise<void>;
1227
1361
  deleteRun(_runId: string): Promise<void>;
1228
1362
  resume(_runId: string): Promise<void>;
@@ -1230,15 +1364,6 @@ declare class DurableStartClient {
1230
1364
  timeoutMs?: number;
1231
1365
  until?: 'settled' | 'terminal';
1232
1366
  }): Promise<void>;
1233
- signal(_token: string, _payload: unknown): Promise<void>;
1234
- signalWithStart(_workflow: string, _input: unknown, _runId: string, _signal: {
1235
- token: string;
1236
- payload?: unknown;
1237
- }, _opts?: StartOptions): Promise<void>;
1238
- publishEvent(_name: string, _payload: unknown, _opts?: {
1239
- id?: string;
1240
- buffer?: boolean;
1241
- }): Promise<void>;
1242
1367
  }
1243
1368
 
1244
1369
  /**
@@ -1276,6 +1401,19 @@ declare class ThinWorkflowRegistrar implements OnModuleInit {
1276
1401
  /** In this role the store-less `DurableStartClient` facade the module binds under this token. */
1277
1402
  starter: WorkflowStartClient);
1278
1403
  onModuleInit(): void;
1404
+ /**
1405
+ * `@Entity` providers are refused on a tenant, at boot: an entity's state is a run on the store
1406
+ * and its `@On` handlers run inside the engine that owns that store (`EntityService` and
1407
+ * `ctx.callEntity`/`signalEntity` read and serialize it there). A tenant has no store and no
1408
+ * engine, so an entity declared here would never run. Declare it on the control plane.
1409
+ */
1410
+ private assertNoEntities;
1411
+ /**
1412
+ * `@StepInterceptor()` providers wrap every step this tenant runs (each `ctx.step` its workers
1413
+ * execute), as `engine.use` does on an engine. A `@durable-worker` too old to take interceptors
1414
+ * says so instead of dropping them silently.
1415
+ */
1416
+ private useInterceptors;
1279
1417
  }
1280
1418
  /**
1281
1419
  * Discovers every `@Step` method and registers it as a step handler on the thin
@@ -1306,11 +1444,21 @@ declare class ThinWorkerBootstrap implements OnApplicationBootstrap, OnApplicati
1306
1444
  private readonly options;
1307
1445
  private readonly runRedisWorker;
1308
1446
  private readonly runnersSink;
1447
+ private readonly auth;
1309
1448
  private readonly runners;
1310
- constructor(runtime: DurableWorkerRuntime | null, options: DurableModuleOptions, runRedisWorker: RunRedisWorkerFn, runnersSink: RunningWorker[]);
1449
+ constructor(runtime: DurableWorkerRuntime | null, options: DurableModuleOptions, runRedisWorker: RunRedisWorkerFn, runnersSink: RunningWorker[], auth: ResolvedTenantAuth);
1311
1450
  onApplicationBootstrap(): Promise<void>;
1312
1451
  onApplicationShutdown(): Promise<void>;
1313
1452
  }
1453
+ /**
1454
+ * The tenant's `schedules`, as its worker announces them: under the wire tenant its starts carry (the
1455
+ * signed token when the app has one, else the partition), one {@link AnnouncedSchedule} per schedule.
1456
+ * A schedule's `namespace` is dropped (a tenant's runs always belong to its own namespace), and
1457
+ * `backfill` becomes the control plane's `catchup: 'latest'` (at most one late window).
1458
+ */
1459
+ declare function tenantScheduleAnnouncement(options: DurableModuleOptions, tenantToken: TenantTokenSource | undefined): Promise<{
1460
+ schedules?: ScheduleAnnouncement;
1461
+ }>;
1314
1462
  /**
1315
1463
  * The thin-worker slice of {@link import('./durable.module').DurableModule}'s unified provider set —
1316
1464
  * active for the pure thin-worker role (`connection` set, `store` unset): registers discovered
@@ -1580,6 +1728,13 @@ declare class RunRequestResponder {
1580
1728
  * failure never throws back into the transport (errors are captured into an error reply). */
1581
1729
  start(): void;
1582
1730
  private handle;
1731
+ /**
1732
+ * A tenant's `signalWithStart`: the run it names must be the requester's when it exists, and so
1733
+ * must a run already waiting on the token; anything else is refused `cross-tenant` before the
1734
+ * gateway is called. The run is started in the requester's namespace (a customer tenant it claims
1735
+ * is kept only when its verified token grants it, as for a start-run).
1736
+ */
1737
+ private signalWithStart;
1583
1738
  /** The run alone (`getRun`, else from its detail), or null when it does not exist. */
1584
1739
  private runOf;
1585
1740
  /** `call`'s result as an `ok` reply, or its rejection as an error reply. */
@@ -1736,6 +1891,35 @@ declare class ProxyRunGateway implements RunGateway {
1736
1891
  * {@link RunGatewayError} with code {@link UNSUPPORTED_RUN_REQUEST}.
1737
1892
  */
1738
1893
  private requestNewVerb;
1894
+ /**
1895
+ * Signal the run of this tenant's namespace waiting on `token` (`engine.signal`). Resolves null
1896
+ * when no run of this namespace waits on it: the control plane does NOT buffer a tenant's signal
1897
+ * for a wait opened later (another namespace's run could open it). A control plane that predates
1898
+ * the verb fails it with an {@link UNSUPPORTED_RUN_REQUEST} error.
1899
+ */
1900
+ signal(token: string, payload: unknown, opts?: SignalOptions): Promise<RunResult | null>;
1901
+ /**
1902
+ * `engine.signalWithStart` for this tenant: the control plane starts `start` in this tenant's
1903
+ * namespace unless its run exists, then signals it (buffered until the run waits, when the token
1904
+ * names the run id). See the responder for the authorization rule.
1905
+ */
1906
+ signalWithStart(start: Omit<StartRunMessage, 'tenant'> & {
1907
+ runId: string;
1908
+ }, signal: {
1909
+ token: string;
1910
+ payload?: unknown;
1911
+ }): Promise<{
1912
+ runId: string;
1913
+ signalled: boolean;
1914
+ }>;
1915
+ /**
1916
+ * Resume the runs of this tenant's namespace waiting on event `name` (`ctx.waitForEvent`).
1917
+ * Resolves how many it resumed. The tenant's own `onEvent` subscribers are started by the caller
1918
+ * (`DurableStartClient.publishEvent`), not here.
1919
+ */
1920
+ publishEvent(name: string, payload: unknown, opts?: {
1921
+ id?: string;
1922
+ }): Promise<number>;
1739
1923
  subscribe(runId: string, onEvent: (event: EngineEvent) => void): () => void;
1740
1924
  }
1741
1925
 
@@ -1852,7 +2036,17 @@ declare class StoreRunGateway implements RunGateway {
1852
2036
  listSchedules(query: ScheduleListQuery): Promise<ScheduleDescription[]>;
1853
2037
  getSchedule(id: string): Promise<ScheduleDescription | null>;
1854
2038
  scheduleAction(id: string, action: ScheduleAction): Promise<ScheduleDescription | RunResult>;
1855
- signal(token: string, payload: unknown): Promise<RunResult | null>;
2039
+ signal(token: string, payload: unknown, opts?: SignalOptions): Promise<RunResult | null>;
2040
+ signalWithStartForTenant(start: StartRunMessage & {
2041
+ runId: string;
2042
+ }, namespace: string, clientTenant: Pick<StartOptions, 'tenantId' | 'tenantKind'>, signal: {
2043
+ token: string;
2044
+ payload?: unknown;
2045
+ }): Promise<{
2046
+ runId: string;
2047
+ signalled: boolean;
2048
+ }>;
2049
+ publishEventForTenant(name: string, payload: unknown, namespace: string): Promise<number>;
1856
2050
  signalWaiter(token: string): Promise<string | null>;
1857
2051
  /**
1858
2052
  * Stream `runId`'s events. With tenancy, a run the caller may not see streams nothing; events of a
@@ -1900,6 +2094,11 @@ declare class TenantEventRepublisher {
1900
2094
  * byte-identical with nestjs-context's export.
1901
2095
  */
1902
2096
  declare const CONTEXT_ACCESSOR: unique symbol;
2097
+ /**
2098
+ * Internal: the module's resolved tenant auth (`verifyTenant` and `tenantToken`, resolved through
2099
+ * DI). Shared by the module and the thin-worker providers, which announce under the tenant token.
2100
+ */
2101
+ declare const TENANT_AUTH: unique symbol;
1903
2102
  /**
1904
2103
  * @deprecated Inject the `RunGateway` class, which is its own DI token:
1905
2104
  * `constructor(private readonly gateway: RunGateway)`. Kept because published
@@ -1986,4 +2185,4 @@ declare class WorkflowService {
1986
2185
  republishLifecycle(target: RepublishLifecycleTarget): Promise<RepublishLifecycleResult>;
1987
2186
  }
1988
2187
 
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 };
2188
+ 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, type ResolvedTenantAuth, 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_AUTH, 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, tenantScheduleAnnouncement, 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, 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';
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, SignalOptions, RunResult, StartRunMessage, WorkflowInputOf, StartOptions, WorkflowStartClient, ScheduleAnnouncement, 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 } 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';
@@ -970,6 +970,21 @@ interface DurableModuleSharedOptions {
970
970
  * deterministic and advancing a schedule is a compare-and-set. Operator only.
971
971
  */
972
972
  persistedSchedules?: boolean;
973
+ /**
974
+ * Adopt the `schedules` that TENANT apps declare and fire them here (a tenant has no store to fire
975
+ * them from). Each tenant worker announces its app's schedules on its descriptor; every `syncMs`
976
+ * (default 15 s) a driving instance turns them into persisted schedules (id
977
+ * `app:<partition>:<key>`, tagged `schedule:announced`), applies a changed definition, and pauses
978
+ * one that no live worker of its app has announced for `graceMs` (default 10 minutes). It then
979
+ * fires them on every tick, through the tenant start path: with no live worker of the app, a run
980
+ * waits `blocked` (`no_live_worker`) for one. On by default for a driving instance with a store
981
+ * that persists schedules and a transport that reads worker descriptors (BullMQ); `false` turns it
982
+ * off. Operator only.
983
+ */
984
+ announcedSchedules?: boolean | {
985
+ syncMs?: number;
986
+ graceMs?: number;
987
+ };
973
988
  /**
974
989
  * Hard-prune terminal run history on an interval so `durable_workflow_runs` (and its child tables)
975
990
  * stays bounded — without it, completed/failed/cancelled runs accumulate forever and the timer
@@ -1184,6 +1199,11 @@ interface DurableModuleAsyncOptions {
1184
1199
  useFactory: (...args: never[]) => DurableModuleOptions | Promise<DurableModuleOptions>;
1185
1200
  inject?: InjectionToken[];
1186
1201
  }
1202
+ /** The `verifyTenant` / `tenantToken` options, resolved to the plain functions the wire layer calls. */
1203
+ interface ResolvedTenantAuth {
1204
+ verifyTenant: TenantVerifier | undefined;
1205
+ tenantToken: TenantTokenSource | undefined;
1206
+ }
1187
1207
  /**
1188
1208
  * `forRoot` / `forRootAsync` first refuse to boot when two different installs of
1189
1209
  * `@dudousxd/nestjs-durable-core` are loaded in this process (a pnpm peer-variant split): each copy
@@ -1199,6 +1219,42 @@ declare class DurableModule {
1199
1219
  private static build;
1200
1220
  }
1201
1221
 
1222
+ /**
1223
+ * The `@Workflow` options a tenant's start applies itself, before it publishes the start-run: the
1224
+ * ones that are functions of the input, which the control plane (knowing the workflow by name
1225
+ * alone) cannot evaluate. Declared by `ThinWorkflowRegistrar` for every `@Workflow` it discovers.
1226
+ */
1227
+ interface TenantWorkflowStartPolicy {
1228
+ /** `@Workflow({ input, validateInput })`: rejects the start (throws) before anything is published. */
1229
+ validateInput?: ((input: unknown) => void | Promise<void>) | undefined;
1230
+ /** `@Workflow({ singleton })`: its key is evaluated here and carried on the start-run. */
1231
+ singleton?: SingletonConfig | undefined;
1232
+ /** `@Workflow({ concurrency })`: the default quota, evaluated here unless the start passes one. */
1233
+ concurrency?: ConcurrencyConfig | undefined;
1234
+ /** `@Workflow({ onEvent })` / `@OnDurableEvent`: started by this app's own `publishEvent`. */
1235
+ onEvent?: OnEventEntry[] | undefined;
1236
+ /** The workflow coalesces its event triggers (`debounce`/`batch`), which a tenant cannot apply. */
1237
+ coalesces?: boolean | undefined;
1238
+ }
1239
+ /**
1240
+ * Where a tenant's `signal`/`signalWithStart`/`publishEvent` go: run requests to the control plane
1241
+ * (the module's `ProxyRunGateway` over `transport`).
1242
+ */
1243
+ interface TenantRunRequests {
1244
+ signal(token: string, payload: unknown, opts?: SignalOptions): Promise<RunResult | null>;
1245
+ signalWithStart(start: Omit<StartRunMessage, 'tenant'> & {
1246
+ runId: string;
1247
+ }, signal: {
1248
+ token: string;
1249
+ payload?: unknown;
1250
+ }): Promise<{
1251
+ runId: string;
1252
+ signalled: boolean;
1253
+ }>;
1254
+ publishEvent(name: string, payload: unknown, opts?: {
1255
+ id?: string;
1256
+ }): Promise<number>;
1257
+ }
1202
1258
  /**
1203
1259
  * The **store-less `engine.start` facade** for a tenant worker. Provided under the `WorkflowEngine`
1204
1260
  * DI token by {@link import('./durable.module').DurableModule} (`forRoot({ connection })`, no
@@ -1216,13 +1272,91 @@ declare class DurableStartClient {
1216
1272
  private readonly deps?;
1217
1273
  /** The context accessor, for the customer tenant a start claims (else the global slot). */
1218
1274
  private readonly accessor?;
1275
+ /**
1276
+ * Sends `signal`/`signalWithStart`/`publishEvent` to the control plane as run requests (the
1277
+ * module's `ProxyRunGateway` over `transport`). Absent (no `transport`): they reject, naming it.
1278
+ */
1279
+ private readonly requests?;
1219
1280
  private readonly tenant;
1220
1281
  private readonly tenantToken;
1282
+ private readonly policies;
1283
+ private readonly warnedCoalescing;
1221
1284
  constructor(options: DurableModuleOptions, deps?: StartRunDeps | undefined,
1222
1285
  /** The context accessor, for the customer tenant a start claims (else the global slot). */
1223
- accessor?: ContextAccessor | undefined);
1286
+ accessor?: ContextAccessor | undefined,
1287
+ /**
1288
+ * Sends `signal`/`signalWithStart`/`publishEvent` to the control plane as run requests (the
1289
+ * module's `ProxyRunGateway` over `transport`). Absent (no `transport`): they reject, naming it.
1290
+ */
1291
+ requests?: (() => TenantRunRequests | undefined) | undefined);
1292
+ /**
1293
+ * Apply `policy` to every start of `workflow` from this process (see
1294
+ * {@link TenantWorkflowStartPolicy}). Called by `ThinWorkflowRegistrar` at boot.
1295
+ */
1296
+ declareWorkflow(workflow: string, policy: TenantWorkflowStartPolicy): void;
1297
+ /**
1298
+ * The start-run fields a declared policy adds for `input`: it validates the input (throwing), and
1299
+ * evaluates the singleton key and the default quota. A per-start `concurrency` wins over the
1300
+ * workflow's.
1301
+ */
1302
+ private applyPolicy;
1303
+ /** The wire `tenant`: the signed token when configured, else the partition. */
1304
+ private wireTenant;
1305
+ /**
1306
+ * The customer tenant a start claims: an explicit `tenantId` (`null` = none), else the request's
1307
+ * tenant when tenancy is on.
1308
+ */
1309
+ private claimedTenant;
1224
1310
  start<C extends WorkflowClass>(workflow: C, input: WorkflowInputOf<C>, runId?: string, opts?: StartOptions): Promise<RunResult>;
1225
1311
  start(workflow: string, input: unknown, runId?: string, opts?: StartOptions): Promise<RunResult>;
1312
+ /**
1313
+ * The start-run a start of `name` sends (everything but the wire `tenant`): the start options the
1314
+ * control plane applies (version pin, priority, delayed start, quota), the singleton key and the
1315
+ * customer tenant this run claims. Applies the workflow's declared policy first, so a rejected
1316
+ * input throws before anything is published, as `engine.start` does.
1317
+ */
1318
+ private startMessage;
1319
+ /** The control plane's run requests, or a clear error naming what is missing. */
1320
+ private runRequests;
1321
+ /**
1322
+ * Signal the run of this tenant's partition waiting on `token`, through the control plane.
1323
+ * Resolves the resumed run, or null when no run of this partition waits on it: unlike
1324
+ * `engine.signal` on a control plane, a tenant's signal is NOT buffered for a wait opened later
1325
+ * (another partition's run could open it). Use `signalWithStart` to signal a run that may not wait
1326
+ * yet. `opts.id` deduplicates like `engine.signal`.
1327
+ */
1328
+ signal(token: string, payload: unknown, opts?: SignalOptions): Promise<RunResult | null>;
1329
+ /**
1330
+ * Ensure the run `runId` of `workflow` exists in this tenant's partition (started like
1331
+ * {@link start}, with the same options and policy), then signal it. The control plane buffers the
1332
+ * signal until the run waits on `signal.token` only when the token contains `runId` (a run-scoped
1333
+ * token, the pattern `signalWithStart` is for): a token that does not is delivered only to a run
1334
+ * of this partition already waiting on it, and refused otherwise.
1335
+ */
1336
+ signalWithStart<C extends WorkflowClass>(workflow: C, input: WorkflowInputOf<C>, runId: string, signal: {
1337
+ token: string;
1338
+ payload?: unknown;
1339
+ }, opts?: StartOptions): Promise<{
1340
+ runId: string;
1341
+ }>;
1342
+ signalWithStart(workflow: string, input: unknown, runId: string, signal: {
1343
+ token: string;
1344
+ payload?: unknown;
1345
+ }, opts?: StartOptions): Promise<{
1346
+ runId: string;
1347
+ }>;
1348
+ /**
1349
+ * Publish event `name` from this tenant. Starts this app's own `onEvent` subscribers (each one
1350
+ * whose `where` accepts the payload, with its `input` mapping) as runs of this partition, by the
1351
+ * start path ({@link start}, run id `evt:<id>:<workflow>`), and has the control plane resume the
1352
+ * runs of this partition waiting on it (`ctx.waitForEvent`). Resolves how many runs it started or
1353
+ * resumed; a subscriber that throws is warned about and skipped. Unlike a control plane's
1354
+ * `publishEvent`, an event nobody received is not buffered (there is no `buffer` option), and
1355
+ * a subscriber's `debounce`/`batch` is not applied (it starts once per event, with a warning).
1356
+ */
1357
+ publishEvent(name: string, payload: unknown, opts?: {
1358
+ id?: string;
1359
+ }): Promise<number>;
1226
1360
  cancel(_runId: string): Promise<void>;
1227
1361
  deleteRun(_runId: string): Promise<void>;
1228
1362
  resume(_runId: string): Promise<void>;
@@ -1230,15 +1364,6 @@ declare class DurableStartClient {
1230
1364
  timeoutMs?: number;
1231
1365
  until?: 'settled' | 'terminal';
1232
1366
  }): Promise<void>;
1233
- signal(_token: string, _payload: unknown): Promise<void>;
1234
- signalWithStart(_workflow: string, _input: unknown, _runId: string, _signal: {
1235
- token: string;
1236
- payload?: unknown;
1237
- }, _opts?: StartOptions): Promise<void>;
1238
- publishEvent(_name: string, _payload: unknown, _opts?: {
1239
- id?: string;
1240
- buffer?: boolean;
1241
- }): Promise<void>;
1242
1367
  }
1243
1368
 
1244
1369
  /**
@@ -1276,6 +1401,19 @@ declare class ThinWorkflowRegistrar implements OnModuleInit {
1276
1401
  /** In this role the store-less `DurableStartClient` facade the module binds under this token. */
1277
1402
  starter: WorkflowStartClient);
1278
1403
  onModuleInit(): void;
1404
+ /**
1405
+ * `@Entity` providers are refused on a tenant, at boot: an entity's state is a run on the store
1406
+ * and its `@On` handlers run inside the engine that owns that store (`EntityService` and
1407
+ * `ctx.callEntity`/`signalEntity` read and serialize it there). A tenant has no store and no
1408
+ * engine, so an entity declared here would never run. Declare it on the control plane.
1409
+ */
1410
+ private assertNoEntities;
1411
+ /**
1412
+ * `@StepInterceptor()` providers wrap every step this tenant runs (each `ctx.step` its workers
1413
+ * execute), as `engine.use` does on an engine. A `@durable-worker` too old to take interceptors
1414
+ * says so instead of dropping them silently.
1415
+ */
1416
+ private useInterceptors;
1279
1417
  }
1280
1418
  /**
1281
1419
  * Discovers every `@Step` method and registers it as a step handler on the thin
@@ -1306,11 +1444,21 @@ declare class ThinWorkerBootstrap implements OnApplicationBootstrap, OnApplicati
1306
1444
  private readonly options;
1307
1445
  private readonly runRedisWorker;
1308
1446
  private readonly runnersSink;
1447
+ private readonly auth;
1309
1448
  private readonly runners;
1310
- constructor(runtime: DurableWorkerRuntime | null, options: DurableModuleOptions, runRedisWorker: RunRedisWorkerFn, runnersSink: RunningWorker[]);
1449
+ constructor(runtime: DurableWorkerRuntime | null, options: DurableModuleOptions, runRedisWorker: RunRedisWorkerFn, runnersSink: RunningWorker[], auth: ResolvedTenantAuth);
1311
1450
  onApplicationBootstrap(): Promise<void>;
1312
1451
  onApplicationShutdown(): Promise<void>;
1313
1452
  }
1453
+ /**
1454
+ * The tenant's `schedules`, as its worker announces them: under the wire tenant its starts carry (the
1455
+ * signed token when the app has one, else the partition), one {@link AnnouncedSchedule} per schedule.
1456
+ * A schedule's `namespace` is dropped (a tenant's runs always belong to its own namespace), and
1457
+ * `backfill` becomes the control plane's `catchup: 'latest'` (at most one late window).
1458
+ */
1459
+ declare function tenantScheduleAnnouncement(options: DurableModuleOptions, tenantToken: TenantTokenSource | undefined): Promise<{
1460
+ schedules?: ScheduleAnnouncement;
1461
+ }>;
1314
1462
  /**
1315
1463
  * The thin-worker slice of {@link import('./durable.module').DurableModule}'s unified provider set —
1316
1464
  * active for the pure thin-worker role (`connection` set, `store` unset): registers discovered
@@ -1580,6 +1728,13 @@ declare class RunRequestResponder {
1580
1728
  * failure never throws back into the transport (errors are captured into an error reply). */
1581
1729
  start(): void;
1582
1730
  private handle;
1731
+ /**
1732
+ * A tenant's `signalWithStart`: the run it names must be the requester's when it exists, and so
1733
+ * must a run already waiting on the token; anything else is refused `cross-tenant` before the
1734
+ * gateway is called. The run is started in the requester's namespace (a customer tenant it claims
1735
+ * is kept only when its verified token grants it, as for a start-run).
1736
+ */
1737
+ private signalWithStart;
1583
1738
  /** The run alone (`getRun`, else from its detail), or null when it does not exist. */
1584
1739
  private runOf;
1585
1740
  /** `call`'s result as an `ok` reply, or its rejection as an error reply. */
@@ -1736,6 +1891,35 @@ declare class ProxyRunGateway implements RunGateway {
1736
1891
  * {@link RunGatewayError} with code {@link UNSUPPORTED_RUN_REQUEST}.
1737
1892
  */
1738
1893
  private requestNewVerb;
1894
+ /**
1895
+ * Signal the run of this tenant's namespace waiting on `token` (`engine.signal`). Resolves null
1896
+ * when no run of this namespace waits on it: the control plane does NOT buffer a tenant's signal
1897
+ * for a wait opened later (another namespace's run could open it). A control plane that predates
1898
+ * the verb fails it with an {@link UNSUPPORTED_RUN_REQUEST} error.
1899
+ */
1900
+ signal(token: string, payload: unknown, opts?: SignalOptions): Promise<RunResult | null>;
1901
+ /**
1902
+ * `engine.signalWithStart` for this tenant: the control plane starts `start` in this tenant's
1903
+ * namespace unless its run exists, then signals it (buffered until the run waits, when the token
1904
+ * names the run id). See the responder for the authorization rule.
1905
+ */
1906
+ signalWithStart(start: Omit<StartRunMessage, 'tenant'> & {
1907
+ runId: string;
1908
+ }, signal: {
1909
+ token: string;
1910
+ payload?: unknown;
1911
+ }): Promise<{
1912
+ runId: string;
1913
+ signalled: boolean;
1914
+ }>;
1915
+ /**
1916
+ * Resume the runs of this tenant's namespace waiting on event `name` (`ctx.waitForEvent`).
1917
+ * Resolves how many it resumed. The tenant's own `onEvent` subscribers are started by the caller
1918
+ * (`DurableStartClient.publishEvent`), not here.
1919
+ */
1920
+ publishEvent(name: string, payload: unknown, opts?: {
1921
+ id?: string;
1922
+ }): Promise<number>;
1739
1923
  subscribe(runId: string, onEvent: (event: EngineEvent) => void): () => void;
1740
1924
  }
1741
1925
 
@@ -1852,7 +2036,17 @@ declare class StoreRunGateway implements RunGateway {
1852
2036
  listSchedules(query: ScheduleListQuery): Promise<ScheduleDescription[]>;
1853
2037
  getSchedule(id: string): Promise<ScheduleDescription | null>;
1854
2038
  scheduleAction(id: string, action: ScheduleAction): Promise<ScheduleDescription | RunResult>;
1855
- signal(token: string, payload: unknown): Promise<RunResult | null>;
2039
+ signal(token: string, payload: unknown, opts?: SignalOptions): Promise<RunResult | null>;
2040
+ signalWithStartForTenant(start: StartRunMessage & {
2041
+ runId: string;
2042
+ }, namespace: string, clientTenant: Pick<StartOptions, 'tenantId' | 'tenantKind'>, signal: {
2043
+ token: string;
2044
+ payload?: unknown;
2045
+ }): Promise<{
2046
+ runId: string;
2047
+ signalled: boolean;
2048
+ }>;
2049
+ publishEventForTenant(name: string, payload: unknown, namespace: string): Promise<number>;
1856
2050
  signalWaiter(token: string): Promise<string | null>;
1857
2051
  /**
1858
2052
  * Stream `runId`'s events. With tenancy, a run the caller may not see streams nothing; events of a
@@ -1900,6 +2094,11 @@ declare class TenantEventRepublisher {
1900
2094
  * byte-identical with nestjs-context's export.
1901
2095
  */
1902
2096
  declare const CONTEXT_ACCESSOR: unique symbol;
2097
+ /**
2098
+ * Internal: the module's resolved tenant auth (`verifyTenant` and `tenantToken`, resolved through
2099
+ * DI). Shared by the module and the thin-worker providers, which announce under the tenant token.
2100
+ */
2101
+ declare const TENANT_AUTH: unique symbol;
1903
2102
  /**
1904
2103
  * @deprecated Inject the `RunGateway` class, which is its own DI token:
1905
2104
  * `constructor(private readonly gateway: RunGateway)`. Kept because published
@@ -1986,4 +2185,4 @@ declare class WorkflowService {
1986
2185
  republishLifecycle(target: RepublishLifecycleTarget): Promise<RepublishLifecycleResult>;
1987
2186
  }
1988
2187
 
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 };
2188
+ 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, type ResolvedTenantAuth, 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_AUTH, 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, tenantScheduleAnnouncement, thinWorkerProviders, unavailableRunGateway };