@drarzter/kafka-client 0.9.4 → 0.11.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 (180) hide show
  1. package/README.md +693 -8
  2. package/dist/chunk-OR7TPAAE.mjs +4760 -0
  3. package/dist/chunk-OR7TPAAE.mjs.map +1 -0
  4. package/dist/chunk-PQVBRDNV.mjs +149 -0
  5. package/dist/chunk-PQVBRDNV.mjs.map +1 -0
  6. package/dist/cli/dlq.d.ts +119 -0
  7. package/dist/cli/dlq.d.ts.map +1 -0
  8. package/dist/cli/index.d.ts +3 -0
  9. package/dist/cli/index.d.ts.map +1 -0
  10. package/dist/{chunk-SM4FZKAZ.mjs → cli/index.js} +1073 -309
  11. package/dist/cli/index.js.map +1 -0
  12. package/dist/cli/index.mjs +356 -0
  13. package/dist/cli/index.mjs.map +1 -0
  14. package/dist/client/config/from-env.d.ts +188 -0
  15. package/dist/client/config/from-env.d.ts.map +1 -0
  16. package/dist/client/config/index.d.ts +2 -0
  17. package/dist/client/config/index.d.ts.map +1 -0
  18. package/dist/client/errors.d.ts +67 -0
  19. package/dist/client/errors.d.ts.map +1 -0
  20. package/dist/client/kafka.client/admin/ops.d.ts +114 -0
  21. package/dist/client/kafka.client/admin/ops.d.ts.map +1 -0
  22. package/dist/client/kafka.client/consumer/features/delayed.d.ts +24 -0
  23. package/dist/client/kafka.client/consumer/features/delayed.d.ts.map +1 -0
  24. package/dist/client/kafka.client/consumer/features/dlq-replay.d.ts +52 -0
  25. package/dist/client/kafka.client/consumer/features/dlq-replay.d.ts.map +1 -0
  26. package/dist/client/kafka.client/consumer/features/routed.d.ts +4 -0
  27. package/dist/client/kafka.client/consumer/features/routed.d.ts.map +1 -0
  28. package/dist/client/kafka.client/consumer/features/snapshot.d.ts +10 -0
  29. package/dist/client/kafka.client/consumer/features/snapshot.d.ts.map +1 -0
  30. package/dist/client/kafka.client/consumer/features/window.d.ts +5 -0
  31. package/dist/client/kafka.client/consumer/features/window.d.ts.map +1 -0
  32. package/dist/client/kafka.client/consumer/handler.d.ts +163 -0
  33. package/dist/client/kafka.client/consumer/handler.d.ts.map +1 -0
  34. package/dist/client/kafka.client/consumer/ops.d.ts +64 -0
  35. package/dist/client/kafka.client/consumer/ops.d.ts.map +1 -0
  36. package/dist/client/kafka.client/consumer/pipeline.d.ts +168 -0
  37. package/dist/client/kafka.client/consumer/pipeline.d.ts.map +1 -0
  38. package/dist/client/kafka.client/consumer/queue.d.ts +37 -0
  39. package/dist/client/kafka.client/consumer/queue.d.ts.map +1 -0
  40. package/dist/client/kafka.client/consumer/retry-topic.d.ts +68 -0
  41. package/dist/client/kafka.client/consumer/retry-topic.d.ts.map +1 -0
  42. package/dist/client/kafka.client/consumer/setup.d.ts +66 -0
  43. package/dist/client/kafka.client/consumer/setup.d.ts.map +1 -0
  44. package/dist/client/kafka.client/consumer/start.d.ts +7 -0
  45. package/dist/client/kafka.client/consumer/start.d.ts.map +1 -0
  46. package/dist/client/kafka.client/consumer/stop.d.ts +19 -0
  47. package/dist/client/kafka.client/consumer/stop.d.ts.map +1 -0
  48. package/dist/client/kafka.client/consumer/subscribe-retry.d.ts +4 -0
  49. package/dist/client/kafka.client/consumer/subscribe-retry.d.ts.map +1 -0
  50. package/dist/client/kafka.client/context.d.ts +75 -0
  51. package/dist/client/kafka.client/context.d.ts.map +1 -0
  52. package/dist/client/kafka.client/index.d.ts +155 -0
  53. package/dist/client/kafka.client/index.d.ts.map +1 -0
  54. package/dist/client/kafka.client/infra/circuit-breaker.manager.d.ts +61 -0
  55. package/dist/client/kafka.client/infra/circuit-breaker.manager.d.ts.map +1 -0
  56. package/dist/client/kafka.client/infra/dedup.store.d.ts +28 -0
  57. package/dist/client/kafka.client/infra/dedup.store.d.ts.map +1 -0
  58. package/dist/client/kafka.client/infra/inflight.tracker.d.ts +22 -0
  59. package/dist/client/kafka.client/infra/inflight.tracker.d.ts.map +1 -0
  60. package/dist/client/kafka.client/infra/metrics.manager.d.ts +67 -0
  61. package/dist/client/kafka.client/infra/metrics.manager.d.ts.map +1 -0
  62. package/dist/client/kafka.client/producer/lifecycle.d.ts +41 -0
  63. package/dist/client/kafka.client/producer/lifecycle.d.ts.map +1 -0
  64. package/dist/client/kafka.client/producer/ops.d.ts +79 -0
  65. package/dist/client/kafka.client/producer/ops.d.ts.map +1 -0
  66. package/dist/client/kafka.client/producer/send.d.ts +21 -0
  67. package/dist/client/kafka.client/producer/send.d.ts.map +1 -0
  68. package/dist/client/kafka.client/validate-options.d.ts +11 -0
  69. package/dist/client/kafka.client/validate-options.d.ts.map +1 -0
  70. package/dist/client/message/envelope.d.ts +105 -0
  71. package/dist/client/message/envelope.d.ts.map +1 -0
  72. package/dist/client/message/schema-registry.d.ts +124 -0
  73. package/dist/client/message/schema-registry.d.ts.map +1 -0
  74. package/dist/client/message/serde.d.ts +68 -0
  75. package/dist/client/message/serde.d.ts.map +1 -0
  76. package/dist/client/message/topic.d.ts +159 -0
  77. package/dist/client/message/topic.d.ts.map +1 -0
  78. package/dist/client/message/versioned-schema.d.ts +53 -0
  79. package/dist/client/message/versioned-schema.d.ts.map +1 -0
  80. package/dist/client/outbox/index.d.ts +4 -0
  81. package/dist/client/outbox/index.d.ts.map +1 -0
  82. package/dist/client/outbox/outbox.relay.d.ts +90 -0
  83. package/dist/client/outbox/outbox.relay.d.ts.map +1 -0
  84. package/dist/client/outbox/outbox.store.d.ts +42 -0
  85. package/dist/client/outbox/outbox.store.d.ts.map +1 -0
  86. package/dist/client/outbox/outbox.types.d.ts +144 -0
  87. package/dist/client/outbox/outbox.types.d.ts.map +1 -0
  88. package/dist/client/security/acl.d.ts +108 -0
  89. package/dist/client/security/acl.d.ts.map +1 -0
  90. package/dist/client/security/index.d.ts +5 -0
  91. package/dist/client/security/index.d.ts.map +1 -0
  92. package/dist/client/security/providers.d.ts +88 -0
  93. package/dist/client/security/providers.d.ts.map +1 -0
  94. package/dist/client/security/resolve-security.d.ts +19 -0
  95. package/dist/client/security/resolve-security.d.ts.map +1 -0
  96. package/dist/client/security/security.types.d.ts +76 -0
  97. package/dist/client/security/security.types.d.ts.map +1 -0
  98. package/dist/client/transport/confluent.transport.d.ts +32 -0
  99. package/dist/client/transport/confluent.transport.d.ts.map +1 -0
  100. package/dist/client/transport/transport.interface.d.ts +221 -0
  101. package/dist/client/transport/transport.interface.d.ts.map +1 -0
  102. package/dist/client/types/admin.interface.d.ts +174 -0
  103. package/dist/client/types/admin.interface.d.ts.map +1 -0
  104. package/dist/client/types/admin.types.d.ts +140 -0
  105. package/dist/client/types/admin.types.d.ts.map +1 -0
  106. package/dist/client/types/client.d.ts +21 -0
  107. package/dist/client/types/client.d.ts.map +1 -0
  108. package/dist/client/types/common.d.ts +84 -0
  109. package/dist/client/types/common.d.ts.map +1 -0
  110. package/dist/client/types/config.types.d.ts +167 -0
  111. package/dist/client/types/config.types.d.ts.map +1 -0
  112. package/dist/client/types/consumer.interface.d.ts +115 -0
  113. package/dist/client/types/consumer.interface.d.ts.map +1 -0
  114. package/dist/{consumer.types-fFCag3VJ.d.mts → client/types/consumer.types.d.ts} +62 -383
  115. package/dist/client/types/consumer.types.d.ts.map +1 -0
  116. package/dist/client/types/dedup.types.d.ts +50 -0
  117. package/dist/client/types/dedup.types.d.ts.map +1 -0
  118. package/dist/client/types/lifecycle.interface.d.ts +72 -0
  119. package/dist/client/types/lifecycle.interface.d.ts.map +1 -0
  120. package/dist/client/types/producer.interface.d.ts +52 -0
  121. package/dist/client/types/producer.interface.d.ts.map +1 -0
  122. package/dist/client/types/producer.types.d.ts +90 -0
  123. package/dist/client/types/producer.types.d.ts.map +1 -0
  124. package/dist/client/types.d.ts +8 -0
  125. package/dist/client/types.d.ts.map +1 -0
  126. package/dist/core.d.ts +13 -314
  127. package/dist/core.d.ts.map +1 -0
  128. package/dist/core.js +1466 -123
  129. package/dist/core.js.map +1 -1
  130. package/dist/core.mjs +45 -3
  131. package/dist/index.d.ts +7 -128
  132. package/dist/index.d.ts.map +1 -0
  133. package/dist/index.js +1483 -123
  134. package/dist/index.js.map +1 -1
  135. package/dist/index.mjs +62 -3
  136. package/dist/index.mjs.map +1 -1
  137. package/dist/nest/kafka.constants.d.ts +5 -0
  138. package/dist/nest/kafka.constants.d.ts.map +1 -0
  139. package/dist/nest/kafka.decorator.d.ts +49 -0
  140. package/dist/nest/kafka.decorator.d.ts.map +1 -0
  141. package/dist/nest/kafka.explorer.d.ts +17 -0
  142. package/dist/nest/kafka.explorer.d.ts.map +1 -0
  143. package/dist/nest/kafka.health.d.ts +7 -0
  144. package/dist/nest/kafka.health.d.ts.map +1 -0
  145. package/dist/nest/kafka.module.d.ts +61 -0
  146. package/dist/nest/kafka.module.d.ts.map +1 -0
  147. package/dist/otel.d.ts +83 -5
  148. package/dist/otel.d.ts.map +1 -0
  149. package/dist/otel.js +100 -6
  150. package/dist/otel.js.map +1 -1
  151. package/dist/otel.mjs +98 -5
  152. package/dist/otel.mjs.map +1 -1
  153. package/dist/serde.d.ts +157 -0
  154. package/dist/serde.d.ts.map +1 -0
  155. package/dist/serde.js +308 -0
  156. package/dist/serde.js.map +1 -0
  157. package/dist/serde.mjs +158 -0
  158. package/dist/serde.mjs.map +1 -0
  159. package/dist/testing/client.mock.d.ts +47 -0
  160. package/dist/testing/client.mock.d.ts.map +1 -0
  161. package/dist/testing/index.d.ts +4 -0
  162. package/dist/testing/index.d.ts.map +1 -0
  163. package/dist/testing/test.container.d.ts +63 -0
  164. package/dist/testing/test.container.d.ts.map +1 -0
  165. package/dist/{testing.d.mts → testing/transport.fake.d.ts} +7 -111
  166. package/dist/testing/transport.fake.d.ts.map +1 -0
  167. package/dist/testing.d.ts +2 -318
  168. package/dist/testing.d.ts.map +1 -0
  169. package/dist/testing.js +26 -0
  170. package/dist/testing.js.map +1 -1
  171. package/dist/testing.mjs +26 -0
  172. package/dist/testing.mjs.map +1 -1
  173. package/package.json +40 -8
  174. package/dist/chunk-SM4FZKAZ.mjs.map +0 -1
  175. package/dist/client-1irhGEu0.d.mts +0 -751
  176. package/dist/client-BpFjkHhr.d.ts +0 -751
  177. package/dist/consumer.types-fFCag3VJ.d.ts +0 -958
  178. package/dist/core.d.mts +0 -314
  179. package/dist/index.d.mts +0 -128
  180. package/dist/otel.d.mts +0 -27
