@platformatic/kafka 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +270 -0
  3. package/dist/apis/admin/alter-client-quotas.d.ts +33 -0
  4. package/dist/apis/admin/alter-client-quotas.js +64 -0
  5. package/dist/apis/admin/alter-configs.d.ts +26 -0
  6. package/dist/apis/admin/alter-configs.js +57 -0
  7. package/dist/apis/admin/alter-partition-reassignments.d.ts +30 -0
  8. package/dist/apis/admin/alter-partition-reassignments.js +68 -0
  9. package/dist/apis/admin/alter-partition.d.ts +39 -0
  10. package/dist/apis/admin/alter-partition.js +87 -0
  11. package/dist/apis/admin/alter-replica-log-dirs.d.ts +26 -0
  12. package/dist/apis/admin/alter-replica-log-dirs.js +55 -0
  13. package/dist/apis/admin/alter-user-scram-credentials.d.ts +27 -0
  14. package/dist/apis/admin/alter-user-scram-credentials.js +60 -0
  15. package/dist/apis/admin/consumer-group-describe.d.ts +41 -0
  16. package/dist/apis/admin/consumer-group-describe.js +103 -0
  17. package/dist/apis/admin/create-acls.d.ts +24 -0
  18. package/dist/apis/admin/create-acls.js +55 -0
  19. package/dist/apis/admin/create-delegation-token.d.ts +24 -0
  20. package/dist/apis/admin/create-delegation-token.js +54 -0
  21. package/dist/apis/admin/create-partitions.d.ts +24 -0
  22. package/dist/apis/admin/create-partitions.js +54 -0
  23. package/dist/apis/admin/create-topics.d.ts +42 -0
  24. package/dist/apis/admin/create-topics.js +86 -0
  25. package/dist/apis/admin/delete-acls.d.ts +36 -0
  26. package/dist/apis/admin/delete-acls.js +82 -0
  27. package/dist/apis/admin/delete-groups.d.ts +14 -0
  28. package/dist/apis/admin/delete-groups.js +40 -0
  29. package/dist/apis/admin/delete-records.d.ts +27 -0
  30. package/dist/apis/admin/delete-records.js +59 -0
  31. package/dist/apis/admin/delete-topics.d.ts +21 -0
  32. package/dist/apis/admin/delete-topics.js +50 -0
  33. package/dist/apis/admin/describe-acls.d.ts +25 -0
  34. package/dist/apis/admin/describe-acls.js +66 -0
  35. package/dist/apis/admin/describe-client-quotas.d.ts +30 -0
  36. package/dist/apis/admin/describe-client-quotas.js +57 -0
  37. package/dist/apis/admin/describe-cluster.d.ts +23 -0
  38. package/dist/apis/admin/describe-cluster.js +50 -0
  39. package/dist/apis/admin/describe-configs.d.ts +38 -0
  40. package/dist/apis/admin/describe-configs.js +85 -0
  41. package/dist/apis/admin/describe-delegation-token.d.ts +31 -0
  42. package/dist/apis/admin/describe-delegation-token.js +62 -0
  43. package/dist/apis/admin/describe-groups.d.ts +28 -0
  44. package/dist/apis/admin/describe-groups.js +67 -0
  45. package/dist/apis/admin/describe-log-dirs.d.ts +32 -0
  46. package/dist/apis/admin/describe-log-dirs.js +75 -0
  47. package/dist/apis/admin/describe-producers.d.ts +33 -0
  48. package/dist/apis/admin/describe-producers.js +70 -0
  49. package/dist/apis/admin/describe-quorum.d.ts +50 -0
  50. package/dist/apis/admin/describe-quorum.js +116 -0
  51. package/dist/apis/admin/describe-topic-partitions.d.ts +42 -0
  52. package/dist/apis/admin/describe-topic-partitions.js +94 -0
  53. package/dist/apis/admin/describe-transactions.d.ts +24 -0
  54. package/dist/apis/admin/describe-transactions.js +59 -0
  55. package/dist/apis/admin/describe-user-scram-credentials.d.ts +26 -0
  56. package/dist/apis/admin/describe-user-scram-credentials.js +62 -0
  57. package/dist/apis/admin/envelope.d.ts +10 -0
  58. package/dist/apis/admin/envelope.js +32 -0
  59. package/dist/apis/admin/expire-delegation-token.d.ts +11 -0
  60. package/dist/apis/admin/expire-delegation-token.js +29 -0
  61. package/dist/apis/admin/incremental-alter-configs.d.ts +27 -0
  62. package/dist/apis/admin/incremental-alter-configs.js +58 -0
  63. package/dist/apis/admin/index.d.ts +37 -0
  64. package/dist/apis/admin/index.js +37 -0
  65. package/dist/apis/admin/list-groups.d.ts +18 -0
  66. package/dist/apis/admin/list-groups.js +43 -0
  67. package/dist/apis/admin/list-partition-reassignments.d.ts +27 -0
  68. package/dist/apis/admin/list-partition-reassignments.js +56 -0
  69. package/dist/apis/admin/list-transactions.d.ts +18 -0
  70. package/dist/apis/admin/list-transactions.js +45 -0
  71. package/dist/apis/admin/offset-delete.d.ts +26 -0
  72. package/dist/apis/admin/offset-delete.js +59 -0
  73. package/dist/apis/admin/renew-delegation-token.d.ts +11 -0
  74. package/dist/apis/admin/renew-delegation-token.js +29 -0
  75. package/dist/apis/admin/unregister-broker.d.ts +12 -0
  76. package/dist/apis/admin/unregister-broker.js +28 -0
  77. package/dist/apis/admin/update-features.d.ts +23 -0
  78. package/dist/apis/admin/update-features.js +60 -0
  79. package/dist/apis/consumer/consumer-group-heartbeat.d.ts +27 -0
  80. package/dist/apis/consumer/consumer-group-heartbeat.js +70 -0
  81. package/dist/apis/consumer/fetch.d.ts +46 -0
  82. package/dist/apis/consumer/fetch.js +121 -0
  83. package/dist/apis/consumer/heartbeat.d.ts +11 -0
  84. package/dist/apis/consumer/heartbeat.js +34 -0
  85. package/dist/apis/consumer/index.d.ts +9 -0
  86. package/dist/apis/consumer/index.js +9 -0
  87. package/dist/apis/consumer/join-group.d.ts +27 -0
  88. package/dist/apis/consumer/join-group.js +71 -0
  89. package/dist/apis/consumer/leave-group.d.ts +22 -0
  90. package/dist/apis/consumer/leave-group.js +57 -0
  91. package/dist/apis/consumer/list-offsets.d.ts +30 -0
  92. package/dist/apis/consumer/list-offsets.js +68 -0
  93. package/dist/apis/consumer/offset-commit.d.ts +29 -0
  94. package/dist/apis/consumer/offset-commit.js +68 -0
  95. package/dist/apis/consumer/offset-fetch.d.ts +37 -0
  96. package/dist/apis/consumer/offset-fetch.js +81 -0
  97. package/dist/apis/consumer/sync-group.d.ts +18 -0
  98. package/dist/apis/consumer/sync-group.js +49 -0
  99. package/dist/apis/definitions.d.ts +16 -0
  100. package/dist/apis/definitions.js +12 -0
  101. package/dist/apis/enumerations.d.ts +114 -0
  102. package/dist/apis/enumerations.js +78 -0
  103. package/dist/apis/index.d.ts +8 -0
  104. package/dist/apis/index.js +10 -0
  105. package/dist/apis/metadata/api-versions.d.ts +17 -0
  106. package/dist/apis/metadata/api-versions.js +41 -0
  107. package/dist/apis/metadata/find-coordinator.d.ts +19 -0
  108. package/dist/apis/metadata/find-coordinator.js +50 -0
  109. package/dist/apis/metadata/index.d.ts +3 -0
  110. package/dist/apis/metadata/index.js +3 -0
  111. package/dist/apis/metadata/metadata.d.ts +37 -0
  112. package/dist/apis/metadata/metadata.js +92 -0
  113. package/dist/apis/producer/add-offsets-to-txn.d.ts +10 -0
  114. package/dist/apis/producer/add-offsets-to-txn.js +34 -0
  115. package/dist/apis/producer/add-partitions-to-txn.d.ts +34 -0
  116. package/dist/apis/producer/add-partitions-to-txn.js +79 -0
  117. package/dist/apis/producer/end-txn.d.ts +10 -0
  118. package/dist/apis/producer/end-txn.js +34 -0
  119. package/dist/apis/producer/index.d.ts +6 -0
  120. package/dist/apis/producer/index.js +6 -0
  121. package/dist/apis/producer/init-producer-id.d.ts +21 -0
  122. package/dist/apis/producer/init-producer-id.js +38 -0
  123. package/dist/apis/producer/produce.d.ts +29 -0
  124. package/dist/apis/producer/produce.js +104 -0
  125. package/dist/apis/producer/txn-offset-commit.d.ts +29 -0
  126. package/dist/apis/producer/txn-offset-commit.js +77 -0
  127. package/dist/apis/security/index.d.ts +2 -0
  128. package/dist/apis/security/index.js +2 -0
  129. package/dist/apis/security/sasl-authenticate.d.ts +15 -0
  130. package/dist/apis/security/sasl-authenticate.js +30 -0
  131. package/dist/apis/security/sasl-handshake.d.ts +10 -0
  132. package/dist/apis/security/sasl-handshake.js +28 -0
  133. package/dist/apis/telemetry/get-telemetry-subscriptions.d.ts +18 -0
  134. package/dist/apis/telemetry/get-telemetry-subscriptions.js +46 -0
  135. package/dist/apis/telemetry/index.d.ts +3 -0
  136. package/dist/apis/telemetry/index.js +3 -0
  137. package/dist/apis/telemetry/list-client-metrics-resources.d.ts +14 -0
  138. package/dist/apis/telemetry/list-client-metrics-resources.js +32 -0
  139. package/dist/apis/telemetry/push-telemetry.d.ts +10 -0
  140. package/dist/apis/telemetry/push-telemetry.js +36 -0
  141. package/dist/clients/admin/admin.d.ts +18 -0
  142. package/dist/clients/admin/admin.js +322 -0
  143. package/dist/clients/admin/index.d.ts +3 -0
  144. package/dist/clients/admin/index.js +3 -0
  145. package/dist/clients/admin/options.d.ts +135 -0
  146. package/dist/clients/admin/options.js +81 -0
  147. package/dist/clients/admin/types.d.ts +56 -0
  148. package/dist/clients/admin/types.js +1 -0
  149. package/dist/clients/base/base.d.ts +48 -0
  150. package/dist/clients/base/base.js +242 -0
  151. package/dist/clients/base/index.d.ts +3 -0
  152. package/dist/clients/base/index.js +3 -0
  153. package/dist/clients/base/options.d.ts +115 -0
  154. package/dist/clients/base/options.js +59 -0
  155. package/dist/clients/base/types.d.ts +38 -0
  156. package/dist/clients/base/types.js +1 -0
  157. package/dist/clients/callbacks.d.ts +8 -0
  158. package/dist/clients/callbacks.js +42 -0
  159. package/dist/clients/consumer/consumer.d.ts +33 -0
  160. package/dist/clients/consumer/consumer.js +767 -0
  161. package/dist/clients/consumer/index.d.ts +5 -0
  162. package/dist/clients/consumer/index.js +5 -0
  163. package/dist/clients/consumer/messages-stream.d.ts +56 -0
  164. package/dist/clients/consumer/messages-stream.js +404 -0
  165. package/dist/clients/consumer/options.d.ts +521 -0
  166. package/dist/clients/consumer/options.js +177 -0
  167. package/dist/clients/consumer/topics-map.d.ts +8 -0
  168. package/dist/clients/consumer/topics-map.js +48 -0
  169. package/dist/clients/consumer/types.d.ts +74 -0
  170. package/dist/clients/consumer/types.js +11 -0
  171. package/dist/clients/index.d.ts +6 -0
  172. package/dist/clients/index.js +6 -0
  173. package/dist/clients/producer/index.d.ts +3 -0
  174. package/dist/clients/producer/index.js +3 -0
  175. package/dist/clients/producer/options.d.ts +122 -0
  176. package/dist/clients/producer/options.js +47 -0
  177. package/dist/clients/producer/producer.d.ts +13 -0
  178. package/dist/clients/producer/producer.js +272 -0
  179. package/dist/clients/producer/types.d.ts +29 -0
  180. package/dist/clients/producer/types.js +1 -0
  181. package/dist/clients/serde.d.ts +40 -0
  182. package/dist/clients/serde.js +49 -0
  183. package/dist/errors.d.ts +67 -0
  184. package/dist/errors.js +160 -0
  185. package/dist/index.d.ts +6 -0
  186. package/dist/index.js +10 -0
  187. package/dist/network/connection-pool.d.ts +11 -0
  188. package/dist/network/connection-pool.js +101 -0
  189. package/dist/network/connection.d.ts +49 -0
  190. package/dist/network/connection.js +319 -0
  191. package/dist/network/index.d.ts +2 -0
  192. package/dist/network/index.js +2 -0
  193. package/dist/protocol/apis.d.ts +2 -0
  194. package/dist/protocol/apis.js +191 -0
  195. package/dist/protocol/compression.d.ts +70 -0
  196. package/dist/protocol/compression.js +114 -0
  197. package/dist/protocol/crc32c.d.ts +2 -0
  198. package/dist/protocol/crc32c.js +83 -0
  199. package/dist/protocol/definitions.d.ts +12 -0
  200. package/dist/protocol/definitions.js +11 -0
  201. package/dist/protocol/dynamic-buffer.d.ts +65 -0
  202. package/dist/protocol/dynamic-buffer.js +557 -0
  203. package/dist/protocol/errors.d.ts +8 -0
  204. package/dist/protocol/errors.js +908 -0
  205. package/dist/protocol/index.d.ts +14 -0
  206. package/dist/protocol/index.js +14 -0
  207. package/dist/protocol/murmur2.d.ts +1 -0
  208. package/dist/protocol/murmur2.js +55 -0
  209. package/dist/protocol/reader.d.ts +58 -0
  210. package/dist/protocol/reader.js +296 -0
  211. package/dist/protocol/records.d.ts +110 -0
  212. package/dist/protocol/records.js +149 -0
  213. package/dist/protocol/sasl/plain.d.ts +3 -0
  214. package/dist/protocol/sasl/plain.js +3 -0
  215. package/dist/protocol/sasl/scram-sha.d.ts +28 -0
  216. package/dist/protocol/sasl/scram-sha.js +104 -0
  217. package/dist/protocol/varint.d.ts +12 -0
  218. package/dist/protocol/varint.js +36 -0
  219. package/dist/protocol/writer.d.ts +48 -0
  220. package/dist/protocol/writer.js +223 -0
  221. package/dist/utils.d.ts +20 -0
  222. package/dist/utils.js +127 -0
  223. package/package.json +75 -0
