@ebarahona/loopback-transport-core 1.0.0 → 1.1.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 (105) hide show
  1. package/README.md +442 -35
  2. package/dist/client/client-proxy.d.ts +73 -42
  3. package/dist/client/client-proxy.js +71 -42
  4. package/dist/client/client-proxy.js.map +1 -1
  5. package/dist/client/index.d.ts +1 -1
  6. package/dist/client/index.js +3 -15
  7. package/dist/client/index.js.map +1 -1
  8. package/dist/context/execution-context.d.ts +58 -11
  9. package/dist/context/execution-context.js +62 -17
  10. package/dist/context/execution-context.js.map +1 -1
  11. package/dist/context/index.d.ts +2 -1
  12. package/dist/context/index.js +3 -15
  13. package/dist/context/index.js.map +1 -1
  14. package/dist/decorators/constants.d.ts +20 -10
  15. package/dist/decorators/constants.js +6 -2
  16. package/dist/decorators/constants.js.map +1 -1
  17. package/dist/decorators/event-handler.decorator.d.ts +10 -7
  18. package/dist/decorators/event-handler.decorator.js +18 -13
  19. package/dist/decorators/event-handler.decorator.js.map +1 -1
  20. package/dist/decorators/index.d.ts +5 -4
  21. package/dist/decorators/index.js +11 -18
  22. package/dist/decorators/index.js.map +1 -1
  23. package/dist/decorators/message-handler.decorator.d.ts +8 -5
  24. package/dist/decorators/message-handler.decorator.js +16 -11
  25. package/dist/decorators/message-handler.decorator.js.map +1 -1
  26. package/dist/decorators/payload.decorator.d.ts +16 -7
  27. package/dist/decorators/payload.decorator.js +16 -8
  28. package/dist/decorators/payload.decorator.js.map +1 -1
  29. package/dist/discovery/discovery.service.d.ts +143 -0
  30. package/dist/discovery/discovery.service.js +165 -0
  31. package/dist/discovery/discovery.service.js.map +1 -0
  32. package/dist/discovery/event-handler-discoverer.d.ts +19 -0
  33. package/dist/discovery/event-handler-discoverer.js +50 -0
  34. package/dist/discovery/event-handler-discoverer.js.map +1 -0
  35. package/dist/discovery/handler-discoverer.d.ts +48 -0
  36. package/dist/discovery/handler-discoverer.js +3 -0
  37. package/dist/discovery/handler-discoverer.js.map +1 -0
  38. package/dist/discovery/handler-kind.d.ts +23 -0
  39. package/dist/discovery/handler-kind.js +14 -0
  40. package/dist/discovery/handler-kind.js.map +1 -0
  41. package/dist/discovery/index.d.ts +7 -0
  42. package/dist/discovery/index.js +13 -0
  43. package/dist/discovery/index.js.map +1 -0
  44. package/dist/discovery/message-handler-discoverer.d.ts +19 -0
  45. package/dist/discovery/message-handler-discoverer.js +50 -0
  46. package/dist/discovery/message-handler-discoverer.js.map +1 -0
  47. package/dist/discovery/registered-handler.d.ts +35 -0
  48. package/dist/discovery/registered-handler.js +3 -0
  49. package/dist/discovery/registered-handler.js.map +1 -0
  50. package/dist/helpers/errors.d.ts +61 -0
  51. package/dist/helpers/errors.js +80 -0
  52. package/dist/helpers/errors.js.map +1 -0
  53. package/dist/helpers/index.d.ts +2 -0
  54. package/dist/helpers/index.js +14 -0
  55. package/dist/helpers/index.js.map +1 -0
  56. package/dist/helpers/register-server.d.ts +44 -0
  57. package/dist/helpers/register-server.js +72 -0
  58. package/dist/helpers/register-server.js.map +1 -0
  59. package/dist/index.d.ts +15 -7
  60. package/dist/index.js +33 -9
  61. package/dist/index.js.map +1 -1
  62. package/dist/interfaces/index.d.ts +4 -4
  63. package/dist/interfaces/index.js +0 -18
  64. package/dist/interfaces/index.js.map +1 -1
  65. package/dist/interfaces/message-handler.interface.d.ts +12 -6
  66. package/dist/interfaces/packet.interface.d.ts +20 -2
  67. package/dist/interfaces/transport-client.interface.d.ts +25 -13
  68. package/dist/interfaces/transport-server.interface.d.ts +36 -10
  69. package/dist/keys.d.ts +132 -46
  70. package/dist/keys.js +131 -68
  71. package/dist/keys.js.map +1 -1
  72. package/dist/registry/handler-registry.d.ts +94 -24
  73. package/dist/registry/handler-registry.js +195 -89
  74. package/dist/registry/handler-registry.js.map +1 -1
  75. package/dist/registry/index.d.ts +1 -1
  76. package/dist/registry/index.js +3 -15
  77. package/dist/registry/index.js.map +1 -1
  78. package/dist/serializers/cloudevents-serializer.d.ts +107 -0
  79. package/dist/serializers/cloudevents-serializer.js +130 -0
  80. package/dist/serializers/cloudevents-serializer.js.map +1 -0
  81. package/dist/serializers/index.d.ts +4 -1
  82. package/dist/serializers/index.js +7 -15
  83. package/dist/serializers/index.js.map +1 -1
  84. package/dist/serializers/serializer.interface.d.ts +49 -16
  85. package/dist/serializers/serializer.interface.js +41 -15
  86. package/dist/serializers/serializer.interface.js.map +1 -1
  87. package/dist/server/index.d.ts +2 -1
  88. package/dist/server/index.js +3 -15
  89. package/dist/server/index.js.map +1 -1
  90. package/dist/server/server-base.d.ts +125 -52
  91. package/dist/server/server-base.js +168 -57
  92. package/dist/server/server-base.js.map +1 -1
  93. package/dist/transport.component.d.ts +21 -8
  94. package/dist/transport.component.js +40 -18
  95. package/dist/transport.component.js.map +1 -1
  96. package/dist/transport.observer.d.ts +87 -0
  97. package/dist/transport.observer.js +296 -0
  98. package/dist/transport.observer.js.map +1 -0
  99. package/dist/utils/normalize-pattern.d.ts +11 -6
  100. package/dist/utils/normalize-pattern.js +18 -13
  101. package/dist/utils/normalize-pattern.js.map +1 -1
  102. package/package.json +58 -16
  103. package/dist/transport-booter.d.ts +0 -31
  104. package/dist/transport-booter.js +0 -117
  105. package/dist/transport-booter.js.map +0 -1
