@shirudo/ddd-kit 3.0.0-rc.10 → 3.0.0-rc.11

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.
@@ -201,6 +201,14 @@ declare class FoldReturnedNoStateError extends KitWiringError<"FOLD_RETURNED_NO_
201
201
  readonly eventType: string;
202
202
  constructor(eventType: string);
203
203
  }
204
+ /** Constructor options for {@link DirectStateMutationError}. */
205
+ interface DirectStateMutationErrorOptions {
206
+ /** The aggregate the error names. */
207
+ readonly identity: {
208
+ readonly aggregateType: string;
209
+ readonly aggregateId: string;
210
+ };
211
+ }
204
212
  /**
205
213
  * Thrown by `EventSourcedAggregate.setState`: on an event-sourced aggregate
206
214
  * the state changes only through `apply()`, where the fact is recorded and
@@ -210,13 +218,13 @@ declare class FoldReturnedNoStateError extends KitWiringError<"FOLD_RETURNED_NO_
210
218
  * and a handler.
211
219
  */
212
220
  declare class DirectStateMutationError extends KitWiringError<"DIRECT_STATE_MUTATION"> {
213
- readonly aggregateId: string;
214
- constructor(aggregateId: string);
221
+ readonly identity: DirectStateMutationErrorOptions["identity"];
222
+ constructor(options: DirectStateMutationErrorOptions);
215
223
  }
216
224
  /**
217
225
  * Thrown by `Projector.project` when an event cannot be projected
218
226
  * safely because its cursor is missing or malformed, or its aggregate
219
- * address is absent. Applying such an event would break idempotency, so
227
+ * identity is absent. Applying such an event would break idempotency, so
220
228
  * the batch fails. Events written by `withCommit` carry the complete
221
229
  * cursor automatically; other sources compose a gap-proof committed-event
222
230
  * envelope. A well-formed cursor that does not continue the stored chain
@@ -357,6 +365,16 @@ declare class InvalidVersionError extends KitWiringError<"INVALID_VERSION"> {
357
365
  /** Why the value was rejected, for example "is not a safe integer". */
358
366
  reason: string);
359
367
  }
368
+ /** Constructor options for {@link UnreplayableAggregateError}. */
369
+ interface UnreplayableAggregateErrorOptions {
370
+ /** The aggregate the error names. */
371
+ readonly identity: {
372
+ readonly aggregateType: string;
373
+ readonly aggregateId: string;
374
+ };
375
+ /** Why the aggregate cannot take a replay, with the safe remedy. */
376
+ readonly reason: string;
377
+ }
360
378
  /**
361
379
  * Thrown by `EventSourcedAggregate.replayHistory` when the replay target
362
380
  * carries unflushed `pendingEvents`. Replaying persisted facts onto that
@@ -377,16 +395,17 @@ declare class InvalidVersionError extends KitWiringError<"INVALID_VERSION"> {
377
395
  * discard a dirty instance and replay into a fresh one.
378
396
  */
379
397
  declare class UnreplayableAggregateError extends KitWiringError<"UNREPLAYABLE_AGGREGATE"> {
380
- readonly aggregateId: string;
381
- constructor(aggregateId: string, reason: string);
398
+ readonly identity: UnreplayableAggregateErrorOptions["identity"];
399
+ constructor(options: UnreplayableAggregateErrorOptions);
382
400
  }
383
401
  /**
384
- * Constructor options for {@link MisaddressedEventError} and
385
- * {@link ForeignEventError}: the address of the aggregate that received the
386
- * event, and the address fields the event carries. A missing field on the
387
- * event matches by default, so `actual` names only what the event states.
402
+ * Constructor options for {@link MisattributedEventError} and
403
+ * {@link ForeignEventError}: the identity of the aggregate that received the
404
+ * event, and the aggregate identity fields the event carries. A missing
405
+ * field on the event matches by default, so `actual` names only what the
406
+ * event states.
388
407
  */
