kafka-ts 1.3.1-beta.1 → 1.3.1-beta.2

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 (102) hide show
  1. package/README.md +7 -7
  2. package/dist/api/alter-configs.d.ts +26 -0
  3. package/dist/api/alter-configs.js +33 -0
  4. package/dist/api/api-versions.d.ts +5 -2
  5. package/dist/api/api-versions.js +13 -0
  6. package/dist/api/create-topics.d.ts +14 -12
  7. package/dist/api/create-topics.js +104 -12
  8. package/dist/api/delete-topics.d.ts +10 -8
  9. package/dist/api/delete-topics.js +61 -7
  10. package/dist/api/fetch.d.ts +15 -12
  11. package/dist/api/fetch.js +131 -13
  12. package/dist/api/find-coordinator.d.ts +9 -7
  13. package/dist/api/find-coordinator.js +63 -5
  14. package/dist/api/heartbeat.d.ts +7 -5
  15. package/dist/api/heartbeat.js +42 -4
  16. package/dist/api/index.d.ts +47 -118
  17. package/dist/api/init-producer-id.d.ts +7 -5
  18. package/dist/api/init-producer-id.js +53 -9
  19. package/dist/api/join-group.d.ts +9 -7
  20. package/dist/api/join-group.js +95 -6
  21. package/dist/api/leave-group.d.ts +8 -6
  22. package/dist/api/leave-group.js +49 -6
  23. package/dist/api/list-offsets.d.ts +9 -7
  24. package/dist/api/list-offsets.js +85 -8
  25. package/dist/api/metadata.d.ts +10 -9
  26. package/dist/api/metadata.js +109 -8
  27. package/dist/api/offset-commit.d.ts +10 -8
  28. package/dist/api/offset-commit.js +88 -8
  29. package/dist/api/offset-fetch.d.ts +11 -9
  30. package/dist/api/offset-fetch.js +94 -9
  31. package/dist/api/produce.d.ts +8 -10
  32. package/dist/api/produce.js +132 -38
  33. package/dist/api/sasl-authenticate.d.ts +8 -6
  34. package/dist/api/sasl-authenticate.js +43 -3
  35. package/dist/api/sasl-handshake.d.ts +7 -4
  36. package/dist/api/sasl-handshake.js +10 -0
  37. package/dist/api/sync-group.d.ts +7 -5
  38. package/dist/api/sync-group.js +62 -5
  39. package/dist/broker.js +6 -5
  40. package/dist/cluster.test.js +17 -14
  41. package/dist/connection.d.ts +11 -1
  42. package/dist/connection.js +27 -2
  43. package/dist/consumer/consumer.js +13 -9
  44. package/dist/consumer/metadata.d.ts +24 -0
  45. package/dist/consumer/metadata.js +64 -0
  46. package/dist/distributors/messages-to-topic-partition-leaders.d.ts +17 -0
  47. package/dist/distributors/messages-to-topic-partition-leaders.js +15 -0
  48. package/dist/distributors/messages-to-topic-partition-leaders.test.d.ts +1 -0
  49. package/dist/distributors/messages-to-topic-partition-leaders.test.js +30 -0
  50. package/dist/examples/src/replicator.js +34 -0
  51. package/dist/examples/src/utils/json.js +5 -0
  52. package/dist/request-handler.d.ts +16 -0
  53. package/dist/request-handler.js +67 -0
  54. package/dist/request-handler.test.d.ts +1 -0
  55. package/dist/request-handler.test.js +340 -0
  56. package/dist/src/api/api-versions.js +18 -0
  57. package/dist/src/api/create-topics.js +46 -0
  58. package/dist/src/api/delete-topics.js +26 -0
  59. package/dist/src/api/fetch.js +95 -0
  60. package/dist/src/api/find-coordinator.js +34 -0
  61. package/dist/src/api/heartbeat.js +22 -0
  62. package/dist/src/api/index.js +38 -0
  63. package/dist/src/api/init-producer-id.js +24 -0
  64. package/dist/src/api/join-group.js +48 -0
  65. package/dist/src/api/leave-group.js +30 -0
  66. package/dist/src/api/list-offsets.js +39 -0
  67. package/dist/src/api/metadata.js +47 -0
  68. package/dist/src/api/offset-commit.js +39 -0
  69. package/dist/src/api/offset-fetch.js +44 -0
  70. package/dist/src/api/produce.js +119 -0
  71. package/dist/src/api/sync-group.js +31 -0
  72. package/dist/src/broker.js +35 -0
  73. package/dist/src/connection.js +21 -0
  74. package/dist/src/consumer/consumer-group.js +131 -0
  75. package/dist/src/consumer/consumer.js +103 -0
  76. package/dist/src/consumer/metadata.js +52 -0
  77. package/dist/src/consumer/offset-manager.js +23 -0
  78. package/dist/src/index.js +19 -0
  79. package/dist/src/producer/producer.js +84 -0
  80. package/dist/src/request-handler.js +57 -0
  81. package/dist/src/request-handler.test.js +321 -0
  82. package/dist/src/types.js +2 -0
  83. package/dist/src/utils/api.js +5 -0
  84. package/dist/src/utils/decoder.js +161 -0
  85. package/dist/src/utils/encoder.js +137 -0
  86. package/dist/src/utils/error.js +10 -0
  87. package/dist/utils/api.d.ts +4 -1
  88. package/dist/utils/cached.d.ts +3 -0
  89. package/dist/utils/cached.js +19 -0
  90. package/dist/utils/debug.d.ts +2 -0
  91. package/dist/utils/debug.js +11 -0
  92. package/dist/utils/decoder.d.ts +2 -2
  93. package/dist/utils/decoder.js +14 -1
  94. package/dist/utils/encoder.d.ts +1 -0
  95. package/dist/utils/encoder.js +14 -0
  96. package/dist/utils/lock.d.ts +8 -0
  97. package/dist/utils/lock.js +44 -0
  98. package/dist/utils/memo.d.ts +1 -0
  99. package/dist/utils/memo.js +16 -0
  100. package/dist/utils/mutex.d.ts +3 -0
  101. package/dist/utils/mutex.js +32 -0
  102. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import { Api } from '../utils/api';