@@ -1,21 +1,30 @@
1
- import { Observable } from 'rxjs';
2
- import { MessageHandler } from './message-handler.interface';
1
+ import type { Application } from '@loopback/core';
2
+ import type { Observable } from 'rxjs';
3
+ import type { MessageHandler } from './message-handler.interface';
3
4
  /**
4
5
  * Transport connection status.
6
+ *
7
+ * @public
5
8
  */
6
9
  export type TransportStatus = 'connected' | 'disconnected' | 'reconnecting' | 'error';
7
10
  /**
8
- * Interface that all transport servers must implement.
9
- * Each transport (Kafka, RabbitMQ, gRPC, MQTT, NATS) provides
10
- * a concrete implementation.
11
+ * Interface that all transport servers must implement. Each transport
12
+ * (Kafka, RabbitMQ, gRPC, MQTT, NATS) provides a concrete
13
+ * implementation.
14
+ *
15
+ * @public
11
16
  */
12
17
  export interface TransportServer {
13
18
  /**
14
19
  * Start listening for messages.
20
+ *
21
+ * @returns Resolves once the server is ready to receive.
15
22
  */
16
23
  listen(): Promise<void>;
17
24
  /**
18
25
  * Stop listening and close connections.
26
+ *
27
+ * @returns Resolves once the server has been torn down.
19
28
  */
20
29
  close(): Promise<void>;
21
30
  /**
@@ -23,7 +32,9 @@ export interface TransportServer {
23
32
  */
24
33
  readonly status$: Observable<TransportStatus>;
25
34
  /**
26
- * Access the underlying native client (e.g., KafkaJS Consumer).
35
+ * Access the underlying native client (e.g. a KafkaJS `Consumer`).
36
+ *
37
+ * @typeParam T - Caller-asserted native client shape.
27
38
  */
28
39
  unwrap<T>(): T;
29
40
  /**
@@ -31,14 +42,29 @@ export interface TransportServer {
31
42
  */
32
43
  addHandler(pattern: string, handler: MessageHandler): void;
33
44
  /**
34
- * Get all registered handlers. Returns a read-only view.
35
- * Each pattern maps to an array of handlers (one for request/response,
45
+ * Get all registered handlers. Returns a read-only view. Each
46
+ * pattern maps to an array of handlers (one for request/response,
36
47
  * potentially many for event fan-out).
37
48
  */
38
49
  getHandlers(): ReadonlyMap<string, readonly MessageHandler[]>;
39
50
  /**
40
- * Remove all registered handlers.
41
- * Called before rebinding on restart to prevent duplicate registration.
51
+ * Remove all registered handlers. Called before rebinding on
52
+ * restart to prevent duplicate registration.
42
53
  */
43
54
  clearHandlers(): void;
55
+ /**
56
+ * Resolve the serializer/deserializer pair for this server from the app
57
+ * container. Precedence is transport-scoped, then generic, then the
58
+ * implementation default. Called by the transport lifecycle observer between
59
+ * `bindToServers` and `listen()`. Plugins contribute tag-based serializers
60
+ * via {@link SERIALIZER_TAG} / {@link DESERIALIZER_TAG}; implementation-level
61
+ * defaults are honored when no tagged binding matches.
62
+ *
63
+ * Implementations that do not need tag-based serializer resolution
64
+ * (servers that hardcode their codec) may provide a no-op implementation.
65
+ * Subclasses of {@link ServerBase} inherit a default implementation.
66
+ *
67
+ * @public
68
+ */
69
+ resolveSerializer(app: Application): Promise<void>;
44
70
  }
