@haskou/ddd-kernel 2.0.1 → 2.0.3
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/dist/{DomainMessageBus-CQSFU6A6.d.cts → DomainMessageBus-BHnBQZvI.d.cts} +1 -1
- package/dist/{DomainMessageBus-kjMVNGfv.d.ts → DomainMessageBus-DbctRnBy.d.ts} +1 -1
- package/dist/{HandlerContext-DUUExVo3.d.ts → HandlerContext-BT0RLBRT.d.ts} +1 -1
- package/dist/{HandlerContext-Lm89pSeG.d.cts → HandlerContext-CdX28Pr5.d.cts} +1 -1
- package/dist/{MessageBus-BtUXnd0Y.d.cts → MessageBus-BTy_hVua.d.cts} +2 -2
- package/dist/{MessageBus-oQ9BnW84.d.ts → MessageBus-BkHiX3LI.d.ts} +2 -2
- package/dist/{NoFailedMessagesError-z-6ffelK.d.ts → NoFailedMessagesError-C6wMAOvs.d.ts} +2 -2
- package/dist/{NoFailedMessagesError-Dm5AFcJV.d.cts → NoFailedMessagesError-De3UfABY.d.cts} +2 -2
- package/dist/{PublisherHookErrorPolicy-DSsCNE6O.d.ts → PublisherHookErrorPolicy-Bfh_QLs7.d.ts} +1 -1
- package/dist/{PublisherHookErrorPolicy-CjouTcSR.d.cts → PublisherHookErrorPolicy-BgSvNZBD.d.cts} +1 -1
- package/dist/{RetryPredicate-DNdxY_KR.d.cts → RetryPredicate-CqvyqG9g.d.cts} +1 -1
- package/dist/{RetryPredicate-CD9n6cE8.d.ts → RetryPredicate-DTeTm450.d.ts} +1 -1
- package/dist/{ServiceClass-BkEHcXDi.d.cts → ServiceClass-D_0gCcMr.d.cts} +4 -1
- package/dist/{ServiceClass-Bq_fBC5R.d.ts → ServiceClass-IInu6j5L.d.ts} +4 -1
- package/dist/{ServiceResolver-D2Jz-l_Z.d.cts → ServiceResolver-CQGmbk-X.d.cts} +1 -0
- package/dist/{ServiceResolver-D2Jz-l_Z.d.ts → ServiceResolver-CQGmbk-X.d.ts} +1 -0
- package/dist/{ShutdownHook-D23WfIIc.d.cts → ShutdownHook-C48hH6-x.d.cts} +4 -1
- package/dist/{ShutdownHook-CUl7zYwd.d.ts → ShutdownHook-CWTm9Lkn.d.ts} +4 -1
- package/dist/{Subscription-vtF0lEHP.d.ts → Subscription-BdLdP_5-.d.ts} +1 -1
- package/dist/{Subscription-4vuAAxax.d.cts → Subscription-DY3nBVkU.d.cts} +1 -1
- package/dist/adapters/index.cjs +133 -18
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.d.cts +9 -9
- package/dist/adapters/index.d.ts +9 -9
- package/dist/adapters/index.js +132 -18
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/pubsub/amqp/index.cjs +80 -12
- package/dist/adapters/pubsub/amqp/index.cjs.map +1 -1
- package/dist/adapters/pubsub/amqp/index.d.cts +8 -8
- package/dist/adapters/pubsub/amqp/index.d.ts +8 -8
- package/dist/adapters/pubsub/amqp/index.js +80 -12
- package/dist/adapters/pubsub/amqp/index.js.map +1 -1
- package/dist/adapters/pubsub/in-memory/index.d.cts +4 -4
- package/dist/adapters/pubsub/in-memory/index.d.ts +4 -4
- package/dist/adapters/pubsub/index.cjs +80 -12
- package/dist/adapters/pubsub/index.cjs.map +1 -1
- package/dist/adapters/pubsub/index.d.cts +8 -8
- package/dist/adapters/pubsub/index.d.ts +8 -8
- package/dist/adapters/pubsub/index.js +80 -12
- package/dist/adapters/pubsub/index.js.map +1 -1
- package/dist/adapters/ui/express/index.cjs +53 -6
- package/dist/adapters/ui/express/index.cjs.map +1 -1
- package/dist/adapters/ui/express/index.d.cts +16 -4
- package/dist/adapters/ui/express/index.d.ts +16 -4
- package/dist/adapters/ui/express/index.js +52 -6
- package/dist/adapters/ui/express/index.js.map +1 -1
- package/dist/adapters/ui/index.cjs +133 -18
- package/dist/adapters/ui/index.cjs.map +1 -1
- package/dist/adapters/ui/index.d.cts +4 -4
- package/dist/adapters/ui/index.d.ts +4 -4
- package/dist/adapters/ui/index.js +132 -18
- package/dist/adapters/ui/index.js.map +1 -1
- package/dist/adapters/ui/routes/index.cjs +80 -12
- package/dist/adapters/ui/routes/index.cjs.map +1 -1
- package/dist/adapters/ui/routes/index.js +80 -12
- package/dist/adapters/ui/routes/index.js.map +1 -1
- package/dist/contracts/index.d.cts +8 -8
- package/dist/contracts/index.d.ts +8 -8
- package/dist/contracts/kernel/index.d.cts +5 -5
- package/dist/contracts/kernel/index.d.ts +5 -5
- package/dist/contracts/pubsub/index.d.cts +7 -7
- package/dist/contracts/pubsub/index.d.ts +7 -7
- package/dist/contracts/ui/index.d.cts +2 -2
- package/dist/contracts/ui/index.d.ts +2 -2
- package/dist/domain/index.d.cts +5 -5
- package/dist/domain/index.d.ts +5 -5
- package/dist/index.cjs +80 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +80 -12
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/dependency-injection/index.cjs +44 -1
- package/dist/infrastructure/dependency-injection/index.cjs.map +1 -1
- package/dist/infrastructure/dependency-injection/index.d.cts +13 -3
- package/dist/infrastructure/dependency-injection/index.d.ts +13 -3
- package/dist/infrastructure/dependency-injection/index.js +43 -1
- package/dist/infrastructure/dependency-injection/index.js.map +1 -1
- package/dist/infrastructure/express/index.cjs +53 -6
- package/dist/infrastructure/express/index.cjs.map +1 -1
- package/dist/infrastructure/express/index.d.cts +4 -4
- package/dist/infrastructure/express/index.d.ts +4 -4
- package/dist/infrastructure/express/index.js +52 -6
- package/dist/infrastructure/express/index.js.map +1 -1
- package/dist/infrastructure/scheduler/index.cjs +80 -12
- package/dist/infrastructure/scheduler/index.cjs.map +1 -1
- package/dist/infrastructure/scheduler/index.js +80 -12
- package/dist/infrastructure/scheduler/index.js.map +1 -1
- package/package.json +5 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as Message } from './HandlerContext-
|
|
2
|
-
import { a as PublisherHook, M as MessageHandler, S as Subscription } from './Subscription-
|
|
1
|
+
import { M as Message } from './HandlerContext-CdX28Pr5.cjs';
|
|
2
|
+
import { a as PublisherHook, M as MessageHandler, S as Subscription } from './Subscription-DY3nBVkU.cjs';
|
|
3
3
|
|
|
4
4
|
interface MessageBus {
|
|
5
5
|
publish<TMessage extends Message>(topic: string, message: TMessage): Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as Message } from './HandlerContext-
|
|
2
|
-
import { a as PublisherHook, M as MessageHandler, S as Subscription } from './Subscription-
|
|
1
|
+
import { M as Message } from './HandlerContext-BT0RLBRT.js';
|
|
2
|
+
import { a as PublisherHook, M as MessageHandler, S as Subscription } from './Subscription-BdLdP_5-.js';
|
|
3
3
|
|
|
4
4
|
interface MessageBus {
|
|
5
5
|
publish<TMessage extends Message>(topic: string, message: TMessage): Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as PublisherHook } from './Subscription-
|
|
2
|
-
import { P as PublisherHookErrorPolicy } from './PublisherHookErrorPolicy-
|
|
1
|
+
import { a as PublisherHook } from './Subscription-BdLdP_5-.js';
|
|
2
|
+
import { P as PublisherHookErrorPolicy } from './PublisherHookErrorPolicy-Bfh_QLs7.js';
|
|
3
3
|
import { L as Log } from './Log-36L3Z84a.js';
|
|
4
4
|
import { Channel } from 'amqplib';
|
|
5
5
|
import { D as DomainEvent } from './DomainEvent-mXWEtr_J.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as PublisherHook } from './Subscription-
|
|
2
|
-
import { P as PublisherHookErrorPolicy } from './PublisherHookErrorPolicy-
|
|
1
|
+
import { a as PublisherHook } from './Subscription-DY3nBVkU.cjs';
|
|
2
|
+
import { P as PublisherHookErrorPolicy } from './PublisherHookErrorPolicy-BgSvNZBD.cjs';
|
|
3
3
|
import { L as Log } from './Log-36L3Z84a.cjs';
|
|
4
4
|
import { Channel } from 'amqplib';
|
|
5
5
|
import { D as DomainEvent } from './DomainEvent-mXWEtr_J.cjs';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as ServiceResolver } from './ServiceResolver-
|
|
1
|
+
import { S as ServiceResolver } from './ServiceResolver-CQGmbk-X.cjs';
|
|
2
2
|
|
|
3
3
|
type DependencyOverrideToken = unknown;
|
|
4
4
|
|
|
@@ -43,6 +43,7 @@ declare class DependencyInjection implements ServiceResolver {
|
|
|
43
43
|
private ensureFolderExists;
|
|
44
44
|
private getServiceClassName;
|
|
45
45
|
private getOverrideId;
|
|
46
|
+
private hasDirectService;
|
|
46
47
|
private ensureSyntheticService;
|
|
47
48
|
private parentMatchesService;
|
|
48
49
|
private serviceIdMatchesService;
|
|
@@ -59,9 +60,11 @@ declare class DependencyInjection implements ServiceResolver {
|
|
|
59
60
|
private applyFactoryOverride;
|
|
60
61
|
private applyValueOverride;
|
|
61
62
|
private applyOverrides;
|
|
63
|
+
private processAutowire;
|
|
62
64
|
private registerParentAliases;
|
|
63
65
|
compile(): Promise<void>;
|
|
64
66
|
getService<T>(serviceName: unknown): T;
|
|
67
|
+
hasService(serviceName: unknown): boolean;
|
|
65
68
|
}
|
|
66
69
|
|
|
67
70
|
type ServiceClass<T> = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as ServiceResolver } from './ServiceResolver-
|
|
1
|
+
import { S as ServiceResolver } from './ServiceResolver-CQGmbk-X.js';
|
|
2
2
|
|
|
3
3
|
type DependencyOverrideToken = unknown;
|
|
4
4
|
|
|
@@ -43,6 +43,7 @@ declare class DependencyInjection implements ServiceResolver {
|
|
|
43
43
|
private ensureFolderExists;
|
|
44
44
|
private getServiceClassName;
|
|
45
45
|
private getOverrideId;
|
|
46
|
+
private hasDirectService;
|
|
46
47
|
private ensureSyntheticService;
|
|
47
48
|
private parentMatchesService;
|
|
48
49
|
private serviceIdMatchesService;
|
|
@@ -59,9 +60,11 @@ declare class DependencyInjection implements ServiceResolver {
|
|
|
59
60
|
private applyFactoryOverride;
|
|
60
61
|
private applyValueOverride;
|
|
61
62
|
private applyOverrides;
|
|
63
|
+
private processAutowire;
|
|
62
64
|
private registerParentAliases;
|
|
63
65
|
compile(): Promise<void>;
|
|
64
66
|
getService<T>(serviceName: unknown): T;
|
|
67
|
+
hasService(serviceName: unknown): boolean;
|
|
65
68
|
}
|
|
66
69
|
|
|
67
70
|
type ServiceClass<T> = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { D as DomainEvent } from './DomainEvent-mXWEtr_J.cjs';
|
|
2
2
|
import { DotenvConfigOutput } from 'dotenv';
|
|
3
|
-
import { b as DependencyOverride, D as DependencyInjection, S as ServiceClass } from './ServiceClass-
|
|
3
|
+
import { b as DependencyOverride, D as DependencyInjection, S as ServiceClass } from './ServiceClass-D_0gCcMr.cjs';
|
|
4
4
|
import { Initializer, Runtime } from './infrastructure/lifecycle/index.cjs';
|
|
5
5
|
import { a as Scheduler } from './Scheduler-BW-U5Ccg.cjs';
|
|
6
6
|
import { K as KernelLogger } from './KernelLogger-BESOFrpW.cjs';
|
|
@@ -102,11 +102,14 @@ declare class Kernel<TEnvironmentSchema extends KernelEnvironmentSchema | undefi
|
|
|
102
102
|
static get sourceDirectory(): string;
|
|
103
103
|
private static getActiveKernel;
|
|
104
104
|
private static assertRequiredEnvironmentVariable;
|
|
105
|
+
private static assertRequiredEnvironmentVariableIsNotBlank;
|
|
105
106
|
private static assertEnvironmentVariableChoice;
|
|
106
107
|
private static getEnvironmentVariablesPath;
|
|
107
108
|
private static parseBooleanEnvironmentVariable;
|
|
108
109
|
private static parseNumberEnvironmentVariable;
|
|
109
110
|
private static parseEnvironmentVariable;
|
|
111
|
+
private static getEnvironmentVariableValue;
|
|
112
|
+
private static shouldUnsetBlankOptionalEnvironmentVariable;
|
|
110
113
|
private static validateEnvironmentVariables;
|
|
111
114
|
static loadEnvironmentVariables(environment?: string, options?: KernelEnvironmentVariablesOptions<KernelEnvironmentSchema | undefined>): DotenvConfigOutput;
|
|
112
115
|
constructor(options?: KernelOptions<TEnvironmentSchema>);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { D as DomainEvent } from './DomainEvent-mXWEtr_J.js';
|
|
2
2
|
import { DotenvConfigOutput } from 'dotenv';
|
|
3
|
-
import { b as DependencyOverride, D as DependencyInjection, S as ServiceClass } from './ServiceClass-
|
|
3
|
+
import { b as DependencyOverride, D as DependencyInjection, S as ServiceClass } from './ServiceClass-IInu6j5L.js';
|
|
4
4
|
import { Initializer, Runtime } from './infrastructure/lifecycle/index.js';
|
|
5
5
|
import { a as Scheduler } from './Scheduler-BW-U5Ccg.js';
|
|
6
6
|
import { K as KernelLogger } from './KernelLogger-BESOFrpW.js';
|
|
@@ -102,11 +102,14 @@ declare class Kernel<TEnvironmentSchema extends KernelEnvironmentSchema | undefi
|
|
|
102
102
|
static get sourceDirectory(): string;
|
|
103
103
|
private static getActiveKernel;
|
|
104
104
|
private static assertRequiredEnvironmentVariable;
|
|
105
|
+
private static assertRequiredEnvironmentVariableIsNotBlank;
|
|
105
106
|
private static assertEnvironmentVariableChoice;
|
|
106
107
|
private static getEnvironmentVariablesPath;
|
|
107
108
|
private static parseBooleanEnvironmentVariable;
|
|
108
109
|
private static parseNumberEnvironmentVariable;
|
|
109
110
|
private static parseEnvironmentVariable;
|
|
111
|
+
private static getEnvironmentVariableValue;
|
|
112
|
+
private static shouldUnsetBlankOptionalEnvironmentVariable;
|
|
110
113
|
private static validateEnvironmentVariables;
|
|
111
114
|
static loadEnvironmentVariables(environment?: string, options?: KernelEnvironmentVariablesOptions<KernelEnvironmentSchema | undefined>): DotenvConfigOutput;
|
|
112
115
|
constructor(options?: KernelOptions<TEnvironmentSchema>);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Message, H as HandlerContext, D as DomainEvent } from './HandlerContext-
|
|
1
|
+
import { M as Message, H as HandlerContext, D as DomainEvent } from './HandlerContext-BT0RLBRT.js';
|
|
2
2
|
import { D as DomainEvent$1 } from './DomainEvent-mXWEtr_J.js';
|
|
3
3
|
|
|
4
4
|
type MessageHandler<TMessage extends Message = Message, TResult = unknown> = (message: TMessage, context: HandlerContext) => TResult | Promise<TResult>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Message, H as HandlerContext, D as DomainEvent } from './HandlerContext-
|
|
1
|
+
import { M as Message, H as HandlerContext, D as DomainEvent } from './HandlerContext-CdX28Pr5.cjs';
|
|
2
2
|
import { D as DomainEvent$1 } from './DomainEvent-mXWEtr_J.cjs';
|
|
3
3
|
|
|
4
4
|
type MessageHandler<TMessage extends Message = Message, TResult = unknown> = (message: TMessage, context: HandlerContext) => TResult | Promise<TResult>;
|
package/dist/adapters/index.cjs
CHANGED
|
@@ -35,6 +35,7 @@ __export(adapters_exports, {
|
|
|
35
35
|
ConsumerMiddlewarePipeline: () => ConsumerMiddlewarePipeline,
|
|
36
36
|
CorrelationConsumerMiddleware: () => CorrelationConsumerMiddleware,
|
|
37
37
|
DefaultPublisherHookErrorPolicy: () => DefaultPublisherHookErrorPolicy,
|
|
38
|
+
ExpressControllerResolver: () => ExpressControllerResolver,
|
|
38
39
|
ExpressKernelServer: () => ExpressKernelServer,
|
|
39
40
|
HttpErrorHandler: () => HttpErrorHandler,
|
|
40
41
|
IdempotencyConsumerMiddleware: () => IdempotencyConsumerMiddleware,
|
|
@@ -120,6 +121,32 @@ var ConsoleKernelLogger = class {
|
|
|
120
121
|
var import_dotenv = __toESM(require("dotenv"), 1);
|
|
121
122
|
var import_node_path2 = __toESM(require("path"), 1);
|
|
122
123
|
|
|
124
|
+
// src/infrastructure/dependency-injection/AutowireWarningFilter.ts
|
|
125
|
+
var AutowireWarningFilter = class {
|
|
126
|
+
constructor(logger) {
|
|
127
|
+
this.logger = logger;
|
|
128
|
+
}
|
|
129
|
+
logger;
|
|
130
|
+
isIgnorableAutowireWarning(message) {
|
|
131
|
+
return message.startsWith(
|
|
132
|
+
"Autowire: file has export default declaration but no runtime default export:"
|
|
133
|
+
) || message.startsWith("Autowire: failed to create definition for undefined:");
|
|
134
|
+
}
|
|
135
|
+
warn(message, ...optionalParams) {
|
|
136
|
+
if (typeof message === "string" && this.isIgnorableAutowireWarning(message)) {
|
|
137
|
+
this.logger.debug?.(`Ignored ${message}`, ...optionalParams);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
this.logger.warn(message, ...optionalParams);
|
|
141
|
+
}
|
|
142
|
+
info(message, ...optionalParams) {
|
|
143
|
+
this.logger.info?.(message, ...optionalParams);
|
|
144
|
+
}
|
|
145
|
+
debug(message, ...optionalParams) {
|
|
146
|
+
this.logger.debug?.(message, ...optionalParams);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
123
150
|
// src/infrastructure/dependency-injection/DependencyInjection.ts
|
|
124
151
|
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
125
152
|
var import_node_dependency_injection = require("node-dependency-injection");
|
|
@@ -172,6 +199,9 @@ var DependencyInjection = class _DependencyInjection {
|
|
|
172
199
|
const tokenName = this.getServiceClassName(token) ?? String(token);
|
|
173
200
|
return `ddd-kernel.override.${prefix}.${tokenName}`;
|
|
174
201
|
}
|
|
202
|
+
hasDirectService(serviceName) {
|
|
203
|
+
return typeof serviceName === "string" && (this.definitions.has(serviceName) || this.aliases.has(serviceName));
|
|
204
|
+
}
|
|
175
205
|
ensureSyntheticService(id, value) {
|
|
176
206
|
const definition = this.container.register(id);
|
|
177
207
|
definition.public = true;
|
|
@@ -319,6 +349,15 @@ var DependencyInjection = class _DependencyInjection {
|
|
|
319
349
|
this.applyValueOverride(override);
|
|
320
350
|
}
|
|
321
351
|
}
|
|
352
|
+
async processAutowire() {
|
|
353
|
+
const previousLogger = this.container.logger;
|
|
354
|
+
this.container.logger = new AutowireWarningFilter(previousLogger);
|
|
355
|
+
try {
|
|
356
|
+
await this.autowire?.process();
|
|
357
|
+
} finally {
|
|
358
|
+
this.container.logger = previousLogger;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
322
361
|
registerParentAliases() {
|
|
323
362
|
for (const [id, definition] of this.definitions.entries()) {
|
|
324
363
|
if (definition._abstract === true || !definition._parent) {
|
|
@@ -335,7 +374,7 @@ var DependencyInjection = class _DependencyInjection {
|
|
|
335
374
|
this.options.servicesYamlPath,
|
|
336
375
|
false
|
|
337
376
|
);
|
|
338
|
-
await this.
|
|
377
|
+
await this.processAutowire();
|
|
339
378
|
} else {
|
|
340
379
|
this.loader = new import_node_dependency_injection.YamlFileLoader(this.container);
|
|
341
380
|
await this.loader.load(this.options.servicesYamlPath);
|
|
@@ -363,6 +402,9 @@ var DependencyInjection = class _DependencyInjection {
|
|
|
363
402
|
}
|
|
364
403
|
return this.container.get(serviceName);
|
|
365
404
|
}
|
|
405
|
+
hasService(serviceName) {
|
|
406
|
+
return this.overrideTokenIds.has(serviceName) || this.findAliasServiceId(serviceName) !== void 0 || this.findConcreteChildServiceId(serviceName) !== void 0 || this.findRegisteredServiceId(serviceName) !== void 0 || this.hasDirectService(serviceName);
|
|
407
|
+
}
|
|
366
408
|
};
|
|
367
409
|
|
|
368
410
|
// src/kernel/KernelEnvironmentValidationError.ts
|
|
@@ -444,6 +486,13 @@ var Kernel = class _Kernel {
|
|
|
444
486
|
);
|
|
445
487
|
}
|
|
446
488
|
}
|
|
489
|
+
static assertRequiredEnvironmentVariableIsNotBlank(name, value, schema) {
|
|
490
|
+
if (schema[name]?.required === true && value.trim() === "") {
|
|
491
|
+
throw new KernelEnvironmentValidationError(
|
|
492
|
+
`Blank required environment variable "${name}".`
|
|
493
|
+
);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
447
496
|
static assertEnvironmentVariableChoice(name, value, schema) {
|
|
448
497
|
const choices = schema[name]?.choices;
|
|
449
498
|
if (choices && !choices.includes(value)) {
|
|
@@ -466,21 +515,16 @@ var Kernel = class _Kernel {
|
|
|
466
515
|
return false;
|
|
467
516
|
}
|
|
468
517
|
throw new KernelEnvironmentValidationError(
|
|
469
|
-
`Environment variable "${name}"
|
|
518
|
+
`Environment variable "${name}" has invalid boolean value "${value}".`
|
|
470
519
|
);
|
|
471
520
|
}
|
|
472
521
|
static parseNumberEnvironmentVariable(name, value) {
|
|
473
|
-
if (value.trim() === "") {
|
|
474
|
-
throw new KernelEnvironmentValidationError(
|
|
475
|
-
`Environment variable "${name}" must be a number.`
|
|
476
|
-
);
|
|
477
|
-
}
|
|
478
522
|
const parsedValue = Number(value);
|
|
479
523
|
if (Number.isFinite(parsedValue)) {
|
|
480
524
|
return parsedValue;
|
|
481
525
|
}
|
|
482
526
|
throw new KernelEnvironmentValidationError(
|
|
483
|
-
`Environment variable "${name}"
|
|
527
|
+
`Environment variable "${name}" has invalid number value "${value}".`
|
|
484
528
|
);
|
|
485
529
|
}
|
|
486
530
|
static parseEnvironmentVariable(name, value, schema) {
|
|
@@ -498,17 +542,42 @@ var Kernel = class _Kernel {
|
|
|
498
542
|
_Kernel.assertEnvironmentVariableChoice(name, value, schema);
|
|
499
543
|
return value;
|
|
500
544
|
}
|
|
545
|
+
static getEnvironmentVariableValue(name, definition, schema) {
|
|
546
|
+
const value = process.env[name];
|
|
547
|
+
_Kernel.assertRequiredEnvironmentVariable(name, value, schema);
|
|
548
|
+
if (value !== void 0) {
|
|
549
|
+
_Kernel.assertRequiredEnvironmentVariableIsNotBlank(name, value, schema);
|
|
550
|
+
}
|
|
551
|
+
if (value !== void 0 && value.trim() !== "") {
|
|
552
|
+
return value;
|
|
553
|
+
}
|
|
554
|
+
return definition.defaultValue?.toString();
|
|
555
|
+
}
|
|
556
|
+
static shouldUnsetBlankOptionalEnvironmentVariable(name, value, valueOrDefault, schema) {
|
|
557
|
+
return value !== void 0 && value.trim() === "" && valueOrDefault === void 0 && schema[name]?.required !== true;
|
|
558
|
+
}
|
|
501
559
|
static validateEnvironmentVariables(schema) {
|
|
502
560
|
const environmentVariables = {};
|
|
503
561
|
for (const [name, definition] of Object.entries(schema)) {
|
|
504
|
-
const value = process.env[name]
|
|
505
|
-
_Kernel.
|
|
506
|
-
|
|
562
|
+
const value = process.env[name];
|
|
563
|
+
const valueOrDefault = _Kernel.getEnvironmentVariableValue(
|
|
564
|
+
name,
|
|
565
|
+
definition,
|
|
566
|
+
schema
|
|
567
|
+
);
|
|
568
|
+
if (valueOrDefault !== void 0) {
|
|
507
569
|
environmentVariables[name] = _Kernel.parseEnvironmentVariable(
|
|
508
570
|
name,
|
|
509
|
-
|
|
571
|
+
valueOrDefault,
|
|
510
572
|
schema
|
|
511
573
|
);
|
|
574
|
+
} else if (_Kernel.shouldUnsetBlankOptionalEnvironmentVariable(
|
|
575
|
+
name,
|
|
576
|
+
value,
|
|
577
|
+
valueOrDefault,
|
|
578
|
+
schema
|
|
579
|
+
)) {
|
|
580
|
+
environmentVariables[name] = void 0;
|
|
512
581
|
}
|
|
513
582
|
}
|
|
514
583
|
return {
|
|
@@ -1012,6 +1081,45 @@ var InMemoryPubSub = class {
|
|
|
1012
1081
|
}
|
|
1013
1082
|
};
|
|
1014
1083
|
|
|
1084
|
+
// src/adapters/ui/express/ExpressControllerResolver.ts
|
|
1085
|
+
var ExpressControllerResolver = class {
|
|
1086
|
+
constructor(kernel, controllers) {
|
|
1087
|
+
this.kernel = kernel;
|
|
1088
|
+
this.controllers = new Set(controllers);
|
|
1089
|
+
}
|
|
1090
|
+
kernel;
|
|
1091
|
+
controllerInstances = /* @__PURE__ */ new Map();
|
|
1092
|
+
controllers;
|
|
1093
|
+
createControllerInstance(ClassDefinition) {
|
|
1094
|
+
const Controller = ClassDefinition;
|
|
1095
|
+
return new Controller();
|
|
1096
|
+
}
|
|
1097
|
+
getCachedController(ClassDefinition) {
|
|
1098
|
+
const cached = this.controllerInstances.get(ClassDefinition);
|
|
1099
|
+
if (cached) {
|
|
1100
|
+
return cached;
|
|
1101
|
+
}
|
|
1102
|
+
const instance = this.createControllerInstance(ClassDefinition);
|
|
1103
|
+
this.controllerInstances.set(ClassDefinition, instance);
|
|
1104
|
+
return instance;
|
|
1105
|
+
}
|
|
1106
|
+
isKnownController(ClassDefinition) {
|
|
1107
|
+
return this.controllers.has(ClassDefinition);
|
|
1108
|
+
}
|
|
1109
|
+
canResolveService(ClassDefinition) {
|
|
1110
|
+
return this.kernel.di.hasService?.(ClassDefinition) === true;
|
|
1111
|
+
}
|
|
1112
|
+
get(ClassDefinition) {
|
|
1113
|
+
if (!this.canResolveService(ClassDefinition)) {
|
|
1114
|
+
if (this.isKnownController(ClassDefinition)) {
|
|
1115
|
+
return this.getCachedController(ClassDefinition);
|
|
1116
|
+
}
|
|
1117
|
+
return void 0;
|
|
1118
|
+
}
|
|
1119
|
+
return this.kernel.di.getService(ClassDefinition);
|
|
1120
|
+
}
|
|
1121
|
+
};
|
|
1122
|
+
|
|
1015
1123
|
// src/adapters/ui/express/ExpressKernelServer.ts
|
|
1016
1124
|
var import_node_module = require("module");
|
|
1017
1125
|
var import_node_path3 = __toESM(require("path"), 1);
|
|
@@ -1050,16 +1158,19 @@ var ExpressKernelServer = class {
|
|
|
1050
1158
|
copy(items) {
|
|
1051
1159
|
return [...items ?? []];
|
|
1052
1160
|
}
|
|
1053
|
-
configureControllerContainer() {
|
|
1161
|
+
configureControllerContainer(controllers) {
|
|
1054
1162
|
const { useContainer } = this.getRoutingControllers();
|
|
1163
|
+
const resolver = new ExpressControllerResolver(
|
|
1164
|
+
this.options.kernel,
|
|
1165
|
+
controllers
|
|
1166
|
+
);
|
|
1055
1167
|
useContainer(
|
|
1056
1168
|
{
|
|
1057
|
-
|
|
1058
|
-
get: (ClassDefinition) => this.options.kernel.di.getService(ClassDefinition)
|
|
1169
|
+
get: (ClassDefinition) => resolver.get(ClassDefinition)
|
|
1059
1170
|
},
|
|
1060
1171
|
{
|
|
1061
1172
|
fallback: true,
|
|
1062
|
-
fallbackOnErrors:
|
|
1173
|
+
fallbackOnErrors: false
|
|
1063
1174
|
}
|
|
1064
1175
|
);
|
|
1065
1176
|
}
|
|
@@ -1077,8 +1188,11 @@ var ExpressKernelServer = class {
|
|
|
1077
1188
|
}
|
|
1078
1189
|
defaultErrorHandler() {
|
|
1079
1190
|
return (error, request, response, next) => {
|
|
1080
|
-
void next;
|
|
1081
1191
|
void request;
|
|
1192
|
+
if (response.headersSent) {
|
|
1193
|
+
next(error);
|
|
1194
|
+
return;
|
|
1195
|
+
}
|
|
1082
1196
|
response.status(500).json({
|
|
1083
1197
|
error: error instanceof Error ? error.message : String(error)
|
|
1084
1198
|
});
|
|
@@ -1189,7 +1303,7 @@ var ExpressKernelServer = class {
|
|
|
1189
1303
|
this.applyMiddlewares(app, this.preControllerMiddlewares);
|
|
1190
1304
|
await this.runHooks(this.beforeControllersHooks, app);
|
|
1191
1305
|
await this.runPhaseHooks("beforeControllers", app);
|
|
1192
|
-
this.configureControllerContainer();
|
|
1306
|
+
this.configureControllerContainer(controllers);
|
|
1193
1307
|
useExpressServer(app, {
|
|
1194
1308
|
...this.options.routingControllersOptions,
|
|
1195
1309
|
controllers,
|
|
@@ -1379,6 +1493,7 @@ var Route = class extends KernelRoute {
|
|
|
1379
1493
|
ConsumerMiddlewarePipeline,
|
|
1380
1494
|
CorrelationConsumerMiddleware,
|
|
1381
1495
|
DefaultPublisherHookErrorPolicy,
|
|
1496
|
+
ExpressControllerResolver,
|
|
1382
1497
|
ExpressKernelServer,
|
|
1383
1498
|
HttpErrorHandler,
|
|
1384
1499
|
IdempotencyConsumerMiddleware,
|