@dudousxd/nestjs-durable-core 0.90.1 → 0.92.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
@@ -1244,7 +1244,7 @@ declare namespace StandardSchemaV1 {
1244
1244
  * (pnpm peer-dependency multiplexing, or a dual ESM/CJS load) still reads the SAME key. A plain
1245
1245
  * `Symbol()` would mint a distinct token per copy, so a decorator running against one core instance
1246
1246
  * could stamp a name core's `ctx.step` (a different instance) can never read back. Mirrors the
1247
- * `STATE_STORE` token fix in `./tokens.ts`.
1247
+ * DI token fix in `./tokens.ts`.
1248
1248
  */
1249
1249
  declare const DURABLE_STEP_NAME: unique symbol;
1250
1250
  /**
@@ -2671,6 +2671,14 @@ interface StartRunMessage {
2671
2671
  tags?: string[] | undefined;
2672
2672
  /** Typed, queryable run data to stamp on the run (same as {@link StartOptions.searchAttributes}). */
2673
2673
  searchAttributes?: SearchAttributes | undefined;
2674
+ /**
2675
+ * The customer (data tenant) the run belongs to, as the tenant process sees it. Only a claim: the
2676
+ * control plane keeps it when the process's verified token grants `tenancy:*` or
2677
+ * `tenancy:<tenantId>` in its `capabilities`, else the run gets no customer tenant.
2678
+ */
2679
+ tenantId?: string | undefined;
2680
+ /** The kind of {@link tenantId} (`organization`, `clinic`, …). */
2681
+ tenantKind?: string | undefined;
2674
2682
  }
2675
2683
  /**
2676
2684
  * A tenant worker → control plane read/control request over the shared transport. Enqueued on
@@ -4137,13 +4145,6 @@ declare function countRuns(store: StateStore, query: Omit<RunQuery, 'limit' | 'o
4137
4145
  */
4138
4146
  declare function assertConcurrency(store: StateStore, workflow: string, quota: ConcurrencyQuota): Promise<void>;
4139
4147
 
4140
- /**
4141
- * Back-compat alias of {@link WorkflowCtx}. `localStep` — the checkpointed in-process step primitive
4142
- * used for saga compensation — is now part of the public {@link WorkflowCtx}, so this type adds
4143
- * nothing; it is kept only so internal consumers (the durable-entity runner) keep compiling.
4144
- */
4145
- type InternalWorkflowCtx = WorkflowCtx;
4146
-
4147
4148
  /** One operation on a durable entity: mutate `state` in place and/or return a result. */
4148
4149
  type EntityHandler<S = unknown> = (state: S, arg: unknown) => unknown | Promise<unknown>;
4149
4150
  /** A durable keyed entity (a virtual object): per-key serialized handlers over durable state. */
@@ -4155,7 +4156,7 @@ interface EntityConfig<S = unknown> {
4155
4156
  }
4156
4157
  /** The slice of the engine the entity subsystem needs (so it stays a standalone module). */
