@wavehouse/sdk 0.0.0-dev.h825a5d7fa405 → 0.0.0-dev.h9539004107f0
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 +47 -5
- package/dist/cli/codegen.js +202 -0
- package/dist/index.cjs +518 -107
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +287 -11
- package/dist/index.d.ts +287 -11
- package/dist/index.global.js +12 -0
- package/dist/index.global.js.map +1 -0
- package/dist/index.js +518 -107
- package/dist/index.js.map +1 -1
- package/package.json +12 -4
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
/** User-provided database schema mapping table names to row types. */
|
|
2
2
|
type Database = Record<string, Record<string, unknown>>;
|
|
3
3
|
/**
|
|
4
|
-
* Discriminated union for
|
|
4
|
+
* Discriminated union for the async SDK calls that return one. Never throws for
|
|
5
|
+
* anything the server returns; a non-absolute `baseURL` and a rejecting `auth`
|
|
6
|
+
* callback do throw, while a runtime with no `fetch` at all surfaces instead as
|
|
7
|
+
* a retried `NETWORK_ERROR` result.
|
|
8
|
+
*
|
|
9
|
+
* `.stream()` and `.liveQuery()` return no `Result` and report the same three
|
|
10
|
+
* differently: a non-absolute `baseURL` reaches the subscriber's `error`
|
|
11
|
+
* callback as a terminal `SSE_CONNECT_ERROR`, a rejecting `auth` as a retryable
|
|
12
|
+
* `SSE_AUTH_ERROR`, and only a missing `fetch` throws from the call itself.
|
|
5
13
|
*
|
|
6
14
|
* Discriminated on `ok`: `if (result.ok)` narrows to the success arm (and tells
|
|
7
15
|
* the compiler `data` is present), while `error` is always available for
|
|
@@ -47,19 +55,162 @@ interface StreamSubscriber<T = Record<string, unknown>> {
|
|
|
47
55
|
error?: (err: WaveHouseError) => void;
|
|
48
56
|
}
|
|
49
57
|
interface ClientConfig<_DB extends Database = Database> {
|
|
50
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* Base URL of the WaveHouse server (e.g. "http://localhost:8080"). May include
|
|
60
|
+
* a path prefix ("https://app.example.com/api/warehouse") for a WaveHouse
|
|
61
|
+
* behind a backend-for-frontend (BFF), app-server route, or path-routed
|
|
62
|
+
* ingress; request paths are appended to it. The proxy in front must strip
|
|
63
|
+
* the prefix before forwarding.
|
|
64
|
+
*
|
|
65
|
+
* Must be **absolute** — scheme and host included. The transports report a
|
|
66
|
+
* relative value such as "/api/warehouse" differently: a REST call rejects
|
|
67
|
+
* with a `TypeError` instead of returning a `Result`, while a stream reports
|
|
68
|
+
* `SSE_CONNECT_ERROR` to the subscriber's `error` callback. Build an absolute
|
|
69
|
+
* one: `` `${location.origin}/api/warehouse` ``.
|
|
70
|
+
*/
|
|
51
71
|
baseURL: string;
|
|
52
72
|
/** Auth token provider. Omit for public/unauthenticated access. */
|
|
53
73
|
auth?: () => Promise<string> | string;
|
|
54
74
|
/** Additional client options. */
|
|
55
75
|
options?: ClientOptions;
|
|
56
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* A `fetch`-compatible function.
|
|
79
|
+
*
|
|
80
|
+
* Spelled out rather than written `typeof fetch`, which resolves differently
|
|
81
|
+
* depending on whether the consumer's TypeScript `lib` includes DOM — the same
|
|
82
|
+
* signature either way, but stable across configurations.
|
|
83
|
+
*
|
|
84
|
+
* The parameter is `string` rather than `typeof fetch`'s wider union because a
|
|
85
|
+
* string URL is all the SDK ever passes. Since parameters are contravariant,
|
|
86
|
+
* narrowing it *widens* what can be assigned: the global `fetch` still fits, and
|
|
87
|
+
* so does hand-written `(url: string, init?: RequestInit) => Promise<Response>`
|
|
88
|
+
* middleware, which the wider spelling rejects at compile time.
|
|
89
|
+
*
|
|
90
|
+
* On REST the SDK reads `.ok` and `.headers` always, `.text()` on success, and
|
|
91
|
+
* `.status`, `.statusText` plus `.json()` when the response is not `ok`. A
|
|
92
|
+
* rejection becomes a `NETWORK_ERROR` result and is retried with backoff —
|
|
93
|
+
* unless the `AbortSignal` you passed has been aborted, in which case the
|
|
94
|
+
* result is `ABORTED` and nothing is retried. That is decided from the signal
|
|
95
|
+
* rather than the rejection's type, so an implementation that throws something
|
|
96
|
+
* other than a `DOMException` named `AbortError` — `AbortSignal.timeout()`,
|
|
97
|
+
* `node-fetch` — is reported the same way.
|
|
98
|
+
*
|
|
99
|
+
* **Streaming needs more.** `.stream()` and `.liveQuery()` read the response as
|
|
100
|
+
* it arrives, via `.body.getReader()`, so an implementation used with them must
|
|
101
|
+
* return a response carrying a live `ReadableStream` — something the type cannot
|
|
102
|
+
* enforce, since `Response.body` is legitimately nullable. A response handed
|
|
103
|
+
* back with an absent or already-consumed body fails fast with
|
|
104
|
+
* `SSE_NO_STREAM_BODY`. What the SDK *cannot* rescue is an implementation that
|
|
105
|
+
* awaits the body before returning — `await res.text()`, or the
|
|
106
|
+
* `res.clone().text()` a logging wrapper reaches for — because on a stream that
|
|
107
|
+
* never ends, that never resolves and your function never returns. Both satisfy
|
|
108
|
+
* every REST call, which is what makes the trap easy to walk into.
|
|
109
|
+
*
|
|
110
|
+
* Implementations shipping their own request/response declarations (undici,
|
|
111
|
+
* `node-fetch`) need casts on the init and the return value, since those types
|
|
112
|
+
* are separate from the ones behind your global `fetch`; the narrow runtime
|
|
113
|
+
* contract above is what makes them safe.
|
|
114
|
+
*/
|
|
115
|
+
type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
|
|
57
116
|
interface ClientOptions {
|
|
58
117
|
/** Maximum retry attempts for failed requests. Default: 2. */
|
|
59
118
|
maxRetries?: number;
|
|
119
|
+
/**
|
|
120
|
+
* HTTP implementation used for every request, REST and streaming alike.
|
|
121
|
+
* Defaults to the global `fetch`.
|
|
122
|
+
*
|
|
123
|
+
* Provide one to route through a proxy, attach client certificates, add
|
|
124
|
+
* middleware (logging, tracing, circuit breaking), or bypass a transport bug
|
|
125
|
+
* in the runtime's bundled HTTP stack by routing through an implementation
|
|
126
|
+
* you install yourself — e.g. an undici new enough to be free of
|
|
127
|
+
* {@link https://github.com/nodejs/undici/issues/5600 | undici #5600}:
|
|
128
|
+
*
|
|
129
|
+
* ```ts
|
|
130
|
+
* import { Agent, fetch as undiciFetch } from "undici"; // npm install undici — 8.10.0+
|
|
131
|
+
* // Pass the dispatcher explicitly: undici's pool lives on a shared
|
|
132
|
+
* // globalThis symbol claimed by whichever copy loaded first, so an implied
|
|
133
|
+
* // dispatcher can still be the runtime's affected one.
|
|
134
|
+
* const dispatcher = new Agent();
|
|
135
|
+
* createClient({
|
|
136
|
+
* baseURL,
|
|
137
|
+
* options: {
|
|
138
|
+
* fetch: (url, init) =>
|
|
139
|
+
* undiciFetch(url, { ...init, dispatcher } as never) as unknown as Promise<Response>,
|
|
140
|
+
* },
|
|
141
|
+
* });
|
|
142
|
+
* ```
|
|
143
|
+
*
|
|
144
|
+
* `.stream()` and `.liveQuery()` go through it too, which imposes the extra
|
|
145
|
+
* streaming requirement described on {@link FetchLike} — read that before
|
|
146
|
+
* supplying a wrapper that touches the response body.
|
|
147
|
+
*/
|
|
148
|
+
fetch?: FetchLike;
|
|
149
|
+
/**
|
|
150
|
+
* Headers added to every request, REST and streaming alike — for a
|
|
151
|
+
* header-gated proxy in front of WaveHouse, such as a Cloudflare Access
|
|
152
|
+
* service token.
|
|
153
|
+
*
|
|
154
|
+
* Matched case-insensitively, as HTTP headers are. Applied underneath the
|
|
155
|
+
* SDK's own headers: `auth` still owns `Authorization`, and the
|
|
156
|
+
* `Content-Type` and `Accept` a given request needs are not overridable
|
|
157
|
+
* here — a global `Content-Type` that outranked the request's own is a
|
|
158
|
+
* documented way to break uploads.
|
|
159
|
+
*
|
|
160
|
+
* In a browser these are subject to CORS: a header outside the safelist adds
|
|
161
|
+
* it to the preflight, which the origin must allow. WaveHouse's own CORS
|
|
162
|
+
* advertises a fixed set, so custom headers reach it cross-origin only when
|
|
163
|
+
* a proxy in front terminates the preflight — which is the deployment they
|
|
164
|
+
* exist for. Server-side callers never preflight.
|
|
165
|
+
*/
|
|
166
|
+
headers?: Record<string, string>;
|
|
167
|
+
/**
|
|
168
|
+
* Extra `RequestInit` fields merged into every request — `credentials` for a
|
|
169
|
+
* cookie-authenticated origin, `mode`, `cache`, `keepalive`, or a
|
|
170
|
+
* runtime-specific extension such as Next.js's `next: { tags }`.
|
|
171
|
+
*
|
|
172
|
+
* Fields the SDK controls (`method`, `headers`, `body`, `signal`) always
|
|
173
|
+
* win, so this cannot corrupt the request itself. Non-standard fields may
|
|
174
|
+
* need a cast, since `RequestInit` only declares the standard ones.
|
|
175
|
+
*
|
|
176
|
+
* The streaming transport additionally owns `cache` and `redirect`, where the
|
|
177
|
+
* values are load-bearing rather than preference: a `Cache-Control` header
|
|
178
|
+
* would fail cross-origin preflight, and following a redirect would strip the
|
|
179
|
+
* `Authorization` header on a cross-origin hop and silently downgrade the
|
|
180
|
+
* stream to the default role instead of failing. So a request carrying an
|
|
181
|
+
* `auth` token, or configured `headers` that may hold a proxy secret, refuses
|
|
182
|
+
* redirects (`SSE_REDIRECT`); without either it follows them, so CDN
|
|
183
|
+
* canonicalization and an http→https upgrade still work. Note the test is
|
|
184
|
+
* that concrete pair, not "is this authenticated" — **cookies are invisible
|
|
185
|
+
* to it**. A cookie is re-derived from the cookie store at each hop rather
|
|
186
|
+
* than carried, so under the default `same-origin` credentials mode a
|
|
187
|
+
* redirect keeps the stream authenticated only while the hop stays inside
|
|
188
|
+
* both the request's origin and the cookie's `Path`; a hop outside either
|
|
189
|
+
* arrives with no cookie and gets a `default_role` view rather than an error.
|
|
190
|
+
* With `credentials: "include"` the origin half is replaced rather than
|
|
191
|
+
* lifted: ordinary cookie scoping decides, so the cookie crosses a
|
|
192
|
+
* CORS-allowed cross-origin hop only if its own `Domain` covers the target —
|
|
193
|
+
* a host-only cookie, the default, still stops at its host. Spelled out
|
|
194
|
+
* under "Supplying your own `fetch`" in the SDK guide; see #478.
|
|
195
|
+
* `credentials` itself is honored in browsers and dropped elsewhere, since
|
|
196
|
+
* some runtimes throw if it is set.
|
|
197
|
+
*/
|
|
198
|
+
fetchOptions?: RequestInit;
|
|
60
199
|
}
|
|
61
200
|
interface StructuredQuery {
|
|
201
|
+
/**
|
|
202
|
+
* Explicit columns to project. A literal "*" is a column named "*", not a
|
|
203
|
+
* wildcard. Omitting columns (with no aggregations and no select_all) selects
|
|
204
|
+
* nothing — use select_all for a full-row read. Mutually exclusive with
|
|
205
|
+
* select_all.
|
|
206
|
+
*/
|
|
62
207
|
columns?: string[];
|
|
208
|
+
/**
|
|
209
|
+
* Request every column the caller's role may read (the all-columns wildcard,
|
|
210
|
+
* expanded server-side to the allowed/denied set). Mutually exclusive with a
|
|
211
|
+
* non-empty columns list.
|
|
212
|
+
*/
|
|
213
|
+
select_all?: boolean;
|
|
63
214
|
aggregations?: Aggregation[];
|
|
64
215
|
filters?: QueryFilter[];
|
|
65
216
|
group_by?: string[];
|
|
@@ -97,9 +248,36 @@ interface TableSchema {
|
|
|
97
248
|
columns: Column[];
|
|
98
249
|
}
|
|
99
250
|
type Schemas = Record<string, TableSchema>;
|
|
251
|
+
/**
|
|
252
|
+
* A per-record outcome from a batch (array / NDJSON) insert. Mirrors the
|
|
253
|
+
* single-object response shape plus the record's position. Exactly one of
|
|
254
|
+
* `ok` / `duplicate` / `error` is set.
|
|
255
|
+
*/
|
|
256
|
+
interface InsertRecordResult {
|
|
257
|
+
/** 1-based index of the record within the submitted batch. */
|
|
258
|
+
index: number;
|
|
259
|
+
/** Set when the record was validated and published. */
|
|
260
|
+
ok?: boolean;
|
|
261
|
+
/** Set when dedup skipped the record. */
|
|
262
|
+
duplicate?: boolean;
|
|
263
|
+
/** Set (with `ok`/`duplicate` absent) when the record was rejected. */
|
|
264
|
+
error?: string;
|
|
265
|
+
}
|
|
100
266
|
interface InsertResult {
|
|
267
|
+
/** True for a fully successful insert: a single row, or a batch with no rejected records (`failed === 0`). */
|
|
101
268
|
ok: boolean;
|
|
269
|
+
/** Single insert only: set when dedup skipped the row. */
|
|
102
270
|
duplicate?: boolean;
|
|
271
|
+
/** Batch insert (array / NDJSON): number of records submitted. */
|
|
272
|
+
total?: number;
|
|
273
|
+
/** Batch insert: records validated and published. */
|
|
274
|
+
succeeded?: number;
|
|
275
|
+
/** Batch insert: records rejected — see `results`. */
|
|
276
|
+
failed?: number;
|
|
277
|
+
/** Batch insert: records skipped by dedup. */
|
|
278
|
+
duplicates?: number;
|
|
279
|
+
/** Batch insert: per-record outcomes, each `{index, ok|duplicate|error}` (may be truncated for very large batches; the counts stay authoritative). */
|
|
280
|
+
results?: InsertRecordResult[];
|
|
103
281
|
}
|
|
104
282
|
interface DLQStats {
|
|
105
283
|
tables: Record<string, number>;
|
|
@@ -133,8 +311,22 @@ interface RolePermissions {
|
|
|
133
311
|
check?: Record<string, PolicyFilter>;
|
|
134
312
|
allowed_aggregations?: string[];
|
|
135
313
|
denied_aggregations?: string[];
|
|
314
|
+
/** Caps the query result LIMIT. 0 = no limit. */
|
|
136
315
|
max_rows?: number;
|
|
137
|
-
|
|
316
|
+
/**
|
|
317
|
+
* Max query execution time, enforced server-side by ClickHouse. Set it as a
|
|
318
|
+
* duration string ("5s", "500ms") or a number of milliseconds; reads always
|
|
319
|
+
* return the number of milliseconds.
|
|
320
|
+
*/
|
|
321
|
+
max_execution_time?: number | string;
|
|
322
|
+
/** Max rows scanned from storage, enforced server-side by ClickHouse. 0 = no limit. */
|
|
323
|
+
max_rows_to_read?: number;
|
|
324
|
+
/**
|
|
325
|
+
* Max peak query memory, enforced server-side by ClickHouse. Set it as a size
|
|
326
|
+
* string ("4GiB", "512MiB") or a number of bytes; reads always return the
|
|
327
|
+
* number of bytes.
|
|
328
|
+
*/
|
|
329
|
+
max_memory_usage?: number | string;
|
|
138
330
|
}
|
|
139
331
|
interface PolicyFilter {
|
|
140
332
|
_eq?: string;
|
|
@@ -146,10 +338,32 @@ interface PolicyFilter {
|
|
|
146
338
|
interface ValidationResult {
|
|
147
339
|
valid: boolean;
|
|
148
340
|
}
|
|
149
|
-
|
|
341
|
+
/**
|
|
342
|
+
* Options for a single call, passed to `.fetch()`.
|
|
343
|
+
*
|
|
344
|
+
* Note that `await`ing a builder directly (`await wh.from("t").select("*")`)
|
|
345
|
+
* takes no options — use the explicit `.fetch({ … })` form for those.
|
|
346
|
+
*/
|
|
347
|
+
interface RequestOptions {
|
|
150
348
|
signal?: AbortSignal;
|
|
151
349
|
limit?: number;
|
|
152
350
|
}
|
|
351
|
+
/**
|
|
352
|
+
* Options for a single `PipeRef.fetch()` call.
|
|
353
|
+
*
|
|
354
|
+
* `limit` is declared `never` rather than simply left out. Omitting it would
|
|
355
|
+
* still admit a `RequestOptions` value that carries one — excess-property
|
|
356
|
+
* checking only rejects fresh object literals, so a variable would pass and the
|
|
357
|
+
* limit would be silently dropped, which is the whole defect this prevents.
|
|
358
|
+
*
|
|
359
|
+
* A pipe's row cap belongs in its SQL as a `{{limit}}` parameter, supplied via
|
|
360
|
+
* `wh.pipe(name, { limit })`.
|
|
361
|
+
*/
|
|
362
|
+
interface PipeRequestOptions {
|
|
363
|
+
signal?: AbortSignal;
|
|
364
|
+
/** Not supported on pipes — pass `limit` as a pipe parameter instead. */
|
|
365
|
+
limit?: never;
|
|
366
|
+
}
|
|
153
367
|
interface StreamOptions {
|
|
154
368
|
since?: string;
|
|
155
369
|
signal?: AbortSignal;
|
|
@@ -160,6 +374,9 @@ interface HttpContext {
|
|
|
160
374
|
auth?: () => Promise<string> | string;
|
|
161
375
|
options: {
|
|
162
376
|
maxRetries: number;
|
|
377
|
+
fetch?: FetchLike;
|
|
378
|
+
headers?: Record<string, string>;
|
|
379
|
+
fetchOptions?: RequestInit;
|
|
163
380
|
};
|
|
164
381
|
}
|
|
165
382
|
|
|
@@ -236,8 +453,15 @@ declare class PipeRef<Row = Record<string, unknown>> implements PromiseLike<Resu
|
|
|
236
453
|
private readonly _params?;
|
|
237
454
|
private readonly _createStream;
|
|
238
455
|
constructor(ctx: HttpContext, name: string, params: Record<string, unknown> | undefined, createStream: CreateStreamFn$2<Row>);
|
|
239
|
-
/**
|
|
240
|
-
|
|
456
|
+
/**
|
|
457
|
+
* Execute the pipe and return results.
|
|
458
|
+
*
|
|
459
|
+
* Takes only `signal` — deliberately narrower than the `RequestOptions` the
|
|
460
|
+
* query builder accepts. The pipes endpoint binds the body as the pipe's
|
|
461
|
+
* parameters, so there is no row cap to forward; give the pipe a `{{limit}}`
|
|
462
|
+
* parameter in its SQL and pass it via `wh.pipe(name, { limit })`.
|
|
463
|
+
*/
|
|
464
|
+
fetch(opts?: PipeRequestOptions): Promise<Result<Row[]>>;
|
|
241
465
|
/** Subscribe to live events from the pipe's underlying query. */
|
|
242
466
|
stream(opts?: StreamOptions): StreamController<Row>;
|
|
243
467
|
then<TResult1 = Result<Row[]>, TResult2 = never>(onfulfilled?: ((value: Result<Row[]>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
@@ -339,6 +563,7 @@ declare class LiveQuery<T = Record<string, unknown>> {
|
|
|
339
563
|
interface QueryState {
|
|
340
564
|
table: string;
|
|
341
565
|
columns: string[];
|
|
566
|
+
selectAll?: boolean;
|
|
342
567
|
aggregations: Aggregation[];
|
|
343
568
|
filters: QueryFilter[];
|
|
344
569
|
groupBy: string[];
|
|
@@ -361,6 +586,13 @@ declare class QueryBuilder<Row = Record<string, unknown>> implements PromiseLike
|
|
|
361
586
|
private readonly _createStream;
|
|
362
587
|
constructor(ctx: HttpContext, state: QueryState, createStream: CreateStreamFn$1<Row>);
|
|
363
588
|
select(...columns: string[]): QueryBuilder<Row>;
|
|
589
|
+
/**
|
|
590
|
+
* Select every column the caller's role is allowed to read (the all-columns
|
|
591
|
+
* wildcard). Use this instead of `.select(...)` when you want a full-row read;
|
|
592
|
+
* a bare `.fetch()` with no `.select()` does this implicitly. Mutually
|
|
593
|
+
* exclusive with `.select(...)`.
|
|
594
|
+
*/
|
|
595
|
+
selectAll(): QueryBuilder<Row>;
|
|
364
596
|
where(column: string, op: FilterOp, value: unknown): QueryBuilder<Row>;
|
|
365
597
|
count(column?: string, alias?: string): QueryBuilder<Row>;
|
|
366
598
|
sum(column: string, alias?: string): QueryBuilder<Row>;
|
|
@@ -374,9 +606,9 @@ declare class QueryBuilder<Row = Record<string, unknown>> implements PromiseLike
|
|
|
374
606
|
limit(n: number): QueryBuilder<Row>;
|
|
375
607
|
timeRange(column: string, since: string, until?: string): QueryBuilder<Row>;
|
|
376
608
|
cacheTTL(seconds: number): QueryBuilder<Row>;
|
|
377
|
-
/** Default row limit when none is specified
|
|
609
|
+
/** Default row limit when none is specified — deliberately tighter than the backend's DefaultMaxRows (10000) safety cap. */
|
|
378
610
|
static readonly DEFAULT_LIMIT = 1000;
|
|
379
|
-
fetch(opts?:
|
|
611
|
+
fetch(opts?: RequestOptions): Promise<Result<Row[]>>;
|
|
380
612
|
stream(opts?: StreamOptions): StreamController<Row>;
|
|
381
613
|
/**
|
|
382
614
|
* Start a live query: fetches historical data, then streams live updates.
|
|
@@ -396,6 +628,12 @@ declare class QueryBuilder<Row = Record<string, unknown>> implements PromiseLike
|
|
|
396
628
|
}
|
|
397
629
|
|
|
398
630
|
type CreateStreamFn<Row> = (table: string, opts?: StreamOptions) => StreamController<Row>;
|
|
631
|
+
/**
|
|
632
|
+
* Accepted sources for {@link TableRef.insertNDJSON}: a string, raw bytes, a
|
|
633
|
+
* Blob/File (browser file inputs), or a byte stream. Non-string sources are
|
|
634
|
+
* read fully before sending.
|
|
635
|
+
*/
|
|
636
|
+
type NDJSONSource = string | Uint8Array | Blob | ReadableStream<Uint8Array>;
|
|
399
637
|
/**
|
|
400
638
|
* Reference to a table. NOT thenable — safe to pass around without triggering requests.
|
|
401
639
|
* Use `.fetch()`, `.select()`, `.insert()`, `.schema()`, or `.stream()` to act on it.
|
|
@@ -406,13 +644,51 @@ declare class TableRef<Row = Record<string, unknown>> {
|
|
|
406
644
|
private readonly _createStream;
|
|
407
645
|
constructor(ctx: HttpContext, table: string, createStream: CreateStreamFn<Row>);
|
|
408
646
|
/** SELECT * shortcut — fetches rows with optional pagination. */
|
|
409
|
-
fetch(opts?:
|
|
647
|
+
fetch(opts?: RequestOptions): Promise<Result<Row[]>>;
|
|
410
648
|
/** Start building a typed query. Returns an immutable, PromiseLike QueryBuilder. */
|
|
411
649
|
select(...columns: string[]): QueryBuilder<Row>;
|
|
412
|
-
/**
|
|
650
|
+
/**
|
|
651
|
+
* Start a query that selects every column the caller's role is allowed to read
|
|
652
|
+
* (the all-columns wildcard). Use instead of `.select(...)` for an explicit
|
|
653
|
+
* full-row read; `.fetch()` does this implicitly.
|
|
654
|
+
*/
|
|
655
|
+
selectAll(): QueryBuilder<Row>;
|
|
656
|
+
/**
|
|
657
|
+
* Insert one or more rows into this table.
|
|
658
|
+
*
|
|
659
|
+
* A single object is sent as a JSON `POST /v1/ingest`. An **array** is
|
|
660
|
+
* serialized to NDJSON (one record per line) and sent as a single
|
|
661
|
+
* `application/x-ndjson` request: a bad record no longer fails or hides the
|
|
662
|
+
* rest of the batch — per-record outcomes come back in the result
|
|
663
|
+
* (`failed` / `results`), and `ok` is true only when every record succeeded.
|
|
664
|
+
*
|
|
665
|
+
* The array path sends one request regardless of size; bounded-concurrency
|
|
666
|
+
* chunking of very large arrays is tracked separately (#196). For NDJSON you
|
|
667
|
+
* already have (a file or stream), use {@link insertNDJSON}.
|
|
668
|
+
*/
|
|
413
669
|
insert(data: Partial<Row> | Partial<Row>[], opts?: {
|
|
414
670
|
signal?: AbortSignal;
|
|
415
671
|
}): Promise<Result<InsertResult>>;
|
|
672
|
+
/**
|
|
673
|
+
* Insert pre-formatted NDJSON (newline-delimited JSON, one record per line)
|
|
674
|
+
* from a string, raw bytes, a Blob/File, or a byte stream — e.g. a `.ndjson`
|
|
675
|
+
* file or a stream produced by another system. For in-memory rows, prefer
|
|
676
|
+
* {@link insert}.
|
|
677
|
+
*
|
|
678
|
+
* Non-string sources are read fully into memory before sending (the server
|
|
679
|
+
* streams the parse). Returns the same per-record batch summary as an array
|
|
680
|
+
* `insert`.
|
|
681
|
+
*/
|
|
682
|
+
insertNDJSON(source: NDJSONSource, opts?: {
|
|
683
|
+
signal?: AbortSignal;
|
|
684
|
+
}): Promise<Result<InsertResult>>;
|
|
685
|
+
/**
|
|
686
|
+
* @internal Send an NDJSON body and map the server's batch response onto an
|
|
687
|
+
* {@link InsertResult}. A transport / whole-request failure surfaces as the
|
|
688
|
+
* Result error arm; a processed batch (even with rejected records) surfaces
|
|
689
|
+
* as the success arm with `ok = failed === 0`.
|
|
690
|
+
*/
|
|
691
|
+
private _sendNDJSON;
|
|
416
692
|
/** Fetch the schema for this table. */
|
|
417
693
|
schema(opts?: {
|
|
418
694
|
signal?: AbortSignal;
|
|
@@ -458,4 +734,4 @@ declare class WaveHouseClient<DB extends Database = Database> {
|
|
|
458
734
|
/** Create a new WaveHouse client instance. */
|
|
459
735
|
declare function createClient<DB extends Database = Database>(config: ClientConfig<DB>): WaveHouseClient<DB>;
|
|
460
736
|
|
|
461
|
-
export { type Aggregation, type ClientConfig, type ClientOptions, type Column, DLQNamespace, type DLQStats, type Database, type
|
|
737
|
+
export { type Aggregation, type ClientConfig, type ClientOptions, type Column, DLQNamespace, type DLQStats, type Database, type FetchLike, type FilterOp, type InsertRecordResult, type InsertResult, LiveQuery, type NDJSONSource, type OrderClause, type ParamDef, type Pipe, PipeRef, type PipeRequestOptions, PipesNamespace, type Policy, type PolicyFilter, PolicyNamespace, QueryBuilder, type QueryFilter, type RequestOptions, type Result, type RolePermissions, SchemaNamespace, type Schemas, StreamController, type StreamEvent, type StreamOptions, type StreamStatus, type StreamSubscriber, type StructuredQuery, SysNamespace, type TablePolicy, TableRef, type TableSchema, type TimeRange, type ValidationResult, WaveHouseClient, type WaveHouseError, createClient };
|