2
2
  export declare const API: {
3
- API_VERSIONS: Api<unknown, {
3
+ API_VERSIONS: Api<{}, {
4
4
  errorCode: number;
5
5
  versions: {
6
6
  apiKey: number;
@@ -26,44 +26,42 @@ export declare const API: {
26
26
  timeoutMs?: number;
27
27
  validateOnly?: boolean;
28
28
  }, {
29
- _tag: void;
30
29
  throttleTimeMs: number;
31
30
  topics: {
32
- name: string | null;
33
- topicId: string;
31
+ name: string;
32
+ _topicId: string;
34
33
  errorCode: number;
35
34
  errorMessage: string | null;
36
- numPartitions: number;
37
- replicationFactor: number;
35
+ _numPartitions: number;
36
+ _replicationFactor: number;
38
37
  configs: {
39
- name: string | null;
38
+ name: string;
40
39
  value: string | null;
41
40
  readOnly: boolean;
42
41
  configSource: number;
43
42
  isSensitive: boolean;
44
- _tag: void;
43
+ tags: Record<number, Buffer>;
45
44
  }[];
46
- _tag: void;
45
+ tags: Record<number, Buffer>;
47
46
  }[];
48
- _tag2: void;
47
+ tags: Record<number, Buffer>;
49
48
  }>;
50
49
  DELETE_TOPICS: Api<{
51
50
  topics: {
52
- name: string | null;
51
+ name: string;
53
52
  topicId: string | null;
54
53
  }[];
55
54
  timeoutMs?: number;
56
55
  }, {
57
- _tag: void;
58
56
  throttleTimeMs: number;
59
57
  responses: {
60
58
  name: string | null;
61
- topicId: string;
59
+ _topicId: string;
62
60
  errorCode: number;
63
61
  errorMessage: string | null;
64
- _tag: void;
62
+ tags: Record<number, Buffer>;
65
63
  }[];
66
- _tag2: void;
64
+ tags: Record<number, Buffer>;
67
65
  }>;
68
66
  FETCH: Api<{
69
67
  maxWaitMs: number;
@@ -74,6 +72,7 @@ export declare const API: {
74
72
  sessionEpoch: number;
75
73
  topics: {
76
74
  topicId: string;
75
+ topicName: string;
77
76
  partitions: {
78
77
  partition: number;
79
78
  currentLeaderEpoch: number;
@@ -85,80 +84,26 @@ export declare const API: {
85
84
  }[];
86
85
  forgottenTopicsData: {
87
86
  topicId: string;
87
+ topicName: string;
88
88
  partitions: number[];
89
89
  }[];
90
90
  rackId: string;
91
- }, {
92
- _tag: void;
93
- throttleTimeMs: number;
94
- errorCode: number;
95
- sessionId: number;
96
- responses: {
97
- topicId: string;
98
- partitions: {
99
- partitionIndex: number;
100
- errorCode: number;
101
- highWatermark: bigint;
102
- lastStableOffset: bigint;
103
- logStartOffset: bigint;
104
- abortedTransactions: {
105
- producerId: bigint;
106
- firstOffset: bigint;
107
- _tag: void;
108
- }[];
109
- preferredReadReplica: number;
110
- records: {
111
- baseOffset: bigint;
112
- batchLength: number;
113
- partitionLeaderEpoch: number;
114
- magic: number;
115
- crc: number;
116
- attributes: number;
117
- compression: number;
118
- timestampType: string;
119
- isTransactional: boolean;
120
- isControlBatch: boolean;
121
- hasDeleteHorizonMs: boolean;
122
- lastOffsetDelta: number;
123
- baseTimestamp: bigint;
124
- maxTimestamp: bigint;
125
- producerId: bigint;
126
- producerEpoch: number;
127
- baseSequence: number;
128
- records: {
129
- attributes: number;
130
- timestampDelta: bigint;
131
- offsetDelta: number;
132
- key: string | null;
133
- value: string | null;
134
- headers: {
135
- key: string;
136
- value: string;
137
- }[];
138
- }[];
139
- }[];
140
- _tag: void;
141
- }[];
142
- _tag: void;
143
- }[];
144
- _tag2: void;
145
- }>;
91
+ }, import("./fetch").FetchResponse>;
146
92
  FIND_COORDINATOR: Api<{
147
93
  keyType: number;
148
94
  keys: string[];
149
95
  }, {
150
- _tag: void;
151
96
  throttleTimeMs: number;
152
97
  coordinators: {
153
- key: string | null;
98
+ key: string;
154
99
  nodeId: number;
155
100
  host: string;
156
101
  port: number;
157
102
  errorCode: number;
158
103
  errorMessage: string | null;
159
- _tag: void;
104
+ tags: Record<number, Buffer>;
160
105
  }[];
161
- _tag2: void;
106
+ tags: Record<number, Buffer>;
162
107
  }>;
163
108
  HEARTBEAT: Api<{
164
109
  groupId: string;
@@ -166,10 +111,9 @@ export declare const API: {
166
111
  memberId: string;
167
112
  groupInstanceId: string | null;
168
113
  }, {
169
- _tag: void;
170
114
  throttleTimeMs: number;
171
115
  errorCode: number;
172
- _tag2: void;
116
+ tags: Record<number, Buffer>;
173
117
  }>;
174
118
  INIT_PRODUCER_ID: Api<{
175
119
  transactionalId: string | null;
@@ -177,12 +121,11 @@ export declare const API: {
177
121
  producerId: bigint;
178
122
  producerEpoch: number;
179
123
  }, {
180
- _tag: void;
181
124
  throttleTimeMs: number;
182
125
  errorCode: number;
183
126
  producerId: bigint;
184
127
  producerEpoch: number;
185
- _tag2: void;
128
+ tags: Record<number, Buffer>;
186
129
  }>;
187
130
  JOIN_GROUP: Api<{
188
131
  groupId: string;
@@ -200,7 +143,6 @@ export declare const API: {
200
143
  }[];
201
144
  reason: string | null;
202
145
  }, {
203
- _tag: void;
204
146
  throttleTimeMs: number;
205
147
  errorCode: number;
206
148
  generationId: number;
@@ -212,10 +154,10 @@ export declare const API: {
212
154
  members: {
213
155
  memberId: string;
214
156
  groupInstanceId: string | null;
215
- metadata: Buffer<ArrayBufferLike>;
216
- _tag: void;
157
+ metadata: Buffer;
158
+ tags: Record<number, Buffer>;
217
159
  }[];
218
- _tag2: void;
160
+ tags: Record<number, Buffer>;
219
161
  }>;
220
162
  LEAVE_GROUP: Api<{
221
163
  groupId: string;
@@ -225,16 +167,15 @@ export declare const API: {
225
167
  reason: string | null;
226
168
  }[];
227
169
  }, {
228
- _tag: void;
229
170
  throttleTimeMs: number;
230
171
  errorCode: number;
231
172
  members: {
232
173
  memberId: string;
233
174
  groupInstanceId: string | null;
234
175
  errorCode: number;
235
- _tag: void;
176
+ tags: Record<number, Buffer>;
236
177
  }[];
237
- _tag2: void;
178
+ tags: Record<number, Buffer>;
238
179
  }>;
239
180
  LIST_OFFSETS: Api<{
240
181
  replicaId: number;
@@ -248,7 +189,6 @@ export declare const API: {
248
189
  }[];
249
190
  }[];
250
191
  }, {
251
- _tag: void;
252
192
  throttleTimeMs: number;
253
193
  topics: {
254
194
  name: string;
@@ -258,11 +198,11 @@ export declare const API: {
258
198
  timestamp: bigint;
259
199
  offset: bigint;
260
200
  leaderEpoch: number;
261
- _tag: void;
201
+ tags: Record<number, Buffer>;
262
202
  }[];
263
- _tag: void;
203
+ tags: Record<number, Buffer>;
264
204
  }[];
265
- _tag2: void;
205
+ tags: Record<number, Buffer>;
266
206
  }>;
267
207
  METADATA: Api<{
268
208
  topics?: {
@@ -272,14 +212,12 @@ export declare const API: {
272
212
  allowTopicAutoCreation?: boolean;
273
213
  includeTopicAuthorizedOperations?: boolean;
274
214
  }, {
275
- _tag: void;
276
215
  throttleTimeMs: number;
277
216
  brokers: {
278
217
  nodeId: number;
279
218
  host: string;
280
219
  port: number;
281
220
  rack: string | null;
282
- _tag: void;
283
221
  }[];
284
222
  clusterId: string | null;
285
223
  controllerId: number;
@@ -296,12 +234,12 @@ export declare const API: {
296
234
  replicaNodes: number[];
297
235
  isrNodes: number[];
298
236
  offlineReplicas: number[];
299
- _tag: void;
237
+ tags: Record<number, Buffer>;
300
238
  }[];
301
239
  topicAuthorizedOperations: number;
302
- _tag: void;
240
+ tags: Record<number, Buffer>;
303
241
  }[];
304
- _tag2: void;
242
+ tags: Record<number, Buffer>;
305
243
  }>;
306
244
  OFFSET_COMMIT: Api<{
307
245
  groupId: string;
@@ -318,18 +256,17 @@ export declare const API: {
318
256
  }[];
319
257
  }[];
320
258
  }, {
321
- _tag: void;
322
259
  throttleTimeMs: number;
323
260
  topics: {
324
- name: string | null;
261
+ name: string;
325
262
  partitions: {
326
263
  partitionIndex: number;
327
264
  errorCode: number;
328
- _tag: void;
265
+ tags: Record<number, Buffer>;
329
266
  }[];
330
- _tag: void;
267
+ tags: Record<number, Buffer>;
331
268
  }[];
332
- _tag2: void;
269
+ tags: Record<number, Buffer>;
333
270
  }>;
334
271
  OFFSET_FETCH: Api<{
335
272
  groups: {
@@ -341,10 +278,9 @@ export declare const API: {
341
278
  }[];
342
279
  requireStable: boolean;
343
280
  }, {
344
- _tag: void;
345
281
  throttleTimeMs: number;
346
282
  groups: {
347
- groupId: string | null;
283
+ groupId: string;
348
284
  topics: {
349
285
  name: string;
350
286
  partitions: {
@@ -353,14 +289,14 @@ export declare const API: {
353
289
  committedLeaderEpoch: number;
354
290
  committedMetadata: string | null;
355
291
  errorCode: number;
356
- _tag: void;
292
+ tags: Record<number, Buffer>;
357
293
  }[];
358
- _tag: void;
294
+ tags: Record<number, Buffer>;
359
295
  }[];
360
296
  errorCode: number;
361
- _tag: void;
297
+ tags: Record<number, Buffer>;
362
298
  }[];
363
- _tag2: void;
299
+ tags: Record<number, Buffer>;
364
300
  }>;
365
301
  PRODUCE: Api<{
366
302
  transactionalId: string | null;
@@ -393,9 +329,8 @@ export declare const API: {
393
329
  }[];
394
330
  }[];
395
331
  }, {
396
- _tag: void;
397
332
  responses: {
398
- name: string | null;
333
+ name: string;
399
334
  partitionResponses: {
400
335
  index: number;
401
336
  errorCode: number;
@@ -404,32 +339,27 @@ export declare const API: {
404
339
  logStartOffset: bigint;
405
340
  recordErrors: {
406
341
  batchIndex: number;
407
- batchIndexError: number;
408
- _tag: void;
342
+ batchIndexErrorMessage: string | null;
409
343
  }[];
410
344
  errorMessage: string | null;
411
- _tag: void;
412
345
  }[];
413
- _tag: void;
414
346
  }[];
415
347
  throttleTimeMs: number;
416
- _tag2: void;
417
348
  }>;
418
349
  SASL_AUTHENTICATE: Api<{
419
350
  authBytes: Buffer;
420
351
  }, {
421
- _tag: void;
422
352
  errorCode: number;
423
353
  errorMessage: string | null;
424
- authBytes: Buffer<ArrayBufferLike> | null;
354
+ authBytes: Buffer;
425
355
  sessionLifetimeMs: bigint;
426
- _tag2: void;
356
+ tags: Record<number, Buffer>;
427
357
  }>;
428
358
  SASL_HANDSHAKE: Api<{
429
359
  mechanism: string;
430
360
  }, {
431
361
  errorCode: number;
432
- mechanisms: (string | null)[];
362
+ mechanisms: string[];
433
363
  }>;
434
364
  SYNC_GROUP: Api<{
435
365
  groupId: string;
@@ -440,13 +370,12 @@ export declare const API: {
440
370
  protocolName: string | null;
441
371
  assignments: import("./sync-group").MemberAssignment[];
442
372
  }, {
443
- _tag: void;
444
373
  throttleTimeMs: number;
445
374
  errorCode: number;
446
375
  protocolType: string | null;
447
376
  protocolName: string | null;
448
377
  assignments: import("./sync-group").Assignment;
449
- _tag2: void;
378
+ tags: Record<number, Buffer>;
450
379
  }>;
451
380
  };
452
381
  export declare const getApiName: <Request, Response>(api: Api<Request, Response>) => string;
@@ -1,13 +1,15 @@
1
- export declare const INIT_PRODUCER_ID: import("../utils/api").Api<{
1
+ type InitProducerIdRequest = {
2
2
  transactionalId: string | null;
3
3
  transactionTimeoutMs: number;
4
4
  producerId: bigint;
5
5
  producerEpoch: number;
6
- }, {
7
- _tag: void;
6
+ };
7
+ type InitProducerIdResponse = {
8
8
  throttleTimeMs: number;
9
9
  errorCode: number;
10
10
  producerId: bigint;
11
11
  producerEpoch: number;
12
- _tag2: void;
13
- }>;
12
+ tags: Record<number, Buffer>;
13
+ };
14
+ export declare const INIT_PRODUCER_ID: import("../utils/api").Api<InitProducerIdRequest, InitProducerIdResponse>;
15
+ export {};
@@ -3,24 +3,68 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.INIT_PRODUCER_ID = void 0;
4
4
  const api_1 = require("../utils/api");
5
5
  const error_1 = require("../utils/error");
6
+ /*
7
+ InitProducerId Request (Version: 0) => transactional_id transaction_timeout_ms
8
+ transactional_id => NULLABLE_STRING
9
+ transaction_timeout_ms => INT32
10
+
11
+ InitProducerId Response (Version: 0) => throttle_time_ms error_code producer_id producer_epoch
12
+ throttle_time_ms => INT32
13
+ error_code => INT16
14
+ producer_id => INT64
15
+ producer_epoch => INT16
16
+ */
17
+ const INIT_PRODUCER_ID_V0 = (0, api_1.createApi)({
18
+ apiKey: 22,
19
+ apiVersion: 0,
20
+ requestHeaderVersion: 1,
21
+ responseHeaderVersion: 0,
22
+ request: (encoder, data) => encoder.writeString(data.transactionalId).writeInt32(data.transactionTimeoutMs),
23
+ response: (decoder) => {
24
+ const result = {
25
+ throttleTimeMs: decoder.readInt32(),
26
+ errorCode: decoder.readInt16(),
27
+ producerId: decoder.readInt64(),
28
+ producerEpoch: decoder.readInt16(),
29
+ tags: {},
30
+ };
31
+ if (result.errorCode)
32
+ throw new error_1.KafkaTSApiError(result.errorCode, null, result);
33
+ return result;
34
+ },
35
+ });
36
+ /*
37
+ InitProducerId Request (Version: 4) => transactional_id transaction_timeout_ms producer_id producer_epoch _tagged_fields
38
+ transactional_id => COMPACT_NULLABLE_STRING
39
+ transaction_timeout_ms => INT32
40
+ producer_id => INT64
41
+ producer_epoch => INT16
42
+
43
+ InitProducerId Response (Version: 4) => throttle_time_ms error_code producer_id producer_epoch _tagged_fields
44
+ throttle_time_ms => INT32
45
+ error_code => INT16
46
+ producer_id => INT64
47
+ producer_epoch => INT16
48
+ */
6
49
  exports.INIT_PRODUCER_ID = (0, api_1.createApi)({
7
50
  apiKey: 22,
8
51
  apiVersion: 4,
9
- request: (encoder, body) => encoder
10
- .writeUVarInt(0)
11
- .writeCompactString(body.transactionalId)
12
- .writeInt32(body.transactionTimeoutMs)
13
- .writeInt64(body.producerId)
14
- .writeInt16(body.producerEpoch)
15
- .writeUVarInt(0),
52
+ fallback: INIT_PRODUCER_ID_V0,
53
+ requestHeaderVersion: 2,
54
+ responseHeaderVersion: 1,
55
+ request: (encoder, data) => encoder
56
+ .writeCompactString(data.transactionalId)
57
+ .writeInt32(data.transactionTimeoutMs)
58
+ .writeInt64(data.producerId)
59
+ .writeInt16(data.producerEpoch)
60
+ .writeTagBuffer(),
16
61
  response: (decoder) => {
17
62
  const result = {
18
- _tag: decoder.readTagBuffer(),
19
63
  throttleTimeMs: decoder.readInt32(),
20
64
  errorCode: decoder.readInt16(),
21
65
  producerId: decoder.readInt64(),
22
66
  producerEpoch: decoder.readInt16(),
23
- _tag2: decoder.readTagBuffer(),
67
+ tags: decoder.readTagBuffer(),
24
68
  };
25
69
  if (result.errorCode)
26
70
  throw new error_1.KafkaTSApiError(result.errorCode, null, result);
@@ -1,4 +1,4 @@
1
- export declare const JOIN_GROUP: import("../utils/api").Api<{
1
+ type JoinGroupRequest = {
2
2
  groupId: string;
3
3
  sessionTimeoutMs: number;
4
4
  rebalanceTimeoutMs: number;
@@ -13,8 +13,8 @@ export declare const JOIN_GROUP: import("../utils/api").Api<{
13
13
  };
14
14
  }[];
15
15
  reason: string | null;
16
- }, {
17
- _tag: void;
16
+ };
17
+ type JoinGroupResponse = {
18
18
  throttleTimeMs: number;
19
19
  errorCode: number;
20
20
  generationId: number;
@@ -26,8 +26,10 @@ export declare const JOIN_GROUP: import("../utils/api").Api<{
26
26
  members: {
27
27
  memberId: string;
28
28
  groupInstanceId: string | null;
29
- metadata: Buffer<ArrayBufferLike>;
30
- _tag: void;
29
+ metadata: Buffer;
30
+ tags: Record<number, Buffer>;
31
31
  }[];
32
- _tag2: void;
33
- }>;
32
+ tags: Record<number, Buffer>;
33
+ };
34
+ export declare const JOIN_GROUP: import("../utils/api").Api<JoinGroupRequest, JoinGroupResponse>;
35
+ export {};
@@ -4,11 +4,101 @@ exports.JOIN_GROUP = void 0;
4
4
  const api_1 = require("../utils/api");
5
5
  const encoder_1 = require("../utils/encoder");
6
6
  const error_1 = require("../utils/error");
7
+ /*
8
+ JoinGroup Request (Version: 0) => group_id session_timeout_ms member_id protocol_type [protocols]
9
+ group_id => STRING
10
+ session_timeout_ms => INT32
11
+ member_id => STRING
12
+ protocol_type => STRING
13
+ protocols => name metadata
14
+ name => STRING
15
+ metadata => BYTES
16
+
17
+ JoinGroup Response (Version: 0) => error_code generation_id protocol_name leader member_id [members]
18
+ error_code => INT16
19
+ generation_id => INT32
20
+ protocol_name => STRING
21
+ leader => STRING
22
+ member_id => STRING
23
+ members => member_id metadata
24
+ member_id => STRING
25
+ metadata => BYTES
26
+ */
27
+ const JOIN_GROUP_V0 = (0, api_1.createApi)({
28
+ apiKey: 11,
29
+ apiVersion: 0,
30
+ requestHeaderVersion: 1,
31
+ responseHeaderVersion: 0,
32
+ request: (encoder, data) => encoder
33
+ .writeString(data.groupId)
34
+ .writeInt32(data.sessionTimeoutMs)
35
+ .writeString(data.memberId)
36
+ .writeString(data.protocolType)
37
+ .writeArray(data.protocols, (encoder, protocol) => {
38
+ const metadata = new encoder_1.Encoder()
39
+ .writeInt16(protocol.metadata.version)
40
+ .writeArray(protocol.metadata.topics, (encoder, topic) => encoder.writeString(topic))
41
+ .writeBytes(Buffer.alloc(0))
42
+ .value();
43
+ return encoder.writeString(protocol.name).writeBytes(metadata);
44
+ }),
45
+ response: (decoder) => {
46
+ const result = {
47
+ throttleTimeMs: 0,
48
+ errorCode: decoder.readInt16(),
49
+ generationId: decoder.readInt32(),
50
+ protocolType: null,
51
+ protocolName: decoder.readString(),
52
+ leader: decoder.readString(),
53
+ skipAssignment: false,
54
+ memberId: decoder.readString(),
55
+ members: decoder.readArray((decoder) => ({
56
+ memberId: decoder.readString(),
57
+ groupInstanceId: null,
58
+ metadata: decoder.readBytes(),
59
+ tags: {},
60
+ })),
61
+ tags: {},
62
+ };
63
+ if (result.errorCode)
64
+ throw new error_1.KafkaTSApiError(result.errorCode, null, result);
65
+ return result;
66
+ },
67
+ });
68
+ /*
69
+ JoinGroup Request (Version: 9) => group_id session_timeout_ms rebalance_timeout_ms member_id group_instance_id protocol_type [protocols] reason _tagged_fields
70
+ group_id => COMPACT_STRING
71
+ session_timeout_ms => INT32
72
+ rebalance_timeout_ms => INT32
73
+ member_id => COMPACT_STRING
74
+ group_instance_id => COMPACT_NULLABLE_STRING
75
+ protocol_type => COMPACT_STRING
76
+ protocols => name metadata _tagged_fields
77
+ name => COMPACT_STRING
78
+ metadata => COMPACT_BYTES
79
+ reason => COMPACT_NULLABLE_STRING
80
+
81
+ JoinGroup Response (Version: 9) => throttle_time_ms error_code generation_id protocol_type protocol_name leader skip_assignment member_id [members] _tagged_fields
82
+ throttle_time_ms => INT32
83
+ error_code => INT16
84
+ generation_id => INT32
85
+ protocol_type => COMPACT_NULLABLE_STRING
86
+ protocol_name => COMPACT_NULLABLE_STRING
87
+ leader => COMPACT_STRING
88
+ skip_assignment => BOOLEAN
89
+ member_id => COMPACT_STRING
90
+ members => member_id group_instance_id metadata _tagged_fields
91
+ member_id => COMPACT_STRING
92
+ group_instance_id => COMPACT_NULLABLE_STRING
93
+ metadata => COMPACT_BYTES
94
+ */
7
95
  exports.JOIN_GROUP = (0, api_1.createApi)({
8
96
  apiKey: 11,
9
97
  apiVersion: 9,
98
+ fallback: JOIN_GROUP_V0,
99
+ requestHeaderVersion: 2,
100
+ responseHeaderVersion: 1,
10
101
  request: (encoder, data) => encoder
11
- .writeUVarInt(0)
12
102
  .writeCompactString(data.groupId)
13
103
  .writeInt32(data.sessionTimeoutMs)
14
104
  .writeInt32(data.rebalanceTimeoutMs)
@@ -21,13 +111,12 @@ exports.JOIN_GROUP = (0, api_1.createApi)({
21
111
  .writeArray(protocol.metadata.topics, (encoder, topic) => encoder.writeString(topic))
22
112
  .writeBytes(Buffer.alloc(0))
23
113
  .value();
24
- return encoder.writeCompactString(protocol.name).writeCompactBytes(metadata).writeUVarInt(0);
114
+ return encoder.writeCompactString(protocol.name).writeCompactBytes(metadata).writeTagBuffer();
25
115
  })
26
116
  .writeCompactString(data.reason)
27
- .writeUVarInt(0),
117
+ .writeTagBuffer(),
28
118
  response: (decoder) => {
29
119
  const result = {
30
- _tag: decoder.readTagBuffer(),
31
120
  throttleTimeMs: decoder.readInt32(),
32
121
  errorCode: decoder.readInt16(),
33
122
  generationId: decoder.readInt32(),
@@ -40,9 +129,9 @@ exports.JOIN_GROUP = (0, api_1.createApi)({
40
129
  memberId: decoder.readCompactString(),
41
130
  groupInstanceId: decoder.readCompactString(),
42
131
  metadata: decoder.readCompactBytes(),
43
- _tag: decoder.readTagBuffer(),
132
+ tags: decoder.readTagBuffer(),
44
133
  })),
45
- _tag2: decoder.readTagBuffer(),
134
+ tags: decoder.readTagBuffer(),
46
135
  };
47
136
  if (result.errorCode)
48
137
  throw new error_1.KafkaTSApiError(result.errorCode, null, result);
@@ -1,19 +1,21 @@
1
- export declare const LEAVE_GROUP: import("../utils/api").Api<{
1
+ type LeaveGroupRequest = {
2
2
  groupId: string;
3
3
  members: {
4
4
  memberId: string;
5
5
  groupInstanceId: string | null;
6
6
  reason: string | null;
7
7
  }[];
8
- }, {
9
- _tag: void;
8
+ };
9
+ type LeaveGroupResponse = {
10
10
  throttleTimeMs: number;
11
11
  errorCode: number;
12
12
  members: {
13
13
  memberId: string;
14
14
  groupInstanceId: string | null;
15
15
  errorCode: number;
16
- _tag: void;
16
+ tags: Record<number, Buffer>;
17
17
  }[];
18
- _tag2: void;
19
- }>;
18
+ tags: Record<number, Buffer>;
19
+ };
20
+ export declare const LEAVE_GROUP: import("../utils/api").Api<LeaveGroupRequest, LeaveGroupResponse>;
21
+ export {};