@dudousxd/nestjs-durable 0.62.0 → 0.64.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.cjs +197 -88
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +48 -6
- package/dist/index.d.ts +48 -6
- package/dist/index.js +149 -42
- package/dist/index.js.map +1 -1
- package/package.json +7 -5
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WorkflowCtx, SearchAttributes, WorkflowClass, StandardSchemaV1, StepError, OnEventEntry, OnErrorInput, LifecycleEventOf, WorkflowLifecycleEvent, WorkflowRef, SingletonConfig, ConcurrencyConfig, SearchAttributesSchema, EventBatchConfig, TenantVerifier, VerifiedTenant, TenantTokenSource, StateStore, Transport, NamedTransport, ControlPlane, StalledRunInfo, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowInputOf, StartOptions, RunResult, RunGateway, WorkflowEngine, EntityHandler, DurableTopology, RunDetailOptions, RunDetail, FanPageQuery, FanPage, WorkflowRun, RunQuery, RunListItem, RunFacetQuery, RunFacetRow, RunValueAxis, RunValueFacetOptions, RunValueFacetRow, RunWaiting, WorkflowLifecycleLinks, LifecycleKind, GroupHealth, ScheduleListQuery, ScheduleDescription, RepublishLifecycleTarget, RepublishLifecycleResult, ScheduleAction, EngineEvent, RunRequest, RunReply, TenantFilter as TenantFilter$1, StepInvocation, TenantEvent, SignalOptions } from '@dudousxd/nestjs-durable-core';
|
|
1
|
+
import { WorkflowCtx, SearchAttributes, WorkflowClass, StandardSchemaV1, StepError, OnEventEntry, OnErrorInput, LifecycleEventOf, WorkflowLifecycleEvent, WorkflowRef, SingletonConfig, ConcurrencyConfig, SearchAttributesSchema, EventBatchConfig, TenantVerifier, VerifiedTenant, TenantTokenSource, StateStore, Transport, NamedTransport, ControlPlane, StalledRunInfo, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowInputOf, StartOptions, RunResult, WorkflowStartClient, ScheduleAnnouncement, RunGateway, WorkflowEngine, EntityHandler, DurableTopology, RunDetailOptions, RunDetail, FanPageQuery, FanPage, WorkflowRun, RunQuery, RunListItem, RunFacetQuery, RunFacetRow, RunValueAxis, RunValueFacetOptions, RunValueFacetRow, RunWaiting, WorkflowLifecycleLinks, LifecycleKind, GroupHealth, ScheduleListQuery, ScheduleDescription, RepublishLifecycleTarget, RepublishLifecycleResult, ScheduleAction, EngineEvent, RunRequest, RunReply, TenantFilter as TenantFilter$1, StepInvocation, TenantEvent, SignalOptions } from '@dudousxd/nestjs-durable-core';
|
|
2
2
|
export { AttributeFilter, DuplicateDurableCopyError, DynamicWorkflowCtx, EngineEvent, EventSubscription, InferSearchAttributes, LIFECYCLE_PENDING_TAG, LifecycleEventOf, LifecycleKind, OnErrorInput, OnEventEntry, RunDetail, RunGateway, RunListItem, RunQuery, RunSchedulesOptions, RunStatus, RunWaiting, ScheduledWorkflow, SearchAttributes, SearchAttributesSchema, StepCheckpoint, StepEvent, StepLogger, TenantTokenSource, TenantVerifier, VerifiedTenant, WorkflowCtx, WorkflowEngine, WorkflowHandler, WorkflowLifecycleEvent, WorkflowRun, hmacTenantVerifier, lifecycleRunId, lifecycleSourceOf, prevCronFireMs, readSearchAttributes, runCompletedEvent, runFailedEvent, runSchedules, scheduleRunIdAt, scheduledRunId, signTenantToken, triggeredRunsOf } from '@dudousxd/nestjs-durable-core';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { ConcurrencyOption, StartRunDeps, RunRedisWorkerOptions, RunningWorker, DurableWorkerRuntime } from '@dudousxd/durable-worker';
|
|
@@ -823,7 +823,9 @@ interface DurableModuleSharedOptions {
|
|
|
823
823
|
* returns a decision nor sends a run-scoped heartbeat within this window, the engine presumes it dead
|
|
824
824
|
* and lets recovery re-drive; each heartbeat rearms the window so a slow-but-alive worker is never
|
|
825
825
|
* re-driven. Pair with a worker SDK that emits run-scoped heartbeats (`@dudousxd/durable-worker` ≥ the
|
|
826
|
-
* release that ships them, and the Python `durable-worker`).
|
|
826
|
+
* release that ships them, and the Python `durable-worker`). Omitted, a turn dispatched over a
|
|
827
|
+
* broker (a tenant's worker, another SDK's) takes {@link reconcileMs} as its window, so a run whose
|
|
828
|
+
* worker died mid-turn is re-driven within it; `reconcileMs: 0` keeps the unbounded wait.
|
|
827
829
|
* Operator only.
|
|
828
830
|
*/
|
|
829
831
|
remoteAdvanceSilenceMs?: number;
|
|
@@ -850,7 +852,8 @@ interface DurableModuleSharedOptions {
|
|
|
850
852
|
/**
|
|
851
853
|
* Fallback wake-up (ms) for a run suspended on an event (child, signal, `waitForEvent`, remote
|
|
852
854
|
* result) whose wake-up was lost: the reconcile pass re-drives it after this window, an idempotent
|
|
853
|
-
* replay that re-suspends a still-pending wait. Defaults to 300000 (5min); `0` disables it.
|
|
855
|
+
* replay that re-suspends a still-pending wait. Defaults to 300000 (5min); `0` disables it. Also
|
|
856
|
+
* the re-drive window of a dispatched workflow turn when {@link remoteAdvanceSilenceMs} is unset.
|
|
854
857
|
* See `WorkflowEngineDeps.reconcileMs`. Operator only.
|
|
855
858
|
*/
|
|
856
859
|
reconcileMs?: number;
|
|
@@ -967,6 +970,21 @@ interface DurableModuleSharedOptions {
|
|
|
967
970
|
* deterministic and advancing a schedule is a compare-and-set. Operator only.
|
|
968
971
|
*/
|
|
969
972
|
persistedSchedules?: boolean;
|
|
973
|
+
/**
|
|
974
|
+
* Adopt the `schedules` that TENANT apps declare and fire them here (a tenant has no store to fire
|
|
975
|
+
* them from). Each tenant worker announces its app's schedules on its descriptor; every `syncMs`
|
|
976
|
+
* (default 15 s) a driving instance turns them into persisted schedules (id
|
|
977
|
+
* `app:<partition>:<key>`, tagged `schedule:announced`), applies a changed definition, and pauses
|
|
978
|
+
* one that no live worker of its app has announced for `graceMs` (default 10 minutes). It then
|
|
979
|
+
* fires them on every tick, through the tenant start path: with no live worker of the app, a run
|
|
980
|
+
* waits `blocked` (`no_live_worker`) for one. On by default for a driving instance with a store
|
|
981
|
+
* that persists schedules and a transport that reads worker descriptors (BullMQ); `false` turns it
|
|
982
|
+
* off. Operator only.
|
|
983
|
+
*/
|
|
984
|
+
announcedSchedules?: boolean | {
|
|
985
|
+
syncMs?: number;
|
|
986
|
+
graceMs?: number;
|
|
987
|
+
};
|
|
970
988
|
/**
|
|
971
989
|
* Hard-prune terminal run history on an interval so `durable_workflow_runs` (and its child tables)
|
|
972
990
|
* stays bounded — without it, completed/failed/cancelled runs accumulate forever and the timer
|
|
@@ -1181,6 +1199,11 @@ interface DurableModuleAsyncOptions {
|
|
|
1181
1199
|
useFactory: (...args: never[]) => DurableModuleOptions | Promise<DurableModuleOptions>;
|
|
1182
1200
|
inject?: InjectionToken[];
|
|
1183
1201
|
}
|
|
1202
|
+
/** The `verifyTenant` / `tenantToken` options, resolved to the plain functions the wire layer calls. */
|
|
1203
|
+
interface ResolvedTenantAuth {
|
|
1204
|
+
verifyTenant: TenantVerifier | undefined;
|
|
1205
|
+
tenantToken: TenantTokenSource | undefined;
|
|
1206
|
+
}
|
|
1184
1207
|
/**
|
|
1185
1208
|
* `forRoot` / `forRootAsync` first refuse to boot when two different installs of
|
|
1186
1209
|
* `@dudousxd/nestjs-durable-core` are loaded in this process (a pnpm peer-variant split): each copy
|
|
@@ -1267,7 +1290,11 @@ declare class ThinWorkflowRegistrar implements OnModuleInit {
|
|
|
1267
1290
|
private readonly metadataScanner;
|
|
1268
1291
|
private readonly runtime;
|
|
1269
1292
|
private readonly options;
|
|
1270
|
-
|
|
1293
|
+
/** In this role the store-less `DurableStartClient` facade the module binds under this token. */
|
|
1294
|
+
private readonly starter;
|
|
1295
|
+
constructor(discovery: DiscoveryService, metadataScanner: MetadataScanner, runtime: DurableWorkerRuntime | null, options: DurableModuleOptions,
|
|
1296
|
+
/** In this role the store-less `DurableStartClient` facade the module binds under this token. */
|
|
1297
|
+
starter: WorkflowStartClient);
|
|
1271
1298
|
onModuleInit(): void;
|
|
1272
1299
|
}
|
|
1273
1300
|
/**
|
|
@@ -1299,11 +1326,21 @@ declare class ThinWorkerBootstrap implements OnApplicationBootstrap, OnApplicati
|
|
|
1299
1326
|
private readonly options;
|
|
1300
1327
|
private readonly runRedisWorker;
|
|
1301
1328
|
private readonly runnersSink;
|
|
1329
|
+
private readonly auth;
|
|
1302
1330
|
private readonly runners;
|
|
1303
|
-
constructor(runtime: DurableWorkerRuntime | null, options: DurableModuleOptions, runRedisWorker: RunRedisWorkerFn, runnersSink: RunningWorker[]);
|
|
1331
|
+
constructor(runtime: DurableWorkerRuntime | null, options: DurableModuleOptions, runRedisWorker: RunRedisWorkerFn, runnersSink: RunningWorker[], auth: ResolvedTenantAuth);
|
|
1304
1332
|
onApplicationBootstrap(): Promise<void>;
|
|
1305
1333
|
onApplicationShutdown(): Promise<void>;
|
|
1306
1334
|
}
|
|
1335
|
+
/**
|
|
1336
|
+
* The tenant's `schedules`, as its worker announces them: under the wire tenant its starts carry (the
|
|
1337
|
+
* signed token when the app has one, else the partition), one {@link AnnouncedSchedule} per schedule.
|
|
1338
|
+
* A schedule's `namespace` is dropped (a tenant's runs always belong to its own namespace), and
|
|
1339
|
+
* `backfill` becomes the control plane's `catchup: 'latest'` (at most one late window).
|
|
1340
|
+
*/
|
|
1341
|
+
declare function tenantScheduleAnnouncement(options: DurableModuleOptions, tenantToken: TenantTokenSource | undefined): Promise<{
|
|
1342
|
+
schedules?: ScheduleAnnouncement;
|
|
1343
|
+
}>;
|
|
1307
1344
|
/**
|
|
1308
1345
|
* The thin-worker slice of {@link import('./durable.module').DurableModule}'s unified provider set —
|
|
1309
1346
|
* active for the pure thin-worker role (`connection` set, `store` unset): registers discovered
|
|
@@ -1893,6 +1930,11 @@ declare class TenantEventRepublisher {
|
|
|
1893
1930
|
* byte-identical with nestjs-context's export.
|
|
1894
1931
|
*/
|
|
1895
1932
|
declare const CONTEXT_ACCESSOR: unique symbol;
|
|
1933
|
+
/**
|
|
1934
|
+
* Internal: the module's resolved tenant auth (`verifyTenant` and `tenantToken`, resolved through
|
|
1935
|
+
* DI). Shared by the module and the thin-worker providers, which announce under the tenant token.
|
|
1936
|
+
*/
|
|
1937
|
+
declare const TENANT_AUTH: unique symbol;
|
|
1896
1938
|
/**
|
|
1897
1939
|
* @deprecated Inject the `RunGateway` class, which is its own DI token:
|
|
1898
1940
|
* `constructor(private readonly gateway: RunGateway)`. Kept because published
|
|
@@ -1979,4 +2021,4 @@ declare class WorkflowService {
|
|
|
1979
2021
|
republishLifecycle(target: RepublishLifecycleTarget): Promise<RepublishLifecycleResult>;
|
|
1980
2022
|
}
|
|
1981
2023
|
|
|
1982
|
-
export { BAD_RUN_REQUEST, CONTEXT_ACCESSOR, type ContextAccessor, type ContextStore, type ContractClass, type ControlPlaneDurableOptions, DEAD_LETTER_METADATA, DURABLE_STEP_METADATA, DURABLE_WORKER_RUNNERS, DURABLE_WORKER_RUNTIME, DeadLetter, type DtoClass, DurableModule, type DurableModuleAsyncOptions, type DurableModuleOptions, type DurableModuleSharedOptions, type DurableRetentionOptions, DurableStartClient, type DurableStepInterceptor, type DurableStepMeta, type DurableTopologyName, ENTITY_METADATA, ENTITY_ON_METADATA, Entity, EntityService, type ErrorClassWithCode, FederatedAppGateway, type FederatedAppGatewayOptions, IN_APP_RUN_REDIS_WORKER, IN_APP_WORKER_BINDING, IN_APP_WORKER_RUNNERS, IN_APP_WORKER_RUNTIME, type InAppWorkerBinding, InAppWorkerBootstrap, type IoSchema, type LazyContract, ON_ERROR_METADATA, ON_EVENT_BATCH_METADATA, ON_EVENT_METADATA, On, OnDurableEvent, OnError, type OnErrorMethod, OnWorkflowCompleted, OnWorkflowFailed, type OnWorkflowFailedOptions, type OnWorkflowSettledOptions, ProxyRunGateway, RUN_GATEWAY, RUN_REDIS_WORKER, RunGatewayError, type RunGatewayErrorCode, type RunLookupStore, type RunRedisWorkerFn, RunRequestResponder, type RunRequestResponderOptions, type RunRequestTransport, STEP_INTERCEPTOR_METADATA, type StandaloneDurableOptions, Step, StepInterceptor, type StepOptions, StoreRunGateway, type SubscriberBatch, type SubscriberDebounce, type SubscriberDecorator, TENANT_REPUBLISH_MAX_LIMIT, type TenantCredentialsContract, type TenantDurableOptions, TenantEventRepublisher, type TenantFilter, type TenantLevel, type TenantRef, type TenantTokenOption, type TenantVerifierContract, type TenantVerifierInput, type TenantVerifierOption, ThinStepRegistrar, ThinWorkerBootstrap, ThinWorkflowRegistrar, UNSUPPORTED_RUN_REQUEST, type UserRef, WORKFLOW_METADATA, Workflow, type WorkflowAttributesOf, type WorkflowMeta, type WorkflowOptions, WorkflowService, attributesOf, entityConfigFor, eventBatchOf, federatedAppGateway, getDurableStepMeta, getEntityMeta, getOnEvents, getWorkflowMeta, inAppWorkerProviders, isDeadLetterHandler, isDrivingOperator, isOperatorRole, isStepInterceptor, onErrorCodesOf, thinWorkerProviders, unavailableRunGateway };
|
|
2024
|
+
export { BAD_RUN_REQUEST, CONTEXT_ACCESSOR, type ContextAccessor, type ContextStore, type ContractClass, type ControlPlaneDurableOptions, DEAD_LETTER_METADATA, DURABLE_STEP_METADATA, DURABLE_WORKER_RUNNERS, DURABLE_WORKER_RUNTIME, DeadLetter, type DtoClass, DurableModule, type DurableModuleAsyncOptions, type DurableModuleOptions, type DurableModuleSharedOptions, type DurableRetentionOptions, DurableStartClient, type DurableStepInterceptor, type DurableStepMeta, type DurableTopologyName, ENTITY_METADATA, ENTITY_ON_METADATA, Entity, EntityService, type ErrorClassWithCode, FederatedAppGateway, type FederatedAppGatewayOptions, IN_APP_RUN_REDIS_WORKER, IN_APP_WORKER_BINDING, IN_APP_WORKER_RUNNERS, IN_APP_WORKER_RUNTIME, type InAppWorkerBinding, InAppWorkerBootstrap, type IoSchema, type LazyContract, ON_ERROR_METADATA, ON_EVENT_BATCH_METADATA, ON_EVENT_METADATA, On, OnDurableEvent, OnError, type OnErrorMethod, OnWorkflowCompleted, OnWorkflowFailed, type OnWorkflowFailedOptions, type OnWorkflowSettledOptions, ProxyRunGateway, RUN_GATEWAY, RUN_REDIS_WORKER, type ResolvedTenantAuth, RunGatewayError, type RunGatewayErrorCode, type RunLookupStore, type RunRedisWorkerFn, RunRequestResponder, type RunRequestResponderOptions, type RunRequestTransport, STEP_INTERCEPTOR_METADATA, type StandaloneDurableOptions, Step, StepInterceptor, type StepOptions, StoreRunGateway, type SubscriberBatch, type SubscriberDebounce, type SubscriberDecorator, TENANT_AUTH, TENANT_REPUBLISH_MAX_LIMIT, type TenantCredentialsContract, type TenantDurableOptions, TenantEventRepublisher, type TenantFilter, type TenantLevel, type TenantRef, type TenantTokenOption, type TenantVerifierContract, type TenantVerifierInput, type TenantVerifierOption, ThinStepRegistrar, ThinWorkerBootstrap, ThinWorkflowRegistrar, UNSUPPORTED_RUN_REQUEST, type UserRef, WORKFLOW_METADATA, Workflow, type WorkflowAttributesOf, type WorkflowMeta, type WorkflowOptions, WorkflowService, attributesOf, entityConfigFor, eventBatchOf, federatedAppGateway, getDurableStepMeta, getEntityMeta, getOnEvents, getWorkflowMeta, inAppWorkerProviders, isDeadLetterHandler, isDrivingOperator, isOperatorRole, isStepInterceptor, onErrorCodesOf, tenantScheduleAnnouncement, thinWorkerProviders, unavailableRunGateway };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WorkflowCtx, SearchAttributes, WorkflowClass, StandardSchemaV1, StepError, OnEventEntry, OnErrorInput, LifecycleEventOf, WorkflowLifecycleEvent, WorkflowRef, SingletonConfig, ConcurrencyConfig, SearchAttributesSchema, EventBatchConfig, TenantVerifier, VerifiedTenant, TenantTokenSource, StateStore, Transport, NamedTransport, ControlPlane, StalledRunInfo, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowInputOf, StartOptions, RunResult, RunGateway, WorkflowEngine, EntityHandler, DurableTopology, RunDetailOptions, RunDetail, FanPageQuery, FanPage, WorkflowRun, RunQuery, RunListItem, RunFacetQuery, RunFacetRow, RunValueAxis, RunValueFacetOptions, RunValueFacetRow, RunWaiting, WorkflowLifecycleLinks, LifecycleKind, GroupHealth, ScheduleListQuery, ScheduleDescription, RepublishLifecycleTarget, RepublishLifecycleResult, ScheduleAction, EngineEvent, RunRequest, RunReply, TenantFilter as TenantFilter$1, StepInvocation, TenantEvent, SignalOptions } from '@dudousxd/nestjs-durable-core';
|
|
1
|
+
import { WorkflowCtx, SearchAttributes, WorkflowClass, StandardSchemaV1, StepError, OnEventEntry, OnErrorInput, LifecycleEventOf, WorkflowLifecycleEvent, WorkflowRef, SingletonConfig, ConcurrencyConfig, SearchAttributesSchema, EventBatchConfig, TenantVerifier, VerifiedTenant, TenantTokenSource, StateStore, Transport, NamedTransport, ControlPlane, StalledRunInfo, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowInputOf, StartOptions, RunResult, WorkflowStartClient, ScheduleAnnouncement, RunGateway, WorkflowEngine, EntityHandler, DurableTopology, RunDetailOptions, RunDetail, FanPageQuery, FanPage, WorkflowRun, RunQuery, RunListItem, RunFacetQuery, RunFacetRow, RunValueAxis, RunValueFacetOptions, RunValueFacetRow, RunWaiting, WorkflowLifecycleLinks, LifecycleKind, GroupHealth, ScheduleListQuery, ScheduleDescription, RepublishLifecycleTarget, RepublishLifecycleResult, ScheduleAction, EngineEvent, RunRequest, RunReply, TenantFilter as TenantFilter$1, StepInvocation, TenantEvent, SignalOptions } from '@dudousxd/nestjs-durable-core';
|
|
2
2
|
export { AttributeFilter, DuplicateDurableCopyError, DynamicWorkflowCtx, EngineEvent, EventSubscription, InferSearchAttributes, LIFECYCLE_PENDING_TAG, LifecycleEventOf, LifecycleKind, OnErrorInput, OnEventEntry, RunDetail, RunGateway, RunListItem, RunQuery, RunSchedulesOptions, RunStatus, RunWaiting, ScheduledWorkflow, SearchAttributes, SearchAttributesSchema, StepCheckpoint, StepEvent, StepLogger, TenantTokenSource, TenantVerifier, VerifiedTenant, WorkflowCtx, WorkflowEngine, WorkflowHandler, WorkflowLifecycleEvent, WorkflowRun, hmacTenantVerifier, lifecycleRunId, lifecycleSourceOf, prevCronFireMs, readSearchAttributes, runCompletedEvent, runFailedEvent, runSchedules, scheduleRunIdAt, scheduledRunId, signTenantToken, triggeredRunsOf } from '@dudousxd/nestjs-durable-core';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { ConcurrencyOption, StartRunDeps, RunRedisWorkerOptions, RunningWorker, DurableWorkerRuntime } from '@dudousxd/durable-worker';
|
|
@@ -823,7 +823,9 @@ interface DurableModuleSharedOptions {
|
|
|
823
823
|
* returns a decision nor sends a run-scoped heartbeat within this window, the engine presumes it dead
|
|
824
824
|
* and lets recovery re-drive; each heartbeat rearms the window so a slow-but-alive worker is never
|
|
825
825
|
* re-driven. Pair with a worker SDK that emits run-scoped heartbeats (`@dudousxd/durable-worker` ≥ the
|
|
826
|
-
* release that ships them, and the Python `durable-worker`).
|
|
826
|
+
* release that ships them, and the Python `durable-worker`). Omitted, a turn dispatched over a
|
|
827
|
+
* broker (a tenant's worker, another SDK's) takes {@link reconcileMs} as its window, so a run whose
|
|
828
|
+
* worker died mid-turn is re-driven within it; `reconcileMs: 0` keeps the unbounded wait.
|
|
827
829
|
* Operator only.
|
|
828
830
|
*/
|
|
829
831
|
remoteAdvanceSilenceMs?: number;
|
|
@@ -850,7 +852,8 @@ interface DurableModuleSharedOptions {
|
|
|
850
852
|
/**
|
|
851
853
|
* Fallback wake-up (ms) for a run suspended on an event (child, signal, `waitForEvent`, remote
|
|
852
854
|
* result) whose wake-up was lost: the reconcile pass re-drives it after this window, an idempotent
|
|
853
|
-
* replay that re-suspends a still-pending wait. Defaults to 300000 (5min); `0` disables it.
|
|
855
|
+
* replay that re-suspends a still-pending wait. Defaults to 300000 (5min); `0` disables it. Also
|
|
856
|
+
* the re-drive window of a dispatched workflow turn when {@link remoteAdvanceSilenceMs} is unset.
|
|
854
857
|
* See `WorkflowEngineDeps.reconcileMs`. Operator only.
|
|
855
858
|
*/
|
|
856
859
|
reconcileMs?: number;
|
|
@@ -967,6 +970,21 @@ interface DurableModuleSharedOptions {
|
|
|
967
970
|
* deterministic and advancing a schedule is a compare-and-set. Operator only.
|
|
968
971
|
*/
|
|
969
972
|
persistedSchedules?: boolean;
|
|
973
|
+
/**
|
|
974
|
+
* Adopt the `schedules` that TENANT apps declare and fire them here (a tenant has no store to fire
|
|
975
|
+
* them from). Each tenant worker announces its app's schedules on its descriptor; every `syncMs`
|
|
976
|
+
* (default 15 s) a driving instance turns them into persisted schedules (id
|
|
977
|
+
* `app:<partition>:<key>`, tagged `schedule:announced`), applies a changed definition, and pauses
|
|
978
|
+
* one that no live worker of its app has announced for `graceMs` (default 10 minutes). It then
|
|
979
|
+
* fires them on every tick, through the tenant start path: with no live worker of the app, a run
|
|
980
|
+
* waits `blocked` (`no_live_worker`) for one. On by default for a driving instance with a store
|
|
981
|
+
* that persists schedules and a transport that reads worker descriptors (BullMQ); `false` turns it
|
|
982
|
+
* off. Operator only.
|
|
983
|
+
*/
|
|
984
|
+
announcedSchedules?: boolean | {
|
|
985
|
+
syncMs?: number;
|
|
986
|
+
graceMs?: number;
|
|
987
|
+
};
|
|
970
988
|
/**
|
|
971
989
|
* Hard-prune terminal run history on an interval so `durable_workflow_runs` (and its child tables)
|
|
972
990
|
* stays bounded — without it, completed/failed/cancelled runs accumulate forever and the timer
|
|
@@ -1181,6 +1199,11 @@ interface DurableModuleAsyncOptions {
|
|
|
1181
1199
|
useFactory: (...args: never[]) => DurableModuleOptions | Promise<DurableModuleOptions>;
|
|
1182
1200
|
inject?: InjectionToken[];
|
|
1183
1201
|
}
|
|
1202
|
+
/** The `verifyTenant` / `tenantToken` options, resolved to the plain functions the wire layer calls. */
|
|
1203
|
+
interface ResolvedTenantAuth {
|
|
1204
|
+
verifyTenant: TenantVerifier | undefined;
|
|
1205
|
+
tenantToken: TenantTokenSource | undefined;
|
|
1206
|
+
}
|
|
1184
1207
|
/**
|
|
1185
1208
|
* `forRoot` / `forRootAsync` first refuse to boot when two different installs of
|
|
1186
1209
|
* `@dudousxd/nestjs-durable-core` are loaded in this process (a pnpm peer-variant split): each copy
|
|
@@ -1267,7 +1290,11 @@ declare class ThinWorkflowRegistrar implements OnModuleInit {
|
|
|
1267
1290
|
private readonly metadataScanner;
|
|
1268
1291
|
private readonly runtime;
|
|
1269
1292
|
private readonly options;
|
|
1270
|
-
|
|
1293
|
+
/** In this role the store-less `DurableStartClient` facade the module binds under this token. */
|
|
1294
|
+
private readonly starter;
|
|
1295
|
+
constructor(discovery: DiscoveryService, metadataScanner: MetadataScanner, runtime: DurableWorkerRuntime | null, options: DurableModuleOptions,
|
|
1296
|
+
/** In this role the store-less `DurableStartClient` facade the module binds under this token. */
|
|
1297
|
+
starter: WorkflowStartClient);
|
|
1271
1298
|
onModuleInit(): void;
|
|
1272
1299
|
}
|
|
1273
1300
|
/**
|
|
@@ -1299,11 +1326,21 @@ declare class ThinWorkerBootstrap implements OnApplicationBootstrap, OnApplicati
|
|
|
1299
1326
|
private readonly options;
|
|
1300
1327
|
private readonly runRedisWorker;
|
|
1301
1328
|
private readonly runnersSink;
|
|
1329
|
+
private readonly auth;
|
|
1302
1330
|
private readonly runners;
|
|
1303
|
-
constructor(runtime: DurableWorkerRuntime | null, options: DurableModuleOptions, runRedisWorker: RunRedisWorkerFn, runnersSink: RunningWorker[]);
|
|
1331
|
+
constructor(runtime: DurableWorkerRuntime | null, options: DurableModuleOptions, runRedisWorker: RunRedisWorkerFn, runnersSink: RunningWorker[], auth: ResolvedTenantAuth);
|
|
1304
1332
|
onApplicationBootstrap(): Promise<void>;
|
|
1305
1333
|
onApplicationShutdown(): Promise<void>;
|
|
1306
1334
|
}
|
|
1335
|
+
/**
|
|
1336
|
+
* The tenant's `schedules`, as its worker announces them: under the wire tenant its starts carry (the
|
|
1337
|
+
* signed token when the app has one, else the partition), one {@link AnnouncedSchedule} per schedule.
|
|
1338
|
+
* A schedule's `namespace` is dropped (a tenant's runs always belong to its own namespace), and
|
|
1339
|
+
* `backfill` becomes the control plane's `catchup: 'latest'` (at most one late window).
|
|
1340
|
+
*/
|
|
1341
|
+
declare function tenantScheduleAnnouncement(options: DurableModuleOptions, tenantToken: TenantTokenSource | undefined): Promise<{
|
|
1342
|
+
schedules?: ScheduleAnnouncement;
|
|
1343
|
+
}>;
|
|
1307
1344
|
/**
|
|
1308
1345
|
* The thin-worker slice of {@link import('./durable.module').DurableModule}'s unified provider set —
|
|
1309
1346
|
* active for the pure thin-worker role (`connection` set, `store` unset): registers discovered
|
|
@@ -1893,6 +1930,11 @@ declare class TenantEventRepublisher {
|
|
|
1893
1930
|
* byte-identical with nestjs-context's export.
|
|
1894
1931
|
*/
|
|
1895
1932
|
declare const CONTEXT_ACCESSOR: unique symbol;
|
|
1933
|
+
/**
|
|
1934
|
+
* Internal: the module's resolved tenant auth (`verifyTenant` and `tenantToken`, resolved through
|
|
1935
|
+
* DI). Shared by the module and the thin-worker providers, which announce under the tenant token.
|
|
1936
|
+
*/
|
|
1937
|
+
declare const TENANT_AUTH: unique symbol;
|
|
1896
1938
|
/**
|
|
1897
1939
|
* @deprecated Inject the `RunGateway` class, which is its own DI token:
|
|
1898
1940
|
* `constructor(private readonly gateway: RunGateway)`. Kept because published
|
|
@@ -1979,4 +2021,4 @@ declare class WorkflowService {
|
|
|
1979
2021
|
republishLifecycle(target: RepublishLifecycleTarget): Promise<RepublishLifecycleResult>;
|
|
1980
2022
|
}
|
|
1981
2023
|
|
|
1982
|
-
export { BAD_RUN_REQUEST, CONTEXT_ACCESSOR, type ContextAccessor, type ContextStore, type ContractClass, type ControlPlaneDurableOptions, DEAD_LETTER_METADATA, DURABLE_STEP_METADATA, DURABLE_WORKER_RUNNERS, DURABLE_WORKER_RUNTIME, DeadLetter, type DtoClass, DurableModule, type DurableModuleAsyncOptions, type DurableModuleOptions, type DurableModuleSharedOptions, type DurableRetentionOptions, DurableStartClient, type DurableStepInterceptor, type DurableStepMeta, type DurableTopologyName, ENTITY_METADATA, ENTITY_ON_METADATA, Entity, EntityService, type ErrorClassWithCode, FederatedAppGateway, type FederatedAppGatewayOptions, IN_APP_RUN_REDIS_WORKER, IN_APP_WORKER_BINDING, IN_APP_WORKER_RUNNERS, IN_APP_WORKER_RUNTIME, type InAppWorkerBinding, InAppWorkerBootstrap, type IoSchema, type LazyContract, ON_ERROR_METADATA, ON_EVENT_BATCH_METADATA, ON_EVENT_METADATA, On, OnDurableEvent, OnError, type OnErrorMethod, OnWorkflowCompleted, OnWorkflowFailed, type OnWorkflowFailedOptions, type OnWorkflowSettledOptions, ProxyRunGateway, RUN_GATEWAY, RUN_REDIS_WORKER, RunGatewayError, type RunGatewayErrorCode, type RunLookupStore, type RunRedisWorkerFn, RunRequestResponder, type RunRequestResponderOptions, type RunRequestTransport, STEP_INTERCEPTOR_METADATA, type StandaloneDurableOptions, Step, StepInterceptor, type StepOptions, StoreRunGateway, type SubscriberBatch, type SubscriberDebounce, type SubscriberDecorator, TENANT_REPUBLISH_MAX_LIMIT, type TenantCredentialsContract, type TenantDurableOptions, TenantEventRepublisher, type TenantFilter, type TenantLevel, type TenantRef, type TenantTokenOption, type TenantVerifierContract, type TenantVerifierInput, type TenantVerifierOption, ThinStepRegistrar, ThinWorkerBootstrap, ThinWorkflowRegistrar, UNSUPPORTED_RUN_REQUEST, type UserRef, WORKFLOW_METADATA, Workflow, type WorkflowAttributesOf, type WorkflowMeta, type WorkflowOptions, WorkflowService, attributesOf, entityConfigFor, eventBatchOf, federatedAppGateway, getDurableStepMeta, getEntityMeta, getOnEvents, getWorkflowMeta, inAppWorkerProviders, isDeadLetterHandler, isDrivingOperator, isOperatorRole, isStepInterceptor, onErrorCodesOf, thinWorkerProviders, unavailableRunGateway };
|
|
2024
|
+
export { BAD_RUN_REQUEST, CONTEXT_ACCESSOR, type ContextAccessor, type ContextStore, type ContractClass, type ControlPlaneDurableOptions, DEAD_LETTER_METADATA, DURABLE_STEP_METADATA, DURABLE_WORKER_RUNNERS, DURABLE_WORKER_RUNTIME, DeadLetter, type DtoClass, DurableModule, type DurableModuleAsyncOptions, type DurableModuleOptions, type DurableModuleSharedOptions, type DurableRetentionOptions, DurableStartClient, type DurableStepInterceptor, type DurableStepMeta, type DurableTopologyName, ENTITY_METADATA, ENTITY_ON_METADATA, Entity, EntityService, type ErrorClassWithCode, FederatedAppGateway, type FederatedAppGatewayOptions, IN_APP_RUN_REDIS_WORKER, IN_APP_WORKER_BINDING, IN_APP_WORKER_RUNNERS, IN_APP_WORKER_RUNTIME, type InAppWorkerBinding, InAppWorkerBootstrap, type IoSchema, type LazyContract, ON_ERROR_METADATA, ON_EVENT_BATCH_METADATA, ON_EVENT_METADATA, On, OnDurableEvent, OnError, type OnErrorMethod, OnWorkflowCompleted, OnWorkflowFailed, type OnWorkflowFailedOptions, type OnWorkflowSettledOptions, ProxyRunGateway, RUN_GATEWAY, RUN_REDIS_WORKER, type ResolvedTenantAuth, RunGatewayError, type RunGatewayErrorCode, type RunLookupStore, type RunRedisWorkerFn, RunRequestResponder, type RunRequestResponderOptions, type RunRequestTransport, STEP_INTERCEPTOR_METADATA, type StandaloneDurableOptions, Step, StepInterceptor, type StepOptions, StoreRunGateway, type SubscriberBatch, type SubscriberDebounce, type SubscriberDecorator, TENANT_AUTH, TENANT_REPUBLISH_MAX_LIMIT, type TenantCredentialsContract, type TenantDurableOptions, TenantEventRepublisher, type TenantFilter, type TenantLevel, type TenantRef, type TenantTokenOption, type TenantVerifierContract, type TenantVerifierInput, type TenantVerifierOption, ThinStepRegistrar, ThinWorkerBootstrap, ThinWorkflowRegistrar, UNSUPPORTED_RUN_REQUEST, type UserRef, WORKFLOW_METADATA, Workflow, type WorkflowAttributesOf, type WorkflowMeta, type WorkflowOptions, WorkflowService, attributesOf, entityConfigFor, eventBatchOf, federatedAppGateway, getDurableStepMeta, getEntityMeta, getOnEvents, getWorkflowMeta, inAppWorkerProviders, isDeadLetterHandler, isDrivingOperator, isOperatorRole, isStepInterceptor, onErrorCodesOf, tenantScheduleAnnouncement, thinWorkerProviders, unavailableRunGateway };
|