@platformatic/kafka 1.29.0 → 1.30.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 (34) hide show
  1. package/README.md +1 -1
  2. package/dist/apis/admin/alter-partition-reassignments-v0.d.ts +2 -2
  3. package/dist/apis/admin/alter-partition-reassignments-v0.js +1 -1
  4. package/dist/apis/admin/alter-partition-reassignments-v1.d.ts +30 -0
  5. package/dist/apis/admin/alter-partition-reassignments-v1.js +71 -0
  6. package/dist/apis/admin/index.d.ts +2 -0
  7. package/dist/apis/admin/index.js +2 -0
  8. package/dist/apis/admin/list-transactions-v0.d.ts +3 -2
  9. package/dist/apis/admin/list-transactions-v0.js +1 -1
  10. package/dist/apis/admin/list-transactions-v1.d.ts +3 -2
  11. package/dist/apis/admin/list-transactions-v1.js +1 -1
  12. package/dist/apis/admin/list-transactions-v2.d.ts +20 -0
  13. package/dist/apis/admin/list-transactions-v2.js +49 -0
  14. package/dist/apis/consumer/consumer-group-heartbeat-v0.d.ts +2 -2
  15. package/dist/apis/consumer/consumer-group-heartbeat-v0.js +1 -1
  16. package/dist/apis/consumer/consumer-group-heartbeat-v1.d.ts +27 -0
  17. package/dist/apis/consumer/consumer-group-heartbeat-v1.js +70 -0
  18. package/dist/apis/consumer/index.d.ts +1 -0
  19. package/dist/apis/consumer/index.js +1 -0
  20. package/dist/clients/consumer/consumer.js +17 -3
  21. package/dist/clients/consumer/messages-stream.js +4 -0
  22. package/dist/clients/producer/producer.js +4 -0
  23. package/dist/registries/abstract.js +4 -0
  24. package/dist/typescript-4/dist/apis/admin/alter-partition-reassignments-v0.d.ts +2 -2
  25. package/dist/typescript-4/dist/apis/admin/alter-partition-reassignments-v1.d.ts +30 -0
  26. package/dist/typescript-4/dist/apis/admin/index.d.ts +2 -0
  27. package/dist/typescript-4/dist/apis/admin/list-transactions-v0.d.ts +3 -2
  28. package/dist/typescript-4/dist/apis/admin/list-transactions-v1.d.ts +3 -2
  29. package/dist/typescript-4/dist/apis/admin/list-transactions-v2.d.ts +20 -0
  30. package/dist/typescript-4/dist/apis/consumer/consumer-group-heartbeat-v0.d.ts +2 -2
  31. package/dist/typescript-4/dist/apis/consumer/consumer-group-heartbeat-v1.d.ts +27 -0
  32. package/dist/typescript-4/dist/apis/consumer/index.d.ts +1 -0
  33. package/dist/version.js +1 -1
  34. package/package.json +1 -1
package/README.md CHANGED
@@ -16,7 +16,7 @@ A modern, high-performance, pure TypeScript/JavaScript type safe client for Apac
16
16
 
17
17
  ## Supported Kafka Version
18
18
 
19
- Supported Kafka version are from **3.5.0** to **4.0.0** and equivalent, edges included.
19
+ Supported Kafka version are from **3.5.0** to **4.1.0** and equivalent, edges included.
20
20
 
21
21
  ## Supported KIPs
22
22
 
@@ -25,6 +25,6 @@ export interface AlterPartitionReassignmentsResponse {
25
25
  errorMessage: NullableString;
26
26
  responses: AlterPartitionReassignmentsResponseResponse[];
27
27
  }
28
- export declare function createRequest(timeoutMs: number, topics: AlterPartitionReassignmentsRequestTopic[]): Writer;
28
+ export declare function createRequest(timeoutMs: number, _allowReplicationFactorChange: boolean, topics: AlterPartitionReassignmentsRequestTopic[]): Writer;
29
29
  export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): AlterPartitionReassignmentsResponse;
30
- export declare const api: import("../definitions.ts").API<[timeoutMs: number, topics: AlterPartitionReassignmentsRequestTopic[]], AlterPartitionReassignmentsResponse>;
30
+ export declare const api: import("../definitions.ts").API<[timeoutMs: number, _allowReplicationFactorChange: boolean, topics: AlterPartitionReassignmentsRequestTopic[]], AlterPartitionReassignmentsResponse>;
@@ -10,7 +10,7 @@ import { createAPI } from "../definitions.js";
10
10
  partition_index => INT32
11
11
  replicas => INT32
12
12
  */