@@ -0,0 +1,10 @@
1
+ import { type Reader } from '../../protocol/reader.ts';
2
+ import { Writer } from '../../protocol/writer.ts';
3
+ export type AddOffsetsToTxnRequest = Parameters<typeof createRequest>;
4
+ export interface AddOffsetsToTxnResponse {
5
+ throttleTimeMs: number;
6
+ errorCode: number;
7
+ }
8
+ export declare function createRequest(transactionalId: string, producerId: bigint, producerEpoch: number, groupId: string): Writer;
9
+ export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): AddOffsetsToTxnResponse;
10
+ export declare const api: import("../definitions.ts").API<[transactionalId: string, producerId: bigint, producerEpoch: number, groupId: string], AddOffsetsToTxnResponse>;
@@ -0,0 +1,34 @@
1
+ import { ResponseError } from "../../errors.js";
2
+ import { Writer } from "../../protocol/writer.js";
3
+ import { createAPI } from "../definitions.js";
4
+ /*
5
+ AddOffsetsToTxn Request (Version: 4) => transactional_id producer_id producer_epoch group_id TAG_BUFFER
6
+ transactional_id => COMPACT_STRING
7
+ producer_id => INT64
8
+ producer_epoch => INT16
9
+ group_id => COMPACT_STRING
10
+ */
11
+ export function createRequest(transactionalId, producerId, producerEpoch, groupId) {
12
+ return Writer.create()
13
+ .appendString(transactionalId, true)
14
+ .appendInt64(producerId)
15
+ .appendInt16(producerEpoch)
16
+ .appendString(groupId, true)
17
+ .appendTaggedFields();
18
+ }
19
+ /*
20
+ AddOffsetsToTxn Response (Version: 4) => throttle_time_ms error_code TAG_BUFFER
21
+ throttle_time_ms => INT32
22
+ error_code => INT16
23
+ */
24
+ export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
25
+ const response = {
26
+ throttleTimeMs: reader.readInt32(),
27
+ errorCode: reader.readInt16()
28
+ };
29
+ if (response.errorCode !== 0) {
30
+ throw new ResponseError(apiKey, apiVersion, { '': response.errorCode }, response);
31
+ }
32
+ return response;
33
+ }
34
+ export const api = createAPI(25, 4, createRequest, parseResponse);
@@ -0,0 +1,34 @@
1
+ import { type Reader } from '../../protocol/reader.ts';
2
+ import { Writer } from '../../protocol/writer.ts';
3
+ export interface AddPartitionsToTxnRequestTopic {
4
+ name: string;
5
+ partitions: number[];
6
+ }
7
+ export interface AddPartitionsToTxnRequestTransaction {
8
+ transactionalId: string;
9
+ producerId: bigint;
10
+ producerEpoch: number;
11
+ verifyOnly: boolean;
12
+ topics: AddPartitionsToTxnRequestTopic[];
13
+ }
14
+ export type AddPartitionsToTxnRequest = Parameters<typeof createRequest>;
15
+ export interface AddPartitionsToTxnResponsePartition {
16
+ partitionIndex: number;
17
+ partitionErrorCode: number;
18
+ }
19
+ export interface AddPartitionsToTxnResponseTopic {
20
+ name: string;
21
+ resultsByPartition: AddPartitionsToTxnResponsePartition[];
22
+ }
23
+ export interface AddPartitionsToTxnResponseTransaction {
24
+ transactionalId: string;
25
+ topicResults: AddPartitionsToTxnResponseTopic[];
26
+ }
27
+ export interface AddPartitionsToTxnResponse {
28
+ throttleTimeMs: number;
29
+ errorCode: number;
30
+ resultsByTransaction: AddPartitionsToTxnResponseTransaction[];
31
+ }
32
+ export declare function createRequest(transactions: AddPartitionsToTxnRequestTransaction[]): Writer;
33
+ export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): AddPartitionsToTxnResponse;
34
+ export declare const api: import("../definitions.ts").API<[transactions: AddPartitionsToTxnRequestTransaction[]], AddPartitionsToTxnResponse>;
@@ -0,0 +1,79 @@
1
+ import { ResponseError } from "../../errors.js";
2
+ import { Writer } from "../../protocol/writer.js";
3
+ import { createAPI } from "../definitions.js";
4
+ /*
5
+ AddPartitionsToTxn Request (Version: 5) => [transactions] TAG_BUFFER
6
+ transactions => transactional_id producer_id producer_epoch verify_only [topics] TAG_BUFFER
7
+ transactional_id => COMPACT_STRING
8
+ producer_id => INT64
9
+ producer_epoch => INT16
10
+ verify_only => BOOLEAN
11
+ topics => name [partitions] TAG_BUFFER
12
+ name => COMPACT_STRING
13
+ partitions => INT32
14
+ */
15
+ export function createRequest(transactions) {
16
+ return Writer.create()
17
+ .appendArray(transactions, (w, transaction) => {
18
+ w.appendString(transaction.transactionalId)
19
+ .appendInt64(transaction.producerId)
20
+ .appendInt16(transaction.producerEpoch)
21
+ .appendBoolean(transaction.verifyOnly)
22
+ .appendArray(transaction.topics, (w, topic) => {
23
+ w.appendString(topic.name).appendArray(topic.partitions, (w, partition) => w.appendInt32(partition), true, false);
24
+ });
25
+ })
26
+ .appendTaggedFields();
27
+ }
28
+ /*
29
+ AddPartitionsToTxn Response (Version: 5) => throttle_time_ms error_code [results_by_transaction] TAG_BUFFER
30
+ throttle_time_ms => INT32
31
+ error_code => INT16
32
+ results_by_transaction => transactional_id [topic_results] TAG_BUFFER
33
+ transactional_id => COMPACT_STRING
34
+ topic_results => name [results_by_partition] TAG_BUFFER
35
+ name => COMPACT_STRING
36
+ results_by_partition => partition_index partition_error_code TAG_BUFFER
37
+ partition_index => INT32
38
+ partition_error_code => INT16
39
+ */
40
+ export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
41
+ const errors = [];
42
+ const throttleTimeMs = reader.readInt32();
43
+ const errorCode = reader.readInt16();
44
+ if (errorCode !== 0) {
45
+ errors.push(['', errorCode]);
46
+ }
47
+ const response = {
48
+ throttleTimeMs,
49
+ errorCode,
50
+ resultsByTransaction: reader.readArray((r, i) => {
51
+ return {
52
+ transactionalId: r.readString(),
53
+ topicResults: r.readArray((r, j) => {
54
+ return {
55
+ name: r.readString(),
56
+ resultsByPartition: r.readArray((r, k) => {
57
+ const partition = {
58
+ partitionIndex: r.readInt32(),
59
+ partitionErrorCode: r.readInt16()
60
+ };
61
+ if (partition.partitionErrorCode !== 0) {
62
+ errors.push([
63
+ `/results_by_transaction/${i}/topic_results/${j}/results_by_partitions/${k}`,
64
+ partition.partitionErrorCode
65
+ ]);
66
+ }
67
+ return partition;
68
+ })
69
+ };
70
+ })
71
+ };
72
+ })
73
+ };
74
+ if (errors.length) {
75
+ throw new ResponseError(apiKey, apiVersion, Object.fromEntries(errors), response);
76
+ }
77
+ return response;
78
+ }
79
+ export const api = createAPI(24, 5, createRequest, parseResponse);
@@ -0,0 +1,10 @@
1
+ import { type Reader } from '../../protocol/reader.ts';
2
+ import { Writer } from '../../protocol/writer.ts';
3
+ export type EndTxnRequest = Parameters<typeof createRequest>;
4
+ export interface EndTxnResponse {
5
+ throttleTimeMs: number;
6
+ errorCode: number;
7
+ }
8
+ export declare function createRequest(transactionalId: string, producerId: bigint, producerEpoch: number, committed: boolean): Writer;
9
+ export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): EndTxnResponse;
10
+ export declare const api: import("../definitions.ts").API<[transactionalId: string, producerId: bigint, producerEpoch: number, committed: boolean], EndTxnResponse>;
@@ -0,0 +1,34 @@
1
+ import { ResponseError } from "../../errors.js";
2
+ import { Writer } from "../../protocol/writer.js";
3
+ import { createAPI } from "../definitions.js";
4
+ /*
5
+ EndTxn Request (Version: 4) => transactional_id producer_id producer_epoch committed TAG_BUFFER
6
+ transactional_id => COMPACT_STRING
7
+ producer_id => INT64
8
+ producer_epoch => INT16
9
+ committed => BOOLEAN
10
+ */
11
+ export function createRequest(transactionalId, producerId, producerEpoch, committed) {
12
+ return Writer.create()
13
+ .appendString(transactionalId, true)
14
+ .appendInt64(producerId)
15
+ .appendInt16(producerEpoch)
16
+ .appendBoolean(committed)
17
+ .appendTaggedFields();
18
+ }
19
+ /*
20
+ EndTxn Response (Version: 4) => throttle_time_ms error_code TAG_BUFFER
21
+ throttle_time_ms => INT32
22
+ error_code => INT16
23
+ */
24
+ export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
25
+ const response = {
26
+ throttleTimeMs: reader.readInt32(),
27
+ errorCode: reader.readInt16()
28
+ };
29
+ if (response.errorCode !== 0) {
30
+ throw new ResponseError(apiKey, apiVersion, { '': response.errorCode }, response);
31
+ }
32
+ return response;
33
+ }
34
+ export const api = createAPI(26, 4, createRequest, parseResponse);
@@ -0,0 +1,6 @@
1
+ export * as addOffsetsToTxnV4 from './add-offsets-to-txn.ts';
2
+ export * as addPartitionsToTxnV5 from './add-partitions-to-txn.ts';
3
+ export * as endTxnV4 from './end-txn.ts';
4
+ export * as initProducerIdV5 from './init-producer-id.ts';
5
+ export * as produceV11 from './produce.ts';
6
+ export * as txnOffsetCommitV4 from './txn-offset-commit.ts';
@@ -0,0 +1,6 @@
1
+ export * as addOffsetsToTxnV4 from "./add-offsets-to-txn.js";
2
+ export * as addPartitionsToTxnV5 from "./add-partitions-to-txn.js";
3
+ export * as endTxnV4 from "./end-txn.js";
4
+ export * as initProducerIdV5 from "./init-producer-id.js";
5
+ export * as produceV11 from "./produce.js";
6
+ export * as txnOffsetCommitV4 from "./txn-offset-commit.js";
@@ -0,0 +1,21 @@
1
+ import { type NullableString } from '../../protocol/definitions.ts';
2
+ import { type Reader } from '../../protocol/reader.ts';
3
+ import { Writer } from '../../protocol/writer.ts';
4
+ export type InitProducerIdRequest = Parameters<typeof createRequest>;
5
+ export interface InitProducerIdResponseCoordinator {
6
+ key: string;
7
+ nodeId: number;
8
+ host: string;
9
+ port: number;
10
+ errorCode: number;
11
+ errorMessage: NullableString;
12
+ }
13
+ export interface InitProducerIdResponse {
14
+ throttleTimeMs: number;
15
+ errorCode: number;
16
+ producerId: bigint;
17
+ producerEpoch: number;
18
+ }
19
+ export declare function createRequest(transactionalId: NullableString, transactionTimeoutMs: number, producerId: bigint, producerEpoch: number): Writer;
20
+ export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): InitProducerIdResponse;
21
+ export declare const api: import("../definitions.ts").API<[transactionalId: NullableString, transactionTimeoutMs: number, producerId: bigint, producerEpoch: number], InitProducerIdResponse>;
@@ -0,0 +1,38 @@
1
+ import { ResponseError } from "../../errors.js";
2
+ import { Writer } from "../../protocol/writer.js";
3
+ import { createAPI } from "../definitions.js";
4
+ /*
5
+ InitProducerId Request (Version: 5) => transactional_id transaction_timeout_ms producer_id producer_epoch TAG_BUFFER
6
+ transactional_id => COMPACT_NULLABLE_STRING
7
+ transaction_timeout_ms => INT32
8
+ producer_id => INT64
9
+ producer_epoch => INT16
10
+ */
11
+ export function createRequest(transactionalId, transactionTimeoutMs, producerId, producerEpoch) {
12
+ return Writer.create()
13
+ .appendString(transactionalId, true)
14
+ .appendInt32(transactionTimeoutMs)
15
+ .appendInt64(producerId)
16
+ .appendInt16(producerEpoch)
17
+ .appendTaggedFields();
18
+ }
19
+ /*
20
+ InitProducerId Response (Version: 5) => throttle_time_ms error_code producer_id producer_epoch TAG_BUFFER
21
+ throttle_time_ms => INT32
22
+ error_code => INT16
23
+ producer_id => INT64
24
+ producer_epoch => INT16
25
+ */
26
+ export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
27
+ const response = {
28
+ throttleTimeMs: reader.readInt32(),
29
+ errorCode: reader.readInt16(),
30
+ producerId: reader.readInt64(),
31
+ producerEpoch: reader.readInt16()
32
+ };
33
+ if (response.errorCode !== 0) {
34
+ throw new ResponseError(apiKey, apiVersion, { '': response.errorCode }, response);
35
+ }
36
+ return response;
37
+ }
38
+ export const api = createAPI(22, 5, createRequest, parseResponse);
@@ -0,0 +1,29 @@
1
+ import { type NullableString } from '../../protocol/definitions.ts';
2
+ import { type Reader } from '../../protocol/reader.ts';
3
+ import { type CreateRecordsBatchOptions, type MessageRecord } from '../../protocol/records.ts';
4
+ import { Writer } from '../../protocol/writer.ts';
5
+ export type ProduceRequest = Parameters<typeof createRequest>;
6
+ export interface ProduceResponsePartitionRecordError {
7
+ batchIndex: number;
8
+ batchIndexErrorMessage: NullableString;
9
+ }
10
+ export interface ProduceResponsePartition {
11
+ index: number;
12
+ errorCode: number;
13
+ baseOffset: bigint;
14
+ logAppendTimeMs: bigint;
15
+ logStartOffset: bigint;
16
+ recordErrors: ProduceResponsePartitionRecordError[];
17
+ errorMessage: NullableString;
18
+ }
19
+ export interface ProduceResponseTopic {
20
+ name: string;
21
+ partitionResponses: ProduceResponsePartition[];
22
+ }
23
+ export interface ProduceResponse {
24
+ responses: ProduceResponseTopic[];
25
+ throttleTimeMs: number;
26
+ }
27
+ export declare function createRequest(acks: number | undefined, timeout: number | undefined, topicData: MessageRecord[], options?: Partial<CreateRecordsBatchOptions>): Writer;
28
+ export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): ProduceResponse;
29
+ export declare const api: import("../definitions.ts").API<[acks: number | undefined, timeout: number | undefined, topicData: MessageRecord[], options?: Partial<CreateRecordsBatchOptions> | undefined], boolean | ProduceResponse>;
@@ -0,0 +1,104 @@
1
+ import { ResponseError } from "../../errors.js";
2
+ import { createRecordsBatch } from "../../protocol/records.js";
3
+ import { Writer } from "../../protocol/writer.js";
4
+ import { groupByProperty } from "../../utils.js";
5
+ import { createAPI } from "../definitions.js";
6
+ import { ProduceAcks } from "../enumerations.js";
7
+ /*
8
+ Produce Request (Version: 11) => transactional_id acks timeout_ms [topic_data] TAG_BUFFER
9
+ transactional_id => COMPACT_NULLABLE_STRING
10
+ acks => INT16
11
+ timeout_ms => INT32
12
+ topic_data => name [partition_data] TAG_BUFFER
13
+ name => COMPACT_STRING
14
+ partition_data => index records TAG_BUFFER
15
+ index => INT32
16
+ records => COMPACT_RECORDS
17
+ */
18
+ export function createRequest(acks = 1, timeout = 0, topicData, options = {}) {
19
+ // Normalize the messages
20
+ const now = BigInt(Date.now());
21
+ for (const message of topicData) {
22
+ if (typeof message.partition === 'undefined') {
23
+ message.partition = 0;
24
+ }
25
+ if (typeof message.timestamp === 'undefined') {
26
+ message.timestamp = now;
27
+ }
28
+ }
29
+ const writer = Writer.create()
30
+ .appendString(options.transactionalId)
31
+ .appendInt16(acks)
32
+ .appendInt32(timeout)
33
+ .appendArray(groupByProperty(topicData, 'topic'), (w, [topic, messages]) => {
34
+ w.appendString(topic).appendArray(groupByProperty(messages, 'partition'), (w, [partition, messages]) => {
35
+ const records = createRecordsBatch(messages, options);
36
+ w.appendInt32(partition)
37
+ .appendUnsignedVarInt(records.length + 1)
38
+ .appendFrom(records);
39
+ });
40
+ })
41
+ .appendTaggedFields();
42
+ if (acks === ProduceAcks.NO_RESPONSE) {
43
+ writer.context.noResponse = true;
44
+ }
45
+ return writer;
46
+ }
47
+ /*
48
+ Produce Response (Version: 11) => [responses] throttle_time_ms TAG_BUFFER
49
+ responses => name [partition_responses] TAG_BUFFER
50
+ name => COMPACT_STRING
51
+ partition_responses => index error_code base_offset log_append_time_ms log_start_offset [record_errors] error_message TAG_BUFFER
52
+ index => INT32
53
+ error_code => INT16
54
+ base_offset => INT64
55
+ log_append_time_ms => INT64
56
+ log_start_offset => INT64
57
+ record_errors => batch_index batch_index_error_message TAG_BUFFER
58
+ batch_index => INT32
59
+ batch_index_error_message => COMPACT_NULLABLE_STRING
60
+ error_message => COMPACT_NULLABLE_STRING
61
+ throttle_time_ms => INT32
62
+ */
63
+ export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
64
+ const errors = [];
65
+ const response = {
66
+ responses: reader.readArray((r, i) => {
67
+ const topicResponse = {
68
+ name: r.readString(),
69
+ partitionResponses: r.readArray((r, j) => {
70
+ const index = r.readInt32();
71
+ const errorCode = r.readInt16();
72
+ if (errorCode !== 0) {
73
+ errors.push([`/responses/${i}/partition_responses/${j}`, errorCode]);
74
+ }
75
+ return {
76
+ index,
77
+ errorCode,
78
+ baseOffset: r.readInt64(),
79
+ logAppendTimeMs: r.readInt64(),
80
+ logStartOffset: r.readInt64(),
81
+ recordErrors: r.readArray((r, k) => {
82
+ const recordError = {
83
+ batchIndex: r.readInt32(),
84
+ batchIndexErrorMessage: r.readNullableString()
85
+ };
86
+ if (recordError.batchIndexErrorMessage) {
87
+ errors.push([`/responses/${i}/partition_responses/${j}/record_errors/${k}`, -1]);
88
+ }
89
+ return recordError;
90
+ }),
91
+ errorMessage: r.readNullableString()
92
+ };
93
+ })
94
+ };
95
+ return topicResponse;
96
+ }),
97
+ throttleTimeMs: reader.readInt32()
98
+ };
99
+ if (errors.length) {
100
+ throw new ResponseError(apiKey, apiVersion, Object.fromEntries(errors), response);
101
+ }
102
+ return response;
103
+ }
104
+ export const api = createAPI(0, 11, createRequest, parseResponse);
@@ -0,0 +1,29 @@
1
+ import { type NullableString } from '../../protocol/definitions.ts';
2
+ import { type Reader } from '../../protocol/reader.ts';
3
+ import { Writer } from '../../protocol/writer.ts';
4
+ export interface TxnOffsetCommitRequestPartition {
5
+ partitionIndex: number;
6
+ committedOffset: bigint;
7
+ committedLeaderEpoch: number;
8
+ committedMetadata?: NullableString;
9
+ }
10
+ export interface TxnOffsetCommitRequestTopic {
11
+ name: string;
12
+ partitions: TxnOffsetCommitRequestPartition[];
13
+ }
14
+ export type TxnOffsetCommitRequest = Parameters<typeof createRequest>;
15
+ export interface TxnOffsetCommitResponsePartition {
16
+ partitionIndex: number;
17
+ errorCode: number;
18
+ }
19
+ export interface TxnOffsetCommitResponseTopic {
20
+ name: string;
21
+ partitions: TxnOffsetCommitResponsePartition[];
22
+ }
23
+ export interface TxnOffsetCommitResponse {
24
+ throttleTimeMs: number;
25
+ topics: TxnOffsetCommitResponseTopic[];
26
+ }
27
+ export declare function createRequest(transactionalId: string, groupId: string, producerId: bigint, producerEpoch: number, generationId: number, memberId: string, groupInstanceId: NullableString, topics: TxnOffsetCommitRequestTopic[]): Writer;
28
+ export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): TxnOffsetCommitResponse;
29
+ export declare const api: import("../definitions.ts").API<[transactionalId: string, groupId: string, producerId: bigint, producerEpoch: number, generationId: number, memberId: string, groupInstanceId: NullableString, topics: TxnOffsetCommitRequestTopic[]], TxnOffsetCommitResponse>;
@@ -0,0 +1,77 @@
1
+ import { ResponseError } from "../../errors.js";
2
+ import { Writer } from "../../protocol/writer.js";
3
+ import { createAPI } from "../definitions.js";
4
+ /*
5
+ TxnOffsetCommit Request (Version: 4) => transactional_id group_id producer_id producer_epoch generation_id member_id group_instance_id [topics] TAG_BUFFER
6
+ transactional_id => COMPACT_STRING
7
+ group_id => COMPACT_STRING
8
+ producer_id => INT64
9
+ producer_epoch => INT16
10
+ generation_id => INT32
11
+ member_id => COMPACT_STRING
12
+ group_instance_id => COMPACT_NULLABLE_STRING
13
+ topics => name [partitions] TAG_BUFFER
14
+ name => COMPACT_STRING
15
+ partitions => partition_index committed_offset committed_leader_epoch committed_metadata TAG_BUFFER
16
+ partition_index => INT32
17
+ committed_offset => INT64
18
+ committed_leader_epoch => INT32
19
+ committed_metadata => COMPACT_NULLABLE_STRING
20
+ */
21
+ export function createRequest(transactionalId, groupId, producerId, producerEpoch, generationId, memberId, groupInstanceId, topics) {
22
+ return Writer.create()
23
+ .appendString(transactionalId, true)
24
+ .appendString(groupId, true)
25
+ .appendInt64(producerId)
26
+ .appendInt16(producerEpoch)
27
+ .appendInt32(generationId)
28
+ .appendString(memberId, true)
29
+ .appendString(groupInstanceId, true)
30
+ .appendArray(topics, (w, t) => {
31
+ w.appendString(t.name, true)
32
+ .appendArray(t.partitions, (w, p) => {
33
+ w.appendInt32(p.partitionIndex)
34
+ .appendInt64(p.committedOffset)
35
+ .appendInt32(p.committedLeaderEpoch)
36
+ .appendString(p.committedMetadata, true)
37
+ .appendTaggedFields(); // Add tagged fields for partitions
38
+ }, true, true)
39
+ .appendTaggedFields(); // Add tagged fields for topics
40
+ }, true, true)
41
+ .appendTaggedFields();
42
+ }
43
+ /*
44
+ TxnOffsetCommit Response (Version: 4) => throttle_time_ms [topics] TAG_BUFFER
45
+ throttle_time_ms => INT32
46
+ topics => name [partitions] TAG_BUFFER
47
+ name => COMPACT_STRING
48
+ partitions => partition_index error_code TAG_BUFFER
49
+ partition_index => INT32
50
+ error_code => INT16
51
+ */
52
+ export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
53
+ const errors = [];
54
+ const response = {
55
+ throttleTimeMs: reader.readInt32(),
56
+ topics: reader.readArray((r, i) => {
57
+ return {
58
+ name: r.readString(),
59
+ partitions: r.readArray((r, j) => {
60
+ const partition = {
61
+ partitionIndex: r.readInt32(),
62
+ errorCode: r.readInt16()
63
+ };
64
+ if (partition.errorCode !== 0) {
65
+ errors.push([`/topics/${i}/partitions/${j}`, partition.errorCode]);
66
+ }
67
+ return partition;
68
+ })
69
+ };
70
+ })
71
+ };
72
+ if (errors.length) {
73
+ throw new ResponseError(apiKey, apiVersion, Object.fromEntries(errors), response);
74
+ }
75
+ return response;
76
+ }
77
+ export const api = createAPI(28, 4, createRequest, parseResponse);
@@ -0,0 +1,2 @@
1
+ export * as saslAuthenticateV2 from './sasl-authenticate.ts';
2
+ export * as saslHandshakeV1 from './sasl-handshake.ts';
@@ -0,0 +1,2 @@
1
+ export * as saslAuthenticateV2 from "./sasl-authenticate.js";
2
+ export * as saslHandshakeV1 from "./sasl-handshake.js";
@@ -0,0 +1,15 @@
1
+ import { type NullableString } from '../../protocol/definitions.ts';
2
+ import { type Reader } from '../../protocol/reader.ts';
3
+ import { Writer } from '../../protocol/writer.ts';
4
+ import { type API } from '../definitions.ts';
5
+ export type SaslAuthenticateRequest = Parameters<typeof createRequest>;
6
+ export interface SaslAuthenticateResponse {
7
+ errorCode: number;
8
+ errorMessage: NullableString;
9
+ authBytes: Buffer;
10
+ sessionLifetimeMs: bigint;
11
+ }
12
+ export type SASLAuthenticationAPI = API<[Buffer], SaslAuthenticateResponse>;
13
+ export declare function createRequest(authBytes: Buffer): Writer;
14
+ export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): SaslAuthenticateResponse;
15
+ export declare const api: API<[authBytes: Buffer<ArrayBufferLike>], SaslAuthenticateResponse>;
@@ -0,0 +1,30 @@
1
+ import { ResponseError } from "../../errors.js";
2
+ import { Writer } from "../../protocol/writer.js";
3
+ import { createAPI } from "../definitions.js";
4
+ /*
5
+ SaslAuthenticate Request (Version: 2) => auth_bytes TAG_BUFFER
6
+ auth_bytes => COMPACT_BYTES
7
+ */
8
+ export function createRequest(authBytes) {
9
+ return Writer.create().appendBytes(authBytes).appendTaggedFields();
10
+ }
11
+ /*
12
+ SaslAuthenticate Response (Version: 2) => error_code error_message auth_bytes session_lifetime_ms TAG_BUFFER
13
+ error_code => INT16
14
+ error_message => COMPACT_NULLABLE_STRING
15
+ auth_bytes => COMPACT_BYTES
16
+ session_lifetime_ms => INT64
17
+ */
18
+ export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
19
+ const response = {
20
+ errorCode: reader.readInt16(),
21
+ errorMessage: reader.readNullableString(),
22
+ authBytes: reader.readBytes(),
23
+ sessionLifetimeMs: reader.readInt64()
24
+ };
25
+ if (response.errorCode !== 0) {
26
+ throw new ResponseError(apiKey, apiVersion, { '': response.errorCode }, response);
27
+ }
28
+ return response;
29
+ }
30
+ export const api = createAPI(36, 2, createRequest, parseResponse);
@@ -0,0 +1,10 @@
1
+ import { type Reader } from '../../protocol/reader.ts';
2
+ import { Writer } from '../../protocol/writer.ts';
3
+ export type SaslHandshakeRequest = Parameters<typeof createRequest>;
4
+ export interface SaslHandshakeResponse {
5
+ errorCode?: number;
6
+ mechanisms?: string[];
7
+ }
8
+ export declare function createRequest(mechanism: string): Writer;
9
+ export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): SaslHandshakeResponse;
10
+ export declare const api: import("../definitions.ts").API<[mechanism: string], SaslHandshakeResponse>;
@@ -0,0 +1,28 @@
1
+ import { ResponseError } from "../../errors.js";
2
+ import { Writer } from "../../protocol/writer.js";
3
+ import { createAPI } from "../definitions.js";
4
+ /*
5
+ SaslHandshake Request (Version: 0) => mechanism
6
+ mechanism => STRING
7
+ */
8
+ export function createRequest(mechanism) {
9
+ return Writer.create().appendString(mechanism, false);
10
+ }
11
+ /*
12
+ SaslHandshake Response (Version: 1) => error_code [mechanisms]
13
+ error_code => INT16
14
+ mechanisms => STRING
15
+ */
16
+ export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
17
+ const response = {
18
+ errorCode: reader.readInt16(),
19
+ mechanisms: reader.readArray(r => {
20
+ return r.readString(false);
21
+ }, false, false)
22
+ };
23
+ if (response.errorCode !== 0) {
24
+ throw new ResponseError(apiKey, apiVersion, { '': response.errorCode }, response);
25
+ }
26
+ return response;
27
+ }
28
+ export const api = createAPI(17, 1, createRequest, parseResponse, false, false);
@@ -0,0 +1,18 @@
1
+ import { type NullableString } from '../../protocol/definitions.ts';
2
+ import { type Reader } from '../../protocol/reader.ts';
3
+ import { Writer } from '../../protocol/writer.ts';
4
+ export type GetTelemetrySubscriptionsRequest = Parameters<typeof createRequest>;
5
+ export interface GetTelemetrySubscriptionsResponse {
6
+ throttleTimeMs: number;
7
+ errorCode: number;
8
+ clientInstanceId: string;
9
+ subscriptionId: number;
10
+ acceptedCompressionTypes: number[];
11
+ pushIntervalMs: number;
12
+ telemetryMaxBytes: number;
13
+ deltaTemporality: boolean;
14
+ requestedMetrics: string[];
15
+ }
16
+ export declare function createRequest(clientInstanceId?: NullableString): Writer;
17
+ export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): GetTelemetrySubscriptionsResponse;
18
+ export declare const api: import("../definitions.ts").API<[clientInstanceId?: NullableString], GetTelemetrySubscriptionsResponse>;