kafka-ts 1.3.1-beta.2 → 1.3.1-beta.3

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.
@@ -33,7 +33,9 @@ const OFFSET_COMMIT_V2 = (0, api_1.createApi)({
33
33
  .writeInt32(data.generationIdOrMemberEpoch)
34
34
  .writeString(data.memberId)
35
35
  .writeInt64(-1n) // retention_time_ms is deprecated and should be set to -1
36
- .writeArray(data.topics, (encoder, topic) => encoder.writeString(topic.name).writeArray(topic.partitions, (encoder, partition) => encoder
36
+ .writeArray(data.topics, (encoder, topic) => encoder
37
+ .writeString(topic.name)
38
+ .writeArray(topic.partitions, (encoder, partition) => encoder
37
39
  .writeInt32(partition.partitionIndex)
38
40
  .writeInt64(partition.committedOffset)
39
41
  .writeString(partition.committedMetadata))),
@@ -1,4 +1,4 @@
1
- import { SASLProvider } from "../broker";
1
+ import { SASLProvider } from '../broker';
2
2
  export declare const saslPlain: ({ username, password }: {
3
3
  username: string;
4
4
  password: string;
package/dist/broker.js CHANGED
@@ -42,7 +42,8 @@ class Broker {
42
42
  logger_1.log.warn(`Broker does not support API ${(0, api_1.getApiName)(api)} version ${api.apiVersion} (minVersion=${minVersion}, maxVersion=${maxVersion})`);
43
43
  }
44
44
  });
45
- this.connection.setVersions(versions);
45
+ const versionsByApiKey = Object.fromEntries(versions.map(({ apiKey, minVersion, maxVersion }) => [apiKey, { minVersion, maxVersion }]));
46
+ this.connection.setVersions(versionsByApiKey);
46
47
  }
47
48
  async saslHandshake() {
48
49
  if (!this.options.sasl) {
@@ -118,13 +118,14 @@ class Connection {
118
118
  if (!versionInfo)
119
119
  throw new Error(`Broker does not support API ${(0, api_1.getApiName)(api)}`);
120
120
  if (api.apiVersion < versionInfo.minVersion || api.apiVersion > versionInfo.maxVersion) {
121
- if (api.fallback)
121
+ if (api.fallback) {
122
122
  return this.validateVersion(api.fallback);
123
+ }
123
124
  throw new Error(`Broker does not support API ${(0, api_1.getApiName)(api)} version ${api.apiVersion} (minVersion=${versionInfo.minVersion}, maxVersion=${versionInfo.maxVersion})`);
124
125
  }
125
126
  return api;
126
127
  }
127
- validateVersionCached = (0, cached_1.cached)(this.validateVersion, (api) => api.apiKey.toString());
128
+ validateVersionCached = (0, cached_1.cached)(this.validateVersion.bind(this), (api) => api.apiKey.toString());
128
129
  async sendRequest(apiLatest, body) {
129
130
  const api = this.validateVersionCached(apiLatest);
130
131
  const correlationId = this.nextCorrelationId();
@@ -1,4 +1,4 @@
1
- import { Cluster } from "../cluster";
1
+ import { Cluster } from '../cluster';
2
2
  type ProducerStateOptions = {
3
3
  cluster: Cluster;
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kafka-ts",
3
- "version": "1.3.1-beta.2",
3
+ "version": "1.3.1-beta.3",
4
4
  "main": "dist/index.js",
5
5
  "author": "Priit Käärd",
6
6
  "license": "MIT",