@platformatic/kafka 1.27.0-alpha.2 → 1.27.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 (114) hide show
  1. package/README.md +6 -1
  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/base/base.js +6 -2
  47. package/dist/clients/base/options.d.ts +9 -2
  48. package/dist/clients/base/options.js +1 -1
  49. package/dist/clients/base/types.d.ts +2 -1
  50. package/dist/clients/consumer/consumer.js +14 -1
  51. package/dist/clients/consumer/messages-stream.d.ts +2 -2
  52. package/dist/clients/consumer/messages-stream.js +3 -3
  53. package/dist/clients/producer/producer.js +7 -1
  54. package/dist/errors.d.ts +0 -4
  55. package/dist/errors.js +0 -6
  56. package/dist/network/connection.js +1 -1
  57. package/dist/protocol/compression.d.ts +1 -1
  58. package/dist/protocol/compression.js +7 -46
  59. package/dist/protocol/crc32c.d.ts +1 -1
  60. package/dist/protocol/crc32c.js +5 -6
  61. package/dist/protocol/definitions.d.ts +1 -1
  62. package/dist/protocol/index.d.ts +0 -2
  63. package/dist/protocol/index.js +0 -2
  64. package/dist/protocol/reader.d.ts +2 -2
  65. package/dist/protocol/reader.js +3 -3
  66. package/dist/protocol/records.d.ts +4 -4
  67. package/dist/protocol/records.js +1 -1
  68. package/dist/protocol/writer.d.ts +1 -1
  69. package/dist/protocol/writer.js +2 -2
  70. package/dist/typescript-4/dist/apis/admin/create-acls-v2.d.ts +16 -0
  71. package/dist/typescript-4/dist/apis/admin/delete-acls-v2.d.ts +21 -0
  72. package/dist/typescript-4/dist/apis/admin/describe-acls-v2.d.ts +17 -0
  73. package/dist/typescript-4/dist/apis/admin/describe-cluster-v0.d.ts +23 -0
  74. package/dist/typescript-4/dist/apis/admin/describe-log-dirs-v2.d.ts +32 -0
  75. package/dist/typescript-4/dist/apis/admin/describe-log-dirs-v3.d.ts +32 -0
  76. package/dist/typescript-4/dist/apis/admin/index.d.ts +7 -0
  77. package/dist/typescript-4/dist/apis/admin/list-transactions-v0.d.ts +18 -0
  78. package/dist/typescript-4/dist/apis/consumer/index.d.ts +8 -0
  79. package/dist/typescript-4/dist/apis/consumer/join-group-v6.d.ts +27 -0
  80. package/dist/typescript-4/dist/apis/consumer/join-group-v7.d.ts +27 -0
  81. package/dist/typescript-4/dist/apis/consumer/join-group-v8.d.ts +27 -0
  82. package/dist/typescript-4/dist/apis/consumer/leave-group-v4.d.ts +22 -0
  83. package/dist/typescript-4/dist/apis/consumer/list-offsets-v5.d.ts +30 -0
  84. package/dist/typescript-4/dist/apis/consumer/list-offsets-v6.d.ts +30 -0
  85. package/dist/typescript-4/dist/apis/consumer/list-offsets-v7.d.ts +30 -0
  86. package/dist/typescript-4/dist/apis/consumer/sync-group-v4.d.ts +18 -0
  87. package/dist/typescript-4/dist/apis/enumerations.d.ts +5 -5
  88. package/dist/typescript-4/dist/apis/producer/add-offsets-to-txn-v1.d.ts +10 -0
  89. package/dist/typescript-4/dist/apis/producer/add-offsets-to-txn-v2.d.ts +10 -0
  90. package/dist/typescript-4/dist/apis/producer/index.d.ts +3 -0
  91. package/dist/typescript-4/dist/apis/producer/init-producer-id-v3.d.ts +21 -0
  92. package/dist/typescript-4/dist/clients/admin/options.d.ts +9 -9
  93. package/dist/typescript-4/dist/clients/base/options.d.ts +9 -2
  94. package/dist/typescript-4/dist/clients/base/types.d.ts +2 -1
  95. package/dist/typescript-4/dist/clients/consumer/messages-stream.d.ts +2 -2
  96. package/dist/typescript-4/dist/errors.d.ts +0 -4
  97. package/dist/typescript-4/dist/protocol/compression.d.ts +1 -1
  98. package/dist/typescript-4/dist/protocol/crc32c.d.ts +1 -1
  99. package/dist/typescript-4/dist/protocol/definitions.d.ts +1 -1
  100. package/dist/typescript-4/dist/protocol/index.d.ts +0 -2
  101. package/dist/typescript-4/dist/protocol/reader.d.ts +2 -2
  102. package/dist/typescript-4/dist/protocol/records.d.ts +4 -4
  103. package/dist/typescript-4/dist/protocol/writer.d.ts +1 -1
  104. package/dist/typescript-4/dist/utils.d.ts +3 -2
  105. package/dist/utils.d.ts +2 -1
  106. package/dist/utils.js +3 -0
  107. package/dist/version.js +1 -1
  108. package/package.json +11 -9
  109. package/dist/protocol/dynamic-buffer.d.ts +0 -65
  110. package/dist/protocol/dynamic-buffer.js +0 -563
  111. package/dist/protocol/varint.d.ts +0 -12
  112. package/dist/protocol/varint.js +0 -36
  113. package/dist/typescript-4/dist/protocol/dynamic-buffer.d.ts +0 -65
  114. package/dist/typescript-4/dist/protocol/varint.d.ts +0 -12
