@shirudo/ddd-kit 3.0.0-rc.3 → 3.0.0-rc.5
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/README.md +7 -21
- package/dist/chunks/{errors.d.ts → kit-errors.d.ts} +272 -48
- package/dist/chunks/{errors.js → kit-errors.js} +275 -57
- package/dist/chunks/kit-errors.js.map +1 -0
- package/dist/chunks/ports.js +829 -95
- package/dist/chunks/ports.js.map +1 -1
- package/dist/chunks/snapshot-store.d.ts +925 -1338
- package/dist/http.d.ts +2 -3
- package/dist/http.js +1 -1
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +3441 -2445
- package/dist/index.js +5188 -4383
- package/dist/index.js.map +1 -1
- package/dist/money.d.ts +11 -11
- package/dist/money.js +9 -9
- package/dist/money.js.map +1 -1
- package/dist/{presentation.d.ts → public-errors.d.ts} +5 -6
- package/dist/{presentation.js → public-errors.js} +5 -5
- package/dist/public-errors.js.map +1 -0
- package/dist/testing.d.ts +61 -11
- package/dist/testing.js +526 -56
- package/dist/testing.js.map +1 -1
- package/package.json +17 -17
- package/dist/chunks/deep-equal-except.js +0 -639
- package/dist/chunks/deep-equal-except.js.map +0 -1
- package/dist/chunks/errors.js.map +0 -1
- package/dist/chunks/utils.d.ts +0 -110
- package/dist/presentation.js.map +0 -1
- package/dist/utils.d.ts +0 -2
- package/dist/utils.js +0 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kit-errors.js","names":[],"sources":["../../src/errors/kit-errors.ts"],"sourcesContent":["import { StructuredError } from \"@shirudo/base-error\";\n\n/**\n * **The kit's error identity model (since v3).** Every kit error is a\n * structured error carrying exactly ONE identifier: `code`, a stable\n * SCREAMING_SNAKE string, and `error.name === error.code` by design, so\n * there is no name/code drift and nothing to keep in sync. `category`\n * follows the class hierarchy mechanically (`\"DOMAIN\"`,\n * `\"INFRASTRUCTURE\"`, or `\"WIRING\"` for the crash-loud family) and\n * `retryable` is a plain boolean field.\n *\n * **No base-error adoption required.** Consumers branch with a plain\n * `switch (error.code)`, catch via `instanceof DomainError` /\n * `instanceof InfrastructureError` (exported from this kit), and read\n * `retryable` / `cause` as ordinary properties. base-error's toolbox\n * (`matchError` exhaustive dispatch, `isStructuredError`, the\n * public-error catalog and `toProblem`) works on every kit error as an\n * OPT-IN benefit on top, never as a prerequisite.\n */\n\n/**\n * Options for consumer subclasses of {@link DomainError} and\n * {@link InfrastructureError}: the `code` (which also becomes\n * `error.name`) and the technical `message` are the only obligations;\n * `retryable` defaults to `false` and the category is fixed by the base.\n */\nexport interface KitErrorOptions<TCode extends string> {\n\t/** Stable SCREAMING_SNAKE identifier; also becomes `error.name`. */\n\tcode: TCode;\n\t/** Technical message for logs and debugging, never for clients. */\n\tmessage: string;\n\t/** Optional underlying error preserved in the cause chain. */\n\tcause?: unknown;\n\t/** Whether retrying the failed operation can succeed. Default `false`. */\n\tretryable?: boolean;\n}\n\n/**\n * Abstract base for **domain-invariant violations**. Domain methods\n * (aggregates, entity validation hooks, value-object constructors)\n * throw `DomainError`-derived exceptions when a business rule is\n * violated. Consumers derive their own concrete errors (e.g.\n * `class OrderAlreadyShippedError extends DomainError<\"ORDER_ALREADY_SHIPPED\">`)\n * for `instanceof`-style catching at the App-Service boundary, where\n * they typically map to HTTP 400 / business-rule responses.\n *\n * The library itself ships no business-rule `DomainError` subclass: the\n * kit can't know your invariants. (The domain-state-machine module's\n * transition errors are the structural exception.)\n *\n * The `category` is fixed to `\"DOMAIN\"` and `retryable` defaults to\n * `false`, so a subclass supplies only its `code` and `message`:\n *\n * ```ts\n * class OrderAlreadyShippedError extends DomainError<\"ORDER_ALREADY_SHIPPED\"> {\n * constructor(orderId: string) {\n * super({\n * code: \"ORDER_ALREADY_SHIPPED\",\n * message: `Order ${orderId} has already been shipped`,\n * });\n * }\n * }\n * ```\n */\nexport abstract class DomainError<\n\tTCode extends string = string,\n> extends StructuredError<TCode, \"DOMAIN\"> {\n\tprotected constructor(options: KitErrorOptions<TCode>) {\n\t\tsuper({\n\t\t\tcode: options.code,\n\t\t\tcategory: \"DOMAIN\",\n\t\t\tretryable: options.retryable ?? false,\n\t\t\tmessage: options.message,\n\t\t\tcause: options.cause,\n\t\t});\n\t}\n}\n\n/**\n * Internal base for the kit's crash-loud **WIRING** family: deterministic\n * programming/configuration bugs that must fail the operation loudly and\n * never be absorbed by generic domain or infrastructure handlers. One\n * implementation of the `{ category: \"WIRING\", retryable: false }` shape\n * so the family cannot drift. Exported for the kit's own modules only;\n * not part of the package entries.\n */\nexport abstract class KitWiringError<\n\tTCode extends string,\n> extends StructuredError<TCode, \"WIRING\"> {\n\tprotected constructor(code: TCode, message: string, cause?: unknown) {\n\t\tsuper({ code, category: \"WIRING\", retryable: false, message, cause });\n\t}\n}\n\n/**\n * Abstract base for **infrastructure / persistence failures** that the\n * App-Service can recover from: typically by retrying, by returning\n * HTTP 404 / 409, or by surfacing a \"please try again\" UX. These are\n * not domain-invariant violations (the business rules were not\n * broken); they describe race conditions and missing rows at the\n * storage boundary.\n *\n * The `category` is fixed to `\"INFRASTRUCTURE\"`; `retryable` defaults\n * to `false` (opt in per subclass, see {@link ConcurrencyConflictError}).\n *\n * Library-internal concrete subclasses: {@link AggregateNotFoundError},\n * {@link ConcurrencyConflictError}, {@link DuplicateAggregateError},\n * plus the unit-of-work lifecycle wrappers `CommitError` and\n * `RollbackError` (in `src/application/unit-of-work/errors.ts`).\n */\nexport abstract class InfrastructureError<\n\tTCode extends string = string,\n> extends StructuredError<TCode, \"INFRASTRUCTURE\"> {\n\tprotected constructor(options: KitErrorOptions<TCode>) {\n\t\tsuper({\n\t\t\tcode: options.code,\n\t\t\tcategory: \"INFRASTRUCTURE\",\n\t\t\tretryable: options.retryable ?? false,\n\t\t\tmessage: options.message,\n\t\t\tcause: options.cause,\n\t\t});\n\t}\n}\n\n/**\n * Copy-safe membership check for the kit's domain-error family.\n *\n * `instanceof` is false for an error constructed by another loaded copy of\n * the kit (a separately installed adapter package, a CJS/ESM dual load), so\n * kit boundaries that route by error family fall back to the structural\n * `category` field, the stable cross-copy contract.\n */\nexport function isDomainErrorLike(value: unknown): value is DomainError {\n\treturn (\n\t\tvalue instanceof DomainError ||\n\t\t(value instanceof Error &&\n\t\t\t(value as { readonly category?: unknown }).category === \"DOMAIN\")\n\t);\n}\n\n/**\n * Copy-safe membership check for the kit's infrastructure-error family.\n * Same rationale as {@link isDomainErrorLike}.\n */\nexport function isInfrastructureErrorLike(\n\tvalue: unknown,\n): value is InfrastructureError {\n\treturn (\n\t\tvalue instanceof InfrastructureError ||\n\t\t(value instanceof Error &&\n\t\t\t(value as { readonly category?: unknown }).category === \"INFRASTRUCTURE\")\n\t);\n}\n\n/** Options bag for {@link InMemoryCapacityExceededError}. */\nexport interface InMemoryCapacityExceededErrorOptions {\n\t/** Concrete reference adapter whose configured capacity was exhausted. */\n\treadonly store: string;\n\t/** Bounded collection or logical resource, such as `events` or `sources`. */\n\treadonly resource: string;\n\t/** Configured maximum number of retained records. */\n\treadonly limit: number;\n\t/** Records retained before the rejected operation. */\n\treadonly current: number;\n\t/** New records the rejected operation would have retained. */\n\treadonly attempted: number;\n}\n\n/**\n * A finite-capacity in-memory reference adapter rejected new state before\n * mutation. Existing records remain usable; callers must release explicit\n * lifecycle state, increase the configured limit, or switch to a durable\n * adapter. The error is not retryable without one of those external changes.\n */\nexport class InMemoryCapacityExceededError extends InfrastructureError<\"IN_MEMORY_CAPACITY_EXCEEDED\"> {\n\treadonly store: string;\n\treadonly resource: string;\n\treadonly limit: number;\n\treadonly current: number;\n\treadonly attempted: number;\n\n\tconstructor(options: InMemoryCapacityExceededErrorOptions) {\n\t\tsuper({\n\t\t\tcode: \"IN_MEMORY_CAPACITY_EXCEEDED\",\n\t\t\tmessage:\n\t\t\t\t`${options.store} cannot retain ${options.attempted} new ` +\n\t\t\t\t`${options.resource}: configured limit ${options.limit}, ` +\n\t\t\t\t`currently retained ${options.current}`,\n\t\t});\n\t\tthis.store = options.store;\n\t\tthis.resource = options.resource;\n\t\tthis.limit = options.limit;\n\t\tthis.current = options.current;\n\t\tthis.attempted = options.attempted;\n\t}\n}\n\n/**\n * Thrown when a projection built with `projectionFromHandlers` receives an\n * event type with no own handler entry: the declared event union and the\n * handler map disagree at runtime, which is a programming / configuration\n * bug rather than a domain or infrastructure failure.\n *\n * Deliberately **not** on `DomainError` or `InfrastructureError`:\n * a generic `catch (e instanceof DomainError)` handler at the App\n * layer must not mask a forgotten handler; this should crash loud and\n * fail the calling Use Case so the bug surfaces in development.\n *\n * Use `isBaseError(e)` from `@shirudo/base-error` to detect\n * \"any structured error from the kit or any other BaseError-using\n * library\" at the App boundary.\n */\nexport class MissingHandlerError extends KitWiringError<\"MISSING_HANDLER\"> {\n\tconstructor(\n\t\tpublic readonly eventType: string,\n\t\tcause?: unknown,\n\t) {\n\t\tsuper(\n\t\t\t\"MISSING_HANDLER\",\n\t\t\t`Missing handler for event type: ${eventType}`,\n\t\t\tcause,\n\t\t);\n\t}\n}\n\n/**\n * Thrown by an event-sourced aggregate when `apply()` or replay reaches an\n * event type with no own entry in the `folds` map: the declared event union\n * and the map disagree at runtime. Same posture as\n * {@link MissingHandlerError}: a deterministic bug, never a domain\n * rejection, so it propagates through `replayHistory` instead of riding its\n * `Result`.\n */\nexport class MissingFoldError extends KitWiringError<\"MISSING_FOLD\"> {\n\tconstructor(\n\t\tpublic readonly eventType: string,\n\t\tcause?: unknown,\n\t) {\n\t\tsuper(\"MISSING_FOLD\", `Missing fold for event type: ${eventType}`, cause);\n\t}\n}\n\n/**\n * Thrown by an event-sourced aggregate when a fold returns `undefined`\n * for an event, which is almost always a fold without a `return` statement.\n * Storing that result would set the aggregate state to `undefined`, record\n * the fact anyway on the apply path, and leave every later fold working on\n * nothing. Same posture as {@link MissingFoldError}: a deterministic bug\n * in the folds map, never a domain rejection, so it propagates through\n * `replayHistory` instead of riding its `Result`.\n */\nexport class FoldReturnedNoStateError extends KitWiringError<\"FOLD_RETURNED_NO_STATE\"> {\n\tconstructor(public readonly eventType: string) {\n\t\tsuper(\n\t\t\t\"FOLD_RETURNED_NO_STATE\",\n\t\t\t`The fold for event type \"${eventType}\" returned no state. ` +\n\t\t\t\t\"A fold must return the next state; check for a missing \" +\n\t\t\t\t\"return statement.\",\n\t\t);\n\t}\n}\n\n/**\n * Thrown by `EventSourcedAggregate.setState`: on an event-sourced aggregate\n * the state changes only through `apply()`, where the fact is recorded and\n * the version advances with it. A direct state write would leave the\n * instance ahead of its stream with nothing to replay. A wiring error: a\n * deterministic bug in the aggregate's own code, the remedy is an event\n * and a handler.\n */\nexport class DirectStateMutationError extends KitWiringError<\"DIRECT_STATE_MUTATION\"> {\n\tconstructor(public readonly aggregateId: string) {\n\t\tsuper(\n\t\t\t\"DIRECT_STATE_MUTATION\",\n\t\t\t`Aggregate ${aggregateId} is event-sourced: its state changes only ` +\n\t\t\t\t\"through apply(). Record the fact as an event and fold it in a \" +\n\t\t\t\t\"handler instead of calling setState.\",\n\t\t);\n\t}\n}\n\n/**\n * Thrown by `Projector.project` when an event cannot be projected\n * safely because its cursor is missing or malformed, or its aggregate\n * address is absent. Applying such an event would break idempotency, so\n * the batch fails. Events written by `withCommit` carry the complete\n * cursor automatically; other sources compose a gap-proof committed-event\n * envelope. A well-formed cursor that does not continue the stored chain\n * instead throws {@link ProjectionGapError}.\n *\n * A wiring error, not a `DomainError`: see {@link MissingHandlerError}\n * for the rationale of crashing loud at the App layer.\n */\nexport class UnprojectableEventError extends KitWiringError<\"UNPROJECTABLE_EVENT\"> {\n\tconstructor(\n\t\tpublic readonly projection: string,\n\t\tpublic readonly eventId: string,\n\t\treason: string,\n\t\tcause?: unknown,\n\t) {\n\t\tsuper(\n\t\t\t\"UNPROJECTABLE_EVENT\",\n\t\t\t`Projector(${projection}): event ${eventId} ${reason}`,\n\t\t\tcause,\n\t\t);\n\t}\n}\n\n/**\n * Thrown when a valid projection cursor does not continue the stored\n * per-aggregate chain. This is an infrastructure/delivery failure: an\n * event or commit is missing, commonly because a partition reordered or\n * dead-lettered it. The projector does not apply the later event and the\n * checkpoint stays put until the missing history is replayed or the\n * projection is rebuilt.\n */\nexport class ProjectionGapError extends InfrastructureError<\"PROJECTION_GAP\"> {\n\tconstructor(\n\t\tpublic readonly projection: string,\n\t\tpublic readonly eventId: string,\n\t\tpublic readonly previousPosition: string,\n\t\tpublic readonly receivedPosition: string,\n\t) {\n\t\tsuper({\n\t\t\tcode: \"PROJECTION_GAP\",\n\t\t\tmessage:\n\t\t\t\t`Projector(${projection}): event ${eventId} creates a projection ` +\n\t\t\t\t`gap after ${previousPosition}; received ${receivedPosition}. ` +\n\t\t\t\t\"Replay the missing commit before advancing the checkpoint.\",\n\t\t});\n\t}\n}\n\n/**\n * Thrown when one batch delivers previously unseen positions of the same\n * aggregate in descending order. Unlike {@link ProjectionGapError}, this is\n * direct proof that the feed violated its per-aggregate ordering contract;\n * no missing-history inference is needed. Positions already covered by the\n * checkpoint at batch start and exact receipts repeated inside the batch\n * remain valid redeliveries and do not trip this diagnostic guard.\n */\nexport class ProjectionOrderViolationError extends InfrastructureError<\"PROJECTION_ORDER_VIOLATION\"> {\n\tconstructor(\n\t\tpublic readonly projection: string,\n\t\tpublic readonly eventId: string,\n\t\tpublic readonly previousReceivedPosition: string,\n\t\tpublic readonly receivedPosition: string,\n\t) {\n\t\tsuper({\n\t\t\tcode: \"PROJECTION_ORDER_VIOLATION\",\n\t\t\tmessage:\n\t\t\t\t`Projector(${projection}): event ${eventId} at ${receivedPosition} ` +\n\t\t\t\t`arrived after the later unprocessed position ${previousReceivedPosition} ` +\n\t\t\t\t\"in the same batch. Partition or serialize the feed by aggregate source.\",\n\t\t});\n\t}\n}\n\n/**\n * Thrown when a source maps different event identities to one position, either\n * inside the current batch or at the position stored as the projection's\n * watermark. The checkpoint retains the identity of that one last-applied\n * event, so the durable collision is provable without keeping an unbounded\n * processed-event ledger. Positions behind the watermark remain governed by\n * the source's one-logical-event-per-position contract.\n */\nexport class ProjectionIdentityViolationError extends InfrastructureError<\"PROJECTION_IDENTITY_VIOLATION\"> {\n\tconstructor(\n\t\tpublic readonly projection: string,\n\t\tpublic readonly eventId: string,\n\t\tpublic readonly recordedEventId: string,\n\t\tpublic readonly position: string,\n\t) {\n\t\tsuper({\n\t\t\tcode: \"PROJECTION_IDENTITY_VIOLATION\",\n\t\t\tmessage:\n\t\t\t\t`Projector(${projection}): position ${position} was already associated ` +\n\t\t\t\t`with event ${recordedEventId}, but the source supplied event ${eventId} ` +\n\t\t\t\t\"at the same position. A source must map exactly one logical event to each position.\",\n\t\t});\n\t}\n}\n\n/**\n * Thrown when one logical projection position keeps its event identity but its\n * commit-boundary receipt changes. `commitSize` and\n * `previousEventfulAggregateVersion` are part of the continuity proof, so a\n * source must keep them immutable just like the eventId. Accepting a\n * contradictory redelivery could hide an incomplete commit or predecessor.\n */\nexport class ProjectionReceiptViolationError extends InfrastructureError<\"PROJECTION_RECEIPT_VIOLATION\"> {\n\tconstructor(\n\t\tpublic readonly projection: string,\n\t\tpublic readonly eventId: string,\n\t\tpublic readonly recordedReceipt: string,\n\t\tpublic readonly receivedReceipt: string,\n\t) {\n\t\tsuper({\n\t\t\tcode: \"PROJECTION_RECEIPT_VIOLATION\",\n\t\t\tmessage:\n\t\t\t\t`Projector(${projection}): event ${eventId} changed its commit receipt ` +\n\t\t\t\t`at one logical position from ${recordedReceipt} to ${receivedReceipt}. ` +\n\t\t\t\t\"A source must keep commitSize and previousEventfulAggregateVersion immutable.\",\n\t\t});\n\t}\n}\n\n/** A malformed or non-JSON-safe message at an integration boundary. */\nexport class InvalidIntegrationMessageError extends InfrastructureError<\"INVALID_INTEGRATION_MESSAGE\"> {\n\tconstructor(\n\t\tpublic readonly path: string,\n\t\tpublic readonly reason: string,\n\t\tcause?: unknown,\n\t) {\n\t\tsuper({\n\t\t\tcode: \"INVALID_INTEGRATION_MESSAGE\",\n\t\t\tmessage: `Invalid integration message at ${path}: ${reason}`,\n\t\t\tcause,\n\t\t});\n\t}\n}\n\n/** A malformed or non-JSON-safe command selected for durable delivery. */\nexport class InvalidCommandMessageError extends InfrastructureError<\"INVALID_COMMAND_MESSAGE\"> {\n\tconstructor(\n\t\tpublic readonly path: string,\n\t\tpublic readonly reason: string,\n\t\tcause?: unknown,\n\t) {\n\t\tsuper({\n\t\t\tcode: \"INVALID_COMMAND_MESSAGE\",\n\t\t\tmessage: `Invalid command message at ${path}: ${reason}`,\n\t\t\tcause,\n\t\t});\n\t}\n}\n\n/**\n * Thrown by `Entity` (constructor and `setState`), by the event-sourced\n * fold (`apply` and replay), by the event constructors for the payload,\n * and by the event metadata helpers (`createDomainEvent`'s\n * `options.metadata`, `mergeMetadata`, `copyMetadata`) when the value\n * carries an own `\"__proto__\"` data key:\n * the shape `JSON.parse` produces for hostile DB rows or request bodies\n * handed to reconstitute factories. Such a key can never be legitimate\n * domain state; accepting it would hand a prototype-pollution payload to\n * every downstream consumer that copies the state through `[[Set]]`\n * (`Object.assign`, for-in assignment loops), and dropping it would be\n * silent data mutation. The check looks at the root object only; nested\n * objects are not walked, and a class instance is an ownership transfer\n * that passes.\n *\n * Deliberately **not** a `DomainError` or `InfrastructureError` (same\n * posture as {@link MissingHandlerError}): untrusted input reaching the\n * domain layer unvalidated is a boundary bug, and a generic\n * business-rule handler must not absorb it. Validate and strip untrusted\n * input at the application edge; model genuinely arbitrary keys with a\n * `Map`, not a plain object.\n */\nexport class HostileStateKeyError extends KitWiringError<\"HOSTILE_STATE_KEY\"> {\n\tconstructor(\n\t\tpublic readonly key: string,\n\t\tsubject: string = \"Entity state\",\n\t) {\n\t\tsuper(\n\t\t\t\"HOSTILE_STATE_KEY\",\n\t\t\t`${subject} carries a hostile own \"${key}\" key, which can never ` +\n\t\t\t\t\"be legitimate domain data. Validate and strip untrusted input \" +\n\t\t\t\t\"at the boundary, or model arbitrary keys with a Map.\",\n\t\t);\n\t}\n}\n\n/**\n * Thrown by the `Entity` constructor when the id is not a non-blank\n * string. That covers `null`, `undefined`, a blank string, and a\n * non-string value that reached the constructor through a cast. An\n * entity without a usable identity cannot be tracked, compared, or\n * persisted, so the construction fails before any state is stored. A\n * wiring error: a deterministic bug at the call site, never a domain\n * rejection.\n */\nexport class MissingEntityIdError extends KitWiringError<\"MISSING_ENTITY_ID\"> {\n\tconstructor(\n\t\t/** The rejected value, for the message only; never a usable id. */\n\t\treceived: unknown,\n\t) {\n\t\tsuper(\n\t\t\t\"MISSING_ENTITY_ID\",\n\t\t\t`Entity ID must be a non-blank string; received ${describeRejectedId(received)}.`,\n\t\t);\n\t}\n}\n\n// Never throws: an object with no primitive conversion is described by\n// its kind, so the coded error reaches the caller for every input.\nfunction describeRejectedId(value: unknown): string {\n\tif (typeof value === \"string\") return JSON.stringify(value);\n\tif (value === null) return \"null\";\n\tif (value === undefined) return \"undefined\";\n\tif (typeof value === \"object\")\n\t\treturn Array.isArray(value) ? \"array\" : \"object\";\n\tif (typeof value === \"function\") return \"function\";\n\treturn `${typeof value} ${String(value)}`;\n}\n\n/**\n * Thrown when a number that is not a valid aggregate version reaches the\n * kit: `toVersion`, `markReconstituted`, `setVersion`, and the post-commit\n * acknowledgement all reject it. A version is a safe integer of at least\n * zero, and a restore never moves below the current version. A wiring\n * error: an adapter passed a corrupt row value or a wrong number, and\n * the optimistic-concurrency cursor must not carry it. Not retryable.\n */\nexport class InvalidVersionError extends KitWiringError<\"INVALID_VERSION\"> {\n\tconstructor(\n\t\tpublic readonly value: unknown,\n\t\t/** Why the value was rejected, for example \"is not a safe integer\". */\n\t\tpublic readonly reason: string,\n\t) {\n\t\tsuper(\n\t\t\t\"INVALID_VERSION\",\n\t\t\t`Version ${String(value)} ${reason}. A version is a safe integer of ` +\n\t\t\t\t\"at least zero; create one with toVersion(n) from the stored \" +\n\t\t\t\t\"row value.\",\n\t\t);\n\t}\n}\n\n/**\n * Thrown by `EventSourcedAggregate.replayHistory` when the replay target\n * carries unflushed `pendingEvents`. Replaying persisted facts onto that\n * instance would advance the version underneath decisions made against an\n * older state and could later claim history the stream does not carry.\n *\n * Deliberately **not** a `DomainError` or `InfrastructureError` (same\n * posture as {@link MissingHandlerError}): a deterministic programming\n * bug in how the aggregate was constructed before the restore. It\n * propagates as a throw instead of riding the replay methods' `Result`\n * channel, so a generic corrupted-stream handler cannot absorb it.\n * Reconstitution belongs on a bare instance: construct the aggregate\n * without factory-recorded events or prior mutations, then restore.\n *\n * Each throw site carries the safe remedy in its `reason`. Persistence\n * lifecycle state is intentionally not mutable through the aggregate API:\n * commit an actually saved instance through application orchestration, or\n * discard a dirty instance and replay into a fresh one.\n */\nexport class UnreplayableAggregateError extends KitWiringError<\"UNREPLAYABLE_AGGREGATE\"> {\n\tconstructor(\n\t\tpublic readonly aggregateId: string,\n\t\treason: string,\n\t) {\n\t\tsuper(\n\t\t\t\"UNREPLAYABLE_AGGREGATE\",\n\t\t\t`Cannot replay onto aggregate ${aggregateId}: ${reason}. ` +\n\t\t\t\t\"Reconstitute on a fresh instance (no factory-recorded events, \" +\n\t\t\t\t\"no unpersisted mutations).\",\n\t\t);\n\t}\n}\n\n/**\n * Constructor options for {@link MisaddressedEventError} and\n * {@link ForeignEventError}: the address of the aggregate that received the\n * event, and the address fields the event carries. A missing field on the\n * event matches by default, so `actual` names only what the event states.\n */\nexport interface AggregateAddressMismatchOptions {\n\treadonly expected: {\n\t\treadonly aggregateType: string;\n\t\treadonly aggregateId: string;\n\t};\n\treadonly actual: {\n\t\treadonly aggregateType?: string;\n\t\treadonly aggregateId?: string;\n\t};\n\treadonly eventType: string;\n}\n\n/** The address the event names; a missing field falls back to the receiving aggregate. */\nfunction describeEventAddress(\n\toptions: AggregateAddressMismatchOptions,\n): string {\n\tconst { expected, actual } = options;\n\treturn `${actual.aggregateType ?? expected.aggregateType} ${actual.aggregateId ?? expected.aggregateId}`;\n}\n\n/**\n * Thrown by `EventSourcedAggregate.apply()` when a NEW event carries an\n * `aggregateId` or `aggregateType` naming a different aggregate: a\n * deterministic programming bug at the call site (a hand-built or\n * copied event addressed elsewhere), caught before the event can be\n * recorded and poison the own stream. Events with MISSING address\n * fields do not trip this: `apply()` stamps them from the aggregate,\n * the same guarantee `createEvent` gives. A wiring error, distinct\n * from {@link ForeignEventError} on purpose: a wrong new event is a\n * bug in today's code, a wrong PERSISTED row is corrupted or miswired\n * infrastructure, and handlers for one must not absorb the other.\n */\nexport class MisaddressedEventError extends KitWiringError<\"MISADDRESSED_EVENT\"> {\n\t/** Address of the aggregate that received the event. */\n\treadonly expected: AggregateAddressMismatchOptions[\"expected\"];\n\t/** Address fields the event carries. */\n\treadonly actual: AggregateAddressMismatchOptions[\"actual\"];\n\treadonly eventType: string;\n\n\tconstructor(options: AggregateAddressMismatchOptions) {\n\t\tsuper(\n\t\t\t\"MISADDRESSED_EVENT\",\n\t\t\t`New event \"${options.eventType}\" is addressed to ` +\n\t\t\t\t`${describeEventAddress(options)} but was applied on ` +\n\t\t\t\t`${options.expected.aggregateType} ${options.expected.aggregateId}: ` +\n\t\t\t\t\"fix the call site (createEvent stamps the right address).\",\n\t\t);\n\t\tthis.expected = options.expected;\n\t\tthis.actual = options.actual;\n\t\tthis.eventType = options.eventType;\n\t}\n}\n\n/** Constructor options for {@link SnapshotVersionNotRestoredError}. */\nexport interface SnapshotVersionNotRestoredErrorOptions {\n\treadonly aggregateType: string;\n\treadonly aggregateId: string;\n\t/** The version the snapshot carries. */\n\treadonly snapshotVersion: number;\n\t/** The version the factory's aggregate reports. */\n\treadonly restoredVersion: number;\n}\n\n/**\n * Thrown by `reconstituteAggregateFromSnapshot` when the `reconstitute`\n * factory returns an aggregate at a version other than the snapshot\n * version. The factory ignored the version parameter, usually a forgotten\n * `markReconstituted(version)`. A wiring error in the snapshot model,\n * never snapshot corruption: routing it into the discard-and-refold\n * channel would mask it as perpetual silent refolding.\n */\nexport class SnapshotVersionNotRestoredError extends KitWiringError<\"SNAPSHOT_VERSION_NOT_RESTORED\"> {\n\treadonly aggregateType: string;\n\treadonly aggregateId: string;\n\treadonly snapshotVersion: number;\n\treadonly restoredVersion: number;\n\n\tconstructor(options: SnapshotVersionNotRestoredErrorOptions) {\n\t\tsuper(\n\t\t\t\"SNAPSHOT_VERSION_NOT_RESTORED\",\n\t\t\t`SnapshotModel.reconstitute for ${options.aggregateType} ` +\n\t\t\t\t`${options.aggregateId} returned an aggregate at version ` +\n\t\t\t\t`${options.restoredVersion} for a snapshot at version ` +\n\t\t\t\t`${options.snapshotVersion}. Reconstitution must restore ` +\n\t\t\t\t\"the persisted version; call markReconstituted(version) inside \" +\n\t\t\t\t\"the aggregate factory.\",\n\t\t);\n\t\tthis.aggregateType = options.aggregateType;\n\t\tthis.aggregateId = options.aggregateId;\n\t\tthis.snapshotVersion = options.snapshotVersion;\n\t\tthis.restoredVersion = options.restoredVersion;\n\t}\n}\n\n/**\n * The structural-integrity rejection for a stored snapshot. A consumer's\n * adapter-owned `SnapshotModel` may throw it from migration or reconstitution\n * when the blob could not have been produced by any version of the model\n * (missing fields, impossible types, truncated data). An\n * `InfrastructureError`, because corrupted persistence is a storage\n * problem, never a business rejection; it is nevertheless RECOVERABLE\n * by design: the repository catches it, discards the derived snapshot, and\n * refolds from the authoritative event stream.\n */\nexport class SnapshotCorruptedError extends InfrastructureError<\"SNAPSHOT_CORRUPTED\"> {\n\tconstructor(message: string, cause?: unknown) {\n\t\tsuper({ code: \"SNAPSHOT_CORRUPTED\", message, cause });\n\t}\n}\n\n/**\n * Thrown when an event reaches the aggregate's recording paths\n * (`apply`, `setState`, `addDomainEvent`) without having been minted by\n * the kit's constructors: `createDomainEvent`,\n * `createDomainEventFromFacts`, `createUncommittedDomainEvent`, or the\n * aggregate `createEvent` helper. Those constructors deep-freeze the\n * event, defensively copy payload and metadata, and mark the result as\n * minted. The mark has two tiers: a\n * module-private one for events of this loaded copy of the kit, and a\n * cooperative `Symbol.for` brand that a second loaded copy stamps and\n * recognizes. Anything else (a hand-rolled literal, a shallow-frozen\n * copy with mutable nested data) is rejected: a mutable event recorded\n * next to a state change can silently diverge from it afterwards. A\n * wiring error: deterministic bug at the call site, the remedy is\n * minting through the constructors. The gate catches accidents, not\n * adversaries: code in the same process can fake the brand.\n */\nexport class UnmintedEventError extends KitWiringError<\"UNMINTED_EVENT\"> {\n\tconstructor(eventType: string) {\n\t\tsuper(\n\t\t\t\"UNMINTED_EVENT\",\n\t\t\t`Event \"${eventType}\" was not minted by a domain-event constructor ` +\n\t\t\t\t\"or aggregate createEvent(...) helper. Those \" +\n\t\t\t\t\"constructors deep-freeze the event \" +\n\t\t\t\t\"and defensively copy payload and metadata; a mutable event \" +\n\t\t\t\t\"could diverge from the state change it records.\",\n\t\t);\n\t}\n}\n\n/**\n * Thrown by `recordPendingEvents` when the aggregate's pending-event list\n * changes while its events are being stamped: a stamp provider that\n * directly or transitively triggers a new decision on the same aggregate\n * would otherwise have that decision silently discarded when recording\n * replaces the pending list. Recording is atomic: when this guard fires,\n * every decision (including the re-entrant one) remains unrecorded. A\n * wiring error: deterministic bug at the call site, the remedy is keeping\n * stamp providers free of domain decisions.\n */\nexport class ReentrantEventRecordingError extends KitWiringError<\"REENTRANT_EVENT_RECORDING\"> {\n\tconstructor(aggregateId: string) {\n\t\tsuper(\n\t\t\t\"REENTRANT_EVENT_RECORDING\",\n\t\t\t`Pending events of aggregate ${aggregateId} changed while ` +\n\t\t\t\t\"recordPendingEvents was stamping them. A stamp provider must not \" +\n\t\t\t\t\"trigger new decisions on the aggregate being recorded; make every \" +\n\t\t\t\t\"domain decision first, then record.\",\n\t\t);\n\t}\n}\n\n/**\n * Thrown when two facts of one aggregate would carry the same `eventId`.\n * Two causes, two sites: the aggregate rejects a recorded event that is\n * already pending at the append, before the state moves; and\n * `recordPendingEvents` rejects a stamp provider that returns one reused\n * stamp (or repeats an explicit id). Either would mint two distinct facts\n * sharing one identity, and downstream idempotent consumers keyed on\n * `eventId` silently drop one of them. A wiring error: deterministic bug at\n * the append site or in the stamp provider, the remedy is one fresh\n * identity per fact.\n */\nexport class DuplicateEventIdError extends KitWiringError<\"DUPLICATE_EVENT_ID\"> {\n\tconstructor(\n\t\taggregateId: string,\n\t\t/** The identity two pending events would have shared. */\n\t\tpublic readonly eventId: string,\n\t) {\n\t\tsuper(\n\t\t\t\"DUPLICATE_EVENT_ID\",\n\t\t\t`Two pending events of aggregate ${aggregateId} carry the same ` +\n\t\t\t\t`eventId \"${eventId}\". Each fact needs its own identity: append ` +\n\t\t\t\t\"a recorded event once, and return a fresh stamp per decision \" +\n\t\t\t\t\"from the stamp provider.\",\n\t\t);\n\t}\n}\n\n/** Constructor options for {@link PendingEventLimitExceededError}. */\nexport interface PendingEventLimitExceededErrorOptions {\n\treadonly aggregateType: string;\n\treadonly aggregateId: string;\n\t/** The configured `maxPendingEvents`. */\n\treadonly limit: number;\n\t/** Events pending before the rejected recording. */\n\treadonly pending: number;\n\t/** Events the rejected recording would have added. */\n\treadonly added: number;\n}\n\n/**\n * Thrown when a recording would grow the pending list of an aggregate past\n * `AggregateConfig.maxPendingEvents`. The check runs before the state\n * moves, so the rejected decision records nothing and moves nothing. The\n * limit is a modelling signal, not a runtime budget: a decision that emits\n * hundreds of facts points at a missing aggregate boundary, and a retry\n * repeats it. A wiring error: split the aggregate, or emit fewer facts\n * per decision.\n */\nexport class PendingEventLimitExceededError extends KitWiringError<\"PENDING_EVENT_LIMIT_EXCEEDED\"> {\n\treadonly aggregateType: string;\n\treadonly aggregateId: string;\n\treadonly limit: number;\n\treadonly pending: number;\n\treadonly added: number;\n\n\tconstructor(options: PendingEventLimitExceededErrorOptions) {\n\t\tsuper(\n\t\t\t\"PENDING_EVENT_LIMIT_EXCEEDED\",\n\t\t\t`Aggregate ${options.aggregateType}(${options.aggregateId}) holds ` +\n\t\t\t\t`${options.pending} pending event(s) and cannot record ` +\n\t\t\t\t`${options.added} more: maxPendingEvents is ${options.limit}. ` +\n\t\t\t\t\"A decision that emits this many facts points at a missing \" +\n\t\t\t\t\"aggregate boundary.\",\n\t\t);\n\t\tthis.aggregateType = options.aggregateType;\n\t\tthis.aggregateId = options.aggregateId;\n\t\tthis.limit = options.limit;\n\t\tthis.pending = options.pending;\n\t\tthis.added = options.added;\n\t}\n}\n\n/**\n * Thrown by the post-commit acknowledgement of an aggregate when the\n * committed batch is not the prefix of its pending events any more. The\n * batch is longer than the pending list, or an event in it is not the\n * pending event at the same position. Acknowledging such a batch would\n * drop decisions the commit never persisted or keep events it did. The\n * pending list stays untouched. A wiring error in application commit\n * orchestration: acknowledge exactly the batch that was enrolled, once.\n */\nexport class PendingEventBatchMismatchError extends KitWiringError<\"PENDING_EVENT_BATCH_MISMATCH\"> {\n\tconstructor(\n\t\tpublic readonly aggregateId: string,\n\t\tpublic readonly batchLength: number,\n\t\tpublic readonly pendingLength: number,\n\t) {\n\t\tsuper(\n\t\t\t\"PENDING_EVENT_BATCH_MISMATCH\",\n\t\t\t`The committed batch of ${batchLength} event(s) is no longer the ` +\n\t\t\t\t`pending prefix of aggregate ${aggregateId} (${pendingLength} ` +\n\t\t\t\t\"pending). Acknowledge exactly the batch that was enrolled, once.\",\n\t\t);\n\t}\n}\n\n/**\n * Thrown by persisted-event consumers (including `replayHistory` and\n * `Projector`) when an event carries an\n * `aggregateId` or `aggregateType` that names a different aggregate:\n * the persisted row belongs to someone else (a miswired stream read,\n * ids colliding across aggregate types, a corrupted store). An\n * `InfrastructureError`, NOT a `DomainError` (same posture as\n * {@link SnapshotSchemaMismatchError}): a wrong address is data\n * corruption or wiring, never an expected business rejection, so it\n * must not be absorbed by generic domain error handling or presented\n * as a 4xx. It therefore PROPAGATES as a throw through the replay\n * methods' `Result` contract (which reserves `Err` for `DomainError`),\n * after the usual all-or-nothing rollback. History events without the\n * optional address fields pass unchecked (the fields are optional on\n * the event shape); new events are covered by\n * {@link MisaddressedEventError}.\n */\nexport class ForeignEventError extends InfrastructureError<\"FOREIGN_EVENT\"> {\n\t/** Address of the aggregate that received the event. */\n\treadonly expected: AggregateAddressMismatchOptions[\"expected\"];\n\t/** Address fields the event carries. */\n\treadonly actual: AggregateAddressMismatchOptions[\"actual\"];\n\treadonly eventType: string;\n\n\tconstructor(options: AggregateAddressMismatchOptions) {\n\t\tsuper({\n\t\t\tcode: \"FOREIGN_EVENT\",\n\t\t\tmessage:\n\t\t\t\t`Persisted event \"${options.eventType}\" belongs to ` +\n\t\t\t\t`${describeEventAddress(options)}, not to ` +\n\t\t\t\t`${options.expected.aggregateType} ${options.expected.aggregateId}: ` +\n\t\t\t\t\"the stream row addresses a different aggregate.\",\n\t\t});\n\t\tthis.expected = options.expected;\n\t\tthis.actual = options.actual;\n\t\tthis.eventType = options.eventType;\n\t}\n}\n\n/** Constructor options for {@link NonProgressingEventStreamPageError}. */\nexport interface NonProgressingEventStreamPageErrorOptions {\n\treadonly aggregateType: string;\n\treadonly aggregateId: string;\n\t/** Exclusive continuation cursor supplied to `EventStore.readStream`. */\n\treadonly fromVersion: number;\n\t/** Pinned inclusive stream version the replay still has to reach. */\n\treadonly targetVersion: number;\n}\n\n/**\n * Thrown by a paged EventStore consumer when `readStream` returns no events\n * even though its continuation cursor has not reached the pinned target.\n * Such a page cannot advance and violates the EventStore port contract; a\n * replay loop that merely continued would spin forever.\n *\n * This is a non-retryable infrastructure error: the persistence adapter\n * deterministically contradicted its port contract, so retrying the same read\n * is not a recovery policy. Run `createEventStoreContractTests` against the\n * adapter and fix its windowing/continuation implementation.\n */\nexport class NonProgressingEventStreamPageError extends InfrastructureError<\"NON_PROGRESSING_EVENT_STREAM_PAGE\"> {\n\treadonly aggregateType: string;\n\treadonly aggregateId: string;\n\treadonly fromVersion: number;\n\treadonly targetVersion: number;\n\n\tconstructor(options: NonProgressingEventStreamPageErrorOptions) {\n\t\tsuper({\n\t\t\tcode: \"NON_PROGRESSING_EVENT_STREAM_PAGE\",\n\t\t\tmessage:\n\t\t\t\t`EventStore returned no events for ${options.aggregateType}(${options.aggregateId}) ` +\n\t\t\t\t`after version ${options.fromVersion}, before pinned target version ` +\n\t\t\t\t`${options.targetVersion}. The page cannot advance; run the EventStore ` +\n\t\t\t\t\"contract suite and fix the adapter's continuation window.\",\n\t\t});\n\t\tthis.aggregateType = options.aggregateType;\n\t\tthis.aggregateId = options.aggregateId;\n\t\tthis.fromVersion = options.fromVersion;\n\t\tthis.targetVersion = options.targetVersion;\n\t}\n}\n\n/** Constructor options for {@link ReplayHeadMismatchError}. */\nexport interface ReplayHeadMismatchErrorOptions {\n\treadonly aggregateType: string;\n\treadonly aggregateId: string;\n\t/** Pinned inclusive stream head the replay had to reach. */\n\treadonly targetVersion: number;\n\t/** Version the aggregate holds after the replay. */\n\treadonly actualVersion: number;\n}\n\n/**\n * Thrown by a load recipe when the replayed aggregate does not end at the\n * pinned stream head. Events carry no stream position, so the aggregate\n * cannot detect a tail that overlaps the restored version or a page that\n * lies outside the requested window; only the caller, which pinned the\n * head, can compare. A snapshot catch-up passes only the events after the\n * restored version, and the final version must equal the head.\n *\n * This is a non-retryable infrastructure error: the persistence adapter\n * contradicted its port contract. Run `createEventStoreContractTests` and\n * `createEsRepositoryContractTests` against the adapter and fix its\n * windowing.\n */\nexport class ReplayHeadMismatchError extends InfrastructureError<\"REPLAY_HEAD_MISMATCH\"> {\n\treadonly aggregateType: string;\n\treadonly aggregateId: string;\n\treadonly targetVersion: number;\n\treadonly actualVersion: number;\n\n\tconstructor(options: ReplayHeadMismatchErrorOptions) {\n\t\tsuper({\n\t\t\tcode: \"REPLAY_HEAD_MISMATCH\",\n\t\t\tmessage:\n\t\t\t\t`Replay of ${options.aggregateType}(${options.aggregateId}) ended at version ` +\n\t\t\t\t`${options.actualVersion}, not at the pinned stream head ${options.targetVersion}. ` +\n\t\t\t\t\"The tail overlapped the restored version or a page lay outside the \" +\n\t\t\t\t\"requested window; pass only the events after the restored version.\",\n\t\t});\n\t\tthis.aggregateType = options.aggregateType;\n\t\tthis.aggregateId = options.aggregateId;\n\t\tthis.targetVersion = options.targetVersion;\n\t\tthis.actualVersion = options.actualVersion;\n\t}\n}\n\n/**\n * Thrown when an event harvested from an aggregate cannot be safely composed\n * into a commit envelope, or when an outbox can prove that accepting a\n * candidate would violate its event identity/source chain. Harvest failures\n * include missing `aggregateId` / `aggregateType` (downstream routing would\n * break), or an\n * eventful persisted aggregate did not advance its version (two commits\n * would receive the same source position). These programming bugs are\n * deterministic and fail identically on every retry.\n *\n * Deliberately **not** an {@link InfrastructureError} (same reasoning as\n * {@link MissingHandlerError}): this is a deterministic programming error,\n * not a transient storage failure. A `catch (e instanceof InfrastructureError)`\n * retry handler, or a retrying `TransactionScope`, must NOT mask it or loop on\n * it forever; it should crash loud so the caller misuse surfaces in\n * development. This is why `withCommit` throws it directly and\n * `UnitOfWork.run` passes it through unchanged instead of wrapping it in\n * `CommitError`.\n */\nexport class EventHarvestError extends KitWiringError<\"EVENT_HARVEST_FAILED\"> {\n\tconstructor(\n\t\tmessage: string,\n\t\t/** The `type` of the offending event, for programmatic routing. */\n\t\tpublic readonly eventType?: string,\n\t) {\n\t\tsuper(\"EVENT_HARVEST_FAILED\", message);\n\t}\n}\n\n/**\n * Thrown at bootstrap when the global key of a kit capability registry\n * already holds a value that is not a registry: another module claimed\n * the key. The kit neither shares that value nor overwrites it, because a\n * silent replacement would break whichever module owned the key first. A\n * wiring error in the host process; the remedy is one owner per key.\n */\nexport class CapabilityRegistryConflictError extends KitWiringError<\"CAPABILITY_REGISTRY_CONFLICT\"> {\n\tconstructor(public readonly key: symbol) {\n\t\tsuper(\n\t\t\t\"CAPABILITY_REGISTRY_CONFLICT\",\n\t\t\t`The global key ${String(key)} holds a value that is not a ` +\n\t\t\t\t\"capability registry of this package. Another module claimed the \" +\n\t\t\t\t\"key; the kit refuses to share or overwrite it.\",\n\t\t);\n\t}\n}\n\n/**\n * Thrown when a kit operation receives an instance that this package did\n * not construct: a structural lookalike, a repository DTO, or an instance\n * from an incompatible copy of the package. Such an instance carries none\n * of the kit-managed capabilities the operation needs. A wiring error:\n * extend the kit's base classes and run one compatible package copy.\n */\nexport class UnmanagedInstanceError extends KitWiringError<\"UNMANAGED_INSTANCE\"> {\n\tconstructor(\n\t\t/** The kit operation that rejected the instance. */\n\t\tpublic readonly operation: string,\n\t\t/** What was rejected: \"aggregate\", \"entity\", \"the persistence baseline\". */\n\t\tpublic readonly subject: string,\n\t\t/** The rejected instance's id, when it has one. */\n\t\tpublic readonly instanceId?: unknown,\n\t\t/** One extra sentence about the registry state, when it explains the rejection. */\n\t\tdetail?: string,\n\t) {\n\t\tsuper(\n\t\t\t\"UNMANAGED_INSTANCE\",\n\t\t\t`${operation} requires an instance constructed by this package; ` +\n\t\t\t\t`${instanceId === undefined ? subject : `${subject} ${String(instanceId)}`} ` +\n\t\t\t\t\"carries no kit-managed capability. Construct it through this \" +\n\t\t\t\t\"package and run one compatible package copy; a structural \" +\n\t\t\t\t\"lookalike or an instance from another copy cannot be managed.\" +\n\t\t\t\t(detail === undefined ? \"\" : ` ${detail}`),\n\t\t);\n\t}\n}\n\n/**\n * Shared guard for the loud-rejection contract on own `__proto__` data\n * keys (the shape `JSON.parse` produces for hostile rows, bodies, or\n * envelopes): used by `Entity` state copies and the event metadata\n * helpers. One implementation so the contract cannot drift.\n * Module-internal export; not part of the package entries.\n */\nexport function assertNoHostileOwnProtoKey(\n\tvalue: object,\n\tsubject: string,\n): void {\n\tif (Object.hasOwn(value, \"__proto__\")) {\n\t\tthrow new HostileStateKeyError(\"__proto__\", subject);\n\t}\n}\n\n/** Constructor options for {@link UnregisteredHandlerError}. */\nexport interface UnregisteredHandlerErrorOptions {\n\t/** Which bus rejected the dispatch. */\n\treadonly busKind: \"command\" | \"query\";\n\t/** The message type no handler was registered for. */\n\treadonly messageType: string;\n}\n\n/**\n * Produced by the in-memory `CommandBus` / `QueryBus` when a message is\n * dispatched for a type no handler was registered under: a wiring bug\n * (typo in the type string, missing `register` call at bootstrap), not\n * a domain or infrastructure failure.\n *\n * Carries the `WIRING` category (same crash-loud family as\n * {@link MissingHandlerError}), and since v3 it is THROWN by `execute`\n * and `executeUnsafe` alike, never delivered through the error channel:\n * the channel carries expected failures a registered handler produced,\n * and a generic err-branch must not absorb a mis-wired bus. Catch it\n * only at a boundary that turns bugs into 500s.\n */\nexport class UnregisteredHandlerError extends KitWiringError<\"UNREGISTERED_HANDLER\"> {\n\treadonly busKind: \"command\" | \"query\";\n\treadonly messageType: string;\n\n\tconstructor(options: UnregisteredHandlerErrorOptions) {\n\t\tsuper(\n\t\t\t\"UNREGISTERED_HANDLER\",\n\t\t\t`No handler registered for ${options.busKind} type: ${options.messageType}`,\n\t\t);\n\t\tthis.busKind = options.busKind;\n\t\tthis.messageType = options.messageType;\n\t}\n}\n\n/** Constructor options for {@link DuplicateHandlerRegistrationError}. */\nexport interface DuplicateHandlerRegistrationErrorOptions {\n\t/** Which bus rejected the registration. */\n\treadonly busKind: \"command\" | \"query\";\n\t/** The message type a handler was already registered for. */\n\treadonly messageType: string;\n}\n\n/**\n * Produced by `CommandBus.register` / `QueryBus.register` when a handler\n * is registered for a type that already has one: silent replacement would\n * turn the first handler into dead code with no signal, so the wiring bug\n * surfaces at registration time. Same crash-loud family as\n * {@link UnregisteredHandlerError}; catch it only at a boundary that\n * turns bugs into 500s.\n */\nexport class DuplicateHandlerRegistrationError extends KitWiringError<\"DUPLICATE_HANDLER_REGISTRATION\"> {\n\treadonly busKind: \"command\" | \"query\";\n\treadonly messageType: string;\n\n\tconstructor(options: DuplicateHandlerRegistrationErrorOptions) {\n\t\tsuper(\n\t\t\t\"DUPLICATE_HANDLER_REGISTRATION\",\n\t\t\t`A handler for ${options.busKind} type \"${options.messageType}\" is ` +\n\t\t\t\t\"already registered; the duplicate would silently shadow the \" +\n\t\t\t\t\"first. Register each type exactly once at bootstrap.\",\n\t\t);\n\t\tthis.busKind = options.busKind;\n\t\tthis.messageType = options.messageType;\n\t}\n}\n\n/** Constructor options for {@link ErrorMapperFailedError}. */\nexport interface ErrorMapperFailedErrorOptions {\n\t/** Which bus was mapping the failure. */\n\treadonly busKind: \"command\" | \"query\";\n\t/** The registered handler's ORIGINAL failure (also set as `cause`). */\n\treadonly handlerError: unknown;\n\t/** The mapper failure or invalid-decision diagnostic. */\n\treadonly mapperError: unknown;\n}\n\n/**\n * Produced by the in-memory `CommandBus` / `QueryBus` when the configured\n * `mapExpectedError` policy fails while classifying a registered handler's\n * failure, either by throwing or by returning an invalid decision. A broken\n * mapper is a wiring bug: letting its failure propagate bare would\n * replace the handler's original failure entirely, and the rest of the\n * kit is fastidious about never letting a secondary failure mask the\n * primary one (`RollbackError.rollbackCause`, the neutralized observers).\n *\n * The handler's original failure is preserved as `cause` (so cause-chain\n * walks, retryability checks, and error-type mapping keep working) and\n * the mapper's own failure rides along as {@link mapperCause}.\n *\n * Carries the `WIRING` category (same crash-loud family as\n * {@link MissingHandlerError} and {@link UnregisteredHandlerError}): it is\n * thrown, never delivered through the error channel.\n */\nexport class ErrorMapperFailedError extends KitWiringError<\"ERROR_MAPPER_FAILED\"> {\n\treadonly busKind: \"command\" | \"query\";\n\t/** The mapper failure or invalid-decision diagnostic. */\n\treadonly mapperCause: unknown;\n\n\tconstructor(options: ErrorMapperFailedErrorOptions) {\n\t\tsuper(\n\t\t\t\"ERROR_MAPPER_FAILED\",\n\t\t\t`The ${options.busKind} bus mapExpectedError policy failed while ` +\n\t\t\t\t\"classifying a \" +\n\t\t\t\t\"handler failure. The original handler error is preserved as \" +\n\t\t\t\t\"cause; the mapper's own failure as mapperCause.\",\n\t\t\toptions.handlerError,\n\t\t);\n\t\tthis.busKind = options.busKind;\n\t\tthis.mapperCause = options.mapperError;\n\t}\n}\n\n/**\n * Thrown at the end of a `UnitOfWork.run` when an aggregate that was\n * loaded into the identity map changed but no `update` intent was registered.\n * Without this guard the changed state or pending events would be silently\n * dropped.\n *\n * Deliberately **not** an `InfrastructureError` (same posture as\n * {@link MissingHandlerError}): a programming bug that must crash loud,\n * not be absorbed by a generic infrastructure-error handler. The throw\n * happens inside the transaction, so the unit of work rolls back and\n * leaves no partial state.\n *\n * **Scope of the guard.** A best-effort runtime safety net, not a proof.\n * It sees aggregates that repository adapters register through\n * `tracking.trackLoaded` and detects ordinary state changes through the version\n * captured at load. The pending-event count remains a second guard for an\n * invalid event-only mutation that did not advance the version. A freshly\n * created aggregate that is never passed to `add` is invisible to the kit.\n */\nexport class UnenrolledChangesError extends KitWiringError<\"UNENROLLED_CHANGES\"> {\n\tconstructor(public readonly aggregateId: string) {\n\t\tsuper(\n\t\t\t\"UNENROLLED_CHANGES\",\n\t\t\t`Aggregate ${aggregateId} was loaded and changed in this unit of work, ` +\n\t\t\t\t\"but no update intent was registered. Call repository.update(aggregate) \" +\n\t\t\t\t\"after the final domain decision so state and events flush together.\",\n\t\t);\n\t}\n}\n\n/**\n * Thrown when an aggregate removed within the current unit of work is added,\n * updated, or tracked again in the same operation. Removal is final within an\n * operation; writing afterwards would resurrect the row, which is always a\n * use-case bug.\n *\n * Carries the `WIRING` category (same reasoning as\n * {@link MissingHandlerError}): a programming bug that should crash\n * loud, not be absorbed by a generic infrastructure-error handler.\n */\nexport class AggregateDeletedError extends KitWiringError<\"AGGREGATE_DELETED\"> {\n\tconstructor(public readonly aggregateId: string) {\n\t\tsuper(\n\t\t\t\"AGGREGATE_DELETED\",\n\t\t\t`Aggregate ${aggregateId} was removed in this unit of work and ` +\n\t\t\t\t\"cannot be added, updated, tracked, or removed through another \" +\n\t\t\t\t\"instance again. Removal is final within an operation. A repeated \" +\n\t\t\t\t\"remove of the SAME instance is an accepted no-op; if the \" +\n\t\t\t\t\"aggregate must remain, do not remove it.\",\n\t\t);\n\t}\n}\n\n/**\n * Thrown by `AggregatePersistence.getById()` when an aggregate with the\n * given id does not exist. `InfrastructureError` because the storage\n * boundary, not a business rule, decided the row is absent. Use the\n * nullable variant `findById()` if \"not found\" is a valid outcome.\n *\n * Accepts an optional `cause` so a repository adapter can wrap a lower-level\n * \"row not found\" or driver-level error without\n * losing context. Cause-chain helpers (`getRootCause`,\n * `findInCauseChain`) from `@shirudo/base-error` traverse the chain.\n *\n * Not retryable: retrying won't make the row appear.\n */\nexport interface AggregateNotFoundErrorOptions {\n\treadonly aggregateType: string;\n\treadonly id: string;\n\t/** Optional lower-level error to preserve in the cause chain. */\n\treadonly cause?: unknown;\n}\n\nexport class AggregateNotFoundError extends InfrastructureError<\"AGGREGATE_NOT_FOUND\"> {\n\treadonly aggregateType: string;\n\treadonly id: string;\n\n\tconstructor(options: AggregateNotFoundErrorOptions) {\n\t\tsuper({\n\t\t\tcode: \"AGGREGATE_NOT_FOUND\",\n\t\t\tmessage: `Aggregate not found: ${options.aggregateType}(${options.id})`,\n\t\t\tcause: options.cause,\n\t\t});\n\t\tthis.aggregateType = options.aggregateType;\n\t\tthis.id = options.id;\n\t}\n}\n\n/**\n * Thrown by a repository's `add()` flush when a row with the\n * aggregate's id already exists (unique-constraint violation): two\n * concurrent creators raced on the same business-derived id, or the\n * id generator collided. Same delegation model as\n * {@link ConcurrencyConflictError}: the kit ships the class, the\n * consumer repository maps its driver's unique-violation signal to it\n * instead of letting a raw driver error escape -\n *\n * - Postgres: SQLSTATE `23505` (`unique_violation`)\n * - MySQL/MariaDB: errno `1062` (`ER_DUP_ENTRY`)\n * - SQLite: `SQLITE_CONSTRAINT_UNIQUE` (extended code 2067)\n *\n * `InfrastructureError` because the storage boundary detects the\n * collision. NOT retryable: re-running the same INSERT cannot succeed.\n * The right reactions are domain decisions - map to HTTP 409, or for\n * idempotency-key flows load the existing aggregate and treat the\n * request as already-applied.\n */\nexport interface DuplicateAggregateErrorOptions {\n\treadonly aggregateType: string;\n\treadonly aggregateId: string;\n\t/** Optional driver-level error to preserve in the cause chain. */\n\treadonly cause?: unknown;\n}\n\nexport class DuplicateAggregateError extends InfrastructureError<\"DUPLICATE_AGGREGATE\"> {\n\treadonly aggregateType: string;\n\treadonly aggregateId: string;\n\n\tconstructor(options: DuplicateAggregateErrorOptions) {\n\t\tsuper({\n\t\t\tcode: \"DUPLICATE_AGGREGATE\",\n\t\t\tmessage: `Duplicate aggregate: ${options.aggregateType}(${options.aggregateId}) already exists`,\n\t\t\tcause: options.cause,\n\t\t});\n\t\tthis.aggregateType = options.aggregateType;\n\t\tthis.aggregateId = options.aggregateId;\n\t}\n}\n\n/**\n * Thrown by `reconstituteAggregateFromSnapshot` when the stored snapshot\n * carries a different schema version than its adapter-owned `SnapshotModel`\n * and the model declares no `migrate` function. Without the check, a snapshot\n * written against an older DTO shape would surface as an undefined-field crash on\n * the first method call after a much later restore.\n *\n * `InfrastructureError` because the storage boundary served outdated\n * data; the schema evolving past stored snapshots is an expected\n * lifecycle event, not a programming bug. NOT retryable: the recovery\n * is a code path, not a repeat. Add `migrate` to the snapshot model (upgrade\n * old DTOs in place), or catch this error in the repository, discard the\n * snapshot, and refold from the full event stream / reload from the source of\n * truth.\n */\nexport interface SnapshotSchemaMismatchErrorOptions {\n\treadonly aggregateType: string;\n\treadonly aggregateId: string;\n\treadonly expectedSchemaVersion: number;\n\treadonly actualSchemaVersion: number;\n}\n\nexport class SnapshotSchemaMismatchError extends InfrastructureError<\"SNAPSHOT_SCHEMA_MISMATCH\"> {\n\treadonly aggregateType: string;\n\treadonly aggregateId: string;\n\treadonly expectedSchemaVersion: number;\n\treadonly actualSchemaVersion: number;\n\n\tconstructor(options: SnapshotSchemaMismatchErrorOptions) {\n\t\tsuper({\n\t\t\tcode: \"SNAPSHOT_SCHEMA_MISMATCH\",\n\t\t\tmessage:\n\t\t\t\t`Snapshot schema mismatch on ${options.aggregateType}(${options.aggregateId}): ` +\n\t\t\t\t`the snapshot model expects schema ${options.expectedSchemaVersion}, ` +\n\t\t\t\t`the stored snapshot carries ${options.actualSchemaVersion}. Override ` +\n\t\t\t\t`the model's migrate function to upgrade old snapshots, or discard the snapshot ` +\n\t\t\t\t`and refold from the full event stream.`,\n\t\t});\n\t\tthis.aggregateType = options.aggregateType;\n\t\tthis.aggregateId = options.aggregateId;\n\t\tthis.expectedSchemaVersion = options.expectedSchemaVersion;\n\t\tthis.actualSchemaVersion = options.actualSchemaVersion;\n\t}\n}\n\n/**\n * Surfaced by a Unit-of-Work flush when the aggregate's expected version does\n * not match the version currently persisted: i.e. another writer\n * updated the aggregate concurrently. The canonical optimistic-\n * concurrency signal; the App-Service typically reloads, re-applies\n * the use case, and retries, or surfaces HTTP 409 to the caller.\n *\n * **Retry means a FRESH unit of work** (a new `UnitOfWork.run()` /\n * `withCommit` invocation): reload, re-apply, and register `update` again. Do NOT catch this\n * inside the same `run()` callback and continue: the failed aggregate\n * is already enrolled (its events would be committed for a write that\n * never happened) and the identity map still serves the same stale\n * instance to any in-place \"reload\".\n *\n * `InfrastructureError` because the persistence layer (not a domain\n * rule) detects the race. Marks itself as `retryable: true` so the\n * `isRetryable` predicate from `@shirudo/base-error` picks it up.\n */\nexport interface ConcurrencyConflictErrorOptions {\n\treadonly aggregateType: string;\n\treadonly aggregateId: string;\n\treadonly expectedVersion: number;\n\treadonly actualVersion: number;\n\t/** Optional driver-level error to preserve in the cause chain. */\n\treadonly cause?: unknown;\n}\n\nexport class ConcurrencyConflictError extends InfrastructureError<\"CONCURRENCY_CONFLICT\"> {\n\treadonly aggregateType: string;\n\treadonly aggregateId: string;\n\treadonly expectedVersion: number;\n\treadonly actualVersion: number;\n\n\tconstructor(options: ConcurrencyConflictErrorOptions) {\n\t\tsuper({\n\t\t\tcode: \"CONCURRENCY_CONFLICT\",\n\t\t\tmessage: `Concurrency conflict on ${options.aggregateType}(${options.aggregateId}): expected version ${options.expectedVersion}, actual ${options.actualVersion}`,\n\t\t\tcause: options.cause,\n\t\t\t// The canonical OCC pattern: reload the aggregate, re-apply the\n\t\t\t// use case, retry in a FRESH unit of work. The structured field\n\t\t\t// is what the retry classifier (someChainRetryable) reads.\n\t\t\tretryable: true,\n\t\t});\n\t\tthis.aggregateType = options.aggregateType;\n\t\tthis.aggregateId = options.aggregateId;\n\t\tthis.expectedVersion = options.expectedVersion;\n\t\tthis.actualVersion = options.actualVersion;\n\t}\n}\n\n/**\n * Options bag for {@link IdempotencyKeyReuseError}.\n */\nexport interface IdempotencyKeyReuseErrorOptions {\n\treadonly key: string;\n\treadonly storedFingerprint: string;\n\treadonly receivedFingerprint: string;\n\t/** Optional driver-level error to preserve in the cause chain. */\n\treadonly cause?: unknown;\n}\n\n/**\n * Thrown by `IdempotencyStore.claim()` when the same idempotency key\n * arrives with a DIFFERENT command fingerprint than the one it was\n * first claimed with: the caller is reusing a key for a different\n * command. Replaying the stored outcome would answer a question that\n * was never asked; rejecting is the only safe reaction.\n *\n * `InfrastructureError` because the store detects the collision, same\n * delegation model as {@link DuplicateAggregateError}. NOT retryable:\n * re-sending the same mismatched pair cannot succeed. Map it to an\n * unprocessable/conflict application outcome.\n */\nexport class IdempotencyKeyReuseError extends InfrastructureError<\"IDEMPOTENCY_KEY_REUSE\"> {\n\treadonly key: string;\n\treadonly storedFingerprint: string;\n\treadonly receivedFingerprint: string;\n\n\tconstructor(options: IdempotencyKeyReuseErrorOptions) {\n\t\tsuper({\n\t\t\tcode: \"IDEMPOTENCY_KEY_REUSE\",\n\t\t\tmessage:\n\t\t\t\t`Idempotency key reuse on \"${options.key}\": stored fingerprint ` +\n\t\t\t\t`${options.storedFingerprint}, received ${options.receivedFingerprint}`,\n\t\t\tcause: options.cause,\n\t\t});\n\t\tthis.key = options.key;\n\t\tthis.storedFingerprint = options.storedFingerprint;\n\t\tthis.receivedFingerprint = options.receivedFingerprint;\n\t}\n}\n\n/** Options bag for {@link IdempotencyClaimLostError}. */\nexport interface IdempotencyClaimLostErrorOptions {\n\treadonly key: string;\n\treadonly token: string;\n\t/** Optional driver-level error to preserve in the cause chain. */\n\treadonly cause?: unknown;\n}\n\n/**\n * Thrown when a leased idempotency owner tries to renew, complete, or\n * reconcile through a claim token that no longer owns the key. The usual\n * cause is lease expiry followed by a successful takeover. The stale\n * execution must abort before its transaction commits; retrying starts from\n * a fresh claim or replays the winner.\n */\nexport class IdempotencyClaimLostError extends InfrastructureError<\"IDEMPOTENCY_CLAIM_LOST\"> {\n\treadonly key: string;\n\treadonly token: string;\n\n\tconstructor(options: IdempotencyClaimLostErrorOptions) {\n\t\tsuper({\n\t\t\tcode: \"IDEMPOTENCY_CLAIM_LOST\",\n\t\t\tmessage:\n\t\t\t\t`Idempotency claim for key \"${options.key}\" no longer belongs to ` +\n\t\t\t\t`token \"${options.token}\"`,\n\t\t\tcause: options.cause,\n\t\t\tretryable: true,\n\t\t});\n\t\tthis.key = options.key;\n\t\tthis.token = options.token;\n\t}\n}\n\n/**\n * Options bag for {@link IdempotencyInFlightError}.\n */\nexport interface IdempotencyInFlightErrorOptions {\n\treadonly key: string;\n\t/** Optional driver-level error to preserve in the cause chain. */\n\treadonly cause?: unknown;\n}\n\n/**\n * Thrown by `IdempotencyStore.claim()` when the key is already claimed\n * by an execution that has not completed yet: the first delivery of the\n * command is still running (or crashed mid-flight on a\n * non-transactional store). Retryable by design: a later retry either\n * finds the completed outcome and replays it, or finds the claim\n * released (rolled back) and executes fresh. `RetryingTransactionScope`\n * picks this up through the `retryable` flag without extra wiring.\n */\nexport class IdempotencyInFlightError extends InfrastructureError<\"IDEMPOTENCY_IN_FLIGHT\"> {\n\treadonly key: string;\n\n\tconstructor(options: IdempotencyInFlightErrorOptions) {\n\t\tsuper({\n\t\t\tcode: \"IDEMPOTENCY_IN_FLIGHT\",\n\t\t\tmessage:\n\t\t\t\t`Idempotency key \"${options.key}\" is claimed by an execution ` +\n\t\t\t\t`that has not completed yet`,\n\t\t\tcause: options.cause,\n\t\t\tretryable: true,\n\t\t});\n\t\tthis.key = options.key;\n\t}\n}\n\n/** Options bag for {@link IdempotencyReconciliationRequiredError}. */\nexport interface IdempotencyReconciliationRequiredErrorOptions {\n\treadonly key: string;\n\treadonly fingerprint: string;\n\treadonly token: string;\n\treadonly expiredAt: string;\n}\n\n/**\n * An expired staged outcome cannot be replayed or discarded until the\n * application checks the authoritative write model. Immediate retry without\n * that evidence cannot make progress, so this error is deliberately not\n * marked retryable.\n */\nexport class IdempotencyReconciliationRequiredError extends InfrastructureError<\"IDEMPOTENCY_RECONCILIATION_REQUIRED\"> {\n\treadonly key: string;\n\treadonly fingerprint: string;\n\treadonly token: string;\n\treadonly expiredAt: string;\n\n\tconstructor(options: IdempotencyReconciliationRequiredErrorOptions) {\n\t\tsuper({\n\t\t\tcode: \"IDEMPOTENCY_RECONCILIATION_REQUIRED\",\n\t\t\tmessage:\n\t\t\t\t`Idempotency key \"${options.key}\" has an expired staged outcome; ` +\n\t\t\t\t\"consult the authoritative write model before confirming or releasing it\",\n\t\t});\n\t\tthis.key = options.key;\n\t\tthis.fingerprint = options.fingerprint;\n\t\tthis.token = options.token;\n\t\tthis.expiredAt = options.expiredAt;\n\t}\n}\n\n/**\n * Thrown by `IdempotencyStore.complete()` when no pending claim exists\n * for the key: `complete` ran without a preceding successful `claim`\n * in the same execution, or against a key whose claim was already\n * completed or abandoned. Always a wiring bug in hand-rolled\n * orchestration (`withIdempotentCommit` cannot produce it), hence the\n * crash-loud category.\n */\nexport class IdempotencyCompletionWithoutClaimError extends KitWiringError<\"IDEMPOTENCY_COMPLETED_WITHOUT_CLAIM\"> {\n\tconstructor(public readonly key: string) {\n\t\tsuper(\n\t\t\t\"IDEMPOTENCY_COMPLETED_WITHOUT_CLAIM\",\n\t\t\t`IdempotencyStore.complete() called for key \"${key}\" without a ` +\n\t\t\t\t\"pending claim; call claim() first (or use withIdempotentCommit)\",\n\t\t);\n\t}\n}\n\n/**\n * The closed union of every error code the kit itself can produce\n * (consumer subclasses of {@link DomainError} / {@link InfrastructureError}\n * add their own on top). Useful for building `switch` tables or\n * base-error `matchError` cases that cover kit and consumer codes\n * together, without importing anything from base-error.\n */\nexport type KitErrorCode =\n\t| \"AGGREGATE_DELETED\"\n\t| \"AGGREGATE_NOT_FOUND\"\n\t| \"AGGREGATE_TRACKING\"\n\t| \"CAPABILITY_REGISTRY_CONFLICT\"\n\t| \"COMMIT_FAILED\"\n\t| \"CONCURRENCY_CONFLICT\"\n\t| \"DIRECT_STATE_MUTATION\"\n\t| \"DOMAIN_TRANSITION_GUARD_REJECTED\"\n\t| \"DUPLICATE_AGGREGATE\"\n\t| \"DUPLICATE_EVENT_ID\"\n\t| \"DUPLICATE_HANDLER_REGISTRATION\"\n\t| \"ERROR_MAPPER_FAILED\"\n\t| \"EVENT_ADDRESS_INVALID\"\n\t| \"EVENT_BUS_CLOSED\"\n\t| \"EVENT_HARVEST_FAILED\"\n\t| \"EVENT_ID_INVALID\"\n\t| \"EVENT_ID_REQUIRED\"\n\t| \"EVENT_OCCURRED_AT_INVALID\"\n\t| \"EVENT_OCCURRED_AT_REQUIRED\"\n\t| \"EVENT_SCHEMA_VERSION_INVALID\"\n\t| \"EVENT_TYPE_INVALID\"\n\t| \"FOLD_RETURNED_NO_STATE\"\n\t| \"FOREIGN_EVENT\"\n\t| \"HOSTILE_STATE_KEY\"\n\t| \"IDEMPOTENCY_CLAIM_LOST\"\n\t| \"IDEMPOTENCY_COMPLETED_WITHOUT_CLAIM\"\n\t| \"IDEMPOTENCY_IN_FLIGHT\"\n\t| \"IDEMPOTENCY_KEY_REUSE\"\n\t| \"IDEMPOTENCY_RECONCILIATION_REQUIRED\"\n\t| \"IN_MEMORY_CAPACITY_EXCEEDED\"\n\t| \"INVALID_DOMAIN_MACHINE_CONTEXT\"\n\t| \"INVALID_DOMAIN_MACHINE_DEFINITION\"\n\t| \"INVALID_DOMAIN_MACHINE_INPUT\"\n\t| \"INVALID_DOMAIN_MACHINE_SNAPSHOT\"\n\t| \"INVALID_DOMAIN_TRANSITION\"\n\t| \"INVALID_DOMAIN_TRANSITION_GUARD_RESULT\"\n\t| \"INVALID_DOMAIN_TRANSITION_RESULT\"\n\t| \"INVALID_COMMAND_MESSAGE\"\n\t| \"INVALID_INTEGRATION_MESSAGE\"\n\t| \"INVALID_MONEY\"\n\t| \"INVALID_REPOSITORY_ADAPTER\"\n\t| \"INVALID_REPOSITORY_DEFINITION\"\n\t| \"INVALID_VERSION\"\n\t| \"MISADDRESSED_EVENT\"\n\t| \"MISSING_ENTITY_ID\"\n\t| \"MISSING_FOLD\"\n\t| \"MISSING_HANDLER\"\n\t| \"MONEY_CURRENCY_MISMATCH\"\n\t| \"MONEY_PRECISION_LOSS\"\n\t| \"MONEY_SCALE_MISMATCH\"\n\t| \"NESTED_UNIT_OF_WORK\"\n\t| \"NON_PROGRESSING_EVENT_STREAM_PAGE\"\n\t| \"PENDING_EVENT_BATCH_MISMATCH\"\n\t| \"PENDING_EVENT_LIMIT_EXCEEDED\"\n\t| \"PROJECTION_GAP\"\n\t| \"PROJECTION_IDENTITY_VIOLATION\"\n\t| \"PROJECTION_ORDER_VIOLATION\"\n\t| \"PROJECTION_RECEIPT_VIOLATION\"\n\t| \"PUBLISH_DEPTH_EXCEEDED\"\n\t| \"REENTRANT_DOMAIN_STATE_MACHINE_EVALUATION\"\n\t| \"REENTRANT_EVENT_RECORDING\"\n\t| \"REPLAY_HEAD_MISMATCH\"\n\t| \"REPOSITORY_ERROR_MAPPING_FAILED\"\n\t| \"ROLLBACK_FAILED\"\n\t| \"SNAPSHOT_CORRUPTED\"\n\t| \"SNAPSHOT_SCHEMA_MISMATCH\"\n\t| \"SNAPSHOT_TIME_INVALID\"\n\t| \"SNAPSHOT_VERSION_NOT_RESTORED\"\n\t| \"TRANSACTION_CLOSED\"\n\t| \"UNENROLLED_CHANGES\"\n\t| \"UNKNOWN_CURRENCY\"\n\t| \"UNMANAGED_INSTANCE\"\n\t| \"UNMINTED_EVENT\"\n\t| \"UNPROJECTABLE_EVENT\"\n\t| \"UNREGISTERED_HANDLER\"\n\t| \"UNREPLAYABLE_AGGREGATE\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,IAAsB,cAAtB,cAEU,gBAAiC;CAC1C,AAAU,YAAY,SAAiC;EACtD,MAAM;GACL,MAAM,QAAQ;GACd,UAAU;GACV,WAAW,QAAQ,aAAa;GAChC,SAAS,QAAQ;GACjB,OAAO,QAAQ;EAChB,CAAC;CACF;AACD;;;;;;;;;AAUA,IAAsB,iBAAtB,cAEU,gBAAiC;CAC1C,AAAU,YAAY,MAAa,SAAiB,OAAiB;EACpE,MA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