@platformatic/kafka 1.27.0-alpha.3 → 1.28.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 (154) hide show
  1. package/README.md +64 -0
  2. package/dist/apis/admin/create-acls-v2.d.ts +16 -0
  3. package/dist/apis/admin/create-acls-v2.js +55 -0
  4. package/dist/apis/admin/delete-acls-v2.d.ts +21 -0
  5. package/dist/apis/admin/delete-acls-v2.js +84 -0
  6. package/dist/apis/admin/describe-acls-v2.d.ts +17 -0
  7. package/dist/apis/admin/describe-acls-v2.js +66 -0
  8. package/dist/apis/admin/describe-cluster-v0.d.ts +23 -0
  9. package/dist/apis/admin/describe-cluster-v0.js +48 -0
  10. package/dist/apis/admin/describe-log-dirs-v2.d.ts +32 -0
  11. package/dist/apis/admin/describe-log-dirs-v2.js +67 -0
  12. package/dist/apis/admin/describe-log-dirs-v3.d.ts +32 -0
  13. package/dist/apis/admin/describe-log-dirs-v3.js +73 -0
  14. package/dist/apis/admin/index.d.ts +7 -0
  15. package/dist/apis/admin/index.js +7 -0
  16. package/dist/apis/admin/list-transactions-v0.d.ts +18 -0
  17. package/dist/apis/admin/list-transactions-v0.js +43 -0
  18. package/dist/apis/consumer/index.d.ts +8 -0
  19. package/dist/apis/consumer/index.js +8 -0
  20. package/dist/apis/consumer/join-group-v6.d.ts +27 -0
  21. package/dist/apis/consumer/join-group-v6.js +67 -0
  22. package/dist/apis/consumer/join-group-v7.d.ts +27 -0
  23. package/dist/apis/consumer/join-group-v7.js +68 -0
  24. package/dist/apis/consumer/join-group-v8.d.ts +27 -0
  25. package/dist/apis/consumer/join-group-v8.js +70 -0
  26. package/dist/apis/consumer/leave-group-v4.d.ts +22 -0
  27. package/dist/apis/consumer/leave-group-v4.js +56 -0
  28. package/dist/apis/consumer/list-offsets-v5.d.ts +30 -0
  29. package/dist/apis/consumer/list-offsets-v5.js +67 -0
  30. package/dist/apis/consumer/list-offsets-v6.d.ts +30 -0
  31. package/dist/apis/consumer/list-offsets-v6.js +68 -0
  32. package/dist/apis/consumer/list-offsets-v7.d.ts +30 -0
  33. package/dist/apis/consumer/list-offsets-v7.js +68 -0
  34. package/dist/apis/consumer/sync-group-v4.d.ts +18 -0
  35. package/dist/apis/consumer/sync-group-v4.js +43 -0
  36. package/dist/apis/enumerations.d.ts +5 -5
  37. package/dist/apis/producer/add-offsets-to-txn-v1.d.ts +10 -0
  38. package/dist/apis/producer/add-offsets-to-txn-v1.js +33 -0
  39. package/dist/apis/producer/add-offsets-to-txn-v2.d.ts +10 -0
  40. package/dist/apis/producer/add-offsets-to-txn-v2.js +33 -0
  41. package/dist/apis/producer/index.d.ts +3 -0
  42. package/dist/apis/producer/index.js +3 -0
  43. package/dist/apis/producer/init-producer-id-v3.d.ts +21 -0
  44. package/dist/apis/producer/init-producer-id-v3.js +38 -0
  45. package/dist/clients/admin/options.d.ts +9 -9
  46. package/dist/clients/consumer/consumer.js +38 -2
  47. package/dist/clients/consumer/messages-stream.d.ts +2 -2
  48. package/dist/clients/consumer/messages-stream.js +105 -21
  49. package/dist/clients/consumer/options.d.ts +24 -0
  50. package/dist/clients/consumer/options.js +3 -1
  51. package/dist/clients/consumer/types.d.ts +4 -1
  52. package/dist/clients/producer/index.d.ts +1 -0
  53. package/dist/clients/producer/index.js +1 -0
  54. package/dist/clients/producer/options.d.ts +65 -18
  55. package/dist/clients/producer/options.js +21 -1
  56. package/dist/clients/producer/producer-stream.d.ts +19 -0
  57. package/dist/clients/producer/producer-stream.js +187 -0
  58. package/dist/clients/producer/producer.d.ts +6 -3
  59. package/dist/clients/producer/producer.js +137 -19
  60. package/dist/clients/producer/types.d.ts +28 -1
  61. package/dist/clients/producer/types.js +6 -1
  62. package/dist/clients/serde.d.ts +11 -6
  63. package/dist/diagnostic.d.ts +2 -2
  64. package/dist/errors.d.ts +5 -5
  65. package/dist/errors.js +8 -6
  66. package/dist/index.d.ts +1 -0
  67. package/dist/index.js +2 -0
  68. package/dist/network/connection.d.ts +7 -6
  69. package/dist/network/connection.js +1 -1
  70. package/dist/protocol/compression.d.ts +1 -1
  71. package/dist/protocol/compression.js +7 -46
  72. package/dist/protocol/crc32c.d.ts +1 -1
  73. package/dist/protocol/crc32c.js +5 -6
  74. package/dist/protocol/definitions.d.ts +1 -1
  75. package/dist/protocol/definitions.js +1 -1
  76. package/dist/protocol/index.d.ts +0 -2
  77. package/dist/protocol/index.js +0 -2
  78. package/dist/protocol/reader.d.ts +2 -2
  79. package/dist/protocol/reader.js +4 -4
  80. package/dist/protocol/records.d.ts +11 -22
  81. package/dist/protocol/records.js +3 -7
  82. package/dist/protocol/sasl/oauth-bearer.d.ts +3 -3
  83. package/dist/protocol/sasl/plain.d.ts +3 -3
  84. package/dist/protocol/sasl/scram-sha.d.ts +3 -3
  85. package/dist/protocol/sasl/utils.d.ts +3 -3
  86. package/dist/protocol/writer.d.ts +1 -1
  87. package/dist/protocol/writer.js +3 -3
  88. package/dist/registries/abstract.d.ts +22 -0
  89. package/dist/registries/abstract.js +38 -0
  90. package/dist/registries/confluent-schema-registry.d.ts +41 -0
  91. package/dist/registries/confluent-schema-registry.js +222 -0
  92. package/dist/registries/index.d.ts +2 -0
  93. package/dist/registries/index.js +2 -0
  94. package/dist/typescript-4/dist/apis/admin/create-acls-v2.d.ts +16 -0
  95. package/dist/typescript-4/dist/apis/admin/delete-acls-v2.d.ts +21 -0
  96. package/dist/typescript-4/dist/apis/admin/describe-acls-v2.d.ts +17 -0
  97. package/dist/typescript-4/dist/apis/admin/describe-cluster-v0.d.ts +23 -0
  98. package/dist/typescript-4/dist/apis/admin/describe-log-dirs-v2.d.ts +32 -0
  99. package/dist/typescript-4/dist/apis/admin/describe-log-dirs-v3.d.ts +32 -0
  100. package/dist/typescript-4/dist/apis/admin/index.d.ts +7 -0
  101. package/dist/typescript-4/dist/apis/admin/list-transactions-v0.d.ts +18 -0
  102. package/dist/typescript-4/dist/apis/consumer/index.d.ts +8 -0
  103. package/dist/typescript-4/dist/apis/consumer/join-group-v6.d.ts +27 -0
  104. package/dist/typescript-4/dist/apis/consumer/join-group-v7.d.ts +27 -0
  105. package/dist/typescript-4/dist/apis/consumer/join-group-v8.d.ts +27 -0
  106. package/dist/typescript-4/dist/apis/consumer/leave-group-v4.d.ts +22 -0
  107. package/dist/typescript-4/dist/apis/consumer/list-offsets-v5.d.ts +30 -0
  108. package/dist/typescript-4/dist/apis/consumer/list-offsets-v6.d.ts +30 -0
  109. package/dist/typescript-4/dist/apis/consumer/list-offsets-v7.d.ts +30 -0
  110. package/dist/typescript-4/dist/apis/consumer/sync-group-v4.d.ts +18 -0
  111. package/dist/typescript-4/dist/apis/enumerations.d.ts +5 -5
  112. package/dist/typescript-4/dist/apis/producer/add-offsets-to-txn-v1.d.ts +10 -0
  113. package/dist/typescript-4/dist/apis/producer/add-offsets-to-txn-v2.d.ts +10 -0
  114. package/dist/typescript-4/dist/apis/producer/index.d.ts +3 -0
  115. package/dist/typescript-4/dist/apis/producer/init-producer-id-v3.d.ts +21 -0
  116. package/dist/typescript-4/dist/clients/admin/options.d.ts +9 -9
  117. package/dist/typescript-4/dist/clients/consumer/messages-stream.d.ts +2 -2
  118. package/dist/typescript-4/dist/clients/consumer/options.d.ts +24 -0
  119. package/dist/typescript-4/dist/clients/consumer/types.d.ts +4 -1
  120. package/dist/typescript-4/dist/clients/producer/index.d.ts +1 -0
  121. package/dist/typescript-4/dist/clients/producer/options.d.ts +66 -19
  122. package/dist/typescript-4/dist/clients/producer/producer-stream.d.ts +19 -0
  123. package/dist/typescript-4/dist/clients/producer/producer.d.ts +6 -3
  124. package/dist/typescript-4/dist/clients/producer/types.d.ts +29 -2
  125. package/dist/typescript-4/dist/clients/serde.d.ts +11 -6
  126. package/dist/typescript-4/dist/diagnostic.d.ts +2 -2
  127. package/dist/typescript-4/dist/errors.d.ts +5 -5
  128. package/dist/typescript-4/dist/index.d.ts +2 -1
  129. package/dist/typescript-4/dist/network/connection.d.ts +7 -6
  130. package/dist/typescript-4/dist/protocol/compression.d.ts +1 -1
  131. package/dist/typescript-4/dist/protocol/crc32c.d.ts +1 -1
  132. package/dist/typescript-4/dist/protocol/definitions.d.ts +1 -1
  133. package/dist/typescript-4/dist/protocol/index.d.ts +0 -2
  134. package/dist/typescript-4/dist/protocol/reader.d.ts +2 -2
  135. package/dist/typescript-4/dist/protocol/records.d.ts +11 -22
  136. package/dist/typescript-4/dist/protocol/sasl/oauth-bearer.d.ts +3 -3
  137. package/dist/typescript-4/dist/protocol/sasl/plain.d.ts +3 -3
  138. package/dist/typescript-4/dist/protocol/sasl/scram-sha.d.ts +3 -3
  139. package/dist/typescript-4/dist/protocol/sasl/utils.d.ts +3 -3
  140. package/dist/typescript-4/dist/protocol/writer.d.ts +1 -1
  141. package/dist/typescript-4/dist/registries/abstract.d.ts +22 -0
  142. package/dist/typescript-4/dist/registries/confluent-schema-registry.d.ts +41 -0
  143. package/dist/typescript-4/dist/registries/index.d.ts +2 -0
  144. package/dist/typescript-4/dist/utils.d.ts +3 -2
  145. package/dist/utils.d.ts +2 -1
  146. package/dist/utils.js +3 -0
  147. package/dist/version.js +1 -1
  148. package/package.json +14 -11
  149. package/dist/protocol/dynamic-buffer.d.ts +0 -65
  150. package/dist/protocol/dynamic-buffer.js +0 -563
  151. package/dist/protocol/varint.d.ts +0 -12
  152. package/dist/protocol/varint.js +0 -36
  153. package/dist/typescript-4/dist/protocol/dynamic-buffer.d.ts +0 -65
  154. package/dist/typescript-4/dist/protocol/varint.d.ts +0 -12