@@ -0,0 +1,68 @@
1
+ import { ResponseError } from "../../errors.js";
2
+ import { Writer } from "../../protocol/writer.js";
3
+ import { createAPI } from "../definitions.js";
4
+ /*
5
+ ListOffsets Request (Version: 6) => replica_id isolation_level [topics] TAG_BUFFER
6
+ replica_id => INT32
7
+ isolation_level => INT8
8
+ topics => name [partitions] TAG_BUFFER
9
+ name => COMPACT_STRING
10
+ partitions => partition_index current_leader_epoch timestamp TAG_BUFFER
11
+ partition_index => INT32
12
+ current_leader_epoch => INT32
13
+ timestamp => INT64
14
+ */
15
+ export function createRequest(replica, isolationLevel, topics) {
16
+ return Writer.create()
17
+ .appendInt32(replica)
18
+ .appendInt8(isolationLevel)
19
+ .appendArray(topics, (w, topic) => {
20
+ w.appendString(topic.name).appendArray(topic.partitions, (w, partition) => {
21
+ w.appendInt32(partition.partitionIndex)
22
+ .appendInt32(partition.currentLeaderEpoch)
23
+ .appendInt64(partition.timestamp);
24
+ });
25
+ })
26
+ .appendTaggedFields();
27
+ }
28
+ /*
29
+ ListOffsets Response (Version: 6) => throttle_time_ms [topics] TAG_BUFFER
30
+ throttle_time_ms => INT32
31
+ topics => name [partitions] TAG_BUFFER
32
+ name => COMPACT_STRING
33
+ partitions => partition_index error_code timestamp offset leader_epoch TAG_BUFFER
34
+ partition_index => INT32
35
+ error_code => INT16
36
+ timestamp => INT64
37
+ offset => INT64
38
+ leader_epoch => INT32
39
+ */
40
+ export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
41
+ const errors = [];
42
+ const response = {
43
+ throttleTimeMs: reader.readInt32(),
44
+ topics: reader.readArray((r, i) => {
45
+ return {
46
+ name: r.readString(),
47
+ partitions: r.readArray((r, j) => {
48
+ const partition = {
49
+ partitionIndex: r.readInt32(),
50
+ errorCode: r.readInt16(),
51
+ timestamp: r.readInt64(),
52
+ offset: r.readInt64(),
53
+ leaderEpoch: r.readInt32()
54
+ };
55
+ if (partition.errorCode !== 0) {
56
+ errors.push([`/topics/${i}/partitions/${j}`, [partition.errorCode, null]]);
57
+ }
58
+ return partition;
59
+ })
60
+ };
61
+ })
62
+ };
63
+ if (errors.length) {
64
+ throw new ResponseError(apiKey, apiVersion, Object.fromEntries(errors), response);
65
+ }
66
+ return response;
67
+ }
68
+ export const api = createAPI(2, 6, createRequest, parseResponse);
@@ -0,0 +1,30 @@
1
+ import { type Reader } from '../../protocol/reader.ts';
2
+ import { Writer } from '../../protocol/writer.ts';
3
+ export interface ListOffsetsRequestPartition {
4
+ partitionIndex: number;
5
+ currentLeaderEpoch: number;
6
+ timestamp: bigint;
7
+ }
8
+ export interface ListOffsetsRequestTopic {
9
+ name: string;
10
+ partitions: ListOffsetsRequestPartition[];
11
+ }
12
+ export type ListOffsetsRequest = Parameters<typeof createRequest>;
13
+ export interface ListOffsetResponsePartition {
14
+ partitionIndex: number;
15
+ errorCode: number;
16
+ timestamp: bigint;
17
+ offset: bigint;
18
+ leaderEpoch: number;
19
+ }
20
+ export interface ListOffsetResponseTopic {
21
+ name: string;
22
+ partitions: ListOffsetResponsePartition[];
23
+ }
24
+ export interface ListOffsetsResponse {
25
+ throttleTimeMs: number;
26
+ topics: ListOffsetResponseTopic[];
27
+ }
28
+ export declare function createRequest(replica: number, isolationLevel: number, topics: ListOffsetsRequestTopic[]): Writer;
29
+ export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): ListOffsetsResponse;
30
+ export declare const api: import("../definitions.ts").API<[replica: number, isolationLevel: number, topics: ListOffsetsRequestTopic[]], ListOffsetsResponse>;
@@ -0,0 +1,68 @@
1
+ import { ResponseError } from "../../errors.js";
2
+ import { Writer } from "../../protocol/writer.js";
3
+ import { createAPI } from "../definitions.js";
4
+ /*
5
+ ListOffsets Request (Version: 7) => replica_id isolation_level [topics] TAG_BUFFER
6
+ replica_id => INT32
7
+ isolation_level => INT8
8
+ topics => name [partitions] TAG_BUFFER
9
+ name => COMPACT_STRING
10
+ partitions => partition_index current_leader_epoch timestamp TAG_BUFFER
11
+ partition_index => INT32
12
+ current_leader_epoch => INT32
13
+ timestamp => INT64
14
+ */
15
+ export function createRequest(replica, isolationLevel, topics) {
16
+ return Writer.create()
17
+ .appendInt32(replica)
18
+ .appendInt8(isolationLevel)
19
+ .appendArray(topics, (w, topic) => {
20
+ w.appendString(topic.name).appendArray(topic.partitions, (w, partition) => {
21
+ w.appendInt32(partition.partitionIndex)
22
+ .appendInt32(partition.currentLeaderEpoch)
23
+ .appendInt64(partition.timestamp);
24
+ });
25
+ })
26
+ .appendTaggedFields();
27
+ }
28
+ /*
29
+ ListOffsets Response (Version: 7) => throttle_time_ms [topics] TAG_BUFFER
30
+ throttle_time_ms => INT32
31
+ topics => name [partitions] TAG_BUFFER
32
+ name => COMPACT_STRING
33
+ partitions => partition_index error_code timestamp offset leader_epoch TAG_BUFFER
34
+ partition_index => INT32
35
+ error_code => INT16
36
+ timestamp => INT64
37
+ offset => INT64
38
+ leader_epoch => INT32
39
+ */
40
+ export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
41
+ const errors = [];
42
+ const response = {
43
+ throttleTimeMs: reader.readInt32(),
44
+ topics: reader.readArray((r, i) => {
45
+ return {
46
+ name: r.readString(),
47
+ partitions: r.readArray((r, j) => {
48
+ const partition = {
49
+ partitionIndex: r.readInt32(),
50
+ errorCode: r.readInt16(),
51
+ timestamp: r.readInt64(),
52
+ offset: r.readInt64(),
53
+ leaderEpoch: r.readInt32()
54
+ };
55
+ if (partition.errorCode !== 0) {
56
+ errors.push([`/topics/${i}/partitions/${j}`, [partition.errorCode, null]]);
57
+ }
58
+ return partition;
59
+ })
60
+ };
61
+ })
62
+ };
63
+ if (errors.length) {
64
+ throw new ResponseError(apiKey, apiVersion, Object.fromEntries(errors), response);
65
+ }
66
+ return response;
67
+ }
68
+ export const api = createAPI(2, 7, 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, 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, assignments: SyncGroupRequestAssignment[]], SyncGroupResponse>;
@@ -0,0 +1,43 @@
1
+ import { ResponseError } from "../../errors.js";
2
+ import { Writer } from "../../protocol/writer.js";
3
+ import { createAPI } from "../definitions.js";
4
+ /*
5
+ SyncGroup Request (Version: 4) => group_id generation_id member_id group_instance_id [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
+ assignments => member_id assignment TAG_BUFFER
11
+ member_id => COMPACT_STRING
12
+ assignment => COMPACT_BYTES
13
+
14
+ */
15
+ export function createRequest(groupId, generationId, memberId, groupInstanceId, assignments) {
16
+ return Writer.create()
17
+ .appendString(groupId)
18
+ .appendInt32(generationId)
19
+ .appendString(memberId)
20
+ .appendString(groupInstanceId)
21
+ .appendArray(assignments, (w, a) => w.appendString(a.memberId).appendBytes(a.assignment))
22
+ .appendTaggedFields();
23
+ }
24
+ /*
25
+ SyncGroup Response (Version: 4) => throttle_time_ms error_code assignment TAG_BUFFER
26
+ throttle_time_ms => INT32
27
+ error_code => INT16
28
+ assignment => COMPACT_BYTES
29
+ */
30
+ export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
31
+ const response = {
32
+ throttleTimeMs: reader.readInt32(),
33
+ errorCode: reader.readInt16(),
34
+ protocolType: null,
35
+ protocolName: null,
36
+ assignment: reader.readBytes()
37
+ };
38
+ if (response.errorCode !== 0) {
39
+ throw new ResponseError(apiKey, apiVersion, { '/': [response.errorCode, null] }, response);
40
+ }
41
+ return response;
42
+ }
43
+ export const api = createAPI(14, 4, createRequest, parseResponse);
@@ -67,7 +67,7 @@ export declare const ResourceTypes: {
67
67
  readonly DELEGATION_TOKEN: 6;
68
68
  readonly USER: 7;
69
69
  };
