@zlink-systems/nestjs 0.30.3 → 0.31.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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export type ZLinkHandlerMessageType = NonNullable<ReturnType<typeof import('../../framework/dist/nest-integration').resolveHandlerMessageType>>;
|
|
1
2
|
import type { RoutingId, Type, ZLinkActor, ZLinkActorFactory, ZLinkApplicationJobQueueOptions, ZLinkCoreHwmOptions, ZLinkDispatchOptions, ZLinkEntrySpot, ZLinkHandlerFilter, ZLinkLocationOptions, ZLinkLocationOptionValues, ZLinkLocationStore, ZLinkRelocationStore, ZLinkSpotRelocationCoordinationMode, ZLinkUserSpotExecutionMode, ZLinkInstanceSpot, ZLinkMessageSerializer, ZLinkMetricsOptions, ZLinkNetworkOptions, ZLinkMessageContext, ZLinkPublishMessageContext, ZLinkRouteMessageContext, ZLinkSpot, ZLinkStreamCompressionOptions, ZLinkTimerOptions } from '@zlink-systems/framework';
|
|
2
3
|
/** Private composition bridge used only by the Nest companion package. */
|
|
3
4
|
export interface ZLinkProviderResolver {
|
|
@@ -287,29 +288,35 @@ export interface ZLinkRouteChannelHandlerOptions {
|
|
|
287
288
|
readonly kind: 'send' | 'request';
|
|
288
289
|
readonly packetName: string;
|
|
289
290
|
readonly handler: ZLinkRouteChannelSendHandler | ZLinkRouteChannelRequestHandler;
|
|
291
|
+
readonly messageType?: ZLinkHandlerMessageType;
|
|
290
292
|
}
|
|
291
293
|
export interface ZLinkRouteChannelSendHandlerRegistration {
|
|
292
294
|
readonly packetName: string;
|
|
293
295
|
readonly handler: ZLinkRouteChannelSendHandler;
|
|
296
|
+
readonly messageType?: ZLinkHandlerMessageType;
|
|
294
297
|
}
|
|
295
298
|
export interface ZLinkRouteChannelRequestHandlerRegistration {
|
|
296
299
|
readonly packetName: string;
|
|
297
300
|
readonly handler: ZLinkRouteChannelRequestHandler;
|
|
301
|
+
readonly messageType?: ZLinkHandlerMessageType;
|
|
298
302
|
}
|
|
299
303
|
export interface ZLinkChannelPublishHandlerRegistration {
|
|
300
304
|
readonly packetName: string;
|
|
305
|
+
readonly messageType?: ZLinkHandlerMessageType;
|
|
301
306
|
readonly handler: {
|
|
302
307
|
handle(payload: unknown, context: ZLinkPublishMessageContext): Promise<void>;
|
|
303
308
|
};
|
|
304
309
|
}
|
|
305
310
|
export interface ZLinkChannelRequestHandlerRegistration {
|
|
306
311
|
readonly packetName: string;
|
|
312
|
+
readonly messageType?: ZLinkHandlerMessageType;
|
|
307
313
|
readonly handler: {
|
|
308
314
|
handle(payload: unknown, context: ZLinkMessageContext): Promise<unknown>;
|
|
309
315
|
};
|
|
310
316
|
}
|
|
311
317
|
export interface ZLinkChannelSendHandlerRegistration {
|
|
312
318
|
readonly packetName: string;
|
|
319
|
+
readonly messageType?: ZLinkHandlerMessageType;
|
|
313
320
|
readonly handler: {
|
|
314
321
|
handle(payload: unknown, context: ZLinkMessageContext): Promise<void>;
|
|
315
322
|
};
|
|
@@ -325,18 +332,21 @@ export interface ZLinkEntrySpotPacketHandlerRegistration {
|
|
|
325
332
|
readonly entrySpotType: Type<ZLinkEntrySpot>;
|
|
326
333
|
readonly handlerType: Type;
|
|
327
334
|
readonly packetName?: string;
|
|
335
|
+
readonly messageType?: ZLinkHandlerMessageType;
|
|
328
336
|
}
|
|
329
337
|
export interface ZLinkEntrySpotSubscriptionHandlerRegistration {
|
|
330
338
|
readonly entrySpotType: Type<ZLinkEntrySpot>;
|
|
331
339
|
readonly handlerType: Type;
|
|
332
340
|
readonly channelName: string;
|
|
333
341
|
readonly topic: string;
|
|
342
|
+
readonly messageType?: ZLinkHandlerMessageType;
|
|
334
343
|
}
|
|
335
344
|
export interface ZLinkEntrySpotActorSendHandlerRegistration {
|
|
336
345
|
readonly entrySpotType: Type<ZLinkEntrySpot>;
|
|
337
346
|
readonly actorType: Type<ZLinkActor>;
|
|
338
347
|
readonly handlerType: Type;
|
|
339
348
|
readonly packetName: string;
|
|
349
|
+
readonly messageType?: ZLinkHandlerMessageType;
|
|
340
350
|
}
|
|
341
351
|
export interface ZLinkEntrySpotActorRequestHandlerRegistration extends ZLinkEntrySpotActorSendHandlerRegistration {
|
|
342
352
|
}
|
|
@@ -351,18 +361,21 @@ export interface ZLinkSpotPacketHandlerRegistration {
|
|
|
351
361
|
readonly spotType: Type<ZLinkSpot>;
|
|
352
362
|
readonly handlerType: Type;
|
|
353
363
|
readonly packetName?: string;
|
|
364
|
+
readonly messageType?: ZLinkHandlerMessageType;
|
|
354
365
|
}
|
|
355
366
|
export interface ZLinkSpotSubscriptionHandlerRegistration {
|
|
356
367
|
readonly spotType: Type<ZLinkSpot>;
|
|
357
368
|
readonly handlerType: Type;
|
|
358
369
|
readonly channelName: string;
|
|
359
370
|
readonly topic: string;
|
|
371
|
+
readonly messageType?: ZLinkHandlerMessageType;
|
|
360
372
|
}
|
|
361
373
|
export interface ZLinkSpotActorSendHandlerRegistration {
|
|
362
374
|
readonly spotType: Type<ZLinkSpot>;
|
|
363
375
|
readonly actorType: Type<ZLinkActor>;
|
|
364
376
|
readonly handlerType: Type;
|
|
365
377
|
readonly packetName: string;
|
|
378
|
+
readonly messageType?: ZLinkHandlerMessageType;
|
|
366
379
|
}
|
|
367
380
|
export interface ZLinkSpotActorRequestHandlerRegistration extends ZLinkSpotActorSendHandlerRegistration {
|
|
368
381
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ZLinkHandlerMessageType } from './framework-integration-contracts';
|
|
1
2
|
import type { Type, ZLinkActorClient, ZLinkActorManager, ZLinkChannelClient, ZLinkCodecRegistrar, ZLinkCodecRegistryBuilder, ZLinkDispatchOptions, ZLinkDispatchOptionsBuilder, ZLinkInboundDispatchOptions, ZLinkLocationOptionValues, ZLinkLocationOptions, ZLinkMessageContext, ZLinkEntrySpot, ZLinkFanoutClient, ZLinkHandlerFilterContext, ZLinkRouteClient, ZLinkSpot, ZLinkSpotManager, ZLinkSpotOutbound, ZLinkSpotPublisherClient, ZLinkStreamCompressionBuilder, ZLinkStreamCompressionCodec } from '@zlink-systems/framework';
|
|
2
3
|
import type { ZLinkHttpExecutionScheduler } from '@zlink-systems/http-client';
|
|
3
4
|
import type { ZLinkCodecSerializerRegistration, ZLinkFrameworkRegistration, ZLinkFrameworkRegistrationOptions, ZLinkNestIntegrationRuntimeHost, ZLinkProviderResolver, ZLinkStreamCodecRegistration } from './framework-integration-contracts';
|
|
@@ -6,6 +7,7 @@ interface HandlerResolver {
|
|
|
6
7
|
resolve<T>(type: Type<T>): Promise<T>;
|
|
7
8
|
}
|
|
8
9
|
interface FrameworkIntegrationModule {
|
|
10
|
+
resolveHandlerMessageType(handlerType: Type): ZLinkHandlerMessageType | undefined;
|
|
9
11
|
ZLinkSpotActorSend(packetName?: string): MethodDecorator;
|
|
10
12
|
ZLinkSpotActorRequest(packetName?: string): MethodDecorator;
|
|
11
13
|
disposeIntegrationHandler(instance: unknown): Promise<void>;
|
package/dist/handler-adapters.js
CHANGED
|
@@ -54,8 +54,10 @@ function createManualSendHandlers(handlerTypes, moduleRef, factories = new Map()
|
|
|
54
54
|
function createManualHandlerRegistrations(handlerTypes, moduleRef, factories, result) {
|
|
55
55
|
return (handlerTypes ?? []).map((registration) => {
|
|
56
56
|
const factory = (0, providers_1.registeredNestHandlerFactory)(factories, registration.handlerType, moduleRef);
|
|
57
|
+
const messageType = framework_loader_1.framework.resolveHandlerMessageType(registration.handlerType);
|
|
57
58
|
return {
|
|
58
59
|
packetName: registration.packetName,
|
|
60
|
+
...(messageType === undefined ? {} : { messageType }),
|
|
59
61
|
handler: {
|
|
60
62
|
async handle(payload, context) {
|
|
61
63
|
return result(await invokeManualHandler(moduleRef, registration.handlerType, factory, payload, context));
|
|
@@ -67,8 +69,10 @@ function createManualHandlerRegistrations(handlerTypes, moduleRef, factories, re
|
|
|
67
69
|
function createDiscoveredHandlerRegistrations(providerRefs, handlerGroups, kind, moduleRef, factories, createHandler) {
|
|
68
70
|
const descriptors = createDiscoveredHandlerDescriptors(providerRefs, handlerGroups, kind);
|
|
69
71
|
return descriptors.map(({ ref, metadata }) => {
|
|
72
|
+
const messageType = framework_loader_1.framework.resolveHandlerMessageType(ref.handlerKey);
|
|
70
73
|
return {
|
|
71
74
|
packetName: metadata.packetName,
|
|
75
|
+
...(messageType === undefined ? {} : { messageType }),
|
|
72
76
|
handler: createHandler(ref, metadata, (0, providers_1.registeredNestHandlerFactory)(factories, ref.handlerKey, moduleRef))
|
|
73
77
|
};
|
|
74
78
|
});
|
|
@@ -45,7 +45,10 @@ class SpotNodeHandlerRegistry {
|
|
|
45
45
|
const packetName = registration.packetName ?? registration.handlerType.name;
|
|
46
46
|
this.assertUnique(node.entrySpotPacketHandlers, (existing) => existing.entrySpotType === registration.entrySpotType &&
|
|
47
47
|
(existing.packetName ?? existing.handlerType.name) === packetName, `Duplicate Entry Spot packet handler '${registration.entrySpotType.name}:${packetName}'.`);
|
|
48
|
-
node.entrySpotPacketHandlers = [
|
|
48
|
+
node.entrySpotPacketHandlers = [
|
|
49
|
+
...(node.entrySpotPacketHandlers ?? []),
|
|
50
|
+
ensureSpotRegistrationMessageType(registration)
|
|
51
|
+
];
|
|
49
52
|
}
|
|
50
53
|
addEntrySpotSubscription(node, registration) {
|
|
51
54
|
this.assertUnique(node.entrySpotSubscriptionHandlers, (existing) => existing.entrySpotType === registration.entrySpotType &&
|
|
@@ -53,33 +56,43 @@ class SpotNodeHandlerRegistry {
|
|
|
53
56
|
existing.topic === registration.topic, `Duplicate Entry Spot subscription handler '${registration.entrySpotType.name}:${registration.channelName}:${registration.topic}'.`);
|
|
54
57
|
node.entrySpotSubscriptionHandlers = [
|
|
55
58
|
...(node.entrySpotSubscriptionHandlers ?? []),
|
|
56
|
-
registration
|
|
59
|
+
ensureSpotRegistrationMessageType(registration)
|
|
57
60
|
];
|
|
58
61
|
}
|
|
59
62
|
addSpotPacket(node, registration) {
|
|
60
63
|
const packetName = registration.packetName ?? registration.handlerType.name;
|
|
61
64
|
this.assertUnique(node.spotPacketHandlers, (existing) => existing.spotType === registration.spotType &&
|
|
62
65
|
(existing.packetName ?? existing.handlerType.name) === packetName, `Duplicate SPOT packet handler '${registration.spotType.name}:${packetName}'.`);
|
|
63
|
-
node.spotPacketHandlers = [
|
|
66
|
+
node.spotPacketHandlers = [
|
|
67
|
+
...(node.spotPacketHandlers ?? []),
|
|
68
|
+
ensureSpotRegistrationMessageType(registration)
|
|
69
|
+
];
|
|
64
70
|
}
|
|
65
71
|
addSpotSubscription(node, registration) {
|
|
66
72
|
this.assertUnique(node.spotSubscriptionHandlers, (existing) => existing.spotType === registration.spotType &&
|
|
67
73
|
existing.channelName === registration.channelName &&
|
|
68
74
|
existing.topic === registration.topic, `Duplicate SPOT subscription handler '${registration.spotType.name}:${registration.channelName}:${registration.topic}'.`);
|
|
69
|
-
node.spotSubscriptionHandlers = [
|
|
75
|
+
node.spotSubscriptionHandlers = [
|
|
76
|
+
...(node.spotSubscriptionHandlers ?? []),
|
|
77
|
+
ensureSpotRegistrationMessageType(registration)
|
|
78
|
+
];
|
|
70
79
|
}
|
|
71
80
|
addEntrySpotActor(node, kind, registration) {
|
|
72
81
|
const existing = kind === 'send' ? node.entrySpotActorSendHandlers : node.entrySpotActorRequestHandlers;
|
|
73
82
|
this.assertUnique(existing, (handler) => handler.entrySpotType === registration.entrySpotType &&
|
|
74
83
|
handler.actorType === registration.actorType &&
|
|
75
84
|
handler.packetName === registration.packetName, `Duplicate Entry Spot actor handler '${registration.entrySpotType.name}:${registration.actorType.name}:${registration.packetName}'.`);
|
|
85
|
+
const typedRegistration = ensureSpotRegistrationMessageType(registration);
|
|
76
86
|
if (kind === 'send') {
|
|
77
|
-
node.entrySpotActorSendHandlers = [
|
|
87
|
+
node.entrySpotActorSendHandlers = [
|
|
88
|
+
...(node.entrySpotActorSendHandlers ?? []),
|
|
89
|
+
typedRegistration
|
|
90
|
+
];
|
|
78
91
|
}
|
|
79
92
|
else {
|
|
80
93
|
node.entrySpotActorRequestHandlers = [
|
|
81
94
|
...(node.entrySpotActorRequestHandlers ?? []),
|
|
82
|
-
|
|
95
|
+
typedRegistration
|
|
83
96
|
];
|
|
84
97
|
}
|
|
85
98
|
}
|
|
@@ -88,11 +101,12 @@ class SpotNodeHandlerRegistry {
|
|
|
88
101
|
this.assertUnique(existing, (handler) => handler.spotType === registration.spotType &&
|
|
89
102
|
handler.actorType === registration.actorType &&
|
|
90
103
|
handler.packetName === registration.packetName, `Duplicate SPOT actor handler '${registration.spotType.name}:${registration.actorType.name}:${registration.packetName}'.`);
|
|
104
|
+
const typedRegistration = ensureSpotRegistrationMessageType(registration);
|
|
91
105
|
if (kind === 'send') {
|
|
92
|
-
node.spotActorSendHandlers = [...(node.spotActorSendHandlers ?? []),
|
|
106
|
+
node.spotActorSendHandlers = [...(node.spotActorSendHandlers ?? []), typedRegistration];
|
|
93
107
|
}
|
|
94
108
|
else {
|
|
95
|
-
node.spotActorRequestHandlers = [...(node.spotActorRequestHandlers ?? []),
|
|
109
|
+
node.spotActorRequestHandlers = [...(node.spotActorRequestHandlers ?? []), typedRegistration];
|
|
96
110
|
}
|
|
97
111
|
}
|
|
98
112
|
requireTargets(predicate, missingMessage) {
|
|
@@ -109,3 +123,10 @@ class SpotNodeHandlerRegistry {
|
|
|
109
123
|
}
|
|
110
124
|
}
|
|
111
125
|
exports.SpotNodeHandlerRegistry = SpotNodeHandlerRegistry;
|
|
126
|
+
function ensureSpotRegistrationMessageType(registration) {
|
|
127
|
+
const messageType = framework_loader_1.framework.resolveHandlerMessageType(registration.handlerType);
|
|
128
|
+
return {
|
|
129
|
+
...registration,
|
|
130
|
+
...(messageType === undefined ? {} : { messageType })
|
|
131
|
+
};
|
|
132
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zlink-systems/nestjs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@nestjs/common": "^10.4.22",
|
|
24
|
-
"@zlink-systems/framework": "0.
|
|
25
|
-
"@zlink-systems/http-client": "0.
|
|
24
|
+
"@zlink-systems/framework": "0.31.0",
|
|
25
|
+
"@zlink-systems/http-client": "0.31.0",
|
|
26
26
|
"reflect-metadata": "^0.2.2",
|
|
27
27
|
"rxjs": "^7.8.2"
|
|
28
28
|
},
|