4157
4158
  interface EntityHost {
4158
- register(name: string, version: string, fn: (ctx: InternalWorkflowCtx, input: unknown) => Promise<unknown>, opts?: {
4159
+ register(name: string, version: string, fn: (ctx: WorkflowCtx, input: unknown) => Promise<unknown>, opts?: {
4159
4160
  origin?: string | undefined;
4160
4161
  }): void;
4161
4162
  signalWithStart(workflow: string, input: unknown, runId: string, signal: {
@@ -4269,6 +4270,12 @@ interface EngineTenancy {
4269
4270
  filter(): TenantFilter;
4270
4271
  /** Run `fn` with `tenant` restored as the ambient context tenant. */
4271
4272
  run<T>(tenant: RunTenant, fn: () => T): T;
4273
+ /**
4274
+ * Run `fn` as durable's own work (a workflow turn, a recovery, a worker's step), where no request
4275
+ * asks for a tenant: a host whose tenancy requires one (`required: true`) must not reject a
4276
+ * missing tenant inside it. Optional: without it, `fn` runs as is.
4277
+ */
4278
+ system?<T>(fn: () => T): T;
4272
4279
  }
4273
4280
  /** A row that may carry a tenant (a run, a schedule). */
4274
4281
  interface TenantRow {
@@ -5222,9 +5229,10 @@ interface VerifiedTenant {
5222
5229
  /** The tenant the token authenticates as. The responder trusts THIS, never the request body. */
5223
5230
  tenant: string;
5224
5231
  /**
5225
- * Capabilities the token grants, if the issuer scopes them. Carried for custom verifiers and for
5226
- * wire parity with Agora; the built-in responder does NOT enforce them yet. A verified tenant can
5227
- * call every verb, scoped to its own namespace.
5232
+ * Capabilities the token grants, if the issuer scopes them. `tenancy:*` or `tenancy:<id>` lets the
5233
+ * process claim that customer tenant for the runs it starts (see `StartRunMessage.tenantId`). The
5234
+ * run-request responder does not enforce them: a verified tenant can call every verb, scoped to
5235
+ * its own namespace.
5228
5236
  */
5229
5237
  capabilities?: string[] | undefined;
5230
5238
  }
@@ -5274,6 +5282,17 @@ declare function signTenantToken(tenant: string, secret: string, opts?: {
5274
5282
  * responder does not enforce it yet, see {@link VerifiedTenant.capabilities}).
5275
5283
  */
5276
5284
  declare function hmacTenantVerifier(secret: string | string[], capabilities?: string[]): TenantVerifier;
5285
+ /**
5286
+ * Verify a wire message's `tenant`: with a verifier, the {@link VerifiedTenant} it derives (`null` on
5287
+ * reject); without one, the wire value trusted verbatim, with no capabilities.
5288
+ */
5289
+ declare function verifyWireTenant(wireTenant: string, verifyTenant: TenantVerifier | undefined): Promise<VerifiedTenant | null>;
5290
+ /**
5291
+ * Whether a verified tenant process may claim the customer `tenantId` for a run it starts: its
5292
+ * `capabilities` hold `tenancy:*` (any customer) or `tenancy:<tenantId>`. An unverified process (no
5293
+ * verifier) holds none, so it never may.
5294
+ */
5295
+ declare function grantsClientTenant(verified: VerifiedTenant | null, tenantId: string): boolean;
5277
5296
  /**
5278
5297
  * Resolve the tenant a wire message is ALLOWED to act as. With a verifier, the wire `tenant` is the
5279
5298
  * signed token: it is verified and the real tenant derived from it (`null` on reject). Without one,
@@ -5283,7 +5302,7 @@ declare function resolveWireTenant(wireTenant: string, verifyTenant: TenantVerif
5283
5302
  /** Resolve a {@link TenantTokenSource} to the token string to put on the wire. */
5284
5303
  declare function resolveTenantToken(source: TenantTokenSource): Promise<string>;
5285
5304
 
5286
- type WorkflowFn = (ctx: InternalWorkflowCtx, input: unknown) => Promise<unknown>;
5305
+ type WorkflowFn = (ctx: WorkflowCtx, input: unknown) => Promise<unknown>;
5287
5306
  /**
5288
5307
  * Options for {@link WorkflowEngine.start}.
5289
5308
  *
@@ -5583,7 +5602,7 @@ interface WorkflowEngineDeps {
5583
5602
  */
5584
5603
  context?: (() => Record<string, unknown> | undefined) | undefined;
5585
5604
  /**
5586
- * Re-hydrate the originating context around a LOCAL step body, so a `@DurableStep` reader sees the
5605
+ * Re-hydrate the originating context around a LOCAL step body, so a `@Step` reader sees the
5587
5606
  * tenant / user / correlation ids that were live when the run was started — even on a path the
5588
5607
  * engine drives outside the originating request scope (a resume after crash/scale-down, a timer).
5589
5608
  * Given the carrier produced by {@link context} (may be empty/undefined) and the step body `fn`, it
@@ -7306,7 +7325,7 @@ declare class WorkflowEngine {
7306
7325
  /** {@link getRunChildren} without the tenancy check (the engine's own subtree walks). */
7307
7326
  private runChildrenUnchecked;
7308
7327
  /** The worker groups this engine dispatches to: every registered remote workflow's group, plus any
7309
- * `extra` the caller declares. Local-step groups (a group consumed by in-process `@DurableStep`
7328
+ * `extra` the caller declares. Local-step groups (a group consumed by in-process `@Step`
7310
7329
  * workers, e.g. `pipeline`) aren't derivable from registrations — pass them via `extra` so a group
7311
7330
  * with backlog and ZERO workers is still reported (the alert case has no heartbeat to discover). */
7312
7331
  knownGroups(extra?: string[]): string[];
@@ -8999,11 +9018,6 @@ interface ScheduledWorkflow<W extends WorkflowRef = WorkflowRef> {
8999
9018
  * `Math.random`; overridden in tests so jitter is deterministic. */
9000
9019
  interface RunSchedulesOptions {
9001
9020
  random?: () => number;
9002
- /**
9003
- * @deprecated No longer called: jitter defers a window to a later tick instead of sleeping inside
9004
- * this one. Kept so existing callers still type-check.
9005
- */
9006
- sleep?: (ms: number) => Promise<void>;
9007
9021
  }
9008
9022
  /** Deterministic run id for a fixed-interval schedule's current time window. */
9009
9023
  declare function scheduledRunId(key: string, everyMs: number, nowMs: number): string;
@@ -9175,35 +9189,33 @@ declare function sanitizeQueueToken(name: string): string;
9175
9189
  * `import` (`index.js`) and once as `require` (`index.cjs`). A plain `Symbol()` would mint a
9176
9190
  * DISTINCT token per copy, so `DurableModule` (provider) and `DashboardService` / a store adapter
9177
9191
  * (injector) could resolve different symbols → Nest can't satisfy the dependency
9178
- * (`STATE_STORE is not available in the DurableApiModule context`). A registered symbol collapses
9192
+ * (`<token> is not available in the DurableApiModule context`). A registered symbol collapses
9179
9193
  * them to one. Mirrors the `CONTEXT_ACCESSOR` token in `@dudousxd/nestjs-durable`'s `tokens.ts`.
9180
9194
  */
9181
9195
  /**
9182
- * @deprecated Use {@link STATE_STORE_CANONICAL} (`@dudousxd/nestjs-durable:state-store`). The legacy
9183
- * token stays bound as a back-compat alias and still resolves; it will be removed in a future major.
9196
+ * The durable DI tokens, following the ecosystem capability naming `@dudousxd/nestjs-durable:<name>`
9197
+ * (identical to `capability('durable', <name>)`), so an external library can resolve durable's
9198
+ * store/transport/options by name without importing durable internals. Bare `Symbol.for` keeps
9199
+ * `core` free of any `@dudousxd/nestjs-diagnostics` runtime dependency.
9200
+ */
9201
+ declare const STATE_STORE_CANONICAL: unique symbol;
9202
+ declare const TRANSPORT_CANONICAL: unique symbol;
9203
+ declare const DURABLE_OPTIONS_CANONICAL: unique symbol;
9204
+ /**
9205
+ * @deprecated Use {@link STATE_STORE_CANONICAL}. Kept because published `@dudousxd/nestjs-durable`
9206
+ * releases import it from core; `DurableModule` binds it to the same instance as the canonical token.
9184
9207
  */
9185
9208
  declare const STATE_STORE: unique symbol;
9186
9209
  /**
9187
- * @deprecated Use {@link TRANSPORT_CANONICAL} (`@dudousxd/nestjs-durable:transport`). The legacy
9188
- * token stays bound as a back-compat alias and still resolves; it will be removed in a future major.
9210
+ * @deprecated Use {@link TRANSPORT_CANONICAL}. Kept because published `@dudousxd/nestjs-durable`
9211
+ * releases import it from core; `DurableModule` binds it to the same instance as the canonical token.
9189
9212
  */
9190
9213
  declare const TRANSPORT: unique symbol;
9191
9214
  /**
9192
- * @deprecated Use {@link DURABLE_OPTIONS_CANONICAL} (`@dudousxd/nestjs-durable:options`). The legacy
9193
- * token stays bound as a back-compat alias and still resolves; it will be removed in a future major.
9215
+ * @deprecated Use {@link DURABLE_OPTIONS_CANONICAL}. Kept because published `@dudousxd/nestjs-durable`
9216
+ * releases import it from core; `DurableModule` binds it to the same instance as the canonical token.
9194
9217
  */
9195
9218
  declare const DURABLE_OPTIONS: unique symbol;
9196
- /**
9197
- * Canonical, cross-lib-discoverable aliases of the durable DI tokens, following the ecosystem
9198
- * capability naming `@dudousxd/nestjs-durable:<name>` (identical to `capability('durable', <name>)`).
9199
- * `DurableModule` binds these alongside the legacy tokens (dual-bind), so an external library can
9200
- * resolve durable's store/transport/options by the canonical name without importing durable
9201
- * internals. Bare `Symbol.for` (same cross-copy-stability rationale as the legacy tokens above)
9202
- * keeps `core` free of any `@dudousxd/nestjs-diagnostics` runtime dependency.
9203
- */
9204
- declare const STATE_STORE_CANONICAL: unique symbol;
9205
- declare const TRANSPORT_CANONICAL: unique symbol;
9206
- declare const DURABLE_OPTIONS_CANONICAL: unique symbol;
9207
9219
 
9208
9220
  /**
9209
9221
  * The OPT-IN declaration-site contract for a `@Workflow` class: `implements WorkflowHandler<TInput,
@@ -9610,4 +9622,4 @@ declare function prevRRuleFireMs(rule: ParsedRRule, atMs: number): number | null
9610
9622
  */
9611
9623
  declare function settleResultsWithPlainCalls(store: Pick<StateStore, 'getRun' | 'getCheckpoint'> & Partial<Pick<StateStore, 'getRuns' | 'getCheckpointsForSettle' | 'getCheckpoints' | 'settleCheckpointsIfPending'>>, results: StepResultSettlement[]): Promise<(StepCheckpoint | null)[]>;
9612
9624
 
9613
- export { ACCUMULATOR_SEEN_MAX, ANY_WAIT_GROUP, type AccumulatorHost, type AccumulatorStartOptions, type Admission, type AdmissionBackend, type AdmissionItem, type AllOptions, type AllSettledOptions, type AllStepsOptions, type AllStepsSettledOptions, type AnnouncedWorkflow, type AnnouncementEvidence, type AttributeFilter, type AttributeOp, type AttributePredicateOperand, type AttributeValue, type BackoffStrategy, type BlockedDispatch, type BlockedResolution, type BufferedSignalRow, CHILD_EDGE_PREFIXES, CONTROL_FLOW_SIGNAL, CORE_ORIGIN, CURRENT_PROTOCOL_VERSION, type CapabilityRequirement, type CheckpointAggregatingStore, type CheckpointNameKind, type CheckpointQuery, type CheckpointStat, type ChildCallOptions, type ChildWait, CodecStateStore, type CodecStateStoreOptions, type ConcurrencyConfig, ConcurrencyLimitError, type ConcurrencyQuota, type ConsoleCapabilities, ContinueAsNew, type ControlMessage, type ControlPlane, DEFAULT_CONCURRENCY_STATUSES, DEFAULT_PARTITION, DEFAULT_STALLED_AFTER_MS, DURABLE_OPTIONS, DURABLE_OPTIONS_CANONICAL, DURABLE_STEP_CONFIG, DURABLE_STEP_NAME, type Disagreement, type DispatchDiagnostics, type DispatchPlan, type DurableExecution, type DurableExecutionWrapper, type DurableTopology, type DurableWebhook, DurableWorkflow, type DynamicWorkflowCtx, ENGINE_MINTED_TAG_PREFIXES, ENTITY_WORKFLOW, EVENT_BUFFER_SCAN_LIMIT, EVENT_TOKEN_PREFIX, type EngineEvent, type EngineEventType, type EngineListener, type EngineTenancy, Entities, type EntityConfig, type EntityHandler, type EntityHost, type EntityWorkflowHost, EventAccumulators, type EventBatchConfig, type EventSubscription, FAN_SUMMARY_FAILURES, type FanJoin, type FanPage, type FanPageQuery, type FanSummary, type FanWait, FatalError, type FindStalledRunsOptions, GatherError, type GatherItemFailure, type GroupHealth, HANDOFF_SEQ_BASE, type Heartbeat, type HeartbeatSighting, type HeartbeatStatus, type HistoryEvent, InMemoryAdmissionBackend, InMemoryRunQueue, InMemoryStateStore, InMemoryTransport, type InferSearchAttributes, LEGACY_V1_CAPABILITIES, LEGACY_V1_PROTOCOL, LIFECYCLE_COALESCED_TAG_PREFIX, LIFECYCLE_HEAL_WINDOW_MS, LIFECYCLE_ORPHAN_MS, LIFECYCLE_OWED_TAG_PREFIX, LIFECYCLE_PENDING_TAG, LIFECYCLE_REGISTRY_HEARTBEAT_MS, LIFECYCLE_REGISTRY_STALE_MS, LIFECYCLE_REGISTRY_TAG, LIFECYCLE_REGISTRY_TTL_MS, LIFECYCLE_REGISTRY_WORKFLOW, LIFECYCLE_TRACE_TAG_PREFIX, LIFECYCLE_TRIGGERED_TAG_PREFIX, LIFECYCLE_TRIGGER_FAILED_TAG_PREFIX, type LifecycleDelivery, type LifecycleDeliveryState, type LifecycleEventOf, type LifecycleKind, type LifecycleRegistryEntry, type LifecycleSource, type LifecycleSubscriptionLink, type ListStalledRunsOptions, type MetricsCollector, type MetricsSnapshot, type NamedTransport, type NegotiateOptions, type NegotiationOutcome, type NegotiationReason, type NegotiationResult, NestedWorkflowCallError, NonDeterminismError, type OnErrorInput, type OnErrorRoute, type OnEventEntry, type OwnedLeaseReclaim, PARENT_CLOSE_TAG_PREFIX, type ParentClosePolicy, type ParsedRRule, type PartitionSighting, type PayloadCodec, type QueueConfig, QueueController, REMOTE_EVENT, RUN_HISTORY_FIXTURE_VERSION, RUN_VALUE_FACET_LIMIT, RUN_VALUE_FACET_SCAN, RUN_WAIT_TOKEN_PREFIX, type RawWorkerDescriptor, RemoteStepError, RemoteStepTimeout, type RemoteTask, RemoteWorkflowExecutor, RemoteWorkflowTimeout, type RepublishLifecycleResult, type RepublishLifecycleTarget, type RetentionPolicy, type RoutableDispatch, type RoutableResolution, type RoutingResolution, type RunAttributeRow, type RunConsumerOptions, type RunDetail, type RunDetailOptions, type RunDispatch, type RunDispatcher, type RunFacetQuery, type RunFacetRow, RunGateway, type RunListItem, type RunQuery, type RunQueueOptions, type RunReply, type RunReplyResult, type RunRequest, type RunRequestKind, type RunResult, type RunSchedulesOptions, type RunScope, type RunStatus, type RunTenant, type RunValueAxis, type RunValueFacetOptions, type RunValueFacetOrder, type RunValueFacetRow, type RunWaitLink, type RunWaiting, SINGLETON_ACTIVE_STATUSES, SINGLETON_ADMITTED_TAG, SINGLETON_LOCK_CHUNK, SINGLETON_RESERVED_TAGS, SINGLETON_TRACKED_TAG, STATE_STORE, STATE_STORE_CANONICAL, SUMMARY_CHILD_LIMIT, type ScalarAttributeFilter, ScheduleAlreadyExistsError, ScheduleClient, type ScheduleClientOptions, type ScheduleDescription, type ScheduleHost, type ScheduleListQuery, ScheduleNotFoundError, type ScheduleOptions, type ScheduleQuery, type ScheduleRecord, type ScheduledWorkflow, type SchemaIssue, type SchemaValidationCode, SchemaValidationError, type SearchAttributes, type SearchAttributesSchema, type Settled, type SignalOptions, SignalTimeoutError, type SignalWaiter, type SingletonConfig, SingletonQueueFullError, type StalePendingStep, type StalledRunInfo, StandardSchemaV1, type StartOptions, type StartRunMessage, type StateStore, type StepCheckpoint, type StepConfig, type StepDef, type StepDispatchOpts, type StepError, type StepEvent, type StepHandler, type StepInterceptor, type StepInvocation, type StepKind, type StepLogger, type StepOptions, type StepRef, type StepResult, type StepResultSettlement, type StepScope, type StepSettlement, type StepUndo, type StoreTransaction, type SubProcessHandle, TERMINAL_RUN_STATUSES, TRANSPORT, TRANSPORT_CANONICAL, type TenantEvent, type TenantFilter, type TenantRow, type TenantTokenSource, type TenantVerifier, type Transport, type UndoOf, type UpdateResult, type UpdateValidator, VERSION_UNDECLARED_TAG, type VerifiedTenant, WORKFLOW_NAME_KEY, type WaitAnyCondition, type WaitAnyOutcome, type WaitAnyResult, type WaitCondition, type WaitConditionSpec, type WaitForRunOptions, type WireDates, type WorkerAdjust, type WorkerConcurrencyStatus, type WorkerDescriptor, type WorkerHeartbeat, type WorkerLifecycle, type WorkerStatus, type WorkflowAnnouncement, WorkflowBlocked, type WorkflowClass, type WorkflowCommand, type WorkflowCtx, type WorkflowDecision, type WorkflowDirectory, WorkflowEngine, type WorkflowEngineDeps, type WorkflowExecutor, type WorkflowHandler, type WorkflowInputOf, type WorkflowLifecycleEvent, type WorkflowLifecycleLinks, WorkflowNotRegistered, type WorkflowOutputOf, type WorkflowRef, type WorkflowRegistration, type WorkflowRun, type WorkflowStartClient, type WorkflowStepEvent, WorkflowSuspended, type WorkflowTask, acceptingSubscription, accumulatorRunId, aggregateAnnouncements, aggregatesCheckpoints, announcementsOf, anyCheckpointName, applyAttributeQuery, assertConcurrency, assertRoutes, attributeColumnFor, attributeOperand, attributePredicateOperands, axisIsRunColumn, bindWorkflowClass, breakpointToken, bufferedEventReaches, buildWorkflowDirectory, canRoute, capableWorkers, carriesLifecyclePending, checkpointNameKind, checkpointStatsOf, childIdsOf, classifyWaiterToken, clearDurableExecutionWrappers, clearTerminalSingletonAdmission, coalescedSubscribersOf, codeAndDetails, codeOf, collectMetrics, concurrencyTag, controlPlaneDescriptor, countRuns, coveredTokens, createStepLogger, currentStep, currentStepScope, currentWorkflowCtx, debug, describeWorker, descriptorHash, detailsOf, error, etagMatches, eventMatchOf, eventMatches, eventNameOf, eventPrefix, eventToken, extendEtag, facetOrigin, fanPageBounds, fanPageEtag, findStalledRuns, foldedCount, getRunsByIds, handoffHandlerId, handoffName, hasDurableExecutionWrappers, heartbeatStatus, hmacTenantVerifier, indexWaitersByRun, info, inheritTenant, isAnyCheckpoint, isAnyMember, isEngineMintedTag, isEventToken, isFailedMember, isLegacyDescriptor, isLifecycleTag, isNonEmptyRunScope, isRemoteEvent, isWorkflowControlFlowSignal, legacySingletonHolders, lifecycleDeliveriesOf, lifecycleEventName, lifecycleEventOf, lifecycleKindOf, lifecycleRegistryNamespace, lifecycleRegistryRunId, lifecycleRegistrySubscriptions, lifecycleRunId, lifecycleSourceOf, lifecycleTraceparentOf, listSignalWaitersOfRuns, liveHandoff, log, markRemoteEvent, matchesAttributes, matchesTenantPredicates, mergeRunFacetRows, mergeRunValueFacetRows, missingCapabilities, negotiate, nextCronFireMs, nextRRuleFireMs, normalizeAttributeRows, normalizeDescriptor, observedAnnouncements, onErrorRunId, owedSubscribersOf, pageFan, pageFanFromStore, parentRunIdOf, parseDuration, parseLifecycleEvent, parseRRule, parseWebhookToken, partitionOfToken, planDispatch, poolNamespace, prevCronFireMs, prevRRuleFireMs, queryCheckpointsOf, readBufferedEvent, readRunsByIds, readSearchAttributes, requiredCapabilities, resolveConcurrency, resolveRouting, resolveRunWaiting, resolveTenantToken, resolveWireTenant, retentionKeeps, retiredHandoffName, routeFor, rowTenant, runCompletedEvent, runDetailEtag, runDurableExecution, runFailedEvent, runInStepLogger, runInStepScope, runInWorkflowCtx, runOutsideWorkflowCtx, runSchedules, runStepHandler, runValueFacetsFromRuns, runWaitPrefix, runWaitTargetOf, runWaitToken, sanitizeQueueToken, scheduleRunIdAt, scheduledRunId, scopeBufferedEvent, scopeTenantQuery, settleResultsWithPlainCalls, signTenantToken, singletonAdmissionDenialPatch, singletonAdmissionTags, singletonClaimantIds, sqlComparator, stepConfigOf, stepId, stepNameOf, sub, subEvent, subProcess, summarizeFan, summarizeRunFromStore, summarizeTimeline, tenantGroup, tenantIdsFor, tenantVisible, toEventSubscription, traceIdOfTraceparent, triggerFailedSubscribersOf, triggeredRunsOf, triggeredSubscribersOf, useDurableExecution, warn, withSingletonTracked, withoutSingletonMarkers, workflowName };
9625
+ export { ACCUMULATOR_SEEN_MAX, ANY_WAIT_GROUP, type AccumulatorHost, type AccumulatorStartOptions, type Admission, type AdmissionBackend, type AdmissionItem, type AllOptions, type AllSettledOptions, type AllStepsOptions, type AllStepsSettledOptions, type AnnouncedWorkflow, type AnnouncementEvidence, type AttributeFilter, type AttributeOp, type AttributePredicateOperand, type AttributeValue, type BackoffStrategy, type BlockedDispatch, type BlockedResolution, type BufferedSignalRow, CHILD_EDGE_PREFIXES, CONTROL_FLOW_SIGNAL, CORE_ORIGIN, CURRENT_PROTOCOL_VERSION, type CapabilityRequirement, type CheckpointAggregatingStore, type CheckpointNameKind, type CheckpointQuery, type CheckpointStat, type ChildCallOptions, type ChildWait, CodecStateStore, type CodecStateStoreOptions, type ConcurrencyConfig, ConcurrencyLimitError, type ConcurrencyQuota, type ConsoleCapabilities, ContinueAsNew, type ControlMessage, type ControlPlane, DEFAULT_CONCURRENCY_STATUSES, DEFAULT_PARTITION, DEFAULT_STALLED_AFTER_MS, DURABLE_OPTIONS, DURABLE_OPTIONS_CANONICAL, DURABLE_STEP_CONFIG, DURABLE_STEP_NAME, type Disagreement, type DispatchDiagnostics, type DispatchPlan, type DurableExecution, type DurableExecutionWrapper, type DurableTopology, type DurableWebhook, DurableWorkflow, type DynamicWorkflowCtx, ENGINE_MINTED_TAG_PREFIXES, ENTITY_WORKFLOW, EVENT_BUFFER_SCAN_LIMIT, EVENT_TOKEN_PREFIX, type EngineEvent, type EngineEventType, type EngineListener, type EngineTenancy, Entities, type EntityConfig, type EntityHandler, type EntityHost, type EntityWorkflowHost, EventAccumulators, type EventBatchConfig, type EventSubscription, FAN_SUMMARY_FAILURES, type FanJoin, type FanPage, type FanPageQuery, type FanSummary, type FanWait, FatalError, type FindStalledRunsOptions, GatherError, type GatherItemFailure, type GroupHealth, HANDOFF_SEQ_BASE, type Heartbeat, type HeartbeatSighting, type HeartbeatStatus, type HistoryEvent, InMemoryAdmissionBackend, InMemoryRunQueue, InMemoryStateStore, InMemoryTransport, type InferSearchAttributes, LEGACY_V1_CAPABILITIES, LEGACY_V1_PROTOCOL, LIFECYCLE_COALESCED_TAG_PREFIX, LIFECYCLE_HEAL_WINDOW_MS, LIFECYCLE_ORPHAN_MS, LIFECYCLE_OWED_TAG_PREFIX, LIFECYCLE_PENDING_TAG, LIFECYCLE_REGISTRY_HEARTBEAT_MS, LIFECYCLE_REGISTRY_STALE_MS, LIFECYCLE_REGISTRY_TAG, LIFECYCLE_REGISTRY_TTL_MS, LIFECYCLE_REGISTRY_WORKFLOW, LIFECYCLE_TRACE_TAG_PREFIX, LIFECYCLE_TRIGGERED_TAG_PREFIX, LIFECYCLE_TRIGGER_FAILED_TAG_PREFIX, type LifecycleDelivery, type LifecycleDeliveryState, type LifecycleEventOf, type LifecycleKind, type LifecycleRegistryEntry, type LifecycleSource, type LifecycleSubscriptionLink, type ListStalledRunsOptions, type MetricsCollector, type MetricsSnapshot, type NamedTransport, type NegotiateOptions, type NegotiationOutcome, type NegotiationReason, type NegotiationResult, NestedWorkflowCallError, NonDeterminismError, type OnErrorInput, type OnErrorRoute, type OnEventEntry, type OwnedLeaseReclaim, PARENT_CLOSE_TAG_PREFIX, type ParentClosePolicy, type ParsedRRule, type PartitionSighting, type PayloadCodec, type QueueConfig, QueueController, REMOTE_EVENT, RUN_HISTORY_FIXTURE_VERSION, RUN_VALUE_FACET_LIMIT, RUN_VALUE_FACET_SCAN, RUN_WAIT_TOKEN_PREFIX, type RawWorkerDescriptor, RemoteStepError, RemoteStepTimeout, type RemoteTask, RemoteWorkflowExecutor, RemoteWorkflowTimeout, type RepublishLifecycleResult, type RepublishLifecycleTarget, type RetentionPolicy, type RoutableDispatch, type RoutableResolution, type RoutingResolution, type RunAttributeRow, type RunConsumerOptions, type RunDetail, type RunDetailOptions, type RunDispatch, type RunDispatcher, type RunFacetQuery, type RunFacetRow, RunGateway, type RunListItem, type RunQuery, type RunQueueOptions, type RunReply, type RunReplyResult, type RunRequest, type RunRequestKind, type RunResult, type RunSchedulesOptions, type RunScope, type RunStatus, type RunTenant, type RunValueAxis, type RunValueFacetOptions, type RunValueFacetOrder, type RunValueFacetRow, type RunWaitLink, type RunWaiting, SINGLETON_ACTIVE_STATUSES, SINGLETON_ADMITTED_TAG, SINGLETON_LOCK_CHUNK, SINGLETON_RESERVED_TAGS, SINGLETON_TRACKED_TAG, STATE_STORE, STATE_STORE_CANONICAL, SUMMARY_CHILD_LIMIT, type ScalarAttributeFilter, ScheduleAlreadyExistsError, ScheduleClient, type ScheduleClientOptions, type ScheduleDescription, type ScheduleHost, type ScheduleListQuery, ScheduleNotFoundError, type ScheduleOptions, type ScheduleQuery, type ScheduleRecord, type ScheduledWorkflow, type SchemaIssue, type SchemaValidationCode, SchemaValidationError, type SearchAttributes, type SearchAttributesSchema, type Settled, type SignalOptions, SignalTimeoutError, type SignalWaiter, type SingletonConfig, SingletonQueueFullError, type StalePendingStep, type StalledRunInfo, StandardSchemaV1, type StartOptions, type StartRunMessage, type StateStore, type StepCheckpoint, type StepConfig, type StepDef, type StepDispatchOpts, type StepError, type StepEvent, type StepHandler, type StepInterceptor, type StepInvocation, type StepKind, type StepLogger, type StepOptions, type StepRef, type StepResult, type StepResultSettlement, type StepScope, type StepSettlement, type StepUndo, type StoreTransaction, type SubProcessHandle, TERMINAL_RUN_STATUSES, TRANSPORT, TRANSPORT_CANONICAL, type TenantEvent, type TenantFilter, type TenantRow, type TenantTokenSource, type TenantVerifier, type Transport, type UndoOf, type UpdateResult, type UpdateValidator, VERSION_UNDECLARED_TAG, type VerifiedTenant, WORKFLOW_NAME_KEY, type WaitAnyCondition, type WaitAnyOutcome, type WaitAnyResult, type WaitCondition, type WaitConditionSpec, type WaitForRunOptions, type WireDates, type WorkerAdjust, type WorkerConcurrencyStatus, type WorkerDescriptor, type WorkerHeartbeat, type WorkerLifecycle, type WorkerStatus, type WorkflowAnnouncement, WorkflowBlocked, type WorkflowClass, type WorkflowCommand, type WorkflowCtx, type WorkflowDecision, type WorkflowDirectory, WorkflowEngine, type WorkflowEngineDeps, type WorkflowExecutor, type WorkflowHandler, type WorkflowInputOf, type WorkflowLifecycleEvent, type WorkflowLifecycleLinks, WorkflowNotRegistered, type WorkflowOutputOf, type WorkflowRef, type WorkflowRegistration, type WorkflowRun, type WorkflowStartClient, type WorkflowStepEvent, WorkflowSuspended, type WorkflowTask, acceptingSubscription, accumulatorRunId, aggregateAnnouncements, aggregatesCheckpoints, announcementsOf, anyCheckpointName, applyAttributeQuery, assertConcurrency, assertRoutes, attributeColumnFor, attributeOperand, attributePredicateOperands, axisIsRunColumn, bindWorkflowClass, breakpointToken, bufferedEventReaches, buildWorkflowDirectory, canRoute, capableWorkers, carriesLifecyclePending, checkpointNameKind, checkpointStatsOf, childIdsOf, classifyWaiterToken, clearDurableExecutionWrappers, clearTerminalSingletonAdmission, coalescedSubscribersOf, codeAndDetails, codeOf, collectMetrics, concurrencyTag, controlPlaneDescriptor, countRuns, coveredTokens, createStepLogger, currentStep, currentStepScope, currentWorkflowCtx, debug, describeWorker, descriptorHash, detailsOf, error, etagMatches, eventMatchOf, eventMatches, eventNameOf, eventPrefix, eventToken, extendEtag, facetOrigin, fanPageBounds, fanPageEtag, findStalledRuns, foldedCount, getRunsByIds, grantsClientTenant, handoffHandlerId, handoffName, hasDurableExecutionWrappers, heartbeatStatus, hmacTenantVerifier, indexWaitersByRun, info, inheritTenant, isAnyCheckpoint, isAnyMember, isEngineMintedTag, isEventToken, isFailedMember, isLegacyDescriptor, isLifecycleTag, isNonEmptyRunScope, isRemoteEvent, isWorkflowControlFlowSignal, legacySingletonHolders, lifecycleDeliveriesOf, lifecycleEventName, lifecycleEventOf, lifecycleKindOf, lifecycleRegistryNamespace, lifecycleRegistryRunId, lifecycleRegistrySubscriptions, lifecycleRunId, lifecycleSourceOf, lifecycleTraceparentOf, listSignalWaitersOfRuns, liveHandoff, log, markRemoteEvent, matchesAttributes, matchesTenantPredicates, mergeRunFacetRows, mergeRunValueFacetRows, missingCapabilities, negotiate, nextCronFireMs, nextRRuleFireMs, normalizeAttributeRows, normalizeDescriptor, observedAnnouncements, onErrorRunId, owedSubscribersOf, pageFan, pageFanFromStore, parentRunIdOf, parseDuration, parseLifecycleEvent, parseRRule, parseWebhookToken, partitionOfToken, planDispatch, poolNamespace, prevCronFireMs, prevRRuleFireMs, queryCheckpointsOf, readBufferedEvent, readRunsByIds, readSearchAttributes, requiredCapabilities, resolveConcurrency, resolveRouting, resolveRunWaiting, resolveTenantToken, resolveWireTenant, retentionKeeps, retiredHandoffName, routeFor, rowTenant, runCompletedEvent, runDetailEtag, runDurableExecution, runFailedEvent, runInStepLogger, runInStepScope, runInWorkflowCtx, runOutsideWorkflowCtx, runSchedules, runStepHandler, runValueFacetsFromRuns, runWaitPrefix, runWaitTargetOf, runWaitToken, sanitizeQueueToken, scheduleRunIdAt, scheduledRunId, scopeBufferedEvent, scopeTenantQuery, settleResultsWithPlainCalls, signTenantToken, singletonAdmissionDenialPatch, singletonAdmissionTags, singletonClaimantIds, sqlComparator, stepConfigOf, stepId, stepNameOf, sub, subEvent, subProcess, summarizeFan, summarizeRunFromStore, summarizeTimeline, tenantGroup, tenantIdsFor, tenantVisible, toEventSubscription, traceIdOfTraceparent, triggerFailedSubscribersOf, triggeredRunsOf, triggeredSubscribersOf, useDurableExecution, verifyWireTenant, warn, withSingletonTracked, withoutSingletonMarkers, workflowName };
package/dist/index.d.ts CHANGED
@@ -1244,7 +1244,7 @@ declare namespace StandardSchemaV1 {
1244
1244
  * (pnpm peer-dependency multiplexing, or a dual ESM/CJS load) still reads the SAME key. A plain
1245
1245
  * `Symbol()` would mint a distinct token per copy, so a decorator running against one core instance
1246
1246
  * could stamp a name core's `ctx.step` (a different instance) can never read back. Mirrors the
1247
- * `STATE_STORE` token fix in `./tokens.ts`.
1247
+ * DI token fix in `./tokens.ts`.
1248
1248
  */
1249
1249
  declare const DURABLE_STEP_NAME: unique symbol;
1250
1250
  /**
@@ -2671,6 +2671,14 @@ interface StartRunMessage {
2671
2671
  tags?: string[] | undefined;
2672
2672
  /** Typed, queryable run data to stamp on the run (same as {@link StartOptions.searchAttributes}). */
2673
2673
  searchAttributes?: SearchAttributes | undefined;
2674
+ /**
2675
+ * The customer (data tenant) the run belongs to, as the tenant process sees it. Only a claim: the
2676
+ * control plane keeps it when the process's verified token grants `tenancy:*` or
2677
+ * `tenancy:<tenantId>` in its `capabilities`, else the run gets no customer tenant.
2678
+ */
2679
+ tenantId?: string | undefined;
2680
+ /** The kind of {@link tenantId} (`organization`, `clinic`, …). */
2681
+ tenantKind?: string | undefined;
2674
2682
  }
2675
2683
  /**
2676
2684
  * A tenant worker → control plane read/control request over the shared transport. Enqueued on
@@ -4137,13 +4145,6 @@ declare function countRuns(store: StateStore, query: Omit<RunQuery, 'limit' | 'o
4137
4145
  */
4138
4146
  declare function assertConcurrency(store: StateStore, workflow: string, quota: ConcurrencyQuota): Promise<void>;
4139
4147
 
4140
- /**
4141
- * Back-compat alias of {@link WorkflowCtx}. `localStep` — the checkpointed in-process step primitive
4142
- * used for saga compensation — is now part of the public {@link WorkflowCtx}, so this type adds
4143
- * nothing; it is kept only so internal consumers (the durable-entity runner) keep compiling.
4144
- */
4145
- type InternalWorkflowCtx = WorkflowCtx;
4146
-
4147
4148
  /** One operation on a durable entity: mutate `state` in place and/or return a result. */
4148
4149
  type EntityHandler<S = unknown> = (state: S, arg: unknown) => unknown | Promise<unknown>;
4149
4150
  /** A durable keyed entity (a virtual object): per-key serialized handlers over durable state. */
@@ -4155,7 +4156,7 @@ interface EntityConfig<S = unknown> {
4155
4156
  }
4156
4157
  /** The slice of the engine the entity subsystem needs (so it stays a standalone module). */
4157
4158
  interface EntityHost {
4158
- register(name: string, version: string, fn: (ctx: InternalWorkflowCtx, input: unknown) => Promise<unknown>, opts?: {
4159
+ register(name: string, version: string, fn: (ctx: WorkflowCtx, input: unknown) => Promise<unknown>, opts?: {
4159
4160
  origin?: string | undefined;
4160
4161
  }): void;
4161
4162
  signalWithStart(workflow: string, input: unknown, runId: string, signal: {
@@ -4269,6 +4270,12 @@ interface EngineTenancy {
4269
4270
  filter(): TenantFilter;
4270
4271
  /** Run `fn` with `tenant` restored as the ambient context tenant. */
4271
4272
  run<T>(tenant: RunTenant, fn: () => T): T;
4273
+ /**
4274
+ * Run `fn` as durable's own work (a workflow turn, a recovery, a worker's step), where no request
4275
+ * asks for a tenant: a host whose tenancy requires one (`required: true`) must not reject a
4276
+ * missing tenant inside it. Optional: without it, `fn` runs as is.
4277
+ */
4278
+ system?<T>(fn: () => T): T;
4272
4279
  }
4273
4280
  /** A row that may carry a tenant (a run, a schedule). */
4274
4281
  interface TenantRow {
@@ -5222,9 +5229,10 @@ interface VerifiedTenant {
5222
5229
  /** The tenant the token authenticates as. The responder trusts THIS, never the request body. */
5223
5230
  tenant: string;
5224
5231
  /**
5225
- * Capabilities the token grants, if the issuer scopes them. Carried for custom verifiers and for
5226
- * wire parity with Agora; the built-in responder does NOT enforce them yet. A verified tenant can
5227
- * call every verb, scoped to its own namespace.
5232
+ * Capabilities the token grants, if the issuer scopes them. `tenancy:*` or `tenancy:<id>` lets the
5233
+ * process claim that customer tenant for the runs it starts (see `StartRunMessage.tenantId`). The
5234
+ * run-request responder does not enforce them: a verified tenant can call every verb, scoped to
5235
+ * its own namespace.
5228
5236
  */
5229
5237
  capabilities?: string[] | undefined;
5230
5238
  }
@@ -5274,6 +5282,17 @@ declare function signTenantToken(tenant: string, secret: string, opts?: {
5274
5282
  * responder does not enforce it yet, see {@link VerifiedTenant.capabilities}).
5275
5283
  */
5276
5284
  declare function hmacTenantVerifier(secret: string | string[], capabilities?: string[]): TenantVerifier;
5285
+ /**
5286
+ * Verify a wire message's `tenant`: with a verifier, the {@link VerifiedTenant} it derives (`null` on
5287
+ * reject); without one, the wire value trusted verbatim, with no capabilities.
5288
+ */
5289
+ declare function verifyWireTenant(wireTenant: string, verifyTenant: TenantVerifier | undefined): Promise<VerifiedTenant | null>;
5290
+ /**
5291
+ * Whether a verified tenant process may claim the customer `tenantId` for a run it starts: its
5292
+ * `capabilities` hold `tenancy:*` (any customer) or `tenancy:<tenantId>`. An unverified process (no
5293
+ * verifier) holds none, so it never may.
5294
+ */
5295
+ declare function grantsClientTenant(verified: VerifiedTenant | null, tenantId: string): boolean;
5277
5296
  /**
5278
5297
  * Resolve the tenant a wire message is ALLOWED to act as. With a verifier, the wire `tenant` is the
5279
5298
  * signed token: it is verified and the real tenant derived from it (`null` on reject). Without one,
@@ -5283,7 +5302,7 @@ declare function resolveWireTenant(wireTenant: string, verifyTenant: TenantVerif
5283
5302
  /** Resolve a {@link TenantTokenSource} to the token string to put on the wire. */
5284
5303
  declare function resolveTenantToken(source: TenantTokenSource): Promise<string>;
5285
5304
 
5286
- type WorkflowFn = (ctx: InternalWorkflowCtx, input: unknown) => Promise<unknown>;
5305
+ type WorkflowFn = (ctx: WorkflowCtx, input: unknown) => Promise<unknown>;
5287
5306
  /**
5288
5307
  * Options for {@link WorkflowEngine.start}.
5289
5308
  *
@@ -5583,7 +5602,7 @@ interface WorkflowEngineDeps {
5583
5602
  */
5584
5603
  context?: (() => Record<string, unknown> | undefined) | undefined;
5585
5604
  /**
5586
- * Re-hydrate the originating context around a LOCAL step body, so a `@DurableStep` reader sees the
5605
+ * Re-hydrate the originating context around a LOCAL step body, so a `@Step` reader sees the
5587
5606
  * tenant / user / correlation ids that were live when the run was started — even on a path the
5588
5607
  * engine drives outside the originating request scope (a resume after crash/scale-down, a timer).
5589
5608
  * Given the carrier produced by {@link context} (may be empty/undefined) and the step body `fn`, it
@@ -7306,7 +7325,7 @@ declare class WorkflowEngine {
7306
7325
  /** {@link getRunChildren} without the tenancy check (the engine's own subtree walks). */
7307
7326
  private runChildrenUnchecked;
7308
7327
  /** The worker groups this engine dispatches to: every registered remote workflow's group, plus any
7309
- * `extra` the caller declares. Local-step groups (a group consumed by in-process `@DurableStep`
7328
+ * `extra` the caller declares. Local-step groups (a group consumed by in-process `@Step`
7310
7329
  * workers, e.g. `pipeline`) aren't derivable from registrations — pass them via `extra` so a group
7311
7330
  * with backlog and ZERO workers is still reported (the alert case has no heartbeat to discover). */
7312
7331
  knownGroups(extra?: string[]): string[];
@@ -8999,11 +9018,6 @@ interface ScheduledWorkflow<W extends WorkflowRef = WorkflowRef> {
8999
9018
  * `Math.random`; overridden in tests so jitter is deterministic. */
9000
9019
  interface RunSchedulesOptions {
9001
9020
  random?: () => number;
9002
- /**
9003
- * @deprecated No longer called: jitter defers a window to a later tick instead of sleeping inside
9004
- * this one. Kept so existing callers still type-check.
9005
- */
9006
- sleep?: (ms: number) => Promise<void>;
9007
9021
  }
9008
9022
  /** Deterministic run id for a fixed-interval schedule's current time window. */
9009
9023
  declare function scheduledRunId(key: string, everyMs: number, nowMs: number): string;
@@ -9175,35 +9189,33 @@ declare function sanitizeQueueToken(name: string): string;
9175
9189
  * `import` (`index.js`) and once as `require` (`index.cjs`). A plain `Symbol()` would mint a
9176
9190
  * DISTINCT token per copy, so `DurableModule` (provider) and `DashboardService` / a store adapter
9177
9191
  * (injector) could resolve different symbols → Nest can't satisfy the dependency
9178
- * (`STATE_STORE is not available in the DurableApiModule context`). A registered symbol collapses
9192
+ * (`<token> is not available in the DurableApiModule context`). A registered symbol collapses
9179
9193
  * them to one. Mirrors the `CONTEXT_ACCESSOR` token in `@dudousxd/nestjs-durable`'s `tokens.ts`.
9180
9194
  */
9181
9195
  /**
9182
- * @deprecated Use {@link STATE_STORE_CANONICAL} (`@dudousxd/nestjs-durable:state-store`). The legacy
9183
- * token stays bound as a back-compat alias and still resolves; it will be removed in a future major.
9196
+ * The durable DI tokens, following the ecosystem capability naming `@dudousxd/nestjs-durable:<name>`
9197
+ * (identical to `capability('durable', <name>)`), so an external library can resolve durable's
9198
+ * store/transport/options by name without importing durable internals. Bare `Symbol.for` keeps
9199
+ * `core` free of any `@dudousxd/nestjs-diagnostics` runtime dependency.
9200
+ */
9201
+ declare const STATE_STORE_CANONICAL: unique symbol;
9202
+ declare const TRANSPORT_CANONICAL: unique symbol;
9203
+ declare const DURABLE_OPTIONS_CANONICAL: unique symbol;
9204
+ /**
9205
+ * @deprecated Use {@link STATE_STORE_CANONICAL}. Kept because published `@dudousxd/nestjs-durable`
9206
+ * releases import it from core; `DurableModule` binds it to the same instance as the canonical token.
9184
9207
  */
9185
9208
  declare const STATE_STORE: unique symbol;
9186
9209
  /**
9187
- * @deprecated Use {@link TRANSPORT_CANONICAL} (`@dudousxd/nestjs-durable:transport`). The legacy
9188
- * token stays bound as a back-compat alias and still resolves; it will be removed in a future major.
9210
+ * @deprecated Use {@link TRANSPORT_CANONICAL}. Kept because published `@dudousxd/nestjs-durable`
9211
+ * releases import it from core; `DurableModule` binds it to the same instance as the canonical token.
9189
9212
  */
9190
9213
  declare const TRANSPORT: unique symbol;
9191
9214
  /**
9192
- * @deprecated Use {@link DURABLE_OPTIONS_CANONICAL} (`@dudousxd/nestjs-durable:options`). The legacy
9193
- * token stays bound as a back-compat alias and still resolves; it will be removed in a future major.
9215
+ * @deprecated Use {@link DURABLE_OPTIONS_CANONICAL}. Kept because published `@dudousxd/nestjs-durable`
9216
+ * releases import it from core; `DurableModule` binds it to the same instance as the canonical token.
9194
9217
  */
9195
9218
  declare const DURABLE_OPTIONS: unique symbol;
9196
- /**
9197
- * Canonical, cross-lib-discoverable aliases of the durable DI tokens, following the ecosystem
9198
- * capability naming `@dudousxd/nestjs-durable:<name>` (identical to `capability('durable', <name>)`).
9199
- * `DurableModule` binds these alongside the legacy tokens (dual-bind), so an external library can
9200
- * resolve durable's store/transport/options by the canonical name without importing durable
9201
- * internals. Bare `Symbol.for` (same cross-copy-stability rationale as the legacy tokens above)
9202
- * keeps `core` free of any `@dudousxd/nestjs-diagnostics` runtime dependency.
9203
- */
9204
- declare const STATE_STORE_CANONICAL: unique symbol;
9205
- declare const TRANSPORT_CANONICAL: unique symbol;
9206
- declare const DURABLE_OPTIONS_CANONICAL: unique symbol;
9207
9219
 
9208
9220
  /**
9209
9221
  * The OPT-IN declaration-site contract for a `@Workflow` class: `implements WorkflowHandler<TInput,
@@ -9610,4 +9622,4 @@ declare function prevRRuleFireMs(rule: ParsedRRule, atMs: number): number | null
9610
9622
  */
9611
9623
  declare function settleResultsWithPlainCalls(store: Pick<StateStore, 'getRun' | 'getCheckpoint'> & Partial<Pick<StateStore, 'getRuns' | 'getCheckpointsForSettle' | 'getCheckpoints' | 'settleCheckpointsIfPending'>>, results: StepResultSettlement[]): Promise<(StepCheckpoint | null)[]>;
9612
9624
 
9613
- export { ACCUMULATOR_SEEN_MAX, ANY_WAIT_GROUP, type AccumulatorHost, type AccumulatorStartOptions, type Admission, type AdmissionBackend, type AdmissionItem, type AllOptions, type AllSettledOptions, type AllStepsOptions, type AllStepsSettledOptions, type AnnouncedWorkflow, type AnnouncementEvidence, type AttributeFilter, type AttributeOp, type AttributePredicateOperand, type AttributeValue, type BackoffStrategy, type BlockedDispatch, type BlockedResolution, type BufferedSignalRow, CHILD_EDGE_PREFIXES, CONTROL_FLOW_SIGNAL, CORE_ORIGIN, CURRENT_PROTOCOL_VERSION, type CapabilityRequirement, type CheckpointAggregatingStore, type CheckpointNameKind, type CheckpointQuery, type CheckpointStat, type ChildCallOptions, type ChildWait, CodecStateStore, type CodecStateStoreOptions, type ConcurrencyConfig, ConcurrencyLimitError, type ConcurrencyQuota, type ConsoleCapabilities, ContinueAsNew, type ControlMessage, type ControlPlane, DEFAULT_CONCURRENCY_STATUSES, DEFAULT_PARTITION, DEFAULT_STALLED_AFTER_MS, DURABLE_OPTIONS, DURABLE_OPTIONS_CANONICAL, DURABLE_STEP_CONFIG, DURABLE_STEP_NAME, type Disagreement, type DispatchDiagnostics, type DispatchPlan, type DurableExecution, type DurableExecutionWrapper, type DurableTopology, type DurableWebhook, DurableWorkflow, type DynamicWorkflowCtx, ENGINE_MINTED_TAG_PREFIXES, ENTITY_WORKFLOW, EVENT_BUFFER_SCAN_LIMIT, EVENT_TOKEN_PREFIX, type EngineEvent, type EngineEventType, type EngineListener, type EngineTenancy, Entities, type EntityConfig, type EntityHandler, type EntityHost, type EntityWorkflowHost, EventAccumulators, type EventBatchConfig, type EventSubscription, FAN_SUMMARY_FAILURES, type FanJoin, type FanPage, type FanPageQuery, type FanSummary, type FanWait, FatalError, type FindStalledRunsOptions, GatherError, type GatherItemFailure, type GroupHealth, HANDOFF_SEQ_BASE, type Heartbeat, type HeartbeatSighting, type HeartbeatStatus, type HistoryEvent, InMemoryAdmissionBackend, InMemoryRunQueue, InMemoryStateStore, InMemoryTransport, type InferSearchAttributes, LEGACY_V1_CAPABILITIES, LEGACY_V1_PROTOCOL, LIFECYCLE_COALESCED_TAG_PREFIX, LIFECYCLE_HEAL_WINDOW_MS, LIFECYCLE_ORPHAN_MS, LIFECYCLE_OWED_TAG_PREFIX, LIFECYCLE_PENDING_TAG, LIFECYCLE_REGISTRY_HEARTBEAT_MS, LIFECYCLE_REGISTRY_STALE_MS, LIFECYCLE_REGISTRY_TAG, LIFECYCLE_REGISTRY_TTL_MS, LIFECYCLE_REGISTRY_WORKFLOW, LIFECYCLE_TRACE_TAG_PREFIX, LIFECYCLE_TRIGGERED_TAG_PREFIX, LIFECYCLE_TRIGGER_FAILED_TAG_PREFIX, type LifecycleDelivery, type LifecycleDeliveryState, type LifecycleEventOf, type LifecycleKind, type LifecycleRegistryEntry, type LifecycleSource, type LifecycleSubscriptionLink, type ListStalledRunsOptions, type MetricsCollector, type MetricsSnapshot, type NamedTransport, type NegotiateOptions, type NegotiationOutcome, type NegotiationReason, type NegotiationResult, NestedWorkflowCallError, NonDeterminismError, type OnErrorInput, type OnErrorRoute, type OnEventEntry, type OwnedLeaseReclaim, PARENT_CLOSE_TAG_PREFIX, type ParentClosePolicy, type ParsedRRule, type PartitionSighting, type PayloadCodec, type QueueConfig, QueueController, REMOTE_EVENT, RUN_HISTORY_FIXTURE_VERSION, RUN_VALUE_FACET_LIMIT, RUN_VALUE_FACET_SCAN, RUN_WAIT_TOKEN_PREFIX, type RawWorkerDescriptor, RemoteStepError, RemoteStepTimeout, type RemoteTask, RemoteWorkflowExecutor, RemoteWorkflowTimeout, type RepublishLifecycleResult, type RepublishLifecycleTarget, type RetentionPolicy, type RoutableDispatch, type RoutableResolution, type RoutingResolution, type RunAttributeRow, type RunConsumerOptions, type RunDetail, type RunDetailOptions, type RunDispatch, type RunDispatcher, type RunFacetQuery, type RunFacetRow, RunGateway, type RunListItem, type RunQuery, type RunQueueOptions, type RunReply, type RunReplyResult, type RunRequest, type RunRequestKind, type RunResult, type RunSchedulesOptions, type RunScope, type RunStatus, type RunTenant, type RunValueAxis, type RunValueFacetOptions, type RunValueFacetOrder, type RunValueFacetRow, type RunWaitLink, type RunWaiting, SINGLETON_ACTIVE_STATUSES, SINGLETON_ADMITTED_TAG, SINGLETON_LOCK_CHUNK, SINGLETON_RESERVED_TAGS, SINGLETON_TRACKED_TAG, STATE_STORE, STATE_STORE_CANONICAL, SUMMARY_CHILD_LIMIT, type ScalarAttributeFilter, ScheduleAlreadyExistsError, ScheduleClient, type ScheduleClientOptions, type ScheduleDescription, type ScheduleHost, type ScheduleListQuery, ScheduleNotFoundError, type ScheduleOptions, type ScheduleQuery, type ScheduleRecord, type ScheduledWorkflow, type SchemaIssue, type SchemaValidationCode, SchemaValidationError, type SearchAttributes, type SearchAttributesSchema, type Settled, type SignalOptions, SignalTimeoutError, type SignalWaiter, type SingletonConfig, SingletonQueueFullError, type StalePendingStep, type StalledRunInfo, StandardSchemaV1, type StartOptions, type StartRunMessage, type StateStore, type StepCheckpoint, type StepConfig, type StepDef, type StepDispatchOpts, type StepError, type StepEvent, type StepHandler, type StepInterceptor, type StepInvocation, type StepKind, type StepLogger, type StepOptions, type StepRef, type StepResult, type StepResultSettlement, type StepScope, type StepSettlement, type StepUndo, type StoreTransaction, type SubProcessHandle, TERMINAL_RUN_STATUSES, TRANSPORT, TRANSPORT_CANONICAL, type TenantEvent, type TenantFilter, type TenantRow, type TenantTokenSource, type TenantVerifier, type Transport, type UndoOf, type UpdateResult, type UpdateValidator, VERSION_UNDECLARED_TAG, type VerifiedTenant, WORKFLOW_NAME_KEY, type WaitAnyCondition, type WaitAnyOutcome, type WaitAnyResult, type WaitCondition, type WaitConditionSpec, type WaitForRunOptions, type WireDates, type WorkerAdjust, type WorkerConcurrencyStatus, type WorkerDescriptor, type WorkerHeartbeat, type WorkerLifecycle, type WorkerStatus, type WorkflowAnnouncement, WorkflowBlocked, type WorkflowClass, type WorkflowCommand, type WorkflowCtx, type WorkflowDecision, type WorkflowDirectory, WorkflowEngine, type WorkflowEngineDeps, type WorkflowExecutor, type WorkflowHandler, type WorkflowInputOf, type WorkflowLifecycleEvent, type WorkflowLifecycleLinks, WorkflowNotRegistered, type WorkflowOutputOf, type WorkflowRef, type WorkflowRegistration, type WorkflowRun, type WorkflowStartClient, type WorkflowStepEvent, WorkflowSuspended, type WorkflowTask, acceptingSubscription, accumulatorRunId, aggregateAnnouncements, aggregatesCheckpoints, announcementsOf, anyCheckpointName, applyAttributeQuery, assertConcurrency, assertRoutes, attributeColumnFor, attributeOperand, attributePredicateOperands, axisIsRunColumn, bindWorkflowClass, breakpointToken, bufferedEventReaches, buildWorkflowDirectory, canRoute, capableWorkers, carriesLifecyclePending, checkpointNameKind, checkpointStatsOf, childIdsOf, classifyWaiterToken, clearDurableExecutionWrappers, clearTerminalSingletonAdmission, coalescedSubscribersOf, codeAndDetails, codeOf, collectMetrics, concurrencyTag, controlPlaneDescriptor, countRuns, coveredTokens, createStepLogger, currentStep, currentStepScope, currentWorkflowCtx, debug, describeWorker, descriptorHash, detailsOf, error, etagMatches, eventMatchOf, eventMatches, eventNameOf, eventPrefix, eventToken, extendEtag, facetOrigin, fanPageBounds, fanPageEtag, findStalledRuns, foldedCount, getRunsByIds, handoffHandlerId, handoffName, hasDurableExecutionWrappers, heartbeatStatus, hmacTenantVerifier, indexWaitersByRun, info, inheritTenant, isAnyCheckpoint, isAnyMember, isEngineMintedTag, isEventToken, isFailedMember, isLegacyDescriptor, isLifecycleTag, isNonEmptyRunScope, isRemoteEvent, isWorkflowControlFlowSignal, legacySingletonHolders, lifecycleDeliveriesOf, lifecycleEventName, lifecycleEventOf, lifecycleKindOf, lifecycleRegistryNamespace, lifecycleRegistryRunId, lifecycleRegistrySubscriptions, lifecycleRunId, lifecycleSourceOf, lifecycleTraceparentOf, listSignalWaitersOfRuns, liveHandoff, log, markRemoteEvent, matchesAttributes, matchesTenantPredicates, mergeRunFacetRows, mergeRunValueFacetRows, missingCapabilities, negotiate, nextCronFireMs, nextRRuleFireMs, normalizeAttributeRows, normalizeDescriptor, observedAnnouncements, onErrorRunId, owedSubscribersOf, pageFan, pageFanFromStore, parentRunIdOf, parseDuration, parseLifecycleEvent, parseRRule, parseWebhookToken, partitionOfToken, planDispatch, poolNamespace, prevCronFireMs, prevRRuleFireMs, queryCheckpointsOf, readBufferedEvent, readRunsByIds, readSearchAttributes, requiredCapabilities, resolveConcurrency, resolveRouting, resolveRunWaiting, resolveTenantToken, resolveWireTenant, retentionKeeps, retiredHandoffName, routeFor, rowTenant, runCompletedEvent, runDetailEtag, runDurableExecution, runFailedEvent, runInStepLogger, runInStepScope, runInWorkflowCtx, runOutsideWorkflowCtx, runSchedules, runStepHandler, runValueFacetsFromRuns, runWaitPrefix, runWaitTargetOf, runWaitToken, sanitizeQueueToken, scheduleRunIdAt, scheduledRunId, scopeBufferedEvent, scopeTenantQuery, settleResultsWithPlainCalls, signTenantToken, singletonAdmissionDenialPatch, singletonAdmissionTags, singletonClaimantIds, sqlComparator, stepConfigOf, stepId, stepNameOf, sub, subEvent, subProcess, summarizeFan, summarizeRunFromStore, summarizeTimeline, tenantGroup, tenantIdsFor, tenantVisible, toEventSubscription, traceIdOfTraceparent, triggerFailedSubscribersOf, triggeredRunsOf, triggeredSubscribersOf, useDurableExecution, warn, withSingletonTracked, withoutSingletonMarkers, workflowName };
9625
+ export { ACCUMULATOR_SEEN_MAX, ANY_WAIT_GROUP, type AccumulatorHost, type AccumulatorStartOptions, type Admission, type AdmissionBackend, type AdmissionItem, type AllOptions, type AllSettledOptions, type AllStepsOptions, type AllStepsSettledOptions, type AnnouncedWorkflow, type AnnouncementEvidence, type AttributeFilter, type AttributeOp, type AttributePredicateOperand, type AttributeValue, type BackoffStrategy, type BlockedDispatch, type BlockedResolution, type BufferedSignalRow, CHILD_EDGE_PREFIXES, CONTROL_FLOW_SIGNAL, CORE_ORIGIN, CURRENT_PROTOCOL_VERSION, type CapabilityRequirement, type CheckpointAggregatingStore, type CheckpointNameKind, type CheckpointQuery, type CheckpointStat, type ChildCallOptions, type ChildWait, CodecStateStore, type CodecStateStoreOptions, type ConcurrencyConfig, ConcurrencyLimitError, type ConcurrencyQuota, type ConsoleCapabilities, ContinueAsNew, type ControlMessage, type ControlPlane, DEFAULT_CONCURRENCY_STATUSES, DEFAULT_PARTITION, DEFAULT_STALLED_AFTER_MS, DURABLE_OPTIONS, DURABLE_OPTIONS_CANONICAL, DURABLE_STEP_CONFIG, DURABLE_STEP_NAME, type Disagreement, type DispatchDiagnostics, type DispatchPlan, type DurableExecution, type DurableExecutionWrapper, type DurableTopology, type DurableWebhook, DurableWorkflow, type DynamicWorkflowCtx, ENGINE_MINTED_TAG_PREFIXES, ENTITY_WORKFLOW, EVENT_BUFFER_SCAN_LIMIT, EVENT_TOKEN_PREFIX, type EngineEvent, type EngineEventType, type EngineListener, type EngineTenancy, Entities, type EntityConfig, type EntityHandler, type EntityHost, type EntityWorkflowHost, EventAccumulators, type EventBatchConfig, type EventSubscription, FAN_SUMMARY_FAILURES, type FanJoin, type FanPage, type FanPageQuery, type FanSummary, type FanWait, FatalError, type FindStalledRunsOptions, GatherError, type GatherItemFailure, type GroupHealth, HANDOFF_SEQ_BASE, type Heartbeat, type HeartbeatSighting, type HeartbeatStatus, type HistoryEvent, InMemoryAdmissionBackend, InMemoryRunQueue, InMemoryStateStore, InMemoryTransport, type InferSearchAttributes, LEGACY_V1_CAPABILITIES, LEGACY_V1_PROTOCOL, LIFECYCLE_COALESCED_TAG_PREFIX, LIFECYCLE_HEAL_WINDOW_MS, LIFECYCLE_ORPHAN_MS, LIFECYCLE_OWED_TAG_PREFIX, LIFECYCLE_PENDING_TAG, LIFECYCLE_REGISTRY_HEARTBEAT_MS, LIFECYCLE_REGISTRY_STALE_MS, LIFECYCLE_REGISTRY_TAG, LIFECYCLE_REGISTRY_TTL_MS, LIFECYCLE_REGISTRY_WORKFLOW, LIFECYCLE_TRACE_TAG_PREFIX, LIFECYCLE_TRIGGERED_TAG_PREFIX, LIFECYCLE_TRIGGER_FAILED_TAG_PREFIX, type LifecycleDelivery, type LifecycleDeliveryState, type LifecycleEventOf, type LifecycleKind, type LifecycleRegistryEntry, type LifecycleSource, type LifecycleSubscriptionLink, type ListStalledRunsOptions, type MetricsCollector, type MetricsSnapshot, type NamedTransport, type NegotiateOptions, type NegotiationOutcome, type NegotiationReason, type NegotiationResult, NestedWorkflowCallError, NonDeterminismError, type OnErrorInput, type OnErrorRoute, type OnEventEntry, type OwnedLeaseReclaim, PARENT_CLOSE_TAG_PREFIX, type ParentClosePolicy, type ParsedRRule, type PartitionSighting, type PayloadCodec, type QueueConfig, QueueController, REMOTE_EVENT, RUN_HISTORY_FIXTURE_VERSION, RUN_VALUE_FACET_LIMIT, RUN_VALUE_FACET_SCAN, RUN_WAIT_TOKEN_PREFIX, type RawWorkerDescriptor, RemoteStepError, RemoteStepTimeout, type RemoteTask, RemoteWorkflowExecutor, RemoteWorkflowTimeout, type RepublishLifecycleResult, type RepublishLifecycleTarget, type RetentionPolicy, type RoutableDispatch, type RoutableResolution, type RoutingResolution, type RunAttributeRow, type RunConsumerOptions, type RunDetail, type RunDetailOptions, type RunDispatch, type RunDispatcher, type RunFacetQuery, type RunFacetRow, RunGateway, type RunListItem, type RunQuery, type RunQueueOptions, type RunReply, type RunReplyResult, type RunRequest, type RunRequestKind, type RunResult, type RunSchedulesOptions, type RunScope, type RunStatus, type RunTenant, type RunValueAxis, type RunValueFacetOptions, type RunValueFacetOrder, type RunValueFacetRow, type RunWaitLink, type RunWaiting, SINGLETON_ACTIVE_STATUSES, SINGLETON_ADMITTED_TAG, SINGLETON_LOCK_CHUNK, SINGLETON_RESERVED_TAGS, SINGLETON_TRACKED_TAG, STATE_STORE, STATE_STORE_CANONICAL, SUMMARY_CHILD_LIMIT, type ScalarAttributeFilter, ScheduleAlreadyExistsError, ScheduleClient, type ScheduleClientOptions, type ScheduleDescription, type ScheduleHost, type ScheduleListQuery, ScheduleNotFoundError, type ScheduleOptions, type ScheduleQuery, type ScheduleRecord, type ScheduledWorkflow, type SchemaIssue, type SchemaValidationCode, SchemaValidationError, type SearchAttributes, type SearchAttributesSchema, type Settled, type SignalOptions, SignalTimeoutError, type SignalWaiter, type SingletonConfig, SingletonQueueFullError, type StalePendingStep, type StalledRunInfo, StandardSchemaV1, type StartOptions, type StartRunMessage, type StateStore, type StepCheckpoint, type StepConfig, type StepDef, type StepDispatchOpts, type StepError, type StepEvent, type StepHandler, type StepInterceptor, type StepInvocation, type StepKind, type StepLogger, type StepOptions, type StepRef, type StepResult, type StepResultSettlement, type StepScope, type StepSettlement, type StepUndo, type StoreTransaction, type SubProcessHandle, TERMINAL_RUN_STATUSES, TRANSPORT, TRANSPORT_CANONICAL, type TenantEvent, type TenantFilter, type TenantRow, type TenantTokenSource, type TenantVerifier, type Transport, type UndoOf, type UpdateResult, type UpdateValidator, VERSION_UNDECLARED_TAG, type VerifiedTenant, WORKFLOW_NAME_KEY, type WaitAnyCondition, type WaitAnyOutcome, type WaitAnyResult, type WaitCondition, type WaitConditionSpec, type WaitForRunOptions, type WireDates, type WorkerAdjust, type WorkerConcurrencyStatus, type WorkerDescriptor, type WorkerHeartbeat, type WorkerLifecycle, type WorkerStatus, type WorkflowAnnouncement, WorkflowBlocked, type WorkflowClass, type WorkflowCommand, type WorkflowCtx, type WorkflowDecision, type WorkflowDirectory, WorkflowEngine, type WorkflowEngineDeps, type WorkflowExecutor, type WorkflowHandler, type WorkflowInputOf, type WorkflowLifecycleEvent, type WorkflowLifecycleLinks, WorkflowNotRegistered, type WorkflowOutputOf, type WorkflowRef, type WorkflowRegistration, type WorkflowRun, type WorkflowStartClient, type WorkflowStepEvent, WorkflowSuspended, type WorkflowTask, acceptingSubscription, accumulatorRunId, aggregateAnnouncements, aggregatesCheckpoints, announcementsOf, anyCheckpointName, applyAttributeQuery, assertConcurrency, assertRoutes, attributeColumnFor, attributeOperand, attributePredicateOperands, axisIsRunColumn, bindWorkflowClass, breakpointToken, bufferedEventReaches, buildWorkflowDirectory, canRoute, capableWorkers, carriesLifecyclePending, checkpointNameKind, checkpointStatsOf, childIdsOf, classifyWaiterToken, clearDurableExecutionWrappers, clearTerminalSingletonAdmission, coalescedSubscribersOf, codeAndDetails, codeOf, collectMetrics, concurrencyTag, controlPlaneDescriptor, countRuns, coveredTokens, createStepLogger, currentStep, currentStepScope, currentWorkflowCtx, debug, describeWorker, descriptorHash, detailsOf, error, etagMatches, eventMatchOf, eventMatches, eventNameOf, eventPrefix, eventToken, extendEtag, facetOrigin, fanPageBounds, fanPageEtag, findStalledRuns, foldedCount, getRunsByIds, grantsClientTenant, handoffHandlerId, handoffName, hasDurableExecutionWrappers, heartbeatStatus, hmacTenantVerifier, indexWaitersByRun, info, inheritTenant, isAnyCheckpoint, isAnyMember, isEngineMintedTag, isEventToken, isFailedMember, isLegacyDescriptor, isLifecycleTag, isNonEmptyRunScope, isRemoteEvent, isWorkflowControlFlowSignal, legacySingletonHolders, lifecycleDeliveriesOf, lifecycleEventName, lifecycleEventOf, lifecycleKindOf, lifecycleRegistryNamespace, lifecycleRegistryRunId, lifecycleRegistrySubscriptions, lifecycleRunId, lifecycleSourceOf, lifecycleTraceparentOf, listSignalWaitersOfRuns, liveHandoff, log, markRemoteEvent, matchesAttributes, matchesTenantPredicates, mergeRunFacetRows, mergeRunValueFacetRows, missingCapabilities, negotiate, nextCronFireMs, nextRRuleFireMs, normalizeAttributeRows, normalizeDescriptor, observedAnnouncements, onErrorRunId, owedSubscribersOf, pageFan, pageFanFromStore, parentRunIdOf, parseDuration, parseLifecycleEvent, parseRRule, parseWebhookToken, partitionOfToken, planDispatch, poolNamespace, prevCronFireMs, prevRRuleFireMs, queryCheckpointsOf, readBufferedEvent, readRunsByIds, readSearchAttributes, requiredCapabilities, resolveConcurrency, resolveRouting, resolveRunWaiting, resolveTenantToken, resolveWireTenant, retentionKeeps, retiredHandoffName, routeFor, rowTenant, runCompletedEvent, runDetailEtag, runDurableExecution, runFailedEvent, runInStepLogger, runInStepScope, runInWorkflowCtx, runOutsideWorkflowCtx, runSchedules, runStepHandler, runValueFacetsFromRuns, runWaitPrefix, runWaitTargetOf, runWaitToken, sanitizeQueueToken, scheduleRunIdAt, scheduledRunId, scopeBufferedEvent, scopeTenantQuery, settleResultsWithPlainCalls, signTenantToken, singletonAdmissionDenialPatch, singletonAdmissionTags, singletonClaimantIds, sqlComparator, stepConfigOf, stepId, stepNameOf, sub, subEvent, subProcess, summarizeFan, summarizeRunFromStore, summarizeTimeline, tenantGroup, tenantIdsFor, tenantVisible, toEventSubscription, traceIdOfTraceparent, triggerFailedSubscribersOf, triggeredRunsOf, triggeredSubscribersOf, useDurableExecution, verifyWireTenant, warn, withSingletonTracked, withoutSingletonMarkers, workflowName };
package/dist/index.js CHANGED
@@ -4641,6 +4641,21 @@ function hmacTenantVerifier(secret, capabilities) {
4641
4641
  };
4642
4642
  }
4643
4643
  __name(hmacTenantVerifier, "hmacTenantVerifier");
4644
+ async function verifyWireTenant(wireTenant, verifyTenant) {
4645
+ if (!verifyTenant) return {
4646
+ tenant: wireTenant
4647
+ };
4648
+ return await verifyTenant({
4649
+ token: wireTenant,
4650
+ tenant: wireTenant
4651
+ }) ?? null;
4652
+ }
4653
+ __name(verifyWireTenant, "verifyWireTenant");
4654
+ function grantsClientTenant(verified, tenantId) {
4655
+ const capabilities = verified?.capabilities ?? [];
4656
+ return capabilities.includes("tenancy:*") || capabilities.includes(`tenancy:${tenantId}`);
4657
+ }
4658
+ __name(grantsClientTenant, "grantsClientTenant");
4644
4659
  async function resolveWireTenant(wireTenant, verifyTenant) {
4645
4660
  if (!verifyTenant) return wireTenant;
4646
4661
  const verified = await verifyTenant({
@@ -6911,20 +6926,31 @@ var WorkflowEngine = class _WorkflowEngine {
6911
6926
  }
6912
6927
  const verifyTenant = deps.verifyTenant;
6913
6928
  this.pool.onStartRun(async (message) => {
6914
- let tenant;
6929
+ let verified;
6915
6930
  try {
6916
- tenant = await resolveWireTenant(message.tenant, verifyTenant);
6931
+ verified = await verifyWireTenant(message.tenant, verifyTenant);
6917
6932
  } catch {
6918
- tenant = null;
6933
+ verified = null;
6919
6934
  }
6920
- if (tenant === null) {
6935
+ const tenant = verified?.tenant ?? null;
6936
+ if (verified === null || tenant === null) {
6921
6937
  console.warn(`[nestjs-durable] dropped a start-run for "${message.workflow}": invalid or unauthorized tenant token`);
6922
6938
  return;
6923
6939
  }
6924
6940
  await this.start(message.workflow, message.input, message.runId ?? globalThis.crypto.randomUUID(), {
6925
6941
  namespace: tenant,
6926
6942
  tags: message.tags,
6927
- searchAttributes: message.searchAttributes
6943
+ searchAttributes: message.searchAttributes,
6944
+ // The customer a tenant process claims for the run (A4): kept only when its verified
6945
+ // token grants `tenancy:*` or `tenancy:<id>`, else the run gets no customer tenant.
6946
+ ...message.tenantId !== void 0 ? grantsClientTenant(verified, message.tenantId) ? message.tenantKind !== void 0 ? {
6947
+ tenantId: message.tenantId,
6948
+ tenantKind: message.tenantKind
6949
+ } : {
6950
+ tenantId: message.tenantId
6951
+ } : {
6952
+ tenantId: null
6953
+ } : {}
6928
6954
  });
6929
6955
  });
6930
6956
  this.controlPlane?.onControl((msg) => {
@@ -9063,7 +9089,12 @@ var WorkflowEngine = class _WorkflowEngine {
9063
9089
  * invisible run reads exactly like a missing one (not found, never forbidden).
9064
9090
  */
9065
9091
  visibleRun(runId) {
9066
- const filter = this.restrictiveFilter();
9092
+ let filter;
9093
+ try {
9094
+ filter = this.restrictiveFilter();
9095
+ } catch (err) {
9096
+ return Promise.reject(err);
9097
+ }
9067
9098
  if (!filter) return this.store.getRun(runId);
9068
9099
  return this.store.getRun(runId).then((run) => run && tenantVisible(run, filter) ? run : null);
9069
9100
  }
@@ -9110,8 +9141,11 @@ var WorkflowEngine = class _WorkflowEngine {
9110
9141
  * timer, a signal, recovery or a worker. A run with no tenant, or tenancy off, runs `fn` as is.
9111
9142
  */
9112
9143
  inRunTenant(run, fn) {
9113
- const tenant = this.tenancy ? rowTenant(run) : void 0;
9114
- return tenant && this.tenancy ? this.tenancy.run(tenant, fn) : fn();
9144
+ const tenancy = this.tenancy;
9145
+ if (!tenancy) return fn();
9146
+ const tenant = rowTenant(run);
9147
+ const turn = tenant ? () => tenancy.run(tenant, fn) : fn;
9148
+ return tenancy.system ? tenancy.system(turn) : turn();
9115
9149
  }
9116
9150
  /**
9117
9151
  * Read a run's current persisted state (or null if unknown). With tenancy on, a run of another
@@ -11256,7 +11290,7 @@ var WorkflowEngine = class _WorkflowEngine {
11256
11290
  ];
11257
11291
  }
11258
11292
  /** The worker groups this engine dispatches to: every registered remote workflow's group, plus any
11259
- * `extra` the caller declares. Local-step groups (a group consumed by in-process `@DurableStep`
11293
+ * `extra` the caller declares. Local-step groups (a group consumed by in-process `@Step`
11260
11294
  * workers, e.g. `pipeline`) aren't derivable from registrations — pass them via `extra` so a group
11261
11295
  * with backlog and ZERO workers is still reported (the alert case has no heartbeat to discover). */
11262
11296
  knownGroups(extra = []) {
@@ -16026,12 +16060,12 @@ function readSearchAttributes(schema, run) {
16026
16060
  __name(readSearchAttributes, "readSearchAttributes");
16027
16061
 
16028
16062
  // src/tokens.ts
16029
- var STATE_STORE = Symbol.for("nestjs-durable:STATE_STORE");
16030
- var TRANSPORT = Symbol.for("nestjs-durable:TRANSPORT");
16031
- var DURABLE_OPTIONS = Symbol.for("nestjs-durable:DURABLE_OPTIONS");
16032
16063
  var STATE_STORE_CANONICAL = Symbol.for("@dudousxd/nestjs-durable:state-store");
16033
16064
  var TRANSPORT_CANONICAL = Symbol.for("@dudousxd/nestjs-durable:transport");
16034
16065
  var DURABLE_OPTIONS_CANONICAL = Symbol.for("@dudousxd/nestjs-durable:options");
16066
+ var STATE_STORE = Symbol.for("nestjs-durable:STATE_STORE");
16067
+ var TRANSPORT = Symbol.for("nestjs-durable:TRANSPORT");
16068
+ var DURABLE_OPTIONS = Symbol.for("nestjs-durable:DURABLE_OPTIONS");
16035
16069
 
16036
16070
  // src/testing/in-memory-state-store.ts
16037
16071
  var RETENTION_EXCLUDED = [
@@ -17107,6 +17141,7 @@ export {
17107
17141
  findStalledRuns,
17108
17142
  foldedCount,
17109
17143
  getRunsByIds,
17144
+ grantsClientTenant,
17110
17145
  handoffHandlerId,
17111
17146
  handoffName,
17112
17147
  hasDurableExecutionWrappers,
@@ -17222,6 +17257,7 @@ export {
17222
17257
  triggeredRunsOf,
17223
17258
  triggeredSubscribersOf,
17224
17259
  useDurableExecution,
17260
+ verifyWireTenant,
17225
17261
  warn,
17226
17262
  withSingletonTracked,
17227
17263
  withoutSingletonMarkers,