@dudousxd/nestjs-durable-core 0.77.0 → 0.78.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -474,6 +474,198 @@ declare class WorkflowBlocked extends Error {
474
474
  */
475
475
  declare function planDispatch(requires: string[], liveDescriptors: readonly (RawWorkerDescriptor | WorkerDescriptor)[], cp: WorkerDescriptor, token: string): DispatchPlan;
476
476
 
477
+ /**
478
+ * A parallel fan (a `ctx.all`, a step fan, a polyglot `gather`) reduced to what a detail view needs
479
+ * to draw it: one node, its progress and its failures. A run detail with a 40,000-item fan otherwise
480
+ * carries every member — megabytes of JSON, and one rendered row (or fetched child) per member.
481
+ */
482
+ interface FanSummary {
483
+ /** The fan's `parallelGroup`. */
484
+ group: string;
485
+ /** The members' common step name, or `child runs` for a fan of child workflows. */
486
+ label: string;
487
+ firstSeq: number;
488
+ lastSeq: number;
489
+ /** Members started so far: steps, or child runs (a folded checkpoint counts as the children it stands for). */
490
+ size: number;
491
+ /**
492
+ * The fan's declared size, when its group carries it. More than `size` while waves are still to
493
+ * be sent (`concurrency`), and for good when a failFast fan stopped early.
494
+ */
495
+ total?: number | undefined;
496
+ /** `total - size`: members never started yet — or never to start, once the run has finished. */
497
+ notStarted?: number | undefined;
498
+ /** The fan stops at its first failure. */
499
+ failFast: boolean;
500
+ /** Members by status. A child that failed counts as `failed`, though its checkpoint is `completed`. */
501
+ counts: Partial<Record<StepCheckpoint['status'], number>>;
502
+ startedAt?: Date | undefined;
503
+ finishedAt?: Date | undefined;
504
+ /** The first {@link FAN_SUMMARY_FAILURES} failed members, so a failure shows without paging. */
505
+ failures: StepCheckpoint[];
506
+ }
507
+ /** A page of one fan's members, in seq order. */
508
+ interface FanPage {
509
+ items: StepCheckpoint[];
510
+ /** Members matching the query, across all pages. */
511
+ total: number;
512
+ }
513
+ interface FanPageQuery {
514
+ offset?: number | undefined;
515
+ limit?: number | undefined;
516
+ /** Only failed members (a failed step, or a child that failed). */
517
+ failedOnly?: boolean | undefined;
518
+ }
519
+ declare const FAN_SUMMARY_FAILURES = 20;
520
+ /** The most children a summarized detail lists by id; `childCount` carries the rest. */
521
+ declare const SUMMARY_CHILD_LIMIT = 200;
522
+ /** A failed member: a failed step, or a child whose completion reports `ok: false`. */
523
+ declare function isFailedMember(cp: StepCheckpoint): boolean;
524
+ /** Summarize one fan's members (in seq order). */
525
+ declare function summarizeFan(group: string, members: StepCheckpoint[]): FanSummary;
526
+ /**
527
+ * Split a run's timeline into the checkpoints a detail view lists one by one and the fans it draws as
528
+ * one node each: every `parallelGroup` with more than `over` members, or declared wider than that,
529
+ * becomes a {@link FanSummary}, and its members leave the timeline. Smaller groups and ungrouped steps stay as they are.
530
+ */
531
+ declare function summarizeTimeline(timeline: StepCheckpoint[], over: number): {
532
+ timeline: StepCheckpoint[];
533
+ fans: FanSummary[];
534
+ };
535
+ /** One page of a fan's members out of a run's timeline. */
536
+ declare function pageFan(timeline: StepCheckpoint[], group: string, query: FanPageQuery): FanPage;
537
+
538
+ /** A run as returned by the gateway's list — the durable run plus an optional {@link RunWaiting}
539
+ * descriptor the control plane resolves (what a suspended run is parked on), so the dashboard can
540
+ * name the wait in a list row without fetching each run's timeline. Additive: `waiting` is absent
541
+ * on a non-parked run and on gateways/versions that don't compute it. */
542
+ type RunListItem = WorkflowRun & {
543
+ waiting?: RunWaiting | undefined;
544
+ };
545
+ /** Which durable topology a gateway speaks for — surfaced in the dashboard so an operator can tell a
546
+ * control plane from a tenant at a glance (the store-backed gateway is the operator; the proxy is a
547
+ * tenant). Cheap, synchronous, local knowledge — no round-trip. */
548
+ interface DurableTopology {
549
+ role: 'control-plane' | 'tenant';
550
+ /** The tenant's isolation partition name; set only when `role` is 'tenant'. */
551
+ tenant?: string;
552
+ }
553
+ /** A run + its timeline + child ids — the detail view. Single source of truth: the dashboard server
554
+ * re-exports this instead of re-declaring it, and the dashboard client derives its wire mirror from
555
+ * it via {@link WireDates} instead of hand-mirroring field by field. */
556
+ interface RunDetail {
557
+ run: WorkflowRun;
558
+ /**
559
+ * Steps in execution order (local + remote). With {@link RunDetailOptions.summarizeFansOver}, the
560
+ * members of a summarized fan are left out — see {@link fans}.
561
+ */
562
+ timeline: StepCheckpoint[];
563
+ /** Ids of runs this run spawned (parent→children tree). Capped when summarized — see {@link childCount}. */
564
+ children: string[];
565
+ /** The fans drawn as one node each, when the detail was asked to summarize them. */
566
+ fans?: FanSummary[] | undefined;
567
+ /** How many children the run has, when `children` lists only the first of them. */
568
+ childCount?: number | undefined;
569
+ }
570
+ /** How to shape a {@link RunDetail}. */
571
+ interface RunDetailOptions {
572
+ /**
573
+ * Summarize every fan with more than this many members into a {@link FanSummary} instead of
574
+ * listing them, and cap `children`. Unset returns the full timeline, as before. A view of a run
575
+ * with a wide fan should set it: the full detail of a 40k-member fan is megabytes.
576
+ */
577
+ summarizeFansOver?: number | undefined;
578
+ }
579
+ /**
580
+ * Maps every `Date` (and `Date | undefined`) field of `T` to its ISO-string wire form — the shape a
581
+ * JSON response actually carries once dates cross the wire (`JSON.stringify` already does this
582
+ * coercion; this just types it). Homomorphic: each field keeps its own optional modifier, so a
583
+ * required `Date` becomes a required `string` and an optional one stays optional. Lets a consumer
584
+ * derive its own wire-facing client type from a core server type (e.g. the dashboard's SPA `WorkflowRun`/
585
+ * `StepCheckpoint`/`RunDetail`) instead of hand-mirroring it field by field and drifting.
586
+ */
587
+ type WireDates<T> = {
588
+ [K in keyof T]: T[K] extends Date ? string : T[K] extends Date | undefined ? string | undefined : T[K];
589
+ };
590
+ /**
591
+ * The bounded read/control/stream surface a consumer (e.g. a controller) needs, satisfied by BOTH
592
+ * topologies: the control plane binds a store-backed impl (reuses `DashboardService`); a tenant binds
593
+ * a `ProxyRunGateway` that round-trips over the transport. Deliberately smaller than the full dashboard
594
+ * (no metrics/bulk/update/signal) — those stay control-plane-only. `workerHealth` IS on the port: the
595
+ * operator answers it scoped to the requester's own groups, so a tenant's Workers panel works too.
596
+ *
597
+ * Declared as an **abstract class** rather than an interface so it doubles as its own NestJS DI token
598
+ * (the idiomatic inject-by-type pattern): providers bind `{ provide: RunGateway, useClass/useFactory }`
599
+ * and consumers inject `constructor(private readonly gateway: RunGateway)` with no string/symbol token.
600
+ * `StoreRunGateway`/`ProxyRunGateway` `implements RunGateway`; abstract methods carry no body, so the
601
+ * emitted runtime class is an empty, non-instantiable shell used only as the token.
602
+ */
603
+ declare abstract class RunGateway {
604
+ /** This deployment's durable role (control plane vs tenant) — synchronous local metadata. */
605
+ abstract topology(): DurableTopology;
606
+ abstract getRunDetail(runId: string, options?: RunDetailOptions): Promise<RunDetail | null>;
607
+ /**
608
+ * One page of a fan's members, for a view that drew the fan from its {@link FanSummary}. Optional:
609
+ * a gateway without it serves summarized details whose fans cannot be expanded.
610
+ */
611
+ getFanMembers?(runId: string, group: string, query: FanPageQuery): Promise<FanPage | null>;
612
+ /**
613
+ * The run alone, without its timeline. Optional: a caller that only needs the run (an ownership
614
+ * check) falls back to {@link getRunDetail}, which reads every checkpoint.
615
+ */
616
+ getRun?(runId: string): Promise<WorkflowRun | null>;
617
+ /** List runs, each optionally carrying a {@link RunWaiting} descriptor (what a suspended run is
618
+ * parked on). The store-backed gateway resolves `waiting`; a proxy relays whatever the control
619
+ * plane sent. */
620
+ abstract listRuns(query: RunQuery): Promise<RunListItem[]>;
621
+ /**
622
+ * Counts of the runs matching `query`, grouped by `(status, origin)` — what a console's status and
623
+ * origin chips display. Separate from {@link listRuns} precisely so the list can be PAGINATED: the
624
+ * page bounds what is rendered, these counts stay whole-set exact. Zero-count cells are absent.
625
+ */
626
+ abstract runFacets(query: RunFacetQuery): Promise<RunFacetRow[]>;
627
+ /**
628
+ * The distinct values of one filter axis over the runs matching `query`, with counts — what fills a
629
+ * console's tenant/tag/attribute pickers. On the port (not control-plane-only) because the pickers
630
+ * belong to the same panel as {@link listRuns}: a tenant that can list its runs has to be able to
631
+ * see what it may filter them by, or its console offers a blank dropdown.
632
+ *
633
+ * Returns `[]` when the underlying store does not implement the enumeration — an empty picker with
634
+ * free-text entry still standing, not an error.
635
+ */
636
+ abstract runValueFacets(axis: RunValueAxis, query: RunFacetQuery, opts?: RunValueFacetOptions): Promise<RunValueFacetRow[]>;
637
+ /**
638
+ * Bulk-resolve {@link RunWaiting} for an arbitrary set of run ids — for a consumer with its OWN
639
+ * filtered/paginated run listing (so it isn't just `listRuns` under another name) that needs to know
640
+ * which of ITS runs are parked on a breakpoint (or any other event wait) without re-deriving the bulk
641
+ * waiter scan itself or reaching for raw SQL against `durable_step_checkpoints`. A `Record` (not a
642
+ * `Map`) because `ProxyRunGateway` serialises the reply over the transport as plain JSON. Entries are
643
+ * present ONLY for runs currently waiting — an unknown id, a non-suspended id, and a suspended id
644
+ * parked on something non-event (a bare `ctx.sleep`, an in-flight step) are simply absent, same as a
645
+ * `listRuns` row with no `waiting`.
646
+ */
647
+ abstract waitingFor(runIds: string[]): Promise<Record<string, RunWaiting>>;
648
+ /** Per-group worker health (queue backlog + live worker heartbeats). On the control plane this is
649
+ * every group; over a tenant proxy the operator scopes it to the tenant's own groups. */
650
+ abstract workerHealth(): Promise<GroupHealth[]>;
651
+ abstract cancel(runId: string, opts?: {
652
+ compensate?: boolean;
653
+ }): Promise<RunResult | null>;
654
+ abstract retry(runId: string): Promise<RunResult | null>;
655
+ abstract continue(runId: string): Promise<RunResult | null>;
656
+ /** Re-dispatch every remote step of a run stuck `pending` — the operator recovery for a LOST step
657
+ * dispatch (crashed worker / dropped job) that no automatic path re-drives. Returns the run's status
658
+ * plus how many steps were re-dispatched, or null if the run is unknown. */
659
+ abstract redispatchPending(runId: string): Promise<(RunResult & {
660
+ redispatched: number;
661
+ }) | null>;
662
+ abstract retryWithInput(runId: string, input: unknown): Promise<{
663
+ runId: string;
664
+ } | null>;
665
+ /** Live lifecycle events for one run; returns an unsubscribe fn. Framework-agnostic (no rxjs). */
666
+ abstract subscribe(runId: string, onEvent: (event: EngineEvent) => void): () => void;
667
+ }
668
+
477
669
  /**
478
670
  * Vendored subset of the Standard Schema spec (https://standardschema.dev) — the `~standard`
479
671
  * property protocol implemented by zod 3.24+, valibot, arktype, and others. Vendored (rather than
@@ -1569,6 +1761,12 @@ interface RunRequest {
1569
1761
  type RunRequestKind = {
1570
1762
  kind: 'getRunDetail';
1571
1763
  runId: string;
1764
+ options?: RunDetailOptions | undefined;
1765
+ } | {
1766
+ kind: 'getFanMembers';
1767
+ runId: string;
1768
+ group: string;
1769
+ query: FanPageQuery;
1572
1770
  } | {
1573
1771
  kind: 'listRuns';
1574
1772
  query: RunQuery;
@@ -5007,6 +5205,8 @@ declare class RemoteStepError extends Error {
5007
5205
  readonly stepError?: StepError | undefined;
5008
5206
  constructor(stepError?: StepError);
5009
5207
  }
5208
+ /** The child run ids a parent's {@link CHILD_EDGE_PREFIXES} checkpoints point at (others are skipped). */
5209
+ declare function childIdsOf(checkpoints: StepCheckpoint[]): string[];
5010
5210
 
5011
5211
  /**
5012
5212
  * What the class-first statics need from whoever registered the workflow class: the engine, or a
@@ -5437,111 +5637,6 @@ declare function mergeRunValueFacetRows(rows: readonly {
5437
5637
  */
5438
5638
  declare function runValueFacetsFromRuns(runs: readonly WorkflowRun[], axis: RunValueAxis, opts?: RunValueFacetOptions): RunValueFacetRow[];
5439
5639
 
5440
- /** A run as returned by the gateway's list — the durable run plus an optional {@link RunWaiting}
5441
- * descriptor the control plane resolves (what a suspended run is parked on), so the dashboard can
5442
- * name the wait in a list row without fetching each run's timeline. Additive: `waiting` is absent
5443
- * on a non-parked run and on gateways/versions that don't compute it. */
5444
- type RunListItem = WorkflowRun & {
5445
- waiting?: RunWaiting | undefined;
5446
- };
5447
- /** Which durable topology a gateway speaks for — surfaced in the dashboard so an operator can tell a
5448
- * control plane from a tenant at a glance (the store-backed gateway is the operator; the proxy is a
5449
- * tenant). Cheap, synchronous, local knowledge — no round-trip. */
5450
- interface DurableTopology {
5451
- role: 'control-plane' | 'tenant';
5452
- /** The tenant's isolation partition name; set only when `role` is 'tenant'. */
5453
- tenant?: string;
5454
- }
5455
- /** A run + its timeline + child ids — the detail view. Single source of truth: the dashboard server
5456
- * re-exports this instead of re-declaring it, and the dashboard client derives its wire mirror from
5457
- * it via {@link WireDates} instead of hand-mirroring field by field. */
5458
- interface RunDetail {
5459
- run: WorkflowRun;
5460
- /** Steps in execution order (local + remote). */
5461
- timeline: StepCheckpoint[];
5462
- /** Ids of runs this run spawned (parent→children tree). */
5463
- children: string[];
5464
- }
5465
- /**
5466
- * Maps every `Date` (and `Date | undefined`) field of `T` to its ISO-string wire form — the shape a
5467
- * JSON response actually carries once dates cross the wire (`JSON.stringify` already does this
5468
- * coercion; this just types it). Homomorphic: each field keeps its own optional modifier, so a
5469
- * required `Date` becomes a required `string` and an optional one stays optional. Lets a consumer
5470
- * derive its own wire-facing client type from a core server type (e.g. the dashboard's SPA `WorkflowRun`/
5471
- * `StepCheckpoint`/`RunDetail`) instead of hand-mirroring it field by field and drifting.
5472
- */
5473
- type WireDates<T> = {
5474
- [K in keyof T]: T[K] extends Date ? string : T[K] extends Date | undefined ? string | undefined : T[K];
5475
- };
5476
- /**
5477
- * The bounded read/control/stream surface a consumer (e.g. a controller) needs, satisfied by BOTH
5478
- * topologies: the control plane binds a store-backed impl (reuses `DashboardService`); a tenant binds
5479
- * a `ProxyRunGateway` that round-trips over the transport. Deliberately smaller than the full dashboard
5480
- * (no metrics/bulk/update/signal) — those stay control-plane-only. `workerHealth` IS on the port: the
5481
- * operator answers it scoped to the requester's own groups, so a tenant's Workers panel works too.
5482
- *
5483
- * Declared as an **abstract class** rather than an interface so it doubles as its own NestJS DI token
5484
- * (the idiomatic inject-by-type pattern): providers bind `{ provide: RunGateway, useClass/useFactory }`
5485
- * and consumers inject `constructor(private readonly gateway: RunGateway)` with no string/symbol token.
5486
- * `StoreRunGateway`/`ProxyRunGateway` `implements RunGateway`; abstract methods carry no body, so the
5487
- * emitted runtime class is an empty, non-instantiable shell used only as the token.
5488
- */
5489
- declare abstract class RunGateway {
5490
- /** This deployment's durable role (control plane vs tenant) — synchronous local metadata. */
5491
- abstract topology(): DurableTopology;
5492
- abstract getRunDetail(runId: string): Promise<RunDetail | null>;
5493
- /** List runs, each optionally carrying a {@link RunWaiting} descriptor (what a suspended run is
5494
- * parked on). The store-backed gateway resolves `waiting`; a proxy relays whatever the control
5495
- * plane sent. */
5496
- abstract listRuns(query: RunQuery): Promise<RunListItem[]>;
5497
- /**
5498
- * Counts of the runs matching `query`, grouped by `(status, origin)` — what a console's status and
5499
- * origin chips display. Separate from {@link listRuns} precisely so the list can be PAGINATED: the
5500
- * page bounds what is rendered, these counts stay whole-set exact. Zero-count cells are absent.
5501
- */
5502
- abstract runFacets(query: RunFacetQuery): Promise<RunFacetRow[]>;
5503
- /**
5504
- * The distinct values of one filter axis over the runs matching `query`, with counts — what fills a
5505
- * console's tenant/tag/attribute pickers. On the port (not control-plane-only) because the pickers
5506
- * belong to the same panel as {@link listRuns}: a tenant that can list its runs has to be able to
5507
- * see what it may filter them by, or its console offers a blank dropdown.
5508
- *
5509
- * Returns `[]` when the underlying store does not implement the enumeration — an empty picker with
5510
- * free-text entry still standing, not an error.
5511
- */
5512
- abstract runValueFacets(axis: RunValueAxis, query: RunFacetQuery, opts?: RunValueFacetOptions): Promise<RunValueFacetRow[]>;
5513
- /**
5514
- * Bulk-resolve {@link RunWaiting} for an arbitrary set of run ids — for a consumer with its OWN
5515
- * filtered/paginated run listing (so it isn't just `listRuns` under another name) that needs to know
5516
- * which of ITS runs are parked on a breakpoint (or any other event wait) without re-deriving the bulk
5517
- * waiter scan itself or reaching for raw SQL against `durable_step_checkpoints`. A `Record` (not a
5518
- * `Map`) because `ProxyRunGateway` serialises the reply over the transport as plain JSON. Entries are
5519
- * present ONLY for runs currently waiting — an unknown id, a non-suspended id, and a suspended id
5520
- * parked on something non-event (a bare `ctx.sleep`, an in-flight step) are simply absent, same as a
5521
- * `listRuns` row with no `waiting`.
5522
- */
5523
- abstract waitingFor(runIds: string[]): Promise<Record<string, RunWaiting>>;
5524
- /** Per-group worker health (queue backlog + live worker heartbeats). On the control plane this is
5525
- * every group; over a tenant proxy the operator scopes it to the tenant's own groups. */
5526
- abstract workerHealth(): Promise<GroupHealth[]>;
5527
- abstract cancel(runId: string, opts?: {
5528
- compensate?: boolean;
5529
- }): Promise<RunResult | null>;
5530
- abstract retry(runId: string): Promise<RunResult | null>;
5531
- abstract continue(runId: string): Promise<RunResult | null>;
5532
- /** Re-dispatch every remote step of a run stuck `pending` — the operator recovery for a LOST step
5533
- * dispatch (crashed worker / dropped job) that no automatic path re-drives. Returns the run's status
5534
- * plus how many steps were re-dispatched, or null if the run is unknown. */
5535
- abstract redispatchPending(runId: string): Promise<(RunResult & {
5536
- redispatched: number;
5537
- }) | null>;
5538
- abstract retryWithInput(runId: string, input: unknown): Promise<{
5539
- runId: string;
5540
- } | null>;
5541
- /** Live lifecycle events for one run; returns an unsubscribe fn. Framework-agnostic (no rxjs). */
5542
- abstract subscribe(runId: string, onEvent: (event: EngineEvent) => void): () => void;
5543
- }
5544
-
5545
5640
  /**
5546
5641
  * Resolve WHAT a suspended run is parked on from the token of the {@link SignalWaiter} it registered.
5547
5642
  * The token prefix carries the kind — no extra store lookup and no new persisted field. Used by the
@@ -6200,4 +6295,4 @@ declare function singletonAdmissionDenialPatch(runs: WorkflowRun[], runId: strin
6200
6295
  updatedAt: Date;
6201
6296
  } | undefined;
6202
6297
 
6203
- export { type AccumulatorHost, type Admission, type AdmissionBackend, type AdmissionItem, type AllOptions, type AllStepsOptions, type AnnouncedWorkflow, type AnnouncementEvidence, type AttributeFilter, type AttributeOp, type AttributePredicateOperand, type AttributeValue, type BackoffStrategy, type BlockedDispatch, type BlockedResolution, CONTROL_FLOW_SIGNAL, CURRENT_PROTOCOL_VERSION, type CapabilityRequirement, type ChildCallOptions, type ChildWait, CodecStateStore, type ConcurrencyConfig, ConcurrencyLimitError, type ConcurrencyQuota, ContinueAsNew, type ControlMessage, type ControlPlane, DEFAULT_CONCURRENCY_STATUSES, DEFAULT_PARTITION, DURABLE_OPTIONS, DURABLE_OPTIONS_CANONICAL, DURABLE_STEP_CONFIG, DURABLE_STEP_NAME, type Disagreement, type DispatchDiagnostics, type DispatchPlan, type DurableExecution, type DurableExecutionWrapper, type DurableTopology, type DurableWebhook, DurableWorkflow, type DynamicWorkflowCtx, ENGINE_MINTED_TAG_PREFIXES, EVENT_BUFFER_SCAN_LIMIT, EVENT_TOKEN_PREFIX, type EngineEvent, type EngineEventType, type EngineListener, Entities, type EntityConfig, type EntityHandler, type EntityHost, EventAccumulators, type EventBatchConfig, type FanJoin, type FanWait, FatalError, GatherError, type GroupHealth, type Heartbeat, type HeartbeatSighting, type HeartbeatStatus, type HistoryEvent, InMemoryAdmissionBackend, InMemoryStateStore, InMemoryTransport, type InferSearchAttributes, LEGACY_V1_CAPABILITIES, LEGACY_V1_PROTOCOL, type MetricsCollector, type MetricsSnapshot, type NamedTransport, type NegotiateOptions, type NegotiationOutcome, type NegotiationReason, type NegotiationResult, NestedWorkflowCallError, NonDeterminismError, type PartitionSighting, type PayloadCodec, type QueueConfig, QueueController, RUN_VALUE_FACET_LIMIT, RUN_VALUE_FACET_SCAN, type RawWorkerDescriptor, RemoteStepError, RemoteStepTimeout, type RemoteTask, RemoteWorkflowExecutor, RemoteWorkflowTimeout, type RetentionPolicy, type RoutableDispatch, type RoutableResolution, type RoutingResolution, type RunAttributeRow, type RunDetail, type RunDispatcher, type RunFacetQuery, type RunFacetRow, RunGateway, type RunListItem, type RunQuery, type RunReply, type RunReplyResult, type RunRequest, type RunRequestKind, type RunResult, type RunSchedulesOptions, type RunScope, type RunStatus, type RunValueAxis, type RunValueFacetOptions, type RunValueFacetOrder, type RunValueFacetRow, type RunWaiting, SINGLETON_ACTIVE_STATUSES, SINGLETON_ADMITTED_TAG, STATE_STORE, STATE_STORE_CANONICAL, type ScalarAttributeFilter, ScheduleAlreadyExistsError, ScheduleClient, type ScheduleClientOptions, type ScheduleDescription, type ScheduleHost, type ScheduleListQuery, ScheduleNotFoundError, type ScheduleOptions, type ScheduleQuery, type ScheduleRecord, type ScheduledWorkflow, type SearchAttributes, type SearchAttributesSchema, SignalTimeoutError, type SignalWaiter, type SingletonConfig, SingletonQueueFullError, StandardSchemaV1, type StartOptions, type StartRunMessage, type StateStore, type StepCheckpoint, type StepConfig, type StepDef, type StepDispatchOpts, type StepError, type StepEvent, type StepHandler, type StepInterceptor, type StepInvocation, type StepKind, type StepLogger, type StepOptions, type StepRef, type StepResult, type StepScope, type StepUndo, type StoreTransaction, type SubProcessHandle, TERMINAL_RUN_STATUSES, TRANSPORT, TRANSPORT_CANONICAL, type TenantEvent, type Transport, type UndoOf, type UpdateResult, type UpdateValidator, VERSION_UNDECLARED_TAG, WORKFLOW_NAME_KEY, type WireDates, type WorkerAdjust, type WorkerConcurrencyStatus, type WorkerDescriptor, type WorkerHeartbeat, type WorkerLifecycle, type WorkerStatus, type WorkflowAnnouncement, WorkflowBlocked, type WorkflowClass, type WorkflowCommand, type WorkflowCtx, type WorkflowDecision, type WorkflowDirectory, WorkflowEngine, type WorkflowEngineDeps, type WorkflowExecutor, type WorkflowHandler, type WorkflowInputOf, type WorkflowOutputOf, type WorkflowRef, type WorkflowRegistration, type WorkflowRun, type WorkflowStartClient, type WorkflowStepEvent, WorkflowSuspended, type WorkflowTask, aggregateAnnouncements, announcementsOf, applyAttributeQuery, assertConcurrency, attributeColumnFor, attributeOperand, attributePredicateOperands, axisIsRunColumn, bindWorkflowClass, breakpointToken, buildWorkflowDirectory, canRoute, capableWorkers, classifyWaiterToken, clearDurableExecutionWrappers, clearTerminalSingletonAdmission, collectMetrics, concurrencyTag, controlPlaneDescriptor, countRuns, coveredTokens, createStepLogger, currentStep, currentStepScope, currentWorkflowCtx, debug, describeWorker, descriptorHash, error, eventMatchOf, eventMatches, eventNameOf, eventPrefix, eventToken, facetOrigin, hasDurableExecutionWrappers, heartbeatStatus, indexWaitersByRun, info, isEngineMintedTag, isEventToken, isLegacyDescriptor, isNonEmptyRunScope, isWorkflowControlFlowSignal, listSignalWaitersOfRuns, log, matchesAttributes, mergeRunFacetRows, mergeRunValueFacetRows, missingCapabilities, negotiate, nextCronFireMs, normalizeAttributeRows, normalizeDescriptor, observedAnnouncements, parentRunIdOf, parseDuration, partitionOfToken, planDispatch, prevCronFireMs, readSearchAttributes, requiredCapabilities, resolveConcurrency, resolveRouting, resolveRunWaiting, runDurableExecution, runInStepLogger, runInStepScope, runInWorkflowCtx, runOutsideWorkflowCtx, runSchedules, runStepHandler, runValueFacetsFromRuns, sanitizeQueueToken, scheduledRunId, singletonAdmissionDenialPatch, singletonAdmissionTags, sqlComparator, stepConfigOf, stepId, stepNameOf, sub, subEvent, subProcess, tenantGroup, useDurableExecution, warn, workflowName };
6298
+ export { type AccumulatorHost, type Admission, type AdmissionBackend, type AdmissionItem, type AllOptions, type AllStepsOptions, type AnnouncedWorkflow, type AnnouncementEvidence, type AttributeFilter, type AttributeOp, type AttributePredicateOperand, type AttributeValue, type BackoffStrategy, type BlockedDispatch, type BlockedResolution, CONTROL_FLOW_SIGNAL, CURRENT_PROTOCOL_VERSION, type CapabilityRequirement, type ChildCallOptions, type ChildWait, CodecStateStore, type ConcurrencyConfig, ConcurrencyLimitError, type ConcurrencyQuota, ContinueAsNew, type ControlMessage, type ControlPlane, DEFAULT_CONCURRENCY_STATUSES, DEFAULT_PARTITION, DURABLE_OPTIONS, DURABLE_OPTIONS_CANONICAL, DURABLE_STEP_CONFIG, DURABLE_STEP_NAME, type Disagreement, type DispatchDiagnostics, type DispatchPlan, type DurableExecution, type DurableExecutionWrapper, type DurableTopology, type DurableWebhook, DurableWorkflow, type DynamicWorkflowCtx, ENGINE_MINTED_TAG_PREFIXES, EVENT_BUFFER_SCAN_LIMIT, EVENT_TOKEN_PREFIX, type EngineEvent, type EngineEventType, type EngineListener, Entities, type EntityConfig, type EntityHandler, type EntityHost, EventAccumulators, type EventBatchConfig, FAN_SUMMARY_FAILURES, type FanJoin, type FanPage, type FanPageQuery, type FanSummary, type FanWait, FatalError, GatherError, type GroupHealth, type Heartbeat, type HeartbeatSighting, type HeartbeatStatus, type HistoryEvent, InMemoryAdmissionBackend, InMemoryStateStore, InMemoryTransport, type InferSearchAttributes, LEGACY_V1_CAPABILITIES, LEGACY_V1_PROTOCOL, type MetricsCollector, type MetricsSnapshot, type NamedTransport, type NegotiateOptions, type NegotiationOutcome, type NegotiationReason, type NegotiationResult, NestedWorkflowCallError, NonDeterminismError, type PartitionSighting, type PayloadCodec, type QueueConfig, QueueController, RUN_VALUE_FACET_LIMIT, RUN_VALUE_FACET_SCAN, type RawWorkerDescriptor, RemoteStepError, RemoteStepTimeout, type RemoteTask, RemoteWorkflowExecutor, RemoteWorkflowTimeout, type RetentionPolicy, type RoutableDispatch, type RoutableResolution, type RoutingResolution, type RunAttributeRow, type RunDetail, type RunDetailOptions, type RunDispatcher, type RunFacetQuery, type RunFacetRow, RunGateway, type RunListItem, type RunQuery, type RunReply, type RunReplyResult, type RunRequest, type RunRequestKind, type RunResult, type RunSchedulesOptions, type RunScope, type RunStatus, type RunValueAxis, type RunValueFacetOptions, type RunValueFacetOrder, type RunValueFacetRow, type RunWaiting, SINGLETON_ACTIVE_STATUSES, SINGLETON_ADMITTED_TAG, STATE_STORE, STATE_STORE_CANONICAL, SUMMARY_CHILD_LIMIT, type ScalarAttributeFilter, ScheduleAlreadyExistsError, ScheduleClient, type ScheduleClientOptions, type ScheduleDescription, type ScheduleHost, type ScheduleListQuery, ScheduleNotFoundError, type ScheduleOptions, type ScheduleQuery, type ScheduleRecord, type ScheduledWorkflow, type SearchAttributes, type SearchAttributesSchema, SignalTimeoutError, type SignalWaiter, type SingletonConfig, SingletonQueueFullError, StandardSchemaV1, type StartOptions, type StartRunMessage, type StateStore, type StepCheckpoint, type StepConfig, type StepDef, type StepDispatchOpts, type StepError, type StepEvent, type StepHandler, type StepInterceptor, type StepInvocation, type StepKind, type StepLogger, type StepOptions, type StepRef, type StepResult, type StepScope, type StepUndo, type StoreTransaction, type SubProcessHandle, TERMINAL_RUN_STATUSES, TRANSPORT, TRANSPORT_CANONICAL, type TenantEvent, type Transport, type UndoOf, type UpdateResult, type UpdateValidator, VERSION_UNDECLARED_TAG, WORKFLOW_NAME_KEY, type WireDates, type WorkerAdjust, type WorkerConcurrencyStatus, type WorkerDescriptor, type WorkerHeartbeat, type WorkerLifecycle, type WorkerStatus, type WorkflowAnnouncement, WorkflowBlocked, type WorkflowClass, type WorkflowCommand, type WorkflowCtx, type WorkflowDecision, type WorkflowDirectory, WorkflowEngine, type WorkflowEngineDeps, type WorkflowExecutor, type WorkflowHandler, type WorkflowInputOf, type WorkflowOutputOf, type WorkflowRef, type WorkflowRegistration, type WorkflowRun, type WorkflowStartClient, type WorkflowStepEvent, WorkflowSuspended, type WorkflowTask, aggregateAnnouncements, announcementsOf, applyAttributeQuery, assertConcurrency, attributeColumnFor, attributeOperand, attributePredicateOperands, axisIsRunColumn, bindWorkflowClass, breakpointToken, buildWorkflowDirectory, canRoute, capableWorkers, childIdsOf, classifyWaiterToken, clearDurableExecutionWrappers, clearTerminalSingletonAdmission, collectMetrics, concurrencyTag, controlPlaneDescriptor, countRuns, coveredTokens, createStepLogger, currentStep, currentStepScope, currentWorkflowCtx, debug, describeWorker, descriptorHash, error, eventMatchOf, eventMatches, eventNameOf, eventPrefix, eventToken, facetOrigin, hasDurableExecutionWrappers, heartbeatStatus, indexWaitersByRun, info, isEngineMintedTag, isEventToken, isFailedMember, isLegacyDescriptor, isNonEmptyRunScope, isWorkflowControlFlowSignal, listSignalWaitersOfRuns, log, matchesAttributes, mergeRunFacetRows, mergeRunValueFacetRows, missingCapabilities, negotiate, nextCronFireMs, normalizeAttributeRows, normalizeDescriptor, observedAnnouncements, pageFan, parentRunIdOf, parseDuration, partitionOfToken, planDispatch, prevCronFireMs, readSearchAttributes, requiredCapabilities, resolveConcurrency, resolveRouting, resolveRunWaiting, runDurableExecution, runInStepLogger, runInStepScope, runInWorkflowCtx, runOutsideWorkflowCtx, runSchedules, runStepHandler, runValueFacetsFromRuns, sanitizeQueueToken, scheduledRunId, singletonAdmissionDenialPatch, singletonAdmissionTags, sqlComparator, stepConfigOf, stepId, stepNameOf, sub, subEvent, subProcess, summarizeFan, summarizeTimeline, tenantGroup, useDurableExecution, warn, workflowName };
package/dist/index.js CHANGED
@@ -1083,8 +1083,9 @@ function allChildId(runId, firstSeq, index, wave) {
1083
1083
  return `${allBase(runId, firstSeq, wave)}${index}`;
1084
1084
  }
1085
1085
  __name(allChildId, "allChildId");
1086
- function allGroup(firstSeq, mode) {
1087
- return mode === "failFast" ? `all:${firstSeq}:failFast` : `all:${firstSeq}`;
1086
+ function allGroup(firstSeq, size, mode) {
1087
+ const group = `all:${firstSeq}:n${size}`;
1088
+ return mode === "failFast" ? `${group}:failFast` : group;
1088
1089
  }
1089
1090
  __name(allGroup, "allGroup");
1090
1091
  function stepFanGroup(firstSeq, size, mode) {
@@ -1093,14 +1094,26 @@ function stepFanGroup(firstSeq, size, mode) {
1093
1094
  }
1094
1095
  __name(stepFanGroup, "stepFanGroup");
1095
1096
  function parseStepFanGroup(group) {
1096
- const m = group ? /^steps:(\d+):(\d+)(?::failFast)?$/.exec(group) : null;
1097
- if (!m) return void 0;
1097
+ const fan = parseFanGroup(group);
1098
+ if (fan?.kind !== "steps" || fan.size === void 0) return void 0;
1098
1099
  return {
1099
- firstSeq: Number(m[1]),
1100
- size: Number(m[2])
1100
+ firstSeq: fan.firstSeq,
1101
+ size: fan.size
1101
1102
  };
1102
1103
  }
1103
1104
  __name(parseStepFanGroup, "parseStepFanGroup");
1105
+ function parseFanGroup(group) {
1106
+ const m = group ? /^(all|steps):(\d+)(?::n?(\d+))?(:failFast)?$/.exec(group) : null;
1107
+ if (!m) return void 0;
1108
+ if (m[1] === "steps" && m[3] === void 0) return void 0;
1109
+ return {
1110
+ kind: m[1],
1111
+ firstSeq: Number(m[2]),
1112
+ size: m[3] === void 0 ? void 0 : Number(m[3]),
1113
+ failFast: m[4] !== void 0
1114
+ };
1115
+ }
1116
+ __name(parseFanGroup, "parseFanGroup");
1104
1117
  function allWait(runId, firstSeq, wave) {
1105
1118
  const base = allBase(runId, firstSeq, wave);
1106
1119
  return {
@@ -1150,7 +1163,7 @@ function parentRunIdOf(runId) {
1150
1163
  return ENGINE_CHILD_ID.exec(runId)?.[1];
1151
1164
  }
1152
1165
  __name(parentRunIdOf, "parentRunIdOf");
1153
- var GROUP = /^all:(\d+)(:failFast)?$/;
1166
+ var GROUP = /^all:(\d+)(?::n\d+)?(:failFast)?$/;
1154
1167
  var REST = /^(?:w(\d+)\.)?\d+$/;
1155
1168
  function fanOfWaiter(waiter) {
1156
1169
  const group = waiter.parallelGroup ? GROUP.exec(waiter.parallelGroup) : null;
@@ -3150,7 +3163,7 @@ function createWorkflowCtx(host, runId, compensations, workflow = "", searchAttr
3150
3163
  const waves = allWaves(inputs.length, opts?.concurrency);
3151
3164
  const positions = inputs.map(() => pos.next());
3152
3165
  const firstSeq = positions[0];
3153
- const group = allGroup(firstSeq, mode);
3166
+ const group = allGroup(firstSeq, inputs.length, mode);
3154
3167
  const waveOf = /* @__PURE__ */ __name((i) => waves ? Math.floor(i / waves.waveSize) : void 0, "waveOf");
3155
3168
  const id = /* @__PURE__ */ __name((i) => allChildId(runId, firstSeq, i, waveOf(i)), "id");
3156
3169
  const { checkpoints: existing, folded } = await readFan(positions, [
@@ -7935,6 +7948,110 @@ var RunGateway = class {
7935
7948
  }
7936
7949
  };
7937
7950
 
7951
+ // src/run-detail-summary.ts
7952
+ var FAN_SUMMARY_FAILURES = 20;
7953
+ var SUMMARY_CHILD_LIMIT = 200;
7954
+ var FAN_PAGE_MAX = 500;
7955
+ function foldedCount(cp) {
7956
+ if (!cp.name.startsWith(FOLDED_PREFIX)) return void 0;
7957
+ const values = cp.output?.values;
7958
+ return Array.isArray(values) ? values.length : 0;
7959
+ }
7960
+ __name(foldedCount, "foldedCount");
7961
+ function isFailedMember(cp) {
7962
+ if (cp.status === "failed") return true;
7963
+ if (!cp.name.startsWith("signal:child:") || cp.status !== "completed") return false;
7964
+ return cp.output?.ok === false;
7965
+ }
7966
+ __name(isFailedMember, "isFailedMember");
7967
+ function fanLabel(members) {
7968
+ if (members.some((cp) => cp.name.startsWith("signal:child:") || foldedCount(cp) !== void 0)) {
7969
+ return "child runs";
7970
+ }
7971
+ const first = members[0]?.name ?? "";
7972
+ return members.every((cp) => cp.name === first) ? first : "steps";
7973
+ }
7974
+ __name(fanLabel, "fanLabel");
7975
+ function summarizeFan(group, members) {
7976
+ const counts = {};
7977
+ const failures = [];
7978
+ let size = 0;
7979
+ let startedAt;
7980
+ let finishedAt;
7981
+ let firstSeq = Number.POSITIVE_INFINITY;
7982
+ let lastSeq = Number.NEGATIVE_INFINITY;
7983
+ for (const cp of members) {
7984
+ firstSeq = Math.min(firstSeq, cp.seq);
7985
+ lastSeq = Math.max(lastSeq, cp.seq);
7986
+ const folded = foldedCount(cp);
7987
+ const n = folded ?? 1;
7988
+ size += n;
7989
+ const status = isFailedMember(cp) ? "failed" : cp.status;
7990
+ counts[status] = (counts[status] ?? 0) + n;
7991
+ if (status === "failed" && failures.length < FAN_SUMMARY_FAILURES) failures.push(cp);
7992
+ if (cp.status !== "pending" && cp.status !== "running") {
7993
+ if (!startedAt || cp.startedAt < startedAt) startedAt = cp.startedAt;
7994
+ if (!finishedAt || cp.finishedAt > finishedAt) finishedAt = cp.finishedAt;
7995
+ } else if (!startedAt || cp.enqueuedAt < startedAt) {
7996
+ startedAt = cp.enqueuedAt;
7997
+ }
7998
+ }
7999
+ const parsed = parseFanGroup(group);
8000
+ const total = parsed?.size;
8001
+ return {
8002
+ group,
8003
+ label: fanLabel(members),
8004
+ firstSeq,
8005
+ lastSeq,
8006
+ size,
8007
+ total,
8008
+ notStarted: total === void 0 ? void 0 : Math.max(0, total - size),
8009
+ failFast: parsed?.failFast ?? false,
8010
+ counts,
8011
+ startedAt,
8012
+ finishedAt,
8013
+ failures
8014
+ };
8015
+ }
8016
+ __name(summarizeFan, "summarizeFan");
8017
+ function summarizeTimeline(timeline, over) {
8018
+ const byGroup = /* @__PURE__ */ new Map();
8019
+ for (const cp of timeline) {
8020
+ if (cp.parallelGroup === void 0) continue;
8021
+ const members = byGroup.get(cp.parallelGroup);
8022
+ if (members) members.push(cp);
8023
+ else byGroup.set(cp.parallelGroup, [
8024
+ cp
8025
+ ]);
8026
+ }
8027
+ const summarized = /* @__PURE__ */ new Set();
8028
+ const fans = [];
8029
+ for (const [group, members] of byGroup) {
8030
+ if (members.length <= over && (parseFanGroup(group)?.size ?? 0) <= over) continue;
8031
+ summarized.add(group);
8032
+ fans.push(summarizeFan(group, members));
8033
+ }
8034
+ if (fans.length === 0) return {
8035
+ timeline,
8036
+ fans
8037
+ };
8038
+ return {
8039
+ timeline: timeline.filter((cp) => cp.parallelGroup === void 0 || !summarized.has(cp.parallelGroup)),
8040
+ fans: fans.sort((a, b) => a.firstSeq - b.firstSeq)
8041
+ };
8042
+ }
8043
+ __name(summarizeTimeline, "summarizeTimeline");
8044
+ function pageFan(timeline, group, query) {
8045
+ const matching = timeline.filter((cp) => cp.parallelGroup === group && (!query.failedOnly || isFailedMember(cp)));
8046
+ const offset = query.offset !== void 0 && Number.isFinite(query.offset) ? Math.max(0, Math.floor(query.offset)) : 0;
8047
+ const limit = query.limit !== void 0 && Number.isFinite(query.limit) ? Math.min(FAN_PAGE_MAX, Math.max(1, Math.floor(query.limit))) : 100;
8048
+ return {
8049
+ items: matching.slice(offset, offset + limit),
8050
+ total: matching.length
8051
+ };
8052
+ }
8053
+ __name(pageFan, "pageFan");
8054
+
7938
8055
  // src/codec-state-store.ts
7939
8056
  var CodecStateStore = class {
7940
8057
  static {
@@ -8940,6 +9057,7 @@ export {
8940
9057
  EVENT_TOKEN_PREFIX,
8941
9058
  Entities,
8942
9059
  EventAccumulators,
9060
+ FAN_SUMMARY_FAILURES,
8943
9061
  FatalError,
8944
9062
  GatherError,
8945
9063
  InMemoryAdmissionBackend,
@@ -8961,6 +9079,7 @@ export {
8961
9079
  SINGLETON_ADMITTED_TAG,
8962
9080
  STATE_STORE,
8963
9081
  STATE_STORE_CANONICAL,
9082
+ SUMMARY_CHILD_LIMIT,
8964
9083
  ScheduleAlreadyExistsError,
8965
9084
  ScheduleClient,
8966
9085
  ScheduleNotFoundError,
@@ -8987,6 +9106,7 @@ export {
8987
9106
  buildWorkflowDirectory,
8988
9107
  canRoute,
8989
9108
  capableWorkers,
9109
+ childIdsOf,
8990
9110
  classifyWaiterToken,
8991
9111
  clearDurableExecutionWrappers,
8992
9112
  clearTerminalSingletonAdmission,
@@ -9015,6 +9135,7 @@ export {
9015
9135
  info,
9016
9136
  isEngineMintedTag,
9017
9137
  isEventToken,
9138
+ isFailedMember,
9018
9139
  isLegacyDescriptor,
9019
9140
  isNonEmptyRunScope,
9020
9141
  isWorkflowControlFlowSignal,
@@ -9029,6 +9150,7 @@ export {
9029
9150
  normalizeAttributeRows,
9030
9151
  normalizeDescriptor,
9031
9152
  observedAnnouncements,
9153
+ pageFan,
9032
9154
  parentRunIdOf,
9033
9155
  parseDuration,
9034
9156
  partitionOfToken,
@@ -9058,6 +9180,8 @@ export {
9058
9180
  sub,
9059
9181
  subEvent,
9060
9182
  subProcess,
9183
+ summarizeFan,
9184
+ summarizeTimeline,
9061
9185
  tenantGroup,
9062
9186
  useDurableExecution,
9063
9187
  warn,