@platformatic/kafka 1.27.0 → 1.29.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 (54) hide show
  1. package/README.md +14 -7
  2. package/dist/apis/admin/describe-cluster-v0.d.ts +2 -2
  3. package/dist/apis/admin/describe-cluster-v0.js +1 -1
  4. package/dist/apis/admin/list-groups-v4.d.ts +2 -2
  5. package/dist/apis/admin/list-groups-v4.js +1 -1
  6. package/dist/apis/admin/list-transactions-v0.d.ts +2 -2
  7. package/dist/apis/admin/list-transactions-v0.js +1 -1
  8. package/dist/apis/consumer/join-group-v6.d.ts +2 -2
  9. package/dist/apis/consumer/join-group-v6.js +1 -1
  10. package/dist/apis/consumer/join-group-v7.d.ts +2 -2
  11. package/dist/apis/consumer/join-group-v7.js +1 -1
  12. package/dist/apis/consumer/offset-commit-v8.d.ts +2 -2
  13. package/dist/apis/consumer/sync-group-v4.d.ts +2 -2
  14. package/dist/apis/consumer/sync-group-v4.js +1 -1
  15. package/dist/clients/admin/admin.d.ts +3 -1
  16. package/dist/clients/admin/admin.js +88 -7
  17. package/dist/clients/admin/options.d.ts +43 -0
  18. package/dist/clients/admin/options.js +33 -0
  19. package/dist/clients/admin/types.d.ts +19 -0
  20. package/dist/clients/base/base.js +6 -1
  21. package/dist/clients/consumer/messages-stream.js +41 -12
  22. package/dist/clients/producer/index.d.ts +1 -0
  23. package/dist/clients/producer/index.js +1 -0
  24. package/dist/clients/producer/options.d.ts +63 -0
  25. package/dist/clients/producer/options.js +18 -0
  26. package/dist/clients/producer/producer-stream.d.ts +19 -0
  27. package/dist/clients/producer/producer-stream.js +187 -0
  28. package/dist/clients/producer/producer.d.ts +6 -3
  29. package/dist/clients/producer/producer.js +55 -3
  30. package/dist/clients/producer/types.d.ts +24 -0
  31. package/dist/clients/producer/types.js +6 -1
  32. package/dist/diagnostic.d.ts +2 -2
  33. package/dist/network/connection.js +13 -2
  34. package/dist/protocol/sasl/scram-sha.d.ts +2 -2
  35. package/dist/protocol/sasl/scram-sha.js +35 -27
  36. package/dist/typescript-4/dist/apis/admin/describe-cluster-v0.d.ts +2 -2
  37. package/dist/typescript-4/dist/apis/admin/list-groups-v4.d.ts +2 -2
  38. package/dist/typescript-4/dist/apis/admin/list-transactions-v0.d.ts +2 -2
  39. package/dist/typescript-4/dist/apis/consumer/join-group-v6.d.ts +2 -2
  40. package/dist/typescript-4/dist/apis/consumer/join-group-v7.d.ts +2 -2
  41. package/dist/typescript-4/dist/apis/consumer/offset-commit-v8.d.ts +2 -2
  42. package/dist/typescript-4/dist/apis/consumer/sync-group-v4.d.ts +2 -2
  43. package/dist/typescript-4/dist/clients/admin/admin.d.ts +3 -1
  44. package/dist/typescript-4/dist/clients/admin/options.d.ts +43 -0
  45. package/dist/typescript-4/dist/clients/admin/types.d.ts +19 -0
  46. package/dist/typescript-4/dist/clients/producer/index.d.ts +1 -0
  47. package/dist/typescript-4/dist/clients/producer/options.d.ts +64 -1
  48. package/dist/typescript-4/dist/clients/producer/producer-stream.d.ts +19 -0
  49. package/dist/typescript-4/dist/clients/producer/producer.d.ts +6 -3
  50. package/dist/typescript-4/dist/clients/producer/types.d.ts +25 -1
  51. package/dist/typescript-4/dist/diagnostic.d.ts +2 -2
  52. package/dist/typescript-4/dist/protocol/sasl/scram-sha.d.ts +2 -2
  53. package/dist/version.js +1 -1
  54. package/package.json +3 -3