package/README.md CHANGED
@@ -10,6 +10,7 @@ A modern, high-performance, pure TypeScript/JavaScript type safe client for Apac
10
10
  - **Flexible API**: You can use promises or callbacks on all APIs.
11
11
  - **Streaming or Event-based Consumers**: Thanks to Node.js streams, you can choose your preferred consuming method.
12
12
  - **Flexible Serialisation**: Pluggable serialisers and deserialisers.
13
+ - **Schema Registry Support (Experimental)**: Built-in Confluent Schema Registry integration with AVRO, Protobuf, and JSON Schema support. **This area does not follow semver and may change in minor/patch releases.**
13
14
  - **Connection Management**: Automatic connection pooling and recovery.
14
15
  - **Low Dependencies**: Minimal external dependencies.
15
16
 
@@ -50,6 +51,7 @@ await producer.send({
50
51
  })
51
52
 
52
53
  // Close the producer when done
54
+ // If you created producer streams with producer.asStream(), either close them first or use producer.close(true)
53
55
  await producer.close()
54
56
  ```
55
57
 
@@ -141,6 +143,67 @@ await admin.deleteTopics({ topics: ['my-topic'] })
141
143
  await admin.close()
142
144
  ```
143
145
 
146
+ ### Schema Registry
147
+
148
+ > ⚠️ **Experimental API**
149
+ > The Confluent Schema Registry integration and the related `registry`, `beforeSerialization`, and `beforeDeserialization` hooks are experimental.
150
+ > They **do not follow semver** and may change in minor/patch releases.
151
+
152
+ The library includes built-in support for Confluent Schema Registry with AVRO, Protocol Buffers, and JSON Schema:
153
+
154
+ ```typescript
155
+ import { Producer, Consumer } from '@platformatic/kafka'
156
+ import { ConfluentSchemaRegistry } from '@platformatic/kafka/registries'
157
+
158
+ // Create a schema registry instance
159
+ const registry = new ConfluentSchemaRegistry({
160
+ url: 'http://localhost:8081',
161
+ auth: {
162
+ username: 'user',
163
+ password: 'password'
164
+ }
165
+ })
166
+
167
+ // Producer with schema registry
168
+ const producer = new Producer({
169
+ clientId: 'schema-producer',
170
+ bootstrapBrokers: ['localhost:9092'],
171
+ registry // Automatic serialization with schemas
172
+ })
173
+
174
+ // Send messages with schema IDs
175
+ await producer.send({
176
+ messages: [{
177
+ topic: 'users',
178
+ value: { id: 1, name: 'Alice' },
179
+ metadata: {
180
+ schemas: {
181
+ value: 100 // Schema ID in the registry
182
+ }
183
+ }
184
+ }]
185
+ })
186
+
187
+ // Consumer with schema registry
188
+ const consumer = new Consumer({
189
+ groupId: 'schema-consumers',
190
+ clientId: 'schema-consumer',
191
+ bootstrapBrokers: ['localhost:9092'],
192
+ registry // Automatic deserialization with schemas
193
+ })
194
+
195
+ const stream = await consumer.consume({
196
+ topics: ['users']
197
+ })
198
+
199
+ // Messages are automatically deserialized
200
+ for await (const message of stream) {
201
+ console.log('User:', message.value) // Typed object
202
+ }
203
+ ```
204
+
205
+ For more details, see the [Confluent Schema Registry documentation](./docs/confluent-schema-registry.md).
206
+
144
207
  ## TLS and SASL
