@zlink-systems/nestjs 0.10.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.
Files changed (41) hide show
  1. package/LICENSE +105 -0
  2. package/dist/.tsbuildinfo +1 -0
  3. package/dist/auto-discovery-marker.d.ts +3 -0
  4. package/dist/auto-discovery-marker.js +12 -0
  5. package/dist/contracts.d.ts +229 -0
  6. package/dist/contracts.js +4 -0
  7. package/dist/decorators.d.ts +16 -0
  8. package/dist/decorators.js +174 -0
  9. package/dist/dispatch-scope.d.ts +5 -0
  10. package/dist/dispatch-scope.js +19 -0
  11. package/dist/drain-health-indicator.d.ts +9 -0
  12. package/dist/drain-health-indicator.js +32 -0
  13. package/dist/framework-integration-contracts.d.ts +368 -0
  14. package/dist/framework-integration-contracts.js +2 -0
  15. package/dist/framework-loader.d.ts +50 -0
  16. package/dist/framework-loader.js +16 -0
  17. package/dist/handler-adapters.d.ts +13 -0
  18. package/dist/handler-adapters.js +155 -0
  19. package/dist/handler-metadata.d.ts +55 -0
  20. package/dist/handler-metadata.js +84 -0
  21. package/dist/http-client-module.d.ts +28 -0
  22. package/dist/http-client-module.js +96 -0
  23. package/dist/index.d.ts +10 -0
  24. package/dist/index.js +27 -0
  25. package/dist/internal-tokens.d.ts +2 -0
  26. package/dist/internal-tokens.js +5 -0
  27. package/dist/module.d.ts +11 -0
  28. package/dist/module.js +203 -0
  29. package/dist/options-builder.d.ts +2 -0
  30. package/dist/options-builder.js +973 -0
  31. package/dist/provider-discovery.d.ts +36 -0
  32. package/dist/provider-discovery.js +186 -0
  33. package/dist/providers.d.ts +16 -0
  34. package/dist/providers.js +426 -0
  35. package/dist/registration-composer.d.ts +7 -0
  36. package/dist/registration-composer.js +310 -0
  37. package/dist/spot-node-handler-registry.d.ts +24 -0
  38. package/dist/spot-node-handler-registry.js +105 -0
  39. package/dist/tokens.d.ts +19 -0
  40. package/dist/tokens.js +22 -0
  41. package/package.json +26 -0
