@drarzter/kafka-client 0.7.1 → 0.7.3
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 +141 -8
- package/dist/{chunk-AMEGMOZH.mjs → chunk-XP7LLRGQ.mjs} +1026 -849
- package/dist/chunk-XP7LLRGQ.mjs.map +1 -0
- package/dist/core.d.mts +167 -56
- package/dist/core.d.ts +167 -56
- package/dist/core.js +1025 -848
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +1 -1
- package/dist/index.d.mts +37 -4
- package/dist/index.d.ts +37 -4
- package/dist/index.js +1031 -848
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -1
- package/dist/index.mjs.map +1 -1
- package/dist/otel.d.mts +1 -1
- package/dist/otel.d.ts +1 -1
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/{types-BEIGjmV6.d.mts → types-4qWrf2aJ.d.mts} +136 -4
- package/dist/{types-BEIGjmV6.d.ts → types-4qWrf2aJ.d.ts} +136 -4
- package/package.json +1 -1
- package/dist/chunk-AMEGMOZH.mjs.map +0 -1
package/dist/core.mjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { KafkaClient, KafkaProcessingError, KafkaRetryExhaustedError, KafkaValidationError } from './core.mjs';
|
|
2
|
-
import { T as TopicMapConstraint, C as ClientId, G as GroupId, K as KafkaInstrumentation, a as KafkaClientOptions, S as SchemaLike, b as ConsumerOptions, c as TopicDescriptor, I as IKafkaClient, d as KafkaHealthResult } from './types-
|
|
3
|
-
export { B as BatchMessageItem, e as BatchMeta, f as
|
|
2
|
+
import { T as TopicMapConstraint, C as ClientId, G as GroupId, K as KafkaInstrumentation, a as KafkaClientOptions, S as SchemaLike, b as ConsumerOptions, c as TopicDescriptor, I as IKafkaClient, d as KafkaHealthResult } from './types-4qWrf2aJ.mjs';
|
|
3
|
+
export { B as BatchMessageItem, e as BatchMeta, f as BatchSendOptions, g as BeforeConsumeResult, h as CircuitBreakerOptions, i as CompressionType, j as ConsumerGroupSummary, k as ConsumerHandle, l as ConsumerInterceptor, D as DeduplicationOptions, m as DlqReason, n as DlqReplayOptions, E as EnvelopeHeaderOptions, o as EventEnvelope, H as HEADER_CORRELATION_ID, p as HEADER_EVENT_ID, q as HEADER_LAMPORT_CLOCK, r as HEADER_SCHEMA_VERSION, s as HEADER_TIMESTAMP, t as HEADER_TRACEPARENT, u as InferSchema, v as KafkaLogger, w as KafkaMetrics, M as MessageHeaders, x as MessageLostContext, R as RetryOptions, y as SchemaParseContext, z as SendOptions, A as SubscribeRetryOptions, F as TTopicMessageMap, J as TopicDescription, L as TopicPartitionInfo, N as TopicsFrom, O as TransactionContext, P as TtlExpiredContext, Q as buildEnvelopeHeaders, U as decodeHeaders, V as extractEnvelope, W as getEnvelopeContext, X as runWithEnvelopeContext, Y as topic } from './types-4qWrf2aJ.mjs';
|
|
4
4
|
import { DynamicModule, OnModuleInit } from '@nestjs/common';
|
|
5
5
|
import { DiscoveryService, ModuleRef } from '@nestjs/core';
|
|
6
6
|
|
|
@@ -55,20 +55,47 @@ declare const KAFKA_CLIENT = "KAFKA_CLIENT";
|
|
|
55
55
|
/** Returns the DI token for a named (or default) Kafka client instance. */
|
|
56
56
|
declare const getKafkaClientToken: (name?: string) => string;
|
|
57
57
|
|
|
58
|
+
/** Reflect metadata key used to store `@SubscribeTo` entries on a class constructor. */
|
|
58
59
|
declare const KAFKA_SUBSCRIBER_METADATA = "KAFKA_SUBSCRIBER_METADATA";
|
|
60
|
+
/** Internal shape stored per `@SubscribeTo()` decoration on a class. */
|
|
59
61
|
interface KafkaSubscriberMetadata {
|
|
62
|
+
/** Resolved topic name strings (descriptors are unwrapped to their `__topic` string). */
|
|
60
63
|
topics: string[];
|
|
64
|
+
/** Per-topic schema validators extracted from `TopicDescriptor` objects (if any). */
|
|
61
65
|
schemas?: Map<string, SchemaLike>;
|
|
66
|
+
/** Additional consumer options forwarded to `startConsumer` / `startBatchConsumer`. */
|
|
62
67
|
options?: ConsumerOptions;
|
|
68
|
+
/** Named client identifier — resolves to `KAFKA_CLIENT_<clientName>` in the DI container. */
|
|
63
69
|
clientName?: string;
|
|
70
|
+
/** When `true`, routes to `startBatchConsumer` instead of `startConsumer`. */
|
|
64
71
|
batch?: boolean;
|
|
72
|
+
/** Name of the decorated method on the provider class. */
|
|
65
73
|
methodName?: string | symbol;
|
|
66
74
|
}
|
|
67
75
|
/** Inject a `KafkaClient` instance. Pass a name to target a specific named client. */
|
|
68
76
|
declare const InjectKafkaClient: (name?: string) => ParameterDecorator;
|
|
69
77
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
78
|
+
* Method decorator that auto-subscribes the decorated method to one or more Kafka topics
|
|
79
|
+
* when the NestJS module initialises.
|
|
80
|
+
*
|
|
81
|
+
* The decorated method receives a fully-decoded `EventEnvelope` for each message
|
|
82
|
+
* (or an array of envelopes + `BatchMeta` when `batch: true`).
|
|
83
|
+
*
|
|
84
|
+
* @param topics One or more topic names or `TopicDescriptor` objects. Schemas embedded in
|
|
85
|
+
* descriptors are automatically extracted and forwarded to the consumer.
|
|
86
|
+
* @param options Consumer and routing options:
|
|
87
|
+
* - All `ConsumerOptions` fields (`groupId`, `retry`, `dlq`, `fromBeginning`, …)
|
|
88
|
+
* - `clientName` — target a named `KafkaClient` (resolves `KAFKA_CLIENT_<name>` from the DI container)
|
|
89
|
+
* - `batch` — use `startBatchConsumer` instead of `startConsumer`
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```ts
|
|
93
|
+
* @SubscribeTo('orders.created', { groupId: 'orders-svc', retry: { maxRetries: 3 } })
|
|
94
|
+
* async handleOrder(envelope: EventEnvelope<Order>) { ... }
|
|
95
|
+
*
|
|
96
|
+
* @SubscribeTo(OrdersTopic, { batch: true })
|
|
97
|
+
* async handleBatch(envelopes: EventEnvelope<Order>[], meta: BatchMeta) { ... }
|
|
98
|
+
* ```
|
|
72
99
|
*/
|
|
73
100
|
declare const SubscribeTo: (topics: string | string[] | TopicDescriptor | TopicDescriptor[] | (string | TopicDescriptor)[], options?: ConsumerOptions & {
|
|
74
101
|
clientName?: string;
|
|
@@ -81,6 +108,12 @@ declare class KafkaExplorer implements OnModuleInit {
|
|
|
81
108
|
private readonly moduleRef;
|
|
82
109
|
private readonly logger;
|
|
83
110
|
constructor(discoveryService: DiscoveryService, moduleRef: ModuleRef);
|
|
111
|
+
/**
|
|
112
|
+
* Scan all NestJS providers for `@SubscribeTo()` metadata and wire each decorated
|
|
113
|
+
* method to its Kafka client via `startConsumer` or `startBatchConsumer`.
|
|
114
|
+
*
|
|
115
|
+
* Called automatically by the NestJS lifecycle — do not invoke manually.
|
|
116
|
+
*/
|
|
84
117
|
onModuleInit(): Promise<void>;
|
|
85
118
|
}
|
|
86
119
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { KafkaClient, KafkaProcessingError, KafkaRetryExhaustedError, KafkaValidationError } from './core.js';
|
|
2
|
-
import { T as TopicMapConstraint, C as ClientId, G as GroupId, K as KafkaInstrumentation, a as KafkaClientOptions, S as SchemaLike, b as ConsumerOptions, c as TopicDescriptor, I as IKafkaClient, d as KafkaHealthResult } from './types-
|
|
3
|
-
export { B as BatchMessageItem, e as BatchMeta, f as
|
|
2
|
+
import { T as TopicMapConstraint, C as ClientId, G as GroupId, K as KafkaInstrumentation, a as KafkaClientOptions, S as SchemaLike, b as ConsumerOptions, c as TopicDescriptor, I as IKafkaClient, d as KafkaHealthResult } from './types-4qWrf2aJ.js';
|
|
3
|
+
export { B as BatchMessageItem, e as BatchMeta, f as BatchSendOptions, g as BeforeConsumeResult, h as CircuitBreakerOptions, i as CompressionType, j as ConsumerGroupSummary, k as ConsumerHandle, l as ConsumerInterceptor, D as DeduplicationOptions, m as DlqReason, n as DlqReplayOptions, E as EnvelopeHeaderOptions, o as EventEnvelope, H as HEADER_CORRELATION_ID, p as HEADER_EVENT_ID, q as HEADER_LAMPORT_CLOCK, r as HEADER_SCHEMA_VERSION, s as HEADER_TIMESTAMP, t as HEADER_TRACEPARENT, u as InferSchema, v as KafkaLogger, w as KafkaMetrics, M as MessageHeaders, x as MessageLostContext, R as RetryOptions, y as SchemaParseContext, z as SendOptions, A as SubscribeRetryOptions, F as TTopicMessageMap, J as TopicDescription, L as TopicPartitionInfo, N as TopicsFrom, O as TransactionContext, P as TtlExpiredContext, Q as buildEnvelopeHeaders, U as decodeHeaders, V as extractEnvelope, W as getEnvelopeContext, X as runWithEnvelopeContext, Y as topic } from './types-4qWrf2aJ.js';
|
|
4
4
|
import { DynamicModule, OnModuleInit } from '@nestjs/common';
|
|
5
5
|
import { DiscoveryService, ModuleRef } from '@nestjs/core';
|
|
6
6
|
|
|
@@ -55,20 +55,47 @@ declare const KAFKA_CLIENT = "KAFKA_CLIENT";
|
|
|
55
55
|
/** Returns the DI token for a named (or default) Kafka client instance. */
|
|
56
56
|
declare const getKafkaClientToken: (name?: string) => string;
|
|
57
57
|
|
|
58
|
+
/** Reflect metadata key used to store `@SubscribeTo` entries on a class constructor. */
|
|
58
59
|
declare const KAFKA_SUBSCRIBER_METADATA = "KAFKA_SUBSCRIBER_METADATA";
|
|
60
|
+
/** Internal shape stored per `@SubscribeTo()` decoration on a class. */
|
|
59
61
|
interface KafkaSubscriberMetadata {
|
|
62
|
+
/** Resolved topic name strings (descriptors are unwrapped to their `__topic` string). */
|
|
60
63
|
topics: string[];
|
|
64
|
+
/** Per-topic schema validators extracted from `TopicDescriptor` objects (if any). */
|
|
61
65
|
schemas?: Map<string, SchemaLike>;
|
|
66
|
+
/** Additional consumer options forwarded to `startConsumer` / `startBatchConsumer`. */
|
|
62
67
|
options?: ConsumerOptions;
|
|
68
|
+
/** Named client identifier — resolves to `KAFKA_CLIENT_<clientName>` in the DI container. */
|
|
63
69
|
clientName?: string;
|
|
70
|
+
/** When `true`, routes to `startBatchConsumer` instead of `startConsumer`. */
|
|
64
71
|
batch?: boolean;
|
|
72
|
+
/** Name of the decorated method on the provider class. */
|
|
65
73
|
methodName?: string | symbol;
|
|
66
74
|
}
|
|
67
75
|
/** Inject a `KafkaClient` instance. Pass a name to target a specific named client. */
|
|
68
76
|
declare const InjectKafkaClient: (name?: string) => ParameterDecorator;
|
|
69
77
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
78
|
+
* Method decorator that auto-subscribes the decorated method to one or more Kafka topics
|
|
79
|
+
* when the NestJS module initialises.
|
|
80
|
+
*
|
|
81
|
+
* The decorated method receives a fully-decoded `EventEnvelope` for each message
|
|
82
|
+
* (or an array of envelopes + `BatchMeta` when `batch: true`).
|
|
83
|
+
*
|
|
84
|
+
* @param topics One or more topic names or `TopicDescriptor` objects. Schemas embedded in
|
|
85
|
+
* descriptors are automatically extracted and forwarded to the consumer.
|
|
86
|
+
* @param options Consumer and routing options:
|
|
87
|
+
* - All `ConsumerOptions` fields (`groupId`, `retry`, `dlq`, `fromBeginning`, …)
|
|
88
|
+
* - `clientName` — target a named `KafkaClient` (resolves `KAFKA_CLIENT_<name>` from the DI container)
|
|
89
|
+
* - `batch` — use `startBatchConsumer` instead of `startConsumer`
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```ts
|
|
93
|
+
* @SubscribeTo('orders.created', { groupId: 'orders-svc', retry: { maxRetries: 3 } })
|
|
94
|
+
* async handleOrder(envelope: EventEnvelope<Order>) { ... }
|
|
95
|
+
*
|
|
96
|
+
* @SubscribeTo(OrdersTopic, { batch: true })
|
|
97
|
+
* async handleBatch(envelopes: EventEnvelope<Order>[], meta: BatchMeta) { ... }
|
|
98
|
+
* ```
|
|
72
99
|
*/
|
|
73
100
|
declare const SubscribeTo: (topics: string | string[] | TopicDescriptor | TopicDescriptor[] | (string | TopicDescriptor)[], options?: ConsumerOptions & {
|
|
74
101
|
clientName?: string;
|
|
@@ -81,6 +108,12 @@ declare class KafkaExplorer implements OnModuleInit {
|
|
|
81
108
|
private readonly moduleRef;
|
|
82
109
|
private readonly logger;
|
|
83
110
|
constructor(discoveryService: DiscoveryService, moduleRef: ModuleRef);
|
|
111
|
+
/**
|
|
112
|
+
* Scan all NestJS providers for `@SubscribeTo()` metadata and wire each decorated
|
|
113
|
+
* method to its Kafka client via `startConsumer` or `startBatchConsumer`.
|
|
114
|
+
*
|
|
115
|
+
* Called automatically by the NestJS lifecycle — do not invoke manually.
|
|
116
|
+
*/
|
|
84
117
|
onModuleInit(): Promise<void>;
|
|
85
118
|
}
|
|
86
119
|
|