kafka-crab-js 1.7.0 → 1.8.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
@@ -10,29 +10,35 @@ A lightweight, flexible, and reliable Kafka client for JavaScript/TypeScript. It
10
10
 
11
11
  ---
12
12
 
13
- ## What's New in Version 1.4.0
13
+ ## What's New in Version 1.8.0
14
14
 
15
- ### Major Updates:
16
- 1. **Enums Replaced by Unions**:
17
- - Removed enums such as `KafkaEventName`, `PartitionPosition`, `CommitMode`, and `SecurityProtocol`.
18
- - These enums were replaced with union types for better flexibility and usability.
15
+ ### 🚨 Breaking Changes:
16
+ 1. **Async Consumer Commit**:
17
+ - **BREAKING**: The `consumer.commit()` method is now async and must be awaited
18
+ - **Before**: `consumer.commit(topic, partition, offset, 'Sync')`
19
+ - **After**: `await consumer.commit(topic, partition, offset, 'Sync')`
20
+ - This change improves performance by using `spawn_blocking` for non-blocking operations
19
21
 
20
- 2. **Improved TypeScript Definitions**:
21
- - Enhanced TypeScript definitions for better clarity and usability:
22
- - Changes in `KafkaClientConfig`, `KafkaConsumer`, and `KafkaProducer`.
22
+ ### Major Updates:
23
+ 2. **Enhanced Manual Commit Testing**:
24
+ - Added comprehensive integration tests for manual commit functionality
25
+ - Tests now use PostRebalance events for proper timing instead of arbitrary timeouts
26
+ - Covers both sync and async commit modes with offset verification
27
+ - Tests offset persistence across consumer restarts and batch processing scenarios
23
28
 
24
- 3. **CI/CD Enhancements**:
25
- - Updated GitHub Actions workflow:
26
- - Added matrix builds for better coverage across platforms (e.g., `x86_64`, `aarch64` on Linux and macOS).
29
+ 3. **Improved Error Messages**:
30
+ - Standardized all error messages to use consistent "Failed to [action]" format
31
+ - Enhanced error clarity and specificity throughout the codebase
32
+ - Fixed grammar and spelling issues in error messages
27
33
 
28
34
  4. **Updated Dependencies**:
29
- - Upgraded dependencies to their latest versions for improved performance and security.
35
+ - Upgraded all dependencies to their latest versions for improved performance and security
36
+ - Updated TypeScript bindings and CommonJS exports
37
+ - Synchronized pnpm-lock.yaml with new dependency versions
30
38
 
31
- 5. **New Tests and Examples**:
32
- - Added new integration tests and examples for Kafka to ensure reliability.
33
-
34
- 6. **Enhanced Documentation**:
35
- - Comprehensive API reference and usage examples added to the `docs/wiki` directory.
39
+ 5. **Arc-based Consumer Architecture**:
40
+ - Improved internal architecture using `Arc<StreamConsumer>` for better memory management
41
+ - Enhanced thread safety for commit operations
36
42
 
37
43
  ---
38
44
 
@@ -92,13 +98,17 @@ async function run() {
92
98
  await consumer.subscribe([{ topic: 'foo' }]);
93
99
 
94
100
  const message = await consumer.recv();
95
- const { payload, partition, offset } = message;
101
+ const { payload, partition, offset, topic } = message;
96
102
  console.log({
103
+ topic,
97
104
  partition,
98
105
  offset,
99
106
  value: payload.toString()
100
107
  });
101
108
 
109
+ // Manual commit (v1.8.0+: now requires await)
110
+ await consumer.commit(topic, partition, offset + 1, 'Sync');
111
+
102
112
  consumer.unsubscribe();
103
113
 
104
114
  }
package/js-binding.cjs CHANGED
@@ -78,7 +78,12 @@ function requireNative() {
78
78
  loadErrors.push(e)
79
79
  }
