JavaScript SDK 0.5.0
On this page
Related contents
Released .
JavaScript SDK 0.5.0 follows 0.4.0 with server-assigned statement identifiers, typed regular-expression search index analyzers in Catalog definitions, and stricter HTTP error-envelope validation across Node.js, Bun, and Cloudflare Workers. Node.js 20 remains the minimum supported Node.js version. For a new application, start with the JavaScript SDK guide.
What's new
- Configure custom regular-expression search analyzers on Catalog columns with
CatalogSearchAnalyzer({ patterns: string[] }), or omitanalyzerto use the server's default tokenization pattern. - Use server-assigned statement IDs on
StatementHandle.statementIdand post-submission errors (error.statementId), withwithMaxElapsedSeconds()mapped directly totimeout_secondsand retryable submissions limited to validated coded HTTP429admission refusals. - From 0.4.0: serialize exact 64-bit
bigintvalues withencodeAppendRecord()and.strictEncoding(true), guard Catalog mutations withversionandexpectedVersion, and inspectScopeDBError.catalogOutcomeandAppendOutcome.
Upgrade from 0.4 and 0.3
Update the dependency and commit your manifest and lockfile:
npm install scopedb@0.5.0Applications upgrading from 0.4.0 only need the 0.5 statement and analyzer updates below. Applications upgrading directly from 0.3.0 should also apply the Catalog, Append outcome, and factory-method updates introduced in 0.4.0. Applications using 0.2 should first follow Upgrade from 0.2.
Update statement identifiers, deadlines, and submission recovery
ScopeDB assigns each statement ID when accepting a submission. Client-supplied statement IDs and estimated execution limits are removed:
| In 0.4 | In 0.5 |
|---|---|
statement.withStatementId(id) | Removed; read handle.statementId after submit() |
statement.withMaxEstimatedSeconds(sec) | Removed; use withMaxElapsedSeconds(sec) if a total deadline fits |
error.statementId on failed submit() | undefined; reconcile side effects unless error.retryable is true |
Statement.withMaxElapsedSeconds(seconds) sets the server's timeout_seconds deadline, covering queueing, preparation, and execution. If submit() (or the submission step of execute() or client.query()) fails before receiving a valid status snapshot, error.statementId is undefined, and only validated coded HTTP 429 admission refusals (error.serverRetryable !== false) report error.retryable === true. Once submission succeeds, handle.statementId and ScopeDBError failures from polling or waiting retain the server-assigned ID so you can resume waiting with client.statementHandle(error.statementId) (caller AbortSignal cancellations rethrow the signal's abort reason directly; call submit() first to keep handle across local signal timeouts).
Update Catalog search index analyzers
CatalogColumnIndex.analyzer changes from "log" to CatalogSearchAnalyzer ({ patterns: string[] }):
| In 0.4 | In 0.5 |
|---|---|
{ type: "search" } or { type: "search", analyzer: "log" } | { type: "search" } |
| Untyped JSON workarounds for custom regex rules | { type: "search", analyzer: { patterns: [...] } } |
Omit analyzer for the server's default tokenization pattern, or pass { patterns } for custom regular-expression patterns:
import type { CatalogColumn } from "scopedb";
const messageColumn: CatalogColumn = {
name: "message",
data_type: "string",
indexes: [
{
type: "search",
analyzer: { patterns: ["[A-Za-z0-9_]+", "req-[0-9]+"] },
},
],
};Reading definitions normalizes null, {}, and legacy "log" values to an omitted analyzer field.
Rename Catalog versions, Append outcomes, and factories (from 0.3)
If you are upgrading directly from 0.3.0, update these 0.4 changes as well, including runtime string comparisons in error classifiers and test fixtures:
| In 0.3 | In 0.4 and 0.5 |
|---|---|
CatalogSnapshot.etag / Result.etag | version |
CatalogOptions.ifMatch | expectedVersion |
Checking catalog_commit_outcome_unknown | error.catalogOutcome ("rejected" or "unknown") |
AppendState ("committed", "rejected", "unknown") | AppendOutcome ("succeeded", "failed", "ambiguous") |
AppendRowsError.outcome ("rejected", "unknown") | "failed" or "ambiguous" (and writeDetails.outcome: "ambiguous") |
retryUnknown, unknownRows, unknownBatches | retryAmbiguous, ambiguousRows, ambiguousBatches |
Delivery report "ok" / "unknown" | "succeeded" / "ambiguous" |
Direct new Table(...), new Statement(...), new StatementHandle(...), new Catalog(...) | Client and catalog factory methods (client.table(), client.statement(), client.statementHandle(), client.catalog()) |
ResultSet.fromStatementResultSet(...) | await client.query(...) / await handle.wait() (or new ResultSet(fields, numRows, rows) in test fixtures) |