145
208
 
146
209
  See the relevant sections in the the [Base Client](./docs/base.md) page.
@@ -278,6 +341,7 @@ Many of the methods accept the same options as the client's constructors. The co
278
341
  - [Metrics](./docs/metrics.md)
279
342
  - [Diagnostic and Instrumentation](./docs/diagnostic.md)
280
343
  - [Other APIs and Types](./docs/other.md)
344
+ - [Migrating from KafkaJS](./migration/README.md)
281
345
 
282
346
  ## Requirements
283
347
 
@@ -0,0 +1,16 @@
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 Acl } from '../types.ts';
5
+ export type CreateAclsRequest = Parameters<typeof createRequest>;
6
+ export interface CreateAclsResponseResult {
7
+ errorCode: number;
8
+ errorMessage: NullableString;
9
+ }
10
+ export interface CreateAclsResponse {
11
+ throttleTimeMs: number;
12
+ results: CreateAclsResponseResult[];
13
+ }
14
+ export declare function createRequest(creations: Acl[]): Writer;
15
+ export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): CreateAclsResponse;
16
+ export declare const api: import("../definitions.ts").API<[creations: Acl[]], CreateAclsResponse>;
@@ -0,0 +1,55 @@
1
+ import { ResponseError } from "../../errors.js";
2
+ import { Writer } from "../../protocol/writer.js";
3
+ import { createAPI } from "../definitions.js";
4
+ /*
5
+ CreateAcls Request (Version: 2) => [creations] TAG_BUFFER
6
+ creations => resource_type resource_name resource_pattern_type principal host operation permission_type TAG_BUFFER
7
+ resource_type => INT8
8
+ resource_name => COMPACT_STRING
9
+ resource_pattern_type => INT8
10
+ principal => COMPACT_STRING
11
+ host => COMPACT_STRING
12
+ operation => INT8
13
+ permission_type => INT8
14
+ */
15
+ export function createRequest(creations) {
16
+ return Writer.create()
17
+ .appendArray(creations, (w, c) => {
18
+ w.appendInt8(c.resourceType)
19
+ .appendString(c.resourceName)
20
+ .appendInt8(c.resourcePatternType)
21
+ .appendString(c.principal)
22
+ .appendString(c.host)
23
+ .appendInt8(c.operation)
24
+ .appendInt8(c.permissionType);
25
+ })
26
+ .appendTaggedFields();
27
+ }
28
+ /*
29
+ CreateAcls Response (Version: 2) => throttle_time_ms [results] TAG_BUFFER
30
+ throttle_time_ms => INT32
31
+ results => error_code error_message TAG_BUFFER
32
+ error_code => INT16
33
+ error_message => COMPACT_NULLABLE_STRING
34
+ */
35
+ export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
36
+ const errors = [];
37
+ const response = {
38
+ throttleTimeMs: reader.readInt32(),
39
+ results: reader.readArray((r, i) => {
40
+ const result = {
41
+ errorCode: r.readInt16(),
42
+ errorMessage: r.readNullableString()
43
+ };
44
+ if (result.errorCode !== 0) {
45
+ errors.push([`/results/${i}`, [result.errorCode, result.errorMessage]]);
46
+ }
47
+ return result;
48
+ })
49
+ };
50
+ if (errors.length) {
51
+ throw new ResponseError(apiKey, apiVersion, Object.fromEntries(errors), response);
52
+ }
53
+ return response;
54
+ }
55
+ export const api = createAPI(30, 2, createRequest, parseResponse);
@@ -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
+ import { type Acl, type AclFilter } from '../types.ts';
5
+ export type DeleteAclsRequest = Parameters<typeof createRequest>;
6
+ export interface DeleteAclsResponseMatchingAcl extends Acl {
7
+ errorCode: number;
8
+ errorMessage: NullableString;
9
+ }
10
+ export interface DeleteAclsResponseFilterResults {
11
+ errorCode: number;
12
+ errorMessage: NullableString;
13
+ matchingAcls: DeleteAclsResponseMatchingAcl[];
14
+ }
15
+ export interface DeleteAclsResponse {
16
+ throttleTimeMs: number;
17
+ filterResults: DeleteAclsResponseFilterResults[];
18
+ }
19
+ export declare function createRequest(filters: AclFilter[]): Writer;
20
+ export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): DeleteAclsResponse;
21
+ export declare const api: import("../definitions.ts").API<[filters: AclFilter[]], DeleteAclsResponse>;
@@ -0,0 +1,84 @@
1
+ import { ResponseError } from "../../errors.js";
2
+ import { Writer } from "../../protocol/writer.js";
3
+ import { createAPI } from "../definitions.js";
4
+ /*
5
+ DeleteAcls Request (Version: 2) => [filters] TAG_BUFFER
6
+ filters => resource_type_filter resource_name_filter pattern_type_filter principal_filter host_filter operation permission_type TAG_BUFFER
7
+ resource_type_filter => INT8
8
+ resource_name_filter => COMPACT_NULLABLE_STRING
9
+ pattern_type_filter => INT8
10
+ principal_filter => COMPACT_NULLABLE_STRING
11
+ host_filter => COMPACT_NULLABLE_STRING
12
+ operation => INT8
13
+ permission_type => INT8
14
+ */
15
+ export function createRequest(filters) {
16
+ return Writer.create()
17
+ .appendArray(filters, (w, f) => {
18
+ w.appendInt8(f.resourceType)
19
+ .appendString(f.resourceName)
20
+ .appendInt8(f.resourcePatternType)
21
+ .appendString(f.principal)
22
+ .appendString(f.host)
23
+ .appendInt8(f.operation)
24
+ .appendInt8(f.permissionType);
25
+ })
26
+ .appendTaggedFields();
27
+ }
28
+ /*
29
+ DeleteAcls Response (Version: 2) => throttle_time_ms [filter_results] TAG_BUFFER
30
+ throttle_time_ms => INT32
31
+ filter_results => error_code error_message [matching_acls] TAG_BUFFER
32
+ error_code => INT16
33
+ error_message => COMPACT_NULLABLE_STRING
34
+ matching_acls => error_code error_message resource_type resource_name pattern_type principal host operation permission_type TAG_BUFFER
35
+ error_code => INT16
36
+ error_message => COMPACT_NULLABLE_STRING
37
+ resource_type => INT8
38
+ resource_name => COMPACT_STRING
39
+ pattern_type => INT8
40
+ principal => COMPACT_STRING
41
+ host => COMPACT_STRING
42
+ operation => INT8
43
+ permission_type => INT8
44
+ */
45
+ export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
46
+ const errors = [];
47
+ const response = {
48
+ throttleTimeMs: reader.readInt32(),
49
+ filterResults: reader.readArray((r, i) => {
50
+ const errorCode = r.readInt16();
51
+ const errorMessage = r.readNullableString();
52
+ if (errorCode !== 0) {
53
+ errors.push([`/filter_results/${i}`, [errorCode, errorMessage]]);
54
+ }
55
+ return {
56
+ errorCode,
57
+ errorMessage,
58
+ matchingAcls: r.readArray((r, j) => {
59
+ const errorCode = r.readInt16();
60
+ const errorMessage = r.readNullableString();
61
+ if (errorCode !== 0) {
62
+ errors.push([`/filter_results/${i}/matching_acls/${j}`, [errorCode, errorMessage]]);
63
+ }
64
+ return {
65
+ errorCode,
66
+ errorMessage,
67
+ resourceType: r.readInt8(),
68
+ resourceName: r.readString(),
69
+ resourcePatternType: r.readInt8(),
70
+ principal: r.readString(),
71
+ host: r.readString(),
72
+ operation: r.readInt8(),
73
+ permissionType: r.readInt8()
74
+ };
75
+ })
76
+ };
77
+ })
78
+ };
79
+ if (errors.length) {
80
+ throw new ResponseError(apiKey, apiVersion, Object.fromEntries(errors), response);
81
+ }
82
+ return response;
83
+ }
84
+ export const api = createAPI(31, 2, createRequest, parseResponse);
@@ -0,0 +1,17 @@
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 AclPermission, type AclTarget, type AclFilter } from '../types.ts';
5
+ export type DescribeAclsRequest = Parameters<typeof createRequest>;
6
+ export interface DescribeAclsResponseResource extends AclTarget {
7
+ acls: AclPermission[];
8
+ }
9
+ export interface DescribeAclsResponse {
10
+ throttleTimeMs: number;
11
+ errorCode: number;
12
+ errorMessage: NullableString;
13
+ resources: DescribeAclsResponseResource[];
14
+ }
15
+ export declare function createRequest(filter: AclFilter): Writer;
16
+ export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): DescribeAclsResponse;
17
+ export declare const api: import("../definitions.ts").API<[filter: AclFilter], DescribeAclsResponse>;
@@ -0,0 +1,66 @@
1
+ import { ResponseError } from "../../errors.js";
2
+ import { Writer } from "../../protocol/writer.js";
3
+ import { createAPI } from "../definitions.js";
4
+ /*
5
+ DescribeAcls Request (Version: 2) => resource_type_filter resource_name_filter pattern_type_filter principal_filter host_filter operation permission_type TAG_BUFFER
6
+ resource_type_filter => INT8
7
+ resource_name_filter => COMPACT_NULLABLE_STRING
8
+ pattern_type_filter => INT8
9
+ principal_filter => COMPACT_NULLABLE_STRING
10
+ host_filter => COMPACT_NULLABLE_STRING
11
+ operation => INT8
12
+ permission_type => INT8
13
+ */
14
+ export function createRequest(filter) {
15
+ return Writer.create()
16
+ .appendInt8(filter.resourceType)
17
+ .appendString(filter.resourceName)
18
+ .appendInt8(filter.resourcePatternType)
19
+ .appendString(filter.principal)
20
+ .appendString(filter.host)
21
+ .appendInt8(filter.operation)
22
+ .appendInt8(filter.permissionType)
23
+ .appendTaggedFields();
24
+ }
25
+ /*
26
+ DescribeAcls Response (Version: 2) => throttle_time_ms error_code error_message [resources] TAG_BUFFER
27
+ throttle_time_ms => INT32
28
+ error_code => INT16
29
+ error_message => COMPACT_NULLABLE_STRING
30
+ resources => resource_type resource_name pattern_type [acls] TAG_BUFFER
31
+ resource_type => INT8
32
+ resource_name => COMPACT_STRING
33
+ pattern_type => INT8
34
+ acls => principal host operation permission_type TAG_BUFFER
35
+ principal => COMPACT_STRING
36
+ host => COMPACT_STRING
37
+ operation => INT8
38
+ permission_type => INT8
39
+ */
40
+ export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
41
+ const response = {
42
+ throttleTimeMs: reader.readInt32(),
43
+ errorCode: reader.readInt16(),
44
+ errorMessage: reader.readNullableString(),
45
+ resources: reader.readArray(r => {
46
+ return {
47
+ resourceType: r.readInt8(),
48
+ resourceName: r.readString(),
49
+ resourcePatternType: r.readInt8(),
50
+ acls: r.readArray(r => {
51
+ return {
52
+ principal: r.readString(),
53
+ host: r.readString(),
54
+ operation: r.readInt8(),
55
+ permissionType: r.readInt8()
56
+ };
57
+ })
58
+ };
59
+ })
60
+ };
61
+ if (response.errorCode) {
62
+ throw new ResponseError(apiKey, apiVersion, { '/': [response.errorCode, response.errorMessage] }, response);
63
+ }
64
+ return response;
65
+ }
66
+ export const api = createAPI(29, 2, createRequest, parseResponse);
@@ -0,0 +1,23 @@
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 DescribeClusterRequest = Parameters<typeof createRequest>;
5
+ export interface DescribeClusterResponseBroker {
6
+ brokerId: number;
7
+ host: string;
8
+ port: number;
9
+ rack: NullableString;
10
+ }
11
+ export interface DescribeClusterResponse {
12
+ throttleTimeMs: number;
13
+ errorCode: number;
14
+ errorMessage: NullableString;
15
+ endpointType: number;
16
+ clusterId: string;
17
+ controllerId: number;
18
+ brokers: DescribeClusterResponseBroker[];
19
+ clusterAuthorizedOperations: number;
20
+ }
21
+ export declare function createRequest(includeClusterAuthorizedOperations: boolean): Writer;
22
+ export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): DescribeClusterResponse;
23
+ export declare const api: import("../definitions.ts").API<[includeClusterAuthorizedOperations: boolean], DescribeClusterResponse>;
@@ -0,0 +1,48 @@
1
+ import { ResponseError } from "../../errors.js";
2
+ import { Writer } from "../../protocol/writer.js";
3
+ import { createAPI } from "../definitions.js";
4
+ /*
5
+ DescribeCluster Request (Version: 0) => include_cluster_authorized_operations TAG_BUFFER
6
+ include_cluster_authorized_operations => BOOLEAN
7
+ */
8
+ export function createRequest(includeClusterAuthorizedOperations) {
9
+ return Writer.create().appendBoolean(includeClusterAuthorizedOperations).appendTaggedFields();
10
+ }
11
+ /*
12
+ DescribeCluster Response (Version: 0) => throttle_time_ms error_code error_message cluster_id controller_id [brokers] cluster_authorized_operations TAG_BUFFER
13
+ throttle_time_ms => INT32
14
+ error_code => INT16
15
+ error_message => COMPACT_NULLABLE_STRING
16
+ cluster_id => COMPACT_STRING
17
+ controller_id => INT32
18
+ brokers => broker_id host port rack TAG_BUFFER
19
+ broker_id => INT32
20
+ host => COMPACT_STRING
21
+ port => INT32
22
+ rack => COMPACT_NULLABLE_STRING
23
+ cluster_authorized_operations => INT32
24
+ */
25
+ export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
26
+ const response = {
27
+ throttleTimeMs: reader.readInt32(),
28
+ errorCode: reader.readInt16(),
29
+ errorMessage: reader.readNullableString(),
30
+ endpointType: 0,
31
+ clusterId: reader.readString(),
32
+ controllerId: reader.readInt32(),
33
+ brokers: reader.readArray(r => {
34
+ return {
35
+ brokerId: r.readInt32(),
36
+ host: r.readString(),
37
+ port: r.readInt32(),
38
+ rack: r.readNullableString()
39
+ };
40
+ }),
41
+ clusterAuthorizedOperations: reader.readInt32()
42
+ };
43
+ if (response.errorCode !== 0) {
44
+ throw new ResponseError(apiKey, apiVersion, { '/': [response.errorCode, response.errorMessage] }, response);
45
+ }
46
+ return response;
47
+ }
48
+ export const api = createAPI(60, 0, createRequest, parseResponse);
@@ -0,0 +1,32 @@
1
+ import { type Reader } from '../../protocol/reader.ts';
2
+ import { Writer } from '../../protocol/writer.ts';
3
+ export interface DescribeLogDirsRequestTopic {
4
+ name: string;
5
+ partitions: number[];
6
+ }
7
+ export type DescribeLogDirsRequest = Parameters<typeof createRequest>;
8
+ export interface DescribeLogDirsResponsePartition {
9
+ partitionIndex: number;
10
+ partitionSize: bigint;
11
+ offsetLag: bigint;
12
+ isFutureKey: boolean;
13
+ }
14
+ export interface DescribeLogDirsResponseTopic {
15
+ name: string;
16
+ partitions: DescribeLogDirsResponsePartition[];
17
+ }
18
+ export interface DescribeLogDirsResponseResult {
19
+ errorCode: number;
20
+ logDir: string;
21
+ topics: DescribeLogDirsResponseTopic[];
22
+ totalBytes: bigint;
23
+ usableBytes: bigint;
24
+ }
25
+ export interface DescribeLogDirsResponse {
26
+ throttleTimeMs: number;
27
+ errorCode: number;
28
+ results: DescribeLogDirsResponseResult[];
29
+ }
30
+ export declare function createRequest(topics: DescribeLogDirsRequestTopic[]): Writer;
31
+ export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): DescribeLogDirsResponse;
32
+ export declare const api: import("../definitions.ts").API<[topics: DescribeLogDirsRequestTopic[]], DescribeLogDirsResponse>;
@@ -0,0 +1,67 @@
1
+ import { ResponseError } from "../../errors.js";
2
+ import { Writer } from "../../protocol/writer.js";
3
+ import { createAPI } from "../definitions.js";
4
+ /*
5
+ DescribeLogDirs Request (Version: 2) => [topics] TAG_BUFFER
6
+ topics => topic [partitions] TAG_BUFFER
7
+ topic => COMPACT_STRING
8
+ partitions => INT32
9
+ */
10
+ export function createRequest(topics) {
11
+ return Writer.create()
12
+ .appendArray(topics, (w, t) => {
13
+ w.appendString(t.name).appendArray(t.partitions, (w, p) => w.appendInt32(p), true, false);
14
+ })
15
+ .appendTaggedFields();
16
+ }
17
+ /*
18
+ DescribeLogDirs Response (Version: 2) => throttle_time_ms [results] TAG_BUFFER
19
+ throttle_time_ms => INT32
20
+ results => error_code log_dir [topics] TAG_BUFFER
21
+ error_code => INT16
22
+ log_dir => COMPACT_STRING
23
+ topics => name [partitions] TAG_BUFFER
24
+ name => COMPACT_STRING
25
+ partitions => partition_index partition_size offset_lag is_future_key TAG_BUFFER
26
+ partition_index => INT32
27
+ partition_size => INT64
28
+ offset_lag => INT64
29
+ is_future_key => BOOLEAN
30
+ */
31
+ export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
32
+ const errors = [];
33
+ const response = {
34
+ throttleTimeMs: reader.readInt32(),
35
+ errorCode: 0,
36
+ results: reader.readArray((r, i) => {
37
+ const errorCode = r.readInt16();
38
+ if (errorCode !== 0) {
39
+ errors.push([`/results/${i}`, [errorCode, null]]);
40
+ }
41
+ return {
42
+ errorCode,
43
+ logDir: r.readString(),
44
+ topics: r.readArray(reader => {
45
+ return {
46
+ name: reader.readString(),
47
+ partitions: reader.readArray(reader => {
48
+ return {
49
+ partitionIndex: reader.readInt32(),
50
+ partitionSize: reader.readInt64(),
51
+ offsetLag: reader.readInt64(),
52
+ isFutureKey: reader.readBoolean()
53
+ };
54
+ })
55
+ };
56
+ }),
57
+ totalBytes: 0n,
58
+ usableBytes: 0n
59
+ };
60
+ })
61
+ };
62
+ if (errors.length) {
63
+ throw new ResponseError(apiKey, apiVersion, Object.fromEntries(errors), response);
64
+ }
65
+ return response;
66
+ }
67
+ export const api = createAPI(35, 2, createRequest, parseResponse);
@@ -0,0 +1,32 @@
1
+ import { type Reader } from '../../protocol/reader.ts';
2
+ import { Writer } from '../../protocol/writer.ts';
3
+ export interface DescribeLogDirsRequestTopic {
4
+ name: string;
5
+ partitions: number[];
6
+ }
7
+ export type DescribeLogDirsRequest = Parameters<typeof createRequest>;
8
+ export interface DescribeLogDirsResponsePartition {
9
+ partitionIndex: number;
10
+ partitionSize: bigint;
11
+ offsetLag: bigint;
12
+ isFutureKey: boolean;
13
+ }
14
+ export interface DescribeLogDirsResponseTopic {
15
+ name: string;
16
+ partitions: DescribeLogDirsResponsePartition[];
17
+ }
18
+ export interface DescribeLogDirsResponseResult {
19
+ errorCode: number;
20
+ logDir: string;
21
+ topics: DescribeLogDirsResponseTopic[];
22
+ totalBytes: bigint;
23
+ usableBytes: bigint;
24
+ }
25
+ export interface DescribeLogDirsResponse {
26
+ throttleTimeMs: number;
27
+ errorCode: number;
28
+ results: DescribeLogDirsResponseResult[];
29
+ }
30
+ export declare function createRequest(topics: DescribeLogDirsRequestTopic[]): Writer;
31
+ export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): DescribeLogDirsResponse;
32
+ export declare const api: import("../definitions.ts").API<[topics: DescribeLogDirsRequestTopic[]], DescribeLogDirsResponse>;
@@ -0,0 +1,73 @@
1
+ import { ResponseError } from "../../errors.js";
2
+ import { Writer } from "../../protocol/writer.js";
3
+ import { createAPI } from "../definitions.js";
4
+ /*
5
+ DescribeLogDirs Request (Version: 3) => [topics] TAG_BUFFER
6
+ topics => topic [partitions] TAG_BUFFER
7
+ topic => COMPACT_STRING
8
+ partitions => INT32
9
+ */
10
+ export function createRequest(topics) {
11
+ return Writer.create()
12
+ .appendArray(topics, (w, t) => {
13
+ w.appendString(t.name).appendArray(t.partitions, (w, p) => w.appendInt32(p), true, false);
14
+ })
15
+ .appendTaggedFields();
16
+ }
17
+ /*
18
+ DescribeLogDirs Response (Version: 3) => throttle_time_ms error_code [results] TAG_BUFFER
19
+ throttle_time_ms => INT32
20
+ error_code => INT16
21
+ results => error_code log_dir [topics] TAG_BUFFER
22
+ error_code => INT16
23
+ log_dir => COMPACT_STRING
24
+ topics => name [partitions] TAG_BUFFER
25
+ name => COMPACT_STRING
26
+ partitions => partition_index partition_size offset_lag is_future_key TAG_BUFFER
27
+ partition_index => INT32
28
+ partition_size => INT64
29
+ offset_lag => INT64
30
+ is_future_key => BOOLEAN
31
+ */
32
+ export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
33
+ const errors = [];
34
+ const throttleTimeMs = reader.readInt32();
35
+ const errorCode = reader.readInt16();
36
+ if (errorCode !== 0) {
37
+ errors.push(['/', [errorCode, null]]);
38
+ }
39
+ const response = {
40
+ throttleTimeMs,
41
+ errorCode,
42
+ results: reader.readArray((r, i) => {
43
+ const errorCode = r.readInt16();
44
+ if (errorCode !== 0) {
45
+ errors.push([`/results/${i}`, [errorCode, null]]);
46
+ }
47
+ return {
48
+ errorCode,
49
+ logDir: r.readString(),
50
+ topics: r.readArray(reader => {
51
+ return {
52
+ name: reader.readString(),
53
+ partitions: reader.readArray(reader => {
54
+ return {
55
+ partitionIndex: reader.readInt32(),
56
+ partitionSize: reader.readInt64(),
57
+ offsetLag: reader.readInt64(),
58
+ isFutureKey: reader.readBoolean()
59
+ };
60
+ })
61
+ };
62
+ }),
63
+ totalBytes: 0n,
64
+ usableBytes: 0n
65
+ };
66
+ })
67
+ };
68
+ if (errors.length) {
69
+ throw new ResponseError(apiKey, apiVersion, Object.fromEntries(errors), response);
70
+ }
71
+ return response;
72
+ }
73
+ export const api = createAPI(35, 3, createRequest, parseResponse);
@@ -5,24 +5,30 @@ export * as alterPartitionV3 from './alter-partition-v3.ts';
5
5
  export * as alterReplicaLogDirsV2 from './alter-replica-log-dirs-v2.ts';
