@haskou/ddd-kernel 0.1.1 → 1.0.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.
- package/README.md +5 -10
- 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 +92 -17
- 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
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
[](https://codecov.io/gh/haskou/ddd-kernel)
|
|
5
5
|
[](https://www.npmjs.com/package/@haskou/ddd-kernel)
|
|
6
6
|
[](LICENSE)
|
|
7
|
+
[](https://renovatebot.com)
|
|
7
8
|
|
|
8
9
|
Framework-agnostic DDD kernel for TypeScript applications and microservices.
|
|
9
10
|
|
|
@@ -44,12 +45,6 @@ Constructor injection is the preferred application pattern. Direct service
|
|
|
44
45
|
lookup remains available for compatibility and integration boundaries, but it is
|
|
45
46
|
not the primary dependency model.
|
|
46
47
|
|
|
47
|
-
## Stability
|
|
48
|
-
|
|
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.
|
|
52
|
-
|
|
53
48
|
## Documentation
|
|
54
49
|
|
|
55
50
|
Usage guides, adapter authoring notes and API reference pages are published at:
|
|
@@ -65,10 +60,10 @@ CI publishes npm versions from pull requests merged into the default branch
|
|
|
65
60
|
according to the source branch prefix:
|
|
66
61
|
|
|
67
62
|
| Branch prefix | npm version bump |
|
|
68
|
-
|
|
|
69
|
-
| `fix/*`
|
|
70
|
-
| `feat/*`
|
|
71
|
-
| `break/*`
|
|
63
|
+
| ------------- | ---------------- |
|
|
64
|
+
| `fix/*` | Patch |
|
|
65
|
+
| `feat/*` | Minor |
|
|
66
|
+
| `break/*` | Major |
|
|
72
67
|
|
|
73
68
|
Other branch names run validation only and do not publish.
|
|
74
69
|
|
|
@@ -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 };
|
|
@@ -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 };
|