13
- export function createRequest(timeoutMs, topics) {
13
+ export function createRequest(timeoutMs, _allowReplicationFactorChange, topics) {
14
14
  return Writer.create()
15
15
  .appendInt32(timeoutMs)
16
16
  .appendArray(topics, (w, t) => {
@@ -0,0 +1,30 @@
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 AlterPartitionReassignmentsRequestPartition {
5
+ partitionIndex: number;
6
+ replicas: number[];
7
+ }
8
+ export interface AlterPartitionReassignmentsRequestTopic {
9
+ name: string;
10
+ partitions: AlterPartitionReassignmentsRequestPartition[];
11
+ }
12
+ export type AlterPartitionReassignmentsRequest = Parameters<typeof createRequest>;
13
+ export interface AlterPartitionReassignmentsResponsePartition {
14
+ partitionIndex: number;
15
+ errorCode: number;
16
+ errorMessage: NullableString;
17
+ }
18
+ export interface AlterPartitionReassignmentsResponseResponse {
19
+ name: string;
20
+ partitions: AlterPartitionReassignmentsResponsePartition[];
21
+ }
22
+ export interface AlterPartitionReassignmentsResponse {
23
+ throttleTimeMs: number;
24
+ errorCode: number;
25
+ errorMessage: NullableString;
26
+ responses: AlterPartitionReassignmentsResponseResponse[];
27
+ }
28
+ export declare function createRequest(timeoutMs: number, allowReplicationFactorChange: boolean, topics: AlterPartitionReassignmentsRequestTopic[]): Writer;
29
+ export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): AlterPartitionReassignmentsResponse;
30
+ export declare const api: import("../definitions.ts").API<[timeoutMs: number, allowReplicationFactorChange: boolean, topics: AlterPartitionReassignmentsRequestTopic[]], AlterPartitionReassignmentsResponse>;
@@ -0,0 +1,71 @@
1
+ import { ResponseError } from "../../errors.js";
2
+ import { Writer } from "../../protocol/writer.js";
3
+ import { createAPI } from "../definitions.js";
4
+ /*
5
+ AlterPartitionReassignments Request (Version: 1) => timeout_ms allow_replication_factor_change [topics] TAG_BUFFER
6
+ timeout_ms => INT32
7
+ allow_replication_factor_change => BOOLEAN
8
+ topics => name [partitions] TAG_BUFFER
9
+ name => COMPACT_STRING
10
+ partitions => partition_index [replicas] TAG_BUFFER
11
+ partition_index => INT32
12
+ replicas => INT32
13
+ */
14
+ export function createRequest(timeoutMs, allowReplicationFactorChange, topics) {
15
+ return Writer.create()
16
+ .appendInt32(timeoutMs)
17
+ .appendBoolean(allowReplicationFactorChange)
18
+ .appendArray(topics, (w, t) => {
19
+ w.appendString(t.name).appendArray(t.partitions, (w, p) => {
20
+ w.appendInt32(p.partitionIndex).appendArray(p.replicas, (w, r) => w.appendInt32(r), true, false);
21
+ });
22
+ })
23
+ .appendTaggedFields();
24
+ }
25
+ /*
26
+ AlterPartitionReassignments Response (Version: 1) => throttle_time_ms error_code error_message [responses] TAG_BUFFER
27
+ throttle_time_ms => INT32
28
+ error_code => INT16
29
+ error_message => COMPACT_NULLABLE_STRING
30
+ responses => name [partitions] TAG_BUFFER
31
+ name => COMPACT_STRING
32
+ partitions => partition_index error_code error_message TAG_BUFFER
33
+ partition_index => INT32
34
+ error_code => INT16
35
+ error_message => COMPACT_NULLABLE_STRING
36
+ */
37
+ export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
38
+ const errors = [];
39
+ const throttleTimeMs = reader.readInt32();
40
+ const errorCode = reader.readInt16();
41
+ const errorMessage = reader.readNullableString();
42
+ if (errorCode !== 0) {
43
+ errors.push(['', [errorCode, errorMessage]]);
44
+ }
45
+ const response = {
46
+ throttleTimeMs,
47
+ errorCode,
48
+ errorMessage,
49
+ responses: reader.readArray((r, i) => {
50
+ return {
51
+ name: r.readString(),
52
+ partitions: r.readArray((r, j) => {
53
+ const partition = {
54
+ partitionIndex: r.readInt32(),
55
+ errorCode: r.readInt16(),
56
+ errorMessage: r.readNullableString()
57
+ };
58
+ if (partition.errorCode !== 0) {
59
+ errors.push([`responses/${i}/partitions/${j}`, [partition.errorCode, partition.errorMessage]]);
60
+ }
61
+ return partition;
62
+ })
63
+ };
64
+ })
65
+ };
66
+ if (errors.length) {
67
+ throw new ResponseError(apiKey, apiVersion, Object.fromEntries(errors), response);
68
+ }
69
+ return response;
70
+ }
71
+ export const api = createAPI(45, 1, createRequest, parseResponse);
@@ -1,6 +1,7 @@
1
1
  export * as alterClientQuotasV1 from './alter-client-quotas-v1.ts';
2
2
  export * as alterConfigsV2 from './alter-configs-v2.ts';
3
3
  export * as alterPartitionReassignmentsV0 from './alter-partition-reassignments-v0.ts';
4
+ export * as alterPartitionReassignmentsV1 from './alter-partition-reassignments-v1.ts';
4
5
  export * as alterPartitionV3 from './alter-partition-v3.ts';
5
6
  export * as alterReplicaLogDirsV2 from './alter-replica-log-dirs-v2.ts';
6
7
  export * as alterUserScramCredentialsV0 from './alter-user-scram-credentials-v0.ts';
@@ -43,6 +44,7 @@ export * as listGroupsV5 from './list-groups-v5.ts';
43
44
  export * as listPartitionReassignmentsV0 from './list-partition-reassignments-v0.ts';
44
45
  export * as listTransactionsV0 from './list-transactions-v0.ts';
45
46
  export * as listTransactionsV1 from './list-transactions-v1.ts';
47
+ export * as listTransactionsV2 from './list-transactions-v2.ts';
46
48
  export * as offsetDeleteV0 from './offset-delete-v0.ts';
47
49
  export * as renewDelegationTokenV2 from './renew-delegation-token-v2.ts';
48
50
  export * as unregisterBrokerV0 from './unregister-broker-v0.ts';
@@ -1,6 +1,7 @@
1
1
  export * as alterClientQuotasV1 from "./alter-client-quotas-v1.js";
2
2
  export * as alterConfigsV2 from "./alter-configs-v2.js";
3
3
  export * as alterPartitionReassignmentsV0 from "./alter-partition-reassignments-v0.js";
4
+ export * as alterPartitionReassignmentsV1 from "./alter-partition-reassignments-v1.js";
4
5
  export * as alterPartitionV3 from "./alter-partition-v3.js";
5
6
  export * as alterReplicaLogDirsV2 from "./alter-replica-log-dirs-v2.js";
6
7
  export * as alterUserScramCredentialsV0 from "./alter-user-scram-credentials-v0.js";
@@ -43,6 +44,7 @@ export * as listGroupsV5 from "./list-groups-v5.js";
43
44
  export * as listPartitionReassignmentsV0 from "./list-partition-reassignments-v0.js";
44
45
  export * as listTransactionsV0 from "./list-transactions-v0.js";
45
46
  export * as listTransactionsV1 from "./list-transactions-v1.js";
47
+ export * as listTransactionsV2 from "./list-transactions-v2.js";
46
48
  export * as offsetDeleteV0 from "./offset-delete-v0.js";
47
49
  export * as renewDelegationTokenV2 from "./renew-delegation-token-v2.js";
48
50
  export * as unregisterBrokerV0 from "./unregister-broker-v0.js";
@@ -1,3 +1,4 @@
1
+ import { type NullableString } from '../../protocol/definitions.ts';
1
2
  import { type Reader } from '../../protocol/reader.ts';
2
3
  import { Writer } from '../../protocol/writer.ts';
3
4
  import { type TransactionState } from '../enumerations.ts';
@@ -13,6 +14,6 @@ export interface ListTransactionsResponse {
13
14
  unknownStateFilters: string[];
14
15
  transactionStates: ListTransactionsResponseTransactionState[];
15
16
  }
16
- export declare function createRequest(stateFilters: TransactionState[], producerIdFilters: bigint[], _durationFilter: bigint): Writer;
17
+ export declare function createRequest(stateFilters: TransactionState[], producerIdFilters: bigint[], _durationFilter: bigint, _transactionalIdPattern: NullableString): Writer;
17
18
  export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): ListTransactionsResponse;
18
- export declare const api: import("../definitions.ts").API<[stateFilters: ("EMPTY" | "ONGOING" | "PREPARE_ABORT" | "COMMITTING" | "ABORTING" | "COMPLETE_COMMIT" | "COMPLETE_ABORT")[], producerIdFilters: bigint[], _durationFilter: bigint], ListTransactionsResponse>;
19
+ export declare const api: import("../definitions.ts").API<[stateFilters: ("EMPTY" | "ONGOING" | "PREPARE_ABORT" | "COMMITTING" | "ABORTING" | "COMPLETE_COMMIT" | "COMPLETE_ABORT")[], producerIdFilters: bigint[], _durationFilter: bigint, _transactionalIdPattern: NullableString], ListTransactionsResponse>;
@@ -6,7 +6,7 @@ import { createAPI } from "../definitions.js";
6
6
  state_filters => COMPACT_STRING
7
7
  producer_id_filters => INT64
8
8
  */
9
- export function createRequest(stateFilters, producerIdFilters, _durationFilter) {
9
+ export function createRequest(stateFilters, producerIdFilters, _durationFilter, _transactionalIdPattern) {
10
10
  return Writer.create()
11
11
  .appendArray(stateFilters, (w, t) => w.appendString(t), true, false)
12
12
  .appendArray(producerIdFilters, (w, p) => w.appendInt64(p), true, false)
@@ -1,3 +1,4 @@
1
+ import { type NullableString } from '../../protocol/definitions.ts';
1
2
  import { type Reader } from '../../protocol/reader.ts';
2
3
  import { Writer } from '../../protocol/writer.ts';
3
4
  import { type TransactionState } from '../enumerations.ts';
@@ -13,6 +14,6 @@ export interface ListTransactionsResponse {
13
14
  unknownStateFilters: string[];
14
15
  transactionStates: ListTransactionsResponseTransactionState[];
15
16
  }
16
- export declare function createRequest(stateFilters: TransactionState[], producerIdFilters: bigint[], durationFilter: bigint): Writer;
17
+ export declare function createRequest(stateFilters: TransactionState[], producerIdFilters: bigint[], durationFilter: bigint, _transactionalIdPattern: NullableString): Writer;
17
18
  export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): ListTransactionsResponse;
18
- export declare const api: import("../definitions.ts").API<[stateFilters: ("EMPTY" | "ONGOING" | "PREPARE_ABORT" | "COMMITTING" | "ABORTING" | "COMPLETE_COMMIT" | "COMPLETE_ABORT")[], producerIdFilters: bigint[], durationFilter: bigint], ListTransactionsResponse>;
19
+ export declare const api: import("../definitions.ts").API<[stateFilters: ("EMPTY" | "ONGOING" | "PREPARE_ABORT" | "COMMITTING" | "ABORTING" | "COMPLETE_COMMIT" | "COMPLETE_ABORT")[], producerIdFilters: bigint[], durationFilter: bigint, _transactionalIdPattern: NullableString], ListTransactionsResponse>;
@@ -7,7 +7,7 @@ import { createAPI } from "../definitions.js";
7
7
  producer_id_filters => INT64
8
8
  duration_filter => INT64
9
9
  */
10
- export function createRequest(stateFilters, producerIdFilters, durationFilter) {
10
+ export function createRequest(stateFilters, producerIdFilters, durationFilter, _transactionalIdPattern) {
11
11
  return Writer.create()
12
12
  .appendArray(stateFilters, (w, t) => w.appendString(t), true, false)
13
13
  .appendArray(producerIdFilters, (w, p) => w.appendInt64(p), true, false)
@@ -0,0 +1,20 @@
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 TransactionState } from '../enumerations.ts';
5
+ export type ListTransactionsRequest = Parameters<typeof createRequest>;
6
+ export interface ListTransactionsResponseTransactionState {
7
+ transactionalId: string;
8
+ producerId: bigint;
9
+ transactionState: string;
10
+ }
11
+ export interface ListTransactionsResponse {
12
+ throttleTimeMs: number;
13
+ errorCode: number;
14
+ errorMessage: NullableString;
15
+ unknownStateFilters: string[];
16
+ transactionStates: ListTransactionsResponseTransactionState[];
17
+ }
18
+ export declare function createRequest(stateFilters: TransactionState[], producerIdFilters: bigint[], durationFilter: bigint, transactionalIdPattern: NullableString): Writer;
19
+ export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): ListTransactionsResponse;
20
+ export declare const api: import("../definitions.ts").API<[stateFilters: ("EMPTY" | "ONGOING" | "PREPARE_ABORT" | "COMMITTING" | "ABORTING" | "COMPLETE_COMMIT" | "COMPLETE_ABORT")[], producerIdFilters: bigint[], durationFilter: bigint, transactionalIdPattern: NullableString], ListTransactionsResponse>;
@@ -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
+ ListTransactions Request (Version: 2) => [state_filters] [producer_id_filters] duration_filter transactional_id_pattern TAG_BUFFER
6
+ state_filters => COMPACT_STRING
7
+ producer_id_filters => INT64
8
+ duration_filter => INT64
9
+ transactional_id_pattern => COMPACT_NULLABLE_STRING
10
+ */
11
+ export function createRequest(stateFilters, producerIdFilters, durationFilter, transactionalIdPattern) {
12
+ return Writer.create()
13
+ .appendArray(stateFilters, (w, t) => w.appendString(t), true, false)
14
+ .appendArray(producerIdFilters, (w, p) => w.appendInt64(p), true, false)
15
+ .appendInt64(durationFilter)
16
+ .appendString(transactionalIdPattern)
17
+ .appendTaggedFields();
18
+ }
19
+ /*
20
+ ListTransactions Response (Version: 2) => throttle_time_ms error_code error_message [unknown_state_filters] [transaction_states] TAG_BUFFER
21
+ throttle_time_ms => INT32
22
+ error_code => INT16
23
+ error_message => COMPACT_NULLABLE_STRING
24
+ unknown_state_filters => COMPACT_STRING
25
+ transaction_states => transactional_id producer_id transaction_state TAG_BUFFER
26
+ transactional_id => COMPACT_STRING
27
+ producer_id => INT64
28
+ transaction_state => COMPACT_STRING
29
+ */
30
+ export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
31
+ const response = {
32
+ throttleTimeMs: reader.readInt32(),
33
+ errorCode: reader.readInt16(),
34
+ errorMessage: reader.readNullableString(),
35
+ unknownStateFilters: reader.readArray(r => r.readString(), true, false),
36
+ transactionStates: reader.readArray(r => {
37
+ return {
38
+ transactionalId: r.readString(),
39
+ producerId: r.readInt64(),
40
+ transactionState: r.readString()
41
+ };
42
+ })
43
+ };
44
+ if (response.errorCode !== 0) {
45
+ throw new ResponseError(apiKey, apiVersion, { '/': [response.errorCode, response.errorMessage] }, response);
46
+ }
47
+ return response;
48
+ }
49
+ export const api = createAPI(66, 2, createRequest, parseResponse);
@@ -22,6 +22,6 @@ export interface ConsumerGroupHeartbeatResponse {
22
22
  heartbeatIntervalMs: number;
23
23
  assignment: ConsumerGroupHeartbeatResponseAssignment | null;
24
24
  }
25
- export declare function createRequest(groupId: string, memberId: string, memberEpoch: number, instanceId: NullableString, rackId: NullableString, rebalanceTimeoutMs: number, subscribedTopicNames: string[] | null, serverAssignor: NullableString, topicPartitions: ConsumerGroupHeartbeatRequestTopicPartition[]): Writer;
25
+ export declare function createRequest(groupId: string, memberId: string, memberEpoch: number, instanceId: NullableString, rackId: NullableString, rebalanceTimeoutMs: number, subscribedTopicNames: string[] | null, _subscribedTopicRegex: NullableString, serverAssignor: NullableString, topicPartitions: ConsumerGroupHeartbeatRequestTopicPartition[]): Writer;
26
26
  export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): ConsumerGroupHeartbeatResponse;
