@dudousxd/nestjs-durable 0.64.0 → 0.66.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 +752 -359
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +216 -23
- package/dist/index.d.ts +216 -23
- package/dist/index.js +605 -212
- package/dist/index.js.map +1 -1
- package/dist/migrate-from-nestjs-workflows.cjs +8 -2
- package/dist/migrate-from-nestjs-workflows.cjs.map +1 -1
- package/dist/migrate-from-nestjs-workflows.js +8 -2
- package/dist/migrate-from-nestjs-workflows.js.map +1 -1
- package/package.json +4 -4
- package/skills/durable-setup/SKILL.md +5 -1
- package/skills/durable-signals-and-timers/SKILL.md +12 -3
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,
|
|
1
|
+
import { WorkflowCtx, SearchAttributes, WorkflowClass, StandardSchemaV1, StepError, OnEventEntry, OnErrorInput, LifecycleEventOf, WorkflowLifecycleEvent, WorkflowRef, SingletonConfig, ConcurrencyConfig, SearchAttributesSchema, EventBatchConfig, TenantVerifier, VerifiedTenant, TenantTokenSource, StateStore, Transport, NamedTransport, ControlPlane, StalledRunInfo, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, SignalOptions, RunResult, StartRunMessage, WorkflowInputOf, StartOptions, WorkflowStartClient, ScheduleAnnouncement, RunGateway, WorkflowEngine, EntityHandler, DurableTopology, RunDetailOptions, RunDetail, FanPageQuery, FanPage, WorkflowRun, RunQuery, RunListItem, RunFacetQuery, RunFacetRow, RunValueAxis, RunValueFacetOptions, RunValueFacetRow, RunWaiting, WorkflowLifecycleLinks, LifecycleKind, GroupHealth, ScheduleListQuery, ScheduleDescription, RepublishLifecycleTarget, RepublishLifecycleResult, ScheduleAction, EngineEvent, RunRequest, RunReply, TenantFilter as TenantFilter$1, StepInvocation, TenantEvent } from '@dudousxd/nestjs-durable-core';
|
|
2
2
|
export { AttributeFilter, DuplicateDurableCopyError, DynamicWorkflowCtx, EngineEvent, EventSubscription, InferSearchAttributes, LIFECYCLE_PENDING_TAG, LifecycleEventOf, LifecycleKind, OnErrorInput, OnEventEntry, RunDetail, RunGateway, RunListItem, RunQuery, RunSchedulesOptions, RunStatus, RunWaiting, ScheduledWorkflow, SearchAttributes, SearchAttributesSchema, StepCheckpoint, StepEvent, StepLogger, TenantTokenSource, TenantVerifier, VerifiedTenant, WorkflowCtx, WorkflowEngine, WorkflowHandler, WorkflowLifecycleEvent, WorkflowRun, hmacTenantVerifier, lifecycleRunId, lifecycleSourceOf, prevCronFireMs, readSearchAttributes, runCompletedEvent, runFailedEvent, runSchedules, scheduleRunIdAt, scheduledRunId, signTenantToken, triggeredRunsOf } from '@dudousxd/nestjs-durable-core';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { ConcurrencyOption, StartRunDeps, RunRedisWorkerOptions, RunningWorker, DurableWorkerRuntime } from '@dudousxd/durable-worker';
|
|
@@ -166,6 +166,21 @@ type DtoClass = new (...args: any[]) => object;
|
|
|
166
166
|
* constructor is a DTO. A zod schema older than 3.24 (no `~standard`) still works through its `parse`.
|
|
167
167
|
*/
|
|
168
168
|
type IoSchema = StandardSchemaV1 | DtoClass | z.ZodType;
|
|
169
|
+
/**
|
|
170
|
+
* The value a schema parses to, which is what `run(ctx, input)`, `validateInput` and the `singleton`
|
|
171
|
+
* / `concurrency` keys receive: a Standard Schema's output type (`z.output` for zod), a DTO class's
|
|
172
|
+
* instance, `unknown` without a schema. Use it to type `run`'s input from the same schema:
|
|
173
|
+
*
|
|
174
|
+
* ```ts
|
|
175
|
+
* const Input = z.object({ companyId: z.string() });
|
|
176
|
+
*
|
|
177
|
+
* @Workflow({ name: 'sync', input: Input, singleton: { key: (input) => input.companyId } })
|
|
178
|
+
* class SyncWorkflow {
|
|
179
|
+
* async run(ctx: WorkflowCtx, input: InferWorkflowInput<typeof Input>) {}
|
|
180
|
+
* }
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
type InferWorkflowInput<S> = [S] extends [undefined] ? unknown : [S] extends [StandardSchemaV1] ? StandardSchemaV1.InferOutput<S> : [S] extends [z.ZodType] ? z.output<S> : [S] extends [DtoClass] ? InstanceType<S> : unknown;
|
|
169
184
|
|
|
170
185
|
declare const WORKFLOW_METADATA: unique symbol;
|
|
171
186
|
interface WorkflowMeta {
|
|
@@ -208,7 +223,14 @@ interface WorkflowMeta {
|
|
|
208
223
|
* `WorkflowOptions`. */
|
|
209
224
|
requires?: string[] | undefined;
|
|
210
225
|
}
|
|
211
|
-
|
|
226
|
+
/**
|
|
227
|
+
* `@Workflow` options. `S` is the `input` schema's type, inferred from the option: the `singleton`
|
|
228
|
+
* and `concurrency` keys and `validateInput` then take the schema's parsed type (see
|
|
229
|
+
* {@link InferWorkflowInput}); without an `input` schema they take `unknown`, as they always did.
|
|
230
|
+
* Written without a type argument (`const opts: WorkflowOptions = …`, an interface extending it),
|
|
231
|
+
* it accepts any `input` schema and the callbacks take `unknown`, as before.
|
|
232
|
+
*/
|
|
233
|
+
interface WorkflowOptions<S extends IoSchema | undefined = IoSchema | undefined> {
|
|
212
234
|
name: string;
|
|
213
235
|
version?: string;
|
|
214
236
|
/**
|
|
@@ -238,18 +260,20 @@ interface WorkflowOptions {
|
|
|
238
260
|
* Serialize runs of this workflow that share a key — a durable FIFO mutex. e.g.
|
|
239
261
|
* `singleton: { key: (input) => `base:${input.baseId}` }` runs at most one pipeline per base at a
|
|
240
262
|
* time; same-key runs queue (suspended) and admit in creation order as slots free. `limit` (default
|
|
241
|
-
* 1) raises the concurrency.
|
|
263
|
+
* 1) raises the concurrency. With an `input` schema, `key` receives the parsed input (typed from
|
|
264
|
+
* the schema, the same value `run` gets); without one, the input as sent (`unknown`).
|
|
242
265
|
*/
|
|
243
|
-
singleton?: SingletonConfig
|
|
266
|
+
singleton?: SingletonConfig<InferWorkflowInput<S>>;
|
|
244
267
|
/**
|
|
245
268
|
* A start-time concurrency QUOTA: at most `limit` runs sharing a key in flight, and a start over it
|
|
246
269
|
* is REJECTED (`ConcurrencyLimitError`, nothing created) rather than queued. e.g.
|
|
247
270
|
* `concurrency: { key: (input) => `tenant:${input.tenantId}`, limit: 8 }` caps what one tenant can
|
|
248
271
|
* have executing at once. The key is shared across workflows; `limit` may be a (async) function of
|
|
249
272
|
* the key for per-plan limits; `countStatuses` narrows what occupies a slot (default: every
|
|
250
|
-
* non-terminal status). Use `singleton` instead when excess runs should wait their turn.
|
|
273
|
+
* non-terminal status). Use `singleton` instead when excess runs should wait their turn. With an
|
|
274
|
+
* `input` schema, `key` receives the parsed input, typed from the schema, like `singleton`'s.
|
|
251
275
|
*/
|
|
252
|
-
concurrency?: ConcurrencyConfig
|
|
276
|
+
concurrency?: ConcurrencyConfig<InferWorkflowInput<S>>;
|
|
253
277
|
/**
|
|
254
278
|
* Max wall-clock lifetime for a run of this workflow (e.g. `'2h'`, `'7 days'`, or ms), counted from
|
|
255
279
|
* the run's creation. A run that outlives it is moved to `cancelled` (`execution_timeout`) by the
|
|
@@ -280,9 +304,10 @@ interface WorkflowOptions {
|
|
|
280
304
|
* workflow — bump `version`. A stored input that no longer parses fails the run with
|
|
281
305
|
* `code: 'invalid_input'`.
|
|
282
306
|
*
|
|
283
|
-
* `@Workflow({ name: 'checkout', input: CheckoutInput })` or `input: z.object({ … })`.
|
|
307
|
+
* `@Workflow({ name: 'checkout', input: CheckoutInput })` or `input: z.object({ … })`. Type `run`'s
|
|
308
|
+
* input from the same schema with `InferWorkflowInput<typeof CheckoutInput>`.
|
|
284
309
|
*/
|
|
285
|
-
input?:
|
|
310
|
+
input?: S;
|
|
286
311
|
/**
|
|
287
312
|
* The run's output schema (same forms as {@link input}). The value `run()` returns is parsed before
|
|
288
313
|
* the run completes, and the parsed value is what the run stores as its output. A mismatch fails the
|
|
@@ -292,9 +317,9 @@ interface WorkflowOptions {
|
|
|
292
317
|
/**
|
|
293
318
|
* A custom check at `start` (throw to reject) for a rule a schema can't express — a cross-field
|
|
294
319
|
* invariant, an async lookup. It runs after `input` parses and receives the parsed value (the input
|
|
295
|
-
* as sent when there is no `input` schema).
|
|
320
|
+
* as sent when there is no `input` schema), typed from the schema.
|
|
296
321
|
*/
|
|
297
|
-
validateInput?: (input:
|
|
322
|
+
validateInput?: (input: InferWorkflowInput<S>) => void | Promise<void>;
|
|
298
323
|
/**
|
|
299
324
|
* Validate this workflow's {@link WorkflowCtx.upsertSearchAttributes} writes against a **Standard
|
|
300
325
|
* Schema** (https://standardschema.dev — zod 3.24+, valibot, arktype, …). `ctx.upsertSearchAttributes`
|
|
@@ -349,7 +374,7 @@ interface WorkflowOptions {
|
|
|
349
374
|
* Marks a provider class as a durable workflow. Its `run(ctx, input)` method becomes the
|
|
350
375
|
* workflow function the engine executes and replays.
|
|
351
376
|
*/
|
|
352
|
-
declare function Workflow(options: WorkflowOptions): ClassDecorator;
|
|
377
|
+
declare function Workflow<S extends IoSchema | undefined = undefined>(options: WorkflowOptions<S>): ClassDecorator;
|
|
353
378
|
declare function getWorkflowMeta(target: Function): WorkflowMeta | undefined;
|
|
354
379
|
declare const DURABLE_STEP_METADATA: unique symbol;
|
|
355
380
|
interface DurableStepMeta {
|
|
@@ -1219,6 +1244,46 @@ declare class DurableModule {
|
|
|
1219
1244
|
private static build;
|
|
1220
1245
|
}
|
|
1221
1246
|
|
|
1247
|
+
/**
|
|
1248
|
+
* The `@Workflow` options a tenant's start applies itself, before it publishes the start-run: the
|
|
1249
|
+
* ones that are functions of the input, which the control plane (knowing the workflow by name
|
|
1250
|
+
* alone) cannot evaluate. Declared by `ThinWorkflowRegistrar` for every `@Workflow` it discovers.
|
|
1251
|
+
*/
|
|
1252
|
+
interface TenantWorkflowStartPolicy {
|
|
1253
|
+
/** `@Workflow({ input })`: parses the input once (throwing rejects the start before anything is
|
|
1254
|
+
* published); `validateInput` and the singleton and concurrency keys read the parsed value. */
|
|
1255
|
+
parseInput?: ((input: unknown) => unknown) | undefined;
|
|
1256
|
+
/** `@Workflow({ validateInput })`: rejects the start (throws) before anything is published. It
|
|
1257
|
+
* receives the value `parseInput` returned, or the input as sent without one. */
|
|
1258
|
+
validateInput?: ((input: unknown) => void | Promise<void>) | undefined;
|
|
1259
|
+
/** `@Workflow({ singleton })`: its key is evaluated here and carried on the start-run. */
|
|
1260
|
+
singleton?: SingletonConfig | undefined;
|
|
1261
|
+
/** `@Workflow({ concurrency })`: the default quota, evaluated here unless the start passes one. */
|
|
1262
|
+
concurrency?: ConcurrencyConfig | undefined;
|
|
1263
|
+
/** `@Workflow({ onEvent })` / `@OnDurableEvent`: started by this app's own `publishEvent`. */
|
|
1264
|
+
onEvent?: OnEventEntry[] | undefined;
|
|
1265
|
+
/** The workflow coalesces its event triggers (`debounce`/`batch`), which a tenant cannot apply. */
|
|
1266
|
+
coalesces?: boolean | undefined;
|
|
1267
|
+
}
|
|
1268
|
+
/**
|
|
1269
|
+
* Where a tenant's `signal`/`signalWithStart`/`publishEvent` go: run requests to the control plane
|
|
1270
|
+
* (the module's `ProxyRunGateway` over `transport`).
|
|
1271
|
+
*/
|
|
1272
|
+
interface TenantRunRequests {
|
|
1273
|
+
signal(token: string, payload: unknown, opts?: SignalOptions): Promise<RunResult | null>;
|
|
1274
|
+
signalWithStart(start: Omit<StartRunMessage, 'tenant'> & {
|
|
1275
|
+
runId: string;
|
|
1276
|
+
}, signal: {
|
|
1277
|
+
token: string;
|
|
1278
|
+
payload?: unknown;
|
|
1279
|
+
}): Promise<{
|
|
1280
|
+
runId: string;
|
|
1281
|
+
signalled: boolean;
|
|
1282
|
+
}>;
|
|
1283
|
+
publishEvent(name: string, payload: unknown, opts?: {
|
|
1284
|
+
id?: string;
|
|
1285
|
+
}): Promise<number>;
|
|
1286
|
+
}
|
|
1222
1287
|
/**
|
|
1223
1288
|
* The **store-less `engine.start` facade** for a tenant worker. Provided under the `WorkflowEngine`
|
|
1224
1289
|
* DI token by {@link import('./durable.module').DurableModule} (`forRoot({ connection })`, no
|
|
@@ -1236,13 +1301,91 @@ declare class DurableStartClient {
|
|
|
1236
1301
|
private readonly deps?;
|
|
1237
1302
|
/** The context accessor, for the customer tenant a start claims (else the global slot). */
|
|
1238
1303
|
private readonly accessor?;
|
|
1304
|
+
/**
|
|
1305
|
+
* Sends `signal`/`signalWithStart`/`publishEvent` to the control plane as run requests (the
|
|
1306
|
+
* module's `ProxyRunGateway` over `transport`). Absent (no `transport`): they reject, naming it.
|
|
1307
|
+
*/
|
|
1308
|
+
private readonly requests?;
|
|
1239
1309
|
private readonly tenant;
|
|
1240
1310
|
private readonly tenantToken;
|
|
1311
|
+
private readonly policies;
|
|
1312
|
+
private readonly warnedCoalescing;
|
|
1241
1313
|
constructor(options: DurableModuleOptions, deps?: StartRunDeps | undefined,
|
|
1242
1314
|
/** The context accessor, for the customer tenant a start claims (else the global slot). */
|
|
1243
|
-
accessor?: ContextAccessor | undefined
|
|
1315
|
+
accessor?: ContextAccessor | undefined,
|
|
1316
|
+
/**
|
|
1317
|
+
* Sends `signal`/`signalWithStart`/`publishEvent` to the control plane as run requests (the
|
|
1318
|
+
* module's `ProxyRunGateway` over `transport`). Absent (no `transport`): they reject, naming it.
|
|
1319
|
+
*/
|
|
1320
|
+
requests?: (() => TenantRunRequests | undefined) | undefined);
|
|
1321
|
+
/**
|
|
1322
|
+
* Apply `policy` to every start of `workflow` from this process (see
|
|
1323
|
+
* {@link TenantWorkflowStartPolicy}). Called by `ThinWorkflowRegistrar` at boot.
|
|
1324
|
+
*/
|
|
1325
|
+
declareWorkflow(workflow: string, policy: TenantWorkflowStartPolicy): void;
|
|
1326
|
+
/**
|
|
1327
|
+
* The start-run fields a declared policy adds for `input`: it validates the input (throwing), and
|
|
1328
|
+
* evaluates the singleton key and the default quota against the parsed input. A per-start `concurrency` wins over the
|
|
1329
|
+
* workflow's.
|
|
1330
|
+
*/
|
|
1331
|
+
private applyPolicy;
|
|
1332
|
+
/** The wire `tenant`: the signed token when configured, else the partition. */
|
|
1333
|
+
private wireTenant;
|
|
1334
|
+
/**
|
|
1335
|
+
* The customer tenant a start claims: an explicit `tenantId` (`null` = none), else the request's
|
|
1336
|
+
* tenant when tenancy is on.
|
|
1337
|
+
*/
|
|
1338
|
+
private claimedTenant;
|
|
1244
1339
|
start<C extends WorkflowClass>(workflow: C, input: WorkflowInputOf<C>, runId?: string, opts?: StartOptions): Promise<RunResult>;
|
|
1245
1340
|
start(workflow: string, input: unknown, runId?: string, opts?: StartOptions): Promise<RunResult>;
|
|
1341
|
+
/**
|
|
1342
|
+
* The start-run a start of `name` sends (everything but the wire `tenant`): the start options the
|
|
1343
|
+
* control plane applies (version pin, priority, delayed start, quota), the singleton key and the
|
|
1344
|
+
* customer tenant this run claims. Applies the workflow's declared policy first, so a rejected
|
|
1345
|
+
* input throws before anything is published, as `engine.start` does.
|
|
1346
|
+
*/
|
|
1347
|
+
private startMessage;
|
|
1348
|
+
/** The control plane's run requests, or a clear error naming what is missing. */
|
|
1349
|
+
private runRequests;
|
|
1350
|
+
/**
|
|
1351
|
+
* Signal the run of this tenant's partition waiting on `token`, through the control plane.
|
|
1352
|
+
* Resolves the resumed run, or null when no run of this partition waits on it: unlike
|
|
1353
|
+
* `engine.signal` on a control plane, a tenant's signal is NOT buffered for a wait opened later
|
|
1354
|
+
* (another partition's run could open it). Use `signalWithStart` to signal a run that may not wait
|
|
1355
|
+
* yet. `opts.id` deduplicates like `engine.signal`.
|
|
1356
|
+
*/
|
|
1357
|
+
signal(token: string, payload: unknown, opts?: SignalOptions): Promise<RunResult | null>;
|
|
1358
|
+
/**
|
|
1359
|
+
* Ensure the run `runId` of `workflow` exists in this tenant's partition (started like
|
|
1360
|
+
* {@link start}, with the same options and policy), then signal it. The control plane buffers the
|
|
1361
|
+
* signal until the run waits on `signal.token` only when the token contains `runId` (a run-scoped
|
|
1362
|
+
* token, the pattern `signalWithStart` is for): a token that does not is delivered only to a run
|
|
1363
|
+
* of this partition already waiting on it, and refused otherwise.
|
|
1364
|
+
*/
|
|
1365
|
+
signalWithStart<C extends WorkflowClass>(workflow: C, input: WorkflowInputOf<C>, runId: string, signal: {
|
|
1366
|
+
token: string;
|
|
1367
|
+
payload?: unknown;
|
|
1368
|
+
}, opts?: StartOptions): Promise<{
|
|
1369
|
+
runId: string;
|
|
1370
|
+
}>;
|
|
1371
|
+
signalWithStart(workflow: string, input: unknown, runId: string, signal: {
|
|
1372
|
+
token: string;
|
|
1373
|
+
payload?: unknown;
|
|
1374
|
+
}, opts?: StartOptions): Promise<{
|
|
1375
|
+
runId: string;
|
|
1376
|
+
}>;
|
|
1377
|
+
/**
|
|
1378
|
+
* Publish event `name` from this tenant. Starts this app's own `onEvent` subscribers (each one
|
|
1379
|
+
* whose `where` accepts the payload, with its `input` mapping) as runs of this partition, by the
|
|
1380
|
+
* start path ({@link start}, run id `evt:<id>:<workflow>`), and has the control plane resume the
|
|
1381
|
+
* runs of this partition waiting on it (`ctx.waitForEvent`). Resolves how many runs it started or
|
|
1382
|
+
* resumed; a subscriber that throws is warned about and skipped. Unlike a control plane's
|
|
1383
|
+
* `publishEvent`, an event nobody received is not buffered (there is no `buffer` option), and
|
|
1384
|
+
* a subscriber's `debounce`/`batch` is not applied (it starts once per event, with a warning).
|
|
1385
|
+
*/
|
|
1386
|
+
publishEvent(name: string, payload: unknown, opts?: {
|
|
1387
|
+
id?: string;
|
|
1388
|
+
}): Promise<number>;
|
|
1246
1389
|
cancel(_runId: string): Promise<void>;
|
|
1247
1390
|
deleteRun(_runId: string): Promise<void>;
|
|
1248
1391
|
resume(_runId: string): Promise<void>;
|
|
@@ -1250,15 +1393,6 @@ declare class DurableStartClient {
|
|
|
1250
1393
|
timeoutMs?: number;
|
|
1251
1394
|
until?: 'settled' | 'terminal';
|
|
1252
1395
|
}): Promise<void>;
|
|
1253
|
-
signal(_token: string, _payload: unknown): Promise<void>;
|
|
1254
|
-
signalWithStart(_workflow: string, _input: unknown, _runId: string, _signal: {
|
|
1255
|
-
token: string;
|
|
1256
|
-
payload?: unknown;
|
|
1257
|
-
}, _opts?: StartOptions): Promise<void>;
|
|
1258
|
-
publishEvent(_name: string, _payload: unknown, _opts?: {
|
|
1259
|
-
id?: string;
|
|
1260
|
-
buffer?: boolean;
|
|
1261
|
-
}): Promise<void>;
|
|
1262
1396
|
}
|
|
1263
1397
|
|
|
1264
1398
|
/**
|
|
@@ -1296,6 +1430,19 @@ declare class ThinWorkflowRegistrar implements OnModuleInit {
|
|
|
1296
1430
|
/** In this role the store-less `DurableStartClient` facade the module binds under this token. */
|
|
1297
1431
|
starter: WorkflowStartClient);
|
|
1298
1432
|
onModuleInit(): void;
|
|
1433
|
+
/**
|
|
1434
|
+
* `@Entity` providers are refused on a tenant, at boot: an entity's state is a run on the store
|
|
1435
|
+
* and its `@On` handlers run inside the engine that owns that store (`EntityService` and
|
|
1436
|
+
* `ctx.callEntity`/`signalEntity` read and serialize it there). A tenant has no store and no
|
|
1437
|
+
* engine, so an entity declared here would never run. Declare it on the control plane.
|
|
1438
|
+
*/
|
|
1439
|
+
private assertNoEntities;
|
|
1440
|
+
/**
|
|
1441
|
+
* `@StepInterceptor()` providers wrap every step this tenant runs (each `ctx.step` its workers
|
|
1442
|
+
* execute), as `engine.use` does on an engine. A `@durable-worker` too old to take interceptors
|
|
1443
|
+
* says so instead of dropping them silently.
|
|
1444
|
+
*/
|
|
1445
|
+
private useInterceptors;
|
|
1299
1446
|
}
|
|
1300
1447
|
/**
|
|
1301
1448
|
* Discovers every `@Step` method and registers it as a step handler on the thin
|
|
@@ -1610,6 +1757,13 @@ declare class RunRequestResponder {
|
|
|
1610
1757
|
* failure never throws back into the transport (errors are captured into an error reply). */
|
|
1611
1758
|
start(): void;
|
|
1612
1759
|
private handle;
|
|
1760
|
+
/**
|
|
1761
|
+
* A tenant's `signalWithStart`: the run it names must be the requester's when it exists, and so
|
|
1762
|
+
* must a run already waiting on the token; anything else is refused `cross-tenant` before the
|
|
1763
|
+
* gateway is called. The run is started in the requester's namespace (a customer tenant it claims
|
|
1764
|
+
* is kept only when its verified token grants it, as for a start-run).
|
|
1765
|
+
*/
|
|
1766
|
+
private signalWithStart;
|
|
1613
1767
|
/** The run alone (`getRun`, else from its detail), or null when it does not exist. */
|
|
1614
1768
|
private runOf;
|
|
1615
1769
|
/** `call`'s result as an `ok` reply, or its rejection as an error reply. */
|
|
@@ -1766,6 +1920,35 @@ declare class ProxyRunGateway implements RunGateway {
|
|
|
1766
1920
|
* {@link RunGatewayError} with code {@link UNSUPPORTED_RUN_REQUEST}.
|
|
1767
1921
|
*/
|
|
1768
1922
|
private requestNewVerb;
|
|
1923
|
+
/**
|
|
1924
|
+
* Signal the run of this tenant's namespace waiting on `token` (`engine.signal`). Resolves null
|
|
1925
|
+
* when no run of this namespace waits on it: the control plane does NOT buffer a tenant's signal
|
|
1926
|
+
* for a wait opened later (another namespace's run could open it). A control plane that predates
|
|
1927
|
+
* the verb fails it with an {@link UNSUPPORTED_RUN_REQUEST} error.
|
|
1928
|
+
*/
|
|
1929
|
+
signal(token: string, payload: unknown, opts?: SignalOptions): Promise<RunResult | null>;
|
|
1930
|
+
/**
|
|
1931
|
+
* `engine.signalWithStart` for this tenant: the control plane starts `start` in this tenant's
|
|
1932
|
+
* namespace unless its run exists, then signals it (buffered until the run waits, when the token
|
|
1933
|
+
* names the run id). See the responder for the authorization rule.
|
|
1934
|
+
*/
|
|
1935
|
+
signalWithStart(start: Omit<StartRunMessage, 'tenant'> & {
|
|
1936
|
+
runId: string;
|
|
1937
|
+
}, signal: {
|
|
1938
|
+
token: string;
|
|
1939
|
+
payload?: unknown;
|
|
1940
|
+
}): Promise<{
|
|
1941
|
+
runId: string;
|
|
1942
|
+
signalled: boolean;
|
|
1943
|
+
}>;
|
|
1944
|
+
/**
|
|
1945
|
+
* Resume the runs of this tenant's namespace waiting on event `name` (`ctx.waitForEvent`).
|
|
1946
|
+
* Resolves how many it resumed. The tenant's own `onEvent` subscribers are started by the caller
|
|
1947
|
+
* (`DurableStartClient.publishEvent`), not here.
|
|
1948
|
+
*/
|
|
1949
|
+
publishEvent(name: string, payload: unknown, opts?: {
|
|
1950
|
+
id?: string;
|
|
1951
|
+
}): Promise<number>;
|
|
1769
1952
|
subscribe(runId: string, onEvent: (event: EngineEvent) => void): () => void;
|
|
1770
1953
|
}
|
|
1771
1954
|
|
|
@@ -1882,7 +2065,17 @@ declare class StoreRunGateway implements RunGateway {
|
|
|
1882
2065
|
listSchedules(query: ScheduleListQuery): Promise<ScheduleDescription[]>;
|
|
1883
2066
|
getSchedule(id: string): Promise<ScheduleDescription | null>;
|
|
1884
2067
|
scheduleAction(id: string, action: ScheduleAction): Promise<ScheduleDescription | RunResult>;
|
|
1885
|
-
signal(token: string, payload: unknown): Promise<RunResult | null>;
|
|
2068
|
+
signal(token: string, payload: unknown, opts?: SignalOptions): Promise<RunResult | null>;
|
|
2069
|
+
signalWithStartForTenant(start: StartRunMessage & {
|
|
2070
|
+
runId: string;
|
|
2071
|
+
}, namespace: string, clientTenant: Pick<StartOptions, 'tenantId' | 'tenantKind'>, signal: {
|
|
2072
|
+
token: string;
|
|
2073
|
+
payload?: unknown;
|
|
2074
|
+
}): Promise<{
|
|
2075
|
+
runId: string;
|
|
2076
|
+
signalled: boolean;
|
|
2077
|
+
}>;
|
|
2078
|
+
publishEventForTenant(name: string, payload: unknown, namespace: string): Promise<number>;
|
|
1886
2079
|
signalWaiter(token: string): Promise<string | null>;
|
|
1887
2080
|
/**
|
|
1888
2081
|
* Stream `runId`'s events. With tenancy, a run the caller may not see streams nothing; events of a
|
|
@@ -2021,4 +2214,4 @@ declare class WorkflowService {
|
|
|
2021
2214
|
republishLifecycle(target: RepublishLifecycleTarget): Promise<RepublishLifecycleResult>;
|
|
2022
2215
|
}
|
|
2023
2216
|
|
|
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 };
|
|
2217
|
+
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 InferWorkflowInput, 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 };
|