package/dist/keys.d.ts CHANGED
@@ -1,28 +1,141 @@
1
- import { Application, Binding, BindingKey, Constructor, Provider } from '@loopback/core';
2
- import { TransportClient, TransportServer } from './interfaces';
1
+ import { BindingKey } from '@loopback/core';
2
+ import type { DiscoveryService } from './discovery';
3
+ import type { TransportClient, TransportServer } from './interfaces';
3
4
  import type { HandlerRegistry } from './registry';
4
5
  /**
5
- * Tag used to identify transport server bindings.
6
- * Transport adapters should tag their server bindings with this value.
6
+ * Tag attached to every transport server binding so the booter can
7
+ * discover servers via `app.findByTag(TRANSPORT_SERVER_TAG)`.
8
+ *
9
+ * Equivalent to `TransportBindings.tags.SERVER` — both forms are
10
+ * supported.
11
+ *
12
+ * @public
7
13
  */
8
14
  export declare const TRANSPORT_SERVER_TAG = "transport-server";
9
15
  /**
10
- * Tag key for the transport name on server bindings.
16
+ * Tag key carrying the transport name (e.g. `'kafka'`, `'rabbitmq'`)
17
+ * on a transport server binding. The booter reads this to route
18
+ * transport-specific handlers.
19
+ *
20
+ * Equivalent to `TransportBindings.tags.NAME` — both forms are
21
+ * supported.
22
+ *
23
+ * @public
11
24
  */
12
25
  export declare const TRANSPORT_NAME_TAG = "transport";