80
80
  try {
81
- return require('kafka-crab-js-android-arm64')
81
+ const binding = require('kafka-crab-js-android-arm64')
82
+ const bindingPackageVersion = require('kafka-crab-js-android-arm64/package.json').version
83
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
84
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
85
+ }
86
+ return binding
82
87
  } catch (e) {
83
88
  loadErrors.push(e)
84
89
  }
@@ -89,7 +94,12 @@ function requireNative() {
89
94
  loadErrors.push(e)
90
95
  }
91
96
  try {
92
- return require('kafka-crab-js-android-arm-eabi')
97
+ const binding = require('kafka-crab-js-android-arm-eabi')
98
+ const bindingPackageVersion = require('kafka-crab-js-android-arm-eabi/package.json').version
99
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
100
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
101
+ }
102
+ return binding
93
103
  } catch (e) {
94
104
  loadErrors.push(e)
95
105
  }
@@ -104,7 +114,12 @@ function requireNative() {
104
114
  loadErrors.push(e)
105
115
  }
106
116
  try {
107
- return require('kafka-crab-js-win32-x64-msvc')
117
+ const binding = require('kafka-crab-js-win32-x64-msvc')
118
+ const bindingPackageVersion = require('kafka-crab-js-win32-x64-msvc/package.json').version
119
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
120
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
121
+ }
122
+ return binding
108
123
  } catch (e) {
109
124
  loadErrors.push(e)
110
125
  }
@@ -115,7 +130,12 @@ function requireNative() {
115
130
  loadErrors.push(e)
116
131
  }
117
132
  try {
118
- return require('kafka-crab-js-win32-ia32-msvc')
133
+ const binding = require('kafka-crab-js-win32-ia32-msvc')
134
+ const bindingPackageVersion = require('kafka-crab-js-win32-ia32-msvc/package.json').version
135
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
136
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
137
+ }
138
+ return binding
119
139
  } catch (e) {
120
140
  loadErrors.push(e)
121
141
  }
@@ -126,7 +146,12 @@ function requireNative() {
126
146
  loadErrors.push(e)
127
147
  }
128
148
  try {
129
- return require('kafka-crab-js-win32-arm64-msvc')
149
+ const binding = require('kafka-crab-js-win32-arm64-msvc')
150
+ const bindingPackageVersion = require('kafka-crab-js-win32-arm64-msvc/package.json').version
151
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
152
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
153
+ }
154
+ return binding
130
155
  } catch (e) {
131
156
  loadErrors.push(e)
132
157
  }
@@ -140,7 +165,12 @@ function requireNative() {
140
165
  loadErrors.push(e)
141
166
  }
142
167
  try {
143
- return require('kafka-crab-js-darwin-universal')
168
+ const binding = require('kafka-crab-js-darwin-universal')
169
+ const bindingPackageVersion = require('kafka-crab-js-darwin-universal/package.json').version
170
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
171
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
172
+ }
173
+ return binding
144
174
  } catch (e) {
145
175
  loadErrors.push(e)
146
176
  }
@@ -151,7 +181,12 @@ function requireNative() {
151
181
  loadErrors.push(e)
152
182
  }
153
183
  try {
154
- return require('kafka-crab-js-darwin-x64')
184
+ const binding = require('kafka-crab-js-darwin-x64')
185
+ const bindingPackageVersion = require('kafka-crab-js-darwin-x64/package.json').version
186
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
187
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
188
+ }
189
+ return binding
155
190
  } catch (e) {
156
191
  loadErrors.push(e)
157
192
  }
@@ -162,7 +197,12 @@ function requireNative() {
162
197
  loadErrors.push(e)
163
198
  }
164
199
  try {
165
- return require('kafka-crab-js-darwin-arm64')
200
+ const binding = require('kafka-crab-js-darwin-arm64')
201
+ const bindingPackageVersion = require('kafka-crab-js-darwin-arm64/package.json').version
202
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
203
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
204
+ }
205
+ return binding
166
206
  } catch (e) {
167
207
  loadErrors.push(e)
168
208
  }
@@ -177,7 +217,12 @@ function requireNative() {
177
217
  loadErrors.push(e)
178
218
  }
