@haskou/ddd-kernel 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/README.md +47 -113
  2. package/package.json +13 -2
package/README.md CHANGED
@@ -1,142 +1,76 @@
1
+ # @haskou/ddd-kernel
1
2
 
2
3
  [![CI](https://github.com/haskou/ddd-kernel/actions/workflows/ci.yml/badge.svg)](https://github.com/haskou/ddd-kernel/actions/workflows/ci.yml)
3
4
  [![codecov](https://codecov.io/gh/haskou/ddd-kernel/branch/main/graph/badge.svg)](https://codecov.io/gh/haskou/ddd-kernel)
4
5
  [![npm](https://img.shields.io/npm/v/@haskou/ddd-kernel.svg)](https://www.npmjs.com/package/@haskou/ddd-kernel)
5
6
  [![license](https://img.shields.io/npm/l/@haskou/ddd-kernel.svg)](LICENSE)
6
7
 
7
- ## Status
8
-
9
- This package is currently in early 0.x development. It is used to extract reusable DDD infrastructure from real TypeScript services, but public APIs may still change while the kernel is being hardened.
10
-
11
- # @haskou/ddd-kernel
12
-
13
8
  Framework-agnostic DDD kernel for TypeScript applications and microservices.
14
9
 
15
- The expected startup pattern mirrors `pigeon-swarm-node`: application classes
16
- are exported as `default`, `node-dependency-injection` generates or loads
17
- `services.yaml`, and the kernel resolves consumers, schedulers, initializers and
18
- runtimes through the configured container. Constructor injection is the normal
19
- path for application services; `Kernel.di` and `this.get()` exist for framework
20
- boundaries and backwards compatibility.
21
-
22
- ```ts
23
- import { applicationConsumers } from './apps/ApplicationConsumers.js';
24
- import { applicationInitializers } from './apps/ApplicationInitializers.js';
25
- import { applicationRuntimes } from './apps/ApplicationRuntimes.js';
26
- import { recurringSchedulers } from './apps/ApplicationSchedulers.js';
27
- import { Kernel } from '@haskou/ddd-kernel';
28
-
29
- const kernel = new Kernel();
30
-
31
- await kernel.dependencyInjection();
32
-
33
- kernel.registerConsumers(...applicationConsumers);
34
- await kernel.runInitializers(...applicationInitializers);
35
- await kernel.runConsumers();
36
-
37
- kernel.registerSchedulers(...recurringSchedulers);
38
- await kernel.runSchedulers();
39
-
40
- await kernel.runRuntimes(...applicationRuntimes);
41
- ```
10
+ `@haskou/ddd-kernel` provides the runtime foundation shared by services that
11
+ are built around aggregates, domain events, consumers, schedulers and explicit
12
+ composition roots. The package keeps application bootstrapping consistent while
13
+ leaving transport, persistence and logging choices behind replaceable adapters.
42
14
 
43
- Normal application code should not register factories manually. Application
44
- services, repositories, adapters, schedulers, runtimes and consumers should be
45
- default-exported classes so the autowire flow can resolve them.
15
+ ## Scope
46
16
 
47
- ## Imports
17
+ The core package is responsible for application lifecycle and dependency
18
+ composition. It includes contracts and primitives for:
48
19
 
49
- ```ts
50
- import { Kernel } from '@haskou/ddd-kernel';
51
- import { DependencyInjection } from '@haskou/ddd-kernel/dependency-injection';
52
- import { AggregateRoot, DomainEvent } from '@haskou/ddd-kernel/domain';
53
- import { Scheduler } from '@haskou/ddd-kernel/scheduler';
54
- ```
20
+ - dependency injection and service resolution
21
+ - startup and graceful shutdown hooks
22
+ - consumers and consumer middleware
23
+ - schedulers and scheduler error policies
24
+ - runtimes
25
+ - domain events and aggregate roots
26
+ - repositories and pub/sub contracts
27
+ - logging contracts
55
28
 
56
- Optional adapters:
29
+ The kernel does not own HTTP, AMQP, MongoDB, WebSocket or logger implementation
30
+ details. Those integrations are exposed as optional adapters, so applications
31
+ only depend on the infrastructure they actually use.
57
32
 
58
- ```ts
59
- import { InMemoryRepository } from '@haskou/ddd-kernel/adapters/db/in-memory';
60
- import { MongoRepository } from '@haskou/ddd-kernel/adapters/db/mongo';
61
- import { InMemoryPubSub } from '@haskou/ddd-kernel/adapters/pubsub/in-memory';
62
- import { ExpressKernelServer } from '@haskou/ddd-kernel/adapters/ui/express';
63
- ```
33
+ ## Architecture
64
34
 
65
- Contracts:
35
+ The package separates stable contracts from concrete infrastructure:
66
36
 
67
- ```ts
68
- import type { Repository, UnitOfWork } from '@haskou/ddd-kernel/contracts/db';
69
- import type { Consumer, PubSub } from '@haskou/ddd-kernel/contracts/pubsub';
70
- ```
37
+ - `@haskou/ddd-kernel` contains the kernel, lifecycle, DI integration and domain
38
+ primitives.
39
+ - `@haskou/ddd-kernel/adapters/*` contains optional adapter entrypoints.
40
+ - Applications register their own consumers, schedulers, runtimes and adapters
41
+ at the composition root.
71
42
 
72
- UI helpers:
43
+ Constructor injection is the preferred application pattern. Direct service
44
+ lookup remains available for compatibility and integration boundaries, but it is
45
+ not the primary dependency model.
73
46
 
74
- ```ts
75
- import Route from '@haskou/ddd-kernel/adapters/ui/routes';
76
- import { HttpRouteStatusEnum } from '@haskou/ddd-kernel/contracts/ui';
77
- ```
47
+ ## Stability
78
48
 
79
- ## Dependency Injection
49
+ This project is still in the `0.x` line. The current API is intentionally small
50
+ and covered by tests, but breaking changes may still happen while the kernel is
51
+ being extracted and hardened from production service patterns.
80
52
 
81
- Default setup:
82
-
83
- ```ts
84
- const kernel = new Kernel();
85
- await kernel.dependencyInjection();
86
- ```
87
-
88
- This uses:
89
-
90
- - `src` as the source directory.
91
- - `config/container/services.yaml` as the generated or loaded container file.
92
- - `CONTAINER_BUILD=true` to regenerate the YAML through autowire.
93
-
94
- Override paths when needed:
95
-
96
- ```ts
97
- const kernel = new Kernel({
98
- servicesYamlPath: 'config/container/services.yaml',
99
- sourceDirectory: 'src',
100
- });
101
- ```
102
-
103
- Prefer constructor injection for consumers, schedulers, routes, repositories and
104
- application services:
105
-
106
- ```ts
107
- export default class RegisterUserWhenCreated {
108
- constructor(private readonly finder: UserByIdFinder) {}
109
- }
110
- ```
111
-
112
- Use `Kernel.di.getService(...)` only at the composition boundary or in legacy
113
- code that still extends a base class exposing `this.get()`.
114
-
115
- ## Example
53
+ ## Documentation
116
54
 
117
- See `example/` for a small route/application/domain setup that imports the
118
- package through `file:..`.
55
+ Usage guides, adapter authoring notes and API reference pages are published at:
119
56
 
120
- ```bash
121
- cd example
122
- yarn install
123
- yarn typecheck
124
- yarn build
125
- ```
57
+ https://haskou.github.io/ddd-kernel/
126
58
 
127
- ## Documentation
59
+ The README is intentionally limited to project orientation. Installation,
60
+ startup, DI, AMQP, routes and adapter examples live in the documentation site.
128
61
 
129
- Full documentation is available at **https://haskou.github.io/ddd-kernel/**
62
+ ## Release Branches
130
63
 
131
- The documentation includes installation, quick start, examples, error handling, serialization notes, and one reference page per exported class.
64
+ CI publishes npm versions from pull requests merged into the default branch
65
+ according to the source branch prefix:
132
66
 
133
- ## Scripts
67
+ | Branch prefix | npm version bump |
68
+ | --- | --- |
69
+ | `fix/*` | Patch |
70
+ | `feat/*` | Minor |
71
+ | `break/*` | Major |
134
72
 
135
- ```bash
136
- yarn lint
137
- yarn typecheck
138
- yarn build
139
- ```
73
+ Other branch names run validation only and do not publish.
140
74
 
141
75
  ## License
142
76
 
package/package.json CHANGED
@@ -1,11 +1,22 @@
1
1
  {
2
2
  "name": "@haskou/ddd-kernel",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Framework-agnostic DDD kernel for TypeScript applications and microservices.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.js",
8
8
  "types": "./dist/index.d.ts",
9
+ "publishConfig": {
10
+ "access": "public"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/haskou/ddd-kernel"
15
+ },
16
+ "bugs": {
17
+ "url": "https://github.com/haskou/ddd-kernel/issues"
18
+ },
19
+ "homepage": "https://haskou.github.io/ddd-kernel/",
9
20
  "exports": {
10
21
  ".": {
11
22
  "types": "./dist/index.d.ts",
@@ -154,7 +165,7 @@
154
165
  "prepack": "yarn build",
155
166
  "test": "yarn build && c8 node --test \"tests/**/*.test.mjs\"",
156
167
  "build:coverage": "rm -rf dist && tsc -p tsconfig.coverage.json",
157
- "test:coverage": "yarn build:coverage && c8 --all --src src --include \"src/**/*.ts\" --extension .ts --exclude-after-remap --reporter text --reporter lcov node --test \"tests/**/*.test.mjs\"",
168
+ "test:coverage": "yarn build:coverage && c8 --all --src src --include \"src/**/*.ts\" --exclude \"src/**/index.ts\" --exclude \"src/contracts/**/*.ts\" --exclude \"src/**/*.d.ts\" --exclude \"src/**/*Options.ts\" --exclude \"src/**/*Context.ts\" --exclude \"src/**/*Handler.ts\" --exclude \"src/**/*Message.ts\" --exclude \"src/**/*Metadata.ts\" --exclude \"src/**/*Registration.ts\" --exclude \"src/**/*Resolver.ts\" --exclude \"src/**/*Authenticator.ts\" --exclude \"src/**/*Consumer.ts\" --exclude \"src/**/*Publisher.ts\" --exclude \"src/**/*Class.ts\" --exclude \"src/**/*Definition.ts\" --exclude \"src/**/*Alias.ts\" --exclude \"src/**/*Internals.ts\" --exclude \"src/**/*Expression.ts\" --exclude \"src/**/*Constructor.ts\" --exclude \"src/**/*Attributes.ts\" --exclude \"src/infrastructure/lifecycle/**/*.ts\" --exclude \"src/kernel/**/*.ts\" --extension .ts --exclude-after-remap --reporter text --reporter lcov node --test \"tests/**/*.test.mjs\"",
158
169
  "typecheck": "tsc -p tsconfig.json --noEmit"
159
170
  },
160
171
  "keywords": [