@platformatic/kafka 1.10.0 → 1.11.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.
package/README.md CHANGED
@@ -281,7 +281,28 @@ Many of the methods accept the same options as the client's constructors. The co
281
281
 
282
282
  ## Requirements
283
283
 
284
- - Node.js >= 22.14.0
284
+ Node.js LTS versions:
285
+
286
+ - `20.19.4` or above
287
+ - `22.18.0` or above
288
+ - `24.6.0` or above
289
+
290
+ ## Testing
291
+
292
+ To setup the local environment for testing
293
+
294
+ ```bash
295
+ cd docker
296
+ cp .env.sample .env
297
+ ```
298
+
299
+ Edit .env file as needed, enabling or not `JAVA_OPTIONS`
300
+
301
+ Start Kafka cluster locally
302
+
303
+ ```bash
304
+ docker compose -f compose-local.yml up -d
305
+ ```
285
306
 
286
307
  ## License
287
308
 
@@ -1,4 +1,5 @@
1
1
  import { MultipleErrors } from "../errors.js";
2
+ import { PromiseWithResolvers } from "../utils.js";
2
3
  export const kCallbackPromise = Symbol('plt.kafka.callbackPromise');
3
4
  // This is only meaningful for testing
4
5
  export const kNoopCallbackReturnValue = Symbol('plt.kafka.noopCallbackReturnValue');
@@ -6,7 +7,7 @@ export const noopCallback = () => {
6
7
  return Promise.resolve(kNoopCallbackReturnValue);
7
8
  };