70
- export declare const allowedResourceTypes: (0 | 1 | 7 | 2 | 4 | 3 | 5 | 6)[];
70
+ export declare const allowedResourceTypes: (0 | 1 | 2 | 4 | 7 | 3 | 5 | 6)[];
71
71
  export type ResourceTypeLabel = keyof typeof ResourceTypes;
72
72
  export type ResourceTypeValue = (typeof ResourceTypes)[ResourceTypeLabel];
73
73
  /** @deprecated Use ResourceTypeLabel */
@@ -102,7 +102,7 @@ export declare const AclOperations: {
102
102
  readonly DESCRIBE_TOKENS: 14;
103
103
  readonly TWO_PHASE_COMMIT: 15;
104
104
  };
105
- export declare const allowedAclOperations: (0 | 1 | 7 | 8 | 2 | 4 | 10 | 3 | 5 | 6 | 9 | 11 | 12 | 13 | 14 | 15)[];
105
+ export declare const allowedAclOperations: (0 | 1 | 2 | 4 | 8 | 7 | 10 | 3 | 5 | 6 | 9 | 11 | 12 | 13 | 14 | 15)[];
106
106
  export type AclOperationLabel = keyof typeof AclOperations;
107
107
  export type AclOperationValue = (typeof AclOperations)[AclOperationLabel];
