kafka-ts 0.0.1-beta → 0.0.3-beta

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 (188) hide show
  1. package/.github/workflows/release.yml +17 -0
  2. package/.prettierrc +3 -2
  3. package/LICENSE +1 -1
  4. package/README.md +48 -35
  5. package/docker-compose.yml +102 -102
  6. package/examples/package-lock.json +28 -27
  7. package/examples/package.json +12 -12
  8. package/examples/src/client.ts +6 -6
  9. package/examples/src/consumer.ts +9 -8
  10. package/examples/src/create-topic.ts +23 -16
  11. package/examples/src/producer.ts +7 -7
  12. package/examples/src/replicator.ts +4 -4
  13. package/examples/src/utils/delay.ts +1 -0
  14. package/examples/src/utils/json.ts +1 -1
  15. package/examples/tsconfig.json +2 -2
  16. package/package.json +21 -15
  17. package/src/__snapshots__/request-handler.test.ts.snap +9 -718
  18. package/src/api/api-versions.ts +2 -2
  19. package/src/api/create-topics.ts +2 -2
  20. package/src/api/delete-topics.ts +2 -2
  21. package/src/api/fetch.ts +3 -3
  22. package/src/api/find-coordinator.ts +2 -2
  23. package/src/api/heartbeat.ts +2 -2
  24. package/src/api/index.ts +18 -18
  25. package/src/api/init-producer-id.ts +2 -2
  26. package/src/api/join-group.ts +3 -3
  27. package/src/api/leave-group.ts +2 -2
  28. package/src/api/list-offsets.ts +3 -3
  29. package/src/api/metadata.ts +3 -3
  30. package/src/api/offset-commit.ts +2 -2
  31. package/src/api/offset-fetch.ts +2 -2
  32. package/src/api/produce.ts +3 -3
  33. package/src/api/sasl-authenticate.ts +2 -2
  34. package/src/api/sasl-handshake.ts +2 -2
  35. package/src/api/sync-group.ts +2 -2
  36. package/src/broker.ts +9 -9
  37. package/src/client.ts +6 -6
  38. package/src/{request-handler.test.ts → cluster.test.ts} +72 -69
  39. package/src/cluster.ts +7 -7
  40. package/src/connection.ts +17 -15
  41. package/src/consumer/consumer-group.ts +14 -14
  42. package/src/consumer/consumer-metadata.ts +2 -2
  43. package/src/consumer/consumer.ts +84 -82
  44. package/src/consumer/fetch-manager.ts +179 -0
  45. package/src/consumer/fetcher.ts +57 -0
  46. package/src/consumer/offset-manager.ts +6 -6
  47. package/src/consumer/processor.ts +47 -0
  48. package/src/distributors/assignments-to-replicas.test.ts +7 -7
  49. package/src/distributors/assignments-to-replicas.ts +1 -1
  50. package/src/distributors/messages-to-topic-partition-leaders.test.ts +6 -6
  51. package/src/index.ts +4 -3
  52. package/src/metadata.ts +4 -4
  53. package/src/producer/producer.ts +8 -8
  54. package/src/types.ts +2 -0
  55. package/src/utils/api.ts +4 -4
  56. package/src/utils/debug.ts +2 -2
  57. package/src/utils/decoder.ts +4 -4
  58. package/src/utils/encoder.ts +6 -6
  59. package/src/utils/error.ts +3 -3
  60. package/src/utils/retrier.ts +1 -1
  61. package/src/utils/tracer.ts +7 -4
  62. package/tsconfig.json +16 -16
  63. package/dist/api/api-versions.d.ts +0 -9
  64. package/dist/api/api-versions.js +0 -24
  65. package/dist/api/create-topics.d.ts +0 -38
  66. package/dist/api/create-topics.js +0 -53
  67. package/dist/api/delete-topics.d.ts +0 -18
  68. package/dist/api/delete-topics.js +0 -33
  69. package/dist/api/fetch.d.ts +0 -77
  70. package/dist/api/fetch.js +0 -106
  71. package/dist/api/find-coordinator.d.ts +0 -21
  72. package/dist/api/find-coordinator.js +0 -39
  73. package/dist/api/heartbeat.d.ts +0 -11
  74. package/dist/api/heartbeat.js +0 -27
  75. package/dist/api/index.d.ts +0 -573
  76. package/dist/api/index.js +0 -164
  77. package/dist/api/init-producer-id.d.ts +0 -13
  78. package/dist/api/init-producer-id.js +0 -29
  79. package/dist/api/join-group.d.ts +0 -34
  80. package/dist/api/join-group.js +0 -51
  81. package/dist/api/leave-group.d.ts +0 -19
  82. package/dist/api/leave-group.js +0 -39
  83. package/dist/api/list-offsets.d.ts +0 -29
  84. package/dist/api/list-offsets.js +0 -48
  85. package/dist/api/metadata.d.ts +0 -40
  86. package/dist/api/metadata.js +0 -58
  87. package/dist/api/offset-commit.d.ts +0 -28
  88. package/dist/api/offset-commit.js +0 -48
  89. package/dist/api/offset-fetch.d.ts +0 -33
  90. package/dist/api/offset-fetch.js +0 -57
  91. package/dist/api/produce.d.ts +0 -53
  92. package/dist/api/produce.js +0 -129
  93. package/dist/api/sasl-authenticate.d.ts +0 -11
  94. package/dist/api/sasl-authenticate.js +0 -23
  95. package/dist/api/sasl-handshake.d.ts +0 -6
  96. package/dist/api/sasl-handshake.js +0 -19
  97. package/dist/api/sync-group.d.ts +0 -24
  98. package/dist/api/sync-group.js +0 -36
  99. package/dist/broker.d.ts +0 -29
  100. package/dist/broker.js +0 -60
  101. package/dist/client.d.ts +0 -23
  102. package/dist/client.js +0 -36
  103. package/dist/cluster.d.ts +0 -24
  104. package/dist/cluster.js +0 -72
  105. package/dist/connection.d.ts +0 -25
  106. package/dist/connection.js +0 -155
  107. package/dist/consumer/consumer-group.d.ts +0 -36
  108. package/dist/consumer/consumer-group.js +0 -182
  109. package/dist/consumer/consumer-metadata.d.ts +0 -7
  110. package/dist/consumer/consumer-metadata.js +0 -14
  111. package/dist/consumer/consumer.d.ts +0 -37
  112. package/dist/consumer/consumer.js +0 -178
  113. package/dist/consumer/metadata.d.ts +0 -24
  114. package/dist/consumer/metadata.js +0 -64
  115. package/dist/consumer/offset-manager.d.ts +0 -22
  116. package/dist/consumer/offset-manager.js +0 -56
  117. package/dist/distributors/assignments-to-replicas.d.ts +0 -17
  118. package/dist/distributors/assignments-to-replicas.js +0 -60
  119. package/dist/distributors/assignments-to-replicas.test.d.ts +0 -1
  120. package/dist/distributors/assignments-to-replicas.test.js +0 -40
  121. package/dist/distributors/messages-to-topic-partition-leaders.d.ts +0 -17
  122. package/dist/distributors/messages-to-topic-partition-leaders.js +0 -15
  123. package/dist/distributors/messages-to-topic-partition-leaders.test.d.ts +0 -1
  124. package/dist/distributors/messages-to-topic-partition-leaders.test.js +0 -30
  125. package/dist/examples/src/replicator.js +0 -34
  126. package/dist/examples/src/utils/json.js +0 -5
  127. package/dist/index.d.ts +0 -3
  128. package/dist/index.js +0 -19
  129. package/dist/metadata.d.ts +0 -24
  130. package/dist/metadata.js +0 -89
  131. package/dist/producer/producer.d.ts +0 -19
  132. package/dist/producer/producer.js +0 -111
  133. package/dist/request-handler.d.ts +0 -16
  134. package/dist/request-handler.js +0 -67
  135. package/dist/request-handler.test.d.ts +0 -1
  136. package/dist/request-handler.test.js +0 -340
  137. package/dist/src/api/api-versions.js +0 -18
  138. package/dist/src/api/create-topics.js +0 -46
  139. package/dist/src/api/delete-topics.js +0 -26
  140. package/dist/src/api/fetch.js +0 -95
  141. package/dist/src/api/find-coordinator.js +0 -34
  142. package/dist/src/api/heartbeat.js +0 -22
  143. package/dist/src/api/index.js +0 -38
  144. package/dist/src/api/init-producer-id.js +0 -24
  145. package/dist/src/api/join-group.js +0 -48
  146. package/dist/src/api/leave-group.js +0 -30
  147. package/dist/src/api/list-offsets.js +0 -39
  148. package/dist/src/api/metadata.js +0 -47
  149. package/dist/src/api/offset-commit.js +0 -39
  150. package/dist/src/api/offset-fetch.js +0 -44
  151. package/dist/src/api/produce.js +0 -119
  152. package/dist/src/api/sync-group.js +0 -31
  153. package/dist/src/broker.js +0 -35
  154. package/dist/src/connection.js +0 -21
  155. package/dist/src/consumer/consumer-group.js +0 -131
  156. package/dist/src/consumer/consumer.js +0 -103
  157. package/dist/src/consumer/metadata.js +0 -52
  158. package/dist/src/consumer/offset-manager.js +0 -23
  159. package/dist/src/index.js +0 -19
  160. package/dist/src/producer/producer.js +0 -84
  161. package/dist/src/request-handler.js +0 -57
  162. package/dist/src/request-handler.test.js +0 -321
  163. package/dist/src/types.js +0 -2
  164. package/dist/src/utils/api.js +0 -5
  165. package/dist/src/utils/decoder.js +0 -161
  166. package/dist/src/utils/encoder.js +0 -137
  167. package/dist/src/utils/error.js +0 -10
  168. package/dist/types.d.ts +0 -9
  169. package/dist/types.js +0 -2
  170. package/dist/utils/api.d.ts +0 -9
  171. package/dist/utils/api.js +0 -5
  172. package/dist/utils/debug.d.ts +0 -2
  173. package/dist/utils/debug.js +0 -11
  174. package/dist/utils/decoder.d.ts +0 -29
  175. package/dist/utils/decoder.js +0 -147
  176. package/dist/utils/delay.d.ts +0 -1
  177. package/dist/utils/delay.js +0 -5
  178. package/dist/utils/encoder.d.ts +0 -28
  179. package/dist/utils/encoder.js +0 -122
  180. package/dist/utils/error.d.ts +0 -11
  181. package/dist/utils/error.js +0 -27
  182. package/dist/utils/memo.d.ts +0 -1
  183. package/dist/utils/memo.js +0 -16
  184. package/dist/utils/retrier.d.ts +0 -10
  185. package/dist/utils/retrier.js +0 -22
  186. package/dist/utils/tracer.d.ts +0 -1
  187. package/dist/utils/tracer.js +0 -26
  188. package/examples/node_modules/.package-lock.json +0 -22