26
+ /**
27
+ * Tag attached to every `HandlerDiscoverer` binding so the handler
28
+ * registry can discover them via
29
+ * `app.findByTag(HANDLER_DISCOVERER_TAG)`.
30
+ *
31
+ * Equivalent to `TransportBindings.tags.HANDLER_DISCOVERER` — both
32
+ * forms are supported.
33
+ *
34
+ * @public
35
+ */
36
+ export declare const HANDLER_DISCOVERER_TAG = "transport-handler-discoverer";
37
+ /**
38
+ * Tag identifying bindings that contribute a
39
+ * {@link Serializer | `Serializer`} to the transport layer.
40
+ *
41
+ * Combine with {@link TRANSPORT_NAME_TAG} (set to a transport name
42
+ * string such as `'kafka'`) to scope the serializer to a specific
43
+ * transport. Bindings tagged with `SERIALIZER_TAG` but without a
44
+ * `TRANSPORT_NAME_TAG` tag are treated as generic and apply to any
45
+ * transport that does not have a transport-scoped match.
46
+ *
47
+ * Resolution precedence at boot (most specific wins):
48
+ *
49
+ * 1. Transport-scoped binding (`SERIALIZER_TAG` + matching
50
+ * `TRANSPORT_NAME_TAG`).
51
+ * 2. Generic binding (`SERIALIZER_TAG` only).
52
+ * 3. Subclass default set via the `protected serializer` field on
53
+ * `ServerBase`.
54
+ *
55
+ * Equivalent to `TransportBindings.tags.SERIALIZER` — both forms are
56
+ * supported.
57
+ *
58
+ * @public
59
+ */
60
+ export declare const SERIALIZER_TAG = "transport-serializer";
61
+ /**
62
+ * Tag identifying bindings that contribute a
63
+ * {@link Deserializer | `Deserializer`} to the transport layer.
64
+ *
65
+ * See {@link SERIALIZER_TAG} for scoping rules and resolution
66
+ * precedence.
67
+ *
68
+ * Equivalent to `TransportBindings.tags.DESERIALIZER` — both forms are
69
+ * supported.
70
+ *
71
+ * @public
72
+ */
73
+ export declare const DESERIALIZER_TAG = "transport-deserializer";
74
+ /**
75
+ * Binding keys and tag constants for the transport core.
76
+ *
77
+ * Registration helpers (`registerServer`, `registerServerClass`,
78
+ * `registerServerProvider`) live in `helpers/register-server.ts` and
79
+ * are exported from the package root.
80
+ *
81
+ * @public
82
+ */
13
83
  export declare namespace TransportBindings {
14
84
  /**
15
- * Binding key for the handler registry.
85
+ * Tag values used by transport server bindings. Prefer these typed
86
+ * accessors over the raw string exports.
87
+ *
88
+ * @public
89
+ */
90
+ namespace tags {
91
+ /**
92
+ * Tag attached to every transport server binding.
93
+ */
94
+ const SERVER = "transport-server";
95
+ /**
96
+ * Tag key holding the transport name on a server binding.
97
+ */
98
+ const NAME = "transport";
99
+ /**
100
+ * Tag attached to every `HandlerDiscoverer` binding. Plugins that
101
+ * contribute a custom decorator vocabulary bind their discoverer
102
+ * under this tag so the handler registry consults it during boot.
103
+ */
104
+ const HANDLER_DISCOVERER = "transport-handler-discoverer";
105
+ /**
106
+ * Tag attached to every `Serializer` binding. Plugins contribute a
107
+ * tag-based serializer via this tag; combine with {@link NAME} to
108
+ * scope the serializer to a specific transport. See
109
+ * {@link SERIALIZER_TAG} for resolution precedence.
110
+ */
111
+ const SERIALIZER = "transport-serializer";
112
+ /**
113
+ * Tag attached to every `Deserializer` binding. See
114
+ * {@link DESERIALIZER_TAG} for resolution precedence.
115
+ */
116
+ const DESERIALIZER = "transport-deserializer";
117
+ }
118
+ /**
119
+ * Binding key for the singleton handler registry that owns the
120
+ * mapping between message patterns and controller method handlers.
16
121
  */
17
122
  const HANDLER_REGISTRY: BindingKey<HandlerRegistry>;
18
123
  /**
19
- * Binding key for the current message payload.
20
- * Set by the handler registry before invoking the handler.
124
+ * Binding key for the singleton {@link DiscoveryService}. Populated
125
+ * by the transport lifecycle observer after discovery and wrapping
126
+ * complete. Cross-cutting plugins inject this service to enumerate
127
+ * every handler the application contains.
128
+ */
129
+ const DISCOVERY_SERVICE: BindingKey<DiscoveryService>;
130
+ /**
131
+ * Binding key for the current message payload. The handler registry
132
+ * binds this per-message inside the invocation child context.
21
133
  */
22
134
  const CURRENT_PAYLOAD: BindingKey<unknown>;
23
135
  /**
24
- * Binding key for the current transport context.
25
- * Set by the transport server before invoking the handler.
136
+ * Binding key for the transport-specific context object passed to the
137
+ * handler (Kafka context, RabbitMQ context, etc.). The handler
138
+ * registry binds this per-message inside the invocation child context.
26
139
  */
27
140
  const CURRENT_CONTEXT: BindingKey<unknown>;
28
141
  /**
@@ -39,50 +152,23 @@ export declare namespace TransportBindings {
39
152
  const SERVER_PREFIX = "transport.server";
40
153
  /**
41
154
  * Get a binding key for a specific transport's configuration.
155
+ *
156
+ * @param transport - Transport name (e.g. `'kafka'`).
157
+ * @returns The typed binding key.
42
158
  */
43
159
  function config(transport: string): BindingKey<Record<string, unknown>>;
44
160
  /**
45
161
  * Get a binding key for a specific transport's client.
162
+ *
163
+ * @param transport - Transport name (e.g. `'kafka'`).
164
+ * @returns The typed binding key.
46
165
  */
47
166
  function client(transport: string): BindingKey<TransportClient>;
48
167
  /**
49
168
  * Get a binding key for a specific transport's server.
50
- */
51
- function server(transport: string): BindingKey<TransportServer>;
52
- /**
53
- * Register a concrete transport server instance.
54
- *
55
- * Use when the server is already constructed (e.g., in tests or
56
- * when no DI is needed).
57
- *
58
- * @param app - The LoopBack application
59
- * @param transport - Transport name (e.g., 'kafka', 'rabbitmq')
60
- * @param instance - A concrete transport server instance
61
- */
62
- function registerServer(app: Application, transport: string, instance: TransportServer): Binding<TransportServer>;
63
- /**
64
- * Register a transport server class with the IoC container.
65
- *
66
- * The class is instantiated by the container, enabling constructor
67
- * injection of config, clients, health checks, and other dependencies.
68
- * This is the recommended registration method for transport adapters.
69
169
  *
70
- * @param app - The LoopBack application
71
- * @param transport - Transport name (e.g., 'kafka', 'rabbitmq')
72
- * @param serverClass - A transport server class constructor
170
+ * @param transport - Transport name (e.g. `'kafka'`).
171
+ * @returns The typed binding key.
73
172
  */
74
- function registerServerClass(app: Application, transport: string, serverClass: Constructor<TransportServer>): Binding<TransportServer>;
75
- /**
76
- * Register a transport server provider.
77
- *
78
- * Providers enable async factory patterns with full DI support.
79
- * Use when server construction requires async initialization or
80
- * complex setup logic. The binding is singleton-scoped so every
81
- * resolution returns the same server instance.
82
- *
83
- * @param app - The LoopBack application
84
- * @param transport - Transport name (e.g., 'kafka', 'rabbitmq')
85
- * @param serverProvider - A provider class that produces a TransportServer
86
- */
87
- function registerServerProvider(app: Application, transport: string, serverProvider: Constructor<Provider<TransportServer>>): Binding<TransportServer>;
173
+ function server(transport: string): BindingKey<TransportServer>;
88
174
  }