@@ -5,7 +5,7 @@ import { type CallbackWithPromise } from "../../apis/callbacks";
5
5
  import { type Callback } from "../../apis/definitions";
6
6
  import { type Acl } from "../../apis/types";
7
7
  import { Base } from "../base/base";
8
- import { type AdminListOffsetsOptions, type AdminOptions, type AlterClientQuotasOptions, type AlterConfigsOptions, type AlterConsumerGroupOffsetsOptions, type BrokerLogDirDescription, type ConfigDescription, type CreateAclsOptions, type CreatedTopic, type CreatePartitionsOptions, type CreateTopicsOptions, type DeleteAclsOptions, type DeleteConsumerGroupOffsetsOptions, type DeleteGroupsOptions, type DeleteTopicsOptions, type DescribeAclsOptions, type DescribeClientQuotasOptions, type DescribeConfigsOptions, type DescribeGroupsOptions, type DescribeLogDirsOptions, type Group, type GroupBase, type IncrementalAlterConfigsOptions, type ListConsumerGroupOffsetsGroup, type ListConsumerGroupOffsetsOptions, type ListedOffsetsTopic, type ListGroupsOptions, type ListTopicsOptions, type RemoveMembersFromConsumerGroupOptions } from "./types";
8
+ import { type AdminListOffsetsOptions, type AdminOptions, type AlterClientQuotasOptions, type AlterConfigsOptions, type AlterConsumerGroupOffsetsOptions, type BrokerLogDirDescription, type ConfigDescription, type CreateAclsOptions, type CreatedTopic, type CreatePartitionsOptions, type CreateTopicsOptions, type DeleteAclsOptions, type DeleteConsumerGroupOffsetsOptions, type DeleteRecordsOptions, type DeleteGroupsOptions, type DeleteTopicsOptions, type DeletedRecordsTopic, type DescribeAclsOptions, type DescribeClientQuotasOptions, type DescribeConfigsOptions, type DescribeGroupsOptions, type DescribeLogDirsOptions, type Group, type GroupBase, type IncrementalAlterConfigsOptions, type ListConsumerGroupOffsetsGroup, type ListConsumerGroupOffsetsOptions, type ListedOffsetsTopic, type ListGroupsOptions, type ListTopicsOptions, type RemoveMembersFromConsumerGroupOptions } from "./types";
9
9
  export declare class Admin extends Base<AdminOptions> {
10
10
  #private;
11
11
  constructor(options: AdminOptions);
@@ -57,4 +57,6 @@ export declare class Admin extends Base<AdminOptions> {
57
57
  deleteAcls(options: DeleteAclsOptions): Promise<Acl[]>;
58
58
  listOffsets(options: AdminListOffsetsOptions, callback: CallbackWithPromise<ListedOffsetsTopic[]>): void;
59
59
  listOffsets(options: AdminListOffsetsOptions): Promise<ListedOffsetsTopic[]>;
60
+ deleteRecords(options: DeleteRecordsOptions, callback: CallbackWithPromise<DeletedRecordsTopic[]>): void;
61
+ deleteRecords(options: DeleteRecordsOptions): Promise<DeletedRecordsTopic[]>;
60
62
  }
@@ -484,6 +484,46 @@ export declare const deleteConsumerGroupOffsetsOptionsSchema: {
484
484
  required: string[];
485
485
  additionalProperties: boolean;
486
486
  };
487
+ export declare const deleteRecordsOptionsSchema: {
488
+ type: string;
489
+ properties: {
490
+ topics: {
491
+ type: string;
492
+ items: {
493
+ type: string;
494
+ properties: {
495
+ name: {
496
+ type: string;
497
+ minLength: number;
498
+ };
499
+ partitions: {
500
+ type: string;
501
+ items: {
502
+ type: string;
503
+ properties: {
504
+ partition: {
505
+ type: string;
506
+ minimum: number;
507
+ };
508
+ offset: {
509
+ bigint: boolean;
510
+ };
511
+ };
512
+ required: string[];
513
+ additionalProperties: boolean;
514
+ };
515
+ minItems: number;
516
+ };
517
+ };
518
+ required: string[];
519
+ additionalProperties: boolean;
520
+ };
521
+ minItems: number;
522
+ };
523
+ };
524
+ required: string[];
525
+ additionalProperties: boolean;
526
+ };
487
527
  export declare const describeConfigsOptionsSchema: {
488
528
  type: string;
489
529
  properties: {
@@ -881,6 +921,9 @@ export declare const alterConsumerGroupOffsetsOptionsValidator: import("ajv").Va
881
921
  export declare const deleteConsumerGroupOffsetsOptionsValidator: import("ajv").ValidateFunction<{
882
922
  [x: string]: {};
883
923
  }>;
924
+ export declare const deleteRecordsOptionsValidator: import("ajv").ValidateFunction<{
925
+ [x: string]: {};
926
+ }>;
884
927
  export declare const listConsumerGroupOffsetsOptionsValidator: import("ajv").ValidateFunction<{
885
928
  [x: string]: {};
886
929
  }>;
@@ -138,6 +138,25 @@ export interface DeleteConsumerGroupOffsetsOptions {
138
138
  partitionIndexes: number[];
139
139
  }[];
140
140
  }
141
+ export interface DeleteRecordsPartitionOffset {
142
+ partition: number;
143
+ offset: bigint;
144
+ }
145
+ export interface DeleteRecordsTopic {
146
+ name: string;
147
+ partitions: DeleteRecordsPartitionOffset[];
148
+ }
149
+ export interface DeleteRecordsOptions {
150
+ topics: DeleteRecordsTopic[];
151
+ }
152
+ export interface DeletedRecordsPartition {
153
+ partition: number;
154
+ lowWatermark: bigint;
155
+ }
156
+ export interface DeletedRecordsTopic {
157
+ name: string;
158
+ partitions: DeletedRecordsPartition[];
159
+ }
141
160
  export interface DescribeConfigsOptions {
142
161
  resources: DescribeConfigsRequestResource[];
143
162
  includeSynonyms?: boolean;
@@ -1,3 +1,4 @@
1
1
  export * from "./options";
2
+ export * from "./producer-stream";
2
3
  export * from "./producer";
3
4
  export * from "./types";
@@ -154,4 +154,67 @@ export declare const sendOptionsSchema: {
154
154
  };
155
155
  export declare const sendOptionsValidator: import("ajv").ValidateFunction<{
156
156
  [x: string]: {};
157
- }>;
157
+ }>;
158
+ export declare const defaultProducerStreamOptions: {
159
+ batchSize: number;
160
+ batchTime: number;
161
+ reportMode: "none";
162
+ };
163
+ export declare const producerStreamOptionsSchema: {
164
+ type: string;
165
+ properties: {
166
+ producerId: {
167
+ bigint: boolean;
168
+ };
169
+ producerEpoch: {
170
+ type: string;
171
+ };
172
+ idempotent: {
173
+ type: string;
174
+ };
175
+ transactionalId: {
176
+ type: string;
177
+ };
178
+ acks: {
179
+ type: string;
180
+ enumeration: {
181
+ allowed: (0 | 1 | -1)[];
182
+ errorMessage: string;
183
+ };
184
+ };
185
+ compression: {
186
+ type: string;
187
+ enumeration: {
188
+ allowed: import("../../protocol/compression").CompressionAlgorithmValue[];
189
+ errorMessage: string;
190
+ };
191
+ };
192
+ partitioner: {
193
+ function: boolean;
194
+ };
195
+ autocreateTopics: {
196
+ type: string;
197
+ };
198
+ repeatOnStaleMetadata: {
199
+ type: string;
200
+ };
201
+ highWaterMark: {
202
+ type: string;
203
+ minimum: number;
204
+ };
205
+ batchSize: {
206
+ type: string;
207
+ minimum: number;
208
+ };
209
+ batchTime: {
210
+ type: string;
211
+ minimum: number;
212
+ };
213
+ reportMode: {
214
+ type: string;
215
+ enum: import("./types").ProducerStreamReportModeValue[];
216
+ };
217
+ };
218
+ additionalProperties: boolean;
219
+ };
220
+ export declare const producerStreamOptionsValidator: import("ajv").ValidateFunction<unknown>;
@@ -0,0 +1,19 @@
1
+ import { Writable } from 'node:stream';
2
+ import { type CallbackWithPromise } from "../../apis/callbacks";
3
+ import type { MessageToProduce } from "../../protocol/records";
4
+ import type { Producer } from "./producer";
5
+ import { type ProducerStreamOptions } from "./types";
6
+ export declare class ProducerStream<Key = Buffer, Value = Buffer, HeaderKey = Buffer, HeaderValue = Buffer> extends Writable {
7
+ #private;
8
+ instance: number;
9
+ constructor(producer: Producer<Key, Value, HeaderKey, HeaderValue>, options: ProducerStreamOptions<Key, Value, HeaderKey, HeaderValue>);
10
+ get producer(): Producer<Key, Value, HeaderKey, HeaderValue>;
11
+ close(callback: CallbackWithPromise<void>): void;
12
+ close(): Promise<void>;
13
+ _write(message: MessageToProduce<Key, Value, HeaderKey, HeaderValue>, _: BufferEncoding, callback: (error?: Error | null) => void): void;
14
+ _writev(chunks: Array<{
15
+ chunk: MessageToProduce<Key, Value, HeaderKey, HeaderValue>;
16
+ }>, callback: (error?: Error | null) => void): void;
17
+ _final(callback: (error?: Error | null) => void): void;
18
+ _destroy(error: Error | null, callback: (error?: Error | null) => void): void;
19
+ }
@@ -2,8 +2,9 @@ import { type CallbackWithPromise } from "../../apis/callbacks";
2
2
  import { type Message } from "../../protocol/records";
3
3
  import { kTransaction, kTransactionAddOffsets, kTransactionAddPartitions, kTransactionCancel, kTransactionCommitOffset, kTransactionEnd, kTransactionFindCoordinator } from "../../symbols";
4
4
  import { Base } from "../base/base";
5
+ import { ProducerStream } from "./producer-stream";
5
6
  import { Transaction } from "./transaction";
6
- import { type ProduceOptions, type ProduceResult, type ProducerInfo, type ProducerOptions, type SendOptions } from "./types";
7
+ import { type ProduceOptions, type ProduceResult, type ProducerInfo, type ProducerOptions, type ProducerStreamOptions, type SendOptions } from "./types";
7
8
  export declare function noopSerializer(data?: Buffer): Buffer | undefined;
8
9
  export declare class Producer<Key = Buffer, Value = Buffer, HeaderKey = Buffer, HeaderValue = Buffer> extends Base<ProducerOptions<Key, Value, HeaderKey, HeaderValue>> {
9
10
  #private;
@@ -12,8 +13,9 @@ export declare class Producer<Key = Buffer, Value = Buffer, HeaderKey = Buffer,
12
13
  get producerEpoch(): number | undefined;
13
14
  get transaction(): Transaction<Key, Value, HeaderKey, HeaderValue> | undefined;
14
15
  get coordinatorId(): number;
15
- close(callback: CallbackWithPromise<void>): void;
16
- close(): Promise<void>;
16
+ get streamsCount(): number;
17
+ close(force: boolean | CallbackWithPromise<void>, callback?: CallbackWithPromise<void>): void;
18
+ close(force?: boolean): Promise<void>;
17
19
  initIdempotentProducer(options: ProduceOptions<Key, Value, HeaderKey, HeaderValue>, callback: CallbackWithPromise<ProducerInfo>): void;
18
20
  initIdempotentProducer(options: ProduceOptions<Key, Value, HeaderKey, HeaderValue>): Promise<ProducerInfo>;
19
21
  send(options: SendOptions<Key, Value, HeaderKey, HeaderValue> & {
@@ -22,6 +24,7 @@ export declare class Producer<Key = Buffer, Value = Buffer, HeaderKey = Buffer,
22
24
  send(options: SendOptions<Key, Value, HeaderKey, HeaderValue> & {
23
25
  [kTransaction]?: number;
24
26
  }): Promise<ProduceResult>;
27
+ asStream(options?: ProducerStreamOptions<Key, Value, HeaderKey, HeaderValue>): ProducerStream<Key, Value, HeaderKey, HeaderValue>;
25
28
  beginTransaction(options: ProduceOptions<Key, Value, HeaderKey, HeaderValue>, callback: CallbackWithPromise<Transaction<Key, Value, HeaderKey, HeaderValue>>): void;
26
29
  beginTransaction(options?: ProduceOptions<Key, Value, HeaderKey, HeaderValue>): Promise<Transaction<Key, Value, HeaderKey, HeaderValue>>;
27
30
  [kTransactionFindCoordinator](callback: CallbackWithPromise<void>): void;
@@ -13,6 +13,16 @@ export interface ProduceResult {
13
13
  unwritableNodes?: number[];
14
14
  }
15
15
  export type Partitioner<Key, Value, HeaderKey, HeaderValue> = (message: MessageToProduce<Key, Value, HeaderKey, HeaderValue>) => number;
16
+ export interface ProducerStreamReport {
17
+ batchId: number;
18
+ count: number;
19
+ result: ProduceResult;
20
+ }
21
+ export interface ProducerStreamMessageReport<Key, Value, HeaderKey, HeaderValue> {
22
+ batchId: number;
23
+ index: number;
24
+ message: MessageToProduce<Key, Value, HeaderKey, HeaderValue>;
25
+ }
16
26
  export interface ProduceOptions<Key, Value, HeaderKey, HeaderValue> {
17
27
  producerId?: bigint;
18
28
  producerEpoch?: number;
@@ -31,4 +41,18 @@ export type ProducerOptions<Key, Value, HeaderKey, HeaderValue> = BaseOptions &
31
41
  };
32
42
  export type SendOptions<Key, Value, HeaderKey, HeaderValue> = {
33
43
  messages: MessageToProduce<Key, Value, HeaderKey, HeaderValue>[];
34
- } & ProduceOptions<Key, Value, HeaderKey, HeaderValue>;
44
+ } & ProduceOptions<Key, Value, HeaderKey, HeaderValue>;
45
+ export declare const ProducerStreamReportModes: {
46
+ readonly NONE: "none";
47
+ readonly BATCH: "batch";
48
+ readonly MESSAGE: "message";
49
+ };
50
+ export declare const allowedProducerStreamReportModes: ProducerStreamReportModeValue[];
51
+ export type ProducerStreamReportMode = keyof typeof ProducerStreamReportModes;
52
+ export type ProducerStreamReportModeValue = (typeof ProducerStreamReportModes)[keyof typeof ProducerStreamReportModes];
53
+ export type ProducerStreamOptions<Key, Value, HeaderKey, HeaderValue> = Omit<SendOptions<Key, Value, HeaderKey, HeaderValue>, 'messages'> & {
54
+ highWaterMark?: number;
55
+ batchSize?: number;
56
+ batchTime?: number;
57
+ reportMode?: ProducerStreamReportModeValue;
58
+ };
@@ -4,7 +4,7 @@ import { type ConnectionPool } from "./network/connection-pool";
4
4
  import { type Connection } from "./network/connection";
5
5
  export type ClientType = 'base' | 'producer' | 'consumer' | 'admin';
6
6
  export interface CreationEvent<InstanceType> {
7
- type: ClientType | 'connection' | 'connectionPool';
7
+ type: ClientType | 'connection' | 'connection-pool' | 'messages-stream' | 'producer-stream';
8
8
  instance: InstanceType;
9
9
  }
10
10
  export type ConnectionDiagnosticEvent<Attributes = Record<string, unknown>> = {
@@ -29,7 +29,7 @@ export type DiagnosticContext<BaseContext = {}> = BaseContext & {
29
29
  };
30
30
  export declare const channelsNamespace: "plt:kafka";
31
31
  export declare function createDiagnosticContext<BaseContext = {}>(context: BaseContext): DiagnosticContext<BaseContext>;
32
- export declare function notifyCreation<InstanceType>(type: ClientType | 'connection' | 'connection-pool' | 'messages-stream', instance: InstanceType): void;
32
+ export declare function notifyCreation<InstanceType>(type: ClientType | 'connection' | 'connection-pool' | 'messages-stream' | 'producer-stream', instance: InstanceType): void;
33
33
  export declare function createChannel<DiagnosticEvent extends object>(name: string): ChannelWithName<DiagnosticEvent>;
34
34
  export declare function createTracingChannel<DiagnosticEvent extends object>(name: string): TracingChannelWithName<DiagnosticEvent>;
35
35
  export declare const instancesChannel: ChannelWithName<object>;
@@ -8,7 +8,7 @@ export interface ScramAlgorithmDefinition {
8
8
  }
9
9
  export interface ScramCryptoModule {
10
10
  h: (definition: ScramAlgorithmDefinition, data: string | Buffer) => Buffer;
11
- hi: (definition: ScramAlgorithmDefinition, password: string, salt: Buffer, iterations: number) => Buffer;
11
+ hi: (definition: ScramAlgorithmDefinition, password: string, salt: Buffer, iterations: number) => Promise<Buffer>;
12
12
  hmac: (definition: ScramAlgorithmDefinition, key: Buffer, data: string | Buffer) => Buffer;
13
13
  xor: (a: Buffer, b: Buffer) => Buffer;
14
14
  }
@@ -31,7 +31,7 @@ export declare function createNonce(): string;
31
31
  export declare function sanitizeString(str: string): string;
32
32
  export declare function parseParameters(data: Buffer): Record<string, string>;
33
33
  export declare function h(definition: ScramAlgorithmDefinition, data: string | Buffer): Buffer;
34
- export declare function hi(definition: ScramAlgorithmDefinition, password: string, salt: Buffer, iterations: number): Buffer;
34
+ export declare function hi(definition: ScramAlgorithmDefinition, password: string, salt: Buffer, iterations: number): Promise<Buffer>;
35
35
  export declare function hmac(definition: ScramAlgorithmDefinition, key: Buffer, data: string | Buffer): Buffer;
36
36
  export declare function xor(a: Buffer, b: Buffer): Buffer;
37
37
  export declare const defaultCrypto: ScramCryptoModule;
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = "@platformatic/kafka";
2
- export const version = "1.27.0";
2
+ export const version = "1.29.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/kafka",
3
- "version": "1.27.0",
3
+ "version": "1.29.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)",
@@ -25,9 +25,10 @@
25
25
  "exports": "./dist/index.js",
26
26
  "types": "./dist/index.d.ts",
27
27
  "dependencies": {
28
- "@platformatic/dynamic-buffer": "^0.3.0",
28
+ "@platformatic/dynamic-buffer": "^0.3.1",
29
29
  "@platformatic/wasm-utils": "^0.1.0",
30
30
  "ajv": "^8.17.1",
31
+ "avsc": "^5.7.9",
31
32
  "debug": "^4.4.3",
32
33
  "fastq": "^1.19.1",
33
34
  "mnemonist": "^0.40.3",
@@ -53,7 +54,6 @@
53
54
  "@types/node": "^22.18.8",
54
55
  "@types/semver": "^7.7.1",
55
56
  "@watchable/unpromise": "^1.0.2",
56
- "avsc": "^5.7.9",
57
57
  "c8": "^10.1.3",
58
58
  "cleaner-spec-reporter": "^0.5.0",
59
59
  "cronometro": "^5.3.0",