@reddb-io/client 1.26.2 → 1.26.4

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
@@ -75,6 +75,14 @@ For `http://` and `https://` connections, `connect()` verifies readiness with
75
75
  a lightweight `SELECT 1` round-trip. `/health` states such as `degraded` are
76
76
  transient during boot and are not fatal as long as queries succeed.
77
77
 
78
+ RedWire query parameters retain `Float32Array`, `Float64Array`, `Uint8Array`
79
+ and `Buffer` views through normalization, avoiding intermediate number arrays
80
+ and base64 strings. The request owns its encoded bytes before `query()` yields;
81
+ later mutations of caller-owned views do not change the sent request. The
82
+ transport drops input-view references before waiting for the network. HTTP/gRPC
83
+ keep the same JSON-compatible parameter envelopes. See the measured
84
+ [encoding results](../../docs/perf/client-codecs-2026-10-23.md).
85
+
78
86
  ## Transactions
79
87
 
80
88
  Use `db.transaction()` when a group of writes must commit or roll back together.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reddb-io/client",
3
- "version": "1.26.2",
3
+ "version": "1.26.4",
4
4
  "description": "Thin remote-only RedDB driver. Pure JavaScript — no install scripts, no native binary. Speaks RedWire/gRPC/HTTP. Embedded URIs (memory://, file://, red:///path) are rejected — use @reddb-io/sdk for those.",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/core/reddb.js CHANGED
@@ -122,7 +122,7 @@ export class RedDB {
122
122
 
123
123
  /** Execute a SQL query. Returns `{ statement, affected, columns, rows }`. */
124
124
  query(sql, ...params) {
125
- const wireParams = normalizeQueryParams(params)
125
+ const wireParams = normalizeQueryParams(params, this.client.binaryQueryParams === true)
126
126
  if (wireParams == null) {
127
127
  return this.client.call('query', { sql }).then(normalizeExactNumbers)
128
128
  }
@@ -126,10 +126,20 @@ export function assertSupportedParam(value) {
126
126
  )
127
127
  }
128
128
 
129
- export function normalizeQueryParams(args) {
129
+ function serializeBinaryParam(value) {
130
+ if (value instanceof Uint8Array || value instanceof Float32Array || value instanceof Float64Array) {
131
+ // Preserve the existing handling of empty, detached and resized views.
132
+ if (value.byteLength === 0) return serializeParam(value)
133
+ return value
134
+ }
135
+ return serializeParam(value)
136
+ }
137
+
138
+ export function normalizeQueryParams(args, binary = false) {
130
139
  if (args.length === 0) return null
131
- if (args.length === 1 && Array.isArray(args[0])) return args[0].map(serializeParam)
132
- return args.map(serializeParam)
140
+ const serialize = binary ? serializeBinaryParam : serializeParam
141
+ if (args.length === 1 && Array.isArray(args[0])) return args[0].map(serialize)
142
+ return args.map(serialize)
133
143
  }
134
144
 
135
145
  export function bytesToBase64(value) {
@@ -226,6 +226,8 @@ export class RedWireClient {
226
226
  this.reader = reader
227
227
  this.session = session
228
228
  this.serverFeatures = serverFeatures >>> 0
229
+ // RedWire consumes typed views directly; JSON transports use envelopes.
230
+ this.binaryQueryParams = true
229
231
  this.nextCorr = 1n
230
232
  this.nextStream = 1
231
233
  this.closed = false
@@ -357,6 +359,8 @@ export class RedWireClient {
357
359
  kind = isSelectQuery(sql) ? MessageKind.QueryBinary : MessageKind.Query
358
360
  payload = new TextEncoder().encode(sql)
359
361
  }
362
+ // The encoded payload owns its bytes; release caller views before suspending.
363
+ params = undefined
360
364
  await writeFrame(this.socket, kind, corr, payload)
361
365
  const resp = await this.reader.next()
362
366
  if (resp.kind === MessageKind.Result) {