@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StructuredError } from "@shirudo/base-error";
|
|
2
2
|
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region src/errors/kit-errors.ts
|
|
4
4
|
/**
|
|
5
5
|
* Abstract base for **domain-invariant violations**. Domain methods
|
|
6
6
|
* (aggregates, entity validation hooks, value-object constructors)
|
|
@@ -72,7 +72,7 @@ var KitWiringError = class extends StructuredError {
|
|
|
72
72
|
* Library-internal concrete subclasses: {@link AggregateNotFoundError},
|
|
73
73
|
* {@link ConcurrencyConflictError}, {@link DuplicateAggregateError},
|
|
74
74
|
* plus the unit-of-work lifecycle wrappers `CommitError` and
|
|
75
|
-
* `RollbackError` (in `src/
|
|
75
|
+
* `RollbackError` (in `src/application/unit-of-work/errors.ts`).
|
|
76
76
|
*/
|
|
77
77
|
var InfrastructureError = class extends StructuredError {
|
|
78
78
|
constructor(options) {
|
|
@@ -128,18 +128,15 @@ var InMemoryCapacityExceededError = class extends InfrastructureError {
|
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
130
|
/**
|
|
131
|
-
* Thrown when
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* a domain or infrastructure failure.
|
|
131
|
+
* Thrown when a projection built with `projectionFromHandlers` receives an
|
|
132
|
+
* event type with no own handler entry: the declared event union and the
|
|
133
|
+
* handler map disagree at runtime, which is a programming / configuration
|
|
134
|
+
* bug rather than a domain or infrastructure failure.
|
|
136
135
|
*
|
|
137
136
|
* Deliberately **not** on `DomainError` or `InfrastructureError`:
|
|
138
137
|
* a generic `catch (e instanceof DomainError)` handler at the App
|
|
139
138
|
* layer must not mask a forgotten handler; this should crash loud and
|
|
140
|
-
* fail the calling Use Case so the bug surfaces in development.
|
|
141
|
-
* replay through `loadFromHistory` also lets it propagate uncaught instead
|
|
142
|
-
* of wrapping it in `Result.Err`.
|
|
139
|
+
* fail the calling Use Case so the bug surfaces in development.
|
|
143
140
|
*
|
|
144
141
|
* Use `isBaseError(e)` from `@shirudo/base-error` to detect
|
|
145
142
|
* "any structured error from the kit or any other BaseError-using
|
|
@@ -153,6 +150,52 @@ var MissingHandlerError = class extends KitWiringError {
|
|
|
153
150
|
}
|
|
154
151
|
};
|
|
155
152
|
/**
|
|
153
|
+
* Thrown by an event-sourced aggregate when `apply()` or replay reaches an
|
|
154
|
+
* event type with no own entry in the `folds` map: the declared event union
|
|
155
|
+
* and the map disagree at runtime. Same posture as
|
|
156
|
+
* {@link MissingHandlerError}: a deterministic bug, never a domain
|
|
157
|
+
* rejection, so it propagates through `replayHistory` instead of riding its
|
|
158
|
+
* `Result`.
|
|
159
|
+
*/
|
|
160
|
+
var MissingFoldError = class extends KitWiringError {
|
|
161
|
+
eventType;
|
|
162
|
+
constructor(eventType, cause) {
|
|
163
|
+
super("MISSING_FOLD", `Missing fold for event type: ${eventType}`, cause);
|
|
164
|
+
this.eventType = eventType;
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* Thrown by an event-sourced aggregate when a fold returns `undefined`
|
|
169
|
+
* for an event, which is almost always a fold without a `return` statement.
|
|
170
|
+
* Storing that result would set the aggregate state to `undefined`, record
|
|
171
|
+
* the fact anyway on the apply path, and leave every later fold working on
|
|
172
|
+
* nothing. Same posture as {@link MissingFoldError}: a deterministic bug
|
|
173
|
+
* in the folds map, never a domain rejection, so it propagates through
|
|
174
|
+
* `replayHistory` instead of riding its `Result`.
|
|
175
|
+
*/
|
|
176
|
+
var FoldReturnedNoStateError = class extends KitWiringError {
|
|
177
|
+
eventType;
|
|
178
|
+
constructor(eventType) {
|
|
179
|
+
super("FOLD_RETURNED_NO_STATE", `The fold for event type "${eventType}" returned no state. A fold must return the next state; check for a missing return statement.`);
|
|
180
|
+
this.eventType = eventType;
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* Thrown by `EventSourcedAggregate.setState`: on an event-sourced aggregate
|
|
185
|
+
* the state changes only through `apply()`, where the fact is recorded and
|
|
186
|
+
* the version advances with it. A direct state write would leave the
|
|
187
|
+
* instance ahead of its stream with nothing to replay. A wiring error: a
|
|
188
|
+
* deterministic bug in the aggregate's own code, the remedy is an event
|
|
189
|
+
* and a handler.
|
|
190
|
+
*/
|
|
191
|
+
var DirectStateMutationError = class extends KitWiringError {
|
|
192
|
+
aggregateId;
|
|
193
|
+
constructor(aggregateId) {
|
|
194
|
+
super("DIRECT_STATE_MUTATION", `Aggregate ${aggregateId} is event-sourced: its state changes only through apply(). Record the fact as an event and fold it in a handler instead of calling setState.`);
|
|
195
|
+
this.aggregateId = aggregateId;
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
156
199
|
* Thrown by `Projector.project` when an event cannot be projected
|
|
157
200
|
* safely because its cursor is missing or malformed, or its aggregate
|
|
158
201
|
* address is absent. Applying such an event would break idempotency, so
|
|
@@ -297,16 +340,19 @@ var InvalidCommandMessageError = class extends InfrastructureError {
|
|
|
297
340
|
}
|
|
298
341
|
};
|
|
299
342
|
/**
|
|
300
|
-
* Thrown by `Entity` (constructor and `setState`)
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
* `
|
|
343
|
+
* Thrown by `Entity` (constructor and `setState`), by the event-sourced
|
|
344
|
+
* fold (`apply` and replay), by the event constructors for the payload,
|
|
345
|
+
* and by the event metadata helpers (`createDomainEvent`'s
|
|
346
|
+
* `options.metadata`, `mergeMetadata`, `copyMetadata`) when the value
|
|
347
|
+
* carries an own `"__proto__"` data key:
|
|
304
348
|
* the shape `JSON.parse` produces for hostile DB rows or request bodies
|
|
305
349
|
* handed to reconstitute factories. Such a key can never be legitimate
|
|
306
350
|
* domain state; accepting it would hand a prototype-pollution payload to
|
|
307
351
|
* every downstream consumer that copies the state through `[[Set]]`
|
|
308
352
|
* (`Object.assign`, for-in assignment loops), and dropping it would be
|
|
309
|
-
* silent data mutation.
|
|
353
|
+
* silent data mutation. The check looks at the root object only; nested
|
|
354
|
+
* objects are not walked, and a class instance is an ownership transfer
|
|
355
|
+
* that passes.
|
|
310
356
|
*
|
|
311
357
|
* Deliberately **not** a `DomainError` or `InfrastructureError` (same
|
|
312
358
|
* posture as {@link MissingHandlerError}): untrusted input reaching the
|
|
@@ -323,7 +369,46 @@ var HostileStateKeyError = class extends KitWiringError {
|
|
|
323
369
|
}
|
|
324
370
|
};
|
|
325
371
|
/**
|
|
326
|
-
* Thrown by `
|
|
372
|
+
* Thrown by the `Entity` constructor when the id is not a non-blank
|
|
373
|
+
* string. That covers `null`, `undefined`, a blank string, and a
|
|
374
|
+
* non-string value that reached the constructor through a cast. An
|
|
375
|
+
* entity without a usable identity cannot be tracked, compared, or
|
|
376
|
+
* persisted, so the construction fails before any state is stored. A
|
|
377
|
+
* wiring error: a deterministic bug at the call site, never a domain
|
|
378
|
+
* rejection.
|
|
379
|
+
*/
|
|
380
|
+
var MissingEntityIdError = class extends KitWiringError {
|
|
381
|
+
constructor(received) {
|
|
382
|
+
super("MISSING_ENTITY_ID", `Entity ID must be a non-blank string; received ${describeRejectedId(received)}.`);
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
function describeRejectedId(value) {
|
|
386
|
+
if (typeof value === "string") return JSON.stringify(value);
|
|
387
|
+
if (value === null) return "null";
|
|
388
|
+
if (value === void 0) return "undefined";
|
|
389
|
+
if (typeof value === "object") return Array.isArray(value) ? "array" : "object";
|
|
390
|
+
if (typeof value === "function") return "function";
|
|
391
|
+
return `${typeof value} ${String(value)}`;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Thrown when a number that is not a valid aggregate version reaches the
|
|
395
|
+
* kit: `toVersion`, `markReconstituted`, `setVersion`, and the post-commit
|
|
396
|
+
* acknowledgement all reject it. A version is a safe integer of at least
|
|
397
|
+
* zero, and a restore never moves below the current version. A wiring
|
|
398
|
+
* error: an adapter passed a corrupt row value or a wrong number, and
|
|
399
|
+
* the optimistic-concurrency cursor must not carry it. Not retryable.
|
|
400
|
+
*/
|
|
401
|
+
var InvalidVersionError = class extends KitWiringError {
|
|
402
|
+
value;
|
|
403
|
+
reason;
|
|
404
|
+
constructor(value, reason) {
|
|
405
|
+
super("INVALID_VERSION", `Version ${String(value)} ${reason}. A version is a safe integer of at least zero; create one with toVersion(n) from the stored row value.`);
|
|
406
|
+
this.value = value;
|
|
407
|
+
this.reason = reason;
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
/**
|
|
411
|
+
* Thrown by `EventSourcedAggregate.replayHistory` when the replay target
|
|
327
412
|
* carries unflushed `pendingEvents`. Replaying persisted facts onto that
|
|
328
413
|
* instance would advance the version underneath decisions made against an
|
|
329
414
|
* older state and could later claim history the stream does not carry.
|
|
@@ -348,6 +433,11 @@ var UnreplayableAggregateError = class extends KitWiringError {
|
|
|
348
433
|
this.aggregateId = aggregateId;
|
|
349
434
|
}
|
|
350
435
|
};
|
|
436
|
+
/** The address the event names; a missing field falls back to the receiving aggregate. */
|
|
437
|
+
function describeEventAddress(options) {
|
|
438
|
+
const { expected, actual } = options;
|
|
439
|
+
return `${actual.aggregateType ?? expected.aggregateType} ${actual.aggregateId ?? expected.aggregateId}`;
|
|
440
|
+
}
|
|
351
441
|
/**
|
|
352
442
|
* Thrown by `EventSourcedAggregate.apply()` when a NEW event carries an
|
|
353
443
|
* `aggregateId` or `aggregateType` naming a different aggregate: a
|
|
@@ -361,18 +451,37 @@ var UnreplayableAggregateError = class extends KitWiringError {
|
|
|
361
451
|
* infrastructure, and handlers for one must not absorb the other.
|
|
362
452
|
*/
|
|
363
453
|
var MisaddressedEventError = class extends KitWiringError {
|
|
364
|
-
|
|
365
|
-
|
|
454
|
+
/** Address of the aggregate that received the event. */
|
|
455
|
+
expected;
|
|
456
|
+
/** Address fields the event carries. */
|
|
457
|
+
actual;
|
|
366
458
|
eventType;
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
this.
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
459
|
+
constructor(options) {
|
|
460
|
+
super("MISADDRESSED_EVENT", `New event "${options.eventType}" is addressed to ${describeEventAddress(options)} but was applied on ${options.expected.aggregateType} ${options.expected.aggregateId}: fix the call site (createEvent stamps the right address).`);
|
|
461
|
+
this.expected = options.expected;
|
|
462
|
+
this.actual = options.actual;
|
|
463
|
+
this.eventType = options.eventType;
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
/**
|
|
467
|
+
* Thrown by `reconstituteAggregateFromSnapshot` when the `reconstitute`
|
|
468
|
+
* factory returns an aggregate at a version other than the snapshot
|
|
469
|
+
* version. The factory ignored the version parameter, usually a forgotten
|
|
470
|
+
* `markReconstituted(version)`. A wiring error in the snapshot model,
|
|
471
|
+
* never snapshot corruption: routing it into the discard-and-refold
|
|
472
|
+
* channel would mask it as perpetual silent refolding.
|
|
473
|
+
*/
|
|
474
|
+
var SnapshotVersionNotRestoredError = class extends KitWiringError {
|
|
475
|
+
aggregateType;
|
|
476
|
+
aggregateId;
|
|
477
|
+
snapshotVersion;
|
|
478
|
+
restoredVersion;
|
|
479
|
+
constructor(options) {
|
|
480
|
+
super("SNAPSHOT_VERSION_NOT_RESTORED", `SnapshotModel.reconstitute for ${options.aggregateType} ${options.aggregateId} returned an aggregate at version ${options.restoredVersion} for a snapshot at version ${options.snapshotVersion}. Reconstitution must restore the persisted version; call markReconstituted(version) inside the aggregate factory.`);
|
|
481
|
+
this.aggregateType = options.aggregateType;
|
|
482
|
+
this.aggregateId = options.aggregateId;
|
|
483
|
+
this.snapshotVersion = options.snapshotVersion;
|
|
484
|
+
this.restoredVersion = options.restoredVersion;
|
|
376
485
|
}
|
|
377
486
|
};
|
|
378
487
|
/**
|
|
@@ -396,17 +505,20 @@ var SnapshotCorruptedError = class extends InfrastructureError {
|
|
|
396
505
|
};
|
|
397
506
|
/**
|
|
398
507
|
* Thrown when an event reaches the aggregate's recording paths
|
|
399
|
-
* (`apply`, `
|
|
508
|
+
* (`apply`, `setState`, `addDomainEvent`) without having been minted by
|
|
400
509
|
* the kit's constructors: `createDomainEvent`,
|
|
401
|
-
* `createDomainEventFromFacts`, `createUncommittedDomainEvent`, or
|
|
402
|
-
*
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
*
|
|
406
|
-
*
|
|
407
|
-
*
|
|
408
|
-
*
|
|
409
|
-
*
|
|
510
|
+
* `createDomainEventFromFacts`, `createUncommittedDomainEvent`, or the
|
|
511
|
+
* aggregate `createEvent` helper. Those constructors deep-freeze the
|
|
512
|
+
* event, defensively copy payload and metadata, and mark the result as
|
|
513
|
+
* minted. The mark has two tiers: a
|
|
514
|
+
* module-private one for events of this loaded copy of the kit, and a
|
|
515
|
+
* cooperative `Symbol.for` brand that a second loaded copy stamps and
|
|
516
|
+
* recognizes. Anything else (a hand-rolled literal, a shallow-frozen
|
|
517
|
+
* copy with mutable nested data) is rejected: a mutable event recorded
|
|
518
|
+
* next to a state change can silently diverge from it afterwards. A
|
|
519
|
+
* wiring error: deterministic bug at the call site, the remedy is
|
|
520
|
+
* minting through the constructors. The gate catches accidents, not
|
|
521
|
+
* adversaries: code in the same process can fake the brand.
|
|
410
522
|
*/
|
|
411
523
|
var UnmintedEventError = class extends KitWiringError {
|
|
412
524
|
constructor(eventType) {
|
|
@@ -429,22 +541,69 @@ var ReentrantEventRecordingError = class extends KitWiringError {
|
|
|
429
541
|
}
|
|
430
542
|
};
|
|
431
543
|
/**
|
|
432
|
-
* Thrown
|
|
433
|
-
*
|
|
434
|
-
*
|
|
544
|
+
* Thrown when two facts of one aggregate would carry the same `eventId`.
|
|
545
|
+
* Two causes, two sites: the aggregate rejects a recorded event that is
|
|
546
|
+
* already pending at the append, before the state moves; and
|
|
547
|
+
* `recordPendingEvents` rejects a stamp provider that returns one reused
|
|
548
|
+
* stamp (or repeats an explicit id). Either would mint two distinct facts
|
|
435
549
|
* sharing one identity, and downstream idempotent consumers keyed on
|
|
436
|
-
* `eventId` silently drop one of them. A wiring error: deterministic bug
|
|
437
|
-
* the stamp provider, the remedy is one fresh
|
|
550
|
+
* `eventId` silently drop one of them. A wiring error: deterministic bug at
|
|
551
|
+
* the append site or in the stamp provider, the remedy is one fresh
|
|
552
|
+
* identity per fact.
|
|
438
553
|
*/
|
|
439
554
|
var DuplicateEventIdError = class extends KitWiringError {
|
|
440
555
|
eventId;
|
|
441
556
|
constructor(aggregateId, eventId) {
|
|
442
|
-
super("DUPLICATE_EVENT_ID", `Two pending events of aggregate ${aggregateId} carry the same eventId "${eventId}". Each
|
|
557
|
+
super("DUPLICATE_EVENT_ID", `Two pending events of aggregate ${aggregateId} carry the same eventId "${eventId}". Each fact needs its own identity: append a recorded event once, and return a fresh stamp per decision from the stamp provider.`);
|
|
443
558
|
this.eventId = eventId;
|
|
444
559
|
}
|
|
445
560
|
};
|
|
446
561
|
/**
|
|
447
|
-
* Thrown
|
|
562
|
+
* Thrown when a recording would grow the pending list of an aggregate past
|
|
563
|
+
* `AggregateConfig.maxPendingEvents`. The check runs before the state
|
|
564
|
+
* moves, so the rejected decision records nothing and moves nothing. The
|
|
565
|
+
* limit is a modelling signal, not a runtime budget: a decision that emits
|
|
566
|
+
* hundreds of facts points at a missing aggregate boundary, and a retry
|
|
567
|
+
* repeats it. A wiring error: split the aggregate, or emit fewer facts
|
|
568
|
+
* per decision.
|
|
569
|
+
*/
|
|
570
|
+
var PendingEventLimitExceededError = class extends KitWiringError {
|
|
571
|
+
aggregateType;
|
|
572
|
+
aggregateId;
|
|
573
|
+
limit;
|
|
574
|
+
pending;
|
|
575
|
+
added;
|
|
576
|
+
constructor(options) {
|
|
577
|
+
super("PENDING_EVENT_LIMIT_EXCEEDED", `Aggregate ${options.aggregateType}(${options.aggregateId}) holds ${options.pending} pending event(s) and cannot record ${options.added} more: maxPendingEvents is ${options.limit}. A decision that emits this many facts points at a missing aggregate boundary.`);
|
|
578
|
+
this.aggregateType = options.aggregateType;
|
|
579
|
+
this.aggregateId = options.aggregateId;
|
|
580
|
+
this.limit = options.limit;
|
|
581
|
+
this.pending = options.pending;
|
|
582
|
+
this.added = options.added;
|
|
583
|
+
}
|
|
584
|
+
};
|
|
585
|
+
/**
|
|
586
|
+
* Thrown by the post-commit acknowledgement of an aggregate when the
|
|
587
|
+
* committed batch is not the prefix of its pending events any more. The
|
|
588
|
+
* batch is longer than the pending list, or an event in it is not the
|
|
589
|
+
* pending event at the same position. Acknowledging such a batch would
|
|
590
|
+
* drop decisions the commit never persisted or keep events it did. The
|
|
591
|
+
* pending list stays untouched. A wiring error in application commit
|
|
592
|
+
* orchestration: acknowledge exactly the batch that was enrolled, once.
|
|
593
|
+
*/
|
|
594
|
+
var PendingEventBatchMismatchError = class extends KitWiringError {
|
|
595
|
+
aggregateId;
|
|
596
|
+
batchLength;
|
|
597
|
+
pendingLength;
|
|
598
|
+
constructor(aggregateId, batchLength, pendingLength) {
|
|
599
|
+
super("PENDING_EVENT_BATCH_MISMATCH", `The committed batch of ${batchLength} event(s) is no longer the pending prefix of aggregate ${aggregateId} (${pendingLength} pending). Acknowledge exactly the batch that was enrolled, once.`);
|
|
600
|
+
this.aggregateId = aggregateId;
|
|
601
|
+
this.batchLength = batchLength;
|
|
602
|
+
this.pendingLength = pendingLength;
|
|
603
|
+
}
|
|
604
|
+
};
|
|
605
|
+
/**
|
|
606
|
+
* Thrown by persisted-event consumers (including `replayHistory` and
|
|
448
607
|
* `Projector`) when an event carries an
|
|
449
608
|
* `aggregateId` or `aggregateType` that names a different aggregate:
|
|
450
609
|
* the persisted row belongs to someone else (a miswired stream read,
|
|
@@ -461,21 +620,19 @@ var DuplicateEventIdError = class extends KitWiringError {
|
|
|
461
620
|
* {@link MisaddressedEventError}.
|
|
462
621
|
*/
|
|
463
622
|
var ForeignEventError = class extends InfrastructureError {
|
|
464
|
-
|
|
465
|
-
|
|
623
|
+
/** Address of the aggregate that received the event. */
|
|
624
|
+
expected;
|
|
625
|
+
/** Address fields the event carries. */
|
|
626
|
+
actual;
|
|
466
627
|
eventType;
|
|
467
|
-
|
|
468
|
-
actualAggregateType;
|
|
469
|
-
constructor(expectedAggregateId, expectedAggregateType, eventType, actualAggregateId, actualAggregateType) {
|
|
628
|
+
constructor(options) {
|
|
470
629
|
super({
|
|
471
630
|
code: "FOREIGN_EVENT",
|
|
472
|
-
message: `Persisted event "${eventType}" belongs to ${
|
|
631
|
+
message: `Persisted event "${options.eventType}" belongs to ${describeEventAddress(options)}, not to ${options.expected.aggregateType} ${options.expected.aggregateId}: the stream row addresses a different aggregate.`
|
|
473
632
|
});
|
|
474
|
-
this.
|
|
475
|
-
this.
|
|
476
|
-
this.eventType = eventType;
|
|
477
|
-
this.actualAggregateId = actualAggregateId;
|
|
478
|
-
this.actualAggregateType = actualAggregateType;
|
|
633
|
+
this.expected = options.expected;
|
|
634
|
+
this.actual = options.actual;
|
|
635
|
+
this.eventType = options.eventType;
|
|
479
636
|
}
|
|
480
637
|
};
|
|
481
638
|
/**
|
|
@@ -506,6 +663,35 @@ var NonProgressingEventStreamPageError = class extends InfrastructureError {
|
|
|
506
663
|
}
|
|
507
664
|
};
|
|
508
665
|
/**
|
|
666
|
+
* Thrown by a load recipe when the replayed aggregate does not end at the
|
|
667
|
+
* pinned stream head. Events carry no stream position, so the aggregate
|
|
668
|
+
* cannot detect a tail that overlaps the restored version or a page that
|
|
669
|
+
* lies outside the requested window; only the caller, which pinned the
|
|
670
|
+
* head, can compare. A snapshot catch-up passes only the events after the
|
|
671
|
+
* restored version, and the final version must equal the head.
|
|
672
|
+
*
|
|
673
|
+
* This is a non-retryable infrastructure error: the persistence adapter
|
|
674
|
+
* contradicted its port contract. Run `createEventStoreContractTests` and
|
|
675
|
+
* `createEsRepositoryContractTests` against the adapter and fix its
|
|
676
|
+
* windowing.
|
|
677
|
+
*/
|
|
678
|
+
var ReplayHeadMismatchError = class extends InfrastructureError {
|
|
679
|
+
aggregateType;
|
|
680
|
+
aggregateId;
|
|
681
|
+
targetVersion;
|
|
682
|
+
actualVersion;
|
|
683
|
+
constructor(options) {
|
|
684
|
+
super({
|
|
685
|
+
code: "REPLAY_HEAD_MISMATCH",
|
|
686
|
+
message: `Replay of ${options.aggregateType}(${options.aggregateId}) ended at version ${options.actualVersion}, not at the pinned stream head ${options.targetVersion}. The tail overlapped the restored version or a page lay outside the requested window; pass only the events after the restored version.`
|
|
687
|
+
});
|
|
688
|
+
this.aggregateType = options.aggregateType;
|
|
689
|
+
this.aggregateId = options.aggregateId;
|
|
690
|
+
this.targetVersion = options.targetVersion;
|
|
691
|
+
this.actualVersion = options.actualVersion;
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
/**
|
|
509
695
|
* Thrown when an event harvested from an aggregate cannot be safely composed
|
|
510
696
|
* into a commit envelope, or when an outbox can prove that accepting a
|
|
511
697
|
* candidate would violate its event identity/source chain. Harvest failures
|
|
@@ -532,6 +718,38 @@ var EventHarvestError = class extends KitWiringError {
|
|
|
532
718
|
}
|
|
533
719
|
};
|
|
534
720
|
/**
|
|
721
|
+
* Thrown at bootstrap when the global key of a kit capability registry
|
|
722
|
+
* already holds a value that is not a registry: another module claimed
|
|
723
|
+
* the key. The kit neither shares that value nor overwrites it, because a
|
|
724
|
+
* silent replacement would break whichever module owned the key first. A
|
|
725
|
+
* wiring error in the host process; the remedy is one owner per key.
|
|
726
|
+
*/
|
|
727
|
+
var CapabilityRegistryConflictError = class extends KitWiringError {
|
|
728
|
+
key;
|
|
729
|
+
constructor(key) {
|
|
730
|
+
super("CAPABILITY_REGISTRY_CONFLICT", `The global key ${String(key)} holds a value that is not a capability registry of this package. Another module claimed the key; the kit refuses to share or overwrite it.`);
|
|
731
|
+
this.key = key;
|
|
732
|
+
}
|
|
733
|
+
};
|
|
734
|
+
/**
|
|
735
|
+
* Thrown when a kit operation receives an instance that this package did
|
|
736
|
+
* not construct: a structural lookalike, a repository DTO, or an instance
|
|
737
|
+
* from an incompatible copy of the package. Such an instance carries none
|
|
738
|
+
* of the kit-managed capabilities the operation needs. A wiring error:
|
|
739
|
+
* extend the kit's base classes and run one compatible package copy.
|
|
740
|
+
*/
|
|
741
|
+
var UnmanagedInstanceError = class extends KitWiringError {
|
|
742
|
+
operation;
|
|
743
|
+
subject;
|
|
744
|
+
instanceId;
|
|
745
|
+
constructor(operation, subject, instanceId, detail) {
|
|
746
|
+
super("UNMANAGED_INSTANCE", `${operation} requires an instance constructed by this package; ${instanceId === void 0 ? subject : `${subject} ${String(instanceId)}`} carries no kit-managed capability. Construct it through this package and run one compatible package copy; a structural lookalike or an instance from another copy cannot be managed.` + (detail === void 0 ? "" : ` ${detail}`));
|
|
747
|
+
this.operation = operation;
|
|
748
|
+
this.subject = subject;
|
|
749
|
+
this.instanceId = instanceId;
|
|
750
|
+
}
|
|
751
|
+
};
|
|
752
|
+
/**
|
|
535
753
|
* Shared guard for the loud-rejection contract on own `__proto__` data
|
|
536
754
|
* keys (the shape `JSON.parse` produces for hostile rows, bodies, or
|
|
537
755
|
* envelopes): used by `Entity` state copies and the event metadata
|
|
@@ -818,5 +1036,5 @@ var IdempotencyCompletionWithoutClaimError = class extends KitWiringError {
|
|
|
818
1036
|
};
|
|
819
1037
|
|
|
820
1038
|
//#endregion
|
|
821
|
-
export {
|
|
822
|
-
//# sourceMappingURL=errors.js.map
|
|
1039
|
+
export { NonProgressingEventStreamPageError as A, SnapshotSchemaMismatchError as B, InvalidIntegrationMessageError as C, MissingEntityIdError as D, MisaddressedEventError as E, ProjectionOrderViolationError as F, UnprojectableEventError as G, UnenrolledChangesError as H, ProjectionReceiptViolationError as I, assertNoHostileOwnProtoKey as J, UnregisteredHandlerError as K, ReentrantEventRecordingError as L, PendingEventLimitExceededError as M, ProjectionGapError as N, MissingFoldError as O, ProjectionIdentityViolationError as P, ReplayHeadMismatchError as R, InvalidCommandMessageError as S, KitWiringError as T, UnmanagedInstanceError as U, SnapshotVersionNotRestoredError as V, UnmintedEventError as W, isInfrastructureErrorLike as X, isDomainErrorLike as Y, IdempotencyInFlightError as _, DirectStateMutationError as a, InMemoryCapacityExceededError as b, DuplicateEventIdError as c, EventHarvestError as d, FoldReturnedNoStateError as f, IdempotencyCompletionWithoutClaimError as g, IdempotencyClaimLostError as h, ConcurrencyConflictError as i, PendingEventBatchMismatchError as j, MissingHandlerError as k, DuplicateHandlerRegistrationError as l, HostileStateKeyError as m, AggregateNotFoundError as n, DomainError as o, ForeignEventError as p, UnreplayableAggregateError as q, CapabilityRegistryConflictError as r, DuplicateAggregateError as s, AggregateDeletedError as t, ErrorMapperFailedError as u, IdempotencyKeyReuseError as v, InvalidVersionError as w, InfrastructureError as x, IdempotencyReconciliationRequiredError as y, SnapshotCorruptedError as z };
|
|
1040
|
+
//# sourceMappingURL=kit-errors.js.map
|