27
- export declare const api: import("../definitions.ts").API<[groupId: string, memberId: string, memberEpoch: number, instanceId: NullableString, rackId: NullableString, rebalanceTimeoutMs: number, subscribedTopicNames: string[] | null, serverAssignor: NullableString, topicPartitions: ConsumerGroupHeartbeatRequestTopicPartition[]], ConsumerGroupHeartbeatResponse>;
27
+ export declare const api: import("../definitions.ts").API<[groupId: string, memberId: string, memberEpoch: number, instanceId: NullableString, rackId: NullableString, rebalanceTimeoutMs: number, subscribedTopicNames: string[] | null, _subscribedTopicRegex: NullableString, serverAssignor: NullableString, topicPartitions: ConsumerGroupHeartbeatRequestTopicPartition[]], ConsumerGroupHeartbeatResponse>;
@@ -15,7 +15,7 @@ import { createAPI } from "../definitions.js";
15
15
  topic_id => UUID
16
16
  partitions => INT32
17
17
  */
18
- export function createRequest(groupId, memberId, memberEpoch, instanceId, rackId, rebalanceTimeoutMs, subscribedTopicNames, serverAssignor, topicPartitions) {
18
+ export function createRequest(groupId, memberId, memberEpoch, instanceId, rackId, rebalanceTimeoutMs, subscribedTopicNames, _subscribedTopicRegex, serverAssignor, topicPartitions) {
19
19
  return Writer.create()
20
20
  .appendString(groupId)
21
21
  .appendString(memberId)
@@ -0,0 +1,27 @@
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 ConsumerGroupHeartbeatRequestTopicPartition {
5
+ topicId: string;
6
+ partitions: number[];
7
+ }
8
+ export type ConsumerGroupHeartbeatRequest = Parameters<typeof createRequest>;
9
+ export interface ConsumerGroupHeartbeatResponseAssignmentTopicPartition {
10
+ topicId: string;
11
+ partitions: number[];
12
+ }
13
+ export interface ConsumerGroupHeartbeatResponseAssignment {
14
+ topicPartitions: ConsumerGroupHeartbeatResponseAssignmentTopicPartition[];
15
+ }
16
+ export interface ConsumerGroupHeartbeatResponse {
17
+ throttleTimeMs: number;
18
+ errorCode: number;
19
+ errorMessage: NullableString;
20
+ memberId: NullableString;
21
+ memberEpoch: number;
22
+ heartbeatIntervalMs: number;
23
+ assignment: ConsumerGroupHeartbeatResponseAssignment | null;
24
+ }
25
+ export declare function createRequest(groupId: string, memberId: string, memberEpoch: number, instanceId: NullableString, rackId: NullableString, rebalanceTimeoutMs: number, subscribedTopicNames: string[] | null, subscribedTopicRegex: NullableString, serverAssignor: NullableString, topicPartitions: ConsumerGroupHeartbeatRequestTopicPartition[]): Writer;
26
+ export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): ConsumerGroupHeartbeatResponse;
27
+ export declare const api: import("../definitions.ts").API<[groupId: string, memberId: string, memberEpoch: number, instanceId: NullableString, rackId: NullableString, rebalanceTimeoutMs: number, subscribedTopicNames: string[] | null, subscribedTopicRegex: NullableString, serverAssignor: NullableString, topicPartitions: ConsumerGroupHeartbeatRequestTopicPartition[]], ConsumerGroupHeartbeatResponse>;
@@ -0,0 +1,70 @@
1
+ import { ResponseError } from "../../errors.js";
2
+ import { Writer } from "../../protocol/writer.js";
3
+ import { createAPI } from "../definitions.js";
4
+ /*
5
+ ConsumerGroupHeartbeat Request (Version: 1) => group_id member_id member_epoch instance_id rack_id rebalance_timeout_ms [subscribed_topic_names] subscribed_topic_regex server_assignor [topic_partitions] TAG_BUFFER
6
+ group_id => COMPACT_STRING
7
+ member_id => COMPACT_STRING
8
+ member_epoch => INT32
9
+ instance_id => COMPACT_NULLABLE_STRING
10
+ rack_id => COMPACT_NULLABLE_STRING
11
+ rebalance_timeout_ms => INT32
12
+ subscribed_topic_names => COMPACT_STRING
13
+ subscribed_topic_regex => COMPACT_NULLABLE_STRING
14
+ server_assignor => COMPACT_NULLABLE_STRING
15
+ topic_partitions => topic_id [partitions] TAG_BUFFER
16
+ topic_id => UUID
17
+ partitions => INT32
18
+ */
19
+ export function createRequest(groupId, memberId, memberEpoch, instanceId, rackId, rebalanceTimeoutMs, subscribedTopicNames, subscribedTopicRegex, serverAssignor, topicPartitions) {
20
+ return Writer.create()
21
+ .appendString(groupId)
22
+ .appendString(memberId)
23
+ .appendInt32(memberEpoch)
24
+ .appendString(instanceId)
25
+ .appendString(rackId)
26
+ .appendInt32(rebalanceTimeoutMs)
27
+ .appendArray(subscribedTopicNames, (w, t) => w.appendString(t), true, false)
28
+ .appendString(subscribedTopicRegex)
29
+ .appendString(serverAssignor)
30
+ .appendArray(topicPartitions, (w, t) => {
31
+ return w.appendUUID(t.topicId).appendArray(t.partitions, (w, p) => w.appendInt32(p), true, false);
32
+ })
33
+ .appendTaggedFields();
34
+ }
35
+ /*
36
+ ConsumerGroupHeartbeat Response (Version: 1) => throttle_time_ms error_code error_message member_id member_epoch heartbeat_interval_ms assignment TAG_BUFFER
37
+ throttle_time_ms => INT32
38
+ error_code => INT16
39
+ error_message => COMPACT_NULLABLE_STRING
40
+ member_id => COMPACT_NULLABLE_STRING
41
+ member_epoch => INT32
42
+ heartbeat_interval_ms => INT32
43
+ assignment => [topic_partitions] TAG_BUFFER
44
+ topic_partitions => topic_id [partitions] TAG_BUFFER
45
+ topic_id => UUID
46
+ partitions => INT32
47
+ */
48
+ export function parseResponse(_correlationId, apiKey, apiVersion, reader) {
49
+ const response = {
50
+ throttleTimeMs: reader.readInt32(),
51
+ errorCode: reader.readInt16(),
52
+ errorMessage: reader.readNullableString(),
53
+ memberId: reader.readNullableString(),
54
+ memberEpoch: reader.readInt32(),
55
+ heartbeatIntervalMs: reader.readInt32(),
56
+ assignment: reader.readNullableStruct(() => ({
57
+ topicPartitions: reader.readArray(r => {
58
+ return {
59
+ topicId: r.readUUID(),
60
+ partitions: r.readArray(r => r.readInt32(), true, false)
61
+ };
62
+ })
63
+ }))
64
+ };
65
+ if (response.errorCode !== 0) {
66
+ throw new ResponseError(apiKey, apiVersion, { '/': [response.errorCode, response.errorMessage] }, response);
67
+ }
68
+ return response;
69
+ }
70
+ export const api = createAPI(68, 1, createRequest, parseResponse);
@@ -1,4 +1,5 @@
1
1
  export * as consumerGroupHeartbeatV0 from './consumer-group-heartbeat-v0.ts';
2
+ export * as consumerGroupHeartbeatV1 from './consumer-group-heartbeat-v1.ts';
2
3
  export * as fetchV12 from './fetch-v12.ts';
3
4
  export * as fetchV13 from './fetch-v13.ts';
4
5
  export * as fetchV14 from './fetch-v14.ts';
@@ -1,4 +1,5 @@
1
1
  export * as consumerGroupHeartbeatV0 from "./consumer-group-heartbeat-v0.js";
2
+ export * as consumerGroupHeartbeatV1 from "./consumer-group-heartbeat-v1.js";
2
3
  export * as fetchV12 from "./fetch-v12.js";
3
4
  export * as fetchV13 from "./fetch-v13.js";
4
5
  export * as fetchV14 from "./fetch-v14.js";
@@ -1,3 +1,4 @@
1
+ import { randomUUID } from 'node:crypto';
1
2
  import { createPromisifiedCallback, kCallbackPromise, runConcurrentCallbacks } from "../../apis/callbacks.js";
2
3
  import { FetchIsolationLevels, FindCoordinatorKeyTypes } from "../../apis/enumerations.js";
3
4
  import { consumerCommitsChannel, consumerConsumesChannel, consumerFetchesChannel, consumerGroupChannel, consumerHeartbeatChannel, consumerLagChannel, consumerOffsetsChannel, createDiagnosticContext } from "../../diagnostic.js";
@@ -700,8 +701,9 @@ export class Consumer extends Base {
700
701
  groupCallback(error);
701
702
  return;
702
703
  }
703
- api(connection, this.groupId, this.memberId || '', this.#memberEpoch, this.groupInstanceId, null, // rackId
704
- options.rebalanceTimeout, this.topics.current, this.#groupRemoteAssignor, this.#assignments, groupCallback);
704
+ const memberId = this.#getConsumerGroupHeartbeatMemberId(api.version);
705
+ api(connection, this.groupId, memberId, this.#memberEpoch, this.groupInstanceId, null, // rackId
706
+ options.rebalanceTimeout, this.topics.current, null, this.#groupRemoteAssignor, this.#assignments, groupCallback);
705
707
  });
706
708
  }, (error, response) => {
707
709
  if (this[kClosed]) {
@@ -849,10 +851,12 @@ export class Consumer extends Base {
849
851
  groupCallback(error);
850
852
  return;
851
853
  }
852
- api(connection, this.groupId, this.memberId, -1, // memberEpoch = -1 signals leave
854
+ const memberId = this.#getConsumerGroupHeartbeatMemberId(api.version);
855
+ api(connection, this.groupId, memberId, -1, // memberEpoch = -1 signals leave
853
856
  this.groupInstanceId, null, // rackId
854
857
  0, // rebalanceTimeout
855
858
  [], // subscribedTopicNames
859
+ null, // subscribedTopicRegex
856
860
  this.#groupRemoteAssignor, [], // topicPartitions
857
861
  groupCallback);
858
862
  });
@@ -865,6 +869,16 @@ export class Consumer extends Base {
865
869
  callback(null);
866
870
  });
