@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
|
@@ -1,10 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { K as KernelLogger } from './KernelLogger-BESOFrpW.js';
|
|
1
|
+
import { D as DomainEvent } from './DomainEvent-mXWEtr_J.js';
|
|
2
|
+
import { D as DomainEventConsumer } from './DomainEventConsumer-BroJmVty.js';
|
|
4
3
|
import { Route } from './adapters/ui/routes/index.js';
|
|
5
|
-
import { D as DependencyInjection, S as ServiceClass } from './ServiceClass-
|
|
4
|
+
import { b as DependencyOverride, D as DependencyInjection, S as ServiceClass } from './ServiceClass-Bq_fBC5R.js';
|
|
6
5
|
import { Initializer, Runtime } from './infrastructure/lifecycle/index.js';
|
|
7
|
-
import {
|
|
6
|
+
import { a as Scheduler } from './Scheduler-BW-U5Ccg.js';
|
|
7
|
+
import { K as KernelLogger } from './KernelLogger-BESOFrpW.js';
|
|
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 };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { M as Message, H as HandlerContext, D as DomainEvent } from './HandlerContext-Lm89pSeG.cjs';
|
|
2
|
+
import { D as DomainEvent$1 } from './DomainEvent-mXWEtr_J.cjs';
|
|
3
|
+
|
|
4
|
+
type MessageHandler<TMessage extends Message = Message, TResult = unknown> = (message: TMessage, context: HandlerContext) => TResult | Promise<TResult>;
|
|
5
|
+
|
|
6
|
+
interface PublishContext<TMessage extends Message | DomainEvent = Message> {
|
|
7
|
+
readonly domainEvent?: DomainEvent$1;
|
|
8
|
+
readonly message: TMessage;
|
|
9
|
+
readonly metadata: Readonly<Record<string, unknown>>;
|
|
10
|
+
readonly topic: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface PublisherHook {
|
|
14
|
+
afterPublish?(context: PublishContext): Promise<void> | void;
|
|
15
|
+
beforePublish?(context: PublishContext): Promise<void> | void;
|
|
16
|
+
onPublishError?(error: unknown, context: PublishContext): Promise<void> | void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface Subscription {
|
|
20
|
+
close(): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type { MessageHandler as M, PublishContext as P, Subscription as S, PublisherHook as a };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { M as Message, H as HandlerContext, D as DomainEvent } from './HandlerContext-DUUExVo3.js';
|
|
2
|
+
import { D as DomainEvent$1 } from './DomainEvent-mXWEtr_J.js';
|
|
3
|
+
|
|
4
|
+
type MessageHandler<TMessage extends Message = Message, TResult = unknown> = (message: TMessage, context: HandlerContext) => TResult | Promise<TResult>;
|
|
5
|
+
|
|
6
|
+
interface PublishContext<TMessage extends Message | DomainEvent = Message> {
|
|
7
|
+
readonly domainEvent?: DomainEvent$1;
|
|
8
|
+
readonly message: TMessage;
|
|
9
|
+
readonly metadata: Readonly<Record<string, unknown>>;
|
|
10
|
+
readonly topic: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface PublisherHook {
|
|
14
|
+
afterPublish?(context: PublishContext): Promise<void> | void;
|
|
15
|
+
beforePublish?(context: PublishContext): Promise<void> | void;
|
|
16
|
+
onPublishError?(error: unknown, context: PublishContext): Promise<void> | void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface Subscription {
|
|
20
|
+
close(): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type { MessageHandler as M, PublishContext as P, Subscription as S, PublisherHook as a };
|