@valkey/valkey-glide 2.4.0-rc1 → 2.4.0-rc3

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.
@@ -163,22 +163,6 @@ function convertRecordToGlideRecord(data) {
163
163
  return { key, value };
164
164
  });
165
165
  }
166
- /**
167
- * Our purpose in creating PointerResponse type is to mark when response is of number/long pointer response type.
168
- * Consequently, when the response is returned, we can check whether it is instanceof the PointerResponse type and pass it to the Rust core function with the proper parameters.
169
- */
170
- class PointerResponse {
171
- pointer;
172
- // As Javascript does not support 64-bit integers,
173
- // we split the Rust u64 pointer into two u32 integers (high and low) and build it again when we call value_from_split_pointer, the Rust function.
174
- high;
175
- low;
176
- constructor(pointer, high, low) {
177
- this.pointer = pointer;
178
- this.high = high;
179
- this.low = low;
180
- }
181
- }
182
166
  /** Represents the types of services that can be used for IAM authentication. */
183
167
  var ServiceType;
184
168
  (function (ServiceType) {
@@ -401,18 +385,11 @@ class BaseClient {
401
385
  reject(new errorType(message.requestError.message ?? undefined));
402
386
  }
403
387
  else if (message.respPointer != null) {
404
- let pointer;
405
- if (typeof message.respPointer === "number") {
406
- // Response from type number
407
- const long = long_1.default.fromNumber(message.respPointer);
408
- pointer = new PointerResponse(message.respPointer, long.high, long.low);
409
- }
410
- else {
411
- // Response from type long
412
- pointer = new PointerResponse(message.respPointer, message.respPointer.high, message.respPointer.low);
413
- }
388
+ const ptrNum = typeof message.respPointer === "number"
389
+ ? message.respPointer
390
+ : message.respPointer.toNumber();
414
391
  try {
415
- resolve((0, _1.valueFromSplitPointer)(pointer.high, pointer.low, decoder === Decoder.String));
392
+ resolve((0, _1.valueFromPointer)(ptrNum, decoder === Decoder.String));
416
393
  }
417
394
  catch (err) {
418
395
  _1.Logger.log("error", "Decoder", `Decoding error: '${err}'`);
@@ -739,12 +716,10 @@ class BaseClient {
739
716
  let nextPushNotificationValue = {};
740
717
  const isStringDecoder = (decoder ?? this.defaultDecoder) === Decoder.String;
741
718
  if (responsePointer) {
742
- if (typeof responsePointer !== "number") {
743
- nextPushNotificationValue = (0, _1.valueFromSplitPointer)(responsePointer.high, responsePointer.low, isStringDecoder);
744
- }
745
- else {
746
- nextPushNotificationValue = (0, _1.valueFromSplitPointer)(0, responsePointer, isStringDecoder);
747
- }
719
+ const ptrNum = typeof responsePointer === "number"
720
+ ? responsePointer
721
+ : responsePointer.toNumber();
722
+ nextPushNotificationValue = (0, _1.valueFromPointer)(ptrNum, isStringDecoder);
748
723
  const messageKind = nextPushNotificationValue["kind"];
749
724
  if (messageKind === "Disconnect") {
750
725
  _1.Logger.log("warn", "disconnect notification", "Transport disconnected, messages might be lost");
@@ -70,7 +70,17 @@ export declare function StartSocketConnection(): Promise<string>
70
70
  export declare function InitOpenTelemetry(openTelemetryConfig: OpenTelemetryConfig): void
71
71
  export declare function log(logLevel: Level, logIdentifier: string, message: string): void
72
72
  export declare function InitInternalLogger(level?: Level | undefined | null, fileName?: string | undefined | null): Level
73
- export declare function valueFromSplitPointer(highBits: number, lowBits: number, stringDecoder: boolean): null | string | Uint8Array | number | {} | Boolean | BigInt | Set<any> | any[] | Buffer
73
+ /**
74
+ * Dereference a response pointer passed as a single JS number.
75
+ *
76
+ * napi-rs marshals `i64` via `napi_get_value_int64`, which preserves all
77
+ * bits for values within the safe integer range. User-space heap addresses
78
+ * on current 64-bit platforms (48-bit on arm64 macOS, 47-bit on x86-64
79
+ * Linux) are well within this range. Using a single integer avoids the
80
+ * high/low u32 split and eliminates the class of bugs where the caller
81
+ * passes the wrong high bits.
82
+ */
83
+ export declare function valueFromPointer(pointerNumber: number, stringDecoder: boolean): null | string | Uint8Array | number | {} | Boolean | BigInt | Set<any> | any[] | Buffer
74
84
  /**
75
85
  * @internal @test
76
86
  * This function is for tests that require a value allocated on the heap.
@@ -310,7 +310,7 @@ if (!nativeBinding) {
310
310
  throw new Error(`Failed to load native binding`)
311
311
  }
312
312
 
313
- const { Level, MAX_REQUEST_ARGS_LEN, DEFAULT_REQUEST_TIMEOUT_IN_MILLISECONDS, DEFAULT_CONNECTION_TIMEOUT_IN_MILLISECONDS, DEFAULT_INFLIGHT_REQUESTS_LIMIT, AsyncClient, StartSocketConnection, InitOpenTelemetry, log, InitInternalLogger, valueFromSplitPointer, createLeakedStringVec, createLeakedOtelSpan, createOtelSpanWithTraceContext, dropOtelSpan, Script, ClusterScanCursor, getStatistics } = nativeBinding
313
+ const { Level, MAX_REQUEST_ARGS_LEN, DEFAULT_REQUEST_TIMEOUT_IN_MILLISECONDS, DEFAULT_CONNECTION_TIMEOUT_IN_MILLISECONDS, DEFAULT_INFLIGHT_REQUESTS_LIMIT, AsyncClient, StartSocketConnection, InitOpenTelemetry, log, InitInternalLogger, valueFromPointer, createLeakedStringVec, createLeakedOtelSpan, createOtelSpanWithTraceContext, dropOtelSpan, Script, ClusterScanCursor, getStatistics } = nativeBinding
314
314
 
315
315
  module.exports.Level = Level
316
316
  module.exports.MAX_REQUEST_ARGS_LEN = MAX_REQUEST_ARGS_LEN
@@ -322,7 +322,7 @@ module.exports.StartSocketConnection = StartSocketConnection
322
322
  module.exports.InitOpenTelemetry = InitOpenTelemetry
323
323
  module.exports.log = log
324
324
  module.exports.InitInternalLogger = InitInternalLogger
325
- module.exports.valueFromSplitPointer = valueFromSplitPointer
325
+ module.exports.valueFromPointer = valueFromPointer
326
326
  module.exports.createLeakedStringVec = createLeakedStringVec
327
327
  module.exports.createLeakedOtelSpan = createLeakedOtelSpan
328
328
  module.exports.createOtelSpanWithTraceContext = createOtelSpanWithTraceContext
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "main": "build-ts/index.js",
5
5
  "module": "build-ts/index.js",
6
6
  "types": "build-ts/index.d.ts",
7
- "version": "2.4.0-rc1",
7
+ "version": "2.4.0-rc3",
8
8
  "exports": {
9
9
  ".": {
10
10
  "import": {
@@ -135,11 +135,11 @@
135
135
  }
136
136
  },
137
137
  "optionalDependencies": {
138
- "@valkey/valkey-glide-darwin-x64": "2.4.0-rc1",
139
- "@valkey/valkey-glide-darwin-arm64": "2.4.0-rc1",
140
- "@valkey/valkey-glide-linux-x64-gnu": "2.4.0-rc1",
141
- "@valkey/valkey-glide-linux-arm64-gnu": "2.4.0-rc1",
142
- "@valkey/valkey-glide-linux-x64-musl": "2.4.0-rc1",
143
- "@valkey/valkey-glide-linux-arm64-musl": "2.4.0-rc1"
138
+ "@valkey/valkey-glide-darwin-x64": "2.4.0-rc3",
139
+ "@valkey/valkey-glide-darwin-arm64": "2.4.0-rc3",
140
+ "@valkey/valkey-glide-linux-x64-gnu": "2.4.0-rc3",
141
+ "@valkey/valkey-glide-linux-arm64-gnu": "2.4.0-rc3",
142
+ "@valkey/valkey-glide-linux-x64-musl": "2.4.0-rc3",
143
+ "@valkey/valkey-glide-linux-arm64-musl": "2.4.0-rc3"
144
144
  }
145
145
  }