179
219
  try {
180
- return require('kafka-crab-js-freebsd-x64')
220
+ const binding = require('kafka-crab-js-freebsd-x64')
221
+ const bindingPackageVersion = require('kafka-crab-js-freebsd-x64/package.json').version
222
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
223
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
224
+ }
225
+ return binding
181
226
  } catch (e) {
182
227
  loadErrors.push(e)
183
228
  }
@@ -188,7 +233,12 @@ function requireNative() {
188
233
  loadErrors.push(e)
189
234
  }
190
235
  try {
191
- return require('kafka-crab-js-freebsd-arm64')
236
+ const binding = require('kafka-crab-js-freebsd-arm64')
237
+ const bindingPackageVersion = require('kafka-crab-js-freebsd-arm64/package.json').version
238
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
239
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
240
+ }
241
+ return binding
192
242
  } catch (e) {
193
243
  loadErrors.push(e)
194
244
  }
@@ -204,7 +254,12 @@ function requireNative() {
204
254
  loadErrors.push(e)
205
255
  }
206
256
  try {
207
- return require('kafka-crab-js-linux-x64-musl')
257
+ const binding = require('kafka-crab-js-linux-x64-musl')
258
+ const bindingPackageVersion = require('kafka-crab-js-linux-x64-musl/package.json').version
259
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
260
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
261
+ }
262
+ return binding
208
263
  } catch (e) {
209
264
  loadErrors.push(e)
210
265
  }
@@ -215,7 +270,12 @@ function requireNative() {
215
270
  loadErrors.push(e)
216
271
  }
217
272
  try {
218
- return require('kafka-crab-js-linux-x64-gnu')
273
+ const binding = require('kafka-crab-js-linux-x64-gnu')
274
+ const bindingPackageVersion = require('kafka-crab-js-linux-x64-gnu/package.json').version
275
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
276
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
277
+ }
278
+ return binding
219
279
  } catch (e) {
220
280
  loadErrors.push(e)
221
281
  }
@@ -228,7 +288,12 @@ function requireNative() {
228
288
  loadErrors.push(e)
229
289
  }
230
290
  try {
231
- return require('kafka-crab-js-linux-arm64-musl')
291
+ const binding = require('kafka-crab-js-linux-arm64-musl')
292
+ const bindingPackageVersion = require('kafka-crab-js-linux-arm64-musl/package.json').version
293
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
294
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
295
+ }
296
+ return binding
232
297
  } catch (e) {
233
298
  loadErrors.push(e)
234
299
  }
@@ -239,7 +304,12 @@ function requireNative() {
239
304
  loadErrors.push(e)
240
305
  }
241
306
  try {
242
- return require('kafka-crab-js-linux-arm64-gnu')
307
+ const binding = require('kafka-crab-js-linux-arm64-gnu')
308
+ const bindingPackageVersion = require('kafka-crab-js-linux-arm64-gnu/package.json').version
309
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
310
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
311
+ }
312
+ return binding
243
313
  } catch (e) {
244
314
  loadErrors.push(e)
245
315
  }
@@ -252,7 +322,12 @@ function requireNative() {
252
322
  loadErrors.push(e)
253
323
  }
254
324
  try {
255
- return require('kafka-crab-js-linux-arm-musleabihf')
325
+ const binding = require('kafka-crab-js-linux-arm-musleabihf')
326
+ const bindingPackageVersion = require('kafka-crab-js-linux-arm-musleabihf/package.json').version
327
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
328
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
329
+ }
330
+ return binding
256
331
  } catch (e) {
257
332
  loadErrors.push(e)
258
333
  }
@@ -263,7 +338,12 @@ function requireNative() {
263
338
  loadErrors.push(e)
264
339
  }
265
340
  try {
266
- return require('kafka-crab-js-linux-arm-gnueabihf')
341
+ const binding = require('kafka-crab-js-linux-arm-gnueabihf')
342
+ const bindingPackageVersion = require('kafka-crab-js-linux-arm-gnueabihf/package.json').version
343
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
344
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
345
+ }
346
+ return binding
267
347
  } catch (e) {
268
348
  loadErrors.push(e)
269
349
  }
