@spooky-sync/client-solid2 0.0.1-canary.242 → 0.0.1-canary.244
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/dist/index.cjs +19 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +26 -0
package/src/index.ts
CHANGED
|
@@ -310,6 +310,32 @@ export class SyncedDb<S extends SchemaStructure> {
|
|
|
310
310
|
if (!this.sp00ky) throw new Error('SyncedDb not initialized');
|
|
311
311
|
return await this.sp00ky.useRemote(fn);
|
|
312
312
|
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Run one SurrealQL statement against the REMOTE database, results shaped
|
|
316
|
+
* like the SDK's own `.query()` (one entry per statement).
|
|
317
|
+
*
|
|
318
|
+
* Prefer this over `useRemote(s => s.query(...))` for a plain read: the bare
|
|
319
|
+
* SDK client the callback receives bypasses the client's connect gate, so a
|
|
320
|
+
* statement issued while the socket is being rebuilt fails with "Specify a
|
|
321
|
+
* namespace to use" instead of waiting for the session to be applied. It is
|
|
322
|
+
* also bounded by the remote service's concurrency limit and query timeout.
|
|
323
|
+
*
|
|
324
|
+
* Vars go through `unproxy` for the same reason writes do: a value read out
|
|
325
|
+
* of a Solid 2 store is a Proxy, and one bound as a query parameter reaches
|
|
326
|
+
* the CBOR encoder (and, under shared tabs, `postMessage`) as something it
|
|
327
|
+
* cannot serialize.
|
|
328
|
+
*/
|
|
329
|
+
public async remoteQuery<T extends unknown[] = unknown[]>(
|
|
330
|
+
sql: string,
|
|
331
|
+
vars?: Record<string, unknown>
|
|
332
|
+
): Promise<T> {
|
|
333
|
+
if (!this.sp00ky) throw new Error('SyncedDb not initialized');
|
|
334
|
+
return await this.sp00ky.remoteQuery<T>(
|
|
335
|
+
sql,
|
|
336
|
+
vars ? (unproxy(vars) as Record<string, unknown>) : undefined
|
|
337
|
+
);
|
|
338
|
+
}
|
|
313
339
|
/**
|
|
314
340
|
* Access the remote database service directly
|
|
315
341
|
*/
|