@@ -0,0 +1,229 @@
1
+ import type { InjectionToken, ModuleMetadata } from '@nestjs/common';
2
+ import type { Type, ZLinkActor, ZLinkActorFactory, ZLinkCodecExtension, ZLinkDispatchOptions, ZLinkDispatchOptionsBuilder, ZLinkInboundDispatchOptions, ZLinkEntrySpot, ZLinkHandlerFilter, ZLinkLocationStore, ZLinkLocationOptions, ZLinkRelocationStore, ZLinkActorFactoryBuilder, ZLinkInstanceSpotFactoryBuilder, ZLinkUserSpotFactoryBuilder, ZLinkInstanceSpot, ZLinkMeshNodeSocketConfig, ZLinkMeshPeerConnections, ZLinkMetricsOptions, ZLinkNetworkOptions, ZLinkMessageContext, ZLinkPublishMessageContext, ZLinkRouteMessageContext, ZLinkSession, ZLinkSessionFactory, ZLinkSpot, ZLinkSpotPublisherConfig, ZLinkStreamCompressionBuilder, ZLinkTimerOptions } from '@zlink-systems/framework';
3
+ import type { ZLinkChannelOptions, ZLinkChannelPublishHandlerRegistration, ZLinkClientCapabilityOptions, ZLinkCodecRegistryOptions, ZLinkFrameworkRegistrationOptions, ZLinkPublisherCapabilityOptions, ZLinkSpotNodeOptions, ZLinkSpotNodeRegistrationOptions, ZLinkStreamNodeOptions, ZLinkWorkerOptions } from './framework-integration-contracts';
4
+ export type MutableCodecRegistryOptions = {
5
+ serializers: NonNullable<ZLinkCodecRegistryOptions['serializers']>[number][];
6
+ streamCodecs: NonNullable<ZLinkCodecRegistryOptions['streamCodecs']>[number][];
7
+ };
8
+ export interface ZLinkModuleFactoryOptions<TArgs extends unknown[] = unknown[]> {
9
+ readonly useFactory: (...args: TArgs) => ZLinkModuleOptions | Promise<ZLinkModuleOptions>;
10
+ readonly inject?: {
11
+ readonly [TIndex in keyof TArgs]: InjectionToken;
12
+ };
13
+ readonly imports?: ModuleMetadata['imports'];
14
+ }
15
+ export interface ZLinkNestHandlerDiscoveryOptions {
16
+ readonly handlerGroups?: readonly string[];
17
+ }
18
+ export interface ZLinkNestManualHandlerOptions {
19
+ readonly packetName: string;
20
+ readonly handlerType: Type;
21
+ }
22
+ export type Mutable<T> = {
23
+ -readonly [K in keyof T]: T[K];
24
+ };
25
+ export interface InternalZLinkNestFanoutChannelOptions extends ZLinkNestHandlerDiscoveryOptions {
26
+ readonly routingId?: string;
27
+ readonly routingIdPrefix?: string;
28
+ readonly publisher?: ZLinkPublisherCapabilityOptions;
29
+ readonly subscriber?: ZLinkClientCapabilityOptions;
30
+ readonly publishHandlers?: readonly ZLinkChannelPublishHandlerRegistration[];
31
+ readonly publishHandlerTypes?: readonly ZLinkNestManualHandlerOptions[];
32
+ }
33
+ export interface InternalZLinkNestClientServerChannelOptions extends ZLinkNestHandlerDiscoveryOptions {
34
+ readonly client?: ZLinkClientCapabilityOptions;
35
+ readonly server?: NonNullable<ZLinkChannelOptions['server']>;
36
+ readonly requestHandlerTypes?: readonly ZLinkNestManualHandlerOptions[];
37
+ readonly sendHandlerTypes?: readonly ZLinkNestManualHandlerOptions[];
38
+ }
39
+ export interface ZLinkNestHandlerOptions {
40
+ readonly methodName?: string;
41
+ readonly decodePayload?: (payload: Buffer, context: ZLinkMessageContext | ZLinkRouteMessageContext | ZLinkPublishMessageContext) => unknown;
42
+ readonly encodeResult?: (result: unknown, context: ZLinkMessageContext | ZLinkRouteMessageContext) => unknown;
43
+ }
44
+ export interface ZLinkNestProviderDiscoveryOptions {
45
+ readonly recursive?: boolean;
46
+ }
47
+ export type ZLinkNestProviderDiscoveryRoot = string | {
48
+ readonly rootDir: string;
49
+ readonly options?: ZLinkNestProviderDiscoveryOptions;
50
+ };
51
+ export interface ZLinkNestModuleMetadata extends ModuleMetadata {
52
+ readonly providerDiscovery?: readonly ZLinkNestProviderDiscoveryRoot[];
53
+ }
54
+ export type ZLinkNestModuleRoleRoot = string;
55
+ export type ZLinkNestTypeResolver<T> = Type<T> | (() => Type<T>);
56
+ export interface ZLinkNestSpotActorSendHandlerOptions<TSpot extends ZLinkSpot, TActor extends ZLinkActor> {
57
+ readonly spot: ZLinkNestTypeResolver<TSpot>;
58
+ readonly actor: ZLinkNestTypeResolver<TActor>;
59
+ readonly packetName: string;
60
+ readonly methodName?: string;
61
+ }
62
+ export interface ZLinkNestSpotPacketHandlerOptions<TSpot extends ZLinkSpot | ZLinkInstanceSpot> {
63
+ readonly spot: ZLinkNestTypeResolver<TSpot>;
64
+ readonly packetName?: string;
65
+ }
66
+ export interface ZLinkNestEntrySpotPacketHandlerOptions<TEntrySpot extends ZLinkEntrySpot> {
67
+ readonly entrySpot: ZLinkNestTypeResolver<TEntrySpot>;
68
+ readonly packetName?: string;
69
+ }
70
+ export interface ZLinkNestSpotSubscriptionHandlerOptions<TSpot extends ZLinkSpot> {
71
+ readonly spot: ZLinkNestTypeResolver<TSpot>;
72
+ readonly channelName: string;
73
+ readonly topic: string;
74
+ }
75
+ export interface ZLinkNestEntrySpotSubscriptionHandlerOptions<TEntrySpot extends ZLinkEntrySpot> {
76
+ readonly entrySpot: ZLinkNestTypeResolver<TEntrySpot>;
77
+ readonly channelName: string;
78
+ readonly topic: string;
79
+ }
80
+ export interface ZLinkNestSpotActorRequestHandlerOptions<TSpot extends ZLinkSpot, TActor extends ZLinkActor> {
81
+ readonly spot: ZLinkNestTypeResolver<TSpot>;
82
+ readonly actor: ZLinkNestTypeResolver<TActor>;
83
+ readonly packetName: string;
84
+ readonly methodName?: string;
85
+ }
86
+ export interface ZLinkNestEntrySpotActorRequestHandlerOptions<TEntrySpot extends ZLinkEntrySpot, TActor extends ZLinkActor> {
87
+ readonly entrySpot: ZLinkNestTypeResolver<TEntrySpot>;
88
+ readonly actor: ZLinkNestTypeResolver<TActor>;
89
+ readonly packetName: string;
90
+ readonly methodName?: string;
91
+ }
92
+ export interface ZLinkNestEntrySpotActorSendHandlerOptions<TEntrySpot extends ZLinkEntrySpot, TActor extends ZLinkActor> {
93
+ readonly entrySpot: ZLinkNestTypeResolver<TEntrySpot>;
94
+ readonly actor: ZLinkNestTypeResolver<TActor>;
95
+ readonly packetName: string;
96
+ readonly methodName?: string;
97
+ }
98
+ export interface ZLinkNestSpotTimerHandlerOptions<TSpot extends ZLinkSpot = ZLinkSpot> {
99
+ readonly spot?: ZLinkNestTypeResolver<TSpot>;
100
+ readonly entrySpot?: ZLinkNestTypeResolver<ZLinkEntrySpot>;
101
+ readonly name?: string;
102
+ readonly periodMs?: number;
103
+ readonly options?: ZLinkTimerOptions;
104
+ }
105
+ export declare const ZLINK_MODULE_OPTIONS_BRAND: unique symbol;
106
+ export interface ZLinkModuleOptions {
107
+ readonly [ZLINK_MODULE_OPTIONS_BRAND]: true;
108
+ }
109
+ export interface ZLinkNestModuleRegistrationOptions extends Omit<ZLinkFrameworkRegistrationOptions, 'channels' | 'routeChannels' | 'streamNodes' | 'spotNodes'> {
110
+ readonly [ZLINK_MODULE_OPTIONS_BRAND]: true;
111
+ readonly implicitHandlerAutoRegistration?: boolean;
112
+ readonly clientServerChannels?: Readonly<Record<string, InternalZLinkNestClientServerChannelOptions>>;
113
+ readonly fanoutChannels?: Readonly<Record<string, InternalZLinkNestFanoutChannelOptions>>;
114
+ readonly spotNodes?: readonly (string | ZLinkSpotNodeRegistrationOptions)[] | Readonly<Record<string, ZLinkSpotNodeOptions>>;
115
+ readonly streams?: Readonly<Record<string, ZLinkStreamNodeOptions>>;
116
+ }
117
+ export interface ZLinkNestFrameworkOptionsBuilder {
118
+ options(options: ZLinkNestFrameworkAdditionalOptions): this;
119
+ disableImplicitHandlerAutoRegistration(): this;
120
+ codecs(): ZLinkNestCodecRegistryBuilder;
121
+ configureDispatch(): ZLinkDispatchOptionsBuilder;
122
+ configureInboundDispatch(): ZLinkInboundDispatchOptions;
123
+ addLocationStore(store: ZLinkLocationStore): this;
124
+ addRelocationStore(store: ZLinkRelocationStore): this;
125
+ setApplicationVersion(version: bigint): this;
126
+ setMaintenanceWave(waveId: string): this;
127
+ setActorTransferTimeout(timeoutMs: number): this;
128
+ setMessageFollowDuration(timeoutMs: number): this;
129
+ setSessionReplacementCallbackTimeout(timeoutMs: number): this;
130
+ configureStreamCompression(): ZLinkStreamCompressionBuilder;
131
+ configureLocations(): ZLinkLocationOptions;
132
+ configureNetwork(): ZLinkNetworkOptions;
133
+ addClientServerChannel(name: string): ZLinkNestClientServerChannelRoleBuilder;
134
+ addFanoutChannel(name: string): ZLinkNestFanoutChannelBuilder;
135
+ addRouteMesh(name: string): ZLinkNestMeshNodeBuilder;
136
+ addStreamNode(name: string): ZLinkNestStreamNodeBuilder;
137
+ build(): ZLinkModuleOptions;
138
+ }
139
+ export interface ZLinkNestFrameworkAdditionalOptions {
140
+ readonly requestTimeoutMs?: number;
141
+ readonly sessionReplacementCallbackTimeoutMs?: number;
142
+ readonly filters?: readonly Type<ZLinkHandlerFilter>[];
143
+ readonly worker?: ZLinkWorkerOptions;
144
+ readonly dispatch?: ZLinkDispatchOptions;
145
+ readonly metrics?: ZLinkMetricsOptions;
146
+ }
147
+ export interface ZLinkNestCodecRegistryBuilder extends ZLinkNestFrameworkOptionsBuilder {
148
+ use(extension: ZLinkCodecExtension): this;
149
+ }
150
+ export interface ZLinkNestFanoutChannelBuilder extends ZLinkNestFrameworkOptionsBuilder {
151
+ enablePublisher(bind: string | undefined): this;
152
+ enablePublisher(port?: number): this;
153
+ setBindHost(bindHost: string): this;
154
+ setAdvertiseHost(advertiseHost: string): this;
155
+ routingId(routingId: string | undefined): this;
156
+ setRoutingIdPrefix(prefix: string): this;
157
+ enableSubscriber(endpoint?: string | readonly string[]): this;
158
+ addPublishHandler(packetName: string, handlerType: Type): this;
159
+ addHandlerGroup(groupName: string): this;
160
+ }
161
+ export interface ZLinkNestClientServerChannelRoleBuilder extends ZLinkNestFrameworkOptionsBuilder {
162
+ client(): ZLinkNestClientServerChannelClientBuilder;
163
+ server(): ZLinkNestClientServerChannelServerBuilder;
164
+ }
165
+ export interface ZLinkNestClientServerChannelClientBuilder extends ZLinkNestFrameworkOptionsBuilder {
166
+ connect(endpoint: string): this;
167
+ }
168
+ export interface ZLinkNestClientServerChannelServerBuilder extends ZLinkNestFrameworkOptionsBuilder {
169
+ listen(port?: number): this;
170
+ setBindHost(bindHost: string): this;
171
+ setAdvertiseHost(advertiseHost: string): this;
172
+ setWeight(weight: number): this;
173
+ addSendHandler(packetName: string, handlerType: Type): this;
174
+ addRequestHandler(packetName: string, handlerType: Type): this;
175
+ addHandlerGroup(groupName: string): this;
176
+ }
177
+ export interface ZLinkNestStreamNodeBuilder extends ZLinkNestFrameworkOptionsBuilder {
178
+ bind(endpoint: string | undefined): this;
179
+ bind(port?: number): this;
180
+ setBindHost(bindHost: string): this;
181
+ setAdvertiseHost(advertiseHost: string): this;
182
+ enableActorDispatch(): this;
183
+ setTlsServer(certificatePath: string, keyPath: string, requireClientCertificate?: boolean): this;
184
+ registerSession<TSession extends ZLinkSession>(sessionType: Type<TSession> | Type<ZLinkSessionFactory<TSession>>): this;
185
+ }
186
+ export interface ZLinkNestMeshNodeBuilder extends ZLinkNestFrameworkOptionsBuilder {
187
+ channel(name: string): ZLinkNestMeshChannelBuilder;
188
+ listen(endpoint: string): this;
189
+ listen(port?: number): this;
190
+ setBindHost(bindHost: string): this;
191
+ setAdvertiseHost(advertiseHost: string): this;
192
+ routingId(routingId: string | undefined): this;
193
+ setRoutingIdPrefix(prefix: string): this;
194
+ setPlacementWeight(weight: number): this;
195
+ setActorLimit(limit: number): this;
196
+ setSpotLimit(limit: number): this;
197
+ setActivationConcurrency(limit: number): this;
198
+ setInstanceSpotIdleTimeout(timeoutMs: number): this;
199
+ configureRouterSocket(): ZLinkMeshNodeSocketConfig;
200
+ configureSpotPublisher(): ZLinkSpotPublisherConfig;
201
+ peerConnections(): ZLinkMeshPeerConnections;
202
+ objects(): ZLinkNestMeshObjectRoleBuilder;
203
+ addSendHandler(packetName: string, handlerType: Type): this;
204
+ addRequestHandler(packetName: string, handlerType: Type): this;
205
+ }
206
+ export interface ZLinkNestMeshObjectRoleBuilder extends ZLinkNestFrameworkOptionsBuilder {
207
+ client(): ZLinkNestMeshObjectClientBuilder;
208
+ server(): ZLinkNestMeshObjectServerBuilder;
209
+ }
210
+ export interface ZLinkNestMeshObjectClientBuilder extends ZLinkNestFrameworkOptionsBuilder {
211
+ }
212
+ export interface ZLinkNestMeshObjectServerBuilder extends ZLinkNestFrameworkOptionsBuilder {
213
+ addEntrySpot<TEntrySpot extends ZLinkEntrySpot>(entrySpotType: Type<TEntrySpot>): this;
214
+ addSpotFactory<TSpot extends ZLinkSpot>(spotType: string, implementation: Type<TSpot>, configure: (builder: ZLinkUserSpotFactoryBuilder<TSpot>) => void): this;
215
+ addInstanceSpotFactory<TSpot extends ZLinkInstanceSpot>(instanceSpotType: string, implementation: Type<TSpot>, configure: (builder: ZLinkInstanceSpotFactoryBuilder<TSpot>) => void): this;
216
+ addActorFactory<TActor extends ZLinkActor>(actorType: string, implementation: Type<ZLinkActorFactory<TActor>>, configure: (builder: ZLinkActorFactoryBuilder<TActor>) => void): this;
217
+ }
218
+ export interface ZLinkNestMeshChannelBuilder extends ZLinkNestFrameworkOptionsBuilder {
219
+ client(): ZLinkNestMeshChannelClientBuilder;
220
+ server(): ZLinkNestMeshChannelServerBuilder;
221
+ }
222
+ export interface ZLinkNestMeshChannelClientBuilder extends ZLinkNestFrameworkOptionsBuilder {
223
+ }
224
+ export interface ZLinkNestMeshChannelServerBuilder extends ZLinkNestFrameworkOptionsBuilder {
225
+ setWeight(weight: number): this;
226
+ addSendHandler(packetName: string, handlerType: Type): this;
227
+ addRequestHandler(packetName: string, handlerType: Type): this;
228
+ addHandlerGroup(groupName: string): this;
229
+ }
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ZLINK_MODULE_OPTIONS_BRAND = void 0;
4
+ exports.ZLINK_MODULE_OPTIONS_BRAND = Symbol('@zlink-systems/nestjs:module-options');
@@ -0,0 +1,16 @@
1
+ import type { ZLinkActor, ZLinkEntrySpot, ZLinkInstanceSpot, ZLinkSpot } from '@zlink-systems/framework';
2
+ import type { ZLinkNestEntrySpotActorRequestHandlerOptions, ZLinkNestEntrySpotActorSendHandlerOptions, ZLinkNestEntrySpotPacketHandlerOptions, ZLinkNestEntrySpotSubscriptionHandlerOptions, ZLinkNestHandlerOptions, ZLinkNestSpotActorRequestHandlerOptions, ZLinkNestSpotActorSendHandlerOptions, ZLinkNestSpotPacketHandlerOptions, ZLinkNestSpotSubscriptionHandlerOptions, ZLinkNestSpotTimerHandlerOptions } from './contracts';
3
+ import { type ZLinkNestHandlerKind } from './handler-metadata';
4
+ export declare function zlinkRequestHandler(groupName: string, packetName?: string, options?: ZLinkNestHandlerOptions): ClassDecorator;
5
+ export declare function zlinkSendHandler(groupName: string, packetName?: string, options?: ZLinkNestHandlerOptions): ClassDecorator;
6
+ export declare function zlinkPublishHandler(groupName: string, packetName?: string, options?: ZLinkNestHandlerOptions): ClassDecorator;
7
+ export declare function zlinkSpotActorRequestHandler<TSpot extends ZLinkSpot, TActor extends ZLinkActor>(options: ZLinkNestSpotActorRequestHandlerOptions<TSpot, TActor>): ClassDecorator;
8
+ export declare function zlinkSpotPacketHandler<TSpot extends ZLinkSpot | ZLinkInstanceSpot>(options: ZLinkNestSpotPacketHandlerOptions<TSpot>): ClassDecorator;
9
+ export declare function zlinkEntrySpotPacketHandler<TEntrySpot extends ZLinkEntrySpot>(options: ZLinkNestEntrySpotPacketHandlerOptions<TEntrySpot>): ClassDecorator;
10
+ export declare function zlinkSpotSubscriptionHandler<TSpot extends ZLinkSpot>(options: ZLinkNestSpotSubscriptionHandlerOptions<TSpot>): ClassDecorator;
11
+ export declare function zlinkEntrySpotSubscriptionHandler<TEntrySpot extends ZLinkEntrySpot>(options: ZLinkNestEntrySpotSubscriptionHandlerOptions<TEntrySpot>): ClassDecorator;
12
+ export declare function zlinkSpotActorSendHandler<TSpot extends ZLinkSpot, TActor extends ZLinkActor>(options: ZLinkNestSpotActorSendHandlerOptions<TSpot, TActor>): ClassDecorator;
13
+ export declare function zlinkEntrySpotActorRequestHandler<TEntrySpot extends ZLinkEntrySpot, TActor extends ZLinkActor>(options: ZLinkNestEntrySpotActorRequestHandlerOptions<TEntrySpot, TActor>): ClassDecorator;
14
+ export declare function zlinkEntrySpotActorSendHandler<TEntrySpot extends ZLinkEntrySpot, TActor extends ZLinkActor>(options: ZLinkNestEntrySpotActorSendHandlerOptions<TEntrySpot, TActor>): ClassDecorator;
15
+ export declare function zlinkSpotTimerHandler<TSpot extends ZLinkSpot = ZLinkSpot>(options?: ZLinkNestSpotTimerHandlerOptions<TSpot>): ClassDecorator;
16
+ export declare function zlinkHandler(groupName: string, kind: ZLinkNestHandlerKind, packetName?: string, options?: ZLinkNestHandlerOptions): ClassDecorator;
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.zlinkRequestHandler = zlinkRequestHandler;
4
+ exports.zlinkSendHandler = zlinkSendHandler;
5
+ exports.zlinkPublishHandler = zlinkPublishHandler;
6
+ exports.zlinkSpotActorRequestHandler = zlinkSpotActorRequestHandler;
7
+ exports.zlinkSpotPacketHandler = zlinkSpotPacketHandler;
8
+ exports.zlinkEntrySpotPacketHandler = zlinkEntrySpotPacketHandler;
9
+ exports.zlinkSpotSubscriptionHandler = zlinkSpotSubscriptionHandler;
10
+ exports.zlinkEntrySpotSubscriptionHandler = zlinkEntrySpotSubscriptionHandler;
11
+ exports.zlinkSpotActorSendHandler = zlinkSpotActorSendHandler;
12
+ exports.zlinkEntrySpotActorRequestHandler = zlinkEntrySpotActorRequestHandler;
13
+ exports.zlinkEntrySpotActorSendHandler = zlinkEntrySpotActorSendHandler;
14
+ exports.zlinkSpotTimerHandler = zlinkSpotTimerHandler;
15
+ exports.zlinkHandler = zlinkHandler;
16
+ const common_1 = require("@nestjs/common");
17
+ const framework_loader_1 = require("./framework-loader");
18
+ const handler_metadata_1 = require("./handler-metadata");
19
+ function zlinkRequestHandler(groupName, packetName, options = {}) {
20
+ return zlinkHandler(groupName, 'request', packetName, options);
21
+ }
22
+ function zlinkSendHandler(groupName, packetName, options = {}) {
23
+ return zlinkHandler(groupName, 'send', packetName, options);
24
+ }
25
+ function zlinkPublishHandler(groupName, packetName, options = {}) {
26
+ return zlinkHandler(groupName, 'publish', packetName, options);
27
+ }
28
+ function zlinkSpotActorRequestHandler(options) {
29
+ return (target) => {
30
+ (0, common_1.Injectable)()(target);
31
+ (0, handler_metadata_1.appendNestSpotActorHandlerMetadata)(target, {
32
+ actor: options.actor,
33
+ handlerType: target,
34
+ kind: 'spotActorRequest',
35
+ methodName: options.methodName ?? 'handle',
36
+ packetName: options.packetName,
37
+ spot: options.spot
38
+ });
39
+ };
40
+ }
41
+ function zlinkSpotPacketHandler(options) {
42
+ return (target) => {
43
+ (0, common_1.Injectable)()(target);
44
+ (0, handler_metadata_1.appendNestSpotHandlerMetadata)(target, {
45
+ handlerType: target,
46
+ kind: 'spotPacket',
47
+ packetName: options.packetName,
48
+ spot: options.spot
49
+ });
50
+ };
51
+ }
52
+ function zlinkEntrySpotPacketHandler(options) {
53
+ return (target) => {
54
+ (0, common_1.Injectable)()(target);
55
+ (0, handler_metadata_1.appendNestSpotHandlerMetadata)(target, {
56
+ entrySpot: options.entrySpot,
57
+ handlerType: target,
58
+ kind: 'entrySpotPacket',
59
+ packetName: options.packetName
60
+ });
61
+ };
62
+ }
63
+ function zlinkSpotSubscriptionHandler(options) {
64
+ return (target) => {
65
+ (0, common_1.Injectable)()(target);
66
+ (0, handler_metadata_1.appendNestSpotHandlerMetadata)(target, {
67
+ handlerType: target,
68
+ kind: 'spotSubscription',
69
+ spot: options.spot,
70
+ channelName: options.channelName,
71
+ topic: options.topic
72
+ });
73
+ };
74
+ }
75
+ function zlinkEntrySpotSubscriptionHandler(options) {
76
+ return (target) => {
77
+ (0, common_1.Injectable)()(target);
78
+ (0, handler_metadata_1.appendNestSpotHandlerMetadata)(target, {
79
+ entrySpot: options.entrySpot,
80
+ handlerType: target,
81
+ kind: 'entrySpotSubscription',
82
+ channelName: options.channelName,
83
+ topic: options.topic
84
+ });
85
+ };
86
+ }
87
+ function zlinkSpotActorSendHandler(options) {
88
+ return (target) => {
89
+ (0, common_1.Injectable)()(target);
90
+ (0, handler_metadata_1.appendNestSpotActorHandlerMetadata)(target, {
91
+ actor: options.actor,
92
+ handlerType: target,
93
+ kind: 'spotActorSend',
94
+ methodName: options.methodName ?? 'handle',
95
+ packetName: options.packetName,
96
+ spot: options.spot
97
+ });
98
+ };
99
+ }
100
+ function zlinkEntrySpotActorRequestHandler(options) {
101
+ return (target) => {
102
+ (0, common_1.Injectable)()(target);
103
+ (0, handler_metadata_1.appendNestSpotActorHandlerMetadata)(target, {
104
+ actor: options.actor,
105
+ entrySpot: options.entrySpot,
106
+ handlerType: target,
107
+ kind: 'entrySpotActorRequest',
108
+ methodName: options.methodName ?? 'handle',
109
+ packetName: options.packetName
110
+ });
111
+ };
112
+ }
113
+ function zlinkEntrySpotActorSendHandler(options) {
114
+ return (target) => {
115
+ (0, common_1.Injectable)()(target);
116
+ (0, handler_metadata_1.appendNestSpotActorHandlerMetadata)(target, {
117
+ actor: options.actor,
118
+ entrySpot: options.entrySpot,
119
+ handlerType: target,
120
+ kind: 'entrySpotActorSend',
121
+ methodName: options.methodName ?? 'handle',
122
+ packetName: options.packetName
123
+ });
124
+ };
125
+ }
126
+ function zlinkSpotTimerHandler(options = {}) {
127
+ return (target) => {
128
+ (0, common_1.Injectable)()(target);
129
+ (0, handler_metadata_1.markNestSpotTimerHandler)(target);
130
+ if (options.name !== undefined && options.periodMs !== undefined) {
131
+ (0, handler_metadata_1.appendNestSpotTimerHandlerMetadata)(target, {
132
+ entrySpot: options.entrySpot,
133
+ handlerType: target,
134
+ name: options.name,
135
+ options: options.options,
136
+ periodMs: options.periodMs,
137
+ spot: options.spot
138
+ });
139
+ }
140
+ };
141
+ }
142
+ function zlinkHandler(groupName, kind, packetName, options = {}) {
143
+ validateHandlerGroupName(groupName);
144
+ return (target) => {
145
+ (0, common_1.Injectable)()(target);
146
+ (0, handler_metadata_1.appendNestHandlerMetadata)(target, {
147
+ decodePayload: options.decodePayload,
148
+ encodeResult: options.encodeResult,
149
+ groupName,
150
+ kind,
151
+ methodName: options.methodName ?? 'handle',
152
+ packetName: packetName ?? inferPacketName(target, target)
153
+ });
154
+ };
155
+ }
156
+ function validateHandlerGroupName(groupName) {
157
+ if (groupName.trim() === '') {
158
+ throw new framework_loader_1.framework.ZLinkConfigurationException('ZLink handler group name must not be empty.');
159
+ }
160
+ }
161
+ function inferPacketName(handlerType, handlerToken) {
162
+ if (handlerType !== undefined) {
163
+ return handlerType.name.endsWith('Handler')
164
+ ? handlerType.name.slice(0, -'Handler'.length)
165
+ : handlerType.name;
166
+ }
167
+ const tokenName = typeof handlerToken === 'symbol'
168
+ ? handlerToken.description
169
+ : String(handlerToken);
170
+ if (tokenName === undefined || tokenName.trim() === '') {
171
+ throw new framework_loader_1.framework.ZLinkConfigurationException('ZLink handler packetName is required for anonymous provider tokens.');
172
+ }
173
+ return tokenName;
174
+ }
@@ -0,0 +1,5 @@
1
+ import type { Type, ZLinkMessageContext } from '@zlink-systems/framework';
2
+ import type { ContextId, ModuleRef } from '@nestjs/core';
3
+ export declare function runInNestDispatchScope<T>(moduleRef: ModuleRef, context: ZLinkMessageContext, callback: () => Promise<T>): Promise<T>;
4
+ export declare function resolveInNestDispatchScope<T>(moduleRef: ModuleRef, type: Type<T>): Promise<T>;
5
+ export declare function currentNestDispatchContext(): ContextId | undefined;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runInNestDispatchScope = runInNestDispatchScope;
4
+ exports.resolveInNestDispatchScope = resolveInNestDispatchScope;
5
+ exports.currentNestDispatchContext = currentNestDispatchContext;
6
+ const node_async_hooks_1 = require("node:async_hooks");
7
+ const core_1 = require("@nestjs/core");
8
+ const dispatchContext = new node_async_hooks_1.AsyncLocalStorage();
9
+ async function runInNestDispatchScope(moduleRef, context, callback) {
10
+ const contextId = core_1.ContextIdFactory.create();
11
+ moduleRef.registerRequestByContextId({ zlinkContext: context }, contextId);
12
+ return dispatchContext.run(contextId, callback);
13
+ }
14
+ async function resolveInNestDispatchScope(moduleRef, type) {
15
+ return await moduleRef.resolve(type, dispatchContext.getStore(), { strict: false });
16
+ }
17
+ function currentNestDispatchContext() {
18
+ return dispatchContext.getStore();
19
+ }
@@ -0,0 +1,9 @@
1
+ import type { ZLinkRouteMeshRuntime } from '@zlink-systems/framework';
2
+ export declare class ZLinkDrainHealthIndicator {
3
+ private readonly runtime;
4
+ private readonly meshName;
5
+ constructor(runtime: ZLinkRouteMeshRuntime, meshName: string);
6
+ isHealthy(key?: string): Promise<Record<string, {
7
+ readonly status: 'up';
8
+ }>>;
9
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ZLinkDrainHealthIndicator = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ let ZLinkDrainHealthIndicator = class ZLinkDrainHealthIndicator {
15
+ runtime;
16
+ meshName;
17
+ constructor(runtime, meshName) {
18
+ this.runtime = runtime;
19
+ this.meshName = meshName;
20
+ }
21
+ async isHealthy(key = 'zlink') {
22
+ if (!this.runtime.isReady(this.meshName)) {
23
+ throw new Error(`${key} is draining.`);
24
+ }
25
+ return { [key]: { status: 'up' } };
26
+ }
27
+ };
28
+ exports.ZLinkDrainHealthIndicator = ZLinkDrainHealthIndicator;
29
+ exports.ZLinkDrainHealthIndicator = ZLinkDrainHealthIndicator = __decorate([
30
+ (0, common_1.Injectable)(),
31
+ __metadata("design:paramtypes", [Object, String])
32
+ ], ZLinkDrainHealthIndicator);