108
108
  /** @deprecated Use AclOperationLabel */
@@ -129,7 +129,7 @@ export declare const ConfigSources: {
129
129
  readonly CLIENT_METRICS_CONFIG: 7;
130
130
  readonly GROUP_CONFIG: 8;
131
131
  };
132
- export declare const allowedConfigSources: (0 | 1 | 7 | 8 | 2 | 4 | 3 | 5 | 6)[];
132
+ export declare const allowedConfigSources: (0 | 1 | 2 | 4 | 8 | 7 | 3 | 5 | 6)[];
133
133
  export type ConfigSourceLabel = keyof typeof ConfigSources;
134
134
  export type ConfigSourceValue = (typeof ConfigSources)[ConfigSourceLabel];
135
135
  /** @deprecated Use ConfigSourceLabel */
@@ -142,7 +142,7 @@ export declare const ConfigResourceTypes: {
142
142
  readonly CLIENT_METRICS: 16;
143
143
  readonly GROUP: 32;
144
144
  };
145
- export declare const allowedConfigResourceTypes: (0 | 8 | 2 | 4 | 16 | 32)[];
145
+ export declare const allowedConfigResourceTypes: (0 | 2 | 4 | 8 | 16 | 32)[];
146
146
  export type ConfigResourceTypeLabel = keyof typeof ConfigResourceTypes;