package/dist/keys.js CHANGED
@@ -1,30 +1,143 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TransportBindings = exports.TRANSPORT_NAME_TAG = exports.TRANSPORT_SERVER_TAG = void 0;
3
+ exports.TransportBindings = exports.DESERIALIZER_TAG = exports.SERIALIZER_TAG = exports.HANDLER_DISCOVERER_TAG = exports.TRANSPORT_NAME_TAG = exports.TRANSPORT_SERVER_TAG = void 0;
4
4
  const core_1 = require("@loopback/core");
5
5
  /**
6
- * Tag used to identify transport server bindings.
7
- * Transport adapters should tag their server bindings with this value.
6
+ * Tag attached to every transport server binding so the booter can
7
+ * discover servers via `app.findByTag(TRANSPORT_SERVER_TAG)`.
8
+ *
9
+ * Equivalent to `TransportBindings.tags.SERVER` — both forms are
10
+ * supported.
11
+ *
12
+ * @public
8
13
  */
9
14
  exports.TRANSPORT_SERVER_TAG = 'transport-server';
10
15
  /**
11
- * Tag key for the transport name on server bindings.
16
+ * Tag key carrying the transport name (e.g. `'kafka'`, `'rabbitmq'`)
17
+ * on a transport server binding. The booter reads this to route
18
+ * transport-specific handlers.
19
+ *
20
+ * Equivalent to `TransportBindings.tags.NAME` — both forms are
21
+ * supported.
22
+ *
23
+ * @public
12
24
  */
