@haskou/ddd-kernel 2.0.0 → 2.0.2
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/{RetryPredicate-DNdxY_KR.d.cts → RetryPredicate-BFGD3FUP.d.cts} +1 -1
- package/dist/{RetryPredicate-CD9n6cE8.d.ts → RetryPredicate-CuL59f8-.d.ts} +1 -1
- package/dist/{ServiceClass-BkEHcXDi.d.cts → ServiceClass-Cv5KbUSf.d.cts} +1 -0
- package/dist/{ServiceClass-Bq_fBC5R.d.ts → ServiceClass-DXDAxvao.d.ts} +1 -0
- package/dist/{ShutdownHook-D23WfIIc.d.cts → ShutdownHook-6-YKfmzG.d.cts} +4 -1
- package/dist/{ShutdownHook-CUl7zYwd.d.ts → ShutdownHook-dvsrwsQi.d.ts} +4 -1
- package/dist/adapters/index.cjs +74 -12
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.d.cts +3 -3
- package/dist/adapters/index.d.ts +3 -3
- package/dist/adapters/index.js +74 -12
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/pubsub/amqp/index.cjs +74 -12
- package/dist/adapters/pubsub/amqp/index.cjs.map +1 -1
- package/dist/adapters/pubsub/amqp/index.js +74 -12
- package/dist/adapters/pubsub/amqp/index.js.map +1 -1
- package/dist/adapters/pubsub/index.cjs +74 -12
- package/dist/adapters/pubsub/index.cjs.map +1 -1
- package/dist/adapters/pubsub/index.d.cts +3 -3
- package/dist/adapters/pubsub/index.d.ts +3 -3
- package/dist/adapters/pubsub/index.js +74 -12
- package/dist/adapters/pubsub/index.js.map +1 -1
- package/dist/adapters/ui/express/index.d.cts +2 -2
- package/dist/adapters/ui/express/index.d.ts +2 -2
- package/dist/adapters/ui/index.cjs +74 -12
- package/dist/adapters/ui/index.cjs.map +1 -1
- package/dist/adapters/ui/index.d.cts +2 -2
- package/dist/adapters/ui/index.d.ts +2 -2
- package/dist/adapters/ui/index.js +74 -12
- package/dist/adapters/ui/index.js.map +1 -1
- package/dist/adapters/ui/routes/index.cjs +74 -12
- package/dist/adapters/ui/routes/index.cjs.map +1 -1
- package/dist/adapters/ui/routes/index.js +74 -12
- package/dist/adapters/ui/routes/index.js.map +1 -1
- package/dist/contracts/index.d.cts +3 -3
- package/dist/contracts/index.d.ts +3 -3
- package/dist/contracts/kernel/index.d.cts +3 -3
- package/dist/contracts/kernel/index.d.ts +3 -3
- package/dist/index.cjs +74 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +74 -12
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/dependency-injection/index.cjs +38 -1
- package/dist/infrastructure/dependency-injection/index.cjs.map +1 -1
- package/dist/infrastructure/dependency-injection/index.d.cts +12 -2
- package/dist/infrastructure/dependency-injection/index.d.ts +12 -2
- package/dist/infrastructure/dependency-injection/index.js +37 -1
- package/dist/infrastructure/dependency-injection/index.js.map +1 -1
- package/dist/infrastructure/express/index.d.cts +2 -2
- package/dist/infrastructure/express/index.d.ts +2 -2
- package/dist/infrastructure/scheduler/index.cjs +74 -12
- package/dist/infrastructure/scheduler/index.cjs.map +1 -1
- package/dist/infrastructure/scheduler/index.js +74 -12
- package/dist/infrastructure/scheduler/index.js.map +1 -1
- package/package.json +4 -3
|
@@ -59,6 +59,7 @@ declare class DependencyInjection implements ServiceResolver {
|
|
|
59
59
|
private applyFactoryOverride;
|
|
60
60
|
private applyValueOverride;
|
|
61
61
|
private applyOverrides;
|
|
62
|
+
private processAutowire;
|
|
62
63
|
private registerParentAliases;
|
|
63
64
|
compile(): Promise<void>;
|
|
64
65
|
getService<T>(serviceName: unknown): T;
|
|
@@ -59,6 +59,7 @@ declare class DependencyInjection implements ServiceResolver {
|
|
|
59
59
|
private applyFactoryOverride;
|
|
60
60
|
private applyValueOverride;
|
|
61
61
|
private applyOverrides;
|
|
62
|
+
private processAutowire;
|
|
62
63
|
private registerParentAliases;
|
|
63
64
|
compile(): Promise<void>;
|
|
64
65
|
getService<T>(serviceName: unknown): 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-Cv5KbUSf.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-DXDAxvao.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>);
|
package/dist/adapters/index.cjs
CHANGED
|
@@ -120,6 +120,32 @@ var ConsoleKernelLogger = class {
|
|
|
120
120
|
var import_dotenv = __toESM(require("dotenv"), 1);
|
|
121
121
|
var import_node_path2 = __toESM(require("path"), 1);
|
|
122
122
|
|
|
123
|
+
// src/infrastructure/dependency-injection/AutowireWarningFilter.ts
|
|
124
|
+
var AutowireWarningFilter = class {
|
|
125
|
+
constructor(logger) {
|
|
126
|
+
this.logger = logger;
|
|
127
|
+
}
|
|
128
|
+
logger;
|
|
129
|
+
isIgnorableAutowireWarning(message) {
|
|
130
|
+
return message.startsWith(
|
|
131
|
+
"Autowire: file has export default declaration but no runtime default export:"
|
|
132
|
+
) || message.startsWith("Autowire: failed to create definition for undefined:");
|
|
133
|
+
}
|
|
134
|
+
warn(message, ...optionalParams) {
|
|
135
|
+
if (typeof message === "string" && this.isIgnorableAutowireWarning(message)) {
|
|
136
|
+
this.logger.debug?.(`Ignored ${message}`, ...optionalParams);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
this.logger.warn(message, ...optionalParams);
|
|
140
|
+
}
|
|
141
|
+
info(message, ...optionalParams) {
|
|
142
|
+
this.logger.info?.(message, ...optionalParams);
|
|
143
|
+
}
|
|
144
|
+
debug(message, ...optionalParams) {
|
|
145
|
+
this.logger.debug?.(message, ...optionalParams);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
|
|
123
149
|
// src/infrastructure/dependency-injection/DependencyInjection.ts
|
|
124
150
|
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
125
151
|
var import_node_dependency_injection = require("node-dependency-injection");
|
|
@@ -319,6 +345,15 @@ var DependencyInjection = class _DependencyInjection {
|
|
|
319
345
|
this.applyValueOverride(override);
|
|
320
346
|
}
|
|
321
347
|
}
|
|
348
|
+
async processAutowire() {
|
|
349
|
+
const previousLogger = this.container.logger;
|
|
350
|
+
this.container.logger = new AutowireWarningFilter(previousLogger);
|
|
351
|
+
try {
|
|
352
|
+
await this.autowire?.process();
|
|
353
|
+
} finally {
|
|
354
|
+
this.container.logger = previousLogger;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
322
357
|
registerParentAliases() {
|
|
323
358
|
for (const [id, definition] of this.definitions.entries()) {
|
|
324
359
|
if (definition._abstract === true || !definition._parent) {
|
|
@@ -335,7 +370,7 @@ var DependencyInjection = class _DependencyInjection {
|
|
|
335
370
|
this.options.servicesYamlPath,
|
|
336
371
|
false
|
|
337
372
|
);
|
|
338
|
-
await this.
|
|
373
|
+
await this.processAutowire();
|
|
339
374
|
} else {
|
|
340
375
|
this.loader = new import_node_dependency_injection.YamlFileLoader(this.container);
|
|
341
376
|
await this.loader.load(this.options.servicesYamlPath);
|
|
@@ -444,6 +479,13 @@ var Kernel = class _Kernel {
|
|
|
444
479
|
);
|
|
445
480
|
}
|
|
446
481
|
}
|
|
482
|
+
static assertRequiredEnvironmentVariableIsNotBlank(name, value, schema) {
|
|
483
|
+
if (schema[name]?.required === true && value.trim() === "") {
|
|
484
|
+
throw new KernelEnvironmentValidationError(
|
|
485
|
+
`Blank required environment variable "${name}".`
|
|
486
|
+
);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
447
489
|
static assertEnvironmentVariableChoice(name, value, schema) {
|
|
448
490
|
const choices = schema[name]?.choices;
|
|
449
491
|
if (choices && !choices.includes(value)) {
|
|
@@ -466,21 +508,16 @@ var Kernel = class _Kernel {
|
|
|
466
508
|
return false;
|
|
467
509
|
}
|
|
468
510
|
throw new KernelEnvironmentValidationError(
|
|
469
|
-
`Environment variable "${name}"
|
|
511
|
+
`Environment variable "${name}" has invalid boolean value "${value}".`
|
|
470
512
|
);
|
|
471
513
|
}
|
|
472
514
|
static parseNumberEnvironmentVariable(name, value) {
|
|
473
|
-
if (value.trim() === "") {
|
|
474
|
-
throw new KernelEnvironmentValidationError(
|
|
475
|
-
`Environment variable "${name}" must be a number.`
|
|
476
|
-
);
|
|
477
|
-
}
|
|
478
515
|
const parsedValue = Number(value);
|
|
479
516
|
if (Number.isFinite(parsedValue)) {
|
|
480
517
|
return parsedValue;
|
|
481
518
|
}
|
|
482
519
|
throw new KernelEnvironmentValidationError(
|
|
483
|
-
`Environment variable "${name}"
|
|
520
|
+
`Environment variable "${name}" has invalid number value "${value}".`
|
|
484
521
|
);
|
|
485
522
|
}
|
|
486
523
|
static parseEnvironmentVariable(name, value, schema) {
|
|
@@ -498,17 +535,42 @@ var Kernel = class _Kernel {
|
|
|
498
535
|
_Kernel.assertEnvironmentVariableChoice(name, value, schema);
|
|
499
536
|
return value;
|
|
500
537
|
}
|
|
538
|
+
static getEnvironmentVariableValue(name, definition, schema) {
|
|
539
|
+
const value = process.env[name];
|
|
540
|
+
_Kernel.assertRequiredEnvironmentVariable(name, value, schema);
|
|
541
|
+
if (value !== void 0) {
|
|
542
|
+
_Kernel.assertRequiredEnvironmentVariableIsNotBlank(name, value, schema);
|
|
543
|
+
}
|
|
544
|
+
if (value !== void 0 && value.trim() !== "") {
|
|
545
|
+
return value;
|
|
546
|
+
}
|
|
547
|
+
return definition.defaultValue?.toString();
|
|
548
|
+
}
|
|
549
|
+
static shouldUnsetBlankOptionalEnvironmentVariable(name, value, valueOrDefault, schema) {
|
|
550
|
+
return value !== void 0 && value.trim() === "" && valueOrDefault === void 0 && schema[name]?.required !== true;
|
|
551
|
+
}
|
|
501
552
|
static validateEnvironmentVariables(schema) {
|
|
502
553
|
const environmentVariables = {};
|
|
503
554
|
for (const [name, definition] of Object.entries(schema)) {
|
|
504
|
-
const value = process.env[name]
|
|
505
|
-
_Kernel.
|
|
506
|
-
|
|
555
|
+
const value = process.env[name];
|
|
556
|
+
const valueOrDefault = _Kernel.getEnvironmentVariableValue(
|
|
557
|
+
name,
|
|
558
|
+
definition,
|
|
559
|
+
schema
|
|
560
|
+
);
|
|
561
|
+
if (valueOrDefault !== void 0) {
|
|
507
562
|
environmentVariables[name] = _Kernel.parseEnvironmentVariable(
|
|
508
563
|
name,
|
|
509
|
-
|
|
564
|
+
valueOrDefault,
|
|
510
565
|
schema
|
|
511
566
|
);
|
|
567
|
+
} else if (_Kernel.shouldUnsetBlankOptionalEnvironmentVariable(
|
|
568
|
+
name,
|
|
569
|
+
value,
|
|
570
|
+
valueOrDefault,
|
|
571
|
+
schema
|
|
572
|
+
)) {
|
|
573
|
+
environmentVariables[name] = void 0;
|
|
512
574
|
}
|
|
513
575
|
}
|
|
514
576
|
return {
|