@shirudo/ddd-kit 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -18
- package/dist/aggregate-DclYgG_D.d.ts +662 -0
- package/dist/http.d.ts +2 -2
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +623 -655
- package/dist/index.js +554 -48
- package/dist/index.js.map +1 -1
- package/dist/testing.d.ts +251 -0
- package/dist/testing.js +793 -0
- package/dist/testing.js.map +1 -0
- package/dist/utils.d.ts +3 -3
- package/dist/utils.js.map +1 -1
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @shirudo/ddd-kit
|
|
2
2
|
|
|
3
|
-
Composable TypeScript toolkit for tactical Domain-Driven Design. Ships the canonical building blocks
|
|
3
|
+
Composable TypeScript toolkit for tactical Domain-Driven Design. Ships the canonical building blocks (Value Objects, Entities, Aggregate Roots, Domain Events, Repositories, and CQRS handlers) without a framework or runtime lock-in. ESM-only; runs on Node 18+, Cloudflare Workers, Vercel Edge, Deno, and Bun.
|
|
4
4
|
|
|
5
|
-
> **Stable
|
|
5
|
+
> **Stable: 1.0**
|
|
6
6
|
>
|
|
7
7
|
> The public API is stable and follows [Semantic Versioning](https://semver.org/). Breaking changes bump the major and ship with a migration path in the [CHANGELOG](https://github.com/shi-rudo/ddd-kit-ts/blob/main/CHANGELOG.md).
|
|
8
8
|
|
|
@@ -11,14 +11,16 @@ Composable TypeScript toolkit for tactical Domain-Driven Design. Ships the canon
|
|
|
11
11
|
|
|
12
12
|
## Features
|
|
13
13
|
|
|
14
|
-
- **Value Objects
|
|
15
|
-
- **Entities
|
|
16
|
-
- **Aggregate Roots
|
|
17
|
-
- **Domain Events
|
|
18
|
-
- **Repositories
|
|
19
|
-
- **CQRS
|
|
20
|
-
- **
|
|
21
|
-
- **
|
|
14
|
+
- **Value Objects:** deep-frozen, by-attribute equality (`vo`, `ValueObject`, `voEquals`).
|
|
15
|
+
- **Entities:** identity + lifecycle, with collection helpers branded by `Id<Tag>`.
|
|
16
|
+
- **Aggregate Roots:** state-stored (`AggregateRoot`) and event-sourced (`EventSourcedAggregate`), with optimistic-concurrency versioning.
|
|
17
|
+
- **Domain Events:** typed, deeply frozen, carry metadata for traceability and schema evolution.
|
|
18
|
+
- **Repositories:** technology-agnostic persistence ports with an Identity-Map contract and OCC.
|
|
19
|
+
- **CQRS:** zero-config in-memory `CommandBus` / `QueryBus`, plus `CommandHandler` / `QueryHandler` types for external brokers.
|
|
20
|
+
- **Unit of Work:** opt-in `UnitOfWork` facade with tx-bound repositories, repository-side enrollment, a per-operation Identity Map, and aggregate-level dirty tracking (`changedKeys` / `hasChanges`) for partial writes — honestly speaking: a transaction coordinator with registration and Identity Map; writes stay explicit by design (no auto-flush).
|
|
21
|
+
- **Outbox:** `withCommit` harvests pending events inside the transaction, stamps them with the aggregate's commit version, and publishes them atomically.
|
|
22
|
+
- **Repository contract tests:** `@shirudo/ddd-kit/testing` ships the suite every adapter must pass — OCC is a testable contract, not a documented pattern.
|
|
23
|
+
- **Result-first boundary:** a typed error hierarchy on [`@shirudo/base-error`](https://www.npmjs.com/package/@shirudo/base-error) and `Result` from [`@shirudo/result`](https://www.npmjs.com/package/@shirudo/result); `voValidated` collects field violations and renders RFC 9457 via the opt-in `@shirudo/ddd-kit/http` entry.
|
|
22
24
|
|
|
23
25
|
## Installation
|
|
24
26
|
|
|
@@ -26,7 +28,7 @@ Composable TypeScript toolkit for tactical Domain-Driven Design. Ships the canon
|
|
|
26
28
|
pnpm add @shirudo/ddd-kit @shirudo/result @shirudo/base-error
|
|
27
29
|
```
|
|
28
30
|
|
|
29
|
-
`@shirudo/result` and `@shirudo/base-error` are peer dependencies
|
|
31
|
+
`@shirudo/result` and `@shirudo/base-error` are peer dependencies; install them once in the consuming app.
|
|
30
32
|
|
|
31
33
|
## Quick start
|
|
32
34
|
|
|
@@ -43,11 +45,11 @@ function createEmail(value: string): EmailAddress {
|
|
|
43
45
|
const email = createEmail("user@example.com");
|
|
44
46
|
```
|
|
45
47
|
|
|
46
|
-
For a complete walkthrough
|
|
48
|
+
For a complete walkthrough (a minimal `Order` aggregate with typed events, `commit()`, and the App-Service boundary), see [Getting Started](https://github.com/shi-rudo/ddd-kit-ts/blob/main/docs/guide/getting-started.md).
|
|
47
49
|
|
|
48
50
|
## Core concepts
|
|
49
51
|
|
|
50
|
-
Each building block has a dedicated guide. Start with [Design Decisions](https://github.com/shi-rudo/ddd-kit-ts/blob/main/docs/guide/design-decisions.md) for the non-obvious calls (Result at the App boundary, no Specification pattern,
|
|
52
|
+
Each building block has a dedicated guide. Start with [Design Decisions](https://github.com/shi-rudo/ddd-kit-ts/blob/main/docs/guide/design-decisions.md) for the non-obvious calls (Result at the App boundary, no Specification pattern, the TransactionScope/Unit-of-Work layering, class-based aggregates).
|
|
51
53
|
|
|
52
54
|
| Concept | Guide |
|
|
53
55
|
|---|---|
|
|
@@ -59,6 +61,7 @@ Each building block has a dedicated guide. Start with [Design Decisions](https:/
|
|
|
59
61
|
| Errors: throw vs Result, `ValidationError`, RFC 9457 | [Result vs Throw](https://github.com/shi-rudo/ddd-kit-ts/blob/main/docs/guide/result-vs-throw.md) |
|
|
60
62
|
| Commands, queries, buses | [CQRS & Buses](https://github.com/shi-rudo/ddd-kit-ts/blob/main/docs/guide/cqrs-and-buses.md) |
|
|
61
63
|
| Repositories, Identity Map, OCC | [Repository](https://github.com/shi-rudo/ddd-kit-ts/blob/main/docs/guide/repository.md) |
|
|
64
|
+
| Unit of Work, enrollment, contract test suite | [Unit of Work](https://github.com/shi-rudo/ddd-kit-ts/blob/main/docs/guide/unit-of-work.md) |
|
|
62
65
|
| Outbox, `withCommit`, transactions | [Outbox & Transactions](https://github.com/shi-rudo/ddd-kit-ts/blob/main/docs/guide/outbox.md) |
|
|
63
66
|
| Read-side projections | [Projections](https://github.com/shi-rudo/ddd-kit-ts/blob/main/docs/guide/projections.md) |
|
|
64
67
|
| Concurrency & operation-scoped aggregates | [Concurrency](https://github.com/shi-rudo/ddd-kit-ts/blob/main/docs/guide/concurrency.md) |
|
|
@@ -66,10 +69,10 @@ Each building block has a dedicated guide. Start with [Design Decisions](https:/
|
|
|
66
69
|
|
|
67
70
|
## Documentation
|
|
68
71
|
|
|
69
|
-
- **[LLM.md](https://github.com/shi-rudo/ddd-kit-ts/blob/main/LLM.md)
|
|
70
|
-
- **[Common Mistakes](https://github.com/shi-rudo/ddd-kit-ts/blob/main/docs/guide/common-mistakes.md)
|
|
71
|
-
- **API reference
|
|
72
|
-
- **[CHANGELOG](https://github.com/shi-rudo/ddd-kit-ts/blob/main/CHANGELOG.md)
|
|
72
|
+
- **[LLM.md](https://github.com/shi-rudo/ddd-kit-ts/blob/main/LLM.md):** hand-curated, high-signal guide for LLM coding tools and a fast human skim of the whole surface.
|
|
73
|
+
- **[Common Mistakes](https://github.com/shi-rudo/ddd-kit-ts/blob/main/docs/guide/common-mistakes.md):** the footgun catalogue; read it before writing consumer code.
|
|
74
|
+
- **API reference:** full type definitions ship with the package (`node_modules/@shirudo/ddd-kit/dist/index.d.ts`); the `@shirudo/ddd-kit/http` subpath exports the RFC 9457 presenter.
|
|
75
|
+
- **[CHANGELOG](https://github.com/shi-rudo/ddd-kit-ts/blob/main/CHANGELOG.md):** release history with a migration path for every breaking change.
|
|
73
76
|
|
|
74
77
|
## TypeScript support
|
|
75
78
|
|
|
@@ -85,4 +88,4 @@ MIT.
|
|
|
85
88
|
|
|
86
89
|
## Author
|
|
87
90
|
|
|
88
|
-
**Shirudo
|
|
91
|
+
**Shirudo:** [@shi-rudo](https://github.com/shi-rudo) · [npm](https://www.npmjs.com/package/@shirudo/ddd-kit) · [repo](https://github.com/shi-rudo/ddd-kit-ts)
|