kafka-ts 0.0.3-beta → 0.0.4

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 (176) hide show
  1. package/README.md +72 -8
  2. package/dist/api/api-versions.d.ts +9 -0
  3. package/{src/api/api-versions.ts → dist/api/api-versions.js} +8 -5
  4. package/dist/api/create-topics.d.ts +38 -0
  5. package/dist/api/create-topics.js +53 -0
  6. package/dist/api/delete-topics.d.ts +18 -0
  7. package/dist/api/delete-topics.js +33 -0
  8. package/dist/api/fetch.d.ts +84 -0
  9. package/dist/api/fetch.js +142 -0
  10. package/dist/api/find-coordinator.d.ts +21 -0
  11. package/{src/api/find-coordinator.ts → dist/api/find-coordinator.js} +14 -14
  12. package/dist/api/heartbeat.d.ts +11 -0
  13. package/dist/api/heartbeat.js +27 -0
  14. package/dist/api/index.d.ts +576 -0
  15. package/{src/api/index.ts → dist/api/index.js} +42 -41
  16. package/dist/api/init-producer-id.d.ts +13 -0
  17. package/dist/api/init-producer-id.js +29 -0
  18. package/dist/api/join-group.d.ts +34 -0
  19. package/dist/api/join-group.js +51 -0
  20. package/dist/api/leave-group.d.ts +19 -0
  21. package/dist/api/leave-group.js +39 -0
  22. package/dist/api/list-offsets.d.ts +29 -0
  23. package/dist/api/list-offsets.js +48 -0
  24. package/dist/api/metadata.d.ts +40 -0
  25. package/{src/api/metadata.ts → dist/api/metadata.js} +18 -26
  26. package/dist/api/offset-commit.d.ts +28 -0
  27. package/dist/api/offset-commit.js +48 -0
  28. package/dist/api/offset-fetch.d.ts +31 -0
  29. package/dist/api/offset-fetch.js +55 -0
  30. package/dist/api/produce.d.ts +54 -0
  31. package/{src/api/produce.ts → dist/api/produce.js} +55 -102
  32. package/dist/api/sasl-authenticate.d.ts +11 -0
  33. package/dist/api/sasl-authenticate.js +23 -0
  34. package/dist/api/sasl-handshake.d.ts +6 -0
  35. package/dist/api/sasl-handshake.js +19 -0
  36. package/dist/api/sync-group.d.ts +24 -0
  37. package/dist/api/sync-group.js +36 -0
  38. package/dist/auth/index.d.ts +2 -0
  39. package/dist/auth/index.js +8 -0
  40. package/dist/auth/plain.d.ts +5 -0
  41. package/dist/auth/plain.js +12 -0
  42. package/dist/auth/scram.d.ts +9 -0
  43. package/dist/auth/scram.js +40 -0
  44. package/dist/broker.d.ts +30 -0
  45. package/dist/broker.js +55 -0
  46. package/dist/client.d.ts +22 -0
  47. package/dist/client.js +36 -0
  48. package/dist/cluster.d.ts +27 -0
  49. package/dist/cluster.js +70 -0
  50. package/dist/cluster.test.d.ts +1 -0
  51. package/{src/cluster.test.ts → dist/cluster.test.js} +87 -113
  52. package/dist/codecs/gzip.d.ts +2 -0
  53. package/dist/codecs/gzip.js +8 -0
  54. package/dist/codecs/index.d.ts +2 -0
  55. package/dist/codecs/index.js +17 -0
  56. package/dist/codecs/none.d.ts +2 -0
  57. package/dist/codecs/none.js +7 -0
  58. package/dist/codecs/types.d.ts +5 -0
  59. package/dist/codecs/types.js +2 -0
  60. package/dist/connection.d.ts +26 -0
  61. package/dist/connection.js +175 -0
  62. package/dist/consumer/consumer-group.d.ts +41 -0
  63. package/dist/consumer/consumer-group.js +215 -0
  64. package/dist/consumer/consumer-metadata.d.ts +7 -0
  65. package/dist/consumer/consumer-metadata.js +14 -0
  66. package/dist/consumer/consumer.d.ts +44 -0
  67. package/dist/consumer/consumer.js +225 -0
  68. package/dist/consumer/fetch-manager.d.ts +33 -0
  69. package/dist/consumer/fetch-manager.js +140 -0
  70. package/dist/consumer/fetcher.d.ts +25 -0
  71. package/dist/consumer/fetcher.js +64 -0
  72. package/dist/consumer/offset-manager.d.ts +22 -0
  73. package/dist/consumer/offset-manager.js +66 -0
  74. package/dist/consumer/processor.d.ts +19 -0
  75. package/dist/consumer/processor.js +59 -0
  76. package/dist/distributors/assignments-to-replicas.d.ts +16 -0
  77. package/{src/distributors/assignments-to-replicas.ts → dist/distributors/assignments-to-replicas.js} +15 -41
  78. package/dist/distributors/assignments-to-replicas.test.d.ts +1 -0
  79. package/dist/distributors/assignments-to-replicas.test.js +40 -0
  80. package/dist/distributors/messages-to-topic-partition-leaders.d.ts +17 -0
  81. package/dist/distributors/messages-to-topic-partition-leaders.js +15 -0
  82. package/dist/distributors/messages-to-topic-partition-leaders.test.d.ts +1 -0
  83. package/dist/distributors/messages-to-topic-partition-leaders.test.js +30 -0
  84. package/dist/distributors/partitioner.d.ts +7 -0
  85. package/dist/distributors/partitioner.js +23 -0
  86. package/dist/index.d.ts +9 -0
  87. package/dist/index.js +26 -0
  88. package/dist/metadata.d.ts +24 -0
  89. package/dist/metadata.js +106 -0
  90. package/dist/producer/producer.d.ts +24 -0
  91. package/dist/producer/producer.js +131 -0
  92. package/{src/types.ts → dist/types.d.ts} +4 -4
  93. package/dist/types.js +2 -0
  94. package/{src/utils/api.ts → dist/utils/api.d.ts} +2 -4
  95. package/dist/utils/api.js +5 -0
  96. package/dist/utils/crypto.d.ts +8 -0
  97. package/dist/utils/crypto.js +18 -0
  98. package/dist/utils/decoder.d.ts +30 -0
  99. package/{src/utils/decoder.ts → dist/utils/decoder.js} +41 -57
  100. package/dist/utils/delay.d.ts +1 -0
  101. package/dist/utils/delay.js +5 -0
  102. package/dist/utils/encoder.d.ts +28 -0
  103. package/{src/utils/encoder.ts → dist/utils/encoder.js} +50 -66
  104. package/dist/utils/error.d.ts +11 -0
  105. package/dist/utils/error.js +27 -0
  106. package/dist/utils/logger.d.ts +9 -0
  107. package/dist/utils/logger.js +32 -0
  108. package/dist/utils/memo.d.ts +1 -0
  109. package/{src/utils/memo.ts → dist/utils/memo.js} +7 -3
  110. package/dist/utils/murmur2.d.ts +3 -0
  111. package/dist/utils/murmur2.js +40 -0
  112. package/dist/utils/retrier.d.ts +10 -0
  113. package/dist/utils/retrier.js +22 -0
  114. package/dist/utils/tracer.d.ts +5 -0
  115. package/dist/utils/tracer.js +39 -0
  116. package/package.json +11 -2
  117. package/.github/workflows/release.yml +0 -17
  118. package/.prettierrc +0 -8
  119. package/certs/ca.crt +0 -29
  120. package/certs/ca.key +0 -52
  121. package/certs/ca.srl +0 -1
  122. package/certs/kafka.crt +0 -29
  123. package/certs/kafka.csr +0 -26
  124. package/certs/kafka.key +0 -52
  125. package/certs/kafka.keystore.jks +0 -0
  126. package/certs/kafka.truststore.jks +0 -0
  127. package/docker-compose.yml +0 -104
  128. package/examples/package-lock.json +0 -31
  129. package/examples/package.json +0 -14
  130. package/examples/src/client.ts +0 -9
  131. package/examples/src/consumer.ts +0 -18
  132. package/examples/src/create-topic.ts +0 -44
  133. package/examples/src/producer.ts +0 -24
  134. package/examples/src/replicator.ts +0 -25
  135. package/examples/src/utils/delay.ts +0 -1
  136. package/examples/src/utils/json.ts +0 -1
  137. package/examples/tsconfig.json +0 -7
  138. package/log4j.properties +0 -95
  139. package/scripts/generate-certs.sh +0 -24
  140. package/src/__snapshots__/request-handler.test.ts.snap +0 -978
  141. package/src/api/create-topics.ts +0 -78
  142. package/src/api/delete-topics.ts +0 -42
  143. package/src/api/fetch.ts +0 -143
  144. package/src/api/heartbeat.ts +0 -33
  145. package/src/api/init-producer-id.ts +0 -35
  146. package/src/api/join-group.ts +0 -67
  147. package/src/api/leave-group.ts +0 -48
  148. package/src/api/list-offsets.ts +0 -65
  149. package/src/api/offset-commit.ts +0 -67
  150. package/src/api/offset-fetch.ts +0 -74
  151. package/src/api/sasl-authenticate.ts +0 -21
  152. package/src/api/sasl-handshake.ts +0 -16
  153. package/src/api/sync-group.ts +0 -54
  154. package/src/broker.ts +0 -74
  155. package/src/client.ts +0 -47
  156. package/src/cluster.ts +0 -87
  157. package/src/connection.ts +0 -143
  158. package/src/consumer/consumer-group.ts +0 -209
  159. package/src/consumer/consumer-metadata.ts +0 -14
  160. package/src/consumer/consumer.ts +0 -231
  161. package/src/consumer/fetch-manager.ts +0 -179
  162. package/src/consumer/fetcher.ts +0 -57
  163. package/src/consumer/offset-manager.ts +0 -93
  164. package/src/consumer/processor.ts +0 -47
  165. package/src/distributors/assignments-to-replicas.test.ts +0 -43
  166. package/src/distributors/messages-to-topic-partition-leaders.test.ts +0 -32
  167. package/src/distributors/messages-to-topic-partition-leaders.ts +0 -19
  168. package/src/index.ts +0 -4
  169. package/src/metadata.ts +0 -122
  170. package/src/producer/producer.ts +0 -132
  171. package/src/utils/debug.ts +0 -9
  172. package/src/utils/delay.ts +0 -1
  173. package/src/utils/error.ts +0 -21
  174. package/src/utils/retrier.ts +0 -39
  175. package/src/utils/tracer.ts +0 -31
  176. package/tsconfig.json +0 -17