867
871
  }
872
+ #getConsumerGroupHeartbeatMemberId(apiVersion) {
873
+ if (this.memberId) {
874
+ return this.memberId;
875
+ }
876
+ if (apiVersion >= 1) {
877
+ this.memberId = randomUUID();
878
+ return this.memberId;
879
+ }
880
+ return '';
881
+ }
868
882
  #performConsume(options, trackTopics, callback) {
869
883
  // Subscribe all topics
870
884
  let joinNeeded = this.memberId === null;
@@ -708,6 +708,10 @@ export class MessagesStream extends Readable {
708
708
  }
709
709
  }
710
710
  }
711
+ if (requests.length === 0) {
712
+ this.#pushRecords(metadata, topicIds, response, requestedOffsets);
713
+ return;
714
+ }
711
715
  runAsyncSeries((request, cb) => {
712
716
  const [data, type, message] = request;
713
717
  const result = hook(data, type, message, cb);
@@ -726,6 +726,10 @@ export class Producer extends Base {
726
726
  }
727
727
  }
728
728
  }
729
+ if (requests.length === 0) {
730
+ this.#send(options, callback);
731
+ return;
732
+ }
729
733
  runAsyncSeries((request, cb) => {
730
734
  const [data, type, message] = request;
731
735
  const result = hook(data, type, message, cb);
@@ -1,4 +1,8 @@
1
1
  export function runAsyncSeries(operation, collection, index, callback) {
2
+ if (collection.length === 0 || index >= collection.length) {
3
+ callback(null);
4
+ return;
5
+ }
2
6
  operation(collection[index], error => {
3
7
  if (error) {
4
8
  callback(error);
@@ -25,6 +25,6 @@ export interface AlterPartitionReassignmentsResponse {
25
25
  errorMessage: NullableString;
26
26
  responses: AlterPartitionReassignmentsResponseResponse[];
27
27
  }
28
- export declare function createRequest(timeoutMs: number, topics: AlterPartitionReassignmentsRequestTopic[]): Writer;
28
+ export declare function createRequest(timeoutMs: number, _allowReplicationFactorChange: boolean, topics: AlterPartitionReassignmentsRequestTopic[]): Writer;
29
29
  export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): AlterPartitionReassignmentsResponse;
30
- export declare const api: import("../definitions").API<[timeoutMs: number, topics: AlterPartitionReassignmentsRequestTopic[]], AlterPartitionReassignmentsResponse>;
30
+ export declare const api: import("../definitions").API<[timeoutMs: number, _allowReplicationFactorChange: boolean, topics: AlterPartitionReassignmentsRequestTopic[]], AlterPartitionReassignmentsResponse>;
@@ -0,0 +1,30 @@
1
+ import { type NullableString } from "../../protocol/definitions";
2
+ import { type Reader } from "../../protocol/reader";
3
+ import { Writer } from "../../protocol/writer";
4
+ export interface AlterPartitionReassignmentsRequestPartition {
5
+ partitionIndex: number;
6
+ replicas: number[];
7
+ }
8
+ export interface AlterPartitionReassignmentsRequestTopic {
9
+ name: string;
10
+ partitions: AlterPartitionReassignmentsRequestPartition[];
11
+ }
12
+ export type AlterPartitionReassignmentsRequest = Parameters<typeof createRequest>;
13
+ export interface AlterPartitionReassignmentsResponsePartition {
14
+ partitionIndex: number;
15
+ errorCode: number;
16
+ errorMessage: NullableString;
17
+ }
18
+ export interface AlterPartitionReassignmentsResponseResponse {
19
+ name: string;
20
+ partitions: AlterPartitionReassignmentsResponsePartition[];
21
+ }
22
+ export interface AlterPartitionReassignmentsResponse {
23
+ throttleTimeMs: number;
24
+ errorCode: number;
25
+ errorMessage: NullableString;
26
+ responses: AlterPartitionReassignmentsResponseResponse[];
27
+ }
28
+ export declare function createRequest(timeoutMs: number, allowReplicationFactorChange: boolean, topics: AlterPartitionReassignmentsRequestTopic[]): Writer;
29
+ export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): AlterPartitionReassignmentsResponse;
30
+ export declare const api: import("../definitions").API<[timeoutMs: number, allowReplicationFactorChange: boolean, topics: AlterPartitionReassignmentsRequestTopic[]], AlterPartitionReassignmentsResponse>;
@@ -1,6 +1,7 @@
1
1
  export * as alterClientQuotasV1 from "./alter-client-quotas-v1";
2
2
  export * as alterConfigsV2 from "./alter-configs-v2";
3
3
  export * as alterPartitionReassignmentsV0 from "./alter-partition-reassignments-v0";
4
+ export * as alterPartitionReassignmentsV1 from "./alter-partition-reassignments-v1";
4
5
  export * as alterPartitionV3 from "./alter-partition-v3";
5
6
  export * as alterReplicaLogDirsV2 from "./alter-replica-log-dirs-v2";
6
7
  export * as alterUserScramCredentialsV0 from "./alter-user-scram-credentials-v0";
@@ -43,6 +44,7 @@ export * as listGroupsV5 from "./list-groups-v5";
43
44
  export * as listPartitionReassignmentsV0 from "./list-partition-reassignments-v0";
44
45
  export * as listTransactionsV0 from "./list-transactions-v0";
45
46
  export * as listTransactionsV1 from "./list-transactions-v1";
47
+ export * as listTransactionsV2 from "./list-transactions-v2";
46
48
  export * as offsetDeleteV0 from "./offset-delete-v0";
47
49
  export * as renewDelegationTokenV2 from "./renew-delegation-token-v2";
48
50
  export * as unregisterBrokerV0 from "./unregister-broker-v0";
@@ -1,3 +1,4 @@
1
+ import { type NullableString } from "../../protocol/definitions";
1
2
  import { type Reader } from "../../protocol/reader";
2
3
  import { Writer } from "../../protocol/writer";
3
4
  import { type TransactionState } from "../enumerations";
@@ -13,6 +14,6 @@ export interface ListTransactionsResponse {
13
14
  unknownStateFilters: string[];
14
15
  transactionStates: ListTransactionsResponseTransactionState[];
15
16
  }
16
- export declare function createRequest(stateFilters: TransactionState[], producerIdFilters: bigint[], _durationFilter: bigint): Writer;
17
+ export declare function createRequest(stateFilters: TransactionState[], producerIdFilters: bigint[], _durationFilter: bigint, _transactionalIdPattern: NullableString): Writer;
17
18
  export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): ListTransactionsResponse;
18
- export declare const api: import("../definitions").API<[stateFilters: ("EMPTY" | "ONGOING" | "PREPARE_ABORT" | "COMMITTING" | "ABORTING" | "COMPLETE_COMMIT" | "COMPLETE_ABORT")[], producerIdFilters: bigint[], _durationFilter: bigint], ListTransactionsResponse>;
19
+ export declare const api: import("../definitions").API<[stateFilters: ("EMPTY" | "ONGOING" | "PREPARE_ABORT" | "COMMITTING" | "ABORTING" | "COMPLETE_COMMIT" | "COMPLETE_ABORT")[], producerIdFilters: bigint[], _durationFilter: bigint, _transactionalIdPattern: NullableString], ListTransactionsResponse>;
@@ -1,3 +1,4 @@
1
+ import { type NullableString } from "../../protocol/definitions";
1
2
  import { type Reader } from "../../protocol/reader";
2
3
  import { Writer } from "../../protocol/writer";
3
4
  import { type TransactionState } from "../enumerations";
@@ -13,6 +14,6 @@ export interface ListTransactionsResponse {
13
14
  unknownStateFilters: string[];
14
15
  transactionStates: ListTransactionsResponseTransactionState[];
15
16
  }
16
- export declare function createRequest(stateFilters: TransactionState[], producerIdFilters: bigint[], durationFilter: bigint): Writer;
17
+ export declare function createRequest(stateFilters: TransactionState[], producerIdFilters: bigint[], durationFilter: bigint, _transactionalIdPattern: NullableString): Writer;
17
18
  export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): ListTransactionsResponse;
18
- export declare const api: import("../definitions").API<[stateFilters: ("EMPTY" | "ONGOING" | "PREPARE_ABORT" | "COMMITTING" | "ABORTING" | "COMPLETE_COMMIT" | "COMPLETE_ABORT")[], producerIdFilters: bigint[], durationFilter: bigint], ListTransactionsResponse>;
19
+ export declare const api: import("../definitions").API<[stateFilters: ("EMPTY" | "ONGOING" | "PREPARE_ABORT" | "COMMITTING" | "ABORTING" | "COMPLETE_COMMIT" | "COMPLETE_ABORT")[], producerIdFilters: bigint[], durationFilter: bigint, _transactionalIdPattern: NullableString], ListTransactionsResponse>;
@@ -0,0 +1,20 @@
1
+ import { type NullableString } from "../../protocol/definitions";
2
+ import { type Reader } from "../../protocol/reader";
3
+ import { Writer } from "../../protocol/writer";
4
+ import { type TransactionState } from "../enumerations";
5
+ export type ListTransactionsRequest = Parameters<typeof createRequest>;
6
+ export interface ListTransactionsResponseTransactionState {
7
+ transactionalId: string;
8
+ producerId: bigint;
9
+ transactionState: string;
10
+ }
11
+ export interface ListTransactionsResponse {
12
+ throttleTimeMs: number;
13
+ errorCode: number;
14
+ errorMessage: NullableString;
15
+ unknownStateFilters: string[];
16
+ transactionStates: ListTransactionsResponseTransactionState[];
17
+ }
18
+ export declare function createRequest(stateFilters: TransactionState[], producerIdFilters: bigint[], durationFilter: bigint, transactionalIdPattern: NullableString): Writer;
19
+ export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): ListTransactionsResponse;
20
+ export declare const api: import("../definitions").API<[stateFilters: ("EMPTY" | "ONGOING" | "PREPARE_ABORT" | "COMMITTING" | "ABORTING" | "COMPLETE_COMMIT" | "COMPLETE_ABORT")[], producerIdFilters: bigint[], durationFilter: bigint, transactionalIdPattern: NullableString], ListTransactionsResponse>;
@@ -22,6 +22,6 @@ export interface ConsumerGroupHeartbeatResponse {
22
22
  heartbeatIntervalMs: number;
23
23
  assignment: ConsumerGroupHeartbeatResponseAssignment | null;
24
24
  }
25
- export declare function createRequest(groupId: string, memberId: string, memberEpoch: number, instanceId: NullableString, rackId: NullableString, rebalanceTimeoutMs: number, subscribedTopicNames: string[] | null, serverAssignor: NullableString, topicPartitions: ConsumerGroupHeartbeatRequestTopicPartition[]): Writer;
25
+ export declare function createRequest(groupId: string, memberId: string, memberEpoch: number, instanceId: NullableString, rackId: NullableString, rebalanceTimeoutMs: number, subscribedTopicNames: string[] | null, _subscribedTopicRegex: NullableString, serverAssignor: NullableString, topicPartitions: ConsumerGroupHeartbeatRequestTopicPartition[]): Writer;
26
26
  export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): ConsumerGroupHeartbeatResponse;