147
147
  export type ConfigResourceTypeValue = (typeof ConfigResourceTypes)[ConfigResourceTypeLabel];
148
148
  export declare const ConfigTypes: {
@@ -157,7 +157,7 @@ export declare const ConfigTypes: {
157
157
  readonly CLASS: 8;
158
158
  readonly PASSWORD: 9;
159
159
  };
160
- export declare const allowedConfigTypes: (0 | 1 | 7 | 8 | 2 | 4 | 3 | 5 | 6 | 9)[];
160
+ export declare const allowedConfigTypes: (0 | 1 | 2 | 4 | 8 | 7 | 3 | 5 | 6 | 9)[];
161
161
  export type ConfigTypeLabel = keyof typeof ConfigTypes;
162
162
  export type ConfigTypeValue = (typeof ConfigTypes)[ConfigTypeLabel];
163
163
  export declare const IncrementalAlterConfigOperationTypes: {
@@ -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,33 @@
1
+ import { ResponseError } from "../../errors.js";
2
+ import { Writer } from "../../protocol/writer.js";
3
+ import { createAPI } from "../definitions.js";
4
+ /*
5
+ AddOffsetsToTxn Request (Version: 1) => transactional_id producer_id producer_epoch group_id
6
+ transactional_id => STRING
7
+ producer_id => INT64
8
+ producer_epoch => INT16
9
+ group_id => STRING
10
+ */
11
+ export function createRequest(transactionalId, producerId, producerEpoch, groupId) {
12
+ return Writer.create()
13
+ .appendString(transactionalId, false)
14
+ .appendInt64(producerId)
15
+ .appendInt16(producerEpoch)
16
+ .appendString(groupId, false);
17
+ }
18
+ /*
19
+ AddOffsetsToTxn Response (Version: 1) => throttle_time_ms error_code
20
+ throttle_time_ms => INT32
21
+ error_code => INT16
22
+ */
23
+ export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
24
+ const response = {
25
+ throttleTimeMs: reader.readInt32(),
26
+ errorCode: reader.readInt16()
27
+ };
28
+ if (response.errorCode !== 0) {
29
+ throw new ResponseError(apiKey, apiVersion, { '/': [response.errorCode, null] }, response);
30
+ }
31
+ return response;
32
+ }
33
+ export const api = createAPI(25, 1, createRequest, parseResponse, false, false);
@@ -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,33 @@
1
+ import { ResponseError } from "../../errors.js";
2
+ import { Writer } from "../../protocol/writer.js";
3
+ import { createAPI } from "../definitions.js";
4
+ /*
5
+ AddOffsetsToTxn Request (Version: 2) => transactional_id producer_id producer_epoch group_id
6
+ transactional_id => STRING
7
+ producer_id => INT64
8
+ producer_epoch => INT16
9
+ group_id => STRING
10
+ */
11
+ export function createRequest(transactionalId, producerId, producerEpoch, groupId) {
12
+ return Writer.create()
13
+ .appendString(transactionalId, false)
14
+ .appendInt64(producerId)
15
+ .appendInt16(producerEpoch)
16
+ .appendString(groupId, false);
17
+ }
18
+ /*
19
+ AddOffsetsToTxn Response (Version: 2) => throttle_time_ms error_code
20
+ throttle_time_ms => INT32
21
+ error_code => INT16
22
+ */
23
+ export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
24
+ const response = {
25
+ throttleTimeMs: reader.readInt32(),
26
+ errorCode: reader.readInt16()
27
+ };
28
+ if (response.errorCode !== 0) {
29
+ throw new ResponseError(apiKey, apiVersion, { '/': [response.errorCode, null] }, response);
30
+ }
31
+ return response;
32
+ }
33
+ export const api = createAPI(25, 2, createRequest, parseResponse, false, false);
@@ -1,3 +1,5 @@
1
+ export * as addOffsetsToTxnV1 from './add-offsets-to-txn-v1.ts';
2
+ export * as addOffsetsToTxnV2 from './add-offsets-to-txn-v2.ts';
1
3
  export * as addOffsetsToTxnV3 from './add-offsets-to-txn-v3.ts';