@@ -276,7 +356,12 @@ function requireNative() {
276
356
  loadErrors.push(e)
277
357
  }
278
358
  try {
279
- return require('kafka-crab-js-linux-riscv64-musl')
359
+ const binding = require('kafka-crab-js-linux-riscv64-musl')
360
+ const bindingPackageVersion = require('kafka-crab-js-linux-riscv64-musl/package.json').version
361
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
362
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
363
+ }
364
+ return binding
280
365
  } catch (e) {
281
366
  loadErrors.push(e)
282
367
  }
@@ -287,7 +372,12 @@ function requireNative() {
287
372
  loadErrors.push(e)
288
373
  }
289
374
  try {
290
- return require('kafka-crab-js-linux-riscv64-gnu')
375
+ const binding = require('kafka-crab-js-linux-riscv64-gnu')
376
+ const bindingPackageVersion = require('kafka-crab-js-linux-riscv64-gnu/package.json').version
377
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
378
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
379
+ }
380
+ return binding
291
381
  } catch (e) {
292
382
  loadErrors.push(e)
293
383
  }
@@ -299,7 +389,12 @@ function requireNative() {
299
389
  loadErrors.push(e)
300
390
  }
301
391
  try {
302
- return require('kafka-crab-js-linux-ppc64-gnu')
392
+ const binding = require('kafka-crab-js-linux-ppc64-gnu')
393
+ const bindingPackageVersion = require('kafka-crab-js-linux-ppc64-gnu/package.json').version
394
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
395
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
396
+ }
397
+ return binding
303
398
  } catch (e) {
304
399
  loadErrors.push(e)
305
400
  }
@@ -310,7 +405,12 @@ function requireNative() {
310
405
  loadErrors.push(e)
311
406
  }
312
407
  try {
313
- return require('kafka-crab-js-linux-s390x-gnu')
408
+ const binding = require('kafka-crab-js-linux-s390x-gnu')
409
+ const bindingPackageVersion = require('kafka-crab-js-linux-s390x-gnu/package.json').version
410
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
412
+ }
413
+ return binding
314
414
  } catch (e) {
315
415
  loadErrors.push(e)
316
416
  }
@@ -320,34 +420,49 @@ function requireNative() {
320
420
  } else if (process.platform === 'openharmony') {
321
421
  if (process.arch === 'arm64') {
322
422
  try {
323
- return require('./kafka-crab-js.linux-arm64-ohos.node')
423
+ return require('./kafka-crab-js.openharmony-arm64.node')
324
424
  } catch (e) {
325
425
  loadErrors.push(e)
326
426
  }
327
427
  try {
328
- return require('kafka-crab-js-linux-arm64-ohos')
428
+ const binding = require('kafka-crab-js-openharmony-arm64')
429
+ const bindingPackageVersion = require('kafka-crab-js-openharmony-arm64/package.json').version
430
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
431
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
432
+ }
433
+ return binding
329
434
  } catch (e) {
330
435
  loadErrors.push(e)
331
436
  }
332
437
  } else if (process.arch === 'x64') {
333
438
  try {
334
- return require('./kafka-crab-js.linux-x64-ohos.node')
439
+ return require('./kafka-crab-js.openharmony-x64.node')
335
440
  } catch (e) {
336
441
  loadErrors.push(e)
337
442
  }
338
443
  try {
339
- return require('kafka-crab-js-linux-x64-ohos')
444
+ const binding = require('kafka-crab-js-openharmony-x64')
445
+ const bindingPackageVersion = require('kafka-crab-js-openharmony-x64/package.json').version
446
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
447
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
448
+ }
449
+ return binding
340
450
  } catch (e) {
341
451
  loadErrors.push(e)
342
452
  }