13
25
  exports.TRANSPORT_NAME_TAG = 'transport';
26
+ /**
27
+ * Tag attached to every `HandlerDiscoverer` binding so the handler
28
+ * registry can discover them via
29
+ * `app.findByTag(HANDLER_DISCOVERER_TAG)`.
30
+ *
31
+ * Equivalent to `TransportBindings.tags.HANDLER_DISCOVERER` — both
32
+ * forms are supported.
33
+ *
34
+ * @public
35
+ */
36
+ exports.HANDLER_DISCOVERER_TAG = 'transport-handler-discoverer';
37
+ /**
38
+ * Tag identifying bindings that contribute a
39
+ * {@link Serializer | `Serializer`} to the transport layer.
40
+ *
41
+ * Combine with {@link TRANSPORT_NAME_TAG} (set to a transport name
42
+ * string such as `'kafka'`) to scope the serializer to a specific
43
+ * transport. Bindings tagged with `SERIALIZER_TAG` but without a
44
+ * `TRANSPORT_NAME_TAG` tag are treated as generic and apply to any
45
+ * transport that does not have a transport-scoped match.
46
+ *
47
+ * Resolution precedence at boot (most specific wins):
48
+ *
49
+ * 1. Transport-scoped binding (`SERIALIZER_TAG` + matching
50
+ * `TRANSPORT_NAME_TAG`).
51
+ * 2. Generic binding (`SERIALIZER_TAG` only).
52
+ * 3. Subclass default set via the `protected serializer` field on
53
+ * `ServerBase`.
54
+ *
55
+ * Equivalent to `TransportBindings.tags.SERIALIZER` — both forms are
56
+ * supported.
57
+ *
58
+ * @public
59
+ */
60
+ exports.SERIALIZER_TAG = 'transport-serializer';
61
+ /**
62
+ * Tag identifying bindings that contribute a
63
+ * {@link Deserializer | `Deserializer`} to the transport layer.
64
+ *
65
+ * See {@link SERIALIZER_TAG} for scoping rules and resolution
66
+ * precedence.
67
+ *
68
+ * Equivalent to `TransportBindings.tags.DESERIALIZER` — both forms are
69
+ * supported.
70
+ *
71
+ * @public
72
+ */
73
+ exports.DESERIALIZER_TAG = 'transport-deserializer';
74
+ /**
75
+ * Binding keys and tag constants for the transport core.
76
+ *
77
+ * Registration helpers (`registerServer`, `registerServerClass`,
78
+ * `registerServerProvider`) live in `helpers/register-server.ts` and
79
+ * are exported from the package root.
80
+ *
81
+ * @public
82
+ */
14
83
  var TransportBindings;