27
- export declare const api: import("../definitions").API<[groupId: string, memberId: string, memberEpoch: number, instanceId: NullableString, rackId: NullableString, rebalanceTimeoutMs: number, subscribedTopicNames: string[] | null, serverAssignor: NullableString, topicPartitions: ConsumerGroupHeartbeatRequestTopicPartition[]], ConsumerGroupHeartbeatResponse>;
27
+ export declare const api: import("../definitions").API<[groupId: string, memberId: string, memberEpoch: number, instanceId: NullableString, rackId: NullableString, rebalanceTimeoutMs: number, subscribedTopicNames: string[] | null, _subscribedTopicRegex: NullableString, serverAssignor: NullableString, topicPartitions: ConsumerGroupHeartbeatRequestTopicPartition[]], ConsumerGroupHeartbeatResponse>;
@@ -0,0 +1,27 @@
1
+ import { type NullableString } from "../../protocol/definitions";
2
+ import { type Reader } from "../../protocol/reader";
3
+ import { Writer } from "../../protocol/writer";
4
+ export interface ConsumerGroupHeartbeatRequestTopicPartition {
5
+ topicId: string;
6
+ partitions: number[];
7
+ }
8
+ export type ConsumerGroupHeartbeatRequest = Parameters<typeof createRequest>;
9
+ export interface ConsumerGroupHeartbeatResponseAssignmentTopicPartition {
10
+ topicId: string;
11
+ partitions: number[];
12
+ }
13
+ export interface ConsumerGroupHeartbeatResponseAssignment {
14
+ topicPartitions: ConsumerGroupHeartbeatResponseAssignmentTopicPartition[];
15
+ }
16
+ export interface ConsumerGroupHeartbeatResponse {
17
+ throttleTimeMs: number;
18
+ errorCode: number;
19
+ errorMessage: NullableString;
20
+ memberId: NullableString;
21
+ memberEpoch: number;
22
+ heartbeatIntervalMs: number;
23
+ assignment: ConsumerGroupHeartbeatResponseAssignment | null;
24
+ }
25
+ export declare function createRequest(groupId: string, memberId: string, memberEpoch: number, instanceId: NullableString, rackId: NullableString, rebalanceTimeoutMs: number, subscribedTopicNames: string[] | null, subscribedTopicRegex: NullableString, serverAssignor: NullableString, topicPartitions: ConsumerGroupHeartbeatRequestTopicPartition[]): Writer;
26
+ export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): ConsumerGroupHeartbeatResponse;
27
+ export declare const api: import("../definitions").API<[groupId: string, memberId: string, memberEpoch: number, instanceId: NullableString, rackId: NullableString, rebalanceTimeoutMs: number, subscribedTopicNames: string[] | null, subscribedTopicRegex: NullableString, serverAssignor: NullableString, topicPartitions: ConsumerGroupHeartbeatRequestTopicPartition[]], ConsumerGroupHeartbeatResponse>;
@@ -1,4 +1,5 @@
1
1
  export * as consumerGroupHeartbeatV0 from "./consumer-group-heartbeat-v0";
2
+ export * as consumerGroupHeartbeatV1 from "./consumer-group-heartbeat-v1";
2
3
  export * as fetchV12 from "./fetch-v12";
3
4
  export * as fetchV13 from "./fetch-v13";
4
5
  export * as fetchV14 from "./fetch-v14";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = "@platformatic/kafka";
2
- export const version = "1.29.0";
2
+ export const version = "1.30.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/kafka",
3
- "version": "1.29.0",
3
+ "version": "1.30.0",
4
4
  "description": "Modern and performant client for Apache Kafka",
5
5
  "homepage": "https://github.com/platformatic/kafka",
6
6
  "author": "Platformatic Inc. <oss@platformatic.dev> (https://platformatic.dev)",