@@ -0,0 +1,221 @@
1
+ /** A topic-partition pair. */
2
+ export type ITopicPartition = {
3
+ topic: string;
4
+ partition: number;
5
+ };
6
+ /** A topic-partition pair with an absolute offset string. */
7
+ export type ITopicPartitionOffset = {
8
+ topic: string;
9
+ partition: number;
10
+ offset: string;
11
+ };
12
+ /** Pause / resume assignment shape: one topic + its partition list. */
13
+ export type ITopicPartitions = {
14
+ topic: string;
15
+ partitions: number[];
16
+ };
17
+ /** A single message in a produce request. */
18
+ export type IProducerMessage = {
19
+ /**
20
+ * Wire payload. `string` for text serdes (e.g. JSON), `Buffer` for binary
21
+ * serdes (Avro/Protobuf) and for losslessly re-forwarded messages
22
+ * (DLQ / retry / duplicates / delayed relay). librdkafka accepts both.
23
+ */
24
+ value: string | Buffer | null;
25
+ key?: string | null;
26
+ headers?: Record<string, string | Buffer | string[]>;
27
+ };
28
+ /** Produce request payload for one topic. */
29
+ export type IProducerRecord = {
30
+ topic: string;
31
+ messages: IProducerMessage[];
32
+ };
33
+ /** Options for creating a producer. */
34
+ export type IProducerCreationOptions = {
35
+ /** When set, the producer uses idempotent + exactly-once semantics. */
36
+ transactionalId?: string;
37
+ /** Enable idempotent writes (required for `transactionalId`). */
38
+ idempotent?: boolean;
39
+ };
40
+ /** An open Kafka transaction. */
41
+ export interface ITransaction {
42
+ send(record: IProducerRecord): Promise<void>;
43
+ /**
44
+ * Atomically commit offsets for `consumer` as part of this transaction.
45
+ * The `consumer` parameter must be the `IConsumer` whose offsets are being committed.
46
+ */
47
+ sendOffsets(options: {
48
+ consumer: IConsumer;
49
+ topics: Array<{
50
+ topic: string;
51
+ partitions: Array<{
52
+ partition: number;
53
+ offset: string;
54
+ }>;
55
+ }>;
56
+ }): Promise<void>;
57
+ commit(): Promise<void>;
58
+ abort(): Promise<void>;
59
+ }
60
+ /** A Kafka producer. */
61
+ export interface IProducer {
62
+ connect(): Promise<void>;
63
+ disconnect(): Promise<void>;
64
+ send(record: IProducerRecord): Promise<void>;
65
+ transaction(): Promise<ITransaction>;
66
+ }
67
+ /** A single message in an `eachMessage` callback. */
68
+ export type IMessage = {
69
+ value: Buffer | null;
70
+ /** Header map as returned by librdkafka — values may be arrays. */
71
+ headers: Record<string, any>;
72
+ offset: string;
73
+ key: Buffer | null;
74
+ };
75
+ /** Payload passed to the `eachMessage` handler. */
76
+ export type IEachMessagePayload = {
77
+ topic: string;
78
+ partition: number;
79
+ message: IMessage;
80
+ };
81
+ /** A batch of messages from one topic-partition. */
82
+ export type IMessageBatch = {
83
+ topic: string;
84
+ partition: number;
85
+ messages: IMessage[];
86
+ highWatermark: string;
87
+ };
88
+ /** Payload passed to the `eachBatch` handler. */
89
+ export type IEachBatchPayload = {
90
+ batch: IMessageBatch;
91
+ /** Send a heartbeat to the broker to prevent session timeout. */
92
+ heartbeat: () => Promise<void>;
93
+ /** Mark `offset` as processed (without committing). */
94
+ resolveOffset: (offset: string) => void;
95
+ /** Commit if the auto-commit threshold has been reached. */
96
+ commitOffsetsIfNecessary: () => Promise<void>;
97
+ };
98
+ /** Configuration passed to `IConsumer.run()`. */
99
+ export type IConsumerRunConfig = {
100
+ eachMessage?: (payload: IEachMessagePayload) => Promise<void>;
101
+ eachBatch?: (payload: IEachBatchPayload) => Promise<void>;
102
+ };
103
+ /** Options for creating a consumer. */
104
+ export type IConsumerCreationOptions = {
105
+ groupId: string;
106
+ fromBeginning?: boolean;
107
+ autoCommit?: boolean;
108
+ partitionAssigner?: "cooperative-sticky" | "roundrobin" | "range";
109
+ /**
110
+ * Static group membership id (`group.instance.id`). A member that restarts
111
+ * within the broker's `session.timeout.ms` rejoins with the same partitions
112
+ * and no rebalance — useful for k8s rolling restarts.
113
+ * Must be unique per member within a consumer group.
114
+ */
115
+ groupInstanceId?: string;
116
+ /** Fired on every partition assign/revoke. */
117
+ onRebalance?: (type: "assign" | "revoke", assignments: ITopicPartition[]) => void;
118
+ };
119
+ /** A Kafka consumer. */
120
+ export interface IConsumer {
121
+ connect(): Promise<void>;
122
+ disconnect(): Promise<void>;
123
+ subscribe(options: {
124
+ topics: (string | RegExp)[];
125
+ }): Promise<void>;
126
+ run(config: IConsumerRunConfig): Promise<void>;
127
+ pause(assignments: ITopicPartitions[]): void;
128
+ resume(assignments: ITopicPartitions[]): void;
129
+ /** Seek a partition to an explicit offset. */
130
+ seek(options: ITopicPartitionOffset): void;
131
+ /** Current partition assignment for this consumer. */
132
+ assignment(): ITopicPartition[];
133
+ commitOffsets(offsets: ITopicPartitionOffset[]): Promise<void>;
134
+ /** Stop processing (alias for disconnect in some usages). */
135
+ stop(): Promise<void>;
136
+ }
137
+ /** Low/current/high watermark offsets for one partition. */
138
+ export type IPartitionWatermarks = {
139
+ partition: number;
140
+ low: string;
141
+ high: string;
142
+ };
143
+ /** A partition → offset pair. */
144
+ export type IPartitionOffset = {
145
+ partition: number;
146
+ offset: string;
147
+ };
148
+ /** Committed offsets for a group's topic. */
149
+ export type IGroupTopicOffsets = {
150
+ topic: string;
151
+ partitions: IPartitionOffset[];
152
+ };
153
+ /** A consumer group descriptor. */
154
+ export type IGroupDescription = {
155
+ groupId: string;
156
+ state?: string;
157
+ };
158
+ /** Partition metadata. */
159
+ export type IPartitionMetadata = {
160
+ partitionId?: number;
161
+ partition?: number;
162
+ leader?: number;
163
+ replicas?: (number | {
164
+ nodeId: number;
165
+ })[];
166
+ isr?: (number | {
167
+ nodeId: number;
168
+ })[];
169
+ };
170
+ /** Topic metadata. */
171
+ export type ITopicMetadata = {
172
+ name: string;
173
+ partitions: IPartitionMetadata[];
174
+ };
175
+ /** A Kafka admin client. */
176
+ export interface IAdmin {
177
+ connect(): Promise<void>;
178
+ disconnect(): Promise<void>;
179
+ createTopics(options: {
180
+ topics: Array<{
181
+ topic: string;
182
+ numPartitions: number;
183
+ }>;
184
+ }): Promise<void>;
185
+ fetchTopicOffsets(topic: string): Promise<IPartitionWatermarks[]>;
186
+ fetchTopicOffsetsByTimestamp(topic: string, timestamp: number): Promise<IPartitionOffset[]>;
187
+ fetchOffsets(options: {
188
+ groupId: string;
189
+ }): Promise<IGroupTopicOffsets[]>;
190
+ setOffsets(options: {
191
+ groupId: string;
192
+ topic: string;
193
+ partitions: IPartitionOffset[];
194
+ }): Promise<void>;
195
+ listTopics(): Promise<string[]>;
196
+ listGroups(): Promise<{
197
+ groups: IGroupDescription[];
198
+ }>;
199
+ fetchTopicMetadata(options?: {
200
+ topics?: string[];
201
+ }): Promise<{
202
+ topics: ITopicMetadata[];
203
+ }>;
204
+ deleteGroups(groupIds: string[]): Promise<void>;
205
+ deleteTopicRecords(options: {
206
+ topic: string;
207
+ partitions: IPartitionOffset[];
208
+ }): Promise<void>;
209
+ }
210
+ /**
211
+ * Factory that creates connected Kafka primitives.
212
+ * The default implementation wraps `@confluentinc/kafka-javascript` via
213
+ * `ConfluentTransport`. Inject a custom transport (e.g. a fake) via
214
+ * `KafkaClientOptions.transport` for testing or alternative broker support.
215
+ */
216
+ export interface KafkaTransport {
217
+ producer(options?: IProducerCreationOptions): IProducer;
218
+ consumer(options: IConsumerCreationOptions): IConsumer;
219
+ admin(): IAdmin;
220
+ }
221
+ //# sourceMappingURL=transport.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.interface.d.ts","sourceRoot":"","sources":["../../../src/client/transport/transport.interface.ts"],"names":[],"mappings":"AASA,8BAA8B;AAC9B,MAAM,MAAM,eAAe,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnE,6DAA6D;AAC7D,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AA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AwB,GAAG,SAAS,CAAC;IACxD,QAAQ,CAAC,OAAO,EAAE,wBAAwB,GAAG,SAAS,CAAC;IACvD,KAAK,IAAI,MAAM,CAAC;CACjB"}
@@ -0,0 +1,174 @@
1
+ import type { TopicMapConstraint } from "./common";
2
+ import type { KafkaHealthResult, ConsumerGroupSummary, TopicDescription, ReadSnapshotOptions, CheckpointResult, RestoreCheckpointOptions, CheckpointRestoreResult, DlqReplayOptions } from "./admin.types";
3
+ import type { EventEnvelope } from "../message/envelope";
4
+ /** Admin, offset-management, and state methods of `IKafkaClient`. */
5
+ export interface IKafkaAdmin<T extends TopicMapConstraint<T>> {
6
+ /**
7
+ * @example
8
+ * ```ts
9
+ * const status = await kafka.checkStatus();
10
+ * if (status.status === 'down') console.error(status.error);
11
+ * ```
12
+ */
13
+ checkStatus(): Promise<KafkaHealthResult>;
14
+ /**
15
+ * List all consumer groups known to the broker.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * const groups = await kafka.listConsumerGroups();
20
+ * console.log(groups.map(g => `${g.groupId}: ${g.state}`));
21
+ * ```
22
+ */
23
+ listConsumerGroups(): Promise<ConsumerGroupSummary[]>;
24
+ /**
25
+ * Describe topics — returns partition layout, leader, replicas, and ISR for each topic.
26
+ * Omit `topics` to describe all topics visible to this client.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * const [desc] = await kafka.describeTopics(['orders.created']);
31
+ * console.log(desc.partitions.length);
32
+ * ```
33
+ */
34
+ describeTopics(topics?: string[]): Promise<TopicDescription[]>;
35
+ /**
36
+ * Delete records from a topic up to (but not including) the specified offsets.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * await kafka.deleteRecords('orders.created', [
41
+ * { partition: 0, offset: '1000' },
42
+ * { partition: 1, offset: '500' },
43
+ * ]);
44
+ * ```
45
+ */
46
+ deleteRecords(topic: string, partitions: Array<{
47
+ partition: number;
48
+ offset: string;
49
+ }>): Promise<void>;
50
+ /**
51
+ * Query the consumer group lag per partition.
52
+ * Lag = (broker high-watermark offset) − (last committed offset).
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * const lag = await kafka.getConsumerLag();
57
+ * const total = lag.reduce((sum, p) => sum + p.lag, 0);
58
+ * ```
59
+ */
60
+ getConsumerLag(groupId?: string): Promise<Array<{
61
+ topic: string;
62
+ partition: number;
63
+ lag: number;
64
+ }>>;
65
+ /**
66
+ * Consume all messages in `{topic}.dlq` and re-publish each to its original topic
67
+ * (or `options.targetTopic`). The DLQ topic itself is not modified.
68
+ *
69
+ * @returns `{ replayed, skipped }` counts.
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * const { replayed } = await kafka.replayDlq('orders.created');
74
+ * ```
75
+ */
76
+ replayDlq(topic: string, options?: DlqReplayOptions): Promise<{
77
+ replayed: number;
78
+ skipped: number;
79
+ }>;
80
+ /**
81
+ * Reset committed offsets to `'earliest'` or `'latest'`.
82
+ * The consumer group must be inactive — call `stopConsumer(groupId)` first.
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * await kafka.stopConsumer('billing-service');
87
+ * await kafka.resetOffsets('billing-service', 'orders.created', 'earliest');
88
+ * ```
89
+ */
90
+ resetOffsets(groupId: string | undefined, topic: string, position: "earliest" | "latest"): Promise<void>;
91
+ /**
92
+ * Seek specific partitions to explicit offsets.
93
+ * The consumer group must be inactive.
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * await kafka.seekToOffset('billing-service', [
98
+ * { topic: 'orders.created', partition: 0, offset: '1000' },
99
+ * ]);
100
+ * ```
101
+ */
102
+ seekToOffset(groupId: string | undefined, assignments: Array<{
103
+ topic: string;
104
+ partition: number;
105
+ offset: string;
106
+ }>): Promise<void>;
107
+ /**
108
+ * Seek partitions to the offset nearest to a given Unix timestamp (ms).
109
+ * The consumer group must be inactive.
110
+ *
111
+ * @example
112
+ * ```ts
113
+ * const midnight = new Date('2025-01-01').getTime();
114
+ * await kafka.seekToTimestamp('billing-service', [
115
+ * { topic: 'orders.created', partition: 0, timestamp: midnight },
116
+ * ]);
117
+ * ```
118
+ */
119
+ seekToTimestamp(groupId: string | undefined, assignments: Array<{
120
+ topic: string;
121
+ partition: number;
122
+ timestamp: number;
123
+ }>): Promise<void>;
124
+ /**
125
+ * Returns the current circuit breaker state for a topic partition.
126
+ * Returns `undefined` when `circuitBreaker` is not configured or never tripped.
127
+ *
128
+ * @example
129
+ * ```ts
130
+ * const state = kafka.getCircuitState('orders.created', 0);
131
+ * if (state?.status === 'open') console.warn('Circuit open!', state.failures);
132
+ * ```
133
+ */
134
+ getCircuitState(topic: string, partition: number, groupId?: string): {
135
+ status: "closed" | "open" | "half-open";
136
+ failures: number;
137
+ windowSize: number;
138
+ } | undefined;
139
+ /**
140
+ * Read a compacted topic from the beginning to its high-watermark and return a
141
+ * `Map<key, EventEnvelope<T>>` with the latest value per key.
142
+ * Tombstone records remove the key from the map.
143
+ *
144
+ * @example
145
+ * ```ts
146
+ * const orders = await kafka.readSnapshot('orders.state');
147
+ * // orders.get('order-123') → latest EventEnvelope for that key
148
+ * ```
149
+ */
150
+ readSnapshot<K extends keyof T & string>(topic: K, options?: ReadSnapshotOptions): Promise<Map<string, EventEnvelope<T[K]>>>;
151
+ /**
152
+ * Snapshot the current committed offsets of a consumer group into a Kafka topic.
153
+ * Requires `connectProducer()` to have been called.
154
+ *
155
+ * @example
156
+ * ```ts
157
+ * const result = await kafka.checkpointOffsets(undefined, 'checkpoints');
158
+ * console.log(`Saved ${result.partitionCount} offsets at ${result.savedAt}`);
159
+ * ```
160
+ */
161
+ checkpointOffsets(groupId: string | undefined, checkpointTopic: string): Promise<CheckpointResult>;
162
+ /**
163
+ * Restore a consumer group's committed offsets from the nearest checkpoint.
164
+ * The consumer group must be stopped before calling this method.
165
+ *
166
+ * @example
167
+ * ```ts
168
+ * await kafka.stopConsumer('billing-service');
169
+ * const result = await kafka.restoreFromCheckpoint(undefined, 'checkpoints');
170
+ * ```
171
+ */
172
+ restoreFromCheckpoint(groupId: string | undefined, checkpointTopic: string, options?: RestoreCheckpointOptions): Promise<CheckpointRestoreResult>;
173
+ }
174
+ //# sourceMappingURL=admin.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin.interface.d.ts","sourceRoot":"","sources":["../../../src/client/types/admin.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AACnD,OAAO,KAAK,EACV,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,wBAAwB,EACxB,uBAAuB,EACvB,gBAAgB,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,qEAAqE;AACrE,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,kBAAkB,CAAC,CAAC,CAAC;IAC1D;;;;;;OAMG;IACH,WAAW,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAE1C;;;;;;;;OAQG;IACH,kBAAkB,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAEtD;;;;;;;;;OASG;IACH,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAE/D;;;;;;;;;;OAUG;IACH,aAAa,CACX,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,KAAK,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,GACvD,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB;;;;;;;;;OASG;IACH,cAAc,CACZ,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IAErE;;;;;;;;;;OAUG;IACH,SAAS,CACP,KAAK,EAAE,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,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAE7C;;;;;;;;;OASG;IACH,iBAAiB,CACf,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAE7B;;;;;;;;;OASG;IACH,qBAAqB,CACnB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,eAAe,EAAE,MAAM,EACvB,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,uBAAuB,CAAC,CAAC;CACrC"}
@@ -0,0 +1,140 @@
1
+ import type { MessageHeaders } from "./common";
2
+ import type { SchemaLike } from "../message/topic";
3
+ /**
4
+ * Options for `readSnapshot`.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * const snapshot = await kafka.readSnapshot('users.state', {
9
+ * schema: UserSchema,
10
+ * onTombstone: (key) => console.log(`Key ${key} was compacted away`),
11
+ * });
12
+ * ```
13
+ */
14
+ export interface ReadSnapshotOptions {
15
+ /**
16
+ * Schema to validate each message payload against (Zod, Valibot, ArkType, or any `.parse()` shape).
17
+ * Messages that fail validation are skipped with a warning log — they do not throw.
18
+ */
19
+ schema?: SchemaLike;
20
+ /**
21
+ * Called when a tombstone record (null-value message) is encountered.
22
+ * The corresponding key is removed from the snapshot automatically.
23
+ * Use this for auditing or logging which keys were compacted away.
24
+ */
25
+ onTombstone?: (key: string) => void;
26
+ }
27
+ /** A single partition offset entry stored in a checkpoint record. */
28
+ export interface CheckpointEntry {
29
+ topic: string;
30
+ partition: number;
31
+ offset: string;
32
+ }
33
+ /** Result returned by a successful `checkpointOffsets` call. */
34
+ export interface CheckpointResult {
35
+ /** Consumer group whose offsets were saved. */
36
+ groupId: string;
37
+ /** Topics included in the checkpoint. */
38
+ topics: string[];
39
+ /** Total number of topic-partition pairs saved. */
40
+ partitionCount: number;
41
+ /** Unix timestamp (ms) when the checkpoint was created. */
42
+ savedAt: number;
43
+ }
44
+ /** Options for `restoreFromCheckpoint`. */
45
+ export interface RestoreCheckpointOptions {
46
+ /**
47
+ * Target Unix timestamp (ms). The newest checkpoint whose `savedAt` is **≤ this value**
48
+ * is selected. Defaults to the latest available checkpoint when omitted.
49
+ */
50
+ timestamp?: number;
51
+ }
52
+ /** Result returned by a successful `restoreFromCheckpoint` call. */
53
+ export interface CheckpointRestoreResult {
54
+ /** Consumer group that was repositioned. */
55
+ groupId: string;
56
+ /** The committed offsets restored from the checkpoint. */
57
+ offsets: CheckpointEntry[];
58
+ /** Unix timestamp (ms) recorded when the checkpoint was originally saved. */
59
+ restoredAt: number;
60
+ /** Age of the restored checkpoint in milliseconds (now − `restoredAt`). */
61
+ checkpointAge: number;
62
+ }
63
+ /**
64
+ * Options for `replayDlq`.
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * await kafka.replayDlq('orders.created', {
69
+ * targetTopic: 'orders.retry-manual',
70
+ * dryRun: false,
71
+ * filter: (headers, value) =>
72
+ * headers['x-dlq-reason'] === 'handler-error' &&
73
+ * JSON.parse(value).amount > 0,
74
+ * });
75
+ * ```
76
+ */
77
+ export interface DlqReplayOptions {
78
+ /**
79
+ * Override the target topic to re-publish to.
80
+ * Default: reads the `x-dlq-original-topic` header from each DLQ message.
81
+ */
82
+ targetTopic?: string;
83
+ /**
84
+ * Dry-run mode — log what would be replayed without actually sending.
85
+ * Increments the `replayed` counter so you can see what would happen.
86
+ */
87
+ dryRun?: boolean;
88
+ /**
89
+ * Optional filter — return `false` to skip a message.
90
+ * @param headers All headers on the DLQ message (including `x-dlq-*` metadata).
91
+ * @param value Raw message value (JSON string).
92
+ */
93
+ filter?: (headers: MessageHeaders, value: string) => boolean;
94
+ /**
95
+ * Seek to the earliest available offset before consuming, regardless of any
96
+ * previously committed offsets for the replay consumer group.
97
+ * Default: `true` — full replay of all DLQ messages on every call.
98
+ * Set to `false` to replay only messages added since the previous `replayDlq` call.
99
+ */
100
+ fromBeginning?: boolean;
101
+ }
102
+ /** Result returned by `KafkaClient.checkStatus()`. */
103
+ export type KafkaHealthResult = {
104
+ status: "up";
105
+ clientId: string;
106
+ topics: string[];
107
+ } | {
108
+ status: "down";
109
+ clientId: string;
110
+ error: string;
111
+ };
112
+ /** Summary of a consumer group returned by `listConsumerGroups`. */
113
+ export interface ConsumerGroupSummary {
114
+ /** Consumer group ID. */
115
+ groupId: string;
116
+ /**
117
+ * Current broker-reported state of the group.
118
+ * Common values: `'Empty'`, `'Stable'`, `'PreparingRebalance'`, `'CompletingRebalance'`, `'Dead'`.
119
+ */
120
+ state: string;
121
+ }
122
+ /** Partition-level metadata for a topic. */
123
+ export interface TopicPartitionInfo {
124
+ /** Partition index (0-based). */
125
+ partition: number;
126
+ /** Node ID of the partition leader broker. */
127
+ leader: number;
128
+ /** Node IDs of all replica brokers. */
129
+ replicas: number[];
130
+ /** Node IDs of in-sync replicas. */
131
+ isr: number[];
132
+ }
133
+ /** Topic metadata returned by `describeTopics`. */
134
+ export interface TopicDescription {
135
+ /** Topic name. */
136
+ name: string;
137
+ /** Per-partition metadata. */
138
+ partitions: TopicPartitionInfo[];
139
+ }
140
+ //# sourceMappingURL=admin.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin.types.d.ts","sourceRoot":"","sources":["../../../src/client/types/admin.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAInD;;;;;;;;;;GAUG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB;;;;OAIG;IACH,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC;AAID,qEAAqE;AACrE,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,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;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED,4CAA4C;AAC5C,MAAM,WAAW,kBAAkB;IACjC,iCAAiC;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,oCAAoC;IACpC,GAAG,EAAE,MAAM,EAAE,CAAC;CACf;AAED,mDAAmD;AACnD,MAAM,WAAW,gBAAgB;IAC/B,kBAAkB;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,8BAA8B;IAC9B,UAAU,EAAE,kBAAkB,EAAE,CAAC;CAClC"}
@@ -0,0 +1,21 @@
1
+ import type { TopicMapConstraint } from "./common";
2
+ import type { IKafkaProducer } from "./producer.interface";
3
+ import type { IKafkaConsumer } from "./consumer.interface";
4
+ import type { IKafkaAdmin } from "./admin.interface";
5
+ import type { IKafkaLifecycle } from "./lifecycle.interface";
6
+ export type { IKafkaProducer } from "./producer.interface";
7
+ export type { IKafkaConsumer } from "./consumer.interface";
8
+ export type { IKafkaAdmin } from "./admin.interface";
9
+ export type { IKafkaLifecycle } from "./lifecycle.interface";
10
+ /**
11
+ * Full Kafka client interface — the union of all role-specific sub-interfaces.
12
+ *
13
+ * Compose sub-interfaces directly when you need a narrower dependency:
14
+ * ```ts
15
+ * function sendOrder(producer: IKafkaProducer<MyTopics>) { ... }
16
+ * function startWorker(consumer: IKafkaConsumer<MyTopics>) { ... }
17
+ * ```
18
+ */
19
+ export interface IKafkaClient<T extends TopicMapConstraint<T>> extends IKafkaProducer<T>, IKafkaConsumer<T>, IKafkaAdmin<T>, IKafkaLifecycle {
20
+ }
21
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/client/types/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAY,CAAC,CAAC,SAAS,kBAAkB,CAAC,CAAC,CAAC,CAC3D,SAAQ,cAAc,CAAC,CAAC,CAAC,EACvB,cAAc,CAAC,CAAC,CAAC,EACjB,WAAW,CAAC,CAAC,CAAC,EACd,eAAe;CAAG"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Mapping of topic names to their message types.
3
+ * Define this interface to get type-safe publish/subscribe across your app.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * // with explicit extends (IDE hints for values)
8
+ * interface MyTopics extends TTopicMessageMap {
9
+ * "orders.created": { orderId: string; amount: number };
10
+ * "users.updated": { userId: string; name: string };
11
+ * }
12
+ *
13
+ * // or plain interface / type — works the same
14
+ * interface MyTopics {
15
+ * "orders.created": { orderId: string; amount: number };
16
+ * }
17
+ * ```
18
+ */
19
+ export type TTopicMessageMap = {
20
+ [topic: string]: Record<string, any>;
21
+ };
22
+ /**
23
+ * Generic constraint for topic-message maps.
24
+ * Works with both `type` aliases and `interface` declarations.
25
+ */
26
+ export type TopicMapConstraint<T> = {
27
+ [K in keyof T]: Record<string, any>;
28
+ };
29
+ export type ClientId = string;
30
+ export type GroupId = string;
31
+ export type MessageHeaders = Record<string, string>;
32
+ /**
33
+ * Message compression codec.
34
+ * Maps directly to the underlying librdkafka codec values.
35
+ * - `'none'` — no compression (default)
36
+ * - `'gzip'` — widely supported, moderate compression ratio
37
+ * - `'snappy'` — fast, moderate compression ratio
38
+ * - `'lz4'` — fastest, slightly lower ratio
39
+ * - `'zstd'` — best ratio, slightly slower
40
+ */
41
+ export type CompressionType = "none" | "gzip" | "snappy" | "lz4" | "zstd";
42
+ /**
43
+ * Logger interface for KafkaClient.
44
+ * Compatible with NestJS Logger, console, winston, pino, or any custom logger.
45
+ *
46
+ * `debug` is optional — omit it to suppress debug output in production.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * // Pass a NestJS logger:
51
+ * const kafka = new KafkaClient(config, groupId, { logger: this.logger });
52
+ *
53
+ * // Or a minimal pino wrapper:
54
+ * const kafka = new KafkaClient(config, groupId, {
55
+ * logger: {
56
+ * log: (msg) => pino.info(msg),
57
+ * warn: (msg, ...a) => pino.warn(msg, ...a),
58
+ * error: (msg, ...a) => pino.error(msg, ...a),
59
+ * debug: (msg, ...a) => pino.debug(msg, ...a),
60
+ * },
61
+ * });
62
+ * ```
63
+ */
64
+ export interface KafkaLogger {
65
+ log(message: string): void;
66
+ warn(message: string, ...args: any[]): void;
67
+ error(message: string, ...args: any[]): void;
68
+ debug?(message: string, ...args: any[]): void;
69
+ }
70
+ /**
71
+ * Snapshot of internal event counters accumulated since client creation
72
+ * (or since the last `resetMetrics()` call).
73
+ */
74
+ export interface KafkaMetrics {
75
+ /** Total messages successfully processed by the consumer handler. */
76
+ processedCount: number;
77
+ /** Total retry attempts routed — covers both in-process retries and retry-topic hops. */
78
+ retryCount: number;
79
+ /** Total messages sent to a DLQ topic. */
80
+ dlqCount: number;
81
+ /** Total duplicate messages detected by the Lamport clock. */
82
+ dedupCount: number;
83
+ }
84
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/client/types/common.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;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