6
6
  export * as alterUserScramCredentialsV0 from './alter-user-scram-credentials-v0.ts';
7
7
  export * as consumerGroupDescribeV0 from './consumer-group-describe-v0.ts';
8
+ export * as createAclsV2 from './create-acls-v2.ts';
8
9
  export * as createAclsV3 from './create-acls-v3.ts';
9
10
  export * as createDelegationTokenV3 from './create-delegation-token-v3.ts';
10
11
  export * as createPartitionsV1 from './create-partitions-v1.ts';
11
12
  export * as createPartitionsV2 from './create-partitions-v2.ts';
12
13
  export * as createPartitionsV3 from './create-partitions-v3.ts';
13
14
  export * as createTopicsV7 from './create-topics-v7.ts';
15
+ export * as deleteAclsV2 from './delete-acls-v2.ts';
14
16
  export * as deleteAclsV3 from './delete-acls-v3.ts';
15
17
  export * as deleteGroupsV2 from './delete-groups-v2.ts';
16
18
  export * as deleteRecordsV2 from './delete-records-v2.ts';
17
19
  export * as deleteTopicsV6 from './delete-topics-v6.ts';
20
+ export * as describeAclsV2 from './describe-acls-v2.ts';
18
21
  export * as describeAclsV3 from './describe-acls-v3.ts';
