You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Each match carries the `dataset` it was found in, its similarity `score`, the matched
106
+
column values in `matches`, the dataset's `primary_key`, any `additional_columns` you
107
+
requested in `data`, and `metadata`. The four object fields are always present — they
108
+
default to `{}` when the runtime returns nothing for them, so you can read into them
109
+
without a guard.
110
+
85
111
## Upgrading from v2 to v3
86
112
87
113
Version 3.0 represents a major evolution of the SDK with cross-platform support, new APIs, and enhanced reliability.
@@ -560,6 +586,35 @@ Options:
560
586
-`refresh_sql`: Custom SQL query to use for the refresh
561
587
-`refresh_jitter_max`: Maximum jitter time for refresh scheduling
562
588
589
+
#### `listActiveQueries()` / `cancelActiveQuery(queryId)` - List and cancel running queries
590
+
591
+
`listActiveQueries()` reports the synchronous queries this client currently has running — those started by `sql()`, `query()`, `sqlJson()`, FlightSQL, `nsql()` and `search()` — and `cancelActiveQuery()` stops one by id.
592
+
593
+
The runtime does not hand a query's id back to the client that submitted it, so the two are used together: list to find the query, then cancel it. Both are scoped to the caller, so a client only ever sees and cancels its own queries.
console.log(`${result.query_id} is now ${result.status}`);
607
+
}
608
+
```
609
+
610
+
Each `ActiveQuery` carries `query_id`, `protocol` (`http`, `flight`, `flightsql`, or `internal`), a truncated `sql_preview`, and `started_at_ms` as milliseconds since the Unix epoch.
611
+
612
+
`cancelActiveQuery()` throws when the id is not a UUID, when the API key lacks write access, or when no such query is running — including the case where the id belongs to a different caller, which the runtime reports as not found rather than cancelling.
613
+
614
+
The boundary is the **caller's identity, not the client instance**: the runtime scopes both `listActiveQueries()` and `cancelActiveQuery()` to the authenticated principal. Two clients using the same API key therefore share one set and can cancel each other's queries, and unauthenticated requests all share the runtime's public scope. Do not rely on one `SpiceClient` seeing only its own queries.
615
+
616
+
Both work on Node and in the browser, since they use the HTTP control plane rather than Flight.
617
+
563
618
#### `nsql(request)` - Natural language to SQL (NSQL)
564
619
565
620
The `nsql()` method converts natural language queries into SQL and executes them, returning both the results and the generated SQL.
@@ -637,7 +692,26 @@ The `SpiceClient` automatically handles environments where Apache Arrow Flight g
637
692
2.**Automatic**: If the Flight proto file is missing, it's automatically downloaded from `https://data.spiceai.io/v1/proto/flight` and cached
638
693
3.**Fallback**: If gRPC cannot be initialized, automatically falls back to the HTTP `/v1/sql` endpoint
639
694
640
-
Both gRPC and HTTP modes support compression (gzip, deflate) to reduce bandwidth usage. This ensures the SDK works efficiently in any environment without configuration changes. See [docs/http-fallback.md](./docs/http-fallback.md) for more details.
695
+
Both gRPC and HTTP modes support compression (gzip, deflate) to reduce bandwidth usage. This ensures the SDK works efficiently in any environment without configuration changes.
696
+
697
+
### TLS and mTLS (Node.js only)
698
+
699
+
> **Note:** mTLS (client certificate authentication) is an [Enterprise](https://docs.spice.ai/docs/enterprise) feature of the Spice.ai runtime.
700
+
701
+
The client accepts PEM certificate file paths for custom server verification and mutual TLS:
702
+
703
+
```js
704
+
constclient=newSpiceClient({
705
+
flightUrl:'my-spice-host:50051',
706
+
httpUrl:'https://my-spice-host:8090',
707
+
tlsRootCertFile:'./certs/ca.pem', // custom CA for server verification (optional)
708
+
tlsClientCertFile:'./certs/client.pem', // ┐ provide both to enable mTLS
709
+
tlsClientKeyFile:'./certs/client.key', // ┘
710
+
});
711
+
```
712
+
713
+
-`tlsClientCertFile` and `tlsClientKeyFile` must be provided together; the client certificate is presented during the TLS handshake on both the gRPC and HTTP transports.
714
+
- The Spice runtime must be configured with `client_auth_mode: request` or `required`. See the [mTLS cookbook recipe](https://github.com/spiceai/cookbook/tree/trunk/mtls) for a complete walkthrough.
0 commit comments