@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
@@ -1,10 +1,10 @@
1
1
  import { Readable } from 'node:stream';
2
2
  import { type CallbackWithPromise } from '../../apis/callbacks.ts';
3
- import { type ConnectionPool } from '../../network/connection-pool.ts';
3
+ import type { ConnectionPool } from '../../network/connection-pool.ts';
4
4
  import { type Message } from '../../protocol/records.ts';
5
5
  import { kAutocommit, kInstance, kRefreshOffsetsAndFetch } from '../../symbols.ts';
6
6
  import { kConnections, kInspect } from '../base/base.ts';
7
- import { type Consumer } from './consumer.ts';
7
+ import type { Consumer } from './consumer.ts';
8
8
  import { type CommitOptionsPartition, type ConsumeOptions } from './types.ts';
9
9
  export declare function noopDeserializer(data?: Buffer): Buffer | undefined;
10
10
  export declare function defaultCorruptedMessageHandler(): boolean;
@@ -448,10 +448,10 @@ export class MessagesStream extends Readable {
448
448
  try {
449
449
  const headers = new Map();
450
450
  for (const [headerKey, headerValue] of record.headers) {
451
- headers.set(headerKeyDeserializer(headerKey, messageToConsume), headerValueDeserializer(headerValue, messageToConsume));
451
+ headers.set(headerKeyDeserializer(headerKey ?? undefined, messageToConsume), headerValueDeserializer(headerValue ?? undefined, messageToConsume));
452
452
  }
453
- const key = keyDeserializer(record.key, headers, messageToConsume);
454
- const value = valueDeserializer(record.value, headers, messageToConsume);
453
+ const key = keyDeserializer(record.key ?? undefined, headers, messageToConsume);
454
+ const value = valueDeserializer(record.value ?? undefined, headers, messageToConsume);
455
455
  this.#metricsConsumedMessages?.inc();
456
456
  const message = {
457
457
  key,
@@ -6,7 +6,7 @@ import { UserError } from "../../errors.js";
6
6
  import { murmur2 } from "../../protocol/murmur2.js";
7
7
  import { runAsyncSeries } from "../../registries/abstract.js";
8
8
  import { kInstance, kTransaction, kTransactionAddOffsets, kTransactionAddPartitions, kTransactionCancel, kTransactionCommitOffset, kTransactionEnd, kTransactionFindCoordinator, kTransactionPrepare } from "../../symbols.js";
9
- import { NumericMap } from "../../utils.js";
9
+ import { emitExperimentalApiWarning, NumericMap } from "../../utils.js";
10
10
  import { Base, kAfterCreate, kCheckNotClosed, kClosed, kGetApi, kGetBootstrapConnection, kGetConnection, kMetadata, kOptions, kPerformDeduplicated, kPerformWithRetry, kPrometheus, kValidateOptions } from "../base/base.js";
11
11
  import { ensureMetric } from "../metrics.js";
12
12
  import { produceOptionsValidator, producerOptionsValidator, sendOptionsValidator } from "./options.js";
@@ -42,6 +42,12 @@ export class Producer extends Base {
42
42
  options.repeatOnStaleMetadata ??= true;
43
43
  super(options);
44
44
  this[kValidateOptions](options, producerOptionsValidator, '/options');
45
+ if (options.beforeSerialization) {
46
+ emitExperimentalApiWarning('beforeSerialization');
47
+ }
48
+ if (options.registry) {
49
+ emitExperimentalApiWarning('registry (Confluent Schema Registry integration)');
50
+ }
45
51
  let serializers = options.serializers;
46
52
  if (options.registry) {
47
53
  if (options.beforeSerialization) {
package/dist/errors.d.ts CHANGED
@@ -39,10 +39,6 @@ export declare class ProtocolError extends GenericError {
39
39
  static code: ErrorCode;
40
40
  constructor(codeOrId: string | number, serverErrorMessage?: NullableString, properties?: ErrorProperties, response?: unknown);
41
41
  }
42
- export declare class OutOfBoundsError extends GenericError {
43
- static code: ErrorCode;
44
- constructor(message: string, properties?: ErrorProperties);
45
- }
46
42
  export declare class ResponseError extends MultipleErrors {
47
43
  static code: ErrorCode;
48
44
  constructor(apiName: number, apiVersion: number, errors: Record<string, [number, NullableString]>, response: unknown, properties?: ErrorProperties);
package/dist/errors.js CHANGED
@@ -121,12 +121,6 @@ export class ProtocolError extends GenericError {
121
121
  });
122
122
  }
123
123
  }
124
- export class OutOfBoundsError extends GenericError {
125
- static code = 'PLT_KFK_OUT_OF_BOUNDS';
126
- constructor(message, properties = {}) {
127
- super(OutOfBoundsError.code, message, { isOut: true, ...properties });
128
- }
129
- }
130
124
  export class ResponseError extends MultipleErrors {
131
125
  static code = 'PLT_KFK_RESPONSE';
132
126
  constructor(apiName, apiVersion, errors, response, properties = {}) {
@@ -1,3 +1,4 @@
1
+ import { DynamicBuffer } from '@platformatic/dynamic-buffer';
1
2
  import fastq from 'fastq';
2
3
  import { createConnection } from 'node:net';
3
4
  import { connect as createTLSConnection } from 'node:tls';
@@ -9,7 +10,6 @@ import { AuthenticationError, NetworkError, TimeoutError, UnexpectedCorrelationI
9
10
  import { TypedEventEmitter } from "../events.js";
10
11
  import { protocolAPIsById } from "../protocol/apis.js";
11
12
  import { EMPTY_OR_SINGLE_COMPACT_LENGTH_SIZE, INT32_SIZE } from "../protocol/definitions.js";
12
- import { DynamicBuffer } from "../protocol/dynamic-buffer.js";
13
13
  import { saslOAuthBearer, saslPlain, saslScramSha } from "../protocol/index.js";
14
14
  import { Reader } from "../protocol/reader.js";
15
15
  import { defaultCrypto } from "../protocol/sasl/scram-sha.js";
@@ -1,4 +1,4 @@
1
- import { DynamicBuffer } from './dynamic-buffer.ts';
1
+ import { DynamicBuffer } from '@platformatic/dynamic-buffer';
2
2
  export type SyncCompressionPhase = (data: Buffer | DynamicBuffer) => Buffer;
3
3
  export type CompressionOperation = (data: Buffer) => Buffer;
4
4
  export interface CompressionAlgorithmSpecification {
@@ -1,8 +1,7 @@
1
- import { createRequire } from 'node:module';
1
+ import { DynamicBuffer } from '@platformatic/dynamic-buffer';
2
+ import { lz4Compress, lz4Decompress, snappyCompress, snappyDecompress } from '@platformatic/wasm-utils';
2
3
  import zlib from 'node:zlib';
3
4
  import { UnsupportedCompressionError } from "../errors.js";
4
- import { DynamicBuffer } from "./dynamic-buffer.js";
5
- const require = createRequire(import.meta.url);
6
5
  const { zstdCompressSync, zstdDecompressSync, gzipSync, gunzipSync } = zlib;
7
6
  export const CompressionAlgorithms = {
8
7
  NONE: 'none',
@@ -13,34 +12,12 @@ export const CompressionAlgorithms = {
13
12
  };
14
13
  export const allowedCompressionsAlgorithms = Object.values(CompressionAlgorithms);
15
14
  function ensureBuffer(data) {
16
- return DynamicBuffer.isDynamicBuffer(data) ? data.slice() : data;
17
- }
18
- let snappyCompressSync;
19
- let snappyDecompressSync;
20
- let lz4CompressFrameSync;
21
- let lz4DecompressFrameSync;
22
- function loadSnappy() {
23
- try {
24
- const snappy = require('snappy');
25
- snappyCompressSync = snappy.compressSync;
26
- snappyDecompressSync = snappy.uncompressSync;
27
- /* c8 ignore next 5 - In tests snappy is always available */
28
- }
29
- catch (e) {
30
- throw new UnsupportedCompressionError('Cannot load snappy module, which is an optionalDependency. Please check your local installation.');
31
- }
32
- }
33
- function loadLZ4() {
34
- try {
35
- const lz4 = require('lz4-napi');
36
- lz4CompressFrameSync = lz4.compressFrameSync;
37
- lz4DecompressFrameSync = lz4.decompressFrameSync;
38
- /* c8 ignore next 5 - In tests lz4-napi is always available */
39
- }
40
- catch (e) {
41
- throw new UnsupportedCompressionError('Cannot load lz4-napi module, which is an optionalDependency. Please check your local installation.');
42
- }
15
+ return DynamicBuffer.isDynamicBuffer(data) ? data.buffer : data;
43
16
  }
17
+ const snappyCompressSync = snappyCompress;
18
+ const snappyDecompressSync = snappyDecompress;
19
+ const lz4CompressFrameSync = lz4Compress;
20
+ const lz4DecompressFrameSync = lz4Decompress;
44
21
  export const compressionsAlgorithms = {
45
22
  /* c8 ignore next 8 - 'none' is actually never used but this is to please Typescript */
46
23
  none: {
@@ -65,17 +42,9 @@ export const compressionsAlgorithms = {
65
42
  },
66
43
  snappy: {
67
44
  compressSync(data) {
68
- /* c8 ignore next 4 - In tests snappy is always available */
69
- if (!snappyCompressSync) {
70
- loadSnappy();
71
- }
72
45
  return snappyCompressSync(ensureBuffer(data));
73
46
  },
74
47
  decompressSync(data) {
75
- /* c8 ignore next 4 - In tests snappy is always available */
76
- if (!snappyDecompressSync) {
77
- loadSnappy();
78
- }
79
48
  return snappyDecompressSync(ensureBuffer(data));
80
49
  },
81
50
  bitmask: 2,
@@ -83,17 +52,9 @@ export const compressionsAlgorithms = {
83
52
  },
84
53
  lz4: {
85
54
  compressSync(data) {
86
- /* c8 ignore next 4 - In tests lz4-napi is always available */
87
- if (!lz4CompressFrameSync) {
88
- loadLZ4();
89
- }
90
55
  return lz4CompressFrameSync(ensureBuffer(data));
91
56
  },
92
57
  decompressSync(data) {
93
- /* c8 ignore next 4 - In tests lz4-napi is always available */
94
- if (!lz4DecompressFrameSync) {
95
- loadLZ4();
96
- }
97
58
  return lz4DecompressFrameSync(ensureBuffer(data));
98
59
  },
99
60
  bitmask: 3,
@@ -1,4 +1,4 @@
1
- import { DynamicBuffer } from './dynamic-buffer.ts';
1
+ import { DynamicBuffer } from '@platformatic/dynamic-buffer';
2
2
  export declare function loadNativeCRC32C(): typeof jsCRC32C | null;
3
3
  export declare function jsCRC32C(data: Buffer | Uint8Array | DynamicBuffer): number;
4
4
  export declare const crc32c: typeof jsCRC32C;
@@ -1,6 +1,7 @@
1
- // Based on the work from: https://github.com/tulios/kafkajs/blob/master/src/protocol/recordBatch/crc32C/crc32C.js
1
+ import { DynamicBuffer } from '@platformatic/dynamic-buffer';
2
+ import { crc32c as wasmCRC32C } from '@platformatic/wasm-utils';
2
3
  import { createRequire } from 'node:module';
3
- import { DynamicBuffer } from "./dynamic-buffer.js";
4
+ // Based on the work from: https://github.com/tulios/kafkajs/blob/master/src/protocol/recordBatch/crc32C/crc32C.js
4
5
  /* prettier-ignore */
5
6
  const CRC = [
6
7
  0x00000000, 0xf26b8303, 0xe13b70f7, 0x1350f3f4,
@@ -85,9 +86,7 @@ export function loadNativeCRC32C() {
85
86
  }
86
87
  }
87
88
  export function jsCRC32C(data) {
88
- const bytes = DynamicBuffer.isDynamicBuffer(data)
89
- ? data.buffer
90
- : new Uint8Array(data);
89
+ const bytes = DynamicBuffer.isDynamicBuffer(data) ? data.buffer : data;
91
90
  let crc = 0xffffffff;
92
91
  for (let i = 0, len = bytes.length; i < len; ++i) {
93
92
  crc = CRC[(crc ^ bytes[i]) & 0xff] ^ (crc >>> 8);
@@ -95,4 +94,4 @@ export function jsCRC32C(data) {
95
94
  return (crc ^ 0xffffffff) >>> 0;
96
95
  }
97
96
  /* c8 ignore next - Hard to test */
98
- export const crc32c = loadNativeCRC32C() ?? jsCRC32C;
97
+ export const crc32c = loadNativeCRC32C() ?? wasmCRC32C;
@@ -1,4 +1,4 @@
1
- import { type DynamicBuffer } from './dynamic-buffer.ts';
1
+ import { type DynamicBuffer } from '@platformatic/dynamic-buffer';
2
2
  export declare const INT8_SIZE = 1;
3
3
  export declare const INT16_SIZE = 2;
4
4
  export declare const INT32_SIZE = 4;
@@ -2,7 +2,6 @@ export * from './apis.ts';
2
2
  export * from './compression.ts';
3
3
  export * from './crc32c.ts';
4
4
  export * from './definitions.ts';
5
- export * from './dynamic-buffer.ts';
6
5
  export * from './errors.ts';
7
6
  export * from './murmur2.ts';
8
7
  export * from './reader.ts';
@@ -11,5 +10,4 @@ export * as saslOAuthBearer from './sasl/oauth-bearer.ts';
11
10
  export * as saslPlain from './sasl/plain.ts';
12
11
  export * as saslScramSha from './sasl/scram-sha.ts';
13
12
  export * as saslUtils from './sasl/utils.ts';
14
- export * from './varint.ts';
15
13
  export * from './writer.ts';
@@ -2,7 +2,6 @@ export * from "./apis.js";
2
2
  export * from "./compression.js";
3
3
  export * from "./crc32c.js";
4
4
  export * from "./definitions.js";
5
- export * from "./dynamic-buffer.js";
6
5
  export * from "./errors.js";
7
6
  export * from "./murmur2.js";
8
7
  export * from "./reader.js";
@@ -11,5 +10,4 @@ export * as saslOAuthBearer from "./sasl/oauth-bearer.js";
11
10
  export * as saslPlain from "./sasl/plain.js";
12
11
  export * as saslScramSha from "./sasl/scram-sha.js";
13
12
  export * as saslUtils from "./sasl/utils.js";
14
- export * from "./varint.js";
15
13
  export * from "./writer.js";
@@ -1,4 +1,4 @@
1
- import { DynamicBuffer } from './dynamic-buffer.ts';
1
+ import { DynamicBuffer } from '@platformatic/dynamic-buffer';
2
2
  import { Writer } from './writer.ts';
3
3
  export type EntryReader<OutputType> = (reader: Reader, index: number) => OutputType;
4
4
  declare const instanceIdentifier: unique symbol;
@@ -48,7 +48,7 @@ export declare class Reader {
48
48
  readUUID(): string;
49
49
  readNullableBytes(compact?: boolean): Buffer | null;
50
50
  readBytes(compact?: boolean): Buffer;
51
- readVarIntBytes(): Buffer;
51
+ readVarIntBytes(): Buffer | null;
52
52
  readNullableArray<OutputType>(reader: EntryReader<OutputType>, compact?: boolean, discardTrailingTaggedFields?: boolean): OutputType[] | null;
53
53
  readNullableMap<Key, Value>(reader: EntryReader<[Key, Value]>, compact?: boolean, discardTrailingTaggedFields?: boolean): Map<Key, Value> | null;
54
54
  readArray<OutputType>(reader: EntryReader<OutputType>, compact?: boolean, discardTrailingTaggedFields?: boolean): OutputType[];
@@ -1,5 +1,5 @@
1
+ import { DynamicBuffer } from '@platformatic/dynamic-buffer';
1
2
  import { EMPTY_BUFFER, INT16_SIZE, INT32_SIZE, INT64_SIZE, INT8_SIZE, UUID_SIZE } from "./definitions.js";
2
- import { DynamicBuffer } from "./dynamic-buffer.js";
3
3
  import { Writer } from "./writer.js";
4
4
  const instanceIdentifier = Symbol('plt.kafka.reader.instanceIdentifier');
5
5
  export class Reader {
@@ -214,9 +214,9 @@ export class Reader {
214
214
  return this.readNullableBytes(compact) || EMPTY_BUFFER;
215
215
  }
216
216
  readVarIntBytes() {
217
- let length = this.readVarInt();
217
+ const length = this.readVarInt();
218
218
  if (length === -1) {
219
- length = 0;
219
+ return null;
220
220
  }
221
221
  const value = this.buffer.slice(this.position, this.position + length);
222
222
  this.position += length;
@@ -1,4 +1,4 @@
1
- import { type NumericMap } from '../utils.ts';
1
+ import type { NumericMap } from '../utils.ts';
2
2
  import { type CompressionAlgorithmValue } from './compression.ts';
3
3
  import { type NullableString } from './definitions.ts';
4
4
  import { Reader } from './reader.ts';
@@ -64,9 +64,9 @@ export interface KafkaRecord {
64
64
  attributes: number;
65
65
  timestampDelta: bigint;
66
66
  offsetDelta: number;
67
- key: Buffer;
68
- value: Buffer;
69
- headers: [Buffer, Buffer][];
67
+ key: Buffer | null;
68
+ value: Buffer | null;
69
+ headers: [Buffer | null, Buffer | null][];
70
70
  }
71
71
  export interface MessageToConsume extends KafkaRecord {
72
72
  topic: string;
@@ -1,8 +1,8 @@
1
+ import { DynamicBuffer } from '@platformatic/dynamic-buffer';
1
2
  import { UnsupportedCompressionError } from "../errors.js";
2
3
  import { compressionsAlgorithms, compressionsAlgorithmsByBitmask } from "./compression.js";
3
4
  import { crc32c } from "./crc32c.js";
4
5
  import { INT32_SIZE, INT64_SIZE } from "./definitions.js";
5
- import { DynamicBuffer } from "./dynamic-buffer.js";
6
6
  import { Reader } from "./reader.js";
7
7
  import { Writer } from "./writer.js";
8
8
  export const CURRENT_RECORD_VERSION = 2;
@@ -1,5 +1,5 @@
1
+ import { DynamicBuffer } from '@platformatic/dynamic-buffer';
1
2
  import { type NullableString } from './definitions.ts';
2
- import { DynamicBuffer } from './dynamic-buffer.ts';
3
3
  export type ChildrenWriter = (w: Writer) => void;
4
4
  export type EntryWriter<InputType> = (writer: Writer, entry: InputType, index: number) => void;
5
5
  declare const instanceIdentifier: unique symbol;
@@ -1,6 +1,6 @@
1
+ import { DynamicBuffer } from '@platformatic/dynamic-buffer';
1
2
  import { humanize } from "../utils.js";
2
3
  import { EMPTY_TAGGED_FIELDS_BUFFER, EMPTY_UUID } from "./definitions.js";
3
- import { DynamicBuffer } from "./dynamic-buffer.js";
4
4
  const instanceIdentifier = Symbol('plt.kafka.writer.instanceIdentifier');
5
5
  export class Writer {
6
6
  context;
@@ -144,7 +144,7 @@ export class Writer {
144
144
  // Note that this does not follow the wire protocol specification and thus the length is not +1ed
145
145
  appendVarIntBytes(value) {
146
146
  if (value == null) {
147
- return this.appendVarInt(0);
147
+ return this.appendVarInt(-1);
148
148
  }
149
149
  this.appendVarInt(value.length);
150
150
  this.#buffer.append(value);
@@ -0,0 +1,16 @@
1
+ import { type NullableString } from "../../protocol/definitions";
2
+ import { type Reader } from "../../protocol/reader";
3
+ import { Writer } from "../../protocol/writer";
4
+ import { type Acl } from "../types";
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").API<[creations: Acl[]], CreateAclsResponse>;
@@ -0,0 +1,21 @@
1
+ import { type NullableString } from "../../protocol/definitions";
2
+ import { type Reader } from "../../protocol/reader";
3
+ import { Writer } from "../../protocol/writer";
4
+ import { type Acl, type AclFilter } from "../types";
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").API<[filters: AclFilter[]], DeleteAclsResponse>;
@@ -0,0 +1,17 @@
1
+ import { type NullableString } from "../../protocol/definitions";
2
+ import { type Reader } from "../../protocol/reader";
3
+ import { Writer } from "../../protocol/writer";
4
+ import { type AclPermission, type AclTarget, type AclFilter } from "../types";
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").API<[filter: AclFilter], DescribeAclsResponse>;
@@ -0,0 +1,23 @@
1
+ import { type NullableString } from "../../protocol/definitions";
2
+ import { type Reader } from "../../protocol/reader";
3
+ import { Writer } from "../../protocol/writer";
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").API<[includeClusterAuthorizedOperations: boolean], DescribeClusterResponse>;
@@ -0,0 +1,32 @@
1
+ import { type Reader } from "../../protocol/reader";
2
+ import { Writer } from "../../protocol/writer";
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").API<[topics: DescribeLogDirsRequestTopic[]], DescribeLogDirsResponse>;
@@ -0,0 +1,32 @@
1
+ import { type Reader } from "../../protocol/reader";
2
+ import { Writer } from "../../protocol/writer";
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").API<[topics: DescribeLogDirsRequestTopic[]], DescribeLogDirsResponse>;
@@ -5,24 +5,30 @@ export * as alterPartitionV3 from "./alter-partition-v3";
5
5
  export * as alterReplicaLogDirsV2 from "./alter-replica-log-dirs-v2";
6
6
  export * as alterUserScramCredentialsV0 from "./alter-user-scram-credentials-v0";
7
7
  export * as consumerGroupDescribeV0 from "./consumer-group-describe-v0";
8
+ export * as createAclsV2 from "./create-acls-v2";
8
9
  export * as createAclsV3 from "./create-acls-v3";
9
10
  export * as createDelegationTokenV3 from "./create-delegation-token-v3";
10
11
  export * as createPartitionsV1 from "./create-partitions-v1";
11
12
  export * as createPartitionsV2 from "./create-partitions-v2";
12
13
  export * as createPartitionsV3 from "./create-partitions-v3";
13
14
  export * as createTopicsV7 from "./create-topics-v7";
15
+ export * as deleteAclsV2 from "./delete-acls-v2";
14
16
  export * as deleteAclsV3 from "./delete-acls-v3";
15
17
  export * as deleteGroupsV2 from "./delete-groups-v2";
16
18
  export * as deleteRecordsV2 from "./delete-records-v2";
17
19
  export * as deleteTopicsV6 from "./delete-topics-v6";
20
+ export * as describeAclsV2 from "./describe-acls-v2";
18
21
  export * as describeAclsV3 from "./describe-acls-v3";
19
22
  export * as describeClientQuotasV0 from "./describe-client-quotas-v0";
23
+ export * as describeClusterV0 from "./describe-cluster-v0";
20
24
  export * as describeClusterV1 from "./describe-cluster-v1";
21
25
  export * as describeConfigsV2 from "./describe-configs-v2";
22
26
  export * as describeConfigsV3 from "./describe-configs-v3";
23
27
  export * as describeConfigsV4 from "./describe-configs-v4";
24
28
  export * as describeDelegationTokenV3 from "./describe-delegation-token-v3";
25
29
  export * as describeGroupsV5 from "./describe-groups-v5";
30
+ export * as describeLogDirsV2 from "./describe-log-dirs-v2";
31
+ export * as describeLogDirsV3 from "./describe-log-dirs-v3";
26
32
  export * as describeLogDirsV4 from "./describe-log-dirs-v4";
27
33
  export * as describeProducersV0 from "./describe-producers-v0";
28
34
  export * as describeQuorumV2 from "./describe-quorum-v2";
@@ -35,6 +41,7 @@ export * as incrementalAlterConfigsV1 from "./incremental-alter-configs-v1";
35
41
  export * as listGroupsV4 from "./list-groups-v4";
36
42
  export * as listGroupsV5 from "./list-groups-v5";
37
43
  export * as listPartitionReassignmentsV0 from "./list-partition-reassignments-v0";
44
+ export * as listTransactionsV0 from "./list-transactions-v0";
38
45
  export * as listTransactionsV1 from "./list-transactions-v1";
39
46
  export * as offsetDeleteV0 from "./offset-delete-v0";
40
47
  export * as renewDelegationTokenV2 from "./renew-delegation-token-v2";
@@ -0,0 +1,18 @@
1
+ import { type Reader } from "../../protocol/reader";
2
+ import { Writer } from "../../protocol/writer";
3
+ import { type TransactionState } from "../enumerations";
4
+ export type ListTransactionsRequest = Parameters<typeof createRequest>;
5
+ export interface ListTransactionsResponseTransactionState {
6
+ transactionalId: string;
7
+ producerId: bigint;
8
+ transactionState: string;
9
+ }
10
+ export interface ListTransactionsResponse {
11
+ throttleTimeMs: number;
12
+ errorCode: number;
13
+ unknownStateFilters: string[];
14
+ transactionStates: ListTransactionsResponseTransactionState[];
15
+ }
16
+ export declare function createRequest(stateFilters: TransactionState[], producerIdFilters: bigint[]): Writer;
17
+ 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[]], ListTransactionsResponse>;
@@ -6,8 +6,15 @@ export * as fetchV15 from "./fetch-v15";
6
6
  export * as fetchV16 from "./fetch-v16";
7
7
  export * as fetchV17 from "./fetch-v17";
8
8
  export * as heartbeatV4 from "./heartbeat-v4";
9
+ export * as joinGroupV6 from "./join-group-v6";
10
+ export * as joinGroupV7 from "./join-group-v7";
11
+ export * as joinGroupV8 from "./join-group-v8";
9
12
  export * as joinGroupV9 from "./join-group-v9";
13
+ export * as leaveGroupV4 from "./leave-group-v4";
10
14
  export * as leaveGroupV5 from "./leave-group-v5";
15
+ export * as listOffsetsV5 from "./list-offsets-v5";
16
+ export * as listOffsetsV6 from "./list-offsets-v6";
17
+ export * as listOffsetsV7 from "./list-offsets-v7";
11
18
  export * as listOffsetsV8 from "./list-offsets-v8";
12
19
  export * as listOffsetsV9 from "./list-offsets-v9";
13
20
  export * as offsetCommitV8 from "./offset-commit-v8";
@@ -15,4 +22,5 @@ export * as offsetCommitV9 from "./offset-commit-v9";
15
22
  export * as offsetFetchV8 from "./offset-fetch-v8";
16
23
  export * as offsetFetchV9 from "./offset-fetch-v9";
17
24
  export * as offsetForLeaderEpochV4 from "./offset-for-leader-epoch-v4";
25
+ export * as syncGroupV4 from "./sync-group-v4";
18
26
  export * as syncGroupV5 from "./sync-group-v5";
@@ -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 JoinGroupRequestProtocol {
5
+ name: string;
6
+ metadata?: Buffer | null;
7
+ }
8
+ export type JoinGroupRequest = Parameters<typeof createRequest>;
9
+ export interface JoinGroupResponseMember {
10
+ memberId: string;
11
+ groupInstanceId?: NullableString;
12
+ metadata: Buffer | null;
13
+ }
14
+ export interface JoinGroupResponse {
15
+ throttleTimeMs: number;
16
+ errorCode: number;
17
+ generationId: number;
18
+ protocolType: NullableString;
19
+ protocolName: NullableString;
20
+ leader: string;
21
+ skipAssignment: boolean;
22
+ memberId: NullableString;
23
+ members: JoinGroupResponseMember[];
24
+ }
25
+ export declare function createRequest(groupId: string, sessionTimeoutMs: number, rebalanceTimeoutMs: number, memberId: string, groupInstanceId: NullableString, protocolType: string, protocols: JoinGroupRequestProtocol[]): Writer;
26
+ export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): JoinGroupResponse;
27
+ export declare const api: import("../definitions").API<[groupId: string, sessionTimeoutMs: number, rebalanceTimeoutMs: number, memberId: string, groupInstanceId: NullableString, protocolType: string, protocols: JoinGroupRequestProtocol[]], JoinGroupResponse>;
@@ -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 JoinGroupRequestProtocol {
5
+ name: string;
6
+ metadata?: Buffer | null;
7
+ }
8
+ export type JoinGroupRequest = Parameters<typeof createRequest>;
9
+ export interface JoinGroupResponseMember {
10
+ memberId: string;
11
+ groupInstanceId?: NullableString;
12
+ metadata: Buffer | null;
13
+ }
14
+ export interface JoinGroupResponse {
15
+ throttleTimeMs: number;
16
+ errorCode: number;
17
+ generationId: number;
18
+ protocolType: NullableString;
19
+ protocolName: NullableString;
20
+ leader: string;
21
+ skipAssignment: boolean;
22
+ memberId: NullableString;
23
+ members: JoinGroupResponseMember[];
24
+ }
25
+ export declare function createRequest(groupId: string, sessionTimeoutMs: number, rebalanceTimeoutMs: number, memberId: string, groupInstanceId: NullableString, protocolType: string, protocols: JoinGroupRequestProtocol[]): Writer;
26
+ export declare function parseResponse(_correlationId: number, apiKey: number, apiVersion: number, reader: Reader): JoinGroupResponse;
27
+ export declare const api: import("../definitions").API<[groupId: string, sessionTimeoutMs: number, rebalanceTimeoutMs: number, memberId: string, groupInstanceId: NullableString, protocolType: string, protocols: JoinGroupRequestProtocol[]], JoinGroupResponse>;