2
4
  export * as addOffsetsToTxnV4 from './add-offsets-to-txn-v4.ts';
3
5
  export * as addPartitionsToTxnV3 from './add-partitions-to-txn-v3.ts';
@@ -5,6 +7,7 @@ export * as addPartitionsToTxnV4 from './add-partitions-to-txn-v4.ts';
5
7
  export * as addPartitionsToTxnV5 from './add-partitions-to-txn-v5.ts';
6
8
  export * as endTxnV3 from './end-txn-v3.ts';
7
9
  export * as endTxnV4 from './end-txn-v4.ts';
10
+ export * as initProducerIdV3 from './init-producer-id-v3.ts';
8
11
  export * as initProducerIdV4 from './init-producer-id-v4.ts';
9
12
  export * as initProducerIdV5 from './init-producer-id-v5.ts';
10
13
  export * as produceV10 from './produce-v10.ts';
@@ -1,3 +1,5 @@
1
+ export * as addOffsetsToTxnV1 from "./add-offsets-to-txn-v1.js";
2
+ export * as addOffsetsToTxnV2 from "./add-offsets-to-txn-v2.js";
1
3
  export * as addOffsetsToTxnV3 from "./add-offsets-to-txn-v3.js";
2
4
  export * as addOffsetsToTxnV4 from "./add-offsets-to-txn-v4.js";
3
5
  export * as addPartitionsToTxnV3 from "./add-partitions-to-txn-v3.js";
@@ -5,6 +7,7 @@ export * as addPartitionsToTxnV4 from "./add-partitions-to-txn-v4.js";
5
7
  export * as addPartitionsToTxnV5 from "./add-partitions-to-txn-v5.js";
6
8
  export * as endTxnV3 from "./end-txn-v3.js";
7
9
  export * as endTxnV4 from "./end-txn-v4.js";
10
+ export * as initProducerIdV3 from "./init-producer-id-v3.js";
8
11
  export * as initProducerIdV4 from "./init-producer-id-v4.js";
9
12
  export * as initProducerIdV5 from "./init-producer-id-v5.js";
10
13
  export * as produceV10 from "./produce-v10.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: 3) => 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: 3) => 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, null] }, response);
