@haskou/ddd-kernel 3.0.0 → 4.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 +1 -1
- package/dist/{RetryPredicate-Cch9NXV3.d.ts → RetryPredicate-BR91-irp.d.ts} +4 -6
- package/dist/{RetryPredicate-cPJPlGbJ.d.cts → RetryPredicate-Drg7hU3-.d.cts} +4 -6
- package/dist/{ServiceClass-Bj3G71L8.d.ts → ServiceClass-C-ZCUQWE.d.ts} +1 -1
- package/dist/{ServiceClass-nnDgfgdL.d.cts → ServiceClass-U0Vk46dN.d.cts} +1 -1
- package/dist/{ShutdownHook-Cx1Rc40s.d.ts → ShutdownHook-BCQgEMUI.d.ts} +1 -1
- package/dist/{ShutdownHook-Ho-CeLu8.d.cts → ShutdownHook-CCtg4Ypg.d.cts} +1 -1
- package/dist/adapters/index.cjs +27 -34
- 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 +27 -34
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/pubsub/amqp/index.cjs +22 -6
- package/dist/adapters/pubsub/amqp/index.cjs.map +1 -1
- package/dist/adapters/pubsub/amqp/index.js +22 -6
- package/dist/adapters/pubsub/amqp/index.js.map +1 -1
- package/dist/adapters/pubsub/index.cjs +27 -28
- package/dist/adapters/pubsub/index.cjs.map +1 -1
- package/dist/adapters/pubsub/index.d.cts +3 -6
- package/dist/adapters/pubsub/index.d.ts +3 -6
- package/dist/adapters/pubsub/index.js +27 -28
- package/dist/adapters/pubsub/index.js.map +1 -1
- package/dist/adapters/ui/express/index.cjs +0 -6
- package/dist/adapters/ui/express/index.cjs.map +1 -1
- package/dist/adapters/ui/express/index.d.cts +2 -12
- package/dist/adapters/ui/express/index.d.ts +2 -12
- package/dist/adapters/ui/express/index.js +0 -6
- package/dist/adapters/ui/express/index.js.map +1 -1
- package/dist/adapters/ui/index.cjs +22 -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 +22 -12
- package/dist/adapters/ui/index.js.map +1 -1
- package/dist/adapters/ui/routes/index.cjs +22 -6
- package/dist/adapters/ui/routes/index.cjs.map +1 -1
- package/dist/adapters/ui/routes/index.js +22 -6
- 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 +22 -6
- 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 +22 -6
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/dependency-injection/index.cjs +22 -6
- package/dist/infrastructure/dependency-injection/index.cjs.map +1 -1
- package/dist/infrastructure/dependency-injection/index.d.cts +6 -2
- package/dist/infrastructure/dependency-injection/index.d.ts +6 -2
- package/dist/infrastructure/dependency-injection/index.js +22 -6
- package/dist/infrastructure/dependency-injection/index.js.map +1 -1
- package/dist/infrastructure/express/index.cjs +0 -6
- package/dist/infrastructure/express/index.cjs.map +1 -1
- package/dist/infrastructure/express/index.d.cts +2 -2
- package/dist/infrastructure/express/index.d.ts +2 -2
- package/dist/infrastructure/express/index.js +0 -6
- package/dist/infrastructure/express/index.js.map +1 -1
- package/dist/infrastructure/scheduler/index.cjs +22 -6
- package/dist/infrastructure/scheduler/index.cjs.map +1 -1
- package/dist/infrastructure/scheduler/index.js +22 -6
- package/dist/infrastructure/scheduler/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@ The package separates stable contracts from concrete infrastructure:
|
|
|
42
42
|
at the composition root.
|
|
43
43
|
|
|
44
44
|
Constructor injection is the preferred application pattern. Direct service
|
|
45
|
-
lookup
|
|
45
|
+
lookup is available for composition and integration boundaries, but it is
|
|
46
46
|
not the primary dependency model.
|
|
47
47
|
|
|
48
48
|
## Documentation
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { C as ConsumerExecutionContext } from './ShutdownHook-
|
|
1
|
+
import { C as ConsumerExecutionContext } from './ShutdownHook-BCQgEMUI.js';
|
|
2
2
|
|
|
3
3
|
interface IdempotencyStore {
|
|
4
|
-
claim
|
|
5
|
-
commit
|
|
6
|
-
release
|
|
7
|
-
has(key: string): Promise<boolean> | boolean;
|
|
8
|
-
mark(key: string): Promise<void> | void;
|
|
4
|
+
claim(key: string): Promise<boolean> | boolean;
|
|
5
|
+
commit(key: string): Promise<void> | void;
|
|
6
|
+
release(key: string): Promise<void> | void;
|
|
9
7
|
}
|
|
10
8
|
|
|
11
9
|
type RetryDelayResolver = (attempt: number, error: unknown, context: ConsumerExecutionContext) => number | Promise<number>;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { C as ConsumerExecutionContext } from './ShutdownHook-
|
|
1
|
+
import { C as ConsumerExecutionContext } from './ShutdownHook-CCtg4Ypg.cjs';
|
|
2
2
|
|
|
3
3
|
interface IdempotencyStore {
|
|
4
|
-
claim
|
|
5
|
-
commit
|
|
6
|
-
release
|
|
7
|
-
has(key: string): Promise<boolean> | boolean;
|
|
8
|
-
mark(key: string): Promise<void> | void;
|
|
4
|
+
claim(key: string): Promise<boolean> | boolean;
|
|
5
|
+
commit(key: string): Promise<void> | void;
|
|
6
|
+
release(key: string): Promise<void> | void;
|
|
9
7
|
}
|
|
10
8
|
|
|
11
9
|
type RetryDelayResolver = (attempt: number, error: unknown, context: ConsumerExecutionContext) => number | Promise<number>;
|
|
@@ -31,7 +31,6 @@ interface DependencyInjectionOptions {
|
|
|
31
31
|
declare class DependencyInjection implements ServiceResolver {
|
|
32
32
|
private readonly options;
|
|
33
33
|
private static configuredInstance;
|
|
34
|
-
private autowire;
|
|
35
34
|
private loader;
|
|
36
35
|
private readonly container;
|
|
37
36
|
private readonly overrideTokenIds;
|
|
@@ -58,6 +57,7 @@ declare class DependencyInjection implements ServiceResolver {
|
|
|
58
57
|
private applyFactoryOverride;
|
|
59
58
|
private applyValueOverride;
|
|
60
59
|
private applyOverrides;
|
|
60
|
+
private trackAutowireAliasIds;
|
|
61
61
|
private processAutowire;
|
|
62
62
|
private registerParentAliases;
|
|
63
63
|
compile(): Promise<void>;
|
|
@@ -31,7 +31,6 @@ interface DependencyInjectionOptions {
|
|
|
31
31
|
declare class DependencyInjection implements ServiceResolver {
|
|
32
32
|
private readonly options;
|
|
33
33
|
private static configuredInstance;
|
|
34
|
-
private autowire;
|
|
35
34
|
private loader;
|
|
36
35
|
private readonly container;
|
|
37
36
|
private readonly overrideTokenIds;
|
|
@@ -58,6 +57,7 @@ declare class DependencyInjection implements ServiceResolver {
|
|
|
58
57
|
private applyFactoryOverride;
|
|
59
58
|
private applyValueOverride;
|
|
60
59
|
private applyOverrides;
|
|
60
|
+
private trackAutowireAliasIds;
|
|
61
61
|
private processAutowire;
|
|
62
62
|
private registerParentAliases;
|
|
63
63
|
compile(): Promise<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { D as DomainEvent } from './DomainEvent-C2OvBSCS.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-C-ZCUQWE.js';
|
|
4
4
|
import { Initializer, Runtime } from './infrastructure/lifecycle/index.js';
|
|
5
5
|
import { a as Scheduler } from './Scheduler-Cm24s3-v.js';
|
|
6
6
|
import { K as KernelLogger } from './KernelLogger-BESOFrpW.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { D as DomainEvent } from './DomainEvent-C2OvBSCS.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-U0Vk46dN.cjs';
|
|
4
4
|
import { Initializer, Runtime } from './infrastructure/lifecycle/index.cjs';
|
|
5
5
|
import { a as Scheduler } from './Scheduler-Cm24s3-v.cjs';
|
|
6
6
|
import { K as KernelLogger } from './KernelLogger-BESOFrpW.cjs';
|
package/dist/adapters/index.cjs
CHANGED
|
@@ -167,7 +167,6 @@ var DependencyInjection = class _DependencyInjection {
|
|
|
167
167
|
}
|
|
168
168
|
options;
|
|
169
169
|
static configuredInstance;
|
|
170
|
-
autowire;
|
|
171
170
|
loader;
|
|
172
171
|
container;
|
|
173
172
|
overrideTokenIds = /* @__PURE__ */ new Map();
|
|
@@ -335,14 +334,31 @@ var DependencyInjection = class _DependencyInjection {
|
|
|
335
334
|
this.applyValueOverride(override);
|
|
336
335
|
}
|
|
337
336
|
}
|
|
338
|
-
|
|
337
|
+
trackAutowireAliasIds(autowire) {
|
|
338
|
+
const internals = autowire;
|
|
339
|
+
const createServiceId = internals._getLegacyServiceId.bind(autowire);
|
|
340
|
+
const aliasIds = /* @__PURE__ */ new Set();
|
|
341
|
+
internals._getLegacyServiceId = async (...args) => {
|
|
342
|
+
const id = await createServiceId(...args);
|
|
343
|
+
if (!this.container.hasAlias(id) && !this.container.hasDefinition(id)) {
|
|
344
|
+
aliasIds.add(id);
|
|
345
|
+
}
|
|
346
|
+
return id;
|
|
347
|
+
};
|
|
348
|
+
return aliasIds;
|
|
349
|
+
}
|
|
350
|
+
async processAutowire(autowire) {
|
|
339
351
|
const previousLogger = this.container.logger;
|
|
352
|
+
const autowireAliasIds = this.trackAutowireAliasIds(autowire);
|
|
340
353
|
this.container.logger = new AutowireWarningFilter(previousLogger);
|
|
341
354
|
try {
|
|
342
|
-
await
|
|
355
|
+
await autowire.process();
|
|
343
356
|
} finally {
|
|
344
357
|
this.container.logger = previousLogger;
|
|
345
358
|
}
|
|
359
|
+
for (const id of autowireAliasIds) {
|
|
360
|
+
this.aliases.delete(id);
|
|
361
|
+
}
|
|
346
362
|
}
|
|
347
363
|
registerParentAliases() {
|
|
348
364
|
for (const [id, definition] of this.definitions.entries()) {
|
|
@@ -355,12 +371,12 @@ var DependencyInjection = class _DependencyInjection {
|
|
|
355
371
|
async compile() {
|
|
356
372
|
if (this.options.containerBuild) {
|
|
357
373
|
await this.ensureFolderExists(this.options.servicesYamlPath);
|
|
358
|
-
|
|
359
|
-
|
|
374
|
+
const autowire = new import_node_dependency_injection.Autowire(this.container);
|
|
375
|
+
autowire.serviceFile = new import_node_dependency_injection.ServiceFile(
|
|
360
376
|
this.options.servicesYamlPath,
|
|
361
377
|
false
|
|
362
378
|
);
|
|
363
|
-
await this.processAutowire();
|
|
379
|
+
await this.processAutowire(autowire);
|
|
364
380
|
} else {
|
|
365
381
|
this.loader = new import_node_dependency_injection.YamlFileLoader(this.container);
|
|
366
382
|
await this.loader.load(this.options.servicesYamlPath);
|
|
@@ -840,34 +856,20 @@ var IdempotencyConsumerMiddleware = class {
|
|
|
840
856
|
this.options = options;
|
|
841
857
|
}
|
|
842
858
|
options;
|
|
843
|
-
async
|
|
844
|
-
const
|
|
859
|
+
async handle(event, next, context) {
|
|
860
|
+
const key = this.options.key?.(event, context) ?? context.eventId;
|
|
861
|
+
const claimed = await this.options.store.claim(key);
|
|
845
862
|
if (!claimed) {
|
|
846
863
|
return;
|
|
847
864
|
}
|
|
848
865
|
try {
|
|
849
866
|
await next();
|
|
850
|
-
await
|
|
867
|
+
await this.options.store.commit(key);
|
|
851
868
|
} catch (error) {
|
|
852
|
-
await this.options.store.release
|
|
869
|
+
await this.options.store.release(key);
|
|
853
870
|
throw error;
|
|
854
871
|
}
|
|
855
872
|
}
|
|
856
|
-
async handleLegacyKey(key, next) {
|
|
857
|
-
if (await this.options.store.has(key)) {
|
|
858
|
-
return;
|
|
859
|
-
}
|
|
860
|
-
await next();
|
|
861
|
-
await this.options.store.mark(key);
|
|
862
|
-
}
|
|
863
|
-
async handle(event, next, context) {
|
|
864
|
-
const key = this.options.key?.(event, context) ?? context.eventId;
|
|
865
|
-
if (this.options.store.claim) {
|
|
866
|
-
await this.handleClaimedKey(key, next);
|
|
867
|
-
} else {
|
|
868
|
-
await this.handleLegacyKey(key, next);
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
873
|
};
|
|
872
874
|
|
|
873
875
|
// src/adapters/pubsub/InMemoryIdempotencyStore.ts
|
|
@@ -891,9 +893,6 @@ var InMemoryIdempotencyStore = class {
|
|
|
891
893
|
has(key) {
|
|
892
894
|
return this.handledKeys.has(key);
|
|
893
895
|
}
|
|
894
|
-
mark(key) {
|
|
895
|
-
this.handledKeys.add(key);
|
|
896
|
-
}
|
|
897
896
|
};
|
|
898
897
|
|
|
899
898
|
// src/adapters/pubsub/PublisherHookPipeline.ts
|
|
@@ -1122,8 +1121,6 @@ var ExpressKernelServer = class {
|
|
|
1122
1121
|
options.postControllerMiddlewares
|
|
1123
1122
|
);
|
|
1124
1123
|
this.preControllerMiddlewares = this.copy(options.preControllerMiddlewares);
|
|
1125
|
-
this.staticHooks = this.copy(options.staticHooks);
|
|
1126
|
-
this.swaggerHooks = this.copy(options.swaggerHooks);
|
|
1127
1124
|
}
|
|
1128
1125
|
options;
|
|
1129
1126
|
applicationRequire = (0, import_node_module.createRequire)(
|
|
@@ -1139,8 +1136,6 @@ var ExpressKernelServer = class {
|
|
|
1139
1136
|
postControllerMiddlewares;
|
|
1140
1137
|
preControllerMiddlewares;
|
|
1141
1138
|
serverInstance;
|
|
1142
|
-
staticHooks;
|
|
1143
|
-
swaggerHooks;
|
|
1144
1139
|
copy(items) {
|
|
1145
1140
|
return [...items ?? []];
|
|
1146
1141
|
}
|
|
@@ -1298,8 +1293,6 @@ var ExpressKernelServer = class {
|
|
|
1298
1293
|
this.applyMiddlewares(app, this.postControllerMiddlewares);
|
|
1299
1294
|
await this.runHooks(this.afterControllersHooks, app);
|
|
1300
1295
|
await this.runPhaseHooks("afterControllers", app);
|
|
1301
|
-
await this.runHooks(this.swaggerHooks, app);
|
|
1302
|
-
await this.runHooks(this.staticHooks, app);
|
|
1303
1296
|
await this.runPhaseHooks("beforeErrors", app);
|
|
1304
1297
|
this.applyErrorHandlers(app);
|
|
1305
1298
|
this.appInstance = app;
|