389
- interface AggregateAddressMismatchOptions {
408
+ interface AggregateIdentityMismatchOptions {
390
409
  readonly expected: {
391
410
  readonly aggregateType: string;
392
411
  readonly aggregateId: string;
@@ -401,26 +420,29 @@ interface AggregateAddressMismatchOptions {
401
420
  * Thrown by `EventSourcedAggregate.apply()` when a NEW event carries an
402
421
  * `aggregateId` or `aggregateType` naming a different aggregate: a
403
422
  * deterministic programming bug at the call site (a hand-built or
404
- * copied event addressed elsewhere), caught before the event can be
405
- * recorded and poison the own stream. Events with MISSING address
406
- * fields do not trip this: `apply()` stamps them from the aggregate,
423
+ * copied event that belongs elsewhere), caught before the event can be
424
+ * recorded and poison the own stream. Events with MISSING aggregate
425
+ * identity fields do not trip this: `apply()` stamps them from the aggregate,
407
426
  * the same guarantee `createEvent` gives. A wiring error, distinct
408
427
  * from {@link ForeignEventError} on purpose: a wrong new event is a
409
428
  * bug in today's code, a wrong PERSISTED row is corrupted or miswired
410
429
  * infrastructure, and handlers for one must not absorb the other.
411
430
  */
412
- declare class MisaddressedEventError extends KitWiringError<"MISADDRESSED_EVENT"> {
413
- /** Address of the aggregate that received the event. */
414
- readonly expected: AggregateAddressMismatchOptions["expected"];
415
- /** Address fields the event carries. */
416
- readonly actual: AggregateAddressMismatchOptions["actual"];
431
+ declare class MisattributedEventError extends KitWiringError<"MISATTRIBUTED_EVENT"> {
432
+ /** Identity of the aggregate that received the event. */
433
+ readonly expected: AggregateIdentityMismatchOptions["expected"];
434
+ /** Aggregate identity fields the event carries. */
435
+ readonly actual: AggregateIdentityMismatchOptions["actual"];
417
436
  readonly eventType: string;
418
- constructor(options: AggregateAddressMismatchOptions);
437
+ constructor(options: AggregateIdentityMismatchOptions);
419
438
  }
420
439
  /** Constructor options for {@link SnapshotVersionNotRestoredError}. */
421
440
  interface SnapshotVersionNotRestoredErrorOptions {
422
- readonly aggregateType: string;
423
- readonly aggregateId: string;
441
+ /** The aggregate the error names. */
442
+ readonly identity: {
443
+ readonly aggregateType: string;
444
+ readonly aggregateId: string;
445
+ };
424
446
  /** The version the snapshot carries. */
425
447
  readonly snapshotVersion: number;
426
448
  /** The version the factory's aggregate reports. */
@@ -435,8 +457,7 @@ interface SnapshotVersionNotRestoredErrorOptions {
435
457
  * channel would mask it as perpetual silent refolding.
436
458
  */
437
459
  declare class SnapshotVersionNotRestoredError extends KitWiringError<"SNAPSHOT_VERSION_NOT_RESTORED"> {
438
- readonly aggregateType: string;
439
- readonly aggregateId: string;
460
+ readonly identity: SnapshotVersionNotRestoredErrorOptions["identity"];
440
461
  readonly snapshotVersion: number;
441
462
  readonly restoredVersion: number;
442
463
  constructor(options: SnapshotVersionNotRestoredErrorOptions);
@@ -474,6 +495,14 @@ declare class SnapshotCorruptedError extends InfrastructureError<"SNAPSHOT_CORRU
474
495
  declare class UnmintedEventError extends KitWiringError<"UNMINTED_EVENT"> {
475
496
  constructor(eventType: string);
476
497
  }
498
+ /** Constructor options for {@link ReentrantEventRecordingError}. */
499
+ interface ReentrantEventRecordingErrorOptions {
500
+ /** The aggregate the error names. */
501
+ readonly identity: {
502
+ readonly aggregateType: string;
503
+ readonly aggregateId: string;
504
+ };
505
+ }
477
506
  /**
478
507
  * Thrown by `recordPendingEvents` when the aggregate's pending-event list
479
508
  * changes while its events are being stamped: a stamp provider that
@@ -485,7 +514,18 @@ declare class UnmintedEventError extends KitWiringError<"UNMINTED_EVENT"> {
485
514
  * stamp providers free of domain decisions.
486
515
  */
487
516
  declare class ReentrantEventRecordingError extends KitWiringError<"REENTRANT_EVENT_RECORDING"> {
488
- constructor(aggregateId: string);
517
+ readonly identity: ReentrantEventRecordingErrorOptions["identity"];
518
+ constructor(options: ReentrantEventRecordingErrorOptions);
519
+ }
520
+ /** Constructor options for {@link DuplicateEventIdError}. */
521
+ interface DuplicateEventIdErrorOptions {
522
+ /** The aggregate the error names. */
523
+ readonly identity: {
524
+ readonly aggregateType: string;
525
+ readonly aggregateId: string;
526
+ };
527
+ /** The event id two pending events would have shared. */
528
+ readonly eventId: string;
489
529
  }
490
530
  /**
491
531
  * Thrown when two facts of one aggregate would carry the same `eventId`.
@@ -499,16 +539,18 @@ declare class ReentrantEventRecordingError extends KitWiringError<"REENTRANT_EVE
499
539
  * identity per fact.
500
540
  */
501
541
  declare class DuplicateEventIdError extends KitWiringError<"DUPLICATE_EVENT_ID"> {
502
- /** The identity two pending events would have shared. */
542
+ readonly identity: DuplicateEventIdErrorOptions["identity"];
543
+ /** The event id two pending events would have shared. */
503
544
  readonly eventId: string;
504
- constructor(aggregateId: string,
505
- /** The identity two pending events would have shared. */
506
- eventId: string);
545
+ constructor(options: DuplicateEventIdErrorOptions);
507
546
  }
508
547
  /** Constructor options for {@link PendingEventLimitExceededError}. */
509
548
  interface PendingEventLimitExceededErrorOptions {
510
- readonly aggregateType: string;
511
- readonly aggregateId: string;
549
+ /** The aggregate the error names. */
550
+ readonly identity: {
551
+ readonly aggregateType: string;
552
+ readonly aggregateId: string;
553
+ };
512
554
  /** The configured `maxPendingEvents`. */
513
555
  readonly limit: number;
514
556
  /** Events pending before the rejected recording. */
@@ -526,13 +568,24 @@ interface PendingEventLimitExceededErrorOptions {
526
568
  * per decision.
527
569
  */
528
570
  declare class PendingEventLimitExceededError extends KitWiringError<"PENDING_EVENT_LIMIT_EXCEEDED"> {
529
- readonly aggregateType: string;
530
- readonly aggregateId: string;
571
+ readonly identity: PendingEventLimitExceededErrorOptions["identity"];
531
572
  readonly limit: number;
532
573
  readonly pending: number;
533
574
  readonly added: number;
534
575
  constructor(options: PendingEventLimitExceededErrorOptions);
535
576
  }
577
+ /** Constructor options for {@link PendingEventBatchMismatchError}. */
578
+ interface PendingEventBatchMismatchErrorOptions {
579
+ /** The aggregate the error names. */
580
+ readonly identity: {
581
+ readonly aggregateType: string;
582
+ readonly aggregateId: string;
583
+ };
584
+ /** Events in the committed batch. */
585
+ readonly batchLength: number;
586
+ /** Events pending on the aggregate. */
587
+ readonly pendingLength: number;
588
+ }
536
589
  /**
537
590
  * Thrown by the post-commit acknowledgement of an aggregate when the
538
591
  * committed batch is not the prefix of its pending events any more. The
@@ -543,10 +596,10 @@ declare class PendingEventLimitExceededError extends KitWiringError<"PENDING_EVE
543
596
  * orchestration: acknowledge exactly the batch that was enrolled, once.
544
597
  */
545
598
  declare class PendingEventBatchMismatchError extends KitWiringError<"PENDING_EVENT_BATCH_MISMATCH"> {
546
- readonly aggregateId: string;
599
+ readonly identity: PendingEventBatchMismatchErrorOptions["identity"];
547
600
  readonly batchLength: number;
548
601
  readonly pendingLength: number;
549
- constructor(aggregateId: string, batchLength: number, pendingLength: number);
602
+ constructor(options: PendingEventBatchMismatchErrorOptions);
550
603
  }
551
604
  /**
552
605
  * Thrown by persisted-event consumers (including `replayHistory` and
@@ -555,79 +608,177 @@ declare class PendingEventBatchMismatchError extends KitWiringError<"PENDING_EVE
555
608
  * the persisted row belongs to someone else (a miswired stream read,
556
609
  * ids colliding across aggregate types, a corrupted store). An
557
610
  * `InfrastructureError`, NOT a `DomainError` (same posture as
558
- * {@link SnapshotSchemaMismatchError}): a wrong address is data
611
+ * {@link SnapshotSchemaMismatchError}): a wrong aggregate identity is data
559
612
  * corruption or wiring, never an expected business rejection, so it
560
613
  * must not be absorbed by generic domain error handling or presented
561
614
  * as a 4xx. It therefore PROPAGATES as a throw through the replay
562
615
  * methods' `Result` contract (which reserves `Err` for `DomainError`),
563
616
  * after the usual all-or-nothing rollback. History events without the
564
- * optional address fields pass unchecked (the fields are optional on
617
+ * optional aggregate identity fields pass unchecked (the fields are optional on
565
618
  * the event shape); new events are covered by
566
- * {@link MisaddressedEventError}.
619
+ * {@link MisattributedEventError}.
567
620
  */
568
621
  declare class ForeignEventError extends InfrastructureError<"FOREIGN_EVENT"> {
569
- /** Address of the aggregate that received the event. */
570
- readonly expected: AggregateAddressMismatchOptions["expected"];
571
- /** Address fields the event carries. */
572
- readonly actual: AggregateAddressMismatchOptions["actual"];
622
+ /** Identity of the aggregate that received the event. */
623
+ readonly expected: AggregateIdentityMismatchOptions["expected"];
624
+ /** Aggregate identity fields the event carries. */
625
+ readonly actual: AggregateIdentityMismatchOptions["actual"];
573
626
  readonly eventType: string;
574
- constructor(options: AggregateAddressMismatchOptions);
575
- }
576
- /** Constructor options for {@link NonProgressingEventStreamPageError}. */
577
- interface NonProgressingEventStreamPageErrorOptions {
578
- readonly aggregateType: string;
579
- readonly aggregateId: string;
580
- /** Exclusive continuation cursor supplied to `EventStore.readStream`. */
627
+ constructor(options: AggregateIdentityMismatchOptions);
628
+ }
629
+ /** How a page of a stream read breaks the `readStream` contract. */
630
+ type EventStreamPageReason = "empty_page" | "stream_vanished" | "page_past_target" | "page_over_limit" | "head_regressed" | "invalid_head";
631
+ /** Constructor options for {@link InvalidEventStreamPageError}. */
632
+ interface InvalidEventStreamPageErrorOptions {
633
+ /** The aggregate the error names. */
634
+ readonly identity: {
635
+ readonly aggregateType: string;
636
+ readonly aggregateId: string;
637
+ };
638
+ /** How the page breaks the contract; see {@link EventStreamPageReason}. */
639
+ readonly reason: EventStreamPageReason;
640
+ /** The exclusive cursor the page followed. */
581
641
  readonly fromVersion: number;
582
- /** Pinned inclusive stream version the replay still has to reach. */
583
- readonly targetVersion: number;
642
+ /**
643
+ * The pinned inclusive target version. Absent for `invalid_head` on the
644
+ * first page: that page pins no target.
645
+ */
646
+ readonly targetVersion?: number;
647
+ /**
648
+ * The stream head the page reported, as the adapter returned it. Present
649
+ * for `head_regressed` and `invalid_head`.
650
+ */
651
+ readonly lastVersion?: unknown;
652
+ /** The stream head the first page reported. Present for `head_regressed`. */
653
+ readonly firstPageLastVersion?: number;
654
+ /**
655
+ * The number of events on the page. Present for `page_past_target` and
656
+ * `page_over_limit`.
657
+ */
658
+ readonly eventCount?: number;
659
+ /** The page limit the read asked for. Present for `page_over_limit`. */
660
+ readonly limit?: number;
584
661
  }
585
662
  /**
586
- * Thrown by a paged EventStore consumer when `readStream` returns no events
587
- * even though its continuation cursor has not reached the pinned target.
588
- * Such a page cannot advance and violates the EventStore port contract; a
589
- * replay loop that merely continued would spin forever.
663
+ * Thrown when a page of a stream read breaks the `readStream` contract.
664
+ * `readStreamPages` checks every page it reads, and
665
+ * `reconstituteAggregateFromStreamPages` checks every page an adapter that
666
+ * pages on its own hands over. Both throw this error for the same defect.
590
667
  *
591
- * This is a non-retryable infrastructure error: the persistence adapter
592
- * deterministically contradicted its port contract, so retrying the same read
593
- * is not a recovery policy. Run `createEventStoreContractTests` against the
594
- * adapter and fix its windowing/continuation implementation.
668
+ * The `reason` names the defect. `empty_page`: the page holds no event,
669
+ * but events remain before the target version. `stream_vanished`: a
670
+ * continuation page reports the stream absent. `page_past_target`: the
671
+ * page holds more events than its window has left. `page_over_limit`: the
672
+ * page holds more events than the `limit` of the read. `head_regressed`: a
673
+ * continuation page reports a head below the head of the first page.
674
+ * `invalid_head`: a page of an existing stream reports a head that is not
675
+ * a safe integer of at least 1, for example `0` for a stream without
676
+ * events, or a string from a driver that returns big integers as text.
677
+ *
678
+ * No case is retryable. Fix the adapter: run `createEventStoreContractTests`
679
+ * against an EventStore adapter, and `createReplayableStreamPagesContractTests`
680
+ * against an adapter that pages on its own. Two causes lie outside the
681
+ * adapter. A stream is append-only, and only a physical removal deletes it
682
+ * (the repository guide, "Domain deletion versus physical removal"), so a
683
+ * removal that runs during the read gives `stream_vanished`. An upcaster
684
+ * that splits one stored event into several gives `page_past_target` at
685
+ * the replay, because the replay counts one version per event.
595
686
  */
596
- declare class NonProgressingEventStreamPageError extends InfrastructureError<"NON_PROGRESSING_EVENT_STREAM_PAGE"> {
597
- readonly aggregateType: string;
598
- readonly aggregateId: string;
687
+ declare class InvalidEventStreamPageError extends InfrastructureError<"INVALID_EVENT_STREAM_PAGE"> {
688
+ readonly identity: InvalidEventStreamPageErrorOptions["identity"];
689
+ readonly reason: EventStreamPageReason;
599
690
  readonly fromVersion: number;
691
+ readonly targetVersion: number | undefined;
692
+ readonly lastVersion: unknown;
693
+ readonly firstPageLastVersion: number | undefined;
694
+ readonly eventCount: number | undefined;
695
+ readonly limit: number | undefined;
696
+ constructor(options: InvalidEventStreamPageErrorOptions);
697
+ }
698
+ /** The check a {@link ReplayTargetMismatchError} reports. */
699
+ type ReplayTargetMismatchReason = "target_not_at_cursor" | "pages_short_of_target";
700
+ /** Constructor options for {@link ReplayTargetMismatchError}. */
701
+ interface ReplayTargetMismatchErrorOptions {
702
+ /** The aggregate the error names. */
703
+ readonly identity: {
704
+ readonly aggregateType: string;
705
+ readonly aggregateId: string;
706
+ };
707
+ /** The check that failed; see {@link ReplayTargetMismatchReason}. */
708
+ readonly reason: ReplayTargetMismatchReason;
709
+ /** The cursor the read started at; the replay target must start here. */
710
+ readonly fromVersion: number;
711
+ /**
712
+ * Pinned inclusive target the replay had to reach: the stream head, or
713
+ * `toVersion` on a point-in-time read.
714
+ */
600
715
  readonly targetVersion: number;
601
- constructor(options: NonProgressingEventStreamPageErrorOptions);
602
- }
603
- /** Constructor options for {@link ReplayHeadMismatchError}. */
604
- interface ReplayHeadMismatchErrorOptions {
605
- readonly aggregateType: string;
606
- readonly aggregateId: string;
607
- /** Pinned inclusive stream head the replay had to reach. */
608
- readonly targetVersion: number;
609
- /** Version the aggregate holds after the replay. */
716
+ /** Version the aggregate held when the check ran. */
610
717
  readonly actualVersion: number;
611
718
  }
612
719
  /**
613
- * Thrown by a load recipe when the replayed aggregate does not end at the
614
- * pinned stream head. Events carry no stream position, so the aggregate
615
- * cannot detect a tail that overlaps the restored version or a page that
616
- * lies outside the requested window; only the caller, which pinned the
617
- * head, can compare. A snapshot catch-up passes only the events after the
618
- * restored version, and the final version must equal the head.
720
+ * Thrown by `reconstituteAggregateFromStreamPages`, or by a load recipe
721
+ * that replays on its own, when the replay target does not line up with the
722
+ * read. Events carry no stream position, so the aggregate cannot detect a
723
+ * tail that overlaps or misses the version it was reconstituted at. Only
724
+ * the caller, which pinned the target version, can compare. A single page
725
+ * that breaks its window is an {@link InvalidEventStreamPageError} instead.
619
726
  *
620
- * This is a non-retryable infrastructure error: the persistence adapter
621
- * contradicted its port contract. Run `createEventStoreContractTests` and
622
- * `createEsRepositoryContractTests` against the adapter and fix its
623
- * windowing.
727
+ * The `reason` names the check that failed. `target_not_at_cursor`: the
728
+ * replay target stands at a version other than the `fromVersion` the read
729
+ * used, found before any page is replayed; a reconstitution factory reports
730
+ * the wrong version. `pages_short_of_target`: the pages ended before the
731
+ * target version. The read stopped early, the stream has a gap, or an
732
+ * upcaster merged several stored events into one. For an EventStore
733
+ * adapter, run `createEventStoreContractTests` and
734
+ * `createEsRepositoryContractTests` against it and fix its windowing. None
735
+ * of the cases is retryable. A snapshot beyond its stream does not reach
736
+ * the replay: `readStreamPages` reports that window as unreachable first,
737
+ * and an adapter that pages on its own must do the same.
624
738
  */
625
- declare class ReplayHeadMismatchError extends InfrastructureError<"REPLAY_HEAD_MISMATCH"> {
626
- readonly aggregateType: string;
627
- readonly aggregateId: string;
739
+ declare class ReplayTargetMismatchError extends InfrastructureError<"REPLAY_TARGET_MISMATCH"> {
740
+ readonly identity: ReplayTargetMismatchErrorOptions["identity"];
741
+ readonly reason: ReplayTargetMismatchReason;
742
+ readonly fromVersion: number;
628
743
  readonly targetVersion: number;
629
744
  readonly actualVersion: number;
630
- constructor(options: ReplayHeadMismatchErrorOptions);
745
+ constructor(options: ReplayTargetMismatchErrorOptions);
746
+ }
747
+ /** Constructor options for {@link ReplayRejectedError}. */
748
+ interface ReplayRejectedErrorOptions {
749
+ /** The aggregate the error names. */
750
+ readonly identity: {
751
+ readonly aggregateType: string;
752
+ readonly aggregateId: string;
753
+ };
754
+ /**
755
+ * The version the aggregate held before the rejected page. With
756
+ * `toVersion`, it bounds the window `(fromVersion, toVersion]` of the
757
+ * rejected page, not the window of the read.
758
+ */
759
+ readonly fromVersion: number;
760
+ /** The last stream position of the rejected page (inclusive). */
761
+ readonly toVersion: number;
762
+ /** The error the aggregate raised for a stored event of the page. */
763
+ readonly cause: DomainError;
764
+ }
765
+ /**
766
+ * The `Err` of `reconstituteAggregateFromStreamPages`: the aggregate
767
+ * rejected a stored event while it replayed a page of the stream.
768
+ *
769
+ * The window `(fromVersion, toVersion]` locates the rejected page, and
770
+ * `cause` holds the `DomainError` of the aggregate. A stored stream that
771
+ * the domain cannot replay is a defect of the stored data, not a request
772
+ * the caller can correct. So this is an `InfrastructureError`, and it is
773
+ * not retryable. An empty window means that the replay target rejected an
774
+ * empty history before the first page.
775
+ */
776
+ declare class ReplayRejectedError extends InfrastructureError<"REPLAY_REJECTED"> {
777
+ readonly identity: ReplayRejectedErrorOptions["identity"];
778
+ readonly fromVersion: number;
779
+ readonly toVersion: number;
780
+ readonly cause: DomainError;
781
+ constructor(options: ReplayRejectedErrorOptions);
631
782
  }
632
783
  /**
633
784
  * Thrown when an event harvested from an aggregate cannot be safely composed
@@ -767,6 +918,16 @@ declare class ErrorMapperFailedError extends KitWiringError<"ERROR_MAPPER_FAILED
767
918
  readonly mapperCause: unknown;
768
919
  constructor(options: ErrorMapperFailedErrorOptions);
769
920
  }
921
+ /** Constructor options for {@link UnenrolledChangesError}. */
922
+ interface UnenrolledChangesErrorOptions {
923
+ /** The aggregate the error names. */
924
+ readonly identity: {
925
+ readonly aggregateType: string;
926
+ readonly aggregateId: string;
927
+ };
928
+ /** Whether the repository of the aggregate is append-only. */
929
+ readonly appendOnly?: boolean;
930
+ }
770
931
  /**
771
932
  * Thrown at the end of a `UnitOfWork.run` when an aggregate that was
772
933
  * loaded into the identity map changed but no `update` intent was registered.
@@ -791,10 +952,16 @@ declare class ErrorMapperFailedError extends KitWiringError<"ERROR_MAPPER_FAILED
791
952
  * change.
792
953
  */
793
954
  declare class UnenrolledChangesError extends KitWiringError<"UNENROLLED_CHANGES"> {
794
- readonly aggregateId: string;
795
- constructor(aggregateId: string, options?: {
796
- readonly appendOnly?: boolean;
797
- });
955
+ readonly identity: UnenrolledChangesErrorOptions["identity"];
956
+ constructor(options: UnenrolledChangesErrorOptions);
957
+ }
958
+ /** Constructor options for {@link AggregateDeletedError}. */
959
+ interface AggregateDeletedErrorOptions {
960
+ /** The aggregate the error names. */
961
+ readonly identity: {
962
+ readonly aggregateType: string;
963
+ readonly aggregateId: string;
964
+ };
798
965
  }
799
966
  /**
800
967
  * Thrown when an aggregate removed within the current unit of work is added,
@@ -807,8 +974,8 @@ declare class UnenrolledChangesError extends KitWiringError<"UNENROLLED_CHANGES"
807
974
  * loud, not be absorbed by a generic infrastructure-error handler.
808
975
  */
809
976
  declare class AggregateDeletedError extends KitWiringError<"AGGREGATE_DELETED"> {
810
- readonly aggregateId: string;
811
- constructor(aggregateId: string);
977
+ readonly identity: AggregateDeletedErrorOptions["identity"];
978
+ constructor(options: AggregateDeletedErrorOptions);
812
979
  }
813
980
  /**
814
981
  * Thrown by `AggregatePersistence.getById()` when an aggregate with the
@@ -824,14 +991,16 @@ declare class AggregateDeletedError extends KitWiringError<"AGGREGATE_DELETED">
824
991
  * Not retryable: retrying won't make the row appear.
825
992
  */
826
993
  interface AggregateNotFoundErrorOptions {
827
- readonly aggregateType: string;
828
- readonly id: string;
994
+ /** The aggregate the error names. */
995
+ readonly identity: {
996
+ readonly aggregateType: string;
997
+ readonly aggregateId: string;
998
+ };
829
999
  /** Optional lower-level error to preserve in the cause chain. */
830
1000
  readonly cause?: unknown;
831
1001
  }
832
1002
  declare class AggregateNotFoundError extends InfrastructureError<"AGGREGATE_NOT_FOUND"> {
833
- readonly aggregateType: string;
834
- readonly id: string;
1003
+ readonly identity: AggregateNotFoundErrorOptions["identity"];
835
1004
  constructor(options: AggregateNotFoundErrorOptions);
836
1005
  }
837
1006
  /**
@@ -854,14 +1023,16 @@ declare class AggregateNotFoundError extends InfrastructureError<"AGGREGATE_NOT_
854
1023
  * request as already-applied.
855
1024
  */
856
1025
  interface DuplicateAggregateErrorOptions {
857
- readonly aggregateType: string;
858
- readonly aggregateId: string;
1026
+ /** The aggregate the error names. */
1027
+ readonly identity: {
1028
+ readonly aggregateType: string;
1029
+ readonly aggregateId: string;
1030
+ };
859
1031
  /** Optional driver-level error to preserve in the cause chain. */
860
1032
  readonly cause?: unknown;
861
1033
  }
862
1034
  declare class DuplicateAggregateError extends InfrastructureError<"DUPLICATE_AGGREGATE"> {
863
- readonly aggregateType: string;
864
- readonly aggregateId: string;
1035
+ readonly identity: DuplicateAggregateErrorOptions["identity"];
865
1036
  constructor(options: DuplicateAggregateErrorOptions);
866
1037
  }
867
1038
  /**
@@ -880,14 +1051,16 @@ declare class DuplicateAggregateError extends InfrastructureError<"DUPLICATE_AGG
880
1051
  * truth.
881
1052
  */
882
1053
  interface SnapshotSchemaMismatchErrorOptions {
883
- readonly aggregateType: string;
884
- readonly aggregateId: string;
1054
+ /** The aggregate the error names. */
1055
+ readonly identity: {
1056
+ readonly aggregateType: string;
1057
+ readonly aggregateId: string;
1058
+ };
885
1059
  readonly expectedSchemaVersion: number;
886
1060
  readonly actualSchemaVersion: number;
887
1061
  }
888
1062
  declare class SnapshotSchemaMismatchError extends InfrastructureError<"SNAPSHOT_SCHEMA_MISMATCH"> {
889
- readonly aggregateType: string;
890
- readonly aggregateId: string;
1063
+ readonly identity: SnapshotSchemaMismatchErrorOptions["identity"];
891
1064
  readonly expectedSchemaVersion: number;
892
1065
  readonly actualSchemaVersion: number;
893
1066
  constructor(options: SnapshotSchemaMismatchErrorOptions);
@@ -926,8 +1099,13 @@ type ConcurrencyConflictReason =
926
1099
  /** The version read failed. The failure travels as the cause. */
927
1100
  "version_unknown";
928
1101
  type ConcurrencyConflictErrorOptions = {
929
- readonly aggregateType: string;
930
- readonly aggregateId: string;
1102
+ /** The aggregate the error names. */
1103
+ readonly identity: {
1104
+ readonly aggregateType: string;
1105
+ readonly aggregateId: string;
1106
+ };
1107
+ /** The write that failed, or `null` when the raising code does not know it. */
1108
+ readonly intent?: "add" | "update" | "remove" | null;
931
1109
  readonly expectedVersion: number;
932
1110
  /** Optional driver-level error to preserve in the cause chain. */
933
1111
  readonly cause?: unknown;
@@ -960,8 +1138,9 @@ type ConcurrencyConflictErrorOptions = {
960
1138
  * but `version_unchanged`, which names a defect of the adapter.
961
1139
  */
962
1140
  declare class ConcurrencyConflictError extends InfrastructureError<"CONCURRENCY_CONFLICT"> {
963
- readonly aggregateType: string;
964
- readonly aggregateId: string;
1141
+ readonly identity: ConcurrencyConflictErrorOptions["identity"];
1142
+ /** The write that failed, or `null` when the raising code does not know it. */
1143
+ readonly intent: NonNullable<ConcurrencyConflictErrorOptions["intent"]> | null;
965
1144
  readonly expectedVersion: number;
966
1145
  /** The stored version, or `null` when none exists to name. */
967
1146
  readonly actualVersion: number | null;
@@ -1075,7 +1254,7 @@ declare class IdempotencyCompletionWithoutClaimError extends KitWiringError<"IDE
1075
1254
  * base-error `matchError` cases that cover kit and consumer codes
1076
1255
  * together, without importing anything from base-error.
1077
1256
  */
1078
- type KitErrorCode = "AGGREGATE_DELETED" | "AGGREGATE_NOT_FOUND" | "AGGREGATE_TRACKING" | "CAPABILITY_REGISTRY_CONFLICT" | "COMMIT_FAILED" | "CONCURRENCY_CONFLICT" | "DIRECT_STATE_MUTATION" | "DOMAIN_TRANSITION_GUARD_REJECTED" | "DUPLICATE_AGGREGATE" | "DUPLICATE_EVENT_ID" | "DUPLICATE_HANDLER_REGISTRATION" | "ERROR_MAPPER_FAILED" | "EVENT_ADDRESS_INVALID" | "EVENT_BUS_CLOSED" | "EVENT_HARVEST_FAILED" | "EVENT_ID_INVALID" | "EVENT_ID_REQUIRED" | "EVENT_OCCURRED_AT_INVALID" | "EVENT_OCCURRED_AT_REQUIRED" | "EVENT_SCHEMA_VERSION_INVALID" | "EVENT_TYPE_INVALID" | "FOLD_RETURNED_NO_STATE" | "FOREIGN_EVENT" | "HOSTILE_STATE_KEY" | "IDEMPOTENCY_CLAIM_LOST" | "IDEMPOTENCY_COMPLETED_WITHOUT_CLAIM" | "IDEMPOTENCY_IN_FLIGHT" | "IDEMPOTENCY_KEY_REUSE" | "IDEMPOTENCY_RECONCILIATION_REQUIRED" | "IN_MEMORY_CAPACITY_EXCEEDED" | "INVALID_DOMAIN_MACHINE_CONTEXT" | "INVALID_DOMAIN_MACHINE_DEFINITION" | "INVALID_DOMAIN_MACHINE_INPUT" | "INVALID_DOMAIN_MACHINE_SNAPSHOT" | "INVALID_DOMAIN_TRANSITION" | "INVALID_DOMAIN_TRANSITION_GUARD_RESULT" | "INVALID_DOMAIN_TRANSITION_RESULT" | "INVALID_COMMAND_MESSAGE" | "INVALID_FLUSH_STATEMENT" | "INVALID_INTEGRATION_MESSAGE" | "INVALID_MONEY" | "INVALID_REPOSITORY_ADAPTER" | "INVALID_REPOSITORY_DEFINITION" | "INVALID_VERSION" | "MISADDRESSED_EVENT" | "MISSING_ENTITY_ID" | "MISSING_FOLD" | "MISSING_HANDLER" | "MONEY_CURRENCY_MISMATCH" | "MONEY_PRECISION_LOSS" | "MONEY_SCALE_MISMATCH" | "NESTED_UNIT_OF_WORK" | "NON_PROGRESSING_EVENT_STREAM_PAGE" | "PENDING_EVENT_BATCH_MISMATCH" | "PENDING_EVENT_LIMIT_EXCEEDED" | "PROJECTION_GAP" | "PROJECTION_IDENTITY_VIOLATION" | "PROJECTION_ORDER_VIOLATION" | "PROJECTION_RECEIPT_VIOLATION" | "PUBLISH_DEPTH_EXCEEDED" | "REENTRANT_DOMAIN_STATE_MACHINE_EVALUATION" | "REENTRANT_EVENT_RECORDING" | "REPLAY_HEAD_MISMATCH" | "REPOSITORY_ERROR_MAPPING_FAILED" | "ROLLBACK_FAILED" | "SNAPSHOT_CORRUPTED" | "SNAPSHOT_SCHEMA_MISMATCH" | "SNAPSHOT_TIME_INVALID" | "SNAPSHOT_VERSION_NOT_RESTORED" | "TRANSACTION_CLOSED" | "UNENROLLED_CHANGES" | "UNKNOWN_CURRENCY" | "UNMANAGED_INSTANCE" | "UNMINTED_EVENT" | "UNPROJECTABLE_EVENT" | "UNREGISTERED_HANDLER" | "UNREPLAYABLE_AGGREGATE";
1257
+ type KitErrorCode = "AGGREGATE_DELETED" | "AGGREGATE_NOT_FOUND" | "AGGREGATE_TRACKING" | "CAPABILITY_REGISTRY_CONFLICT" | "COMMIT_FAILED" | "CONCURRENCY_CONFLICT" | "DIRECT_STATE_MUTATION" | "DOMAIN_TRANSITION_GUARD_REJECTED" | "DUPLICATE_AGGREGATE" | "DUPLICATE_EVENT_ID" | "DUPLICATE_HANDLER_REGISTRATION" | "ERROR_MAPPER_FAILED" | "EVENT_AGGREGATE_IDENTITY_INVALID" | "EVENT_BUS_CLOSED" | "EVENT_HARVEST_FAILED" | "EVENT_ID_INVALID" | "EVENT_ID_REQUIRED" | "EVENT_OCCURRED_AT_INVALID" | "EVENT_OCCURRED_AT_REQUIRED" | "EVENT_SCHEMA_VERSION_INVALID" | "EVENT_TYPE_INVALID" | "FOLD_RETURNED_NO_STATE" | "FOREIGN_EVENT" | "HOSTILE_STATE_KEY" | "IDEMPOTENCY_CLAIM_LOST" | "IDEMPOTENCY_COMPLETED_WITHOUT_CLAIM" | "IDEMPOTENCY_IN_FLIGHT" | "IDEMPOTENCY_KEY_REUSE" | "IDEMPOTENCY_RECONCILIATION_REQUIRED" | "IN_MEMORY_CAPACITY_EXCEEDED" | "INVALID_DOMAIN_MACHINE_CONTEXT" | "INVALID_DOMAIN_MACHINE_DEFINITION" | "INVALID_DOMAIN_MACHINE_INPUT" | "INVALID_DOMAIN_MACHINE_SNAPSHOT" | "INVALID_DOMAIN_TRANSITION" | "INVALID_DOMAIN_TRANSITION_GUARD_RESULT" | "INVALID_DOMAIN_TRANSITION_RESULT" | "INVALID_COMMAND_MESSAGE" | "INVALID_EVENT_STREAM_PAGE" | "INVALID_FLUSH_STATEMENT" | "INVALID_INTEGRATION_MESSAGE" | "INVALID_MONEY" | "INVALID_REPOSITORY_ADAPTER" | "INVALID_REPOSITORY_DEFINITION" | "INVALID_VERSION" | "MISATTRIBUTED_EVENT" | "MISSING_ENTITY_ID" | "MISSING_FOLD" | "MISSING_HANDLER" | "MONEY_CURRENCY_MISMATCH" | "MONEY_PRECISION_LOSS" | "MONEY_SCALE_MISMATCH" | "NESTED_UNIT_OF_WORK" | "PENDING_EVENT_BATCH_MISMATCH" | "PENDING_EVENT_LIMIT_EXCEEDED" | "PROJECTION_GAP" | "PROJECTION_IDENTITY_VIOLATION" | "PROJECTION_ORDER_VIOLATION" | "PROJECTION_RECEIPT_VIOLATION" | "PUBLISH_DEPTH_EXCEEDED" | "REENTRANT_DOMAIN_STATE_MACHINE_EVALUATION" | "REENTRANT_EVENT_RECORDING" | "REPLAY_REJECTED" | "REPLAY_TARGET_MISMATCH" | "REPOSITORY_ERROR_MAPPING_FAILED" | "ROLLBACK_FAILED" | "SNAPSHOT_CORRUPTED" | "SNAPSHOT_SCHEMA_MISMATCH" | "SNAPSHOT_TIME_INVALID" | "SNAPSHOT_VERSION_NOT_RESTORED" | "TRANSACTION_CLOSED" | "UNENROLLED_CHANGES" | "UNKNOWN_CURRENCY" | "UNMANAGED_INSTANCE" | "UNMINTED_EVENT" | "UNPROJECTABLE_EVENT" | "UNREGISTERED_HANDLER" | "UNREPLAYABLE_AGGREGATE";
1079
1258
  //#endregion
1080
- export { ReentrantEventRecordingError as $, IdempotencyReconciliationRequiredErrorOptions as A, MisaddressedEventError as B, IdempotencyClaimLostErrorOptions as C, IdempotencyKeyReuseError as D, IdempotencyInFlightErrorOptions as E, InvalidIntegrationMessageError as F, NonProgressingEventStreamPageErrorOptions as G, MissingFoldError as H, InvalidVersionError as I, PendingEventLimitExceededErrorOptions as J, PendingEventBatchMismatchError as K, KitErrorCode as L, InMemoryCapacityExceededErrorOptions as M, InfrastructureError as N, IdempotencyKeyReuseErrorOptions as O, InvalidCommandMessageError as P, ProjectionReceiptViolationError as Q, KitErrorOptions as R, IdempotencyClaimLostError as S, IdempotencyInFlightError as T, MissingHandlerError as U, MissingEntityIdError as V, NonProgressingEventStreamPageError as W, ProjectionIdentityViolationError as X, ProjectionGapError as Y, ProjectionOrderViolationError as Z, ErrorMapperFailedErrorOptions as _, CapabilityRegistryConflictError as a, SnapshotVersionNotRestoredError as at, ForeignEventError as b, ConcurrencyConflictReason as c, UnmanagedInstanceError as ct, DuplicateAggregateError as d, UnregisteredHandlerError as dt, ReplayHeadMismatchError as et, DuplicateAggregateErrorOptions as f, UnregisteredHandlerErrorOptions as ft, ErrorMapperFailedError as g, isWiringErrorLike as gt, DuplicateHandlerRegistrationErrorOptions as h, isInfrastructureErrorLike as ht, AggregateNotFoundErrorOptions as i, SnapshotSchemaMismatchErrorOptions as it, InMemoryCapacityExceededError as j, IdempotencyReconciliationRequiredError as k, DirectStateMutationError as l, UnmintedEventError as lt, DuplicateHandlerRegistrationError as m, isDomainErrorLike as mt, AggregateDeletedError as n, SnapshotCorruptedError as nt, ConcurrencyConflictError as o, SnapshotVersionNotRestoredErrorOptions as ot, DuplicateEventIdError as p, UnreplayableAggregateError as pt, PendingEventLimitExceededError as q, AggregateNotFoundError as r, SnapshotSchemaMismatchError as rt, ConcurrencyConflictErrorOptions as s, UnenrolledChangesError as st, AggregateAddressMismatchOptions as t, ReplayHeadMismatchErrorOptions as tt, DomainError as u, UnprojectableEventError as ut, EventHarvestError as v, IdempotencyCompletionWithoutClaimError as w, HostileStateKeyError as x, FoldReturnedNoStateError as y, KitWiringError as z };
1259
+ export { PendingEventLimitExceededErrorOptions as $, IdempotencyInFlightErrorOptions as A, InvalidEventStreamPageErrorOptions as B, FoldReturnedNoStateError as C, UnreplayableAggregateError as Ct, IdempotencyClaimLostErrorOptions as D, isWiringErrorLike as Dt, IdempotencyClaimLostError as E, isInfrastructureErrorLike as Et, InMemoryCapacityExceededError as F, KitWiringError as G, InvalidVersionError as H, InMemoryCapacityExceededErrorOptions as I, MissingFoldError as J, MisattributedEventError as K, InfrastructureError as L, IdempotencyKeyReuseErrorOptions as M, IdempotencyReconciliationRequiredError as N, IdempotencyCompletionWithoutClaimError as O, IdempotencyReconciliationRequiredErrorOptions as P, PendingEventLimitExceededError as Q, InvalidCommandMessageError as R, EventStreamPageReason as S, UnregisteredHandlerErrorOptions as St, HostileStateKeyError as T, isDomainErrorLike as Tt, KitErrorCode as U, InvalidIntegrationMessageError as V, KitErrorOptions as W, PendingEventBatchMismatchError as X, MissingHandlerError as Y, PendingEventBatchMismatchErrorOptions as Z, DuplicateHandlerRegistrationError as _, UnenrolledChangesErrorOptions as _t, AggregateNotFoundErrorOptions as a, ReentrantEventRecordingErrorOptions as at, ErrorMapperFailedErrorOptions as b, UnprojectableEventError as bt, ConcurrencyConflictErrorOptions as c, ReplayTargetMismatchError as ct, DirectStateMutationErrorOptions as d, SnapshotCorruptedError as dt, ProjectionGapError as et, DomainError as f, SnapshotSchemaMismatchError as ft, DuplicateEventIdErrorOptions as g, UnenrolledChangesError as gt, DuplicateEventIdError as h, SnapshotVersionNotRestoredErrorOptions as ht, AggregateNotFoundError as i, ReentrantEventRecordingError as it, IdempotencyKeyReuseError as j, IdempotencyInFlightError as k, ConcurrencyConflictReason as l, ReplayTargetMismatchErrorOptions as lt, DuplicateAggregateErrorOptions as m, SnapshotVersionNotRestoredError as mt, AggregateDeletedErrorOptions as n, ProjectionOrderViolationError as nt, CapabilityRegistryConflictError as o, ReplayRejectedError as ot, DuplicateAggregateError as p, SnapshotSchemaMismatchErrorOptions as pt, MissingEntityIdError as q, AggregateIdentityMismatchOptions as r, ProjectionReceiptViolationError as rt, ConcurrencyConflictError as s, ReplayRejectedErrorOptions as st, AggregateDeletedError as t, ProjectionIdentityViolationError as tt, DirectStateMutationError as u, ReplayTargetMismatchReason as ut, DuplicateHandlerRegistrationErrorOptions as v, UnmanagedInstanceError as vt, ForeignEventError as w, UnreplayableAggregateErrorOptions as wt, EventHarvestError as x, UnregisteredHandlerError as xt, ErrorMapperFailedError as y, UnmintedEventError as yt, InvalidEventStreamPageError as z };
1081
1260
  //# sourceMappingURL=kit-errors.d.ts.map