343
453
  } else if (process.arch === 'arm') {
344
454
  try {
345
- return require('./kafka-crab-js.linux-arm-ohos.node')
455
+ return require('./kafka-crab-js.openharmony-arm.node')
346
456
  } catch (e) {
347
457
  loadErrors.push(e)
348
458
  }
349
459
  try {
350
- return require('kafka-crab-js-linux-arm-ohos')
460
+ const binding = require('kafka-crab-js-openharmony-arm')
461
+ const bindingPackageVersion = require('kafka-crab-js-openharmony-arm/package.json').version
462
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
463
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
464
+ }
465
+ return binding
351
466
  } catch (e) {
352
467
  loadErrors.push(e)
353
468
  }
package/js-binding.d.ts CHANGED
@@ -28,7 +28,7 @@ export declare class KafkaConsumer {
28
28
  * @returns Array of messages (may be fewer than max_messages)
29
29
  */
30
30
  recvBatch(maxMessages: number, timeoutMs: number): Promise<Array<Message>>
31
- commit(topic: string, partition: number, offset: number, commit: CommitMode): void
31
+ commit(topic: string, partition: number, offset: number, commit: CommitMode): Promise<void>
32
32
  }
33
33
 
34
34
  export declare class KafkaProducer {
package/js-binding.js CHANGED
@@ -79,7 +79,12 @@ function requireNative() {
79
79
  loadErrors.push(e)
80
80
  }
81
81
  try {
82
- return require('kafka-crab-js-android-arm64')
82
+ const binding = require('kafka-crab-js-android-arm64')
83
+ const bindingPackageVersion = require('kafka-crab-js-android-arm64/package.json').version
84
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
85
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
86
+ }
87
+ return binding
83
88
  } catch (e) {
84
89
  loadErrors.push(e)
85
90
  }
@@ -90,7 +95,12 @@ function requireNative() {
90
95
  loadErrors.push(e)
91
96
  }
92
97
  try {
93
- return require('kafka-crab-js-android-arm-eabi')
98
+ const binding = require('kafka-crab-js-android-arm-eabi')
99
+ const bindingPackageVersion = require('kafka-crab-js-android-arm-eabi/package.json').version
100
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
101
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
102
+ }
103
+ return binding
94
104
  } catch (e) {
95
105
  loadErrors.push(e)
96
106
  }
@@ -105,7 +115,12 @@ function requireNative() {
105
115
  loadErrors.push(e)
106
116
  }
107
117
  try {
108
- return require('kafka-crab-js-win32-x64-msvc')
118
+ const binding = require('kafka-crab-js-win32-x64-msvc')
119
+ const bindingPackageVersion = require('kafka-crab-js-win32-x64-msvc/package.json').version
120
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
121
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
122
+ }
123
+ return binding
109
124
  } catch (e) {
110
125
  loadErrors.push(e)
111
126
  }
@@ -116,7 +131,12 @@ function requireNative() {
116
131
  loadErrors.push(e)
117
132
  }
118
133
  try {
119
- return require('kafka-crab-js-win32-ia32-msvc')
134
+ const binding = require('kafka-crab-js-win32-ia32-msvc')
135
+ const bindingPackageVersion = require('kafka-crab-js-win32-ia32-msvc/package.json').version
136
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
137
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
138
+ }
139
+ return binding
120
140
  } catch (e) {
121
141
  loadErrors.push(e)
122
142
  }
@@ -127,7 +147,12 @@ function requireNative() {
127
147
  loadErrors.push(e)
128
148
  }
129
149
  try {
130
- return require('kafka-crab-js-win32-arm64-msvc')
150
+ const binding = require('kafka-crab-js-win32-arm64-msvc')
151
+ const bindingPackageVersion = require('kafka-crab-js-win32-arm64-msvc/package.json').version
152
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
153
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
154
+ }
155
+ return binding
131
156
  } catch (e) {
132
157
  loadErrors.push(e)
133
158
  }
@@ -141,7 +166,12 @@ function requireNative() {
141
166
  loadErrors.push(e)
142
167
  }