15
84
  (function (TransportBindings) {
16
85
  /**
17
- * Binding key for the handler registry.
86
+ * Tag values used by transport server bindings. Prefer these typed
87
+ * accessors over the raw string exports.
88
+ *
89
+ * @public
90
+ */
91
+ let tags;
92
+ (function (tags) {
93
+ /**
94
+ * Tag attached to every transport server binding.
95
+ */
96
+ tags.SERVER = exports.TRANSPORT_SERVER_TAG;
97
+ /**
98
+ * Tag key holding the transport name on a server binding.
99
+ */
100
+ tags.NAME = exports.TRANSPORT_NAME_TAG;
101
+ /**
102
+ * Tag attached to every `HandlerDiscoverer` binding. Plugins that
103
+ * contribute a custom decorator vocabulary bind their discoverer
104
+ * under this tag so the handler registry consults it during boot.
105
+ */
106
+ tags.HANDLER_DISCOVERER = exports.HANDLER_DISCOVERER_TAG;
107
+ /**
108
+ * Tag attached to every `Serializer` binding. Plugins contribute a
109
+ * tag-based serializer via this tag; combine with {@link NAME} to
110
+ * scope the serializer to a specific transport. See
111
+ * {@link SERIALIZER_TAG} for resolution precedence.
112
+ */
113
+ tags.SERIALIZER = exports.SERIALIZER_TAG;
114
+ /**
115
+ * Tag attached to every `Deserializer` binding. See
116
+ * {@link DESERIALIZER_TAG} for resolution precedence.
117
+ */
118
+ tags.DESERIALIZER = exports.DESERIALIZER_TAG;
119
+ })(tags = TransportBindings.tags || (TransportBindings.tags = {}));
120
+ /**
121
+ * Binding key for the singleton handler registry that owns the
122
+ * mapping between message patterns and controller method handlers.
18
123
  */
19
124
  TransportBindings.HANDLER_REGISTRY = core_1.BindingKey.create('transport.handler-registry');
20
125
  /**
21
- * Binding key for the current message payload.
22
- * Set by the handler registry before invoking the handler.
126
+ * Binding key for the singleton {@link DiscoveryService}. Populated
127
+ * by the transport lifecycle observer after discovery and wrapping
128
+ * complete. Cross-cutting plugins inject this service to enumerate
129
+ * every handler the application contains.
130
+ */
131
+ TransportBindings.DISCOVERY_SERVICE = core_1.BindingKey.create('transport.discovery-service');
132
+ /**
133
+ * Binding key for the current message payload. The handler registry
134
+ * binds this per-message inside the invocation child context.
23
135
  */
24
136
  TransportBindings.CURRENT_PAYLOAD = core_1.BindingKey.create('transport.current.payload');
25
137
  /**
26
- * Binding key for the current transport context.
27
- * Set by the transport server before invoking the handler.
138
+ * Binding key for the transport-specific context object passed to the
139
+ * handler (Kafka context, RabbitMQ context, etc.). The handler
140
+ * registry binds this per-message inside the invocation child context.
28
141
  */
29
142
  TransportBindings.CURRENT_CONTEXT = core_1.BindingKey.create('transport.current.context');
30
143
  /**
@@ -41,6 +154,9 @@ var TransportBindings;
41
154
  TransportBindings.SERVER_PREFIX = 'transport.server';
42
155
  /**
43
156
  * Get a binding key for a specific transport's configuration.
157
+ *
158
+ * @param transport - Transport name (e.g. `'kafka'`).
159
+ * @returns The typed binding key.
44
160
  */
45
161
  function config(transport) {
46
162
  return core_1.BindingKey.create(`${TransportBindings.CONFIG_PREFIX}.${transport}`);
@@ -48,6 +164,9 @@ var TransportBindings;
48
164
  TransportBindings.config = config;
49
165
  /**
50
166
  * Get a binding key for a specific transport's client.
167
+ *
168
+ * @param transport - Transport name (e.g. `'kafka'`).
169
+ * @returns The typed binding key.
51
170
  */
52
171
  function client(transport) {
53
172
  return core_1.BindingKey.create(`${TransportBindings.CLIENT_PREFIX}.${transport}`);
@@ -55,69 +174,13 @@ var TransportBindings;
55
174
  TransportBindings.client = client;
56
175
  /**
57
176
  * Get a binding key for a specific transport's server.
177
+ *
178
+ * @param transport - Transport name (e.g. `'kafka'`).
179
+ * @returns The typed binding key.
58
180
  */
59
181
  function server(transport) {
60
182
  return core_1.BindingKey.create(`${TransportBindings.SERVER_PREFIX}.${transport}`);
61
183
  }
62
184
  TransportBindings.server = server;
63
- /**
64
- * Tag a transport server binding for booter discovery.
65
- */
66
- function tagServerBinding(binding, transport) {
67
- return binding
68
- .tag(exports.TRANSPORT_SERVER_TAG)
69
- .tag({ [exports.TRANSPORT_NAME_TAG]: transport });
70
- }
71
- /**
72
- * Register a concrete transport server instance.
73
- *
74
- * Use when the server is already constructed (e.g., in tests or
75
- * when no DI is needed).
76
- *
77
- * @param app - The LoopBack application
78
- * @param transport - Transport name (e.g., 'kafka', 'rabbitmq')
79
- * @param instance - A concrete transport server instance
80
- */
81
- function registerServer(app, transport, instance) {
82
- return tagServerBinding(app.bind(server(transport)).to(instance), transport);
83
- }
84
- TransportBindings.registerServer = registerServer;
85
- /**
86
- * Register a transport server class with the IoC container.
87
- *
88
- * The class is instantiated by the container, enabling constructor
89
- * injection of config, clients, health checks, and other dependencies.
90
- * This is the recommended registration method for transport adapters.
91
- *
92
- * @param app - The LoopBack application
93
- * @param transport - Transport name (e.g., 'kafka', 'rabbitmq')
94
- * @param serverClass - A transport server class constructor
95
- */
96
- function registerServerClass(app, transport, serverClass) {
97
- return tagServerBinding(app
98
- .bind(server(transport))
99
- .toClass(serverClass)
100
- .inScope(core_1.BindingScope.SINGLETON), transport);
101
- }
102
- TransportBindings.registerServerClass = registerServerClass;
103
- /**
104
- * Register a transport server provider.
105
- *
106
- * Providers enable async factory patterns with full DI support.
107
- * Use when server construction requires async initialization or
108
- * complex setup logic. The binding is singleton-scoped so every
109
- * resolution returns the same server instance.
110
- *
111
- * @param app - The LoopBack application
112
- * @param transport - Transport name (e.g., 'kafka', 'rabbitmq')
113
- * @param serverProvider - A provider class that produces a TransportServer
114
- */
115
- function registerServerProvider(app, transport, serverProvider) {
116
- return tagServerBinding(app
117
- .bind(server(transport))
118
- .toProvider(serverProvider)
119
- .inScope(core_1.BindingScope.SINGLETON), transport);
120
- }
121
- TransportBindings.registerServerProvider = registerServerProvider;
122
185
  })(TransportBindings || (exports.TransportBindings = TransportBindings = {}));
123
186
  //# sourceMappingURL=keys.js.map
package/dist/keys.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"keys.js","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":";;;AAAA,yCAOwB;AAIxB;;;GAGG;AACU,QAAA,oBAAoB,GAAG,kBAAkB,CAAC;AAEvD;;GAEG;AACU,QAAA,kBAAkB,GAAG,WAAW,CAAC;AAE9C,IAAiB,iBAAiB,CA4IjC;AA5ID,WAAiB,iBAAiB;IAChC;;OAEG;IACU,kCAAgB,GAAG,iBAAU,CAAC,MAAM,CAC/C,4BAA4B,CAC7B,CAAC;IAEF;;;OAGG;IACU,iCAAe,GAAG,iBAAU,CAAC,MAAM,CAC9C,2BAA2B,CAC5B,CAAC;IAEF;;;OAGG;IACU,iCAAe,GAAG,iBAAU,CAAC,MAAM,CAC9C,2BAA2B,CAC5B,CAAC;IAEF;;OAEG;IACU,+BAAa,GAAG,kBAAkB,CAAC;IAEhD;;OAEG;IACU,+BAAa,GAAG,kBAAkB,CAAC;IAEhD;;OAEG;IACU,+BAAa,GAAG,kBAAkB,CAAC;IAEhD;;OAEG;IACH,SAAgB,MAAM,CAAC,SAAiB;QACtC,OAAO,iBAAU,CAAC,MAAM,CAAC,GAAG,kBAAA,aAAa,IAAI,SAAS,EAAE,CAAC,CAAC;IAC5D,CAAC;IAFe,wBAAM,SAErB,CAAA;IAED;;OAEG;IACH,SAAgB,MAAM,CAAC,SAAiB;QACtC,OAAO,iBAAU,CAAC,MAAM,C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