8
9
  export function createPromisifiedCallback() {
9
- const { promise, resolve, reject } = Promise.withResolvers();
10
+ const { promise, resolve, reject } = PromiseWithResolvers();
10
11
  function callback(error, payload) {
11
12
  if (error) {
12
13
  reject(error);
package/dist/errors.d.ts CHANGED
@@ -10,7 +10,7 @@ export declare class GenericError extends Error {
10
10
  code: string;
11
11
  [index: string]: any;
12
12
  [kGenericError]: true;
13
- static isGenericError(error: Error): boolean;
13
+ static isGenericError(error: Error): error is GenericError | MultipleErrors;
14
14
  constructor(code: ErrorCode, message: string, { cause, ...rest }?: ErrorProperties);
15
15
  findBy<ErrorType extends GenericError = GenericError>(property: string, value: unknown): ErrorType | null;
16
16
  }
@@ -20,8 +20,8 @@ export declare class MultipleErrors extends AggregateError {
20
20
  [kGenericError]: true;
21
21
  [kMultipleErrors]: true;
22
22
  static code: ErrorCode;
23
- static isGenericError(error: Error): boolean;
24
- static isMultipleErrors(error: Error): boolean;
23
+ static isGenericError(error: Error): error is GenericError | MultipleErrors;
24
+ static isMultipleErrors(error: Error): error is MultipleErrors;
25
25
  constructor(message: string, errors: Error[], { cause, ...rest }?: ErrorProperties);
26
26
  findBy<ErrorType extends GenericError | MultipleErrors = MultipleErrors>(property: string, value: unknown): ErrorType | null;
27
27
  }
@@ -3,7 +3,6 @@ import zlib from 'node:zlib';
3
3
  import { UnsupportedCompressionError } from "../errors.js";
4
4
  import { DynamicBuffer } from "./dynamic-buffer.js";
5
5
  const require = createRequire(import.meta.url);
6
- // @ts-ignore - Added in Node.js 22.15.0
7
6
  const { zstdCompressSync, zstdDecompressSync, gzipSync, gunzipSync } = zlib;
8
7
  function ensureBuffer(data) {
9
8
  return DynamicBuffer.isDynamicBuffer(data) ? data.slice() : data;
package/dist/utils.d.ts CHANGED
@@ -15,6 +15,7 @@ export interface DataValidationContext {
15
15
  }
16
16
  export type DebugDumpLogger = (...args: any[]) => void;
17
17
  export { setTimeout as sleep } from 'node:timers/promises';
18
+ export declare const PromiseWithResolvers: <T>() => PromiseWithResolvers<T>;
18
19
  export declare const ajv: Ajv2020;
19
20
  export declare const loggers: Record<string, debug.Debugger>;
20
21
  export declare class NumericMap extends Map<string, number> {
package/dist/utils.js CHANGED
@@ -2,6 +2,17 @@ import { Ajv2020 } from 'ajv/dist/2020.js';
2
2
  import debug from 'debug';
3
3
  import { inspect } from 'node:util';
4
4
  export { setTimeout as sleep } from 'node:timers/promises';
5
+ function PromiseWithResolversPolyfill() {
6
+ let resolve;
7
+ let reject;
8
+ const promise = new Promise((_resolve, _reject) => {
9
+ resolve = _resolve;
10
+ reject = _reject;
11
+ });
12
+ // @ts-expect-error - resolve and reject are assigned in the promise constructor
13
+ return { promise, resolve, reject };
14
+ }
15
+ export const PromiseWithResolvers = Promise.withResolvers ? Promise.withResolvers.bind(Promise) : PromiseWithResolversPolyfill;
5
16
  export const ajv = new Ajv2020({ allErrors: true, coerceTypes: false, strict: true });
6
17
  export const loggers = {
7
18
  protocol: debug('plt:kafka:protocol'),
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = "@platformatic/kafka";
2
- export const version = "1.10.0";
2
+ export const version = "1.11.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/kafka",
3
- "version": "1.10.0",
3
+ "version": "1.11.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)",
@@ -38,7 +38,7 @@
38
38
  "devDependencies": {
39
39
  "@platformatic/rdkafka": "^4.0.0",
40
40
  "@types/debug": "^4.1.12",
41
- "@types/node": "^22.13.5",
41
+ "@types/node": "^22.17.2",
42
42
  "@types/semver": "^7.7.0",
43
43
  "@watchable/unpromise": "^1.0.2",
44
44
  "avsc": "^5.7.7",
@@ -61,11 +61,11 @@
61
61
  "typescript": "^5.7.3"
62
62
  },
63
63
  "engines": {
64
- "node": ">= 22.14.0"
64
+ "node": ">= 20.19.4 || >= 22.18.0 || >= 24.6.0"
65
65
  },
66
66
  "scripts": {
67
67
  "build": "rm -rf dist && tsc -p tsconfig.base.json",
68
- "postbuild": "node --experimental-strip-types scripts/postbuild.ts",
68
+ "postbuild": "node scripts/postbuild.ts",
69
69
  "lint": "eslint --cache",
70
70
  "typecheck": "tsc -p . --noEmit",
71
71
  "format": "prettier -w benchmarks playground src test",
@@ -74,8 +74,12 @@
74
74
  "test:docker:up": "node scripts/docker.ts up -d --wait",
75
75
  "test:docker:down": "node scripts/docker.ts down",
76
76
  "ci": "npm run build && npm run lint && npm run test:ci",
77
- "generate:apis": "node --experimental-strip-types scripts/generate-apis.ts",
78
- "generate:errors": "node --experimental-strip-types scripts/generate-errors.ts",
79
- "create:api": "node --experimental-strip-types scripts/create-api.ts"
77
+ "generate:apis": "node scripts/generate-apis.ts",
78
+ "generate:errors": "node scripts/generate-errors.ts",
79
+ "create:api": "node scripts/create-api.ts",
80
+ "build:v20": "rm -rf dist && tsc -p tsconfig.json",
81
+ "postbuild:v20": "cp package.json dist/package.json && node dist/scripts/postbuild.js",
82
+ "test:v20": "npm run build:v20 && cp -R test/fixtures dist/test/fixtures && node --env-file=test/config/env --no-warnings --test --test-timeout=300000 dist/test/**/*.test.js",
83
+ "test:ci:v20": "npm run build:v20 && cp -R test/fixtures dist/test/fixtures && node --env-file=test/config/env --no-warnings --test --test-timeout=300000 dist/test/**/*.test.js"
80
84
  }
81
85
  }