@@ -0,0 +1,47 @@
1
+ import { EventEmitter } from 'stream';
2
+ import { Batch } from '../types';
3
+ import { createTracer } from '../utils/tracer';
4
+
5
+ const trace = createTracer('Processor');
6
+
7
+ type ProcessorOptions = {
8
+ poll: () => Promise<Batch>;
9
+ process: (batch: Batch) => Promise<void>;
10
+ };
11
+
12
+ export class Processor extends EventEmitter<{ stop: []; stopped: [] }> {
13
+ private isRunning = false;
14
+
15
+ constructor(private options: ProcessorOptions) {
16
+ super();
17
+ }
18
+
19
+ public async loop() {
20
+ const { poll, process } = this.options;
21
+
22
+ this.isRunning = true;
23
+ this.once('stop', () => (this.isRunning = false));
24
+
25
+ try {
26
+ while (this.isRunning) {
27
+ const batch = await poll();
28
+ await process(batch);
29
+ }
30
+ } finally {
31
+ this.isRunning = false;
32
+ this.emit('stopped');
33
+ }
34
+ }
35
+
36
+ @trace()
37
+ public async stop() {
38
+ if (!this.isRunning) {
39
+ return;
40
+ }
41
+
42
+ return new Promise<void>((resolve) => {
43
+ this.once('stopped', resolve);
44
+ this.emit('stop');
45
+ });
46
+ }
47
+ }
@@ -1,9 +1,9 @@
1
- import { describe, expect, it } from "vitest";
2
- import { distributeAssignmentsToNodesBalanced, distributeAssignmentsToNodesOptimized } from "./assignments-to-replicas";
1
+ import { describe, expect, it } from 'vitest';
2
+ import { distributeAssignmentsToNodesBalanced, distributeAssignmentsToNodesOptimized } from './assignments-to-replicas';
3
3
 