143
168
  try {
144
- return require('kafka-crab-js-darwin-universal')
169
+ const binding = require('kafka-crab-js-darwin-universal')
170
+ const bindingPackageVersion = require('kafka-crab-js-darwin-universal/package.json').version
171
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
172
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
173
+ }
174
+ return binding
145
175
  } catch (e) {
146
176
  loadErrors.push(e)
147
177
  }
@@ -152,7 +182,12 @@ function requireNative() {
152
182
  loadErrors.push(e)
153
183
  }
154
184
  try {
155
- return require('kafka-crab-js-darwin-x64')
185
+ const binding = require('kafka-crab-js-darwin-x64')
186
+ const bindingPackageVersion = require('kafka-crab-js-darwin-x64/package.json').version
187
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
188
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
189
+ }
190
+ return binding
156
191
  } catch (e) {
157
192
  loadErrors.push(e)
158
193
  }
@@ -163,7 +198,12 @@ function requireNative() {
163
198
  loadErrors.push(e)
164
199
  }
165
200
  try {
166
- return require('kafka-crab-js-darwin-arm64')
201
+ const binding = require('kafka-crab-js-darwin-arm64')
202
+ const bindingPackageVersion = require('kafka-crab-js-darwin-arm64/package.json').version
203
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
204
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
205
+ }
206
+ return binding
167
207
  } catch (e) {
168
208
  loadErrors.push(e)
169
209
  }
@@ -178,7 +218,12 @@ function requireNative() {
178
218
  loadErrors.push(e)
179
219
  }
180
220
  try {
181
- return require('kafka-crab-js-freebsd-x64')
221
+ const binding = require('kafka-crab-js-freebsd-x64')
222
+ const bindingPackageVersion = require('kafka-crab-js-freebsd-x64/package.json').version
223
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
224
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
225
+ }
226
+ return binding
182
227
  } catch (e) {
183
228
  loadErrors.push(e)
184
229
  }
@@ -189,7 +234,12 @@ function requireNative() {
189
234
  loadErrors.push(e)
190
235
  }
191
236
  try {
192
- return require('kafka-crab-js-freebsd-arm64')
237
+ const binding = require('kafka-crab-js-freebsd-arm64')
238
+ const bindingPackageVersion = require('kafka-crab-js-freebsd-arm64/package.json').version
239
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
240
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
241
+ }
242
+ return binding
193
243
  } catch (e) {
194
244
  loadErrors.push(e)
195
245
  }
@@ -205,7 +255,12 @@ function requireNative() {
205
255
  loadErrors.push(e)
206
256
  }
207
257
  try {
208
- return require('kafka-crab-js-linux-x64-musl')
258
+ const binding = require('kafka-crab-js-linux-x64-musl')
259
+ const bindingPackageVersion = require('kafka-crab-js-linux-x64-musl/package.json').version
260
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
261
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
262
+ }
263
+ return binding
209
264
  } catch (e) {
210
265
  loadErrors.push(e)
211
266
  }
@@ -216,7 +271,12 @@ function requireNative() {
216
271
  loadErrors.push(e)
217
272
  }
218
273
  try {
219
- return require('kafka-crab-js-linux-x64-gnu')
274
+ const binding = require('kafka-crab-js-linux-x64-gnu')
275
+ const bindingPackageVersion = require('kafka-crab-js-linux-x64-gnu/package.json').version
276
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
277
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
278
+ }
279
+ return binding
220
280
  } catch (e) {
221
281
  loadErrors.push(e)
222
282
  }
@@ -229,7 +289,12 @@ function requireNative() {
229
289
  loadErrors.push(e)
230
290
  }
231
291
  try {
232
- return require('kafka-crab-js-linux-arm64-musl')
292
+ const binding = require('kafka-crab-js-linux-arm64-musl')
293
+ const bindingPackageVersion = require('kafka-crab-js-linux-arm64-musl/package.json').version
294
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
295
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
296
+ }
297
+ return binding
233
298
  } catch (e) {
234
299
  loadErrors.push(e)
235
300
  }
