@haskou/ddd-kernel 0.1.0 → 1.0.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 +44 -115
- package/dist/DomainEventConsumer-Bg-bOwmh.d.cts +11 -0
- package/dist/DomainEventConsumer-BroJmVty.d.ts +11 -0
- package/dist/DomainMessageBus-3jYk7TPw.d.ts +13 -0
- package/dist/DomainMessageBus-OyliPu3Z.d.cts +13 -0
- package/dist/MessageBus-BtUXnd0Y.d.cts +10 -0
- package/dist/MessageBus-oQ9BnW84.d.ts +10 -0
- package/dist/{NoFailedMessagesError-0YJKRWPF.d.ts → NoFailedMessagesError-BLpGI-G4.d.ts} +6 -1
- package/dist/{NoFailedMessagesError-Kz7CYWpT.d.cts → NoFailedMessagesError-BjxYoKTR.d.cts} +6 -1
- package/dist/PublisherHookErrorPolicy-CjouTcSR.d.cts +8 -0
- package/dist/PublisherHookErrorPolicy-DSsCNE6O.d.ts +8 -0
- package/dist/RetryPredicate-U7dYnQ4N.d.ts +15 -0
- package/dist/RetryPredicate-yT_z9zk1.d.cts +15 -0
- package/dist/{Scheduler-oigqNOUJ.d.ts → Scheduler-BW-U5Ccg.d.cts} +1 -1
- package/dist/{Scheduler-oigqNOUJ.d.cts → Scheduler-BW-U5Ccg.d.ts} +1 -1
- package/dist/ServiceClass-BkEHcXDi.d.cts +72 -0
- package/dist/ServiceClass-Bq_fBC5R.d.ts +72 -0
- package/dist/{Kernel-BWUOUWWI.d.cts → ShutdownHook-BjbnCKzr.d.cts} +49 -7
- package/dist/{Kernel-CUaqHa1s.d.ts → ShutdownHook-CMWLsfu-.d.ts} +49 -7
- package/dist/Subscription-4vuAAxax.d.cts +23 -0
- package/dist/Subscription-vtF0lEHP.d.ts +23 -0
- package/dist/adapters/index.cjs +665 -37
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.d.cts +15 -13
- package/dist/adapters/index.d.ts +15 -13
- package/dist/adapters/index.js +659 -37
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/pubsub/amqp/index.cjs +241 -16
- package/dist/adapters/pubsub/amqp/index.cjs.map +1 -1
- package/dist/adapters/pubsub/amqp/index.d.cts +16 -8
- package/dist/adapters/pubsub/amqp/index.d.ts +16 -8
- package/dist/adapters/pubsub/amqp/index.js +241 -16
- package/dist/adapters/pubsub/amqp/index.js.map +1 -1
- package/dist/adapters/pubsub/in-memory/index.cjs +96 -8
- package/dist/adapters/pubsub/in-memory/index.cjs.map +1 -1
- package/dist/adapters/pubsub/in-memory/index.d.cts +9 -3
- package/dist/adapters/pubsub/in-memory/index.d.ts +9 -3
- package/dist/adapters/pubsub/in-memory/index.js +96 -8
- package/dist/adapters/pubsub/in-memory/index.js.map +1 -1
- package/dist/adapters/pubsub/index.cjs +397 -27
- package/dist/adapters/pubsub/index.cjs.map +1 -1
- package/dist/adapters/pubsub/index.d.cts +89 -7
- package/dist/adapters/pubsub/index.d.ts +89 -7
- package/dist/adapters/pubsub/index.js +389 -26
- package/dist/adapters/pubsub/index.js.map +1 -1
- package/dist/adapters/ui/express/index.cjs +279 -11
- package/dist/adapters/ui/express/index.cjs.map +1 -1
- package/dist/adapters/ui/express/index.d.cts +127 -12
- package/dist/adapters/ui/express/index.d.ts +127 -12
- package/dist/adapters/ui/express/index.js +270 -11
- package/dist/adapters/ui/express/index.js.map +1 -1
- package/dist/adapters/ui/index.cjs +412 -27
- package/dist/adapters/ui/index.cjs.map +1 -1
- package/dist/adapters/ui/index.d.cts +7 -8
- package/dist/adapters/ui/index.d.ts +7 -8
- package/dist/adapters/ui/index.js +413 -27
- package/dist/adapters/ui/index.js.map +1 -1
- package/dist/adapters/ui/routes/index.cjs +136 -9
- package/dist/adapters/ui/routes/index.cjs.map +1 -1
- package/dist/adapters/ui/routes/index.js +136 -9
- package/dist/adapters/ui/routes/index.js.map +1 -1
- package/dist/contracts/index.cjs +16 -17
- package/dist/contracts/index.cjs.map +1 -1
- package/dist/contracts/index.d.cts +10 -2
- package/dist/contracts/index.d.ts +10 -2
- package/dist/contracts/index.js +16 -17
- package/dist/contracts/index.js.map +1 -1
- package/dist/contracts/kernel/index.cjs.map +1 -1
- package/dist/contracts/kernel/index.d.cts +7 -1
- package/dist/contracts/kernel/index.d.ts +7 -1
- package/dist/contracts/pubsub/index.cjs.map +1 -1
- package/dist/contracts/pubsub/index.d.cts +5 -1
- package/dist/contracts/pubsub/index.d.ts +5 -1
- package/dist/contracts/ui/index.cjs +16 -17
- package/dist/contracts/ui/index.cjs.map +1 -1
- package/dist/contracts/ui/index.d.cts +16 -16
- package/dist/contracts/ui/index.d.ts +16 -16
- package/dist/contracts/ui/index.js +16 -17
- package/dist/contracts/ui/index.js.map +1 -1
- package/dist/domain/index.cjs.map +1 -1
- package/dist/domain/index.d.cts +6 -2
- package/dist/domain/index.d.ts +6 -2
- package/dist/domain/index.js.map +1 -1
- package/dist/index.cjs +152 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -7
- package/dist/index.d.ts +8 -7
- package/dist/index.js +152 -26
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/dependency-injection/index.cjs +119 -3
- package/dist/infrastructure/dependency-injection/index.cjs.map +1 -1
- package/dist/infrastructure/dependency-injection/index.d.cts +4 -1
- package/dist/infrastructure/dependency-injection/index.d.ts +4 -1
- package/dist/infrastructure/dependency-injection/index.js +119 -3
- package/dist/infrastructure/dependency-injection/index.js.map +1 -1
- package/dist/infrastructure/express/index.cjs +279 -11
- package/dist/infrastructure/express/index.cjs.map +1 -1
- package/dist/infrastructure/express/index.d.cts +7 -8
- package/dist/infrastructure/express/index.d.ts +7 -8
- package/dist/infrastructure/express/index.js +270 -11
- package/dist/infrastructure/express/index.js.map +1 -1
- package/dist/infrastructure/scheduler/index.cjs +136 -9
- package/dist/infrastructure/scheduler/index.cjs.map +1 -1
- package/dist/infrastructure/scheduler/index.d.cts +2 -2
- package/dist/infrastructure/scheduler/index.d.ts +2 -2
- package/dist/infrastructure/scheduler/index.js +136 -9
- package/dist/infrastructure/scheduler/index.js.map +1 -1
- package/package.json +101 -11
- package/dist/Consumer-CC8ZRCsd.d.cts +0 -17
- package/dist/Consumer-CeT0Wbxb.d.ts +0 -17
- package/dist/DomainEventConsumer-3WBMSSr2.d.cts +0 -7
- package/dist/DomainEventConsumer-B4hkIUmP.d.ts +0 -7
- package/dist/DomainEventPublisher-8G0lvmdy.d.cts +0 -7
- package/dist/DomainEventPublisher-DhGgM3f2.d.ts +0 -7
- package/dist/ServiceClass-BmNw8fJj.d.cts +0 -37
- package/dist/ServiceClass-C7NCKdSS.d.ts +0 -37
- package/dist/ShutdownHook-BGskq2-q.d.ts +0 -9
- package/dist/ShutdownHook-Dib5uNKB.d.cts +0 -9
- package/dist/Subscription-Bwkb_did.d.ts +0 -9
- package/dist/Subscription-P9WROD_6.d.cts +0 -9
package/README.md
CHANGED
|
@@ -1,142 +1,71 @@
|
|
|
1
|
+
# @haskou/ddd-kernel
|
|
1
2
|
|
|
2
3
|
[](https://github.com/haskou/ddd-kernel/actions/workflows/ci.yml)
|
|
3
4
|
[](https://codecov.io/gh/haskou/ddd-kernel)
|
|
4
5
|
[](https://www.npmjs.com/package/@haskou/ddd-kernel)
|
|
5
6
|
[](LICENSE)
|
|
6
|
-
|
|
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
|
|
7
|
+
[](https://renovatebot.com)
|
|
12
8
|
|
|
13
9
|
Framework-agnostic DDD kernel for TypeScript applications and microservices.
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
are
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
```
|
|
42
|
-
|
|
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.
|
|
11
|
+
`@haskou/ddd-kernel` provides the runtime foundation shared by services that
|
|
12
|
+
are built around aggregates, domain events, consumers, schedulers and explicit
|
|
13
|
+
composition roots. The package keeps application bootstrapping consistent while
|
|
14
|
+
leaving transport, persistence and logging choices behind replaceable adapters.
|
|
46
15
|
|
|
47
|
-
##
|
|
16
|
+
## Scope
|
|
48
17
|
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
```
|
|
18
|
+
The core package is responsible for application lifecycle and dependency
|
|
19
|
+
composition. It includes contracts and primitives for:
|
|
55
20
|
|
|
56
|
-
|
|
21
|
+
- dependency injection and service resolution
|
|
22
|
+
- startup and graceful shutdown hooks
|
|
23
|
+
- consumers and consumer middleware
|
|
24
|
+
- schedulers and scheduler error policies
|
|
25
|
+
- runtimes
|
|
26
|
+
- domain events and aggregate roots
|
|
27
|
+
- repositories and pub/sub contracts
|
|
28
|
+
- logging contracts
|
|
57
29
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
import { InMemoryPubSub } from '@haskou/ddd-kernel/adapters/pubsub/in-memory';
|
|
62
|
-
import { ExpressKernelServer } from '@haskou/ddd-kernel/adapters/ui/express';
|
|
63
|
-
```
|
|
30
|
+
The kernel does not own HTTP, AMQP, MongoDB, WebSocket or logger implementation
|
|
31
|
+
details. Those integrations are exposed as optional adapters, so applications
|
|
32
|
+
only depend on the infrastructure they actually use.
|
|
64
33
|
|
|
65
|
-
|
|
34
|
+
## Architecture
|
|
66
35
|
|
|
67
|
-
|
|
68
|
-
import type { Repository, UnitOfWork } from '@haskou/ddd-kernel/contracts/db';
|
|
69
|
-
import type { Consumer, PubSub } from '@haskou/ddd-kernel/contracts/pubsub';
|
|
70
|
-
```
|
|
36
|
+
The package separates stable contracts from concrete infrastructure:
|
|
71
37
|
|
|
72
|
-
|
|
38
|
+
- `@haskou/ddd-kernel` contains the kernel, lifecycle, DI integration and domain
|
|
39
|
+
primitives.
|
|
40
|
+
- `@haskou/ddd-kernel/adapters/*` contains optional adapter entrypoints.
|
|
41
|
+
- Applications register their own consumers, schedulers, runtimes and adapters
|
|
42
|
+
at the composition root.
|
|
73
43
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
```
|
|
44
|
+
Constructor injection is the preferred application pattern. Direct service
|
|
45
|
+
lookup remains available for compatibility and integration boundaries, but it is
|
|
46
|
+
not the primary dependency model.
|
|
78
47
|
|
|
79
|
-
##
|
|
80
|
-
|
|
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
|
|
48
|
+
## Documentation
|
|
116
49
|
|
|
117
|
-
|
|
118
|
-
package through `file:..`.
|
|
50
|
+
Usage guides, adapter authoring notes and API reference pages are published at:
|
|
119
51
|
|
|
120
|
-
|
|
121
|
-
cd example
|
|
122
|
-
yarn install
|
|
123
|
-
yarn typecheck
|
|
124
|
-
yarn build
|
|
125
|
-
```
|
|
52
|
+
https://haskou.github.io/ddd-kernel/
|
|
126
53
|
|
|
127
|
-
|
|
54
|
+
The README is intentionally limited to project orientation. Installation,
|
|
55
|
+
startup, DI, AMQP, routes and adapter examples live in the documentation site.
|
|
128
56
|
|
|
129
|
-
|
|
57
|
+
## Release Branches
|
|
130
58
|
|
|
131
|
-
|
|
59
|
+
CI publishes npm versions from pull requests merged into the default branch
|
|
60
|
+
according to the source branch prefix:
|
|
132
61
|
|
|
133
|
-
|
|
62
|
+
| Branch prefix | npm version bump |
|
|
63
|
+
| ------------- | ---------------- |
|
|
64
|
+
| `fix/*` | Patch |
|
|
65
|
+
| `feat/*` | Minor |
|
|
66
|
+
| `break/*` | Major |
|
|
134
67
|
|
|
135
|
-
|
|
136
|
-
yarn lint
|
|
137
|
-
yarn typecheck
|
|
138
|
-
yarn build
|
|
139
|
-
```
|
|
68
|
+
Other branch names run validation only and do not publish.
|
|
140
69
|
|
|
141
70
|
## License
|
|
142
71
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { D as DomainEvent } from './DomainEvent-mXWEtr_J.cjs';
|
|
2
|
+
|
|
3
|
+
interface DomainEventConsumerContext {
|
|
4
|
+
readonly metadata: Readonly<Record<string, unknown>>;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
declare abstract class DomainEventConsumer {
|
|
8
|
+
abstract consume(queueName: string, bindingKey: string, domainEvent: typeof DomainEvent, exchange: string, handler: (event: DomainEvent, context?: DomainEventConsumerContext) => Promise<void>): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { DomainEventConsumer as D, type DomainEventConsumerContext as a };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { D as DomainEvent } from './DomainEvent-mXWEtr_J.js';
|
|
2
|
+
|
|
3
|
+
interface DomainEventConsumerContext {
|
|
4
|
+
readonly metadata: Readonly<Record<string, unknown>>;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
declare abstract class DomainEventConsumer {
|
|
8
|
+
abstract consume(queueName: string, bindingKey: string, domainEvent: typeof DomainEvent, exchange: string, handler: (event: DomainEvent, context?: DomainEventConsumerContext) => Promise<void>): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { DomainEventConsumer as D, type DomainEventConsumerContext as a };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { M as MessageBus } from './MessageBus-oQ9BnW84.js';
|
|
2
|
+
import { D as DomainEventConsumer } from './DomainEventConsumer-BroJmVty.js';
|
|
3
|
+
import { D as DomainEvent } from './DomainEvent-mXWEtr_J.js';
|
|
4
|
+
|
|
5
|
+
declare abstract class DomainEventPublisher {
|
|
6
|
+
abstract publish(domainEvents: DomainEvent[]): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface DomainMessageBus extends DomainEventConsumer, DomainEventPublisher {
|
|
10
|
+
registerPublisherHooks: MessageBus['registerPublisherHooks'];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { DomainEventPublisher as D, type DomainMessageBus as a };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { M as MessageBus } from './MessageBus-BtUXnd0Y.cjs';
|
|
2
|
+
import { D as DomainEventConsumer } from './DomainEventConsumer-Bg-bOwmh.cjs';
|
|
3
|
+
import { D as DomainEvent } from './DomainEvent-mXWEtr_J.cjs';
|
|
4
|
+
|
|
5
|
+
declare abstract class DomainEventPublisher {
|
|
6
|
+
abstract publish(domainEvents: DomainEvent[]): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface DomainMessageBus extends DomainEventConsumer, DomainEventPublisher {
|
|
10
|
+
registerPublisherHooks: MessageBus['registerPublisherHooks'];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { DomainEventPublisher as D, type DomainMessageBus as a };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { M as Message } from './HandlerContext-Lm89pSeG.cjs';
|
|
2
|
+
import { a as PublisherHook, M as MessageHandler, S as Subscription } from './Subscription-4vuAAxax.cjs';
|
|
3
|
+
|
|
4
|
+
interface MessageBus {
|
|
5
|
+
publish<TMessage extends Message>(topic: string, message: TMessage): Promise<void>;
|
|
6
|
+
registerPublisherHooks(...hooks: PublisherHook[]): void;
|
|
7
|
+
subscribe<TMessage extends Message>(topic: string, consumer: MessageHandler<TMessage, void>): Promise<Subscription>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type { MessageBus as M };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { M as Message } from './HandlerContext-DUUExVo3.js';
|
|
2
|
+
import { a as PublisherHook, M as MessageHandler, S as Subscription } from './Subscription-vtF0lEHP.js';
|
|
3
|
+
|
|
4
|
+
interface MessageBus {
|
|
5
|
+
publish<TMessage extends Message>(topic: string, message: TMessage): Promise<void>;
|
|
6
|
+
registerPublisherHooks(...hooks: PublisherHook[]): void;
|
|
7
|
+
subscribe<TMessage extends Message>(topic: string, consumer: MessageHandler<TMessage, void>): Promise<Subscription>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type { MessageBus as M };
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { a as PublisherHook } from './Subscription-vtF0lEHP.js';
|
|
1
2
|
import { L as Log } from './Log-36L3Z84a.js';
|
|
3
|
+
import { P as PublisherHookErrorPolicy } from './PublisherHookErrorPolicy-DSsCNE6O.js';
|
|
2
4
|
import { Channel } from 'amqplib';
|
|
3
5
|
import { D as DomainEvent } from './DomainEvent-mXWEtr_J.js';
|
|
4
6
|
import { C as Constructor } from './Constructor-fyZLLIh8.js';
|
|
7
|
+
import { a as DomainEventConsumerContext } from './DomainEventConsumer-BroJmVty.js';
|
|
5
8
|
|
|
6
9
|
type AmqpMessage = {
|
|
7
10
|
readonly aggregate_id: string;
|
|
@@ -20,11 +23,13 @@ interface AmqpMessageBusAdapterOptions {
|
|
|
20
23
|
readonly exchange?: string;
|
|
21
24
|
readonly logger?: Log;
|
|
22
25
|
readonly maxRetries?: number;
|
|
26
|
+
readonly publisherHookErrorPolicy?: PublisherHookErrorPolicy;
|
|
27
|
+
readonly publisherHooks?: PublisherHook[];
|
|
23
28
|
readonly retryDelayInMilliseconds?: number;
|
|
24
29
|
readonly serviceName?: string;
|
|
25
30
|
}
|
|
26
31
|
|
|
27
|
-
type DomainEventHandler = (event: DomainEvent) => Promise<void>;
|
|
32
|
+
type DomainEventHandler = (event: DomainEvent, context?: DomainEventConsumerContext) => Promise<void>;
|
|
28
33
|
|
|
29
34
|
type ConsumerContext = {
|
|
30
35
|
readonly bindingKey: string;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { a as PublisherHook } from './Subscription-4vuAAxax.cjs';
|
|
1
2
|
import { L as Log } from './Log-36L3Z84a.cjs';
|
|
3
|
+
import { P as PublisherHookErrorPolicy } from './PublisherHookErrorPolicy-CjouTcSR.cjs';
|
|
2
4
|
import { Channel } from 'amqplib';
|
|
3
5
|
import { D as DomainEvent } from './DomainEvent-mXWEtr_J.cjs';
|
|
4
6
|
import { C as Constructor } from './Constructor-fyZLLIh8.cjs';
|
|
7
|
+
import { a as DomainEventConsumerContext } from './DomainEventConsumer-Bg-bOwmh.cjs';
|
|
5
8
|
|
|
6
9
|
type AmqpMessage = {
|
|
7
10
|
readonly aggregate_id: string;
|
|
@@ -20,11 +23,13 @@ interface AmqpMessageBusAdapterOptions {
|
|
|
20
23
|
readonly exchange?: string;
|
|
21
24
|
readonly logger?: Log;
|
|
22
25
|
readonly maxRetries?: number;
|
|
26
|
+
readonly publisherHookErrorPolicy?: PublisherHookErrorPolicy;
|
|
27
|
+
readonly publisherHooks?: PublisherHook[];
|
|
23
28
|
readonly retryDelayInMilliseconds?: number;
|
|
24
29
|
readonly serviceName?: string;
|
|
25
30
|
}
|
|
26
31
|
|
|
27
|
-
type DomainEventHandler = (event: DomainEvent) => Promise<void>;
|
|
32
|
+
type DomainEventHandler = (event: DomainEvent, context?: DomainEventConsumerContext) => Promise<void>;
|
|
28
33
|
|
|
29
34
|
type ConsumerContext = {
|
|
30
35
|
readonly bindingKey: string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { P as PublishContext } from './Subscription-4vuAAxax.cjs';
|
|
2
|
+
|
|
3
|
+
interface PublisherHookErrorPolicy {
|
|
4
|
+
handleAfterPublishError(error: unknown, context: PublishContext): Promise<void> | void;
|
|
5
|
+
shouldFailAfterPublish(error: unknown, context: PublishContext): boolean;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type { PublisherHookErrorPolicy as P };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { P as PublishContext } from './Subscription-vtF0lEHP.js';
|
|
2
|
+
|
|
3
|
+
interface PublisherHookErrorPolicy {
|
|
4
|
+
handleAfterPublishError(error: unknown, context: PublishContext): Promise<void> | void;
|
|
5
|
+
shouldFailAfterPublish(error: unknown, context: PublishContext): boolean;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type { PublisherHookErrorPolicy as P };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { a as ConsumerExecutionContext } from './ShutdownHook-CMWLsfu-.js';
|
|
2
|
+
|
|
3
|
+
interface IdempotencyStore {
|
|
4
|
+
claim?(key: string): Promise<boolean> | boolean;
|
|
5
|
+
commit?(key: string): Promise<void> | void;
|
|
6
|
+
release?(key: string): Promise<void> | void;
|
|
7
|
+
has(key: string): Promise<boolean> | boolean;
|
|
8
|
+
mark(key: string): Promise<void> | void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type RetryDelayResolver = (attempt: number, error: unknown, context: ConsumerExecutionContext) => number | Promise<number>;
|
|
12
|
+
|
|
13
|
+
type RetryPredicate = (error: unknown, attempt: number, context: ConsumerExecutionContext) => boolean | Promise<boolean>;
|
|
14
|
+
|
|
15
|
+
export type { IdempotencyStore as I, RetryDelayResolver as R, RetryPredicate as a };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { a as ConsumerExecutionContext } from './ShutdownHook-BjbnCKzr.cjs';
|
|
2
|
+
|
|
3
|
+
interface IdempotencyStore {
|
|
4
|
+
claim?(key: string): Promise<boolean> | boolean;
|
|
5
|
+
commit?(key: string): Promise<void> | void;
|
|
6
|
+
release?(key: string): Promise<void> | void;
|
|
7
|
+
has(key: string): Promise<boolean> | boolean;
|
|
8
|
+
mark(key: string): Promise<void> | void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type RetryDelayResolver = (attempt: number, error: unknown, context: ConsumerExecutionContext) => number | Promise<number>;
|
|
12
|
+
|
|
13
|
+
type RetryPredicate = (error: unknown, attempt: number, context: ConsumerExecutionContext) => boolean | Promise<boolean>;
|
|
14
|
+
|
|
15
|
+
export type { IdempotencyStore as I, RetryDelayResolver as R, RetryPredicate as a };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { S as ServiceResolver } from './ServiceResolver-D2Jz-l_Z.cjs';
|
|
2
|
+
|
|
3
|
+
type DependencyOverrideToken = unknown;
|
|
4
|
+
|
|
5
|
+
interface ClassDependencyOverride {
|
|
6
|
+
readonly token: DependencyOverrideToken;
|
|
7
|
+
readonly useClass: new (...args: never[]) => unknown;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type DependencyOverrideFactory = (resolver: ServiceResolver) => unknown;
|
|
11
|
+
|
|
12
|
+
interface FactoryDependencyOverride {
|
|
13
|
+
readonly token: DependencyOverrideToken;
|
|
14
|
+
readonly useFactory: DependencyOverrideFactory;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface ValueDependencyOverride {
|
|
18
|
+
readonly token: DependencyOverrideToken;
|
|
19
|
+
readonly useValue: unknown;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type DependencyOverride = ClassDependencyOverride | FactoryDependencyOverride | ValueDependencyOverride;
|
|
23
|
+
|
|
24
|
+
interface DependencyInjectionOptions {
|
|
25
|
+
readonly containerBuild?: boolean;
|
|
26
|
+
readonly overrides?: readonly DependencyOverride[];
|
|
27
|
+
readonly servicesYamlPath: string;
|
|
28
|
+
readonly sourceDirectory: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare class DependencyInjection implements ServiceResolver {
|
|
32
|
+
private readonly options;
|
|
33
|
+
private static configuredInstance;
|
|
34
|
+
private autowire;
|
|
35
|
+
private loader;
|
|
36
|
+
private readonly container;
|
|
37
|
+
private readonly overrideTokenIds;
|
|
38
|
+
static configure(options: DependencyInjectionOptions): DependencyInjection;
|
|
39
|
+
static get instance(): DependencyInjection;
|
|
40
|
+
constructor(options?: DependencyInjectionOptions);
|
|
41
|
+
private get definitions();
|
|
42
|
+
private get aliases();
|
|
43
|
+
private ensureFolderExists;
|
|
44
|
+
private getServiceClassName;
|
|
45
|
+
private getOverrideId;
|
|
46
|
+
private ensureSyntheticService;
|
|
47
|
+
private parentMatchesService;
|
|
48
|
+
private serviceIdMatchesService;
|
|
49
|
+
private serviceIdReferencesService;
|
|
50
|
+
private getReferenceId;
|
|
51
|
+
private getDefinitionArgumentReferences;
|
|
52
|
+
private findConcreteChildServiceId;
|
|
53
|
+
private findRegisteredServiceId;
|
|
54
|
+
private findAliasServiceId;
|
|
55
|
+
private findReferencedServiceIds;
|
|
56
|
+
private getOverrideTokenIds;
|
|
57
|
+
private getOverrideClassServiceId;
|
|
58
|
+
private applyClassOverride;
|
|
59
|
+
private applyFactoryOverride;
|
|
60
|
+
private applyValueOverride;
|
|
61
|
+
private applyOverrides;
|
|
62
|
+
private registerParentAliases;
|
|
63
|
+
compile(): Promise<void>;
|
|
64
|
+
getService<T>(serviceName: unknown): T;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
type ServiceClass<T> = {
|
|
68
|
+
readonly prototype: T;
|
|
69
|
+
new (...args: never[]): T;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export { type ClassDependencyOverride as C, DependencyInjection as D, type FactoryDependencyOverride as F, type ServiceClass as S, type ValueDependencyOverride as V, type DependencyInjectionOptions as a, type DependencyOverride as b, type DependencyOverrideFactory as c, type DependencyOverrideToken as d };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { S as ServiceResolver } from './ServiceResolver-D2Jz-l_Z.js';
|
|
2
|
+
|
|
3
|
+
type DependencyOverrideToken = unknown;
|
|
4
|
+
|
|
5
|
+
interface ClassDependencyOverride {
|
|
6
|
+
readonly token: DependencyOverrideToken;
|
|
7
|
+
readonly useClass: new (...args: never[]) => unknown;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type DependencyOverrideFactory = (resolver: ServiceResolver) => unknown;
|
|
11
|
+
|
|
12
|
+
interface FactoryDependencyOverride {
|
|
13
|
+
readonly token: DependencyOverrideToken;
|
|
14
|
+
readonly useFactory: DependencyOverrideFactory;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface ValueDependencyOverride {
|
|
18
|
+
readonly token: DependencyOverrideToken;
|
|
19
|
+
readonly useValue: unknown;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type DependencyOverride = ClassDependencyOverride | FactoryDependencyOverride | ValueDependencyOverride;
|
|
23
|
+
|
|
24
|
+
interface DependencyInjectionOptions {
|
|
25
|
+
readonly containerBuild?: boolean;
|
|
26
|
+
readonly overrides?: readonly DependencyOverride[];
|
|
27
|
+
readonly servicesYamlPath: string;
|
|
28
|
+
readonly sourceDirectory: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare class DependencyInjection implements ServiceResolver {
|
|
32
|
+
private readonly options;
|
|
33
|
+
private static configuredInstance;
|
|
34
|
+
private autowire;
|
|
35
|
+
private loader;
|
|
36
|
+
private readonly container;
|
|
37
|
+
private readonly overrideTokenIds;
|
|
38
|
+
static configure(options: DependencyInjectionOptions): DependencyInjection;
|
|
39
|
+
static get instance(): DependencyInjection;
|
|
40
|
+
constructor(options?: DependencyInjectionOptions);
|
|
41
|
+
private get definitions();
|
|
42
|
+
private get aliases();
|
|
43
|
+
private ensureFolderExists;
|
|
44
|
+
private getServiceClassName;
|
|
45
|
+
private getOverrideId;
|
|
46
|
+
private ensureSyntheticService;
|
|
47
|
+
private parentMatchesService;
|
|
48
|
+
private serviceIdMatchesService;
|
|
49
|
+
private serviceIdReferencesService;
|
|
50
|
+
private getReferenceId;
|
|
51
|
+
private getDefinitionArgumentReferences;
|
|
52
|
+
private findConcreteChildServiceId;
|
|
53
|
+
private findRegisteredServiceId;
|
|
54
|
+
private findAliasServiceId;
|
|
55
|
+
private findReferencedServiceIds;
|
|
56
|
+
private getOverrideTokenIds;
|
|
57
|
+
private getOverrideClassServiceId;
|
|
58
|
+
private applyClassOverride;
|
|
59
|
+
private applyFactoryOverride;
|
|
60
|
+
private applyValueOverride;
|
|
61
|
+
private applyOverrides;
|
|
62
|
+
private registerParentAliases;
|
|
63
|
+
compile(): Promise<void>;
|
|
64
|
+
getService<T>(serviceName: unknown): T;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
type ServiceClass<T> = {
|
|
68
|
+
readonly prototype: T;
|
|
69
|
+
new (...args: never[]): T;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export { type ClassDependencyOverride as C, DependencyInjection as D, type FactoryDependencyOverride as F, type ServiceClass as S, type ValueDependencyOverride as V, type DependencyInjectionOptions as a, type DependencyOverride as b, type DependencyOverrideFactory as c, type DependencyOverrideToken as d };
|
|
@@ -1,10 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { K as KernelLogger } from './KernelLogger-BESOFrpW.cjs';
|
|
1
|
+
import { D as DomainEvent } from './DomainEvent-mXWEtr_J.cjs';
|
|
2
|
+
import { D as DomainEventConsumer } from './DomainEventConsumer-Bg-bOwmh.cjs';
|
|
4
3
|
import { Route } from './adapters/ui/routes/index.cjs';
|
|
5
|
-
import { D as DependencyInjection, S as ServiceClass } from './ServiceClass-
|
|
4
|
+
import { b as DependencyOverride, D as DependencyInjection, S as ServiceClass } from './ServiceClass-BkEHcXDi.cjs';
|
|
6
5
|
import { Initializer, Runtime } from './infrastructure/lifecycle/index.cjs';
|
|
7
|
-
import {
|
|
6
|
+
import { a as Scheduler } from './Scheduler-BW-U5Ccg.cjs';
|
|
7
|
+
import { K as KernelLogger } from './KernelLogger-BESOFrpW.cjs';
|
|
8
|
+
|
|
9
|
+
declare abstract class Consumer {
|
|
10
|
+
private readonly consumer;
|
|
11
|
+
constructor(consumer: DomainEventConsumer);
|
|
12
|
+
private runMiddleware;
|
|
13
|
+
abstract get domainEvent(): typeof DomainEvent;
|
|
14
|
+
abstract get eventName(): string;
|
|
15
|
+
abstract get exchange(): string;
|
|
16
|
+
abstract get queueName(): string;
|
|
17
|
+
abstract handler(event: DomainEvent): Promise<void>;
|
|
18
|
+
init(): Promise<void>;
|
|
19
|
+
get<T>(service: unknown): T;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface KernelDependencyInjectionOptions {
|
|
23
|
+
readonly containerBuild?: boolean;
|
|
24
|
+
readonly overrides?: readonly DependencyOverride[];
|
|
25
|
+
readonly servicesYamlPath?: string;
|
|
26
|
+
readonly sourceDirectory?: string;
|
|
27
|
+
}
|
|
8
28
|
|
|
9
29
|
interface KernelOptions {
|
|
10
30
|
readonly di?: DependencyInjection;
|
|
@@ -29,6 +49,7 @@ declare class Kernel {
|
|
|
29
49
|
static get consumerMiddleware(): ConsumerMiddleware[];
|
|
30
50
|
static get di(): DependencyInjection;
|
|
31
51
|
static get logger(): KernelLogger;
|
|
52
|
+
static get active(): Kernel;
|
|
32
53
|
static get rootDirectory(): string;
|
|
33
54
|
static get routes(): ServiceClass<Route>[];
|
|
34
55
|
static get schedulers(): Scheduler[];
|
|
@@ -46,7 +67,8 @@ declare class Kernel {
|
|
|
46
67
|
get logger(): KernelLogger;
|
|
47
68
|
get routes(): ServiceClass<Route>[];
|
|
48
69
|
get schedulers(): Scheduler[];
|
|
49
|
-
|
|
70
|
+
private getDependencyInjectionOptions;
|
|
71
|
+
dependencyInjection(options?: KernelDependencyInjectionOptions): Promise<void>;
|
|
50
72
|
getRoutes(): ServiceClass<Route>[];
|
|
51
73
|
registerConsumerMiddleware(...middlewares: ConsumerMiddleware[]): void;
|
|
52
74
|
registerConsumers(...ClassDefinitions: ServiceClass<Consumer>[]): void;
|
|
@@ -67,4 +89,24 @@ declare class Kernel {
|
|
|
67
89
|
}
|
|
68
90
|
declare function createKernel(options?: KernelOptions): Kernel;
|
|
69
91
|
|
|
70
|
-
|
|
92
|
+
interface ConsumerExecutionContext {
|
|
93
|
+
readonly causationId?: string;
|
|
94
|
+
readonly correlationId?: string;
|
|
95
|
+
readonly eventId: string;
|
|
96
|
+
readonly eventName: string;
|
|
97
|
+
readonly exchange: string;
|
|
98
|
+
readonly kernel: Kernel;
|
|
99
|
+
readonly metadata: Readonly<Record<string, unknown>>;
|
|
100
|
+
readonly rawMessage?: unknown;
|
|
101
|
+
readonly queueName: string;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
type ConsumerNext = () => Promise<void>;
|
|
105
|
+
|
|
106
|
+
interface ConsumerMiddleware {
|
|
107
|
+
handle(event: DomainEvent, next: ConsumerNext, context: ConsumerExecutionContext): Promise<void>;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
type ShutdownHook = () => Promise<void> | void;
|
|
111
|
+
|
|
112
|
+
export { Consumer as C, Kernel as K, type ShutdownHook as S, type ConsumerExecutionContext as a, type ConsumerMiddleware as b, type ConsumerNext as c, type KernelDependencyInjectionOptions as d, type KernelOptions as e, createKernel as f };
|