@dudousxd/nestjs-durable 0.58.0 → 0.59.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 +256 -135
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +82 -17
- package/dist/index.d.ts +82 -17
- package/dist/index.js +257 -136
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WorkflowCtx, SearchAttributes, WorkflowClass, StandardSchemaV1, StepError, OnEventEntry, OnErrorInput, LifecycleEventOf, WorkflowLifecycleEvent, WorkflowRef, SingletonConfig, ConcurrencyConfig, SearchAttributesSchema, EventBatchConfig, TenantVerifier, VerifiedTenant, TenantTokenSource, StateStore, Transport, NamedTransport, ControlPlane, StalledRunInfo, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowInputOf, StartOptions, RunResult, RunGateway, WorkflowEngine, EntityHandler, RunRequest, RunReply, DurableTopology, RunDetailOptions, RunDetail, FanPageQuery, FanPage, WorkflowRun, RunQuery, RunListItem, RunFacetQuery, RunFacetRow, RunValueAxis, RunValueFacetOptions, RunValueFacetRow, GroupHealth, RunWaiting, RepublishLifecycleTarget, RepublishLifecycleResult, WorkflowLifecycleLinks, EngineEvent, StepInvocation, LifecycleKind, TenantEvent, SignalOptions } from '@dudousxd/nestjs-durable-core';
|
|
1
|
+
import { WorkflowCtx, SearchAttributes, WorkflowClass, StandardSchemaV1, StepError, OnEventEntry, OnErrorInput, LifecycleEventOf, WorkflowLifecycleEvent, WorkflowRef, SingletonConfig, ConcurrencyConfig, SearchAttributesSchema, EventBatchConfig, TenantVerifier, VerifiedTenant, TenantTokenSource, StateStore, Transport, NamedTransport, ControlPlane, StalledRunInfo, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowInputOf, StartOptions, RunResult, RunGateway, WorkflowEngine, EntityHandler, RunRequest, RunReply, TenantFilter as TenantFilter$1, DurableTopology, RunDetailOptions, RunDetail, FanPageQuery, FanPage, WorkflowRun, RunQuery, RunListItem, RunFacetQuery, RunFacetRow, RunValueAxis, RunValueFacetOptions, RunValueFacetRow, GroupHealth, RunWaiting, RepublishLifecycleTarget, RepublishLifecycleResult, WorkflowLifecycleLinks, EngineEvent, StepInvocation, LifecycleKind, TenantEvent, SignalOptions } from '@dudousxd/nestjs-durable-core';
|
|
2
2
|
export { AttributeFilter, DynamicWorkflowCtx, EngineEvent, EventSubscription, InferSearchAttributes, LIFECYCLE_PENDING_TAG, LifecycleEventOf, LifecycleKind, OnErrorInput, OnEventEntry, RunDetail, RunGateway, RunListItem, RunQuery, RunSchedulesOptions, RunStatus, RunWaiting, ScheduledWorkflow, SearchAttributes, SearchAttributesSchema, StepCheckpoint, StepEvent, StepLogger, TenantTokenSource, TenantVerifier, VerifiedTenant, WorkflowCtx, WorkflowEngine, WorkflowHandler, WorkflowLifecycleEvent, WorkflowRun, hmacTenantVerifier, lifecycleRunId, lifecycleSourceOf, prevCronFireMs, readSearchAttributes, runCompletedEvent, runFailedEvent, runSchedules, scheduleRunIdAt, scheduledRunId, signTenantToken, triggeredRunsOf } from '@dudousxd/nestjs-durable-core';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { ConcurrencyOption, StartRunDeps, RunRedisWorkerOptions, RunningWorker, DurableWorkerRuntime } from '@dudousxd/durable-worker';
|
|
@@ -106,15 +106,30 @@ interface ContextAccessor {
|
|
|
106
106
|
* an app's own accessor, may not have it; durable then treats tenancy as off.
|
|
107
107
|
*/
|
|
108
108
|
tenant?(): TenantRef | undefined;
|
|
109
|
-
/** The context's `tenancy` switch: `{ enabled, kinds? }`. Optional, as above. */
|
|
109
|
+
/** The context's `tenancy` switch: `{ enabled, kinds?, required? }`. Optional, as above. */
|
|
110
110
|
tenancy?(): {
|
|
111
111
|
enabled: boolean;
|
|
112
112
|
kinds?: string[];
|
|
113
|
+
required?: boolean;
|
|
113
114
|
};
|
|
114
|
-
/**
|
|
115
|
+
/**
|
|
116
|
+
* How a lib must scope data right now. `kinds` picks the level of a nested tenant, `family` a
|
|
117
|
+
* secondary tenant, `required` overrides the context's (context ≥ 2.1). Optional, as above.
|
|
118
|
+
*/
|
|
115
119
|
tenantFilter?(options?: {
|
|
116
120
|
kinds?: string[];
|
|
121
|
+
family?: string;
|
|
122
|
+
required?: boolean;
|
|
117
123
|
}): TenantFilter;
|
|
124
|
+
/** Display labels keyed by tenant id (context ≥ 2.1). Optional, as above. */
|
|
125
|
+
tenantLabels?(tenants: TenantLevel[]): Promise<Record<string, string>>;
|
|
126
|
+
}
|
|
127
|
+
/** One level of a tenant chain (context ≥ 2.1). */
|
|
128
|
+
interface TenantLevel {
|
|
129
|
+
id: string;
|
|
130
|
+
kind: string;
|
|
131
|
+
slug?: string;
|
|
132
|
+
role?: string;
|
|
118
133
|
}
|
|
119
134
|
/** A tenant as the context reports it. Structural mirror of nestjs-context's `TenantRef`. */
|
|
120
135
|
interface TenantRef {
|
|
@@ -123,6 +138,10 @@ interface TenantRef {
|
|
|
123
138
|
source: string;
|
|
124
139
|
slug?: string;
|
|
125
140
|
role?: string;
|
|
141
|
+
/** The active chain, root first, this tenant last (context ≥ 2.1). */
|
|
142
|
+
chain?: TenantLevel[];
|
|
143
|
+
/** The secondary tenant family this ref belongs to (context ≥ 2.1). */
|
|
144
|
+
family?: string;
|
|
126
145
|
}
|
|
127
146
|
/** How a lib must scope data right now. Structural mirror of nestjs-context's `TenantFilter`. */
|
|
128
147
|
type TenantFilter = {
|
|
@@ -134,6 +153,7 @@ type TenantFilter = {
|
|
|
134
153
|
} | {
|
|
135
154
|
mode: 'tenant';
|
|
136
155
|
tenant: TenantRef;
|
|
156
|
+
chain?: TenantLevel[];
|
|
137
157
|
};
|
|
138
158
|
|
|
139
159
|
/** A class-validator DTO class — validated with the same `plainToInstance` + `validate` NestJS's
|
|
@@ -597,22 +617,34 @@ declare function eventBatchOf(meta: WorkflowMeta, target: object): EventBatchCon
|
|
|
597
617
|
*/
|
|
598
618
|
declare function getOnEvents(meta: WorkflowMeta, target: object): OnEventEntry[];
|
|
599
619
|
|
|
600
|
-
|
|
601
|
-
* Tenancy for durable: the CUSTOMER a run belongs to (`@dudousxd/nestjs-context`'s tenant), not the
|
|
602
|
-
* worker-pool `namespace`. A local, structural reader of the context contract — durable never imports
|
|
603
|
-
* nestjs-context, so it works with any context version or none at all: with the accessor (or its
|
|
604
|
-
* tenancy methods) missing, tenancy reads as off and durable behaves exactly as without it.
|
|
605
|
-
*/
|
|
606
|
-
/** The `tenancy` option of `DurableModule`. Same shape in every Aviary lib. */
|
|
607
|
-
type DurableTenancyOption = 'inherit' | false | {
|
|
608
|
-
/** `'inherit'` (default) follows `ContextModule`'s `tenancy.enabled`. */
|
|
620
|
+
type TenancyOption = 'inherit' | false | {
|
|
609
621
|
enabled?: 'inherit' | boolean;
|
|
610
|
-
/** Tenant kinds durable honours, instead of the context's own `kinds`. */
|
|
611
622
|
kinds?: string[];
|
|
612
|
-
|
|
623
|
+
family?: string;
|
|
624
|
+
required?: boolean;
|
|
613
625
|
nullRows?: 'tenantless' | 'shared';
|
|
614
626
|
};
|
|
615
627
|
|
|
628
|
+
/**
|
|
629
|
+
* Tenancy for durable: the CUSTOMER a run belongs to (`@dudousxd/nestjs-context`'s tenant), not the
|
|
630
|
+
* worker-pool `namespace`. Read through the local copy of the context's tenancy reader
|
|
631
|
+
* (`./tenancy-reader`): durable never imports nestjs-context, so it works with any context version
|
|
632
|
+
* or none at all. With the accessor (or its tenancy methods) missing, tenancy reads as off and
|
|
633
|
+
* durable behaves exactly as without it.
|
|
634
|
+
*/
|
|
635
|
+
/**
|
|
636
|
+
* The `tenancy` option of `DurableModule`. Same shape in every Aviary lib:
|
|
637
|
+
* - `enabled`: `'inherit'` (default) follows `ContextModule`'s `tenancy.enabled`;
|
|
638
|
+
* - `kinds`: the tenant kinds durable stamps and filters by. On a nested tenant (clinic → unit) the
|
|
639
|
+
* most specific level of the active chain whose kind is listed is the one used;
|
|
640
|
+
* - `family`: read a secondary tenant family (e.g. `'account'`) instead of the primary one;
|
|
641
|
+
* - `required`: with no tenant, an app-facing read or start throws the context's
|
|
642
|
+
* `TenantRequiredError` (403) instead of running tenantless. Defaults to the context's own
|
|
643
|
+
* `tenancy.required`. Durable's own work (turns, recovery, schedules, worker steps) never throws;
|
|
644
|
+
* - `nullRows: 'shared'`: a tenant also sees runs with no tenant (default `'tenantless'`: it does not).
|
|
645
|
+
*/
|
|
646
|
+
type DurableTenancyOption = TenancyOption;
|
|
647
|
+
|
|
616
648
|
/** What a tenant verifier receives for each request a tenant process sends. */
|
|
617
649
|
interface TenantVerifierInput {
|
|
618
650
|
/** The token presented on the request (the wire `tenant` field). */
|
|
@@ -1151,9 +1183,13 @@ declare class DurableModule {
|
|
|
1151
1183
|
declare class DurableStartClient {
|
|
1152
1184
|
private readonly options;
|
|
1153
1185
|
private readonly deps?;
|
|
1186
|
+
/** The context accessor, for the customer tenant a start claims (else the global slot). */
|
|
1187
|
+
private readonly accessor?;
|
|
1154
1188
|
private readonly tenant;
|
|
1155
1189
|
private readonly tenantToken;
|
|
1156
|
-
constructor(options: DurableModuleOptions, deps?: StartRunDeps | undefined
|
|
1190
|
+
constructor(options: DurableModuleOptions, deps?: StartRunDeps | undefined,
|
|
1191
|
+
/** The context accessor, for the customer tenant a start claims (else the global slot). */
|
|
1192
|
+
accessor?: ContextAccessor | undefined);
|
|
1157
1193
|
start<C extends WorkflowClass>(workflow: C, input: WorkflowInputOf<C>, runId?: string, opts?: StartOptions): Promise<RunResult>;
|
|
1158
1194
|
start(workflow: string, input: unknown, runId?: string, opts?: StartOptions): Promise<RunResult>;
|
|
1159
1195
|
cancel(_runId: string): Promise<void>;
|
|
@@ -1452,6 +1488,13 @@ declare class ProxyRunGateway implements RunGateway {
|
|
|
1452
1488
|
* stays keyed by `tenant`, never the token: the operator republishes by the run's namespace.
|
|
1453
1489
|
*/
|
|
1454
1490
|
private readonly tenantToken?;
|
|
1491
|
+
/**
|
|
1492
|
+
* The customer-tenancy filter of the request being served (durable's `tenancy` on this process).
|
|
1493
|
+
* The control plane answers for this process's namespace; this narrows it to the request's
|
|
1494
|
+
* customer tenant: lists and counts get the tenant predicate, and a run of another tenant reads
|
|
1495
|
+
* (and is controlled) as missing. Absent: no narrowing.
|
|
1496
|
+
*/
|
|
1497
|
+
private readonly tenantFilter?;
|
|
1455
1498
|
private readonly pending;
|
|
1456
1499
|
/** Verb → when to ask the control plane for it again, after it answered that it does not know it.
|
|
1457
1500
|
* During a rolling upgrade the control plane is several pods of mixed versions behind one queue,
|
|
@@ -1466,7 +1509,28 @@ declare class ProxyRunGateway implements RunGateway {
|
|
|
1466
1509
|
* Omit to send the raw `tenant` (prefix/network isolation only). The live-tail channel always
|
|
1467
1510
|
* stays keyed by `tenant`, never the token: the operator republishes by the run's namespace.
|
|
1468
1511
|
*/
|
|
1469
|
-
tenantToken?: TenantTokenSource | undefined
|
|
1512
|
+
tenantToken?: TenantTokenSource | undefined,
|
|
1513
|
+
/**
|
|
1514
|
+
* The customer-tenancy filter of the request being served (durable's `tenancy` on this process).
|
|
1515
|
+
* The control plane answers for this process's namespace; this narrows it to the request's
|
|
1516
|
+
* customer tenant: lists and counts get the tenant predicate, and a run of another tenant reads
|
|
1517
|
+
* (and is controlled) as missing. Absent: no narrowing.
|
|
1518
|
+
*/
|
|
1519
|
+
tenantFilter?: (() => TenantFilter$1) | undefined);
|
|
1520
|
+
/** The request's tenant filter when it can hide runs (`tenant` / `tenantless`), else undefined. */
|
|
1521
|
+
private restrictive;
|
|
1522
|
+
/**
|
|
1523
|
+
* Send `query`, narrowed to the runs the request may see. A tenant-required request with no
|
|
1524
|
+
* tenant rejects (never throws synchronously).
|
|
1525
|
+
*/
|
|
1526
|
+
private scoped;
|
|
1527
|
+
/** `run` when the request may see it, else null (an invisible run reads like a missing one). */
|
|
1528
|
+
private visible;
|
|
1529
|
+
/** Run a control call unless the request may not act on `runId` (then `null`, like a missing run).
|
|
1530
|
+
* Sent at once when nothing narrows the request. */
|
|
1531
|
+
private guarded;
|
|
1532
|
+
/** Before a control call: true when the request may NOT act on `runId`. */
|
|
1533
|
+
private hidden;
|
|
1470
1534
|
private handleReply;
|
|
1471
1535
|
private request;
|
|
1472
1536
|
private send;
|
|
@@ -1483,6 +1547,7 @@ declare class ProxyRunGateway implements RunGateway {
|
|
|
1483
1547
|
* to know the verb: it then answers with no data, or with an unsupported-request error.
|
|
1484
1548
|
*/
|
|
1485
1549
|
getRun(runId: string): Promise<WorkflowRun | null>;
|
|
1550
|
+
private getRunUnscoped;
|
|
1486
1551
|
private knownUnsupported;
|
|
1487
1552
|
/** The control plane's `StoreRunGateway` resolves each run's `waiting` descriptor; the reply carries
|
|
1488
1553
|
* it through as plain JSON, so a tenant's list rows name the wait too. */
|
|
@@ -1766,4 +1831,4 @@ declare class WorkflowService {
|
|
|
1766
1831
|
republishLifecycle(target: RepublishLifecycleTarget): Promise<RepublishLifecycleResult>;
|
|
1767
1832
|
}
|
|
1768
1833
|
|
|
1769
|
-
export { BAD_RUN_REQUEST, CONTEXT_ACCESSOR, type ContextAccessor, type ContextStore, type ContractClass, type ControlPlaneDurableOptions, DEAD_LETTER_METADATA, DURABLE_STEP_METADATA, DURABLE_WORKER_RUNNERS, DURABLE_WORKER_RUNTIME, DeadLetter, type DtoClass, DurableModule, type DurableModuleAsyncOptions, type DurableModuleOptions, type DurableModuleSharedOptions, type DurableRetentionOptions, DurableStartClient, type DurableStepInterceptor, type DurableStepMeta, type DurableTopologyName, ENTITY_METADATA, ENTITY_ON_METADATA, Entity, EntityService, type ErrorClassWithCode, IN_APP_RUN_REDIS_WORKER, IN_APP_WORKER_BINDING, IN_APP_WORKER_RUNNERS, IN_APP_WORKER_RUNTIME, type InAppWorkerBinding, InAppWorkerBootstrap, type IoSchema, type LazyContract, ON_ERROR_METADATA, ON_EVENT_BATCH_METADATA, ON_EVENT_METADATA, On, OnDurableEvent, OnError, type OnErrorMethod, OnWorkflowCompleted, OnWorkflowFailed, type OnWorkflowFailedOptions, type OnWorkflowSettledOptions, ProxyRunGateway, RUN_GATEWAY, RUN_REDIS_WORKER, RunGatewayError, type RunGatewayErrorCode, type RunLookupStore, type RunRedisWorkerFn, RunRequestResponder, type RunRequestResponderOptions, type RunRequestTransport, STEP_INTERCEPTOR_METADATA, type StandaloneDurableOptions, Step, StepInterceptor, type StepOptions, StoreRunGateway, type SubscriberBatch, type SubscriberDebounce, type SubscriberDecorator, TENANT_REPUBLISH_MAX_LIMIT, type TenantCredentialsContract, type TenantDurableOptions, TenantEventRepublisher, type TenantFilter, type TenantRef, type TenantTokenOption, type TenantVerifierContract, type TenantVerifierInput, type TenantVerifierOption, ThinStepRegistrar, ThinWorkerBootstrap, ThinWorkflowRegistrar, UNSUPPORTED_RUN_REQUEST, type UserRef, WORKFLOW_METADATA, Workflow, type WorkflowAttributesOf, type WorkflowMeta, type WorkflowOptions, WorkflowService, attributesOf, entityConfigFor, eventBatchOf, getDurableStepMeta, getEntityMeta, getOnEvents, getWorkflowMeta, inAppWorkerProviders, isDeadLetterHandler, isDrivingOperator, isOperatorRole, isStepInterceptor, onErrorCodesOf, thinWorkerProviders, unavailableRunGateway };
|
|
1834
|
+
export { BAD_RUN_REQUEST, CONTEXT_ACCESSOR, type ContextAccessor, type ContextStore, type ContractClass, type ControlPlaneDurableOptions, DEAD_LETTER_METADATA, DURABLE_STEP_METADATA, DURABLE_WORKER_RUNNERS, DURABLE_WORKER_RUNTIME, DeadLetter, type DtoClass, DurableModule, type DurableModuleAsyncOptions, type DurableModuleOptions, type DurableModuleSharedOptions, type DurableRetentionOptions, DurableStartClient, type DurableStepInterceptor, type DurableStepMeta, type DurableTopologyName, ENTITY_METADATA, ENTITY_ON_METADATA, Entity, EntityService, type ErrorClassWithCode, IN_APP_RUN_REDIS_WORKER, IN_APP_WORKER_BINDING, IN_APP_WORKER_RUNNERS, IN_APP_WORKER_RUNTIME, type InAppWorkerBinding, InAppWorkerBootstrap, type IoSchema, type LazyContract, ON_ERROR_METADATA, ON_EVENT_BATCH_METADATA, ON_EVENT_METADATA, On, OnDurableEvent, OnError, type OnErrorMethod, OnWorkflowCompleted, OnWorkflowFailed, type OnWorkflowFailedOptions, type OnWorkflowSettledOptions, ProxyRunGateway, RUN_GATEWAY, RUN_REDIS_WORKER, RunGatewayError, type RunGatewayErrorCode, type RunLookupStore, type RunRedisWorkerFn, RunRequestResponder, type RunRequestResponderOptions, type RunRequestTransport, STEP_INTERCEPTOR_METADATA, type StandaloneDurableOptions, Step, StepInterceptor, type StepOptions, StoreRunGateway, type SubscriberBatch, type SubscriberDebounce, type SubscriberDecorator, TENANT_REPUBLISH_MAX_LIMIT, type TenantCredentialsContract, type TenantDurableOptions, TenantEventRepublisher, type TenantFilter, type TenantLevel, type TenantRef, type TenantTokenOption, type TenantVerifierContract, type TenantVerifierInput, type TenantVerifierOption, ThinStepRegistrar, ThinWorkerBootstrap, ThinWorkflowRegistrar, UNSUPPORTED_RUN_REQUEST, type UserRef, WORKFLOW_METADATA, Workflow, type WorkflowAttributesOf, type WorkflowMeta, type WorkflowOptions, WorkflowService, attributesOf, entityConfigFor, eventBatchOf, getDurableStepMeta, getEntityMeta, getOnEvents, getWorkflowMeta, inAppWorkerProviders, isDeadLetterHandler, isDrivingOperator, isOperatorRole, isStepInterceptor, onErrorCodesOf, thinWorkerProviders, unavailableRunGateway };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WorkflowCtx, SearchAttributes, WorkflowClass, StandardSchemaV1, StepError, OnEventEntry, OnErrorInput, LifecycleEventOf, WorkflowLifecycleEvent, WorkflowRef, SingletonConfig, ConcurrencyConfig, SearchAttributesSchema, EventBatchConfig, TenantVerifier, VerifiedTenant, TenantTokenSource, StateStore, Transport, NamedTransport, ControlPlane, StalledRunInfo, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowInputOf, StartOptions, RunResult, RunGateway, WorkflowEngine, EntityHandler, RunRequest, RunReply, DurableTopology, RunDetailOptions, RunDetail, FanPageQuery, FanPage, WorkflowRun, RunQuery, RunListItem, RunFacetQuery, RunFacetRow, RunValueAxis, RunValueFacetOptions, RunValueFacetRow, GroupHealth, RunWaiting, RepublishLifecycleTarget, RepublishLifecycleResult, WorkflowLifecycleLinks, EngineEvent, StepInvocation, LifecycleKind, TenantEvent, SignalOptions } from '@dudousxd/nestjs-durable-core';
|
|
1
|
+
import { WorkflowCtx, SearchAttributes, WorkflowClass, StandardSchemaV1, StepError, OnEventEntry, OnErrorInput, LifecycleEventOf, WorkflowLifecycleEvent, WorkflowRef, SingletonConfig, ConcurrencyConfig, SearchAttributesSchema, EventBatchConfig, TenantVerifier, VerifiedTenant, TenantTokenSource, StateStore, Transport, NamedTransport, ControlPlane, StalledRunInfo, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowInputOf, StartOptions, RunResult, RunGateway, WorkflowEngine, EntityHandler, RunRequest, RunReply, TenantFilter as TenantFilter$1, DurableTopology, RunDetailOptions, RunDetail, FanPageQuery, FanPage, WorkflowRun, RunQuery, RunListItem, RunFacetQuery, RunFacetRow, RunValueAxis, RunValueFacetOptions, RunValueFacetRow, GroupHealth, RunWaiting, RepublishLifecycleTarget, RepublishLifecycleResult, WorkflowLifecycleLinks, EngineEvent, StepInvocation, LifecycleKind, TenantEvent, SignalOptions } from '@dudousxd/nestjs-durable-core';
|
|
2
2
|
export { AttributeFilter, DynamicWorkflowCtx, EngineEvent, EventSubscription, InferSearchAttributes, LIFECYCLE_PENDING_TAG, LifecycleEventOf, LifecycleKind, OnErrorInput, OnEventEntry, RunDetail, RunGateway, RunListItem, RunQuery, RunSchedulesOptions, RunStatus, RunWaiting, ScheduledWorkflow, SearchAttributes, SearchAttributesSchema, StepCheckpoint, StepEvent, StepLogger, TenantTokenSource, TenantVerifier, VerifiedTenant, WorkflowCtx, WorkflowEngine, WorkflowHandler, WorkflowLifecycleEvent, WorkflowRun, hmacTenantVerifier, lifecycleRunId, lifecycleSourceOf, prevCronFireMs, readSearchAttributes, runCompletedEvent, runFailedEvent, runSchedules, scheduleRunIdAt, scheduledRunId, signTenantToken, triggeredRunsOf } from '@dudousxd/nestjs-durable-core';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { ConcurrencyOption, StartRunDeps, RunRedisWorkerOptions, RunningWorker, DurableWorkerRuntime } from '@dudousxd/durable-worker';
|
|
@@ -106,15 +106,30 @@ interface ContextAccessor {
|
|
|
106
106
|
* an app's own accessor, may not have it; durable then treats tenancy as off.
|
|
107
107
|
*/
|
|
108
108
|
tenant?(): TenantRef | undefined;
|
|
109
|
-
/** The context's `tenancy` switch: `{ enabled, kinds? }`. Optional, as above. */
|
|
109
|
+
/** The context's `tenancy` switch: `{ enabled, kinds?, required? }`. Optional, as above. */
|
|
110
110
|
tenancy?(): {
|
|
111
111
|
enabled: boolean;
|
|
112
112
|
kinds?: string[];
|
|
113
|
+
required?: boolean;
|
|
113
114
|
};
|
|
114
|
-
/**
|
|
115
|
+
/**
|
|
116
|
+
* How a lib must scope data right now. `kinds` picks the level of a nested tenant, `family` a
|
|
117
|
+
* secondary tenant, `required` overrides the context's (context ≥ 2.1). Optional, as above.
|
|
118
|
+
*/
|
|
115
119
|
tenantFilter?(options?: {
|
|
116
120
|
kinds?: string[];
|
|
121
|
+
family?: string;
|
|
122
|
+
required?: boolean;
|
|
117
123
|
}): TenantFilter;
|
|
124
|
+
/** Display labels keyed by tenant id (context ≥ 2.1). Optional, as above. */
|
|
125
|
+
tenantLabels?(tenants: TenantLevel[]): Promise<Record<string, string>>;
|
|
126
|
+
}
|
|
127
|
+
/** One level of a tenant chain (context ≥ 2.1). */
|
|
128
|
+
interface TenantLevel {
|
|
129
|
+
id: string;
|
|
130
|
+
kind: string;
|
|
131
|
+
slug?: string;
|
|
132
|
+
role?: string;
|
|
118
133
|
}
|
|
119
134
|
/** A tenant as the context reports it. Structural mirror of nestjs-context's `TenantRef`. */
|
|
120
135
|
interface TenantRef {
|
|
@@ -123,6 +138,10 @@ interface TenantRef {
|
|
|
123
138
|
source: string;
|
|
124
139
|
slug?: string;
|
|
125
140
|
role?: string;
|
|
141
|
+
/** The active chain, root first, this tenant last (context ≥ 2.1). */
|
|
142
|
+
chain?: TenantLevel[];
|
|
143
|
+
/** The secondary tenant family this ref belongs to (context ≥ 2.1). */
|
|
144
|
+
family?: string;
|
|
126
145
|
}
|
|
127
146
|
/** How a lib must scope data right now. Structural mirror of nestjs-context's `TenantFilter`. */
|
|
128
147
|
type TenantFilter = {
|
|
@@ -134,6 +153,7 @@ type TenantFilter = {
|
|
|
134
153
|
} | {
|
|
135
154
|
mode: 'tenant';
|
|
136
155
|
tenant: TenantRef;
|
|
156
|
+
chain?: TenantLevel[];
|
|
137
157
|
};
|
|
138
158
|
|
|
139
159
|
/** A class-validator DTO class — validated with the same `plainToInstance` + `validate` NestJS's
|
|
@@ -597,22 +617,34 @@ declare function eventBatchOf(meta: WorkflowMeta, target: object): EventBatchCon
|
|
|
597
617
|
*/
|
|
598
618
|
declare function getOnEvents(meta: WorkflowMeta, target: object): OnEventEntry[];
|
|
599
619
|
|
|
600
|
-
|
|
601
|
-
* Tenancy for durable: the CUSTOMER a run belongs to (`@dudousxd/nestjs-context`'s tenant), not the
|
|
602
|
-
* worker-pool `namespace`. A local, structural reader of the context contract — durable never imports
|
|
603
|
-
* nestjs-context, so it works with any context version or none at all: with the accessor (or its
|
|
604
|
-
* tenancy methods) missing, tenancy reads as off and durable behaves exactly as without it.
|
|
605
|
-
*/
|
|
606
|
-
/** The `tenancy` option of `DurableModule`. Same shape in every Aviary lib. */
|
|
607
|
-
type DurableTenancyOption = 'inherit' | false | {
|
|
608
|
-
/** `'inherit'` (default) follows `ContextModule`'s `tenancy.enabled`. */
|
|
620
|
+
type TenancyOption = 'inherit' | false | {
|
|
609
621
|
enabled?: 'inherit' | boolean;
|
|
610
|
-
/** Tenant kinds durable honours, instead of the context's own `kinds`. */
|
|
611
622
|
kinds?: string[];
|
|
612
|
-
|
|
623
|
+
family?: string;
|
|
624
|
+
required?: boolean;
|
|
613
625
|
nullRows?: 'tenantless' | 'shared';
|
|
614
626
|
};
|
|
615
627
|
|
|
628
|
+
/**
|
|
629
|
+
* Tenancy for durable: the CUSTOMER a run belongs to (`@dudousxd/nestjs-context`'s tenant), not the
|
|
630
|
+
* worker-pool `namespace`. Read through the local copy of the context's tenancy reader
|
|
631
|
+
* (`./tenancy-reader`): durable never imports nestjs-context, so it works with any context version
|
|
632
|
+
* or none at all. With the accessor (or its tenancy methods) missing, tenancy reads as off and
|
|
633
|
+
* durable behaves exactly as without it.
|
|
634
|
+
*/
|
|
635
|
+
/**
|
|
636
|
+
* The `tenancy` option of `DurableModule`. Same shape in every Aviary lib:
|
|
637
|
+
* - `enabled`: `'inherit'` (default) follows `ContextModule`'s `tenancy.enabled`;
|
|
638
|
+
* - `kinds`: the tenant kinds durable stamps and filters by. On a nested tenant (clinic → unit) the
|
|
639
|
+
* most specific level of the active chain whose kind is listed is the one used;
|
|
640
|
+
* - `family`: read a secondary tenant family (e.g. `'account'`) instead of the primary one;
|
|
641
|
+
* - `required`: with no tenant, an app-facing read or start throws the context's
|
|
642
|
+
* `TenantRequiredError` (403) instead of running tenantless. Defaults to the context's own
|
|
643
|
+
* `tenancy.required`. Durable's own work (turns, recovery, schedules, worker steps) never throws;
|
|
644
|
+
* - `nullRows: 'shared'`: a tenant also sees runs with no tenant (default `'tenantless'`: it does not).
|
|
645
|
+
*/
|
|
646
|
+
type DurableTenancyOption = TenancyOption;
|
|
647
|
+
|
|
616
648
|
/** What a tenant verifier receives for each request a tenant process sends. */
|
|
617
649
|
interface TenantVerifierInput {
|
|
618
650
|
/** The token presented on the request (the wire `tenant` field). */
|
|
@@ -1151,9 +1183,13 @@ declare class DurableModule {
|
|
|
1151
1183
|
declare class DurableStartClient {
|
|
1152
1184
|
private readonly options;
|
|
1153
1185
|
private readonly deps?;
|
|
1186
|
+
/** The context accessor, for the customer tenant a start claims (else the global slot). */
|
|
1187
|
+
private readonly accessor?;
|
|
1154
1188
|
private readonly tenant;
|
|
1155
1189
|
private readonly tenantToken;
|
|
1156
|
-
constructor(options: DurableModuleOptions, deps?: StartRunDeps | undefined
|
|
1190
|
+
constructor(options: DurableModuleOptions, deps?: StartRunDeps | undefined,
|
|
1191
|
+
/** The context accessor, for the customer tenant a start claims (else the global slot). */
|
|
1192
|
+
accessor?: ContextAccessor | undefined);
|
|
1157
1193
|
start<C extends WorkflowClass>(workflow: C, input: WorkflowInputOf<C>, runId?: string, opts?: StartOptions): Promise<RunResult>;
|
|
1158
1194
|
start(workflow: string, input: unknown, runId?: string, opts?: StartOptions): Promise<RunResult>;
|
|
1159
1195
|
cancel(_runId: string): Promise<void>;
|
|
@@ -1452,6 +1488,13 @@ declare class ProxyRunGateway implements RunGateway {
|
|
|
1452
1488
|
* stays keyed by `tenant`, never the token: the operator republishes by the run's namespace.
|
|
1453
1489
|
*/
|
|
1454
1490
|
private readonly tenantToken?;
|
|
1491
|
+
/**
|
|
1492
|
+
* The customer-tenancy filter of the request being served (durable's `tenancy` on this process).
|
|
1493
|
+
* The control plane answers for this process's namespace; this narrows it to the request's
|
|
1494
|
+
* customer tenant: lists and counts get the tenant predicate, and a run of another tenant reads
|
|
1495
|
+
* (and is controlled) as missing. Absent: no narrowing.
|
|
1496
|
+
*/
|
|
1497
|
+
private readonly tenantFilter?;
|
|
1455
1498
|
private readonly pending;
|
|
1456
1499
|
/** Verb → when to ask the control plane for it again, after it answered that it does not know it.
|
|
1457
1500
|
* During a rolling upgrade the control plane is several pods of mixed versions behind one queue,
|
|
@@ -1466,7 +1509,28 @@ declare class ProxyRunGateway implements RunGateway {
|
|
|
1466
1509
|
* Omit to send the raw `tenant` (prefix/network isolation only). The live-tail channel always
|
|
1467
1510
|
* stays keyed by `tenant`, never the token: the operator republishes by the run's namespace.
|
|
1468
1511
|
*/
|
|
1469
|
-
tenantToken?: TenantTokenSource | undefined
|
|
1512
|
+
tenantToken?: TenantTokenSource | undefined,
|
|
1513
|
+
/**
|
|
1514
|
+
* The customer-tenancy filter of the request being served (durable's `tenancy` on this process).
|
|
1515
|
+
* The control plane answers for this process's namespace; this narrows it to the request's
|
|
1516
|
+
* customer tenant: lists and counts get the tenant predicate, and a run of another tenant reads
|
|
1517
|
+
* (and is controlled) as missing. Absent: no narrowing.
|
|
1518
|
+
*/
|
|
1519
|
+
tenantFilter?: (() => TenantFilter$1) | undefined);
|
|
1520
|
+
/** The request's tenant filter when it can hide runs (`tenant` / `tenantless`), else undefined. */
|
|
1521
|
+
private restrictive;
|
|
1522
|
+
/**
|
|
1523
|
+
* Send `query`, narrowed to the runs the request may see. A tenant-required request with no
|
|
1524
|
+
* tenant rejects (never throws synchronously).
|
|
1525
|
+
*/
|
|
1526
|
+
private scoped;
|
|
1527
|
+
/** `run` when the request may see it, else null (an invisible run reads like a missing one). */
|
|
1528
|
+
private visible;
|
|
1529
|
+
/** Run a control call unless the request may not act on `runId` (then `null`, like a missing run).
|
|
1530
|
+
* Sent at once when nothing narrows the request. */
|
|
1531
|
+
private guarded;
|
|
1532
|
+
/** Before a control call: true when the request may NOT act on `runId`. */
|
|
1533
|
+
private hidden;
|
|
1470
1534
|
private handleReply;
|
|
1471
1535
|
private request;
|
|
1472
1536
|
private send;
|
|
@@ -1483,6 +1547,7 @@ declare class ProxyRunGateway implements RunGateway {
|
|
|
1483
1547
|
* to know the verb: it then answers with no data, or with an unsupported-request error.
|
|
1484
1548
|
*/
|
|
1485
1549
|
getRun(runId: string): Promise<WorkflowRun | null>;
|
|
1550
|
+
private getRunUnscoped;
|
|
1486
1551
|
private knownUnsupported;
|
|
1487
1552
|
/** The control plane's `StoreRunGateway` resolves each run's `waiting` descriptor; the reply carries
|
|
1488
1553
|
* it through as plain JSON, so a tenant's list rows name the wait too. */
|
|
@@ -1766,4 +1831,4 @@ declare class WorkflowService {
|
|
|
1766
1831
|
republishLifecycle(target: RepublishLifecycleTarget): Promise<RepublishLifecycleResult>;
|
|
1767
1832
|
}
|
|
1768
1833
|
|
|
1769
|
-
export { BAD_RUN_REQUEST, CONTEXT_ACCESSOR, type ContextAccessor, type ContextStore, type ContractClass, type ControlPlaneDurableOptions, DEAD_LETTER_METADATA, DURABLE_STEP_METADATA, DURABLE_WORKER_RUNNERS, DURABLE_WORKER_RUNTIME, DeadLetter, type DtoClass, DurableModule, type DurableModuleAsyncOptions, type DurableModuleOptions, type DurableModuleSharedOptions, type DurableRetentionOptions, DurableStartClient, type DurableStepInterceptor, type DurableStepMeta, type DurableTopologyName, ENTITY_METADATA, ENTITY_ON_METADATA, Entity, EntityService, type ErrorClassWithCode, IN_APP_RUN_REDIS_WORKER, IN_APP_WORKER_BINDING, IN_APP_WORKER_RUNNERS, IN_APP_WORKER_RUNTIME, type InAppWorkerBinding, InAppWorkerBootstrap, type IoSchema, type LazyContract, ON_ERROR_METADATA, ON_EVENT_BATCH_METADATA, ON_EVENT_METADATA, On, OnDurableEvent, OnError, type OnErrorMethod, OnWorkflowCompleted, OnWorkflowFailed, type OnWorkflowFailedOptions, type OnWorkflowSettledOptions, ProxyRunGateway, RUN_GATEWAY, RUN_REDIS_WORKER, RunGatewayError, type RunGatewayErrorCode, type RunLookupStore, type RunRedisWorkerFn, RunRequestResponder, type RunRequestResponderOptions, type RunRequestTransport, STEP_INTERCEPTOR_METADATA, type StandaloneDurableOptions, Step, StepInterceptor, type StepOptions, StoreRunGateway, type SubscriberBatch, type SubscriberDebounce, type SubscriberDecorator, TENANT_REPUBLISH_MAX_LIMIT, type TenantCredentialsContract, type TenantDurableOptions, TenantEventRepublisher, type TenantFilter, type TenantRef, type TenantTokenOption, type TenantVerifierContract, type TenantVerifierInput, type TenantVerifierOption, ThinStepRegistrar, ThinWorkerBootstrap, ThinWorkflowRegistrar, UNSUPPORTED_RUN_REQUEST, type UserRef, WORKFLOW_METADATA, Workflow, type WorkflowAttributesOf, type WorkflowMeta, type WorkflowOptions, WorkflowService, attributesOf, entityConfigFor, eventBatchOf, getDurableStepMeta, getEntityMeta, getOnEvents, getWorkflowMeta, inAppWorkerProviders, isDeadLetterHandler, isDrivingOperator, isOperatorRole, isStepInterceptor, onErrorCodesOf, thinWorkerProviders, unavailableRunGateway };
|
|
1834
|
+
export { BAD_RUN_REQUEST, CONTEXT_ACCESSOR, type ContextAccessor, type ContextStore, type ContractClass, type ControlPlaneDurableOptions, DEAD_LETTER_METADATA, DURABLE_STEP_METADATA, DURABLE_WORKER_RUNNERS, DURABLE_WORKER_RUNTIME, DeadLetter, type DtoClass, DurableModule, type DurableModuleAsyncOptions, type DurableModuleOptions, type DurableModuleSharedOptions, type DurableRetentionOptions, DurableStartClient, type DurableStepInterceptor, type DurableStepMeta, type DurableTopologyName, ENTITY_METADATA, ENTITY_ON_METADATA, Entity, EntityService, type ErrorClassWithCode, IN_APP_RUN_REDIS_WORKER, IN_APP_WORKER_BINDING, IN_APP_WORKER_RUNNERS, IN_APP_WORKER_RUNTIME, type InAppWorkerBinding, InAppWorkerBootstrap, type IoSchema, type LazyContract, ON_ERROR_METADATA, ON_EVENT_BATCH_METADATA, ON_EVENT_METADATA, On, OnDurableEvent, OnError, type OnErrorMethod, OnWorkflowCompleted, OnWorkflowFailed, type OnWorkflowFailedOptions, type OnWorkflowSettledOptions, ProxyRunGateway, RUN_GATEWAY, RUN_REDIS_WORKER, RunGatewayError, type RunGatewayErrorCode, type RunLookupStore, type RunRedisWorkerFn, RunRequestResponder, type RunRequestResponderOptions, type RunRequestTransport, STEP_INTERCEPTOR_METADATA, type StandaloneDurableOptions, Step, StepInterceptor, type StepOptions, StoreRunGateway, type SubscriberBatch, type SubscriberDebounce, type SubscriberDecorator, TENANT_REPUBLISH_MAX_LIMIT, type TenantCredentialsContract, type TenantDurableOptions, TenantEventRepublisher, type TenantFilter, type TenantLevel, type TenantRef, type TenantTokenOption, type TenantVerifierContract, type TenantVerifierInput, type TenantVerifierOption, ThinStepRegistrar, ThinWorkerBootstrap, ThinWorkflowRegistrar, UNSUPPORTED_RUN_REQUEST, type UserRef, WORKFLOW_METADATA, Workflow, type WorkflowAttributesOf, type WorkflowMeta, type WorkflowOptions, WorkflowService, attributesOf, entityConfigFor, eventBatchOf, getDurableStepMeta, getEntityMeta, getOnEvents, getWorkflowMeta, inAppWorkerProviders, isDeadLetterHandler, isDrivingOperator, isOperatorRole, isStepInterceptor, onErrorCodesOf, thinWorkerProviders, unavailableRunGateway };
|