4
- describe("Distribute assignments to replica ids", () => {
5
- describe("distributeAssignmentsToNodesBalanced", () => {
6
- it("smoke", () => {
4
+ describe('Distribute assignments to replica ids', () => {
5
+ describe('distributeAssignmentsToNodesBalanced', () => {
6
+ it('smoke', () => {
7
7
  const result = distributeAssignmentsToNodesBalanced({ topic: [0, 1] }, { topic: { 0: [0, 1], 1: [1, 2] } });
8
8
  expect(result).toMatchInlineSnapshot(`
9
9
  {
@@ -22,8 +22,8 @@ describe("Distribute assignments to replica ids", () => {
22
22
  });
23
23
  });
24
24
 
25
- describe("distributeAssignmentsToNodesOptimized", () => {
26
- it("smoke", () => {
25
+ describe('distributeAssignmentsToNodesOptimized', () => {
26
+ it('smoke', () => {
27
27
  const result = distributeAssignmentsToNodesOptimized(
28
28
  { topic: [0, 1] },
29
29
  { topic: { 0: [0, 1], 1: [1, 2] } },
@@ -50,7 +50,7 @@ export const distributeAssignmentsToNodesOptimized = (
50
50
  }
51
51
 
52
52
  result[parseInt(replicaId)] = partitions.reduce((acc, partition) => {
53
- const [topicName, partitionId] = partition.split(":");
53
+ const [topicName, partitionId] = partition.split(':');
54
54
  acc[topicName] ??= [];
55
55
  acc[topicName].push(parseInt(partitionId));
56
56
  return acc;
@@ -1,11 +1,11 @@
1
- import { describe, expect, it } from "vitest";
2
- import { distributeMessagesToTopicPartitionLeaders } from "./messages-to-topic-partition-leaders";
1
+ import { describe, expect, it } from 'vitest';
2
+ import { distributeMessagesToTopicPartitionLeaders } from './messages-to-topic-partition-leaders';
3
3
 
4
- describe("Distribute messages to partition leader ids", () => {
5
- describe("distributeMessagesToTopicPartitionLeaders", () => {
6
- it("snoke", () => {
4
+ describe('Distribute messages to partition leader ids', () => {
5
+ describe('distributeMessagesToTopicPartitionLeaders', () => {
6
+ it('snoke', () => {
7
7
  const result = distributeMessagesToTopicPartitionLeaders(
8
- [{ topic: "topic", partition: 0, key: null, value: null, offset: 0n, timestamp: 0n, headers: {} }],
8
+ [{ topic: 'topic', partition: 0, key: null, value: null, offset: 0n, timestamp: 0n, headers: {} }],
9
9
  { topic: { 0: 1 } },
10
10
  );
11
11
  expect(result).toMatchInlineSnapshot(`
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
- export * from "./client";
2
- export * from "./api";
3
- export * from "./types";
1
+ export * from './utils/error';
2
+ export * from './client';
3
+ export * from './api';
4
+ export * from './types';
package/src/metadata.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { API, API_ERROR } from "./api";
2
- import { Cluster } from "./cluster";
3
- import { delay } from "./utils/delay";
4
- import { KafkaTSApiError } from "./utils/error";
1
+ import { API, API_ERROR } from './api';
2
+ import { Cluster } from './cluster';
3
+ import { delay } from './utils/delay';
4
+ import { KafkaTSApiError } from './utils/error';
5
5
 
6
6
  type MetadataOptions = {
7
7
  cluster: Cluster;
@@ -1,11 +1,11 @@
1
- import { API, API_ERROR } from "../api";
2
- import { Cluster } from "../cluster";
3
- import { distributeMessagesToTopicPartitionLeaders } from "../distributors/messages-to-topic-partition-leaders";
4
- import { Metadata } from "../metadata";
5
- import { Message } from "../types";
6
- import { delay } from "../utils/delay";
7
- import { KafkaTSApiError } from "../utils/error";
8
- import { memo } from "../utils/memo";
1
+ import { API, API_ERROR } from '../api';
2
+ import { Cluster } from '../cluster';
3
+ import { distributeMessagesToTopicPartitionLeaders } from '../distributors/messages-to-topic-partition-leaders';
4
+ import { Metadata } from '../metadata';
5
+ import { Message } from '../types';
6
+ import { delay } from '../utils/delay';
7
+ import { KafkaTSApiError } from '../utils/error';
8
+ import { memo } from '../utils/memo';
9
9
 
10
10
  export type ProducerOptions = {
11
11
  allowTopicAutoCreation?: boolean;
package/src/types.ts CHANGED
@@ -7,3 +7,5 @@ export type Message = {
7
7
  value: string | null;
8
8
  headers?: Record<string, string>;
9
9
  };
10
+
11
+ export type Batch = Required<Message>[];
package/src/utils/api.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { Decoder } from "./decoder";
2
- import { Encoder } from "./encoder";
1
+ import { Decoder } from './decoder';
2
+ import { Encoder } from './encoder';
3
3
 
4
4
  export type Api<Request, Response> = {
5
5
  apiKey: number;
6
6
  apiVersion: number;
7
7
  request: (encoder: Encoder, body: Request) => Encoder;
8
8
  response: (buffer: Decoder) => Response;
9
- }
9
+ };
10
10
 
11
- export const createApi = <Request, Response>(api: Api<Request, Response>) => api;
11
+ export const createApi = <Request, Response>(api: Api<Request, Response>) => api;
@@ -1,7 +1,7 @@
1
- export const serializer = (_: string, value: unknown) => (typeof value === "bigint" ? value.toString() : value);
1
+ export const serializer = (_: string, value: unknown) => (typeof value === 'bigint' ? value.toString() : value);
2
2
 
3
3
  export const createDebugger = (module: string) => (func: string, message: string, data?: unknown) => {
4
- if (!process.env.DEBUG?.includes("kafkats")) return;
4
+ if (!process.env.DEBUG?.includes('kafka-ts')) return;
5
5
  console.debug(
6
6
  `[${module}] ${func}: ${message}`,
7
7
  data && `(${data instanceof Error ? data : JSON.stringify(data, serializer, 4)})`,
@@ -81,7 +81,7 @@ export class Decoder {
81
81
  return null;
82
82
  }
83
83
 
84
- const value = this.buffer.toString("utf-8", this.offset, this.offset + length);
84
+ const value = this.buffer.toString('utf-8', this.offset, this.offset + length);
85
85
  this.offset += length;
86
86
  return value;
87
87
  }
@@ -92,7 +92,7 @@ export class Decoder {
92
92
  return null;
93
93
  }
94
94
 
95
- const value = this.buffer.toString("utf-8", this.offset, this.offset + length);
95
+ const value = this.buffer.toString('utf-8', this.offset, this.offset + length);
96
96
  this.offset += length;
97
97
  return value;
98
98
  }
@@ -103,13 +103,13 @@ export class Decoder {
103
103
  return null;
104
104
  }
105
105
 
106
- const value = this.buffer.toString("utf-8", this.offset, this.offset + length);
106
+ const value = this.buffer.toString('utf-8', this.offset, this.offset + length);
107
107
  this.offset += length;
108
108
  return value;
109
109
  }
110
110
 
111
111
  public readUUID() {
112
- const value = this.buffer.toString("hex", this.offset, this.offset + 16);
112
+ const value = this.buffer.toString('hex', this.offset, this.offset + 16);
113
113
  this.offset += 16;
114
114
  return value;
115
115
  }
@@ -74,9 +74,9 @@ export class Encoder {
74
74
  if (value === null) {
75
75
  return this.writeInt16(-1);
76
76
  }
77
- const byteLength = Buffer.byteLength(value, "utf-8");
77
+ const byteLength = Buffer.byteLength(value, 'utf-8');
78
78
  const buffer = Buffer.alloc(byteLength);
79
- buffer.write(value, 0, byteLength, "utf-8");
79
+ buffer.write(value, 0, byteLength, 'utf-8');
80
80
  return this.writeInt16(byteLength).write(buffer);
81
81
  }
82
82
 
@@ -85,9 +85,9 @@ export class Encoder {
85
85
  return this.writeUVarInt(0);
86
86
  }
87
87
 
88
- const byteLength = Buffer.byteLength(value, "utf-8");
88
+ const byteLength = Buffer.byteLength(value, 'utf-8');
89
89
  const buffer = Buffer.alloc(byteLength);
90
- buffer.write(value, 0, byteLength, "utf-8");
90
+ buffer.write(value, 0, byteLength, 'utf-8');
91
91
  return this.writeUVarInt(byteLength + 1).write(buffer);
92
92
  }
93
93
 
@@ -95,14 +95,14 @@ export class Encoder {
95
95
  if (value === null) {
96
96
  return this.writeVarInt(-1);
97
97
  }
98
- return this.writeVarInt(Buffer.byteLength(value, "utf-8")).write(Buffer.from(value, "utf-8"));
98
+ return this.writeVarInt(Buffer.byteLength(value, 'utf-8')).write(Buffer.from(value, 'utf-8'));
99
99
  }
100
100
 
101
101
  public writeUUID(value: string | null) {
102
102
  if (value === null) {
103
103
  return this.write(Buffer.alloc(16));
104
104
  }
105
- return this.write(Buffer.from(value, "hex"));
105
+ return this.write(Buffer.from(value, 'hex'));
106
106
  }
107
107
 
108
108
  public writeBoolean(value: boolean) {
@@ -1,4 +1,4 @@
1
- import { API_ERROR } from "../api";
1
+ import { API_ERROR } from '../api';
2
2
 
3
3
  export class KafkaTSError extends Error {
4
4
  constructor(message: string) {
@@ -13,8 +13,8 @@ export class KafkaTSApiError<T = any> extends KafkaTSError {
13
13
  public errorMessage: string | null,
14
14
  public response: T,
15
15
  ) {
16
- const [errorName] = Object.entries(API_ERROR).find(([, value]) => value === errorCode) ?? ["UNKNOWN"];
17
- super(`${errorName}${errorMessage ? `: ${errorMessage}` : ""}`);
16
+ const [errorName] = Object.entries(API_ERROR).find(([, value]) => value === errorCode) ?? ['UNKNOWN'];
17
+ super(`${errorName}${errorMessage ? `: ${errorMessage}` : ''}`);
18
18
  }
19
19
  }
20
20
 
@@ -1,4 +1,4 @@
1
- import { delay } from "./delay";
1
+ import { delay } from './delay';
2
2
 
3
3
  export type Retrier = (func: () => unknown) => Promise<void>;
4
4
 
@@ -1,9 +1,10 @@
1
- import { serializer } from "./debug";
1
+ import { serializer } from './debug';
2
2
 
3
- export const trace =
3
+ export const createTracer =
4
+ (module: string, attributes?: Record<string, unknown>) =>
4
5
  (fn?: (...args: any[]) => Record<string, unknown> | undefined) =>
5
6
  (target: any, propertyKey: string, descriptor: PropertyDescriptor) => {
6
- if (!process.env.DEBUG?.includes("kafkats")) return;
7
+ if (!process.env.DEBUG?.includes('kafka-ts')) return;
7
8
 
8
9
  const original = descriptor.value;
9
10
  descriptor.value = function (...args: any[]) {
@@ -12,7 +13,7 @@ export const trace =
12
13
 
13
14
  const onEnd = <T>(result: T): T => {
14
15
  console.log(
15
- `[${propertyKey}] +${Date.now() - startTime}ms ${JSON.stringify({ ...metadata, result }, serializer)}`,
16
+ `[${module}.${propertyKey}] +${Date.now() - startTime}ms ${JSON.stringify({ ...attributes, ...metadata, result }, serializer)}`,
16
17
  );
17
18
  return result;
18
19
  };
@@ -26,3 +27,5 @@ export const trace =
26
27
  }
27
28
  };
28
29
  };
30
+
31
+ export const trace = createTracer('GLOBAL');
package/tsconfig.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
- "compilerOptions": {
3
- "lib": ["es2023"],
4
- "target": "es2022",
5
- "module": "node16",
6
- "strict": true,
7
- "forceConsistentCasingInFileNames": true,
8
- "esModuleInterop": true,
9
- "skipLibCheck": true,
10
- "moduleResolution": "node16",
11
- "outDir": "dist",
12
- "declaration": true,
13
- "emitDecoratorMetadata": true,
14
- "experimentalDecorators": true
15
- },
16
- "include": ["src/**/*"],
17
- }
2
+ "compilerOptions": {
3
+ "lib": ["es2023"],
4
+ "target": "es2022",
5
+ "module": "node16",
6
+ "strict": true,
7
+ "forceConsistentCasingInFileNames": true,
8
+ "esModuleInterop": true,
9
+ "skipLibCheck": true,
10
+ "moduleResolution": "node16",
11
+ "outDir": "dist",
12
+ "declaration": true,
13
+ "emitDecoratorMetadata": true,
14
+ "experimentalDecorators": true
15
+ },
16
+ "include": ["src/**/*"]
17
+ }
@@ -1,9 +0,0 @@
1
- export declare const API_VERSIONS: import("../utils/api.js").Api<unknown, {
2
- errorCode: number;
3
- versions: {
4
- apiKey: number;
5
- minVersion: number;
6
- maxVersion: number;
7
- }[];
8
- throttleTimeMs: number;
9
- }>;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.API_VERSIONS = void 0;
4
- const api_js_1 = require("../utils/api.js");
5
- const error_js_1 = require("../utils/error.js");
6
- exports.API_VERSIONS = (0, api_js_1.createApi)({
7
- apiKey: 18,
8
- apiVersion: 2,
9
- request: (encoder) => encoder,
10
- response: (decoder) => {
11
- const result = {
12
- errorCode: decoder.readInt16(),
13
- versions: decoder.readArray((version) => ({
14
- apiKey: version.readInt16(),
15
- minVersion: version.readInt16(),
16
- maxVersion: version.readInt16(),
17
- })),
18
- throttleTimeMs: decoder.readInt32(),
19
- };
20
- if (result.errorCode)
21
- throw new error_js_1.KafkaTSApiError(result.errorCode, null, result);
22
- return result;
23
- },
24
- });
@@ -1,38 +0,0 @@
1
- export declare const CREATE_TOPICS: import("../utils/api").Api<{
2
- topics: {
3
- name: string;
4
- numPartitions: number;
5
- replicationFactor: number;
6
- assignments: {
7
- partitionIndex: number;
8
- brokerIds: number[];
9
- }[];
10
- configs: {
11
- name: string;
12
- value: string | null;
13
- }[];
14
- }[];
15
- timeoutMs: number;
16
- validateOnly: boolean;
17
- }, {
18
- _tag: void;
19
- throttleTimeMs: number;
20
- topics: {
21
- name: string | null;
22
- topicId: string;
23
- errorCode: number;
24
- errorMessage: string | null;
25
- numPartitions: number;
26
- replicationFactor: number;
27
- configs: {
28
- name: string | null;
29
- value: string | null;
30
- readOnly: boolean;
31
- configSource: number;
32
- isSensitive: boolean;
33
- _tag: void;
34
- }[];
35
- _tag: void;
36
- }[];
37
- _tag2: void;
38
- }>;
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CREATE_TOPICS = void 0;
4
- const api_1 = require("../utils/api");
5
- const error_1 = require("../utils/error");
6
- exports.CREATE_TOPICS = (0, api_1.createApi)({
7
- apiKey: 19,
8
- apiVersion: 7,
9
- request: (encoder, data) => encoder
10
- .writeUVarInt(0)
11
- .writeCompactArray(data.topics, (encoder, topic) => encoder
12
- .writeCompactString(topic.name)
13
- .writeInt32(topic.numPartitions)
14
- .writeInt16(topic.replicationFactor)
15
- .writeCompactArray(topic.assignments, (encoder, assignment) => encoder
16
- .writeInt32(assignment.partitionIndex)
17
- .writeCompactArray(assignment.brokerIds, (encoder, brokerId) => encoder.writeInt32(brokerId))
18
- .writeUVarInt(0))
19
- .writeCompactArray(topic.configs, (encoder, config) => encoder.writeCompactString(config.name).writeCompactString(config.value).writeUVarInt(0))
20
- .writeUVarInt(0))
21
- .writeInt32(data.timeoutMs)
22
- .writeBoolean(data.validateOnly)
23
- .writeUVarInt(0),
24
- response: (decoder) => {
25
- const result = {
26
- _tag: decoder.readTagBuffer(),
27
- throttleTimeMs: decoder.readInt32(),
28
- topics: decoder.readCompactArray((topic) => ({
29
- name: topic.readCompactString(),
30
- topicId: topic.readUUID(),
31
- errorCode: topic.readInt16(),
32
- errorMessage: topic.readCompactString(),
33
- numPartitions: topic.readInt32(),
34
- replicationFactor: topic.readInt16(),
35
- configs: topic.readCompactArray((config) => ({
36
- name: config.readCompactString(),
37
- value: config.readCompactString(),
38
- readOnly: config.readBoolean(),
39
- configSource: config.readInt8(),
40
- isSensitive: config.readBoolean(),
41
- _tag: config.readTagBuffer(),
42
- })),
43
- _tag: topic.readTagBuffer(),
44
- })),
45
- _tag2: decoder.readTagBuffer(),
46
- };
47
- result.topics.forEach((topic) => {
48
- if (topic.errorCode)
49
- throw new error_1.KafkaTSApiError(topic.errorCode, topic.errorMessage, result);
50
- });
51
- return result;
52
- },
53
- });
@@ -1,18 +0,0 @@
1
- export declare const DELETE_TOPICS: import("../utils/api").Api<{
2
- topics: {
3
- name: string | null;
4
- topicId: string | null;
5
- }[];
6
- timeoutMs: number;
7
- }, {
8
- _tag: void;
9
- throttleTimeMs: number;
10
- responses: {
11
- name: string | null;
12
- topicId: string;
13
- errorCode: number;
14
- errorMessage: string | null;
15
- _tag: void;
16
- }[];
17
- _tag2: void;
18
- }>;
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DELETE_TOPICS = void 0;
4
- const api_1 = require("../utils/api");
5
- const error_1 = require("../utils/error");
6
- exports.DELETE_TOPICS = (0, api_1.createApi)({
7
- apiKey: 20,
8
- apiVersion: 6,
9
- request: (encoder, data) => encoder
10
- .writeUVarInt(0)
11
- .writeCompactArray(data.topics, (encoder, topic) => encoder.writeCompactString(topic.name).writeUUID(topic.topicId).writeUVarInt(0))
12
- .writeInt32(data.timeoutMs)
13
- .writeUVarInt(0),
14
- response: (decoder) => {
15
- const result = {
16
- _tag: decoder.readTagBuffer(),
17
- throttleTimeMs: decoder.readInt32(),
18
- responses: decoder.readCompactArray((decoder) => ({
19
- name: decoder.readCompactString(),
20
- topicId: decoder.readUUID(),
21
- errorCode: decoder.readInt16(),
22
- errorMessage: decoder.readCompactString(),
23
- _tag: decoder.readTagBuffer(),
24
- })),
25
- _tag2: decoder.readTagBuffer(),
26
- };
27
- result.responses.forEach((response) => {
28
- if (response.errorCode)
29
- throw new error_1.KafkaTSApiError(response.errorCode, response.errorMessage, result);
30
- });
31
- return result;
32
- },
33
- });
@@ -1,77 +0,0 @@
1
- export declare const enum IsolationLevel {
2
- READ_UNCOMMITTED = 0,
3
- READ_COMMITTED = 1
4
- }
5
- export declare const FETCH: import("../utils/api").Api<{
6
- maxWaitMs: number;
7
- minBytes: number;
8
- maxBytes: number;
9
- isolationLevel: IsolationLevel;
10
- sessionId: number;
11
- sessionEpoch: number;
12
- topics: {
13
- topicId: string;
14
- partitions: {
15
- partition: number;
16
- currentLeaderEpoch: number;
17
- fetchOffset: bigint;
18
- lastFetchedEpoch: number;
19
- logStartOffset: bigint;
20
- partitionMaxBytes: number;
21
- }[];
22
- }[];
23
- forgottenTopicsData: {
24
- topicId: string;
25
- partitions: number[];
26
- }[];
27
- rackId: string;
28
- }, {
29
- _tag: void;
30
- throttleTimeMs: number;
31
- errorCode: number;
32
- sessionId: number;
33
- responses: {
34
- topicId: string;
35
- partitions: {
36
- partitionIndex: number;
37
- errorCode: number;
38
- highWatermark: bigint;
39
- lastStableOffset: bigint;
40
- logStartOffset: bigint;
41
- abortedTransactions: {
42
- producerId: bigint;
43
- firstOffset: bigint;
44
- _tag: void;
45
- }[];
46
- preferredReadReplica: number;
47
- records: {
48
- baseOffset: bigint;
49
- batchLength: number;
50
- partitionLeaderEpoch: number;
51
- magic: number;
52
- crc: number;
53
- attributes: number;
54
- lastOffsetDelta: number;
55
- baseTimestamp: bigint;
56
- maxTimestamp: bigint;
57
- producerId: bigint;
58
- producerEpoch: number;
59
- baseSequence: number;
60
- records: {
61
- attributes: number;
62
- timestampDelta: bigint;
63
- offsetDelta: number;
64
- key: string | null;
65
- value: string | null;
66
- headers: {
67
- key: string | null;
68
- value: string | null;
69
- }[];
70
- }[];
71
- }[];
72
- _tag: void;
73
- }[];
74
- _tag: void;
75
- }[];
76
- _tag2: void;
77
- }>;