@shirudo/ddd-kit 3.0.0-rc.4 → 3.0.0-rc.6
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 +4 -20
- 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 +910 -110
- 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 +3469 -2432
- package/dist/index.js +5663 -4869
- 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 +18 -18
- 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
package/dist/testing.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Lt as PublishedCommand, P as EventBus, Pt as AggregateAddress, R as Aggregate, W as Id, Y as CommandOutboxCommitCandidate, Z as CommandOutboxWriter, _ as IdempotencyStore, a as StreamReadResult, c as ProjectionCheckpointStore, ct as EventCommitCandidate, f as IdempotencyClaimHandle, i as ReadStreamOptions, n as EventStore, nt as Outbox, st as CommittedDomainEvent, t as SnapshotStore, tt as DispatchTrackingOutbox, ut as AnyDomainEvent, w as DeadlineStore } from "./chunks/snapshot-store.js";
|
|
3
2
|
//#region src/testing/contract-assertions.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* One entry of a contract test suite. Every suite (repository,
|
|
@@ -119,12 +118,12 @@ declare function createDeadlineStoreContractTests(harness: DeadlineStoreContract
|
|
|
119
118
|
//#endregion
|
|
120
119
|
//#region src/testing/es-repository-contract.d.ts
|
|
121
120
|
/** Event-sourced repositories normally expose no physical removal. */
|
|
122
|
-
interface EsContractRepository<TAggregate extends
|
|
121
|
+
interface EsContractRepository<TAggregate extends Aggregate<Id<string>, AnyDomainEvent>> {
|
|
123
122
|
findById(id: TAggregate["id"]): Promise<TAggregate | undefined>;
|
|
124
123
|
add(aggregate: TAggregate): void;
|
|
125
124
|
update(aggregate: TAggregate): void;
|
|
126
125
|
}
|
|
127
|
-
interface EsRepositoryContractEnvironment<TAggregate extends
|
|
126
|
+
interface EsRepositoryContractEnvironment<TAggregate extends Aggregate<Id<string>, TEvent>, TEvent extends AnyDomainEvent = AnyDomainEvent> {
|
|
128
127
|
run<R>(work: (context: {
|
|
129
128
|
repository: EsContractRepository<TAggregate>;
|
|
130
129
|
}) => Promise<R>): Promise<R>;
|
|
@@ -133,7 +132,7 @@ interface EsRepositoryContractEnvironment<TAggregate extends IAggregateRoot<Id<s
|
|
|
133
132
|
committedStreamEvents(stream: AggregateAddress<TAggregate["id"]>, options: ReadStreamOptions): Promise<StreamReadResult<TEvent>>;
|
|
134
133
|
teardown?(): Promise<void>;
|
|
135
134
|
}
|
|
136
|
-
interface EsRepositoryContractHarness<TAggregate extends
|
|
135
|
+
interface EsRepositoryContractHarness<TAggregate extends Aggregate<Id<string>, TEvent>, TEvent extends AnyDomainEvent = AnyDomainEvent> {
|
|
137
136
|
createEnvironment(): Promise<EsRepositoryContractEnvironment<TAggregate, TEvent>>;
|
|
138
137
|
/** Fresh aggregate with exactly one recorded creation event. */
|
|
139
138
|
createAggregate(): TAggregate;
|
|
@@ -142,6 +141,12 @@ interface EsRepositoryContractHarness<TAggregate extends IAggregateRoot<Id<strin
|
|
|
142
141
|
/** Applies exactly one event and advances the aggregate version by one. */
|
|
143
142
|
mutate(aggregate: TAggregate): void;
|
|
144
143
|
snapshotState?(aggregate: TAggregate): unknown;
|
|
144
|
+
/**
|
|
145
|
+
* Persists a snapshot of the aggregate at its current version in the
|
|
146
|
+
* environment's snapshot store, so the next load there starts from it.
|
|
147
|
+
* Enables the snapshot catch-up proof.
|
|
148
|
+
*/
|
|
149
|
+
captureSnapshot?(aggregate: TAggregate, environment: EsRepositoryContractEnvironment<TAggregate, TEvent>): Promise<void>;
|
|
145
150
|
}
|
|
146
151
|
type EsRepositoryContractTest = ContractTest;
|
|
147
152
|
/**
|
|
@@ -152,7 +157,52 @@ type EsRepositoryContractTest = ContractTest;
|
|
|
152
157
|
* same transaction as the outbox. `run` must support overlapping calls so the
|
|
153
158
|
* mandatory stale-writer proof exercises a real stream OCC predicate.
|
|
154
159
|
*/
|
|
155
|
-
declare function createEsRepositoryContractTests<TAggregate extends
|
|
160
|
+
declare function createEsRepositoryContractTests<TAggregate extends Aggregate<Id<string>, TEvent>, TEvent extends AnyDomainEvent = AnyDomainEvent>(harness: EsRepositoryContractHarness<TAggregate, TEvent>): EsRepositoryContractTest[];
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region src/testing/event-bus-contract.d.ts
|
|
163
|
+
/** One entry of the event-bus contract suite. */
|
|
164
|
+
type EventBusContractTest = ContractTest;
|
|
165
|
+
/**
|
|
166
|
+
* What the suite runs against. The harness creates one per test and tears
|
|
167
|
+
* it down afterwards. No transaction wrapper: the port is in-process and
|
|
168
|
+
* transaction-free by design.
|
|
169
|
+
*/
|
|
170
|
+
interface EventBusContractEnvironment<Evt extends AnyDomainEvent> {
|
|
171
|
+
/** The implementation under test. */
|
|
172
|
+
readonly bus: EventBus<Evt>;
|
|
173
|
+
/** Release connections, drop schemas, etc. Called in a finally. */
|
|
174
|
+
teardown?(): Promise<void>;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* What an implementation supplies to run the event-bus contract suite.
|
|
178
|
+
*
|
|
179
|
+
* The suite mints no events, so it stays free of any event union. The two
|
|
180
|
+
* factories must produce DIFFERENT `type` values: the suite subscribes to
|
|
181
|
+
* both to prove that ordering holds across types and that a catch-all
|
|
182
|
+
* subscription sees every type.
|
|
183
|
+
*/
|
|
184
|
+
interface EventBusContractHarness<Evt extends AnyDomainEvent> {
|
|
185
|
+
createEnvironment(): Promise<EventBusContractEnvironment<Evt>>;
|
|
186
|
+
/** An event of the first type. Called repeatedly; each call may differ. */
|
|
187
|
+
createFirstEvent(): Evt;
|
|
188
|
+
/** An event of the second type, whose `type` differs from the first. */
|
|
189
|
+
createSecondEvent(): Evt;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* The event-bus contract test suite: the proof that an implementation
|
|
193
|
+
* delivers the guarantees the `EventBus` port documents. Ordering,
|
|
194
|
+
* parallelism within one event, and error collection after the batch are
|
|
195
|
+
* a **port contract, not a kit guarantee**; this suite is how an
|
|
196
|
+
* implementation demonstrates them.
|
|
197
|
+
*
|
|
198
|
+
* The suite covers the port and nothing else. Construction options of the
|
|
199
|
+
* kit's own adapter, such as a publish-depth bound or an observer bundle,
|
|
200
|
+
* are not port behavior and are not pinned here.
|
|
201
|
+
*
|
|
202
|
+
* Framework-agnostic: bind with
|
|
203
|
+
* `(test.skipped ? it.skip : it)(test.name, test.run)`.
|
|
204
|
+
*/
|
|
205
|
+
declare function createEventBusContractTests<Evt extends AnyDomainEvent>(harness: EventBusContractHarness<Evt>): EventBusContractTest[];
|
|
156
206
|
//#endregion
|
|
157
207
|
//#region src/testing/event-store-contract.d.ts
|
|
158
208
|
/** One named contract test for an EventStore adapter. */
|
|
@@ -441,7 +491,7 @@ declare function createProjectionCheckpointStoreContractTests<TCtx>(harness: Pro
|
|
|
441
491
|
//#endregion
|
|
442
492
|
//#region src/testing/repository-contract.d.ts
|
|
443
493
|
/** Application-facing state-stored repository exercised by the suite. */
|
|
444
|
-
interface ContractRepository<TAggregate extends
|
|
494
|
+
interface ContractRepository<TAggregate extends Aggregate<Id<string>, AnyDomainEvent>> {
|
|
445
495
|
findById(id: TAggregate["id"]): Promise<TAggregate | undefined>;
|
|
446
496
|
add(aggregate: TAggregate): void;
|
|
447
497
|
update(aggregate: TAggregate): void;
|
|
@@ -449,7 +499,7 @@ interface ContractRepository<TAggregate extends IAggregateRoot<Id<string>, AnyDo
|
|
|
449
499
|
remove?(aggregate: TAggregate): void;
|
|
450
500
|
}
|
|
451
501
|
/** One isolated real-adapter environment. `run` must permit overlapping calls. */
|
|
452
|
-
interface RepositoryContractEnvironment<TAggregate extends
|
|
502
|
+
interface RepositoryContractEnvironment<TAggregate extends Aggregate<Id<string>, TEvent>, TEvent extends AnyDomainEvent = AnyDomainEvent> {
|
|
453
503
|
run<R>(work: (context: {
|
|
454
504
|
repository: ContractRepository<TAggregate>;
|
|
455
505
|
}) => Promise<R>): Promise<R>;
|
|
@@ -459,7 +509,7 @@ interface RepositoryContractEnvironment<TAggregate extends IAggregateRoot<Id<str
|
|
|
459
509
|
teardown?(): Promise<void>;
|
|
460
510
|
}
|
|
461
511
|
/** Fixtures and observable projections supplied by an adapter package. */
|
|
462
|
-
interface RepositoryContractHarness<TAggregate extends
|
|
512
|
+
interface RepositoryContractHarness<TAggregate extends Aggregate<Id<string>, TEvent>, TEvent extends AnyDomainEvent = AnyDomainEvent> {
|
|
463
513
|
createEnvironment(): Promise<RepositoryContractEnvironment<TAggregate, TEvent>>;
|
|
464
514
|
/** A fresh aggregate with a unique id. */
|
|
465
515
|
createAggregate(): TAggregate;
|
|
@@ -502,7 +552,7 @@ type RepositoryContractTest = ContractTest;
|
|
|
502
552
|
* callback returns, while the transaction is still open. A test that passes
|
|
503
553
|
* because `add` or `update` writes early is not a conforming implementation.
|
|
504
554
|
*/
|
|
505
|
-
declare function createRepositoryContractTests<TAggregate extends
|
|
555
|
+
declare function createRepositoryContractTests<TAggregate extends Aggregate<Id<string>, TEvent>, TEvent extends AnyDomainEvent = AnyDomainEvent>(harness: RepositoryContractHarness<TAggregate, TEvent>): RepositoryContractTest[];
|
|
506
556
|
//#endregion
|
|
507
557
|
//#region src/testing/snapshot-store-contract.d.ts
|
|
508
558
|
/** One contract test; bind with `(test.skipped ? it.skip : it)(test.name, test.run)`. */
|
|
@@ -552,5 +602,5 @@ interface SnapshotStoreContractHarness {
|
|
|
552
602
|
*/
|
|
553
603
|
declare function createSnapshotStoreContractTests(harness: SnapshotStoreContractHarness): SnapshotStoreContractTest[];
|
|
554
604
|
//#endregion
|
|
555
|
-
export { type CommandOutboxContractEnvironment, type CommandOutboxContractHarness, type CommandOutboxContractTest, type ContractRepository, type DeadlineStoreContractEnvironment, type DeadlineStoreContractHarness, type DeadlineStoreContractTest, type EsContractRepository, type EsRepositoryContractEnvironment, type EsRepositoryContractHarness, type EsRepositoryContractTest, type EventStoreContractEnvironment, type EventStoreContractHarness, type EventStoreContractTest, type IdempotencyStoreContractEnvironment, type IdempotencyStoreContractHarness, type IdempotencyStoreContractTest, type OutboxContractEnvironment, type OutboxContractHarness, type OutboxContractTest, type ProjectionCheckpointStoreContractEnvironment, type ProjectionCheckpointStoreContractHarness, type ProjectionCheckpointStoreContractTest, type RepositoryContractEnvironment, type RepositoryContractHarness, type RepositoryContractTest, type SnapshotStoreContractEnvironment, type SnapshotStoreContractHarness, type SnapshotStoreContractTest, createCommandOutboxContractTests, createDeadlineStoreContractTests, createEsRepositoryContractTests, createEventStoreContractTests, createIdempotencyStoreContractTests, createOutboxContractTests, createProjectionCheckpointStoreContractTests, createRepositoryContractTests, createSnapshotStoreContractTests };
|
|
605
|
+
export { type CommandOutboxContractEnvironment, type CommandOutboxContractHarness, type CommandOutboxContractTest, type ContractRepository, type DeadlineStoreContractEnvironment, type DeadlineStoreContractHarness, type DeadlineStoreContractTest, type EsContractRepository, type EsRepositoryContractEnvironment, type EsRepositoryContractHarness, type EsRepositoryContractTest, type EventBusContractEnvironment, type EventBusContractHarness, type EventBusContractTest, type EventStoreContractEnvironment, type EventStoreContractHarness, type EventStoreContractTest, type IdempotencyStoreContractEnvironment, type IdempotencyStoreContractHarness, type IdempotencyStoreContractTest, type OutboxContractEnvironment, type OutboxContractHarness, type OutboxContractTest, type ProjectionCheckpointStoreContractEnvironment, type ProjectionCheckpointStoreContractHarness, type ProjectionCheckpointStoreContractTest, type RepositoryContractEnvironment, type RepositoryContractHarness, type RepositoryContractTest, type SnapshotStoreContractEnvironment, type SnapshotStoreContractHarness, type SnapshotStoreContractTest, createCommandOutboxContractTests, createDeadlineStoreContractTests, createEsRepositoryContractTests, createEventBusContractTests, createEventStoreContractTests, createIdempotencyStoreContractTests, createOutboxContractTests, createProjectionCheckpointStoreContractTests, createRepositoryContractTests, createSnapshotStoreContractTests };
|
|
556
606
|
//# sourceMappingURL=testing.d.ts.map
|