19
22
  export * as describeClientQuotasV0 from './describe-client-quotas-v0.ts';
23
+ export * as describeClusterV0 from './describe-cluster-v0.ts';
20
24
  export * as describeClusterV1 from './describe-cluster-v1.ts';
21
25
  export * as describeConfigsV2 from './describe-configs-v2.ts';
22
26
  export * as describeConfigsV3 from './describe-configs-v3.ts';
23
27
  export * as describeConfigsV4 from './describe-configs-v4.ts';
24
28
  export * as describeDelegationTokenV3 from './describe-delegation-token-v3.ts';
25
29
  export * as describeGroupsV5 from './describe-groups-v5.ts';
30
+ export * as describeLogDirsV2 from './describe-log-dirs-v2.ts';
31
+ export * as describeLogDirsV3 from './describe-log-dirs-v3.ts';
26
32
  export * as describeLogDirsV4 from './describe-log-dirs-v4.ts';
27
33
  export * as describeProducersV0 from './describe-producers-v0.ts';
28
34
  export * as describeQuorumV2 from './describe-quorum-v2.ts';
@@ -35,6 +41,7 @@ export * as incrementalAlterConfigsV1 from './incremental-alter-configs-v1.ts';
35
41
  export * as listGroupsV4 from './list-groups-v4.ts';
36
42
  export * as listGroupsV5 from './list-groups-v5.ts';
37
43
  export * as listPartitionReassignmentsV0 from './list-partition-reassignments-v0.ts';
44
+ export * as listTransactionsV0 from './list-transactions-v0.ts';
38
45
  export * as listTransactionsV1 from './list-transactions-v1.ts';
39
46
  export * as offsetDeleteV0 from './offset-delete-v0.ts';
40
47
  export * as renewDelegationTokenV2 from './renew-delegation-token-v2.ts';