@@ -1,78 +0,0 @@
1
- import { createApi } from '../utils/api';
2
- import { KafkaTSApiError } from '../utils/error';
3
-
4
- export const CREATE_TOPICS = createApi({
5
- apiKey: 19,
6
- apiVersion: 7,
7
- request: (
8
- encoder,
9
- data: {
10
- topics: {
11
- name: string;
12
- numPartitions: number;
13
- replicationFactor: number;
14
- assignments: {
15
- partitionIndex: number;
16
- brokerIds: number[];
17
- }[];
18
- configs: {
19
- name: string;
20
- value: string | null;
21
- }[];
22
- }[];
23
- timeoutMs: number;
24
- validateOnly: boolean;
25
- },
26
- ) =>
27
- encoder
28
- .writeUVarInt(0)
29
- .writeCompactArray(data.topics, (encoder, topic) =>
30
- encoder
31
- .writeCompactString(topic.name)
32
- .writeInt32(topic.numPartitions)
33
- .writeInt16(topic.replicationFactor)
34
- .writeCompactArray(topic.assignments, (encoder, assignment) =>
35
- encoder
36
- .writeInt32(assignment.partitionIndex)
37
- .writeCompactArray(assignment.brokerIds, (encoder, brokerId) =>
38
- encoder.writeInt32(brokerId),
39
- )
40
- .writeUVarInt(0),
41
- )
42
- .writeCompactArray(topic.configs, (encoder, config) =>
43
- encoder.writeCompactString(config.name).writeCompactString(config.value).writeUVarInt(0),
44
- )
45
- .writeUVarInt(0),
46
- )
47
- .writeInt32(data.timeoutMs)
48
- .writeBoolean(data.validateOnly)
49
- .writeUVarInt(0),
50
- response: (decoder) => {
51
- const result = {
52
- _tag: decoder.readTagBuffer(),
53
- throttleTimeMs: decoder.readInt32(),
54
- topics: decoder.readCompactArray((topic) => ({
55
- name: topic.readCompactString(),
56
- topicId: topic.readUUID(),
57
- errorCode: topic.readInt16(),
58
- errorMessage: topic.readCompactString(),
59
- numPartitions: topic.readInt32(),
60
- replicationFactor: topic.readInt16(),
61
- configs: topic.readCompactArray((config) => ({
62
- name: config.readCompactString(),
63
- value: config.readCompactString(),
64
- readOnly: config.readBoolean(),
65
- configSource: config.readInt8(),
66
- isSensitive: config.readBoolean(),
67
- _tag: config.readTagBuffer(),
68
- })),
69
- _tag: topic.readTagBuffer(),
70
- })),
71
- _tag2: decoder.readTagBuffer(),
72
- };
73
- result.topics.forEach((topic) => {
74
- if (topic.errorCode) throw new KafkaTSApiError(topic.errorCode, topic.errorMessage, result);
75
- });
76
- return result;
77
- },
78
- });
@@ -1,42 +0,0 @@
1
- import { createApi } from '../utils/api';
2
- import { KafkaTSApiError } from '../utils/error';
3
-
4
- export const DELETE_TOPICS = createApi({
5
- apiKey: 20,
6
- apiVersion: 6,
7
- request: (
8
- encoder,
9
- data: {
10
- topics: {
11
- name: string | null;
12
- topicId: string | null;
13
- }[];
14
- timeoutMs: number;
15
- },
16
- ) =>
17
- encoder
18
- .writeUVarInt(0)
19
- .writeCompactArray(data.topics, (encoder, topic) =>
20
- encoder.writeCompactString(topic.name).writeUUID(topic.topicId).writeUVarInt(0),
21
- )
22
- .writeInt32(data.timeoutMs)
23
- .writeUVarInt(0),
24
- response: (decoder) => {
25
- const result = {
26
- _tag: decoder.readTagBuffer(),
27
- throttleTimeMs: decoder.readInt32(),
28
- responses: decoder.readCompactArray((decoder) => ({
29
- name: decoder.readCompactString(),
30
- topicId: decoder.readUUID(),
31
- errorCode: decoder.readInt16(),
32
- errorMessage: decoder.readCompactString(),
33
- _tag: decoder.readTagBuffer(),
34
- })),
35
- _tag2: decoder.readTagBuffer(),
36
- };
37
- result.responses.forEach((response) => {
38
- if (response.errorCode) throw new KafkaTSApiError(response.errorCode, response.errorMessage, result);
39
- });
40
- return result;
41
- },
42
- });
package/src/api/fetch.ts DELETED
@@ -1,143 +0,0 @@
1
- import { createApi } from '../utils/api';
2
- import { Decoder } from '../utils/decoder';
3
- import { KafkaTSApiError } from '../utils/error';
4
-
5
- export const enum IsolationLevel {
6
- READ_UNCOMMITTED = 0,
7
- READ_COMMITTED = 1,
8
- }
9
-
10
- export const FETCH = createApi({
11
- apiKey: 1,
12
- apiVersion: 16,
13
- request: (
14
- encoder,
15
- data: {
16
- maxWaitMs: number;
17
- minBytes: number;
18
- maxBytes: number;
19
- isolationLevel: IsolationLevel;
20
- sessionId: number;
21
- sessionEpoch: number;
22
- topics: {
23
- topicId: string;
24
- partitions: {
25
- partition: number;
26
- currentLeaderEpoch: number;
27
- fetchOffset: bigint;
28
- lastFetchedEpoch: number;
29
- logStartOffset: bigint;
30
- partitionMaxBytes: number;
31
- }[];
32
- }[];
33
- forgottenTopicsData: {
34
- topicId: string;
35
- partitions: number[];
36
- }[];
37
- rackId: string;
38
- },
39
- ) =>
40
- encoder
41
- .writeUVarInt(0)
42
- .writeInt32(data.maxWaitMs)
43
- .writeInt32(data.minBytes)
44
- .writeInt32(data.maxBytes)
45
- .writeInt8(data.isolationLevel)
46
- .writeInt32(data.sessionId)
47
- .writeInt32(data.sessionEpoch)
48
- .writeCompactArray(data.topics, (encoder, topic) =>
49
- encoder
50
- .writeUUID(topic.topicId)
51
- .writeCompactArray(topic.partitions, (encoder, partition) =>
52
- encoder
53
- .writeInt32(partition.partition)
54
- .writeInt32(partition.currentLeaderEpoch)
55
- .writeInt64(partition.fetchOffset)
56
- .writeInt32(partition.lastFetchedEpoch)
57
- .writeInt64(partition.logStartOffset)
58
- .writeInt32(partition.partitionMaxBytes)
59
- .writeUVarInt(0),
60
- )
61
- .writeUVarInt(0),
62
- )
63
- .writeCompactArray(data.forgottenTopicsData, (encoder, forgottenTopic) =>
64
- encoder
65
- .writeUUID(forgottenTopic.topicId)
66
- .writeCompactArray(forgottenTopic.partitions, (encoder, partition) => encoder.writeInt32(partition))
67
- .writeUVarInt(0),
68
- )
69
- .writeCompactString(data.rackId)
70
- .writeUVarInt(0),
71
- response: (decoder) => {
72
- const result = {
73
- _tag: decoder.readTagBuffer(),
74
- throttleTimeMs: decoder.readInt32(),
75
- errorCode: decoder.readInt16(),
76
- sessionId: decoder.readInt32(),
77
- responses: decoder.readCompactArray((response) => ({
78
- topicId: response.readUUID(),
79
- partitions: response.readCompactArray((partition) => ({
80
- partitionIndex: partition.readInt32(),
81
- errorCode: partition.readInt16(),
82
- highWatermark: partition.readInt64(),
83
- lastStableOffset: partition.readInt64(),
84
- logStartOffset: partition.readInt64(),
85
- abortedTransactions: partition.readCompactArray((abortedTransaction) => ({
86
- producerId: abortedTransaction.readInt64(),
87
- firstOffset: abortedTransaction.readInt64(),
88
- _tag: abortedTransaction.readTagBuffer(),
89
- })),
90
- preferredReadReplica: partition.readInt32(),
91
- records: decodeRecords(partition),
92
- _tag: partition.readTagBuffer(),
93
- })),
94
- _tag: response.readTagBuffer(),
95
- })),
96
- _tag2: decoder.readTagBuffer(),
97
- };
98
- if (result.errorCode) throw new KafkaTSApiError(result.errorCode, null, result);
99
- result.responses.forEach((response) => {
100
- response.partitions.forEach((partition) => {
101
- if (partition.errorCode) throw new KafkaTSApiError(partition.errorCode, null, result);
102
- });
103
- });
104
- return result;
105
- },
106
- });
107
-
108
- const decodeRecords = (decoder: Decoder) => {
109
- const size = decoder.readUVarInt() - 1;
110
- if (size <= 0) {
111
- return [];
112
- }
113
-
114
- const results = [];
115
- while (decoder.getBufferLength() > decoder.getOffset() + 49) {
116
- results.push({
117
- baseOffset: decoder.readInt64(),
118
- batchLength: decoder.readInt32(),
119
- partitionLeaderEpoch: decoder.readInt32(),
120
- magic: decoder.readInt8(),
121
- crc: decoder.readUInt32(),
122
- attributes: decoder.readInt16(),
123
- lastOffsetDelta: decoder.readInt32(),
124
- baseTimestamp: decoder.readInt64(),
125
- maxTimestamp: decoder.readInt64(),
126
- producerId: decoder.readInt64(),
127
- producerEpoch: decoder.readInt16(),
128
- baseSequence: decoder.readInt32(),
129
- records: decoder.readRecords((record) => ({
130
- attributes: record.readInt8(),
131
- timestampDelta: record.readVarLong(),
132
- offsetDelta: record.readVarInt(),
133
- key: record.readVarIntString(),
134
- value: record.readVarIntString(),
135
- headers: record.readCompactArray((header) => ({
136
- key: header.readVarIntString(),
137
- value: header.readVarIntString(),
138
- })),
139
- })),
140
- });
141
- }
142
- return results;
143
- };
@@ -1,33 +0,0 @@
1
- import { createApi } from '../utils/api';
2
- import { KafkaTSApiError } from '../utils/error';
3
-
4
- export const HEARTBEAT = createApi({
5
- apiKey: 12,
6
- apiVersion: 4,
7
- request: (
8
- encoder,
9
- data: {
10
- groupId: string;
11
- generationId: number;
12
- memberId: string;
13
- groupInstanceId: string | null;
14
- },
15
- ) =>
16
- encoder
17
- .writeUVarInt(0)
18
- .writeCompactString(data.groupId)
19
- .writeInt32(data.generationId)
20
- .writeCompactString(data.memberId)
21
- .writeCompactString(data.groupInstanceId)
22
- .writeUVarInt(0),
23
- response: (decoder) => {
24
- const result = {
25
- _tag: decoder.readTagBuffer(),
26
- throttleTimeMs: decoder.readInt32(),
27
- errorCode: decoder.readInt16(),
28
- _tag2: decoder.readTagBuffer(),
29
- };
30
- if (result.errorCode) throw new KafkaTSApiError(result.errorCode, null, result);
31
- return result;
32
- },
33
- });
@@ -1,35 +0,0 @@
1
- import { createApi } from '../utils/api';
2
- import { KafkaTSApiError } from '../utils/error';
3
-
4
- export const INIT_PRODUCER_ID = createApi({
5
- apiKey: 22,
6
- apiVersion: 4,
7
- request: (
8
- encoder,
9
- body: {
10
- transactionalId: string | null;
11
- transactionTimeoutMs: number;
12
- producerId: bigint;
13
- producerEpoch: number;
14
- },
15
- ) =>
16
- encoder
17
- .writeUVarInt(0)
18
- .writeCompactString(body.transactionalId)
19
- .writeInt32(body.transactionTimeoutMs)
20
- .writeInt64(body.producerId)
21
- .writeInt16(body.producerEpoch)
22
- .writeUVarInt(0),
23
- response: (decoder) => {
24
- const result = {
25
- _tag: decoder.readTagBuffer(),
26
- throttleTimeMs: decoder.readInt32(),
27
- errorCode: decoder.readInt16(),
28
- producerId: decoder.readInt64(),
29
- producerEpoch: decoder.readInt16(),
30
- _tag2: decoder.readTagBuffer(),
31
- };
32
- if (result.errorCode) throw new KafkaTSApiError(result.errorCode, null, result);
33
- return result;
34
- },
35
- });
@@ -1,67 +0,0 @@
1
- import { createApi } from '../utils/api';
2
- import { Encoder } from '../utils/encoder';
3
- import { KafkaTSApiError } from '../utils/error';
4
-
5
- export const JOIN_GROUP = createApi({
6
- apiKey: 11,
7
- apiVersion: 9,
8
- request: (
9
- encoder,
10
- data: {
11
- groupId: string;
12
- sessionTimeoutMs: number;
13
- rebalanceTimeoutMs: number;
14
- memberId: string;
15
- groupInstanceId: string | null;
16
- protocolType: string;
17
- protocols: {
18
- name: string;
19
- metadata: {
20
- version: number;
21
- topics: string[];
22
- };
23
- }[];
24
- reason: string | null;
25
- },
26
- ) =>
27
- encoder
28
- .writeUVarInt(0)
29
- .writeCompactString(data.groupId)
30
- .writeInt32(data.sessionTimeoutMs)
31
- .writeInt32(data.rebalanceTimeoutMs)
32
- .writeCompactString(data.memberId)
33
- .writeCompactString(data.groupInstanceId)
34
- .writeCompactString(data.protocolType)
35
- .writeCompactArray(data.protocols, (encoder, protocol) => {
36
- const metadata = new Encoder()
37
- .writeInt16(protocol.metadata.version)
38
- .writeArray(protocol.metadata.topics, (encoder, topic) => encoder.writeString(topic))
39
- .writeBytes(Buffer.alloc(0))
40
- .value();
41
- return encoder.writeCompactString(protocol.name).writeCompactBytes(metadata).writeUVarInt(0);
42
- })
43
- .writeCompactString(data.reason)
44
- .writeUVarInt(0),
45
- response: (decoder) => {
46
- const result = {
47
- _tag: decoder.readTagBuffer(),
48
- throttleTimeMs: decoder.readInt32(),
49
- errorCode: decoder.readInt16(),
50
- generationId: decoder.readInt32(),
51
- protocolType: decoder.readCompactString(),
52
- protocolName: decoder.readCompactString(),
53
- leader: decoder.readCompactString()!,
54
- skipAssignment: decoder.readBoolean(),
55
- memberId: decoder.readCompactString()!,
56
- members: decoder.readCompactArray((decoder) => ({
57
- memberId: decoder.readCompactString()!,
58
- groupInstanceId: decoder.readCompactString(),
59
- metadata: decoder.readCompactBytes()!,
60
- _tag: decoder.readTagBuffer(),
61
- })),
62
- _tag2: decoder.readTagBuffer(),
63
- };
64
- if (result.errorCode) throw new KafkaTSApiError(result.errorCode, null, result);
65
- return result;
66
- },
67
- });
@@ -1,48 +0,0 @@
1
- import { createApi } from '../utils/api';
2
- import { KafkaTSApiError } from '../utils/error';
3
-
4
- export const LEAVE_GROUP = createApi({
5
- apiKey: 13,
6
- apiVersion: 5,
7
- request: (
8
- encoder,
9
- body: {
10
- groupId: string;
11
- members: {
12
- memberId: string;
13
- groupInstanceId: string | null;
14
- reason: string | null;
15
- }[];
16
- },
17
- ) =>
18
- encoder
19
- .writeUVarInt(0)
20
- .writeCompactString(body.groupId)
21
- .writeCompactArray(body.members, (encoder, member) =>
22
- encoder
23
- .writeCompactString(member.memberId)
24
- .writeCompactString(member.groupInstanceId)
25
- .writeCompactString(member.reason)
26
- .writeUVarInt(0),
27
- )
28
- .writeUVarInt(0),
29
- response: (decoder) => {
30
- const result = {
31
- _tag: decoder.readTagBuffer(),
32
- throttleTimeMs: decoder.readInt32(),
33
- errorCode: decoder.readInt16(),
34
- members: decoder.readCompactArray((decoder) => ({
35
- memberId: decoder.readCompactString()!,
36
- groupInstanceId: decoder.readCompactString(),
37
- errorCode: decoder.readInt16(),
38
- _tag: decoder.readTagBuffer(),
39
- })),
40
- _tag2: decoder.readTagBuffer(),
41
- };
42
- if (result.errorCode) throw new KafkaTSApiError(result.errorCode, null, result);
43
- result.members.forEach((member) => {
44
- if (member.errorCode) throw new KafkaTSApiError(member.errorCode, null, result);
45
- });
46
- return result;
47
- },
48
- });
@@ -1,65 +0,0 @@
1
- import { createApi } from '../utils/api';
2
- import { KafkaTSApiError } from '../utils/error';
3
- import { IsolationLevel } from './fetch';
4
-
5
- export const LIST_OFFSETS = createApi({
6
- apiKey: 2,
7
- apiVersion: 8,
8
- request: (
9
- encoder,
10
- data: {
11
- replicaId: number;
12
- isolationLevel: IsolationLevel;
13
- topics: {
14
- name: string;
15
- partitions: {
16
- partitionIndex: number;
17
- currentLeaderEpoch: number;
18
- timestamp: bigint;
19
- }[];
20
- }[];
21
- },
22
- ) =>
23
- encoder
24
- .writeUVarInt(0)
25
- .writeInt32(data.replicaId)
26
- .writeInt8(data.isolationLevel)
27
- .writeCompactArray(data.topics, (encoder, topic) =>
28
- encoder
29
- .writeCompactString(topic.name)
30
- .writeCompactArray(topic.partitions, (encoder, partition) =>
31
- encoder
32
- .writeInt32(partition.partitionIndex)
33
- .writeInt32(partition.currentLeaderEpoch)
34
- .writeInt64(partition.timestamp)
35
- .writeUVarInt(0),
36
- )
37
- .writeUVarInt(0),
38
- )
39
- .writeUVarInt(0),
40
- response: (decoder) => {
41
- const result = {
42
- _tag: decoder.readTagBuffer(),
43
- throttleTimeMs: decoder.readInt32(),
44
- topics: decoder.readCompactArray((decoder) => ({
45
- name: decoder.readCompactString()!,
46
- partitions: decoder.readCompactArray((decoder) => ({
47
- partitionIndex: decoder.readInt32(),
48
- errorCode: decoder.readInt16(),
49
- timestamp: decoder.readInt64(),
50
- offset: decoder.readInt64(),
51
- leaderEpoch: decoder.readInt32(),
52
- _tag: decoder.readTagBuffer(),
53
- })),
54
- _tag: decoder.readTagBuffer(),
55
- })),
56
- _tag2: decoder.readTagBuffer(),
57
- };
58
- result.topics.forEach((topic) => {
59
- topic.partitions.forEach((partition) => {
60
- if (partition.errorCode) throw new KafkaTSApiError(partition.errorCode, null, result);
61
- });
62
- });
63
- return result;
64
- },
65
- });
@@ -1,67 +0,0 @@
1
- import { createApi } from '../utils/api';
2
- import { KafkaTSApiError } from '../utils/error';
3
-
4
- export const OFFSET_COMMIT = createApi({
5
- apiKey: 8,
6
- apiVersion: 9,
7
- request: (
8
- encoder,
9
- data: {
10
- groupId: string;
11
- generationIdOrMemberEpoch: number;
12
- memberId: string;
13
- groupInstanceId: string | null;
14
- topics: {
15
- name: string;
16
- partitions: {
17
- partitionIndex: number;
18
- committedOffset: bigint;
19
- committedLeaderEpoch: number;
20
- committedMetadata: string | null;
21
- }[];
22
- }[];
23
- },
24
- ) =>
25
- encoder
26
- .writeUVarInt(0)
27
- .writeCompactString(data.groupId)
28
- .writeInt32(data.generationIdOrMemberEpoch)
29
- .writeCompactString(data.memberId)
30
- .writeCompactString(data.groupInstanceId)
31
- .writeCompactArray(data.topics, (encoder, topic) =>
32
- encoder
33
- .writeCompactString(topic.name)
34
- .writeCompactArray(topic.partitions, (encoder, partition) =>
35
- encoder
36
- .writeInt32(partition.partitionIndex)
37
- .writeInt64(partition.committedOffset)
38
- .writeInt32(partition.committedLeaderEpoch)
39
- .writeCompactString(partition.committedMetadata)
40
- .writeUVarInt(0),
41
- )
42
- .writeUVarInt(0),
43
- )
44
- .writeUVarInt(0),
45
- response: (decoder) => {
46
- const result = {
47
- _tag: decoder.readTagBuffer(),
48
- throttleTimeMs: decoder.readInt32(),
49
- topics: decoder.readCompactArray((decoder) => ({
50
- name: decoder.readCompactString(),
51
- partitions: decoder.readCompactArray((decoder) => ({
52
- partitionIndex: decoder.readInt32(),
53
- errorCode: decoder.readInt16(),
54
- _tag: decoder.readTagBuffer(),
55
- })),
56
- _tag: decoder.readTagBuffer(),
57
- })),
58
- _tag2: decoder.readTagBuffer(),
59
- };
60
- result.topics.forEach((topic) => {
61
- topic.partitions.forEach((partition) => {
62
- if (partition.errorCode) throw new KafkaTSApiError(partition.errorCode, null, result);
63
- });
64
- });
65
- return result;
66
- },
67
- });
@@ -1,74 +0,0 @@
1
- import { createApi } from '../utils/api';
2
- import { KafkaTSApiError } from '../utils/error';
3
-
4
- export const OFFSET_FETCH = createApi({
5
- apiKey: 9,
6
- apiVersion: 9,
7
- request: (
8
- encoder,
9
- data: {
10
- groups: {
11
- groupId: string;
12
- memberId: string | null;
13
- memberEpoch: number;
14
- topics: {
15
- name: string;
16
- partitionIndexes: number[];
17
- }[];
18
- }[];
19
- requireStable: boolean;
20
- },
21
- ) =>
22
- encoder
23
- .writeUVarInt(0)
24
- .writeCompactArray(data.groups, (encoder, group) =>
25
- encoder
26
- .writeCompactString(group.groupId)
27
- .writeCompactString(group.memberId)
28
- .writeInt32(group.memberEpoch)
29
- .writeCompactArray(group.topics, (encoder, topic) =>
30
- encoder
31
- .writeCompactString(topic.name)
32
- .writeCompactArray(topic.partitionIndexes, (encoder, partitionIndex) =>
33
- encoder.writeInt32(partitionIndex),
34
- )
35
- .writeUVarInt(0),
36
- )
37
- .writeUVarInt(0),
38
- )
39
- .writeBoolean(data.requireStable)
40
- .writeUVarInt(0),
41
- response: (decoder) => {
42
- const result = {
43
- _tag: decoder.readTagBuffer(),
44
- throttleTimeMs: decoder.readInt32(),
45
- groups: decoder.readCompactArray((decoder) => ({
46
- groupId: decoder.readCompactString(),
47
- topics: decoder.readCompactArray((decoder) => ({
48
- name: decoder.readCompactString()!,
49
- partitions: decoder.readCompactArray((decoder) => ({
50
- partitionIndex: decoder.readInt32(),
51
- committedOffset: decoder.readInt64(),
52
- committedLeaderEpoch: decoder.readInt32(),
53
- committedMetadata: decoder.readCompactString(),
54
- errorCode: decoder.readInt16(),
55
- _tag: decoder.readTagBuffer(),
56
- })),
57
- _tag: decoder.readTagBuffer(),
58
- })),
59
- errorCode: decoder.readInt16(),
60
- _tag: decoder.readTagBuffer(),
61
- })),
62
- _tag2: decoder.readTagBuffer(),
63
- };
64
- result.groups.forEach((group) => {
65
- if (group.errorCode) throw new KafkaTSApiError(group.errorCode, null, result);
66
- group.topics.forEach((topic) => {
67
- topic.partitions.forEach((partition) => {
68
- if (partition.errorCode) throw new KafkaTSApiError(partition.errorCode, null, result);
69
- });
70
- });
71
- });
72
- return result;
73
- },
74
- });
@@ -1,21 +0,0 @@
1
- import { createApi } from '../utils/api';
2
- import { KafkaTSApiError } from '../utils/error';
3
-
4
- export const SASL_AUTHENTICATE = createApi({
5
- apiKey: 36,
6
- apiVersion: 2,
7
- request: (encoder, data: { authBytes: Buffer }) =>
8
- encoder.writeUVarInt(0).writeCompactBytes(data.authBytes).writeUVarInt(0),
9
- response: (decoder) => {
10
- const result = {
11
- _tag: decoder.readTagBuffer(),
12
- errorCode: decoder.readInt16(),
13
- errorMessage: decoder.readCompactString(),
14
- authBytes: decoder.readCompactBytes(),
15
- sessionLifetimeMs: decoder.readInt64(),
16
- _tag2: decoder.readTagBuffer(),
17
- };
18
- if (result.errorCode) throw new KafkaTSApiError(result.errorCode, result.errorMessage, result);
19
- return result;
20
- },
21
- });