@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,81 @@
1
+ import { ResponseError } from "../../errors.js";
2
+ import { Writer } from "../../protocol/writer.js";
3
+ import { createAPI } from "../definitions.js";
4
+ /*
5
+ OffsetFetch Request (Version: 9) => [groups] require_stable TAG_BUFFER
6
+ groups => group_id member_id member_epoch [topics] TAG_BUFFER
7
+ group_id => COMPACT_STRING
8
+ member_id => COMPACT_NULLABLE_STRING
9
+ member_epoch => INT32
10
+ topics => name [partition_indexes] TAG_BUFFER
11
+ name => COMPACT_STRING
12
+ partition_indexes => INT32
13
+ require_stable => BOOLEAN
14
+ */
15
+ export function createRequest(groups, requireStable) {
16
+ return Writer.create()
17
+ .appendArray(groups, (w, g) => {
18
+ w.appendString(g.groupId)
19
+ .appendString(g.memberId)
20
+ .appendInt32(g.memberEpoch)
21
+ .appendArray(g.topics, (w, t) => {
22
+ w.appendString(t.name).appendArray(t.partitionIndexes, (w, i) => w.appendInt32(i), true, false);
23
+ });
24
+ })
25
+ .appendBoolean(requireStable)
26
+ .appendTaggedFields();
27
+ }
28
+ /*
29
+ OffsetFetch Response (Version: 9) => throttle_time_ms [groups] TAG_BUFFER
30
+ throttle_time_ms => INT32
31
+ groups => group_id [topics] error_code TAG_BUFFER
32
+ group_id => COMPACT_STRING
33
+ topics => name [partitions] TAG_BUFFER
34
+ name => COMPACT_STRING
35
+ partitions => partition_index committed_offset committed_leader_epoch metadata error_code TAG_BUFFER
36
+ partition_index => INT32
37
+ committed_offset => INT64
38
+ committed_leader_epoch => INT32
39
+ metadata => COMPACT_NULLABLE_STRING
40
+ error_code => INT16
41
+ error_code => INT16
42
+ */
43
+ export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
44
+ const errors = [];
45
+ const response = {
46
+ throttleTimeMs: reader.readInt32(),
47
+ groups: reader.readArray((r, i) => {
48
+ const group = {
49
+ groupId: r.readString(),
50
+ topics: r.readArray((r, j) => {
51
+ return {
52
+ name: r.readString(),
53
+ partitions: r.readArray((r, k) => {
54
+ const partition = {
55
+ partitionIndex: r.readInt32(),
56
+ committedOffset: r.readInt64(),
57
+ committedLeaderEpoch: r.readInt32(),
58
+ metadata: r.readNullableString(),
59
+ errorCode: r.readInt16()
60
+ };
61
+ if (partition.errorCode !== 0) {
62
+ errors.push([`/groups/${i}/topics/${j}/partitions/${k}`, partition.errorCode]);
63
+ }
64
+ return partition;
65
+ })
66
+ };
67
+ }),
68
+ errorCode: r.readInt16()
69
+ };
70
+ if (group.errorCode !== 0) {
71
+ errors.push([`/groups/${i}`, group.errorCode]);
72
+ }
73
+ return group;
74
+ })
75
+ };
76
+ if (errors.length) {
77
+ throw new ResponseError(apiKey, apiVersion, Object.fromEntries(errors), response);
78
+ }
79
+ return response;
80
+ }
81
+ export const api = createAPI(9, 9, createRequest, parseResponse);
@@ -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 interface SyncGroupRequestAssignment {
5
+ memberId: string;
6
+ assignment: Buffer;
7
+ }
8
+ export type SyncGroupRequest = Parameters<typeof createRequest>;
9
+ export interface SyncGroupResponse {
10
+ throttleTimeMs: number;
11
+ errorCode: number;
12
+ protocolType: NullableString;
13
+ protocolName: NullableString;
14
+ assignment: Buffer;
15
+ }
16
+ export declare function createRequest(groupId: string, generationId: number, memberId: string, groupInstanceId: NullableString, protocolType: NullableString, protocolName: NullableString, assignments: SyncGroupRequestAssignment[]): Writer;
17
+ export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): SyncGroupResponse;
18
+ export declare const api: import("../definitions.ts").API<[groupId: string, generationId: number, memberId: string, groupInstanceId: NullableString, protocolType: NullableString, protocolName: NullableString, assignments: SyncGroupRequestAssignment[]], SyncGroupResponse>;
@@ -0,0 +1,49 @@
1
+ import { ResponseError } from "../../errors.js";
2
+ import { Writer } from "../../protocol/writer.js";
3
+ import { createAPI } from "../definitions.js";
4
+ /*
5
+ SyncGroup Request (Version: 5) => group_id generation_id member_id group_instance_id protocol_type protocol_name [assignments] TAG_BUFFER
6
+ group_id => COMPACT_STRING
7
+ generation_id => INT32
8
+ member_id => COMPACT_STRING
9
+ group_instance_id => COMPACT_NULLABLE_STRING
10
+ protocol_type => COMPACT_NULLABLE_STRING
11
+ protocol_name => COMPACT_NULLABLE_STRING
12
+ assignments => member_id assignment TAG_BUFFER
13
+ member_id => COMPACT_STRING
14
+ assignment => COMPACT_BYTES
15
+
16
+ */
17
+ export function createRequest(groupId, generationId, memberId, groupInstanceId, protocolType, protocolName, assignments) {
18
+ return Writer.create()
19
+ .appendString(groupId)
20
+ .appendInt32(generationId)
21
+ .appendString(memberId)
22
+ .appendString(groupInstanceId)
23
+ .appendString(protocolType)
24
+ .appendString(protocolName)
25
+ .appendArray(assignments, (w, a) => w.appendString(a.memberId).appendBytes(a.assignment))
26
+ .appendTaggedFields();
27
+ }
28
+ /*
29
+ SyncGroup Response (Version: 5) => throttle_time_ms error_code protocol_type protocol_name assignment TAG_BUFFER
30
+ throttle_time_ms => INT32
31
+ error_code => INT16
32
+ protocol_type => COMPACT_NULLABLE_STRING
33
+ protocol_name => COMPACT_NULLABLE_STRING
34
+ assignment => COMPACT_BYTES
35
+ */
36
+ export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
37
+ const response = {
38
+ throttleTimeMs: reader.readInt32(),
39
+ errorCode: reader.readInt16(),
40
+ protocolType: reader.readNullableString(),
41
+ protocolName: reader.readNullableString(),
42
+ assignment: reader.readBytes()
43
+ };
44
+ if (response.errorCode !== 0) {
45
+ throw new ResponseError(apiKey, apiVersion, { '': response.errorCode }, response);
46
+ }
47
+ return response;
48
+ }
49
+ export const api = createAPI(14, 5, createRequest, parseResponse);
@@ -0,0 +1,16 @@
1
+ import { type Connection } from '../network/connection.ts';
2
+ import { type Reader } from '../protocol/reader.ts';
3
+ import { type Writer } from '../protocol/writer.ts';
4
+ export type Callback<ReturnType> = (error: Error | null, payload: ReturnType) => void;
5
+ export type CallbackArguments<ReturnType> = [cb: Callback<ReturnType>];
6
+ export type RequestCreator = (...args: any[]) => Writer;
7
+ export type ResponseParser<ReturnType> = (correlationId: number, apiKey: number, apiVersion: number, reader: Reader) => ReturnType | Promise<ReturnType>;
8
+ export type ResponseErrorWithLocation = [string, number];
9
+ export type APIWithCallback<RequestArguments extends Array<unknown>, ResponseType> = (connection: Connection, ...args: [...RequestArguments, ...Partial<CallbackArguments<ResponseType>>]) => void;
10
+ export type APIWithPromise<RequestArguments extends Array<unknown>, ResponseType> = (connection: Connection, ...args: RequestArguments) => Promise<ResponseType>;
11
+ export type API<RequestType extends Array<unknown>, ResponseType> = APIWithCallback<RequestType, ResponseType> & {
12
+ async: APIWithPromise<RequestType, ResponseType>;
13
+ key: number;
14
+ version: number;
15
+ };
16
+ export declare function createAPI<RequestArguments extends Array<unknown>, ResponseType>(apiKey: number, apiVersion: number, createRequest: RequestCreator, parseResponse: ResponseParser<ResponseType>, hasRequestHeaderTaggedFields?: boolean, hasResponseHeaderTaggedFields?: boolean): API<RequestArguments, ResponseType>;
@@ -0,0 +1,12 @@
1
+ import { promisify } from 'node:util';
2
+ export function createAPI(apiKey, apiVersion, createRequest, parseResponse, hasRequestHeaderTaggedFields = true, hasResponseHeaderTaggedFields = true) {
3
+ const api = function api(connection, ...args) {
4
+ /* c8 ignore next */
5
+ const cb = typeof args[args.length - 1] === 'function' ? args.pop() : () => { };
6
+ connection.send(apiKey, apiVersion, () => createRequest(...args), parseResponse, hasRequestHeaderTaggedFields, hasResponseHeaderTaggedFields, cb);
7
+ };
8
+ api.async = promisify(api);
9
+ api.key = apiKey;
10
+ api.version = apiVersion;
11
+ return api;
12
+ }
@@ -0,0 +1,114 @@
1
+ export declare const FindCoordinatorKeyTypes: {
2
+ readonly GROUP: 0;
3
+ readonly TRANSACTION: 1;
4
+ readonly SHARE: 2;
5
+ };
6
+ export type FindCoordinatorKeyType = keyof typeof FindCoordinatorKeyTypes;
7
+ export declare const ProduceAcks: {
8
+ readonly ALL: -1;
9
+ readonly NO_RESPONSE: 0;
10
+ readonly LEADER: 1;
11
+ };
12
+ export type ProduceAck = keyof typeof ProduceAcks;
13
+ export declare const FetchIsolationLevels: {
14
+ READ_UNCOMMITTED: number;
15
+ READ_COMMITTED: number;
16
+ };
17
+ export type FetchIsolationLevel = keyof typeof FetchIsolationLevels;
18
+ export declare const ListOffsetTimestamps: {
19
+ LATEST: bigint;
20
+ EARLIEST: bigint;
21
+ };
22
+ export type ListOffsetTimestamp = keyof typeof ListOffsetTimestamps;
23
+ export declare const ResourceTypes: {
24
+ readonly UNKNOWN: 0;
25
+ readonly ANY: 1;
26
+ readonly TOPIC: 2;
27
+ readonly GROUP: 3;
28
+ readonly CLUSTER: 4;
29
+ readonly TRANSACTIONAL_ID: 5;
30
+ readonly DELEGATION_TOKEN: 6;
31
+ };
32
+ export type ResourceType = keyof typeof ResourceTypes;
33
+ export declare const ResourcePatternTypes: {
34
+ readonly UNKNOWN: 0;
35
+ readonly ANY: 1;
36
+ readonly MATCH: 2;
37
+ readonly LITERAL: 3;
38
+ readonly PREFIXED: 4;
39
+ };
40
+ export type ResourcePatternType = keyof typeof ResourcePatternTypes;
41
+ export declare const AclOperations: {
42
+ readonly UNKNOWN: 0;
43
+ readonly ANY: 1;
44
+ readonly ALL: 2;
45
+ readonly READ: 3;
46
+ readonly WRITE: 4;
47
+ readonly CREATE: 5;
48
+ readonly DELETE: 6;
49
+ readonly ALTER: 7;
50
+ readonly DESCRIBE: 8;
51
+ readonly CLUSTER_ACTION: 9;
52
+ readonly DESCRIBE_CONFIGS: 10;
53
+ readonly ALTER_CONFIGS: 11;
54
+ readonly IDEMPOTENT_WRITE: 12;
55
+ };
56
+ export type AclOperation = keyof typeof AclOperations;
57
+ export declare const AclPermissionTypes: {
58
+ readonly UNKNOWN: 0;
59
+ readonly ANY: 1;
60
+ readonly DENY: 2;
61
+ readonly ALLOW: 3;
62
+ };
63
+ export type AclPermissionType = keyof typeof AclPermissionTypes;
64
+ export declare const ConfigSources: {
65
+ readonly UNKNOWN: 0;
66
+ readonly TOPIC_CONFIG: 1;
67
+ readonly DYNAMIC_BROKER_CONFIG: 2;
68
+ readonly DYNAMIC_DEFAULT_BROKER_CONFIG: 3;
69
+ readonly STATIC_BROKER_CONFIG: 4;
70
+ readonly DEFAULT_CONFIG: 5;
71
+ readonly DYNAMIC_BROKER_LOGGER_CONFIG: 6;
72
+ };
73
+ export type ConfigSource = keyof typeof ConfigSources;
74
+ export declare const ConfigTypes: {
75
+ readonly UNKNOWN: 0;
76
+ readonly TOPIC: 2;
77
+ readonly BROKER: 4;
78
+ readonly BROKER_LOGGER: 8;
79
+ };
80
+ export type ConfigType = keyof typeof ConfigTypes;
81
+ export declare const IncrementalAlterConfigTypes: {
82
+ SET: number;
83
+ DELETE: number;
84
+ APPEND: number;
85
+ SUBTRACT: number;
86
+ };
87
+ export type IncrementalAlterConfigType = keyof typeof IncrementalAlterConfigTypes;
88
+ export declare const ClientQuotaMatchTypes: {
89
+ readonly EXACT: 0;
90
+ readonly DEFAULT: 1;
91
+ readonly ANY: 2;
92
+ };
93
+ export type ClientQuotaMatchType = keyof typeof ClientQuotaMatchTypes;
94
+ export declare const ScramMechanisms: {
95
+ readonly UNKNOWN: 0;
96
+ readonly SCRAM_SHA_256: 1;
97
+ readonly SCRAM_SHA_512: 2;
98
+ };
99
+ export type ScramMechanism = keyof typeof ScramMechanisms;
100
+ export declare const DescribeClusterEndpointTypes: {
101
+ BROKERS: number;
102
+ CONTROLLERS: number;
103
+ };
104
+ export type DescribeClusterEndpointType = keyof typeof DescribeClusterEndpointTypes;
105
+ export declare const ConsumerGroupStates: readonly ["PREPARING_REBALANCE", "COMPLETING_REBALANCE", "STABLE", "DEAD", "EMPTY"];
106
+ export type ConsumerGroupState = (typeof ConsumerGroupStates)[number];
107
+ export declare const TransactionStates: readonly ["EMPTY", "ONGOING", "PREPARE_ABORT", "COMMITTING", "ABORTING", "COMPLETE_COMMIT", "COMPLETE_ABORT"];
108
+ export type TransactionState = (typeof TransactionStates)[number];
109
+ export declare const FeatureUpgradeTypes: {
110
+ readonly UPGRADE: 1;
111
+ readonly SAFE_DOWNGRADE: 2;
112
+ readonly UNSAFE_DOWNGRADE: 3;
113
+ };
114
+ export type FeatureUpgradeType = keyof typeof FeatureUpgradeTypes;
@@ -0,0 +1,78 @@
1
+ // Metadata API
2
+ // ./metadata/find-coordinator.ts
3
+ export const FindCoordinatorKeyTypes = { GROUP: 0, TRANSACTION: 1, SHARE: 2 };
4
+ // Producer API
5
+ export const ProduceAcks = {
6
+ ALL: -1,
7
+ NO_RESPONSE: 0,
8
+ LEADER: 1
9
+ };
10
+ // Consumer API
11
+ // ./consumer/fetch.ts
12
+ export const FetchIsolationLevels = { READ_UNCOMMITTED: 0, READ_COMMITTED: 1 };
13
+ export const ListOffsetTimestamps = { LATEST: -1n, EARLIEST: -2n };
14
+ // Admin API
15
+ // ./admin/*-acls.ts - See: https://cwiki.apache.org/confluence/display/KAFKA/KIP-140%3A+Add+administrative+RPCs+for+adding%2C+deleting%2C+and+listing+ACLs
16
+ export const ResourceTypes = {
17
+ UNKNOWN: 0,
18
+ ANY: 1,
19
+ TOPIC: 2,
20
+ GROUP: 3,
21
+ CLUSTER: 4,
22
+ TRANSACTIONAL_ID: 5,
23
+ DELEGATION_TOKEN: 6
24
+ };
25
+ export const ResourcePatternTypes = { UNKNOWN: 0, ANY: 1, MATCH: 2, LITERAL: 3, PREFIXED: 4 };
26
+ export const AclOperations = {
27
+ UNKNOWN: 0,
28
+ ANY: 1,
29
+ ALL: 2,
30
+ READ: 3,
31
+ WRITE: 4,
32
+ CREATE: 5,
33
+ DELETE: 6,
34
+ ALTER: 7,
35
+ DESCRIBE: 8,
36
+ CLUSTER_ACTION: 9,
37
+ DESCRIBE_CONFIGS: 10,
38
+ ALTER_CONFIGS: 11,
39
+ IDEMPOTENT_WRITE: 12
40
+ };
41
+ export const AclPermissionTypes = { UNKNOWN: 0, ANY: 1, DENY: 2, ALLOW: 3 };
42
+ // ./admin/*-configs.ts
43
+ export const ConfigSources = {
44
+ UNKNOWN: 0,
45
+ TOPIC_CONFIG: 1,
46
+ DYNAMIC_BROKER_CONFIG: 2,
47
+ DYNAMIC_DEFAULT_BROKER_CONFIG: 3,
48
+ STATIC_BROKER_CONFIG: 4,
49
+ DEFAULT_CONFIG: 5,
50
+ DYNAMIC_BROKER_LOGGER_CONFIG: 6
51
+ };
52
+ export const ConfigTypes = {
53
+ UNKNOWN: 0,
54
+ TOPIC: 2,
55
+ BROKER: 4,
56
+ BROKER_LOGGER: 8
57
+ };
58
+ export const IncrementalAlterConfigTypes = { SET: 0, DELETE: 1, APPEND: 2, SUBTRACT: 3 };
59
+ // ./admin/*-client-quotas.ts
60
+ export const ClientQuotaMatchTypes = { EXACT: 0, DEFAULT: 1, ANY: 2 };
61
+ // ./admin/*-scram-credentials.ts
62
+ export const ScramMechanisms = { UNKNOWN: 0, SCRAM_SHA_256: 1, SCRAM_SHA_512: 2 };
63
+ // ./admin/describe-cluster.ts
64
+ export const DescribeClusterEndpointTypes = { BROKERS: 1, CONTROLLERS: 2 };
65
+ // ./admin/list-groups.ts
66
+ export const ConsumerGroupStates = ['PREPARING_REBALANCE', 'COMPLETING_REBALANCE', 'STABLE', 'DEAD', 'EMPTY'];
67
+ // ./admin/list-transactions.ts
68
+ export const TransactionStates = [
69
+ 'EMPTY',
70
+ 'ONGOING',
71
+ 'PREPARE_ABORT',
72
+ 'COMMITTING',
73
+ 'ABORTING',
74
+ 'COMPLETE_COMMIT',
75
+ 'COMPLETE_ABORT'
76
+ ];
77
+ // ./admin/update-features.ts
78
+ export const FeatureUpgradeTypes = { UPGRADE: 1, SAFE_DOWNGRADE: 2, UNSAFE_DOWNGRADE: 3 };
@@ -0,0 +1,8 @@
1
+ export * from './definitions.ts';
2
+ export * from './enumerations.ts';
3
+ export * from './admin/index.ts';
4
+ export * from './consumer/index.ts';
5
+ export * from './metadata/index.ts';
6
+ export * from './producer/index.ts';
7
+ export * from './security/index.ts';
8
+ export * from './telemetry/index.ts';
@@ -0,0 +1,10 @@
1
+ // Generics
2
+ export * from "./definitions.js";
3
+ export * from "./enumerations.js";
4
+ // Low-level APIs
5
+ export * from "./admin/index.js";
6
+ export * from "./consumer/index.js";
7
+ export * from "./metadata/index.js";
8
+ export * from "./producer/index.js";
9
+ export * from "./security/index.js";
10
+ export * from "./telemetry/index.js";
@@ -0,0 +1,17 @@
1
+ import { type Reader } from '../../protocol/reader.ts';
2
+ import { Writer } from '../../protocol/writer.ts';
3
+ export type ApiVersionsRequest = Parameters<typeof createRequest>;
4
+ export interface ApiVersionsResponseApi {
5
+ apiKey: number;
6
+ name: string;
7
+ minVersion: number;
8
+ maxVersion: number;
9
+ }
10
+ export type ApiVersionsResponse = {
11
+ errorCode: number;
12
+ apiKeys: ApiVersionsResponseApi[];
13
+ throttleTimeMs: number;
14
+ };
15
+ export declare function createRequest(clientSoftwareName: string, clientSoftwareVersion: string): Writer;
16
+ export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): ApiVersionsResponse;
17
+ export declare const api: import("../definitions.ts").API<[clientSoftwareName: string, clientSoftwareVersion: string], ApiVersionsResponse>;
@@ -0,0 +1,41 @@
1
+ import { ResponseError } from "../../errors.js";
2
+ import { protocolAPIsById } from "../../protocol/apis.js";
3
+ import { Writer } from "../../protocol/writer.js";
4
+ import { createAPI } from "../definitions.js";
5
+ /*
6
+ ApiVersions Request (Version: 4) => client_software_name client_software_version TAG_BUFFER
7
+ client_software_name => COMPACT_STRING
8
+ client_software_version => COMPACT_STRING
9
+ */
10
+ export function createRequest(clientSoftwareName, clientSoftwareVersion) {
11
+ return Writer.create().appendString(clientSoftwareName).appendString(clientSoftwareVersion).appendTaggedFields();
12
+ }
13
+ /*
14
+ ApiVersions Response (Version: 4) => error_code [api_keys] throttle_time_ms TAG_BUFFER
15
+ error_code => INT16
16
+ api_keys => api_key min_version max_version TAG_BUFFER
17
+ api_key => INT16
18
+ min_version => INT16
19
+ max_version => INT16
20
+ throttle_time_ms => INT32
21
+ */
22
+ export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
23
+ const response = {
24
+ errorCode: reader.readInt16(),
25
+ apiKeys: reader.readArray(r => {
26
+ const apiKey = r.readInt16();
27
+ return {
28
+ apiKey,
29
+ name: protocolAPIsById[apiKey],
30
+ minVersion: r.readInt16(),
31
+ maxVersion: r.readInt16()
32
+ };
33
+ }),
34
+ throttleTimeMs: reader.readInt32()
35
+ };
36
+ if (response.errorCode !== 0) {
37
+ throw new ResponseError(apiKey, apiVersion, { '': response.errorCode }, response);
38
+ }
39
+ return response;
40
+ }
41
+ export const api = createAPI(18, 4, createRequest, parseResponse, true, false);
@@ -0,0 +1,19 @@
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 FindCoordinatorRequest = Parameters<typeof createRequest>;
5
+ export interface FindCoordinatorResponseCoordinator {
6
+ key: string;
7
+ nodeId: number;
8
+ host: string;
9
+ port: number;
10
+ errorCode: number;
11
+ errorMessage: NullableString;
12
+ }
13
+ export interface FindCoordinatorResponse {
14
+ throttleTimeMs: number;
15
+ coordinators: FindCoordinatorResponseCoordinator[];
16
+ }
17
+ export declare function createRequest(keyType: number, coordinatorKeys: string[]): Writer;
18
+ export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): FindCoordinatorResponse;
19
+ export declare const api: import("../definitions.ts").API<[keyType: number, coordinatorKeys: string[]], FindCoordinatorResponse>;
@@ -0,0 +1,50 @@
1
+ import { ResponseError } from "../../errors.js";
2
+ import { Writer } from "../../protocol/writer.js";
3
+ import { createAPI } from "../definitions.js";
4
+ /*
5
+ FindCoordinator Request (Version: 6) => key_type [coordinator_keys] TAG_BUFFER
6
+ key_type => INT8
7
+ coordinator_keys => COMPACT_STRING
8
+ */
9
+ export function createRequest(keyType, coordinatorKeys) {
10
+ return Writer.create()
11
+ .appendInt8(keyType)
12
+ .appendArray(coordinatorKeys, (w, k) => w.appendString(k), true, false)
13
+ .appendTaggedFields();
14
+ }
15
+ /*
16
+ FindCoordinator Response (Version: 6) => throttle_time_ms [coordinators] TAG_BUFFER
17
+ throttle_time_ms => INT32
18
+ coordinators => key node_id host port error_code error_message TAG_BUFFER
19
+ key => COMPACT_STRING
20
+ node_id => INT32
21
+ host => COMPACT_STRING
22
+ port => INT32
23
+ error_code => INT16
24
+ error_message => COMPACT_NULLABLE_STRING
25
+ */
26
+ export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
27
+ const errors = [];
28
+ const response = {
29
+ throttleTimeMs: reader.readInt32(),
30
+ coordinators: reader.readArray((r, i) => {
31
+ const coordinator = {
32
+ key: r.readString(),
33
+ nodeId: r.readInt32(),
34
+ host: r.readString(),
35
+ port: r.readInt32(),
36
+ errorCode: r.readInt16(),
37
+ errorMessage: r.readNullableString()
38
+ };
39
+ if (coordinator.errorCode !== 0) {
40
+ errors.push([`/coordinators/${i}`, coordinator.errorCode]);
41
+ }
42
+ return coordinator;
43
+ })
44
+ };
45
+ if (errors.length) {
46
+ throw new ResponseError(apiKey, apiVersion, Object.fromEntries(errors), response);
47
+ }
48
+ return response;
49
+ }
50
+ export const api = createAPI(10, 6, createRequest, parseResponse);
@@ -0,0 +1,3 @@
1
+ export * as apiVersionsV4 from './api-versions.ts';
2
+ export * as findCoordinatorV6 from './find-coordinator.ts';
3
+ export * as metadataV12 from './metadata.ts';
@@ -0,0 +1,3 @@
1
+ export * as apiVersionsV4 from "./api-versions.js";
2
+ export * as findCoordinatorV6 from "./find-coordinator.js";
3
+ export * as metadataV12 from "./metadata.js";
@@ -0,0 +1,37 @@
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 MetadataRequest = Parameters<typeof createRequest>;
5
+ export interface MetadataResponsePartition {
6
+ errorCode: number;
7
+ partitionIndex: number;
8
+ leaderId: number;
9
+ leaderEpoch: number;
10
+ replicaNodes: number[];
11
+ isrNodes: number[];
12
+ offlineReplicas: number[];
13
+ }
14
+ export interface MetadataResponseTopic {
15
+ errorCode: number;
16
+ name: NullableString;
17
+ topicId: string;
18
+ isInternal: boolean;
19
+ partitions: MetadataResponsePartition[];
20
+ topicAuthorizedOperations: number;
21
+ }
22
+ export interface MetadataResponseBroker {
23
+ nodeId: number;
24
+ host: string;
25
+ port: number;
26
+ rack: NullableString;
27
+ }
28
+ export interface MetadataResponse {
29
+ throttleTimeMs: number;
30
+ brokers: MetadataResponseBroker[];
31
+ clusterId: NullableString;
32
+ controllerId: number;
33
+ topics: MetadataResponseTopic[];
34
+ }
35
+ export declare function createRequest(topics: string[] | null, allowAutoTopicCreation?: boolean, includeTopicAuthorizedOperations?: boolean): Writer;
36
+ export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): MetadataResponse;
37
+ export declare const api: import("../definitions.ts").API<[topics: string[] | null, allowAutoTopicCreation?: boolean | undefined, includeTopicAuthorizedOperations?: boolean | undefined], MetadataResponse>;
@@ -0,0 +1,92 @@
1
+ import { ResponseError } from "../../errors.js";
2
+ import { Writer } from "../../protocol/writer.js";
3
+ import { createAPI } from "../definitions.js";
4
+ /*
5
+ Metadata Request (Version: 12) => [topics] allow_auto_topic_creation include_topic_authorized_operations TAG_BUFFER
6
+ topics => topic_id name TAG_BUFFER
7
+ topic_id => UUID
8
+ name => COMPACT_NULLABLE_STRING
9
+ allow_auto_topic_creation => BOOLEAN
10
+ include_topic_authorized_operations => BOOLEAN
11
+ */
12
+ export function createRequest(topics, allowAutoTopicCreation = false, includeTopicAuthorizedOperations = false) {
13
+ return Writer.create()
14
+ .appendArray(topics, (w, topic) => w.appendUUID(null).appendString(topic))
15
+ .appendBoolean(allowAutoTopicCreation)
16
+ .appendBoolean(includeTopicAuthorizedOperations)
17
+ .appendTaggedFields();
18
+ }
19
+ /*
20
+ Metadata Response (Version: 12) => throttle_time_ms [brokers] cluster_id controller_id [topics] TAG_BUFFER
21
+ throttle_time_ms => INT32
22
+ brokers => node_id host port rack TAG_BUFFER
23
+ node_id => INT32
24
+ host => COMPACT_STRING
25
+ port => INT32
26
+ rack => COMPACT_NULLABLE_STRING
27
+ cluster_id => COMPACT_NULLABLE_STRING
28
+ controller_id => INT32
29
+ topics => error_code name topic_id is_internal [partitions] topic_authorized_operations TAG_BUFFER
30
+ error_code => INT16
31
+ name => COMPACT_NULLABLE_STRING
32
+ topic_id => UUID
33
+ is_internal => BOOLEAN
34
+ partitions => error_code partition_index leader_id leader_epoch [replica_nodes] [isr_nodes] [offline_replicas] TAG_BUFFER
35
+ error_code => INT16
36
+ partition_index => INT32
37
+ leader_id => INT32
38
+ leader_epoch => INT32
39
+ replica_nodes => INT32
40
+ isr_nodes => INT32
41
+ offline_replicas => INT32
42
+ topic_authorized_operations => INT32
43
+ */
44
+ export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
45
+ const errors = [];
46
+ const response = {
47
+ throttleTimeMs: reader.readInt32(),
48
+ brokers: reader.readArray(r => {
49
+ return {
50
+ nodeId: r.readInt32(),
51
+ host: r.readString(),
52
+ port: r.readInt32(),
53
+ rack: r.readNullableString()
54
+ };
55
+ }),
56
+ clusterId: reader.readNullableString(),
57
+ controllerId: reader.readInt32(),
58
+ topics: reader.readArray((r, i) => {
59
+ const errorCode = r.readInt16();
60
+ if (errorCode !== 0) {
61
+ errors.push([`/topics/${i}`, errorCode]);
62
+ }
63
+ return {
64
+ errorCode,
65
+ name: r.readNullableString(),
66
+ topicId: r.readUUID(),
67
+ isInternal: r.readBoolean(),
68
+ partitions: r.readArray((r, j) => {
69
+ const errorCode = r.readInt16();
70
+ if (errorCode !== 0) {
71
+ errors.push([`/topics/${i}/partitions/${j}`, errorCode]);
72
+ }
73
+ return {
74
+ errorCode,
75
+ partitionIndex: r.readInt32(),
76
+ leaderId: r.readInt32(),
77
+ leaderEpoch: r.readInt32(),
78
+ replicaNodes: r.readArray(() => r.readInt32(), true, false),
79
+ isrNodes: r.readArray(() => r.readInt32(), true, false),
80
+ offlineReplicas: r.readArray(() => r.readInt32(), true, false)
81
+ };
82
+ }),
83
+ topicAuthorizedOperations: reader.readInt32()
84
+ };
85
+ })
86
+ };
87
+ if (errors.length) {
88
+ throw new ResponseError(apiKey, apiVersion, Object.fromEntries(errors), response);
89
+ }
90
+ return response;
91
+ }
92
+ export const api = createAPI(3, 12, createRequest, parseResponse);