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
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.INIT_PRODUCER_ID = void 0;
4
+ const api_1 = require("../utils/api");
5
+ const error_1 = require("../utils/error");
6
+ exports.INIT_PRODUCER_ID = (0, api_1.createApi)({
7
+ apiKey: 22,
8
+ 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),
16
+ response: (decoder) => {
17
+ const result = {
18
+ _tag: decoder.readTagBuffer(),
19
+ throttleTimeMs: decoder.readInt32(),
20
+ errorCode: decoder.readInt16(),
21
+ producerId: decoder.readInt64(),
22
+ producerEpoch: decoder.readInt16(),
23
+ _tag2: decoder.readTagBuffer(),
24
+ };
25
+ if (result.errorCode)
26
+ throw new error_1.KafkaTSApiError(result.errorCode, null, result);
27
+ return result;
28
+ },
29
+ });
@@ -0,0 +1,34 @@
1
+ /// <reference types="node" />
2
+ export declare const JOIN_GROUP: import("../utils/api").Api<{
3
+ groupId: string;
4
+ sessionTimeoutMs: number;
5
+ rebalanceTimeoutMs: number;
6
+ memberId: string;
7
+ groupInstanceId: string | null;
8
+ protocolType: string;
9
+ protocols: {
10
+ name: string;
11
+ metadata: {
12
+ version: number;
13
+ topics: string[];
14
+ };
15
+ }[];
16
+ reason: string | null;
17
+ }, {
18
+ _tag: void;
19
+ throttleTimeMs: number;
20
+ errorCode: number;
21
+ generationId: number;
22
+ protocolType: string | null;
23
+ protocolName: string | null;
24
+ leader: string;
25
+ skipAssignment: boolean;
26
+ memberId: string;
27
+ members: {
28
+ memberId: string;
29
+ groupInstanceId: string | null;
30
+ metadata: Buffer;
31
+ _tag: void;
32
+ }[];
33
+ _tag2: void;
34
+ }>;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JOIN_GROUP = void 0;
4
+ const api_1 = require("../utils/api");
5
+ const encoder_1 = require("../utils/encoder");
6
+ const error_1 = require("../utils/error");
7
+ exports.JOIN_GROUP = (0, api_1.createApi)({
8
+ apiKey: 11,
9
+ apiVersion: 9,
10
+ request: (encoder, data) => encoder
11
+ .writeUVarInt(0)
12
+ .writeCompactString(data.groupId)
13
+ .writeInt32(data.sessionTimeoutMs)
14
+ .writeInt32(data.rebalanceTimeoutMs)
15
+ .writeCompactString(data.memberId)
16
+ .writeCompactString(data.groupInstanceId)
17
+ .writeCompactString(data.protocolType)
18
+ .writeCompactArray(data.protocols, (encoder, protocol) => {
19
+ const metadata = new encoder_1.Encoder()
20
+ .writeInt16(protocol.metadata.version)
21
+ .writeArray(protocol.metadata.topics, (encoder, topic) => encoder.writeString(topic))
22
+ .writeBytes(Buffer.alloc(0))
23
+ .value();
24
+ return encoder.writeCompactString(protocol.name).writeCompactBytes(metadata).writeUVarInt(0);
25
+ })
26
+ .writeCompactString(data.reason)
27
+ .writeUVarInt(0),
28
+ response: (decoder) => {
29
+ const result = {
30
+ _tag: decoder.readTagBuffer(),
31
+ throttleTimeMs: decoder.readInt32(),
32
+ errorCode: decoder.readInt16(),
33
+ generationId: decoder.readInt32(),
34
+ protocolType: decoder.readCompactString(),
35
+ protocolName: decoder.readCompactString(),
36
+ leader: decoder.readCompactString(),
37
+ skipAssignment: decoder.readBoolean(),
38
+ memberId: decoder.readCompactString(),
39
+ members: decoder.readCompactArray((decoder) => ({
40
+ memberId: decoder.readCompactString(),
41
+ groupInstanceId: decoder.readCompactString(),
42
+ metadata: decoder.readCompactBytes(),
43
+ _tag: decoder.readTagBuffer(),
44
+ })),
45
+ _tag2: decoder.readTagBuffer(),
46
+ };
47
+ if (result.errorCode)
48
+ throw new error_1.KafkaTSApiError(result.errorCode, null, result);
49
+ return result;
50
+ },
51
+ });
@@ -0,0 +1,19 @@
1
+ export declare const LEAVE_GROUP: import("../utils/api").Api<{
2
+ groupId: string;
3
+ members: {
4
+ memberId: string;
5
+ groupInstanceId: string | null;
6
+ reason: string | null;
7
+ }[];
8
+ }, {
9
+ _tag: void;
10
+ throttleTimeMs: number;
11
+ errorCode: number;
12
+ members: {
13
+ memberId: string;
14
+ groupInstanceId: string | null;
15
+ errorCode: number;
16
+ _tag: void;
17
+ }[];
18
+ _tag2: void;
19
+ }>;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LEAVE_GROUP = void 0;
4
+ const api_1 = require("../utils/api");
5
+ const error_1 = require("../utils/error");
6
+ exports.LEAVE_GROUP = (0, api_1.createApi)({
7
+ apiKey: 13,
8
+ apiVersion: 5,
9
+ request: (encoder, body) => encoder
10
+ .writeUVarInt(0)
11
+ .writeCompactString(body.groupId)
12
+ .writeCompactArray(body.members, (encoder, member) => encoder
13
+ .writeCompactString(member.memberId)
14
+ .writeCompactString(member.groupInstanceId)
15
+ .writeCompactString(member.reason)
16
+ .writeUVarInt(0))
17
+ .writeUVarInt(0),
18
+ response: (decoder) => {
19
+ const result = {
20
+ _tag: decoder.readTagBuffer(),
21
+ throttleTimeMs: decoder.readInt32(),
22
+ errorCode: decoder.readInt16(),
23
+ members: decoder.readCompactArray((decoder) => ({
24
+ memberId: decoder.readCompactString(),
25
+ groupInstanceId: decoder.readCompactString(),
26
+ errorCode: decoder.readInt16(),
27
+ _tag: decoder.readTagBuffer(),
28
+ })),
29
+ _tag2: decoder.readTagBuffer(),
30
+ };
31
+ if (result.errorCode)
32
+ throw new error_1.KafkaTSApiError(result.errorCode, null, result);
33
+ result.members.forEach((member) => {
34
+ if (member.errorCode)
35
+ throw new error_1.KafkaTSApiError(member.errorCode, null, result);
36
+ });
37
+ return result;
38
+ },
39
+ });
@@ -0,0 +1,29 @@
1
+ import { IsolationLevel } from './fetch';
2
+ export declare const LIST_OFFSETS: import("../utils/api").Api<{
3
+ replicaId: number;
4
+ isolationLevel: IsolationLevel;
5
+ topics: {
6
+ name: string;
7
+ partitions: {
8
+ partitionIndex: number;
9
+ currentLeaderEpoch: number;
10
+ timestamp: bigint;
11
+ }[];
12
+ }[];
13
+ }, {
14
+ _tag: void;
15
+ throttleTimeMs: number;
16
+ topics: {
17
+ name: string;
18
+ partitions: {
19
+ partitionIndex: number;
20
+ errorCode: number;
21
+ timestamp: bigint;
22
+ offset: bigint;
23
+ leaderEpoch: number;
24
+ _tag: void;
25
+ }[];
26
+ _tag: void;
27
+ }[];
28
+ _tag2: void;
29
+ }>;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LIST_OFFSETS = void 0;
4
+ const api_1 = require("../utils/api");
5
+ const error_1 = require("../utils/error");
6
+ exports.LIST_OFFSETS = (0, api_1.createApi)({
7
+ apiKey: 2,
8
+ apiVersion: 8,
9
+ request: (encoder, data) => encoder
10
+ .writeUVarInt(0)
11
+ .writeInt32(data.replicaId)
12
+ .writeInt8(data.isolationLevel)
13
+ .writeCompactArray(data.topics, (encoder, topic) => encoder
14
+ .writeCompactString(topic.name)
15
+ .writeCompactArray(topic.partitions, (encoder, partition) => encoder
16
+ .writeInt32(partition.partitionIndex)
17
+ .writeInt32(partition.currentLeaderEpoch)
18
+ .writeInt64(partition.timestamp)
19
+ .writeUVarInt(0))
20
+ .writeUVarInt(0))
21
+ .writeUVarInt(0),
22
+ response: (decoder) => {
23
+ const result = {
24
+ _tag: decoder.readTagBuffer(),
25
+ throttleTimeMs: decoder.readInt32(),
26
+ topics: decoder.readCompactArray((decoder) => ({
27
+ name: decoder.readCompactString(),
28
+ partitions: decoder.readCompactArray((decoder) => ({
29
+ partitionIndex: decoder.readInt32(),
30
+ errorCode: decoder.readInt16(),
31
+ timestamp: decoder.readInt64(),
32
+ offset: decoder.readInt64(),
33
+ leaderEpoch: decoder.readInt32(),
34
+ _tag: decoder.readTagBuffer(),
35
+ })),
36
+ _tag: decoder.readTagBuffer(),
37
+ })),
38
+ _tag2: decoder.readTagBuffer(),
39
+ };
40
+ result.topics.forEach((topic) => {
41
+ topic.partitions.forEach((partition) => {
42
+ if (partition.errorCode)
43
+ throw new error_1.KafkaTSApiError(partition.errorCode, null, result);
44
+ });
45
+ });
46
+ return result;
47
+ },
48
+ });
@@ -0,0 +1,40 @@
1
+ export type Metadata = Awaited<ReturnType<(typeof METADATA)['response']>>;
2
+ export declare const METADATA: import("../utils/api").Api<{
3
+ topics: {
4
+ id: string | null;
5
+ name: string;
6
+ }[] | null;
7
+ allowTopicAutoCreation: boolean;
8
+ includeTopicAuthorizedOperations: boolean;
9
+ }, {
10
+ _tag: void;
11
+ throttleTimeMs: number;
12
+ brokers: {
13
+ nodeId: number;
14
+ host: string;
15
+ port: number;
16
+ rack: string | null;
17
+ _tag: void;
18
+ }[];
19
+ clusterId: string | null;
20
+ controllerId: number;
21
+ topics: {
22
+ errorCode: number;
23
+ name: string;
24
+ topicId: string;
25
+ isInternal: boolean;
26
+ partitions: {
27
+ errorCode: number;
28
+ partitionIndex: number;
29
+ leaderId: number;
30
+ leaderEpoch: number;
31
+ replicaNodes: number[];
32
+ isrNodes: number[];
33
+ offlineReplicas: number[];
34
+ _tag: void;
35
+ }[];
36
+ topicAuthorizedOperations: number;
37
+ _tag: void;
38
+ }[];
39
+ _tag2: void;
40
+ }>;
@@ -1,34 +1,24 @@
1
- import { createApi } from '../utils/api';
2
- import { KafkaTSApiError } from '../utils/error';
3
-
4
- export type Metadata = ReturnType<(typeof METADATA)['response']>;
5
-
6
- export const METADATA = createApi({
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.METADATA = void 0;
4
+ const api_1 = require("../utils/api");
5
+ const error_1 = require("../utils/error");
6
+ exports.METADATA = (0, api_1.createApi)({
7
7
  apiKey: 3,
8
8
  apiVersion: 12,
9
- request: (
10
- encoder,
11
- data: {
12
- topics: { id: string | null; name: string }[] | null;
13
- allowTopicAutoCreation: boolean;
14
- includeTopicAuthorizedOperations: boolean;
15
- },
16
- ) =>
17
- encoder
18
- .writeUVarInt(0)
19
- .writeCompactArray(data.topics, (encoder, topic) =>
20
- encoder.writeUUID(topic.id).writeCompactString(topic.name).writeUVarInt(0),
21
- )
22
- .writeBoolean(data.allowTopicAutoCreation)
23
- .writeBoolean(data.includeTopicAuthorizedOperations)
24
- .writeUVarInt(0),
9
+ request: (encoder, data) => encoder
10
+ .writeUVarInt(0)
11
+ .writeCompactArray(data.topics, (encoder, topic) => encoder.writeUUID(topic.id).writeCompactString(topic.name).writeUVarInt(0))
12
+ .writeBoolean(data.allowTopicAutoCreation)
13
+ .writeBoolean(data.includeTopicAuthorizedOperations)
14
+ .writeUVarInt(0),
25
15
  response: (decoder) => {
26
16
  const result = {
27
17
  _tag: decoder.readTagBuffer(),
28
18
  throttleTimeMs: decoder.readInt32(),
29
19
  brokers: decoder.readCompactArray((broker) => ({
30
20
  nodeId: broker.readInt32(),
31
- host: broker.readCompactString()!,
21
+ host: broker.readCompactString(),
32
22
  port: broker.readInt32(),
33
23
  rack: broker.readCompactString(),
34
24
  _tag: broker.readTagBuffer(),
@@ -37,7 +27,7 @@ export const METADATA = createApi({
37
27
  controllerId: decoder.readInt32(),
38
28
  topics: decoder.readCompactArray((topic) => ({
39
29
  errorCode: topic.readInt16(),
40
- name: topic.readCompactString()!,
30
+ name: topic.readCompactString(),
41
31
  topicId: topic.readUUID(),
42
32
  isInternal: topic.readBoolean(),
43
33
  partitions: topic.readCompactArray((partition) => ({
@@ -56,9 +46,11 @@ export const METADATA = createApi({
56
46
  _tag2: decoder.readTagBuffer(),
57
47
  };
58
48
  result.topics.forEach((topic) => {
59
- if (topic.errorCode) throw new KafkaTSApiError(topic.errorCode, null, result);
49
+ if (topic.errorCode)
50
+ throw new error_1.KafkaTSApiError(topic.errorCode, null, result);
60
51
  topic.partitions.forEach((partition) => {
61
- if (partition.errorCode) throw new KafkaTSApiError(partition.errorCode, null, result);
52
+ if (partition.errorCode)
53
+ throw new error_1.KafkaTSApiError(partition.errorCode, null, result);
62
54
  });
63
55
  });
64
56
  return result;
@@ -0,0 +1,28 @@
1
+ export declare const OFFSET_COMMIT: import("../utils/api").Api<{
2
+ groupId: string;
3
+ generationIdOrMemberEpoch: number;
4
+ memberId: string;
5
+ groupInstanceId: string | null;
6
+ topics: {
7
+ name: string;
8
+ partitions: {
9
+ partitionIndex: number;
10
+ committedOffset: bigint;
11
+ committedLeaderEpoch: number;
12
+ committedMetadata: string | null;
13
+ }[];
14
+ }[];
15
+ }, {
16
+ _tag: void;
17
+ throttleTimeMs: number;
18
+ topics: {
19
+ name: string | null;
20
+ partitions: {
21
+ partitionIndex: number;
22
+ errorCode: number;
23
+ _tag: void;
24
+ }[];
25
+ _tag: void;
26
+ }[];
27
+ _tag2: void;
28
+ }>;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OFFSET_COMMIT = void 0;
4
+ const api_1 = require("../utils/api");
5
+ const error_1 = require("../utils/error");
6
+ exports.OFFSET_COMMIT = (0, api_1.createApi)({
7
+ apiKey: 8,
8
+ apiVersion: 8,
9
+ request: (encoder, data) => encoder
10
+ .writeUVarInt(0)
11
+ .writeCompactString(data.groupId)
12
+ .writeInt32(data.generationIdOrMemberEpoch)
13
+ .writeCompactString(data.memberId)
14
+ .writeCompactString(data.groupInstanceId)
15
+ .writeCompactArray(data.topics, (encoder, topic) => encoder
16
+ .writeCompactString(topic.name)
17
+ .writeCompactArray(topic.partitions, (encoder, partition) => encoder
18
+ .writeInt32(partition.partitionIndex)
19
+ .writeInt64(partition.committedOffset)
20
+ .writeInt32(partition.committedLeaderEpoch)
21
+ .writeCompactString(partition.committedMetadata)
22
+ .writeUVarInt(0))
23
+ .writeUVarInt(0))
24
+ .writeUVarInt(0),
25
+ response: (decoder) => {
26
+ const result = {
27
+ _tag: decoder.readTagBuffer(),
28
+ throttleTimeMs: decoder.readInt32(),
29
+ topics: decoder.readCompactArray((decoder) => ({
30
+ name: decoder.readCompactString(),
31
+ partitions: decoder.readCompactArray((decoder) => ({
32
+ partitionIndex: decoder.readInt32(),
33
+ errorCode: decoder.readInt16(),
34
+ _tag: decoder.readTagBuffer(),
35
+ })),
36
+ _tag: decoder.readTagBuffer(),
37
+ })),
38
+ _tag2: decoder.readTagBuffer(),
39
+ };
40
+ result.topics.forEach((topic) => {
41
+ topic.partitions.forEach((partition) => {
42
+ if (partition.errorCode)
43
+ throw new error_1.KafkaTSApiError(partition.errorCode, null, result);
44
+ });
45
+ });
46
+ return result;
47
+ },
48
+ });
@@ -0,0 +1,31 @@
1
+ export declare const OFFSET_FETCH: import("../utils/api").Api<{
2
+ groups: {
3
+ groupId: string;
4
+ topics: {
5
+ name: string;
6
+ partitionIndexes: number[];
7
+ }[];
8
+ }[];
9
+ requireStable: boolean;
10
+ }, {
11
+ _tag: void;
12
+ throttleTimeMs: number;
13
+ groups: {
14
+ groupId: string | null;
15
+ topics: {
16
+ name: string;
17
+ partitions: {
18
+ partitionIndex: number;
19
+ committedOffset: bigint;
20
+ committedLeaderEpoch: number;
21
+ committedMetadata: string | null;
22
+ errorCode: number;
23
+ _tag: void;
24
+ }[];
25
+ _tag: void;
26
+ }[];
27
+ errorCode: number;
28
+ _tag: void;
29
+ }[];
30
+ _tag2: void;
31
+ }>;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OFFSET_FETCH = void 0;
4
+ const api_1 = require("../utils/api");
5
+ const error_1 = require("../utils/error");
6
+ exports.OFFSET_FETCH = (0, api_1.createApi)({
7
+ apiKey: 9,
8
+ apiVersion: 8,
9
+ request: (encoder, data) => encoder
10
+ .writeUVarInt(0)
11
+ .writeCompactArray(data.groups, (encoder, group) => encoder
12
+ .writeCompactString(group.groupId)
13
+ .writeCompactArray(group.topics, (encoder, topic) => encoder
14
+ .writeCompactString(topic.name)
15
+ .writeCompactArray(topic.partitionIndexes, (encoder, partitionIndex) => encoder.writeInt32(partitionIndex))
16
+ .writeUVarInt(0))
17
+ .writeUVarInt(0))
18
+ .writeBoolean(data.requireStable)
19
+ .writeUVarInt(0),
20
+ response: (decoder) => {
21
+ const result = {
22
+ _tag: decoder.readTagBuffer(),
23
+ throttleTimeMs: decoder.readInt32(),
24
+ groups: decoder.readCompactArray((decoder) => ({
25
+ groupId: decoder.readCompactString(),
26
+ topics: decoder.readCompactArray((decoder) => ({
27
+ name: decoder.readCompactString(),
28
+ partitions: decoder.readCompactArray((decoder) => ({
29
+ partitionIndex: decoder.readInt32(),
30
+ committedOffset: decoder.readInt64(),
31
+ committedLeaderEpoch: decoder.readInt32(),
32
+ committedMetadata: decoder.readCompactString(),
33
+ errorCode: decoder.readInt16(),
34
+ _tag: decoder.readTagBuffer(),
35
+ })),
36
+ _tag: decoder.readTagBuffer(),
37
+ })),
38
+ errorCode: decoder.readInt16(),
39
+ _tag: decoder.readTagBuffer(),
40
+ })),
41
+ _tag2: decoder.readTagBuffer(),
42
+ };
43
+ result.groups.forEach((group) => {
44
+ if (group.errorCode)
45
+ throw new error_1.KafkaTSApiError(group.errorCode, null, result);
46
+ group.topics.forEach((topic) => {
47
+ topic.partitions.forEach((partition) => {
48
+ if (partition.errorCode)
49
+ throw new error_1.KafkaTSApiError(partition.errorCode, null, result);
50
+ });
51
+ });
52
+ });
53
+ return result;
54
+ },
55
+ });
@@ -0,0 +1,54 @@
1
+ /// <reference types="node" />
2
+ export declare const PRODUCE: import("../utils/api.js").Api<{
3
+ transactionalId: string | null;
4
+ acks: number;
5
+ timeoutMs: number;
6
+ topicData: {
7
+ name: string;
8
+ partitionData: {
9
+ index: number;
10
+ baseOffset: bigint;
11
+ partitionLeaderEpoch: number;
12
+ attributes: number;
13
+ lastOffsetDelta: number;
14
+ baseTimestamp: bigint;
15
+ maxTimestamp: bigint;
16
+ producerId: bigint;
17
+ producerEpoch: number;
18
+ baseSequence: number;
19
+ records: {
20
+ attributes: number;
21
+ timestampDelta: bigint;
22
+ offsetDelta: number;
23
+ key: Buffer | null;
24
+ value: Buffer | null;
25
+ headers: {
26
+ key: Buffer;
27
+ value: Buffer;
28
+ }[];
29
+ }[];
30
+ }[];
31
+ }[];
32
+ }, {
33
+ _tag: void;
34
+ responses: {
35
+ name: string | null;
36
+ partitionResponses: {
37
+ index: number;
38
+ errorCode: number;
39
+ baseOffset: bigint;
40
+ logAppendTime: bigint;
41
+ logStartOffset: bigint;
42
+ recordErrors: {
43
+ batchIndex: number;
44
+ batchIndexError: number;
45
+ _tag: void;
46
+ }[];
47
+ errorMessage: string | null;
48
+ _tag: void;
49
+ }[];
50
+ _tag: void;
51
+ }[];
52
+ throttleTimeMs: number;
53
+ _tag2: void;
54
+ }>;