35
+ }
36
+ return response;
37
+ }
38
+ export const api = createAPI(22, 3, createRequest, parseResponse);
@@ -494,7 +494,7 @@ export declare const describeConfigsOptionsSchema: {
494
494
  properties: {
495
495
  resourceType: {
496
496
  type: string;
497
- enum: (0 | 1 | 7 | 2 | 4 | 3 | 5 | 6)[];
497
+ enum: (0 | 1 | 2 | 4 | 7 | 3 | 5 | 6)[];
498
498
  };
499
499
  resourceName: {
500
500
  type: string;
@@ -533,7 +533,7 @@ export declare const alterConfigsOptionsSchema: {
533
533
  properties: {
534
534
  resourceType: {
535
535
  type: string;
536
- enum: (0 | 1 | 7 | 2 | 4 | 3 | 5 | 6)[];
536
+ enum: (0 | 1 | 2 | 4 | 7 | 3 | 5 | 6)[];
537
537
  };
538
538
  resourceName: {
539
539
  type: string;
@@ -580,7 +580,7 @@ export declare const incrementalAlterConfigsOptionsSchema: {
580
580
  properties: {
581
581
  resourceType: {
582
582
  type: string;
583
- enum: (0 | 1 | 7 | 2 | 4 | 3 | 5 | 6)[];
583
+ enum: (0 | 1 | 2 | 4 | 7 | 3 | 5 | 6)[];
584
584
  };
585
585
  resourceName: {
586
586
  type: string;
@@ -648,7 +648,7 @@ export declare const createAclsOptionsSchema: {
648
648
  properties: {
649
649
  resourceType: {
650
650
  type: string;
651
- enum: (0 | 1 | 7 | 2 | 4 | 3 | 5 | 6)[];
651
+ enum: (0 | 1 | 2 | 4 | 7 | 3 | 5 | 6)[];
652
652
  };
653
653
  resourceName: {
654
654
  type: string;
@@ -668,7 +668,7 @@ export declare const createAclsOptionsSchema: {
668
668
  };
669
669
  operation: {
670
670
  type: string;
671
- enum: (0 | 1 | 7 | 8 | 2 | 4 | 10 | 3 | 5 | 6 | 9 | 11 | 12 | 13 | 14 | 15)[];
671
+ enum: (0 | 1 | 2 | 4 | 8 | 7 | 10 | 3 | 5 | 6 | 9 | 11 | 12 | 13 | 14 | 15)[];
672
672
  };
673
673
  permissionType: {
674
674
  type: string;
@@ -692,7 +692,7 @@ export declare const describeAclsOptionsSchema: {
692
692
  properties: {
693
693
  resourceType: {
694
694
  type: string;
695
- enum: (0 | 1 | 7 | 2 | 4 | 3 | 5 | 6)[];
695
+ enum: (0 | 1 | 2 | 4 | 7 | 3 | 5 | 6)[];
696
696
  };
697
697
  resourceName: {
698
698
  anyOf: ({
@@ -727,7 +727,7 @@ export declare const describeAclsOptionsSchema: {
727
727
  };
728
728
  operation: {
729
729
  type: string;
730
- enum: (0 | 1 | 7 | 8 | 2 | 4 | 10 | 3 | 5 | 6 | 9 | 11 | 12 | 13 | 14 | 15)[];
730
+ enum: (0 | 1 | 2 | 4 | 8 | 7 | 10 | 3 | 5 | 6 | 9 | 11 | 12 | 13 | 14 | 15)[];
731
731
  };
732
732
  permissionType: {
733
733
  type: string;
@@ -751,7 +751,7 @@ export declare const deleteAclsOptionsSchema: {
751
751
  properties: {
752
752
  resourceType: {
753
753
  type: string;
754
- enum: (0 | 1 | 7 | 2 | 4 | 3 | 5 | 6)[];
754
+ enum: (0 | 1 | 2 | 4 | 7 | 3 | 5 | 6)[];
755
755
  };
756
756
  resourceName: {
757
757
  anyOf: ({
@@ -786,7 +786,7 @@ export declare const deleteAclsOptionsSchema: {
786
786
  };
787
787
  operation: {
788
788
  type: string;
789
- enum: (0 | 1 | 7 | 8 | 2 | 4 | 10 | 3 | 5 | 6 | 9 | 11 | 12 | 13 | 14 | 15)[];
789
+ enum: (0 | 1 | 2 | 4 | 8 | 7 | 10 | 3 | 5 | 6 | 9 | 11 | 12 | 13 | 14 | 15)[];
790
790
  };
791
791
  permissionType: {
792
792
  type: string;
@@ -230,16 +230,20 @@ export class Base extends TypedEventEmitter {
230
230
  const retriable = !genericError.findBy?.('canRetry', false);
231
231
  errors.push(error);
232
232
  if (attempt < retries && retriable && !shouldSkipRetry?.(error)) {
233
- this.emitWithDebug('client', 'performWithRetry:retry', operationId, attempt, retries);
234
233
  function onClose() {
235
234
  clearTimeout(timeout);
236
235
  errors.push(new UserError(`Client closed while retrying ${operationId}.`));
237
236
  callback(new MultipleErrors(`${operationId} failed ${attempt + 1} times.`, errors));
238
237
  }
238
+ let delay = this[kOptions].retryDelay;
239
+ if (typeof delay === 'function') {
240
+ delay = delay(this, operationId, attempt + 1, retries, error);
241
+ }
242
+ this.emitWithDebug('client', 'performWithRetry:retry', operationId, attempt, retries, delay);
239
243
  const timeout = setTimeout(() => {
240
244
  this.removeListener('client:close', onClose);
241
245
  this[kPerformWithRetry](operationId, operation, callback, attempt + 1, errors, shouldSkipRetry);
242
- }, this[kOptions].retryDelay);
246
+ }, delay);
243
247
  this.once('client:close', onClose);
244
248
  }
245
249
  else {
@@ -67,8 +67,15 @@ export declare const baseOptionsSchema: {
67
67
  })[];
68
68
  };
69
69
  retryDelay: {
70
- type: string;
71
- minimum: number;
70
+ oneOf: ({
71
+ type: string;
72
+ minimum: number;
73
+ function?: undefined;
74
+ } | {
75
+ function: boolean;
76
+ type?: undefined;
77
+ minimum?: undefined;
78
+ })[];
72
79
  };
73
80
  maxInflights: {
74
81
  type: string;
@@ -29,7 +29,7 @@ export const baseOptionsSchema = {
29
29
  timeout: { type: 'number', minimum: 0 },
30
30
  connectTimeout: { type: 'number', minimum: 0 },
31
31
  retries: { oneOf: [{ type: 'number', minimum: 0 }, { type: 'boolean' }] },
32
- retryDelay: { type: 'number', minimum: 0 },
32
+ retryDelay: { oneOf: [{ type: 'number', minimum: 0 }, { function: true }] },
33
33
  maxInflights: { type: 'number', minimum: 0 },
34
34
  handleBackPressure: { type: 'boolean', default: false },
35
35
  tls: { type: 'object', additionalProperties: true }, // No validation as they come from Node.js
@@ -29,12 +29,13 @@ export interface ClusterMetadata {
29
29
  topics: Map<string, ClusterTopicMetadata>;
30
30
  lastUpdate: number;
31
31
  }
32
+ export type RetryDelayGetter<Owner = object> = (client: Owner, operationId: string, attempt: number, retries: number, error: Error) => number;
32
33
  export interface BaseOptions extends ConnectionOptions {
33
34
  clientId: string;
34
35
  bootstrapBrokers: Broker[] | string[];
35
36
  timeout?: number;
36
37
  retries?: number | boolean;
37
- retryDelay?: number;
38
+ retryDelay?: number | RetryDelayGetter;
38
39
  metadataMaxAge?: number;
39
40
  autocreateTopics?: boolean;
40
41
  strict?: boolean;
@@ -7,6 +7,7 @@ import { Reader } from "../../protocol/reader.js";
7
7
  import { IS_CONTROL } from "../../protocol/records.js";
8
8
  import { Writer } from "../../protocol/writer.js";
9
9
  import { kAutocommit, kRefreshOffsetsAndFetch } from "../../symbols.js";
10
+ import { emitExperimentalApiWarning } from "../../utils.js";
10
11
  import { Base, kAfterCreate, kCheckNotClosed, kClosed, kConnections, kFormatValidationErrors, kGetApi, kGetBootstrapConnection, kGetConnection, kMetadata, kOptions, kPerformDeduplicated, kPerformWithRetry, kPrometheus, kValidateOptions } from "../base/base.js";
11
12
  import { ensureMetric } from "../metrics.js";
12
13
  import { MessagesStream } from "./messages-stream.js";
@@ -40,6 +41,12 @@ export class Consumer extends Base {
40
41
  constructor(options) {
41
42
  super({ ...defaultConsumerOptions, ...options });
42
43
  this[kValidateOptions](options, consumerOptionsValidator, '/options');
44
+ if (options.beforeDeserialization) {
45
+ emitExperimentalApiWarning('beforeDeserialization');
46
+ }
47
+ if (options.registry) {
48
+ emitExperimentalApiWarning('registry (Confluent Schema Registry integration)');
49
+ }
43
50
  if (options.registry) {
44
51
  if (options.beforeDeserialization) {
45
52
  throw new UserError('/options/beforeDeserialization cannot be provided when /options/registry is provided.');
@@ -162,6 +169,12 @@ export class Consumer extends Base {
162
169
  options.highWaterMark ??= this[kOptions].highWaterMark;
163
170
  options.registry ??= this[kOptions].registry;
164
171
  options.beforeDeserialization ??= this[kOptions].beforeDeserialization;
172
+ if (options.beforeDeserialization) {
173
+ emitExperimentalApiWarning('beforeDeserialization');
174
+ }
175
+ if (options.registry) {
176
+ emitExperimentalApiWarning('registry (Confluent Schema Registry integration)');
177
+ }
165
178
  if (options.registry) {
166
179
  if (options.beforeDeserialization) {
167
180
  throw new UserError('/options/beforeDeserialization cannot be provided when /options/registry is provided.');
@@ -1231,7 +1244,7 @@ export class Consumer extends Base {
1231
1244
  }
1232
1245
  // Now find last offsets
1233
1246
  for (const batch of partition.records) {
1234
- if (batch.attributes & IS_CONTROL && batch.records[0].key.readInt16BE(2) === 0) {
1247
+ if (batch.attributes & IS_CONTROL && batch.records[0].key?.readInt16BE(2) === 0) {
1235
1248
  abortedRanges.get(batch.producerId)[1] = batch.firstOffset;
1236
1249
  }
1237
1250
  }