@haskou/ddd-kernel 0.1.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.
Files changed (191) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +143 -0
  3. package/dist/Constructor-fyZLLIh8.d.cts +5 -0
  4. package/dist/Constructor-fyZLLIh8.d.ts +5 -0
  5. package/dist/Consumer-CC8ZRCsd.d.cts +17 -0
  6. package/dist/Consumer-CeT0Wbxb.d.ts +17 -0
  7. package/dist/DomainEvent-mXWEtr_J.d.cts +26 -0
  8. package/dist/DomainEvent-mXWEtr_J.d.ts +26 -0
  9. package/dist/DomainEventConsumer-3WBMSSr2.d.cts +7 -0
  10. package/dist/DomainEventConsumer-B4hkIUmP.d.ts +7 -0
  11. package/dist/DomainEventPublisher-8G0lvmdy.d.cts +7 -0
  12. package/dist/DomainEventPublisher-DhGgM3f2.d.ts +7 -0
  13. package/dist/HandlerContext-DUUExVo3.d.ts +20 -0
  14. package/dist/HandlerContext-Lm89pSeG.d.cts +20 -0
  15. package/dist/Kernel-BWUOUWWI.d.cts +70 -0
  16. package/dist/Kernel-CUaqHa1s.d.ts +70 -0
  17. package/dist/KernelLogger-BESOFrpW.d.cts +8 -0
  18. package/dist/KernelLogger-BESOFrpW.d.ts +8 -0
  19. package/dist/Log-36L3Z84a.d.cts +8 -0
  20. package/dist/Log-36L3Z84a.d.ts +8 -0
  21. package/dist/NoFailedMessagesError-0YJKRWPF.d.ts +45 -0
  22. package/dist/NoFailedMessagesError-Kz7CYWpT.d.cts +45 -0
  23. package/dist/Repository-D9CuAyCV.d.cts +7 -0
  24. package/dist/Repository-D9CuAyCV.d.ts +7 -0
  25. package/dist/Scheduler-oigqNOUJ.d.cts +27 -0
  26. package/dist/Scheduler-oigqNOUJ.d.ts +27 -0
  27. package/dist/ServiceClass-BmNw8fJj.d.cts +37 -0
  28. package/dist/ServiceClass-C7NCKdSS.d.ts +37 -0
  29. package/dist/ServiceResolver-D2Jz-l_Z.d.cts +5 -0
  30. package/dist/ServiceResolver-D2Jz-l_Z.d.ts +5 -0
  31. package/dist/ShutdownHook-BGskq2-q.d.ts +9 -0
  32. package/dist/ShutdownHook-Dib5uNKB.d.cts +9 -0
  33. package/dist/Subscription-Bwkb_did.d.ts +9 -0
  34. package/dist/Subscription-P9WROD_6.d.cts +9 -0
  35. package/dist/adapters/db/in-memory/index.cjs +46 -0
  36. package/dist/adapters/db/in-memory/index.cjs.map +1 -0
  37. package/dist/adapters/db/in-memory/index.d.cts +12 -0
  38. package/dist/adapters/db/in-memory/index.d.ts +12 -0
  39. package/dist/adapters/db/in-memory/index.js +19 -0
  40. package/dist/adapters/db/in-memory/index.js.map +1 -0
  41. package/dist/adapters/db/index.cjs +80 -0
  42. package/dist/adapters/db/index.cjs.map +1 -0
  43. package/dist/adapters/db/index.d.cts +4 -0
  44. package/dist/adapters/db/index.d.ts +4 -0
  45. package/dist/adapters/db/index.js +52 -0
  46. package/dist/adapters/db/index.js.map +1 -0
  47. package/dist/adapters/db/mongo/index.cjs +62 -0
  48. package/dist/adapters/db/mongo/index.cjs.map +1 -0
  49. package/dist/adapters/db/mongo/index.d.cts +22 -0
  50. package/dist/adapters/db/mongo/index.d.ts +22 -0
  51. package/dist/adapters/db/mongo/index.js +35 -0
  52. package/dist/adapters/db/mongo/index.js.map +1 -0
  53. package/dist/adapters/index.cjs +651 -0
  54. package/dist/adapters/index.cjs.map +1 -0
  55. package/dist/adapters/index.d.cts +26 -0
  56. package/dist/adapters/index.d.ts +26 -0
  57. package/dist/adapters/index.js +609 -0
  58. package/dist/adapters/index.js.map +1 -0
  59. package/dist/adapters/kernel/console/index.cjs +46 -0
  60. package/dist/adapters/kernel/console/index.cjs.map +1 -0
  61. package/dist/adapters/kernel/console/index.d.cts +10 -0
  62. package/dist/adapters/kernel/console/index.d.ts +10 -0
  63. package/dist/adapters/kernel/console/index.js +19 -0
  64. package/dist/adapters/kernel/console/index.js.map +1 -0
  65. package/dist/adapters/kernel/index.cjs +46 -0
  66. package/dist/adapters/kernel/index.cjs.map +1 -0
  67. package/dist/adapters/kernel/index.d.cts +2 -0
  68. package/dist/adapters/kernel/index.d.ts +2 -0
  69. package/dist/adapters/kernel/index.js +19 -0
  70. package/dist/adapters/kernel/index.js.map +1 -0
  71. package/dist/adapters/pubsub/amqp/index.cjs +724 -0
  72. package/dist/adapters/pubsub/amqp/index.cjs.map +1 -0
  73. package/dist/adapters/pubsub/amqp/index.d.cts +42 -0
  74. package/dist/adapters/pubsub/amqp/index.d.ts +42 -0
  75. package/dist/adapters/pubsub/amqp/index.js +691 -0
  76. package/dist/adapters/pubsub/amqp/index.js.map +1 -0
  77. package/dist/adapters/pubsub/in-memory/index.cjs +79 -0
  78. package/dist/adapters/pubsub/in-memory/index.cjs.map +1 -0
  79. package/dist/adapters/pubsub/in-memory/index.d.cts +21 -0
  80. package/dist/adapters/pubsub/in-memory/index.d.ts +21 -0
  81. package/dist/adapters/pubsub/in-memory/index.js +51 -0
  82. package/dist/adapters/pubsub/in-memory/index.js.map +1 -0
  83. package/dist/adapters/pubsub/index.cjs +492 -0
  84. package/dist/adapters/pubsub/index.cjs.map +1 -0
  85. package/dist/adapters/pubsub/index.d.cts +11 -0
  86. package/dist/adapters/pubsub/index.d.ts +11 -0
  87. package/dist/adapters/pubsub/index.js +456 -0
  88. package/dist/adapters/pubsub/index.js.map +1 -0
  89. package/dist/adapters/ui/express/index.cjs +126 -0
  90. package/dist/adapters/ui/express/index.cjs.map +1 -0
  91. package/dist/adapters/ui/express/index.d.cts +49 -0
  92. package/dist/adapters/ui/express/index.d.ts +49 -0
  93. package/dist/adapters/ui/express/index.js +98 -0
  94. package/dist/adapters/ui/express/index.js.map +1 -0
  95. package/dist/adapters/ui/index.cjs +489 -0
  96. package/dist/adapters/ui/index.cjs.map +1 -0
  97. package/dist/adapters/ui/index.d.cts +14 -0
  98. package/dist/adapters/ui/index.d.ts +14 -0
  99. package/dist/adapters/ui/index.js +455 -0
  100. package/dist/adapters/ui/index.js.map +1 -0
  101. package/dist/adapters/ui/routes/index.cjs +393 -0
  102. package/dist/adapters/ui/routes/index.cjs.map +1 -0
  103. package/dist/adapters/ui/routes/index.d.cts +5 -0
  104. package/dist/adapters/ui/routes/index.d.ts +5 -0
  105. package/dist/adapters/ui/routes/index.js +361 -0
  106. package/dist/adapters/ui/routes/index.js.map +1 -0
  107. package/dist/contracts/db/index.cjs +19 -0
  108. package/dist/contracts/db/index.cjs.map +1 -0
  109. package/dist/contracts/db/index.d.cts +7 -0
  110. package/dist/contracts/db/index.d.ts +7 -0
  111. package/dist/contracts/db/index.js +1 -0
  112. package/dist/contracts/db/index.js.map +1 -0
  113. package/dist/contracts/index.cjs +49 -0
  114. package/dist/contracts/index.cjs.map +1 -0
  115. package/dist/contracts/index.d.cts +11 -0
  116. package/dist/contracts/index.d.ts +11 -0
  117. package/dist/contracts/index.js +22 -0
  118. package/dist/contracts/index.js.map +1 -0
  119. package/dist/contracts/kernel/index.cjs +19 -0
  120. package/dist/contracts/kernel/index.cjs.map +1 -0
  121. package/dist/contracts/kernel/index.d.cts +9 -0
  122. package/dist/contracts/kernel/index.d.ts +9 -0
  123. package/dist/contracts/kernel/index.js +1 -0
  124. package/dist/contracts/kernel/index.js.map +1 -0
  125. package/dist/contracts/pubsub/index.cjs +19 -0
  126. package/dist/contracts/pubsub/index.cjs.map +1 -0
  127. package/dist/contracts/pubsub/index.d.cts +26 -0
  128. package/dist/contracts/pubsub/index.d.ts +26 -0
  129. package/dist/contracts/pubsub/index.js +1 -0
  130. package/dist/contracts/pubsub/index.js.map +1 -0
  131. package/dist/contracts/ui/index.cjs +49 -0
  132. package/dist/contracts/ui/index.cjs.map +1 -0
  133. package/dist/contracts/ui/index.d.cts +29 -0
  134. package/dist/contracts/ui/index.d.ts +29 -0
  135. package/dist/contracts/ui/index.js +22 -0
  136. package/dist/contracts/ui/index.js.map +1 -0
  137. package/dist/domain/index.cjs +121 -0
  138. package/dist/domain/index.cjs.map +1 -0
  139. package/dist/domain/index.d.cts +26 -0
  140. package/dist/domain/index.d.ts +26 -0
  141. package/dist/domain/index.js +89 -0
  142. package/dist/domain/index.js.map +1 -0
  143. package/dist/errors/index.cjs +58 -0
  144. package/dist/errors/index.cjs.map +1 -0
  145. package/dist/errors/index.d.cts +13 -0
  146. package/dist/errors/index.d.ts +13 -0
  147. package/dist/errors/index.js +29 -0
  148. package/dist/errors/index.js.map +1 -0
  149. package/dist/index.cjs +442 -0
  150. package/dist/index.cjs.map +1 -0
  151. package/dist/index.d.cts +19 -0
  152. package/dist/index.d.ts +19 -0
  153. package/dist/index.js +405 -0
  154. package/dist/index.js.map +1 -0
  155. package/dist/infrastructure/dependency-injection/index.cjs +169 -0
  156. package/dist/infrastructure/dependency-injection/index.cjs.map +1 -0
  157. package/dist/infrastructure/dependency-injection/index.d.cts +30 -0
  158. package/dist/infrastructure/dependency-injection/index.d.ts +30 -0
  159. package/dist/infrastructure/dependency-injection/index.js +137 -0
  160. package/dist/infrastructure/dependency-injection/index.js.map +1 -0
  161. package/dist/infrastructure/express/index.cjs +126 -0
  162. package/dist/infrastructure/express/index.cjs.map +1 -0
  163. package/dist/infrastructure/express/index.d.cts +14 -0
  164. package/dist/infrastructure/express/index.d.ts +14 -0
  165. package/dist/infrastructure/express/index.js +98 -0
  166. package/dist/infrastructure/express/index.js.map +1 -0
  167. package/dist/infrastructure/lifecycle/index.cjs +19 -0
  168. package/dist/infrastructure/lifecycle/index.cjs.map +1 -0
  169. package/dist/infrastructure/lifecycle/index.d.cts +9 -0
  170. package/dist/infrastructure/lifecycle/index.d.ts +9 -0
  171. package/dist/infrastructure/lifecycle/index.js +1 -0
  172. package/dist/infrastructure/lifecycle/index.js.map +1 -0
  173. package/dist/infrastructure/logs/index.cjs +144 -0
  174. package/dist/infrastructure/logs/index.cjs.map +1 -0
  175. package/dist/infrastructure/logs/index.d.cts +30 -0
  176. package/dist/infrastructure/logs/index.d.ts +30 -0
  177. package/dist/infrastructure/logs/index.js +107 -0
  178. package/dist/infrastructure/logs/index.js.map +1 -0
  179. package/dist/infrastructure/scheduler/index.cjs +461 -0
  180. package/dist/infrastructure/scheduler/index.cjs.map +1 -0
  181. package/dist/infrastructure/scheduler/index.d.cts +17 -0
  182. package/dist/infrastructure/scheduler/index.d.ts +17 -0
  183. package/dist/infrastructure/scheduler/index.js +426 -0
  184. package/dist/infrastructure/scheduler/index.js.map +1 -0
  185. package/dist/infrastructure/websocket/index.cjs +131 -0
  186. package/dist/infrastructure/websocket/index.cjs.map +1 -0
  187. package/dist/infrastructure/websocket/index.d.cts +56 -0
  188. package/dist/infrastructure/websocket/index.d.ts +56 -0
  189. package/dist/infrastructure/websocket/index.js +103 -0
  190. package/dist/infrastructure/websocket/index.js.map +1 -0
  191. package/package.json +248 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Haskou
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,143 @@
1
+
2
+ [![CI](https://github.com/haskou/ddd-kernel/actions/workflows/ci.yml/badge.svg)](https://github.com/haskou/ddd-kernel/actions/workflows/ci.yml)
3
+ [![codecov](https://codecov.io/gh/haskou/ddd-kernel/branch/main/graph/badge.svg)](https://codecov.io/gh/haskou/ddd-kernel)
4
+ [![npm](https://img.shields.io/npm/v/@haskou/ddd-kernel.svg)](https://www.npmjs.com/package/@haskou/ddd-kernel)
5
+ [![license](https://img.shields.io/npm/l/@haskou/ddd-kernel.svg)](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
12
+
13
+ Framework-agnostic DDD kernel for TypeScript applications and microservices.
14
+
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
+ ```
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.
46
+
47
+ ## Imports
48
+
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
+ ```
55
+
56
+ Optional adapters:
57
+
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
+ ```
64
+
65
+ Contracts:
66
+
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
+ ```
71
+
72
+ UI helpers:
73
+
74
+ ```ts
75
+ import Route from '@haskou/ddd-kernel/adapters/ui/routes';
76
+ import { HttpRouteStatusEnum } from '@haskou/ddd-kernel/contracts/ui';
77
+ ```
78
+
79
+ ## Dependency Injection
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
116
+
117
+ See `example/` for a small route/application/domain setup that imports the
118
+ package through `file:..`.
119
+
120
+ ```bash
121
+ cd example
122
+ yarn install
123
+ yarn typecheck
124
+ yarn build
125
+ ```
126
+
127
+ ## Documentation
128
+
129
+ Full documentation is available at **https://haskou.github.io/ddd-kernel/**
130
+
131
+ The documentation includes installation, quick start, examples, error handling, serialization notes, and one reference page per exported class.
132
+
133
+ ## Scripts
134
+
135
+ ```bash
136
+ yarn lint
137
+ yarn typecheck
138
+ yarn build
139
+ ```
140
+
141
+ ## License
142
+
143
+ MIT. See [LICENSE](LICENSE).
@@ -0,0 +1,5 @@
1
+ type Constructor<T> = {
2
+ new (...args: unknown[]): T;
3
+ };
4
+
5
+ export type { Constructor as C };
@@ -0,0 +1,5 @@
1
+ type Constructor<T> = {
2
+ new (...args: unknown[]): T;
3
+ };
4
+
5
+ export type { Constructor as C };
@@ -0,0 +1,17 @@
1
+ import { D as DomainEventConsumer } from './DomainEventConsumer-3WBMSSr2.cjs';
2
+ import { D as DomainEvent } from './DomainEvent-mXWEtr_J.cjs';
3
+
4
+ declare abstract class Consumer {
5
+ private readonly consumer;
6
+ constructor(consumer: DomainEventConsumer);
7
+ private runMiddleware;
8
+ abstract get domainEvent(): typeof DomainEvent;
9
+ abstract get eventName(): string;
10
+ abstract get exchange(): string;
11
+ abstract get queueName(): string;
12
+ abstract handler(event: DomainEvent): Promise<void>;
13
+ init(): Promise<void>;
14
+ get<T>(service: unknown): T;
15
+ }
16
+
17
+ export { Consumer as C };
@@ -0,0 +1,17 @@
1
+ import { D as DomainEventConsumer } from './DomainEventConsumer-B4hkIUmP.js';
2
+ import { D as DomainEvent } from './DomainEvent-mXWEtr_J.js';
3
+
4
+ declare abstract class Consumer {
5
+ private readonly consumer;
6
+ constructor(consumer: DomainEventConsumer);
7
+ private runMiddleware;
8
+ abstract get domainEvent(): typeof DomainEvent;
9
+ abstract get eventName(): string;
10
+ abstract get exchange(): string;
11
+ abstract get queueName(): string;
12
+ abstract handler(event: DomainEvent): Promise<void>;
13
+ init(): Promise<void>;
14
+ get<T>(service: unknown): T;
15
+ }
16
+
17
+ export { Consumer as C };
@@ -0,0 +1,26 @@
1
+ interface Event {
2
+ decode(): string;
3
+ encode(data: string): object;
4
+ eventName(): string;
5
+ }
6
+
7
+ type EventAttributes = Record<string, unknown>;
8
+
9
+ declare abstract class DomainEvent implements Event {
10
+ readonly aggregateId: string;
11
+ readonly attributes: EventAttributes;
12
+ readonly eventId: string;
13
+ readonly occurredOn: Date;
14
+ private causationId?;
15
+ private correlationId?;
16
+ constructor(aggregateId: string, attributes?: EventAttributes, eventId?: string, occurredOn?: Date, correlationId?: string, causationId?: string);
17
+ encode(data: string): object;
18
+ decode(): string;
19
+ getCorrelationId(): string | undefined;
20
+ getCausationId(): string | undefined;
21
+ withCorrelationId(correlationId: string): this;
22
+ withCausationId(causationId: string): this;
23
+ abstract eventName(): string;
24
+ }
25
+
26
+ export { DomainEvent as D, type Event as E, type EventAttributes as a };
@@ -0,0 +1,26 @@
1
+ interface Event {
2
+ decode(): string;
3
+ encode(data: string): object;
4
+ eventName(): string;
5
+ }
6
+
7
+ type EventAttributes = Record<string, unknown>;
8
+
9
+ declare abstract class DomainEvent implements Event {
10
+ readonly aggregateId: string;
11
+ readonly attributes: EventAttributes;
12
+ readonly eventId: string;
13
+ readonly occurredOn: Date;
14
+ private causationId?;
15
+ private correlationId?;
16
+ constructor(aggregateId: string, attributes?: EventAttributes, eventId?: string, occurredOn?: Date, correlationId?: string, causationId?: string);
17
+ encode(data: string): object;
18
+ decode(): string;
19
+ getCorrelationId(): string | undefined;
20
+ getCausationId(): string | undefined;
21
+ withCorrelationId(correlationId: string): this;
22
+ withCausationId(causationId: string): this;
23
+ abstract eventName(): string;
24
+ }
25
+
26
+ export { DomainEvent as D, type Event as E, type EventAttributes as a };
@@ -0,0 +1,7 @@
1
+ import { D as DomainEvent } from './DomainEvent-mXWEtr_J.cjs';
2
+
3
+ declare abstract class DomainEventConsumer {
4
+ abstract consume(queueName: string, bindingKey: string, domainEvent: typeof DomainEvent, exchange: string, handler: (event: DomainEvent) => Promise<void>): Promise<void>;
5
+ }
6
+
7
+ export { DomainEventConsumer as D };
@@ -0,0 +1,7 @@
1
+ import { D as DomainEvent } from './DomainEvent-mXWEtr_J.js';
2
+
3
+ declare abstract class DomainEventConsumer {
4
+ abstract consume(queueName: string, bindingKey: string, domainEvent: typeof DomainEvent, exchange: string, handler: (event: DomainEvent) => Promise<void>): Promise<void>;
5
+ }
6
+
7
+ export { DomainEventConsumer as D };
@@ -0,0 +1,7 @@
1
+ import { D as DomainEvent } from './DomainEvent-mXWEtr_J.cjs';
2
+
3
+ declare abstract class DomainEventPublisher {
4
+ abstract publish(domainEvents: DomainEvent[]): Promise<void>;
5
+ }
6
+
7
+ export { DomainEventPublisher as D };
@@ -0,0 +1,7 @@
1
+ import { D as DomainEvent } from './DomainEvent-mXWEtr_J.js';
2
+
3
+ declare abstract class DomainEventPublisher {
4
+ abstract publish(domainEvents: DomainEvent[]): Promise<void>;
5
+ }
6
+
7
+ export { DomainEventPublisher as D };
@@ -0,0 +1,20 @@
1
+ import { S as ServiceResolver } from './ServiceResolver-D2Jz-l_Z.js';
2
+
3
+ type MessageMetadata = Readonly<Record<string, unknown>>;
4
+
5
+ interface Message<Name extends string = string, Payload = unknown> {
6
+ readonly name: Name;
7
+ readonly payload: Payload;
8
+ readonly metadata?: MessageMetadata;
9
+ }
10
+
11
+ interface DomainEvent<Name extends string = string, Payload = unknown> extends Message<Name, Payload> {
12
+ readonly occurredAt: Date;
13
+ }
14
+
15
+ interface HandlerContext {
16
+ readonly di: ServiceResolver;
17
+ readonly publish: (event: DomainEvent) => Promise<void>;
18
+ }
19
+
20
+ export type { DomainEvent as D, HandlerContext as H, Message as M, MessageMetadata as a };
@@ -0,0 +1,20 @@
1
+ import { S as ServiceResolver } from './ServiceResolver-D2Jz-l_Z.cjs';
2
+
3
+ type MessageMetadata = Readonly<Record<string, unknown>>;
4
+
5
+ interface Message<Name extends string = string, Payload = unknown> {
6
+ readonly name: Name;
7
+ readonly payload: Payload;
8
+ readonly metadata?: MessageMetadata;
9
+ }
10
+
11
+ interface DomainEvent<Name extends string = string, Payload = unknown> extends Message<Name, Payload> {
12
+ readonly occurredAt: Date;
13
+ }
14
+
15
+ interface HandlerContext {
16
+ readonly di: ServiceResolver;
17
+ readonly publish: (event: DomainEvent) => Promise<void>;
18
+ }
19
+
20
+ export type { DomainEvent as D, HandlerContext as H, Message as M, MessageMetadata as a };
@@ -0,0 +1,70 @@
1
+ import { C as Consumer } from './Consumer-CC8ZRCsd.cjs';
2
+ import { C as ConsumerMiddleware, S as ShutdownHook } from './ShutdownHook-Dib5uNKB.cjs';
3
+ import { K as KernelLogger } from './KernelLogger-BESOFrpW.cjs';
4
+ import { Route } from './adapters/ui/routes/index.cjs';
5
+ import { D as DependencyInjection, S as ServiceClass } from './ServiceClass-BmNw8fJj.cjs';
6
+ import { Initializer, Runtime } from './infrastructure/lifecycle/index.cjs';
7
+ import { S as Scheduler } from './Scheduler-oigqNOUJ.cjs';
8
+
9
+ interface KernelOptions {
10
+ readonly di?: DependencyInjection;
11
+ readonly logger?: KernelLogger;
12
+ readonly servicesYamlPath?: string;
13
+ readonly sourceDirectory?: string;
14
+ }
15
+
16
+ declare class Kernel {
17
+ private readonly options;
18
+ private static readonly stateKey;
19
+ private readonly consumerMiddlewares;
20
+ private readonly consumersList;
21
+ private readonly loggerInstance;
22
+ private readonly routesList;
23
+ private readonly schedulersList;
24
+ private readonly shutdownHooks;
25
+ private dependencyInjectionInstance;
26
+ private static get state();
27
+ static get configDirectory(): string;
28
+ static get consumers(): Consumer[];
29
+ static get consumerMiddleware(): ConsumerMiddleware[];
30
+ static get di(): DependencyInjection;
31
+ static get logger(): KernelLogger;
32
+ static get rootDirectory(): string;
33
+ static get routes(): ServiceClass<Route>[];
34
+ static get schedulers(): Scheduler[];
35
+ static get sourceDirectory(): string;
36
+ private static getActiveKernel;
37
+ constructor(options?: KernelOptions);
38
+ private closeCandidate;
39
+ private getConsumerFromClass;
40
+ private getInitializerFromClass;
41
+ private getRuntimeFromClass;
42
+ private getSchedulerFromClass;
43
+ get consumers(): Consumer[];
44
+ get consumerMiddleware(): ConsumerMiddleware[];
45
+ get di(): DependencyInjection;
46
+ get logger(): KernelLogger;
47
+ get routes(): ServiceClass<Route>[];
48
+ get schedulers(): Scheduler[];
49
+ dependencyInjection(): Promise<void>;
50
+ getRoutes(): ServiceClass<Route>[];
51
+ registerConsumerMiddleware(...middlewares: ConsumerMiddleware[]): void;
52
+ registerConsumers(...ClassDefinitions: ServiceClass<Consumer>[]): void;
53
+ registerConsumerInstances(...consumers: Consumer[]): void;
54
+ registerRoutes(...ClassDefinitions: ServiceClass<Route>[]): void;
55
+ registerSchedulers(...ClassDefinitions: ServiceClass<Scheduler>[]): void;
56
+ registerSchedulerInstances(...schedulers: Scheduler[]): void;
57
+ registerShutdownHook(hook: ShutdownHook): void;
58
+ removeConsumers(): void;
59
+ removeRoutes(): void;
60
+ removeSchedulers(): void;
61
+ runConsumers(): Promise<void>;
62
+ runInitializers(...ClassDefinitions: ServiceClass<Initializer>[]): Promise<void>;
63
+ runRuntimes(...ClassDefinitions: ServiceClass<Runtime>[]): Promise<void>;
64
+ runSchedulerNowAndSchedule(ClassDefinition: ServiceClass<Scheduler>): Promise<void>;
65
+ runSchedulers(): Promise<void>;
66
+ shutdown(): Promise<void>;
67
+ }
68
+ declare function createKernel(options?: KernelOptions): Kernel;
69
+
70
+ export { Kernel as K, type KernelOptions as a, createKernel as c };
@@ -0,0 +1,70 @@
1
+ import { C as Consumer } from './Consumer-CeT0Wbxb.js';
2
+ import { C as ConsumerMiddleware, S as ShutdownHook } from './ShutdownHook-BGskq2-q.js';
3
+ import { K as KernelLogger } from './KernelLogger-BESOFrpW.js';
4
+ import { Route } from './adapters/ui/routes/index.js';
5
+ import { D as DependencyInjection, S as ServiceClass } from './ServiceClass-C7NCKdSS.js';
6
+ import { Initializer, Runtime } from './infrastructure/lifecycle/index.js';
7
+ import { S as Scheduler } from './Scheduler-oigqNOUJ.js';
8
+
9
+ interface KernelOptions {
10
+ readonly di?: DependencyInjection;
11
+ readonly logger?: KernelLogger;
12
+ readonly servicesYamlPath?: string;
13
+ readonly sourceDirectory?: string;
14
+ }
15
+
16
+ declare class Kernel {
17
+ private readonly options;
18
+ private static readonly stateKey;
19
+ private readonly consumerMiddlewares;
20
+ private readonly consumersList;
21
+ private readonly loggerInstance;
22
+ private readonly routesList;
23
+ private readonly schedulersList;
24
+ private readonly shutdownHooks;
25
+ private dependencyInjectionInstance;
26
+ private static get state();
27
+ static get configDirectory(): string;
28
+ static get consumers(): Consumer[];
29
+ static get consumerMiddleware(): ConsumerMiddleware[];
30
+ static get di(): DependencyInjection;
31
+ static get logger(): KernelLogger;
32
+ static get rootDirectory(): string;
33
+ static get routes(): ServiceClass<Route>[];
34
+ static get schedulers(): Scheduler[];
35
+ static get sourceDirectory(): string;
36
+ private static getActiveKernel;
37
+ constructor(options?: KernelOptions);
38
+ private closeCandidate;
39
+ private getConsumerFromClass;
40
+ private getInitializerFromClass;
41
+ private getRuntimeFromClass;
42
+ private getSchedulerFromClass;
43
+ get consumers(): Consumer[];
44
+ get consumerMiddleware(): ConsumerMiddleware[];
45
+ get di(): DependencyInjection;
46
+ get logger(): KernelLogger;
47
+ get routes(): ServiceClass<Route>[];
48
+ get schedulers(): Scheduler[];
49
+ dependencyInjection(): Promise<void>;
50
+ getRoutes(): ServiceClass<Route>[];
51
+ registerConsumerMiddleware(...middlewares: ConsumerMiddleware[]): void;
52
+ registerConsumers(...ClassDefinitions: ServiceClass<Consumer>[]): void;
53
+ registerConsumerInstances(...consumers: Consumer[]): void;
54
+ registerRoutes(...ClassDefinitions: ServiceClass<Route>[]): void;
55
+ registerSchedulers(...ClassDefinitions: ServiceClass<Scheduler>[]): void;
56
+ registerSchedulerInstances(...schedulers: Scheduler[]): void;
57
+ registerShutdownHook(hook: ShutdownHook): void;
58
+ removeConsumers(): void;
59
+ removeRoutes(): void;
60
+ removeSchedulers(): void;
61
+ runConsumers(): Promise<void>;
62
+ runInitializers(...ClassDefinitions: ServiceClass<Initializer>[]): Promise<void>;
63
+ runRuntimes(...ClassDefinitions: ServiceClass<Runtime>[]): Promise<void>;
64
+ runSchedulerNowAndSchedule(ClassDefinition: ServiceClass<Scheduler>): Promise<void>;
65
+ runSchedulers(): Promise<void>;
66
+ shutdown(): Promise<void>;
67
+ }
68
+ declare function createKernel(options?: KernelOptions): Kernel;
69
+
70
+ export { Kernel as K, type KernelOptions as a, createKernel as c };
@@ -0,0 +1,8 @@
1
+ interface KernelLogger {
2
+ debug(message: string): void;
3
+ error(message: string): void;
4
+ info(message: string): void;
5
+ warn(message: string): void;
6
+ }
7
+
8
+ export type { KernelLogger as K };
@@ -0,0 +1,8 @@
1
+ interface KernelLogger {
2
+ debug(message: string): void;
3
+ error(message: string): void;
4
+ info(message: string): void;
5
+ warn(message: string): void;
6
+ }
7
+
8
+ export type { KernelLogger as K };
@@ -0,0 +1,8 @@
1
+ interface Log {
2
+ debug(message: string): void;
3
+ error(message: string): void;
4
+ info(message: string): void;
5
+ warn(message: string): void;
6
+ }
7
+
8
+ export type { Log as L };
@@ -0,0 +1,8 @@
1
+ interface Log {
2
+ debug(message: string): void;
3
+ error(message: string): void;
4
+ info(message: string): void;
5
+ warn(message: string): void;
6
+ }
7
+
8
+ export type { Log as L };
@@ -0,0 +1,45 @@
1
+ import { L as Log } from './Log-36L3Z84a.js';
2
+ import { Channel } from 'amqplib';
3
+ import { D as DomainEvent } from './DomainEvent-mXWEtr_J.js';
4
+ import { C as Constructor } from './Constructor-fyZLLIh8.js';
5
+
6
+ type AmqpMessage = {
7
+ readonly aggregate_id: string;
8
+ readonly attributes: Record<string, unknown>;
9
+ readonly causation_id?: string;
10
+ readonly correlation_id?: string;
11
+ readonly error?: string;
12
+ readonly event_id: string;
13
+ readonly occurred_on?: number | string;
14
+ readonly retries?: number;
15
+ readonly type: string;
16
+ };
17
+
18
+ interface AmqpMessageBusAdapterOptions {
19
+ readonly dsn?: string;
20
+ readonly exchange?: string;
21
+ readonly logger?: Log;
22
+ readonly maxRetries?: number;
23
+ readonly retryDelayInMilliseconds?: number;
24
+ readonly serviceName?: string;
25
+ }
26
+
27
+ type DomainEventHandler = (event: DomainEvent) => Promise<void>;
28
+
29
+ type ConsumerContext = {
30
+ readonly bindingKey: string;
31
+ readonly channel: Channel;
32
+ readonly DomainEventInstance: Constructor<DomainEvent>;
33
+ readonly handler: DomainEventHandler;
34
+ readonly queueName: string;
35
+ };
36
+
37
+ declare class InvalidDomainEventError extends Error {
38
+ constructor(message: string);
39
+ }
40
+
41
+ declare class NoFailedMessagesError extends Error {
42
+ constructor(queueName: string);
43
+ }
44
+
45
+ export { type AmqpMessage as A, type ConsumerContext as C, type DomainEventHandler as D, InvalidDomainEventError as I, NoFailedMessagesError as N, type AmqpMessageBusAdapterOptions as a };
@@ -0,0 +1,45 @@
1
+ import { L as Log } from './Log-36L3Z84a.cjs';
2
+ import { Channel } from 'amqplib';
3
+ import { D as DomainEvent } from './DomainEvent-mXWEtr_J.cjs';
4
+ import { C as Constructor } from './Constructor-fyZLLIh8.cjs';
5
+
6
+ type AmqpMessage = {
7
+ readonly aggregate_id: string;
8
+ readonly attributes: Record<string, unknown>;
9
+ readonly causation_id?: string;
10
+ readonly correlation_id?: string;
11
+ readonly error?: string;
12
+ readonly event_id: string;
13
+ readonly occurred_on?: number | string;
14
+ readonly retries?: number;
15
+ readonly type: string;
16
+ };
17
+
18
+ interface AmqpMessageBusAdapterOptions {
19
+ readonly dsn?: string;
20
+ readonly exchange?: string;
21
+ readonly logger?: Log;
22
+ readonly maxRetries?: number;
23
+ readonly retryDelayInMilliseconds?: number;
24
+ readonly serviceName?: string;
25
+ }
26
+
27
+ type DomainEventHandler = (event: DomainEvent) => Promise<void>;
28
+
29
+ type ConsumerContext = {
30
+ readonly bindingKey: string;
31
+ readonly channel: Channel;
32
+ readonly DomainEventInstance: Constructor<DomainEvent>;
33
+ readonly handler: DomainEventHandler;
34
+ readonly queueName: string;
35
+ };
36
+
37
+ declare class InvalidDomainEventError extends Error {
38
+ constructor(message: string);
39
+ }
40
+
41
+ declare class NoFailedMessagesError extends Error {
42
+ constructor(queueName: string);
43
+ }
44
+
45
+ export { type AmqpMessage as A, type ConsumerContext as C, type DomainEventHandler as D, InvalidDomainEventError as I, NoFailedMessagesError as N, type AmqpMessageBusAdapterOptions as a };
@@ -0,0 +1,7 @@
1
+ interface Repository<TEntity, TId> {
2
+ findById(id: TId): Promise<TEntity | null>;
3
+ save(entity: TEntity): Promise<void>;
4
+ delete(id: TId): Promise<void>;
5
+ }
6
+
7
+ export type { Repository as R };
@@ -0,0 +1,7 @@
1
+ interface Repository<TEntity, TId> {
2
+ findById(id: TId): Promise<TEntity | null>;
3
+ save(entity: TEntity): Promise<void>;
4
+ delete(id: TId): Promise<void>;
5
+ }
6
+
7
+ export type { Repository as R };
@@ -0,0 +1,27 @@
1
+ interface CronExpression {
2
+ readonly dayOfMonth?: number | string;
3
+ readonly dayOfWeek?: number | string;
4
+ readonly hour?: number | string;
5
+ readonly minute?: number | string;
6
+ readonly month?: number | string;
7
+ readonly second?: number | string;
8
+ }
9
+
10
+ interface SchedulerErrorPolicy {
11
+ handle(error: unknown, scheduler: Scheduler): Promise<void> | void;
12
+ shouldSkip(error: unknown): boolean;
13
+ }
14
+
15
+ declare abstract class Scheduler {
16
+ private readonly errorPolicy;
17
+ constructor(errorPolicy?: SchedulerErrorPolicy);
18
+ private parseCronExpression;
19
+ abstract execute(): Promise<void>;
20
+ abstract getCronExpression(): CronExpression;
21
+ abstract getProcessName(): string;
22
+ runOnce(): Promise<void>;
23
+ get<T>(service: unknown): T;
24
+ init(): Promise<void>;
25
+ }
26
+
27
+ export { type CronExpression as C, Scheduler as S, type SchedulerErrorPolicy as a };