@dudousxd/nestjs-durable 0.55.2 → 0.57.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, StateStore, Transport, NamedTransport, ControlPlane, StalledRunInfo, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, TenantVerifier, TenantTokenSource, WorkflowInputOf, StartOptions, RunResult, RunGateway, WorkflowEngine, EntityHandler, RunRequest, RunReply, 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, RunGateway, WorkflowEngine, EntityHandler, RunRequest, RunReply, 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';
2
2
  export { AttributeFilter, 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';
@@ -83,7 +83,8 @@ declare function attributesOf<C extends WorkflowClass>(workflow: C, run: {
83
83
  * Kept byte-aligned with nestjs-context's `ContextAccessor` (and the identical
84
84
  * mirror in `@dudousxd/nestjs-authz`): `traceId()` / `tenantId()` are REQUIRED
85
85
  * (the real accessor always provides them) and `get()` is included, so the
86
- * structural match stays exact when DurableModule auto-feeds the carrier.
86
+ * structural match stays exact when DurableModule auto-feeds the carrier. The tenancy
87
+ * members (`tenant`/`tenancy`/`tenantFilter`, nestjs-context ≥ 1.2) are optional.
87
88
  */
88
89
  interface UserRef {
89
90
  type: string;
@@ -100,7 +101,40 @@ interface ContextAccessor {
100
101
  userRef(): UserRef | undefined;
101
102
  /** The raw context store for the current request, or `undefined`. */
102
103
  get(): ContextStore | undefined;
104
+ /**
105
+ * The active tenant (the customer the request's data belongs to). Optional: an older context, or
106
+ * an app's own accessor, may not have it; durable then treats tenancy as off.
107
+ */
108
+ tenant?(): TenantRef | undefined;
109
+ /** The context's `tenancy` switch: `{ enabled, kinds? }`. Optional, as above. */
110
+ tenancy?(): {
111
+ enabled: boolean;
112
+ kinds?: string[];
113
+ };
114
+ /** How a lib must scope data right now. Optional, as above. */
115
+ tenantFilter?(options?: {
116
+ kinds?: string[];
117
+ }): TenantFilter;
118
+ }
119
+ /** A tenant as the context reports it. Structural mirror of nestjs-context's `TenantRef`. */
120
+ interface TenantRef {
121
+ id: string;
122
+ kind: string;
123
+ source: string;
124
+ slug?: string;
125
+ role?: string;
103
126
  }
127
+ /** How a lib must scope data right now. Structural mirror of nestjs-context's `TenantFilter`. */
128
+ type TenantFilter = {
129
+ mode: 'system';
130
+ } | {
131
+ mode: 'all';
132
+ } | {
133
+ mode: 'tenantless';
134
+ } | {
135
+ mode: 'tenant';
136
+ tenant: TenantRef;
137
+ };
104
138
 
105
139
  /** A class-validator DTO class — validated with the same `plainToInstance` + `validate` NestJS's
106
140
  * `ValidationPipe` runs. */
@@ -575,6 +609,74 @@ declare const OnEvent: typeof OnDurableEvent;
575
609
  */
576
610
  declare function getOnEvents(meta: WorkflowMeta, target: object): OnEventEntry[];
577
611
 
612
+ /**
613
+ * Tenancy for durable: the CUSTOMER a run belongs to (`@dudousxd/nestjs-context`'s tenant), not the
614
+ * worker-pool `namespace`. A local, structural reader of the context contract — durable never imports
615
+ * nestjs-context, so it works with any context version or none at all: with the accessor (or its
616
+ * tenancy methods) missing, tenancy reads as off and durable behaves exactly as without it.
617
+ */
618
+ /** The `tenancy` option of `DurableModule`. Same shape in every Aviary lib. */
619
+ type DurableTenancyOption = 'inherit' | false | {
620
+ /** `'inherit'` (default) follows `ContextModule`'s `tenancy.enabled`. */
621
+ enabled?: 'inherit' | boolean;
622
+ /** Tenant kinds durable honours, instead of the context's own `kinds`. */
623
+ kinds?: string[];
624
+ /** Whether a tenant request also sees runs with no tenant. Default `'tenantless'` (it does not). */
625
+ nullRows?: 'tenantless' | 'shared';
626
+ };
627
+
628
+ /** What a tenant verifier receives for each request a tenant process sends. */
629
+ interface TenantVerifierInput {
630
+ /** The token presented on the request (the wire `tenant` field). */
631
+ token?: string | undefined;
632
+ /** The tenant the request *claims* to be. Advisory only: derive the real one from the token. */
633
+ tenant?: string | undefined;
634
+ }
635
+ /**
636
+ * The object/class form of `verifyTenant`. Runs on the control plane for every request a tenant
637
+ * process sends.
638
+ */
639
+ interface TenantVerifierContract {
640
+ /**
641
+ * Turn the wire token into the tenant it authenticates as. Return `null` to reject: the request is
642
+ * answered `unauthorized` and never touches a run. Throw when you cannot decide (the identity
643
+ * provider is down): the request fails with the error and the next one calls `verify` again. The
644
+ * returned `tenant` is trusted as-is, so derive it from the verified token, never from
645
+ * `input.tenant`.
646
+ */
647
+ verify(input: TenantVerifierInput): VerifiedTenant | null | Promise<VerifiedTenant | null>;
648
+ }
649
+ /**
650
+ * The object/class form of `tenantToken`. Runs on the tenant process before every request it sends.
651
+ */
652
+ interface TenantCredentialsContract {
653
+ /**
654
+ * The token to present on the next request, sent as-is in the wire `tenant` field. Called once per
655
+ * request, so cache the token and fetch a new one before it expires. A throw (or an empty string)
656
+ * fails that request; the next request calls `token()` again.
657
+ */
658
+ token(): string | Promise<string>;
659
+ }
660
+ /** A class implementing a contract; its constructor parameters are resolved by Nest DI. */
661
+ type ContractClass<T> = new (...args: any[]) => T;
662
+ /** A lazy import of a module whose default export is a contract class or object. */
663
+ type LazyContract<T> = () => Promise<{
664
+ default: ContractClass<T> | T;
665
+ }>;
666
+ /**
667
+ * The `verifyTenant` option: a function (e.g. `hmacTenantVerifier(secret)`), an object implementing
668
+ * {@link TenantVerifierContract}, a class implementing it (built once through Nest DI: the registered
669
+ * provider when there is one, else `ModuleRef.create`), or a lazy import of a module whose default
670
+ * export is such a class or object (imported once).
671
+ */
672
+ type TenantVerifierOption = TenantVerifier | TenantVerifierContract | ContractClass<TenantVerifierContract> | LazyContract<TenantVerifierContract>;
673
+ /**
674
+ * The `tenantToken` option: a string, a function called before every request, an object implementing
675
+ * {@link TenantCredentialsContract}, a class implementing it (built once through Nest DI), or a lazy
676
+ * import of a module whose default export is such a class or object (imported once).
677
+ */
678
+ type TenantTokenOption = TenantTokenSource | TenantCredentialsContract | ContractClass<TenantCredentialsContract> | LazyContract<TenantCredentialsContract>;
679
+
578
680
  /**
579
681
  * Retention config for the {@link RetentionPoller}. One or more {@link RetentionPolicy policies}
580
682
  * (status sets must be disjoint per scope — validated at boot), swept together on a shared interval.
@@ -607,28 +709,24 @@ interface DurableRetentionOptions {
607
709
  batchSize?: number;
608
710
  }
609
711
  /**
610
- * Options for `DurableModule.forRoot`/`forRootAsync`. The **role is inferred** from which of `store`/
611
- * `connection` are set:
712
+ * The options every {@link DurableModuleOptions} variant shares. With no `topology` (or
713
+ * `topology: 'standalone'`) the **role is inferred** from which of `store`/`connection` are set:
612
714
  *
613
- * - `{ store, transport }` — **operator**: a real `WorkflowEngine` + `StoreRunGateway` + drivers/
715
+ * - `{ store, transport }`: **operator**, a real `WorkflowEngine` + `StoreRunGateway` + drivers/
614
716
  * timer/retention/registrars, executing registered bodies INLINE. Driven by {@link drive} (default
615
717
  * `true`).
616
- * - `{ connection }` (no `store`) — **thin worker**: `WorkflowEngine` resolves to a store-less
718
+ * - `{ connection }` (no `store`): **thin worker**, `WorkflowEngine` resolves to a store-less
617
719
  * `DurableStartClient`; `RUN_GATEWAY` is a `ProxyRunGateway` when `transport` is also given, else
618
- * every method rejects with a clear error. No store/timer/retention/entity — just discovered
720
+ * every method rejects with a clear error. No store/timer/retention/entity, just discovered
619
721
  * `@Workflow`/`@Step` handlers served over ONE `runRedisWorker` consumer.
620
- * - `{ store, transport, connection }` — an **operator that also runs a co-located worker**: every
722
+ * - `{ store, transport, connection }`: an **operator that also runs a co-located worker**: every
621
723
  * `@Workflow` is registered GROUP-SERVED (dispatched over the transport, PER WORKFLOW NAME, instead
622
724
  * of inline) and a co-located consumer (one `runRedisWorker` call) replays the same bodies.
623
725
  *
624
726
  * `forRoot` throws when neither `store` nor `connection` is set, and when `store` is set without a
625
727
  * `transport`.
626
- *
627
- * Set {@link DurableModuleOptions.topology} to name the role explicitly instead of relying on this
628
- * inference — it additionally VALIDATES the axes above (`namespace` vs `partition`) that this prose
629
- * is otherwise the only source of truth for. Omitting it changes nothing.
630
728
  */
631
- interface DurableModuleOptions {
729
+ interface DurableModuleSharedOptions {
632
730
  /** State store — set this to play the **operator** role (see the interface doc for the full role
633
731
  * matrix). Omit for a store-less **thin worker** (`connection` only). */
634
732
  store?: StateStore;
@@ -879,6 +977,17 @@ interface DurableModuleOptions {
879
977
  * authorization boundary. Operator only.
880
978
  */
881
979
  context?: () => Record<string, unknown> | undefined;
980
+ /**
981
+ * Tenancy: scope runs by the CUSTOMER they belong to (`@dudousxd/nestjs-context`'s tenant), not by
982
+ * the worker-pool {@link namespace}. With it on, `start` stamps the request's tenant on the run
983
+ * (an explicit `StartOptions.tenantId` wins), children, `continueAsNew` and schedules inherit it,
984
+ * every turn runs with it restored as the context tenant, and app-facing reads and control calls
985
+ * (`getRun`, `signal`, `cancel`, retry, the dashboard) only see the caller's tenant's runs.
986
+ *
987
+ * `'inherit'` (default) follows `ContextModule.forRoot({ tenancy: { enabled } })`, which is off by
988
+ * default; `false` keeps durable out of tenancy. Without nestjs-context ≥ 1.2, tenancy is off.
989
+ */
990
+ tenancy?: DurableTenancyOption;
882
991
  /** Attempts for each saga compensation when a run fails. Default 1 (no retry). Idempotent undos.
883
992
  * Operator only. */
884
993
  compensationRetries?: number;
@@ -937,73 +1046,96 @@ interface DurableModuleOptions {
937
1046
  * **Operator.** Verifies the signed tenant token a store-less tenant worker presents in the wire
938
1047
  * `tenant` field of every run request and start-run message, and DERIVES the tenant from it,
939
1048
  * discarding the wire claim. An invalid, tampered or absent token is rejected: a run request gets
940
- * an `unauthorized` error reply, a start-run creates nothing. Use `hmacTenantVerifier(secret)`
941
- * (tokens minted by `signTenantToken`, wire-compatible with Agora) or supply your own.
1049
+ * an `unauthorized` error reply, a start-run creates nothing; a verifier that throws fails the
1050
+ * request with its error. Use `hmacTenantVerifier(secret)` (tokens minted by `signTenantToken`,
1051
+ * wire-compatible with Agora) or supply your own: a function, an object or class implementing
1052
+ * `TenantVerifierContract` (a class is built once through Nest DI), or a lazy import of one
1053
+ * (`() => import('./tenant-verifier.js')`, imported once).
942
1054
  *
943
1055
  * Optional. Absent: the wire `tenant` is trusted verbatim (prefix/network isolation only), exactly
944
- * as before. An explicit `topology: { role: 'control-plane' }` without a verifier logs a warning
945
- * at boot; a plain operator (`store` + `transport`, no `topology`) boots silently.
1056
+ * as before. `topology: 'control-plane'` without a verifier logs a warning at boot; a standalone
1057
+ * operator boots silently.
946
1058
  */
947
- verifyTenant?: TenantVerifier;
1059
+ verifyTenant?: TenantVerifierOption;
948
1060
  /**
949
1061
  * **Tenant worker.** The signed token (see `signTenantToken`) this worker presents, verbatim, in
950
1062
  * the `tenant` field of every run request (`ProxyRunGateway`) and start-run (`engine.start`), so
951
- * an operator with {@link verifyTenant} can authenticate it. A string, or a function called before
952
- * every request (rotation, short-lived tokens). Optional: absent, the raw {@link partition} is
953
- * sent, as before. Live-tail stays keyed by the partition, never the token.
1063
+ * an operator with {@link verifyTenant} can authenticate it. A string, a function called before
1064
+ * every request (rotation, short-lived tokens), an object or class implementing
1065
+ * `TenantCredentialsContract` (a class is built once through Nest DI), or a lazy import of one.
1066
+ * Every form but the string is called per request and owns its caching. Optional: absent, the raw
1067
+ * {@link partition} is sent, as before. Live-tail stays keyed by the partition, never the token.
954
1068
  */
955
- tenantToken?: TenantTokenSource;
1069
+ tenantToken?: TenantTokenOption;
1070
+ }
1071
+ /** The process roles a {@link DurableModuleOptions.topology} names. Same vocabulary as Agora. */
1072
+ type DurableTopologyName = 'standalone' | 'control-plane' | 'tenant';
1073
+ /**
1074
+ * The default topology: today's role inference from `store`/`connection` (see
1075
+ * {@link DurableModuleSharedOptions}). `partition` is the queue suffix a worker role serves.
1076
+ */
1077
+ interface StandaloneDurableOptions extends DurableModuleSharedOptions {
1078
+ topology?: 'standalone';
1079
+ }
1080
+ /**
1081
+ * A coordinator: owns the store, dispatches over the transport, recovers, fires timers, prunes
1082
+ * retention and answers tenant requests. Requires `store` and `transport` (or `transports`).
1083
+ */
1084
+ interface ControlPlaneDurableOptions extends Omit<DurableModuleSharedOptions, 'store' | 'tenantToken'> {
1085
+ topology: 'control-plane';
1086
+ store: StateStore;
956
1087
  /**
957
- * An explicit preset that NAMES the deployment role instead of leaving it to `store`/`connection`
958
- * inference, and VALIDATES the axes that are otherwise only prose (see the interface doc's role
959
- * matrix, and {@link namespace} vs {@link partition}). Omit to keep the existing inference —
960
- * `topology` is entirely additive and changes nothing when unset.
961
- *
962
- * **`namespace` vs `partition` — the two axes this preset locks down:**
963
- * - `namespace` is the OPERATOR's poll-scoping axis: which runs a control-plane instance
964
- * drives/recovers/resumes (`runPending`/`recoverIncomplete`/`resumeDueTimers`/`sweepTimeouts`).
965
- * Unset makes the instance see (drive) EVERY namespace.
966
- * `{ role: 'control-plane' }` is the only preset that allows it.
967
- * - `partition` is the WORKER's queue-routing suffix: which queue a thin/co-located worker's
968
- * consumer subscribes to (`<name>@<partition>`), matching the queue an operator's convention
969
- * dispatch routes a run's `namespace` to. `{ role: 'tenant' }` sets this FOR you from `tenant` —
970
- * you never set `partition` directly under `topology`.
971
- *
972
- * **One `tenant` word, two axes — the preset maps it to the right one per role:** on a
973
- * `control-plane` an optional `tenant` scopes the OPERATOR to its own runs (maps to `namespace` —
974
- * a self-contained local stack sharing a broker with a deployed cluster names itself so neither
975
- * drives the other's runs; leave it unset on a deployed operator to drive every tenant). On a
976
- * `tenant` role it is required and maps to `partition` (the worker's queue suffix).
977
- *
978
- * ```ts
979
- * // Control plane: owns the store, dispatches over the transport, prunes old runs. The optional
980
- * // `tenant` (e.g. from an env var) scopes this operator to its own runs — undefined on a
981
- * // deployed operator (drives everything), set on a local stack sharing the broker.
982
- * DurableModule.forRoot({
983
- * topology: { role: 'control-plane', tenant: process.env.DURABLE_TENANT },
984
- * store,
985
- * transport,
986
- * retention: { policies: [{ statuses: ['completed', 'cancelled'], maxAge: '14d' }] },
987
- * });
988
- *
989
- * // Tenant: store-less worker scoped to its own partition — `tenant` maps to `partition` for you.
990
- * DurableModule.forRoot({
991
- * topology: { role: 'tenant', tenant: 'acme-corp' },
992
- * connection: process.env.REDIS_URL,
993
- * });
994
- * ```
995
- *
996
- * Validated at `forRoot`/`forRootAsync` resolution time — see {@link DurableModule} for the exact
997
- * error messages, which double as the axis primer above.
998
- */
999
- topology?: {
1000
- role: 'control-plane';
1001
- tenant?: string;
1002
- } | {
1003
- role: 'tenant';
1004
- tenant: string;
1005
- };
1088
+ * The namespace this control plane serves. Omit it on a deployed control plane, which then drives
1089
+ * every tenant's runs. Set it to scope a self-contained stack (a developer's machine sharing a
1090
+ * broker with a deployed cluster) to its own runs: it becomes this node's `namespace` and the
1091
+ * `<name>@<partition>` queues its co-located consumers subscribe to.
1092
+ */
1093
+ partition?: string;
1094
+ /** A control plane verifies tenant tokens; it does not present one. */
1095
+ tenantToken?: never;
1006
1096
  }
1097
+ /**
1098
+ * A store-less worker for one partition: it pulls `<name>@<partition>` tasks from the broker over
1099
+ * `connection` and, with a `transport`, proxies reads and control actions to the control plane.
1100
+ */
1101
+ interface TenantDurableOptions extends Omit<DurableModuleSharedOptions, 'store' | 'namespace' | 'partition' | 'connection' | 'verifyTenant'> {
1102
+ topology: 'tenant';
1103
+ /** A tenant is store-less: everything goes over the wire to the control plane. */
1104
+ store?: never;
1105
+ /** `namespace` scopes an operator's poll loop; a tenant has none. Use `partition`. */
1106
+ namespace?: never;
1107
+ /** The partition this process serves and acts as. Required. */
1108
+ partition: string;
1109
+ /** The broker connection the tenant's consumer pulls its partition's tasks from. Required. */
1110
+ connection: string | Record<string, unknown>;
1111
+ /** A tenant presents a token (`tenantToken`); the control plane verifies it. */
1112
+ verifyTenant?: never;
1113
+ }
1114
+ /**
1115
+ * Options for `DurableModule.forRoot`/`forRootAsync`, discriminated on `topology`:
1116
+ *
1117
+ * ```ts
1118
+ * // Control plane: owns the store, dispatches over the transport, prunes old runs.
1119
+ * DurableModule.forRoot({
1120
+ * topology: 'control-plane',
1121
+ * store,
1122
+ * transport,
1123
+ * retention: { policies: [{ statuses: ['completed', 'cancelled'], maxAge: '14d' }] },
1124
+ * });
1125
+ *
1126
+ * // Tenant: a store-less worker serving its own partition.
1127
+ * DurableModule.forRoot({
1128
+ * topology: 'tenant',
1129
+ * partition: 'acme-corp',
1130
+ * connection: process.env.REDIS_URL,
1131
+ * });
1132
+ * ```
1133
+ *
1134
+ * Omit `topology` (or pass `'standalone'`) to keep the role inference described on
1135
+ * {@link DurableModuleSharedOptions}. TypeScript rejects a `store` on a tenant; the rest is
1136
+ * validated at `forRoot`/`forRootAsync` resolution time.
1137
+ */
1138
+ type DurableModuleOptions = StandaloneDurableOptions | ControlPlaneDurableOptions | TenantDurableOptions;
1007
1139
  interface DurableModuleAsyncOptions {
1008
1140
  useFactory: (...args: never[]) => DurableModuleOptions | Promise<DurableModuleOptions>;
1009
1141
  inject?: InjectionToken[];
@@ -1011,13 +1143,7 @@ interface DurableModuleAsyncOptions {
1011
1143
  declare class DurableModule {
1012
1144
  static forRoot(options: DurableModuleOptions): DynamicModule;
1013
1145
  static forRootAsync(options: DurableModuleAsyncOptions): DynamicModule;
1014
- /**
1015
- * Validates role/axis constraints, in resolution order. When {@link DurableModuleOptions.topology}
1016
- * is set, it OWNS validation — {@link assertValidTopology}'s own store/transport/connection checks
1017
- * are strictly stronger than {@link assertValidRole}'s, so the topology-specific, axis-teaching
1018
- * message is what a `topology`-opted-in consumer sees (not the older generic one). Falls back to
1019
- * {@link assertValidRole} unchanged when `topology` is absent — zero behavior change.
1020
- */
1146
+ /** Validates the topology and its role/axis constraints; see {@link assertValidTopology}. */
1021
1147
  private static assertValid;
1022
1148
  private static build;
1023
1149
  }
@@ -1038,6 +1164,7 @@ declare class DurableStartClient {
1038
1164
  private readonly options;
1039
1165
  private readonly deps?;
1040
1166
  private readonly tenant;
1167
+ private readonly tenantToken;
1041
1168
  constructor(options: DurableModuleOptions, deps?: StartRunDeps | undefined);
1042
1169
  start<C extends WorkflowClass>(workflow: C, input: WorkflowInputOf<C>, runId?: string, opts?: StartOptions): Promise<RunResult>;
1043
1170
  start(workflow: string, input: unknown, runId?: string, opts?: StartOptions): Promise<RunResult>;
@@ -1270,7 +1397,7 @@ interface RunRequestResponderOptions {
1270
1397
  verifyTenant?: TenantVerifier | undefined;
1271
1398
  /**
1272
1399
  * Warn at construction when no {@link verifyTenant} is set. Default `true`. `DurableModule` passes
1273
- * `true` only for an explicit `topology: { role: 'control-plane' }`, so a plain operator app that
1400
+ * `true` only for `topology: 'control-plane'`, so a standalone operator app that
1274
1401
  * never serves tenants boots silently.
1275
1402
  */
1276
1403
  warnWithoutVerifier?: boolean | undefined;
@@ -1454,6 +1581,13 @@ declare class StoreRunGateway implements RunGateway {
1454
1581
  private readonly engine;
1455
1582
  constructor(store: StateStore, engine: WorkflowEngine);
1456
1583
  topology(): DurableTopology;
1584
+ /**
1585
+ * Narrow `query` to the caller's tenant (the tenancy matching rule; see `DurableModule`'s
1586
+ * `tenancy`). A no-op with tenancy off, or for a caller outside any request (`system`).
1587
+ */
1588
+ private scoped;
1589
+ /** The run, or null when it is missing OR belongs to a tenant the caller may not see (404). */
1590
+ private visibleRun;
1457
1591
  getRunDetail(runId: string, options?: RunDetailOptions): Promise<RunDetail | null>;
1458
1592
  /**
1459
1593
  * What a run detail reads beyond the run row and its checkpoints: what this run's settling
@@ -1512,6 +1646,10 @@ declare class StoreRunGateway implements RunGateway {
1512
1646
  redispatched: number;
1513
1647
  }) | null>;
1514
1648
  republishLifecycle(target: RepublishLifecycleTarget): Promise<RepublishLifecycleResult>;
1649
+ /**
1650
+ * Stream `runId`'s events. With tenancy, a run the caller may not see streams nothing; events of a
1651
+ * run that does not exist yet are held until its row shows whose it is.
1652
+ */
1515
1653
  subscribe(runId: string, onEvent: (event: EngineEvent) => void): () => void;
1516
1654
  }
1517
1655
 
@@ -1644,4 +1782,4 @@ declare class WorkflowService {
1644
1782
  republishLifecycle(target: RepublishLifecycleTarget): Promise<RepublishLifecycleResult>;
1645
1783
  }
1646
1784
 
1647
- export { BAD_RUN_REQUEST, CONTEXT_ACCESSOR, type ContextAccessor, type ContextStore, DEAD_LETTER_METADATA, DURABLE_STEP_METADATA, DURABLE_WORKER_RUNNERS, DURABLE_WORKER_RUNTIME, DeadLetter, type DtoClass, DurableModule, type DurableModuleAsyncOptions, type DurableModuleOptions, type DurableRetentionOptions, DurableStartClient, DurableStep, type DurableStepInterceptor, type DurableStepMeta, 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, ON_ERROR_METADATA, ON_EVENT_BATCH_METADATA, ON_EVENT_METADATA, On, OnDurableEvent, OnError, type OnErrorMethod, OnEvent, 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, Step, StepInterceptor, type StepOptions, StoreRunGateway, type SubscriberBatch, type SubscriberDebounce, type SubscriberDecorator, TENANT_REPUBLISH_MAX_LIMIT, TenantEventRepublisher, 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 };
1785
+ 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, DurableStep, 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, OnEvent, 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 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 };