@@ -240,7 +305,12 @@ function requireNative() {
240
305
  loadErrors.push(e)
241
306
  }
242
307
  try {
243
- return require('kafka-crab-js-linux-arm64-gnu')
308
+ const binding = require('kafka-crab-js-linux-arm64-gnu')
309
+ const bindingPackageVersion = require('kafka-crab-js-linux-arm64-gnu/package.json').version
310
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
311
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
312
+ }
313
+ return binding
244
314
  } catch (e) {
245
315
  loadErrors.push(e)
246
316
  }
@@ -253,7 +323,12 @@ function requireNative() {
253
323
  loadErrors.push(e)
254
324
  }
255
325
  try {
256
- return require('kafka-crab-js-linux-arm-musleabihf')
326
+ const binding = require('kafka-crab-js-linux-arm-musleabihf')
327
+ const bindingPackageVersion = require('kafka-crab-js-linux-arm-musleabihf/package.json').version
328
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
329
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
330
+ }
331
+ return binding
257
332
  } catch (e) {
258
333
  loadErrors.push(e)
259
334
  }
@@ -264,7 +339,12 @@ function requireNative() {
264
339
  loadErrors.push(e)
265
340
  }
266
341
  try {
267
- return require('kafka-crab-js-linux-arm-gnueabihf')
342
+ const binding = require('kafka-crab-js-linux-arm-gnueabihf')
343
+ const bindingPackageVersion = require('kafka-crab-js-linux-arm-gnueabihf/package.json').version
344
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
345
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
346
+ }
347
+ return binding
268
348
  } catch (e) {
269
349
  loadErrors.push(e)
270
350
  }
@@ -277,7 +357,12 @@ function requireNative() {
277
357
  loadErrors.push(e)
278
358
  }
279
359
  try {
280
- return require('kafka-crab-js-linux-riscv64-musl')
360
+ const binding = require('kafka-crab-js-linux-riscv64-musl')
361
+ const bindingPackageVersion = require('kafka-crab-js-linux-riscv64-musl/package.json').version
362
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
363
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
364
+ }
365
+ return binding
281
366
  } catch (e) {
282
367
  loadErrors.push(e)
283
368
  }
@@ -288,7 +373,12 @@ function requireNative() {
288
373
  loadErrors.push(e)
289
374
  }
290
375
  try {
291
- return require('kafka-crab-js-linux-riscv64-gnu')
376
+ const binding = require('kafka-crab-js-linux-riscv64-gnu')
377
+ const bindingPackageVersion = require('kafka-crab-js-linux-riscv64-gnu/package.json').version
378
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
379
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
380
+ }
381
+ return binding
292
382
  } catch (e) {
293
383
  loadErrors.push(e)
294
384
  }
@@ -300,7 +390,12 @@ function requireNative() {
300
390
  loadErrors.push(e)
301
391
  }
302
392
  try {
303
- return require('kafka-crab-js-linux-ppc64-gnu')
393
+ const binding = require('kafka-crab-js-linux-ppc64-gnu')
394
+ const bindingPackageVersion = require('kafka-crab-js-linux-ppc64-gnu/package.json').version
395
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
396
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
397
+ }
398
+ return binding
304
399
  } catch (e) {
305
400
  loadErrors.push(e)
306
401
  }
@@ -311,7 +406,12 @@ function requireNative() {
311
406
  loadErrors.push(e)
312
407
  }
313
408
  try {
314
- return require('kafka-crab-js-linux-s390x-gnu')
409
+ const binding = require('kafka-crab-js-linux-s390x-gnu')
410
+ const bindingPackageVersion = require('kafka-crab-js-linux-s390x-gnu/package.json').version
411
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
412
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
413
+ }
414
+ return binding
315
415
  } catch (e) {
316
416
  loadErrors.push(e)
317
417
  }
@@ -321,34 +421,49 @@ function requireNative() {
321
421
  } else if (process.platform === 'openharmony') {
322
422
  if (process.arch === 'arm64') {
323
423
  try {
324
- return require('./kafka-crab-js.linux-arm64-ohos.node')
424
+ return require('./kafka-crab-js.openharmony-arm64.node')
325
425
  } catch (e) {
326
426
  loadErrors.push(e)
327
427
  }
328
428
  try {
329
- return require('kafka-crab-js-linux-arm64-ohos')
429
+ const binding = require('kafka-crab-js-openharmony-arm64')
430
+ const bindingPackageVersion = require('kafka-crab-js-openharmony-arm64/package.json').version
431
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
432
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
433
+ }
434
+ return binding
330
435
  } catch (e) {
331
436
  loadErrors.push(e)
332
437
  }
333
438
  } else if (process.arch === 'x64') {
334
439
  try {
335
- return require('./kafka-crab-js.linux-x64-ohos.node')
440
+ return require('./kafka-crab-js.openharmony-x64.node')
336
441
  } catch (e) {
337
442
  loadErrors.push(e)
338
443
  }
339
444
  try {
340
- return require('kafka-crab-js-linux-x64-ohos')
445
+ const binding = require('kafka-crab-js-openharmony-x64')
446
+ const bindingPackageVersion = require('kafka-crab-js-openharmony-x64/package.json').version
447
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
448
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
449
+ }
450
+ return binding
341
451
  } catch (e) {
342
452
  loadErrors.push(e)
343
453
  }
344
454
  } else if (process.arch === 'arm') {
345
455
  try {
346
- return require('./kafka-crab-js.linux-arm-ohos.node')
456
+ return require('./kafka-crab-js.openharmony-arm.node')
347
457
  } catch (e) {
348
458
  loadErrors.push(e)
349
459
  }
350
460
  try {
351
- return require('kafka-crab-js-linux-arm-ohos')
461
+ const binding = require('kafka-crab-js-openharmony-arm')
462
+ const bindingPackageVersion = require('kafka-crab-js-openharmony-arm/package.json').version
463
+ if (bindingPackageVersion !== '1.7.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
464
+ throw new Error(`Native binding package version mismatch, expected 1.7.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
465
+ }
466
+ return binding
352
467
  } catch (e) {
353
468
  loadErrors.push(e)
354
469
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kafka-crab-js",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=20"
@@ -69,23 +69,23 @@
69
69
  },
70
70
  "packageManager": "pnpm@10.12.1",
71
71
  "dependencies": {
72
- "@napi-rs/cli": "^3.0.4"
72
+ "@napi-rs/cli": "^3.1.5"
73
73
  },
74
74
  "devDependencies": {
75
- "@types/node": "^24.2.0",
75
+ "@types/node": "^24.3.0",
76
76
  "dprint": "^0.50.1",
77
- "esbuild": "^0.25.8",
77
+ "esbuild": "^0.25.9",
78
78
  "nanoid": "^5.1.5",
79
- "oxlint": "^1.9.0",
79
+ "oxlint": "^1.12.0",
80
80
  "rimraf": "^6.0.1",
81
81
  "typescript": "^5.9.2"
82
82
  },
83
83
  "optionalDependencies": {
84
- "kafka-crab-js-darwin-x64": "1.7.0",
85
- "kafka-crab-js-darwin-arm64": "1.7.0",
86
- "kafka-crab-js-linux-x64-gnu": "1.7.0",
87
- "kafka-crab-js-linux-x64-musl": "1.7.0",
88
- "kafka-crab-js-linux-arm64-gnu": "1.7.0",
89
- "kafka-crab-js-linux-arm64-musl": "1.7.0"
84
+ "kafka-crab-js-darwin-x64": "1.8.0",
85
+ "kafka-crab-js-darwin-arm64": "1.8.0",
86
+ "kafka-crab-js-linux-x64-gnu": "1.8.0",
87
+ "kafka-crab-js-linux-x64-musl": "1.8.0",
88
+ "kafka-crab-js-linux-arm64-gnu": "1.8.0",
89
+ "kafka-crab-js-linux-arm64-musl": "1.8.0"
90
90
  }
91
91
  }