@lunora/bindings 1.0.0-alpha.2 → 1.0.0-alpha.21
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/LICENSE.md +6 -0
- package/dist/analytics/index.d.mts +66 -87
- package/dist/analytics/index.d.ts +66 -87
- package/dist/analytics/index.mjs +1 -2
- package/dist/images/index.d.mts +148 -148
- package/dist/images/index.d.ts +148 -148
- package/dist/images/index.mjs +1 -3
- package/dist/kv/index.d.mts +130 -113
- package/dist/kv/index.d.ts +130 -113
- package/dist/kv/index.mjs +1 -1
- package/dist/packem_shared/AnalyticsSqlError-B-JcsUhX.mjs +1 -0
- package/dist/packem_shared/R2SqlError-Uaz0RJTR.mjs +1 -0
- package/dist/packem_shared/SelectBuilder-WMBQ2b4q.mjs +1 -0
- package/dist/packem_shared/SetOperation-BrzMB1Tb.mjs +1 -0
- package/dist/packem_shared/Sql-CwhZl1Q5.mjs +1 -0
- package/dist/packem_shared/WindowExpression-CxCuEy8V.mjs +1 -0
- package/dist/packem_shared/WindowFunction-rzl4CzYE.mjs +1 -0
- package/dist/packem_shared/asc-BsbdtIQU.mjs +1 -0
- package/dist/packem_shared/buildImageDeliveryUrl-CMUkVJfB.mjs +1 -0
- package/dist/packem_shared/buildSignedImageUrl-BzgCHIu6.mjs +4 -0
- package/dist/packem_shared/concurrent-DMFQCILU.mjs +1 -0
- package/dist/packem_shared/createAnalytics-HRPCzT1M.mjs +1 -0
- package/dist/packem_shared/createContextVectors-D-ae1wWO.mjs +6 -0
- package/dist/packem_shared/createImages-TW6ircG2.mjs +1 -0
- package/dist/packem_shared/createKv-CKeFDFuG.mjs +1 -0
- package/dist/packem_shared/createKvIntrospector-Bz0nqUjD.mjs +1 -0
- package/dist/packem_shared/createPipelines-n0Bf_p8Y.mjs +1 -0
- package/dist/packem_shared/createVectorAdminIntrospector-B9Yt09yj.mjs +1 -0
- package/dist/packem_shared/createVectors-jb8fAY6R.mjs +1 -0
- package/dist/pipelines/index.d.mts +24 -24
- package/dist/pipelines/index.d.ts +24 -24
- package/dist/pipelines/index.mjs +1 -1
- package/dist/r2sql/index.d.mts +124 -124
- package/dist/r2sql/index.d.ts +124 -124
- package/dist/r2sql/index.mjs +1 -7
- package/dist/vectors/index.d.mts +185 -134
- package/dist/vectors/index.d.ts +185 -134
- package/dist/vectors/index.mjs +1 -3
- package/package.json +5 -1
- package/dist/packem_shared/AnalyticsSqlError-CGTdsi4H.mjs +0 -42
- package/dist/packem_shared/R2SqlError-DlDd_SrE.mjs +0 -67
- package/dist/packem_shared/SelectBuilder-DHaXZwn_.mjs +0 -167
- package/dist/packem_shared/SetOperation-RDHcxccj.mjs +0 -80
- package/dist/packem_shared/Sql-DceGtcUd.mjs +0 -68
- package/dist/packem_shared/WindowExpression-Cg9s2xcr.mjs +0 -44
- package/dist/packem_shared/WindowFunction-DA3pGC3N.mjs +0 -82
- package/dist/packem_shared/asc-Cur-xO8v.mjs +0 -16
- package/dist/packem_shared/buildImageDeliveryUrl-D1sVfIOP.mjs +0 -30
- package/dist/packem_shared/buildSignedImageUrl-Otdgc_jO.mjs +0 -113
- package/dist/packem_shared/concurrent-Dj5sOibv.mjs +0 -23
- package/dist/packem_shared/createAnalytics-CEEI69o9.mjs +0 -57
- package/dist/packem_shared/createContextVectors-BSizpmu5.mjs +0 -140
- package/dist/packem_shared/createImages-CJrvqX0u.mjs +0 -80
- package/dist/packem_shared/createKv-DTiSt216.mjs +0 -141
- package/dist/packem_shared/createPipelines-CfyJ6VGu.mjs +0 -10
- package/dist/packem_shared/createVectorAdminIntrospector-BJUOM6VW.mjs +0 -51
- package/dist/packem_shared/createVectors-LSpGoKCd.mjs +0 -91
package/dist/r2sql/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { LunoraError } from '@lunora/errors';
|
|
1
2
|
/**
|
|
2
|
-
* A composed SQL fragment. Carries the finished `text`; `toString()` returns it
|
|
3
|
-
* so a fragment can be dropped straight into a template or `String(...)`.
|
|
4
|
-
*/
|
|
3
|
+
* A composed SQL fragment. Carries the finished `text`; `toString()` returns it
|
|
4
|
+
* so a fragment can be dropped straight into a template or `String(...)`.
|
|
5
|
+
*/
|
|
5
6
|
declare class Sql {
|
|
6
7
|
readonly text: string;
|
|
7
8
|
constructor(text: string);
|
|
@@ -10,32 +11,32 @@ declare class Sql {
|
|
|
10
11
|
/** True when `value` is a {@link Sql} fragment (an already-trusted, pre-escaped span). */
|
|
11
12
|
declare const isSql: (value: unknown) => value is Sql;
|
|
12
13
|
/**
|
|
13
|
-
* Wrap an already-trusted string as a {@link Sql} fragment so {@link sql}
|
|
14
|
-
* splices it **verbatim** (no escaping). Use ONLY for SQL you constructed
|
|
15
|
-
* yourself (identifiers, keywords, sub-fragments) — never for user input.
|
|
16
|
-
*/
|
|
14
|
+
* Wrap an already-trusted string as a {@link Sql} fragment so {@link sql}
|
|
15
|
+
* splices it **verbatim** (no escaping). Use ONLY for SQL you constructed
|
|
16
|
+
* yourself (identifiers, keywords, sub-fragments) — never for user input.
|
|
17
|
+
*/
|
|
17
18
|
declare const raw: (text: string) => Sql;
|
|
18
19
|
/** Resolve a `string | Sql` to its raw text. A bare string is taken as trusted SQL (callers pass identifiers/fragments here). */
|
|
19
20
|
declare const toText: (value: Sql | string) => string;
|
|
20
21
|
/**
|
|
21
|
-
* Render a JS value as an R2 SQL literal:
|
|
22
|
-
*
|
|
23
|
-
* - `null` / `undefined` → `NULL`
|
|
24
|
-
* - `boolean` → `true` / `false`
|
|
25
|
-
* - finite `number` / `bigint` → the numeric text (non-finite throws — `NaN`/`Infinity` have no SQL literal)
|
|
26
|
-
* - `Date` → an RFC3339 string literal (R2 SQL's `timestamp` form)
|
|
27
|
-
* - `string` → a single-quoted, escaped literal
|
|
28
|
-
* - `Array` → a parenthesised, comma-separated list of literals (for `IN (...)`)
|
|
29
|
-
*
|
|
30
|
-
* Anything else (object, symbol, function) throws — there is no safe SQL literal
|
|
31
|
-
* for it, and silently coercing would risk a malformed or injectable statement.
|
|
32
|
-
*/
|
|
22
|
+
* Render a JS value as an R2 SQL literal:
|
|
23
|
+
*
|
|
24
|
+
* - `null` / `undefined` → `NULL`
|
|
25
|
+
* - `boolean` → `true` / `false`
|
|
26
|
+
* - finite `number` / `bigint` → the numeric text (non-finite throws — `NaN`/`Infinity` have no SQL literal)
|
|
27
|
+
* - `Date` → an RFC3339 string literal (R2 SQL's `timestamp` form)
|
|
28
|
+
* - `string` → a single-quoted, escaped literal
|
|
29
|
+
* - `Array` → a parenthesised, comma-separated list of literals (for `IN (...)`)
|
|
30
|
+
*
|
|
31
|
+
* Anything else (object, symbol, function) throws — there is no safe SQL literal
|
|
32
|
+
* for it, and silently coercing would risk a malformed or injectable statement.
|
|
33
|
+
*/
|
|
33
34
|
declare const lit: (value: unknown) => string;
|
|
34
35
|
/**
|
|
35
|
-
* Tagged template producing a safe {@link Sql} fragment. Each interpolation is
|
|
36
|
-
* escaped with {@link lit} unless it is already a {@link Sql} (spliced
|
|
37
|
-
* verbatim), so user values can never break out of their literal.
|
|
38
|
-
*/
|
|
36
|
+
* Tagged template producing a safe {@link Sql} fragment. Each interpolation is
|
|
37
|
+
* escaped with {@link lit} unless it is already a {@link Sql} (spliced
|
|
38
|
+
* verbatim), so user values can never break out of their literal.
|
|
39
|
+
*/
|
|
39
40
|
declare const sql: (strings: TemplateStringsArray, ...values: unknown[]) => Sql;
|
|
40
41
|
/** Join SQL fragments/strings with `separator` into one {@link Sql} (e.g. `AND`-ed conditions). */
|
|
41
42
|
declare const joinSql: (parts: ReadonlyArray<Sql | string>, separator: string) => Sql;
|
|
@@ -51,29 +52,29 @@ declare const desc: (expr: Sql | string) => OrderTerm;
|
|
|
51
52
|
/** Render one {@link OrderTerm} to SQL. */
|
|
52
53
|
declare const renderOrderTerm: (term: OrderTerm) => string;
|
|
53
54
|
/**
|
|
54
|
-
* Public types for `@lunora/bindings/r2sql`.
|
|
55
|
-
*
|
|
56
|
-
* R2 SQL is Cloudflare's serverless, distributed query engine over **Apache
|
|
57
|
-
* Iceberg** tables in [R2 Data Catalog](https://developers.cloudflare.com/r2/data-catalog/).
|
|
58
|
-
* It has **no Workers binding** — every query is an HTTPS round-trip to the REST
|
|
59
|
-
* endpoint (`POST …/r2-sql/query/{bucket}`). So, like Hyperdrive's `ctx.sql`, the
|
|
60
|
-
* client is **non-deterministic external I/O**: it is wired onto `ActionCtx`
|
|
61
|
-
* only (see the `r2sql_outside_action` advisor lint) and its reads are NOT
|
|
62
|
-
* tracked by Lunora live queries.
|
|
63
|
-
*
|
|
64
|
-
* Everything here is deliberately structural (no hard dependency on
|
|
65
|
-
* `@cloudflare/workers-types`) so unit tests can inject a plain `fetch` double
|
|
66
|
-
* and never touch the network — mirroring `AnalyticsSqlConfig` in
|
|
67
|
-
* `@lunora/bindings/analytics`.
|
|
68
|
-
*/
|
|
55
|
+
* Public types for `@lunora/bindings/r2sql`.
|
|
56
|
+
*
|
|
57
|
+
* R2 SQL is Cloudflare's serverless, distributed query engine over **Apache
|
|
58
|
+
* Iceberg** tables in [R2 Data Catalog](https://developers.cloudflare.com/r2/data-catalog/).
|
|
59
|
+
* It has **no Workers binding** — every query is an HTTPS round-trip to the REST
|
|
60
|
+
* endpoint (`POST …/r2-sql/query/{bucket}`). So, like Hyperdrive's `ctx.sql`, the
|
|
61
|
+
* client is **non-deterministic external I/O**: it is wired onto `ActionCtx`
|
|
62
|
+
* only (see the `r2sql_outside_action` advisor lint) and its reads are NOT
|
|
63
|
+
* tracked by Lunora live queries.
|
|
64
|
+
*
|
|
65
|
+
* Everything here is deliberately structural (no hard dependency on
|
|
66
|
+
* `@cloudflare/workers-types`) so unit tests can inject a plain `fetch` double
|
|
67
|
+
* and never touch the network — mirroring `AnalyticsSqlConfig` in
|
|
68
|
+
* `@lunora/bindings/analytics`.
|
|
69
|
+
*/
|
|
69
70
|
/**
|
|
70
|
-
* Configuration for a {@link import("./client").R2SqlClient | R2SqlClient}.
|
|
71
|
-
*
|
|
72
|
-
* `apiToken` is a **secret** — a Cloudflare API token scoped to R2 SQL (read),
|
|
73
|
-
* R2 Data Catalog, and R2 storage. It is never a binding and must never be
|
|
74
|
-
* auto-scaffolded with a real value; the caller provides it from
|
|
75
|
-
* env/`.dev.vars`.
|
|
76
|
-
*/
|
|
71
|
+
* Configuration for a {@link import("./client").R2SqlClient | R2SqlClient}.
|
|
72
|
+
*
|
|
73
|
+
* `apiToken` is a **secret** — a Cloudflare API token scoped to R2 SQL (read),
|
|
74
|
+
* R2 Data Catalog, and R2 storage. It is never a binding and must never be
|
|
75
|
+
* auto-scaffolded with a real value; the caller provides it from
|
|
76
|
+
* env/`.dev.vars`.
|
|
77
|
+
*/
|
|
77
78
|
interface R2SqlConfig {
|
|
78
79
|
/** Cloudflare account id that owns the bucket/catalog. */
|
|
79
80
|
accountId: string;
|
|
@@ -82,36 +83,36 @@ interface R2SqlConfig {
|
|
|
82
83
|
/** The R2 bucket (warehouse) whose Data Catalog the queries run against. */
|
|
83
84
|
bucket: string;
|
|
84
85
|
/**
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
* Override the REST base URL. Defaults to Cloudflare's public R2 SQL host
|
|
87
|
+
* (`https://api.sql.cloudflarestorage.com/api/v1/accounts`). Injected in
|
|
88
|
+
* tests, or pointed at a regional/preview host.
|
|
89
|
+
*/
|
|
89
90
|
endpoint?: string;
|
|
90
91
|
/**
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
* `fetch` implementation. Defaults to the global `fetch`; injected in tests
|
|
93
|
+
* so a query never touches the network.
|
|
94
|
+
*/
|
|
94
95
|
fetch?: typeof globalThis.fetch;
|
|
95
96
|
}
|
|
96
97
|
/**
|
|
97
|
-
* One column descriptor in a result's schema: the column `name` and, when the
|
|
98
|
-
* engine reports it, the Iceberg storage `type` (`integer`, `string`,
|
|
99
|
-
* `timestamp`, …). R2 SQL does not always echo a schema block, so `type` is
|
|
100
|
-
* optional and `columns` may be derived from the first row's keys.
|
|
101
|
-
*/
|
|
98
|
+
* One column descriptor in a result's schema: the column `name` and, when the
|
|
99
|
+
* engine reports it, the Iceberg storage `type` (`integer`, `string`,
|
|
100
|
+
* `timestamp`, …). R2 SQL does not always echo a schema block, so `type` is
|
|
101
|
+
* optional and `columns` may be derived from the first row's keys.
|
|
102
|
+
*/
|
|
102
103
|
interface R2SqlColumn {
|
|
103
104
|
name: string;
|
|
104
105
|
type?: string;
|
|
105
106
|
}
|
|
106
107
|
/**
|
|
107
|
-
* A parsed R2 SQL result. R2 SQL returns a Cloudflare envelope
|
|
108
|
-
* (`{ success, result, errors }`); we surface the `rows` (the `result` array of
|
|
109
|
-
* column→value records), the inferred/echoed `columns`, and the `rowCount`.
|
|
110
|
-
*
|
|
111
|
-
* `Row` defaults to an open record; supply it (`from
|
|
112
|
-
* `query
|
|
113
|
-
* not `defineSchema`, so the row type is caller-declared rather than inferred.
|
|
114
|
-
*/
|
|
108
|
+
* A parsed R2 SQL result. R2 SQL returns a Cloudflare envelope
|
|
109
|
+
* (`{ success, result, errors }`); we surface the `rows` (the `result` array of
|
|
110
|
+
* column→value records), the inferred/echoed `columns`, and the `rowCount`.
|
|
111
|
+
*
|
|
112
|
+
* `Row` defaults to an open record; supply it (`from<MyRow>(…)` /
|
|
113
|
+
* `query<MyRow>(…)`) to get typed result fields — R2 SQL tables live in Iceberg,
|
|
114
|
+
* not `defineSchema`, so the row type is caller-declared rather than inferred.
|
|
115
|
+
*/
|
|
115
116
|
interface R2SqlResult<Row = Record<string, unknown>> {
|
|
116
117
|
/** Column descriptors, echoed by the engine or inferred from the first row. */
|
|
117
118
|
columns: R2SqlColumn[];
|
|
@@ -123,25 +124,25 @@ interface R2SqlResult<Row = Record<string, unknown>> {
|
|
|
123
124
|
/** Options for {@link import("./client").R2SqlClient.explain | explain}. */
|
|
124
125
|
interface R2SqlExplainOptions {
|
|
125
126
|
/**
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
* `"json"` runs `EXPLAIN FORMAT JSON` (structured plan); `"text"` (default)
|
|
128
|
+
* runs a plain `EXPLAIN`.
|
|
129
|
+
*/
|
|
129
130
|
format?: "json" | "text";
|
|
130
131
|
}
|
|
131
132
|
/**
|
|
132
|
-
* Executes a finished SQL string against R2 SQL and returns the parsed result.
|
|
133
|
-
* Deliberately non-generic (the row type is a caller-side concern) — the typed
|
|
134
|
-
* `run()` / `query()` boundaries cast the open result to the declared row.
|
|
135
|
-
*/
|
|
133
|
+
* Executes a finished SQL string against R2 SQL and returns the parsed result.
|
|
134
|
+
* Deliberately non-generic (the row type is a caller-side concern) — the typed
|
|
135
|
+
* `run()` / `query()` boundaries cast the open result to the declared row.
|
|
136
|
+
*/
|
|
136
137
|
type QueryExecutor = (statement: string) => Promise<R2SqlResult>;
|
|
137
138
|
/** Anything that compiles to a statement and can run — a {@link import("./builder").SelectBuilder | SelectBuilder} or {@link import("./set-operation").SetOperation | SetOperation}. */
|
|
138
139
|
interface Queryable<Row = Record<string, unknown>> {
|
|
139
140
|
/**
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
141
|
+
* True when this query carries its own `ORDER BY`/`LIMIT`, so a set
|
|
142
|
+
* operation must parenthesise it (R2 SQL rejects a bare `LIMIT` before a set
|
|
143
|
+
* operator). Read structurally by the set-operation renderer to avoid an
|
|
144
|
+
* import cycle.
|
|
145
|
+
*/
|
|
145
146
|
readonly needsWrapForSetOperation?: boolean;
|
|
146
147
|
run: () => Promise<R2SqlResult<Row>>;
|
|
147
148
|
toSQL: () => string;
|
|
@@ -154,16 +155,16 @@ interface SetMember {
|
|
|
154
155
|
query: Queryable<unknown>;
|
|
155
156
|
}
|
|
156
157
|
/**
|
|
157
|
-
* A composition of queries via set operations. Chain more operations, or apply a
|
|
158
|
-
* single `ORDER BY` / `LIMIT` to the combined result.
|
|
159
|
-
*/
|
|
158
|
+
* A composition of queries via set operations. Chain more operations, or apply a
|
|
159
|
+
* single `ORDER BY` / `LIMIT` to the combined result.
|
|
160
|
+
*/
|
|
160
161
|
declare class SetOperation<Row = Record<string, unknown>> implements Queryable<Row> {
|
|
161
162
|
/**
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
163
|
+
* Always `true`: a nested set operation must be parenthesised when it is a
|
|
164
|
+
* member of another set operation, or mixed operators mis-associate — e.g.
|
|
165
|
+
* `a.union(b.except(c))` must render `a UNION (b EXCEPT c)`, not the flat
|
|
166
|
+
* `a UNION b EXCEPT c`.
|
|
167
|
+
*/
|
|
167
168
|
readonly needsWrapForSetOperation = true;
|
|
168
169
|
private readonly exec;
|
|
169
170
|
private readonly members;
|
|
@@ -191,9 +192,9 @@ declare class SetOperation<Row = Record<string, unknown>> implements Queryable<R
|
|
|
191
192
|
private add;
|
|
192
193
|
}
|
|
193
194
|
/**
|
|
194
|
-
* A fluent `SELECT` over one Iceberg table (`namespace.table`), generic over the
|
|
195
|
-
* caller-declared `Row` result type.
|
|
196
|
-
*/
|
|
195
|
+
* A fluent `SELECT` over one Iceberg table (`namespace.table`), generic over the
|
|
196
|
+
* caller-declared `Row` result type.
|
|
197
|
+
*/
|
|
197
198
|
declare class SelectBuilder<Row = Record<string, unknown>> implements Queryable<Row> {
|
|
198
199
|
private readonly exec;
|
|
199
200
|
private readonly table;
|
|
@@ -231,9 +232,9 @@ declare class SelectBuilder<Row = Record<string, unknown>> implements Queryable<
|
|
|
231
232
|
/** Add `HAVING` condition(s) over aggregates; multiple are `AND`-ed. */
|
|
232
233
|
having(...conditions: Condition[]): this;
|
|
233
234
|
/**
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
235
|
+
* `QUALIFY` — filter on a window function without a subquery, e.g.
|
|
236
|
+
* `.qualify(fn.rowNumber().over({ partitionBy: "region", orderBy: desc("total") }).lte(3))`.
|
|
237
|
+
*/
|
|
237
238
|
qualify(condition: Condition): this;
|
|
238
239
|
/** `ORDER BY` term(s) — bare strings (ASC) or {@link import("./order").asc | asc}/{@link import("./order").desc | desc} tags. */
|
|
239
240
|
orderBy(...terms: OrderTerm[]): this;
|
|
@@ -261,19 +262,18 @@ declare class SelectBuilder<Row = Record<string, unknown>> implements Queryable<
|
|
|
261
262
|
private setOperation;
|
|
262
263
|
}
|
|
263
264
|
/**
|
|
264
|
-
* Thrown when R2 SQL responds with a non-2xx status, an `success: false`
|
|
265
|
-
* envelope, or an unparseable body; carries the HTTP `status` and the raw body
|
|
266
|
-
* for the caller to surface.
|
|
267
|
-
*/
|
|
268
|
-
declare class R2SqlError extends
|
|
269
|
-
readonly status: number;
|
|
265
|
+
* Thrown when R2 SQL responds with a non-2xx status, an `success: false`
|
|
266
|
+
* envelope, or an unparseable body; carries the HTTP `status` and the raw body
|
|
267
|
+
* for the caller to surface.
|
|
268
|
+
*/
|
|
269
|
+
declare class R2SqlError extends LunoraError {
|
|
270
270
|
constructor(status: number, body: string);
|
|
271
271
|
}
|
|
272
272
|
/**
|
|
273
|
-
* The typed R2 SQL surface bound to `ctx.r2sql` on **`ActionCtx` only**. This is
|
|
274
|
-
* the exact type the generated ctx imports as
|
|
275
|
-
* `import("@lunora/bindings/r2sql").R2SqlClient` — keep the name and shape stable.
|
|
276
|
-
*/
|
|
273
|
+
* The typed R2 SQL surface bound to `ctx.r2sql` on **`ActionCtx` only**. This is
|
|
274
|
+
* the exact type the generated ctx imports as
|
|
275
|
+
* `import("@lunora/bindings/r2sql").R2SqlClient` — keep the name and shape stable.
|
|
276
|
+
*/
|
|
277
277
|
interface R2SqlClient {
|
|
278
278
|
/** Run `DESCRIBE namespace.table` — column names and Iceberg types. */
|
|
279
279
|
describe: (table: string) => Promise<R2SqlResult>;
|
|
@@ -289,16 +289,16 @@ interface R2SqlClient {
|
|
|
289
289
|
showTables: (namespace: string) => Promise<R2SqlResult>;
|
|
290
290
|
}
|
|
291
291
|
/**
|
|
292
|
-
* Build an {@link R2SqlClient}. Each query POSTs to the bucket's
|
|
293
|
-
* `r2-sql/query/{bucket}` endpoint with the bearer token, then normalises the
|
|
294
|
-
* envelope into {@link R2SqlResult}.
|
|
295
|
-
*/
|
|
292
|
+
* Build an {@link R2SqlClient}. Each query POSTs to the bucket's
|
|
293
|
+
* `r2-sql/query/{bucket}` endpoint with the bearer token, then normalises the
|
|
294
|
+
* envelope into {@link R2SqlResult}.
|
|
295
|
+
*/
|
|
296
296
|
declare const createR2Sql: (config: R2SqlConfig) => R2SqlClient;
|
|
297
297
|
/**
|
|
298
|
-
* A windowed expression. Extends {@link Sql}, so it is usable anywhere a raw
|
|
299
|
-
* fragment is; `.as(alias)` makes a `SELECT` item, and the comparison helpers
|
|
300
|
-
* (`.lte`, `.gt`, `.between`, …) make `QUALIFY` conditions.
|
|
301
|
-
*/
|
|
298
|
+
* A windowed expression. Extends {@link Sql}, so it is usable anywhere a raw
|
|
299
|
+
* fragment is; `.as(alias)` makes a `SELECT` item, and the comparison helpers
|
|
300
|
+
* (`.lte`, `.gt`, `.between`, …) make `QUALIFY` conditions.
|
|
301
|
+
*/
|
|
302
302
|
declare class WindowExpression extends Sql {
|
|
303
303
|
/** Alias the expression — `... AS alias` — for use in a `SELECT` list. */
|
|
304
304
|
as(alias: string): Sql;
|
|
@@ -310,18 +310,18 @@ declare class WindowExpression extends Sql {
|
|
|
310
310
|
gt(value: unknown): Sql;
|
|
311
311
|
/** `expr >= value`. */
|
|
312
312
|
gte(value: unknown): Sql;
|
|
313
|
-
/** `expr
|
|
313
|
+
/** `expr < value`. */
|
|
314
314
|
lt(value: unknown): Sql;
|
|
315
|
-
/** `expr
|
|
315
|
+
/** `expr <= value`. */
|
|
316
316
|
lte(value: unknown): Sql;
|
|
317
317
|
private compare;
|
|
318
318
|
}
|
|
319
319
|
/** The `OVER (...)` window specification. */
|
|
320
320
|
interface OverSpec {
|
|
321
321
|
/**
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
322
|
+
* A raw frame clause, e.g. `"ROWS BETWEEN 2 PRECEDING AND CURRENT ROW"`.
|
|
323
|
+
* Spliced verbatim — it is keyword-only SQL, not a value.
|
|
324
|
+
*/
|
|
325
325
|
frame?: string;
|
|
326
326
|
/** `ORDER BY` term(s) within the window. */
|
|
327
327
|
orderBy?: OrderTerm | OrderTerm[];
|
|
@@ -329,9 +329,9 @@ interface OverSpec {
|
|
|
329
329
|
partitionBy?: Sql | string | (Sql | string)[];
|
|
330
330
|
}
|
|
331
331
|
/**
|
|
332
|
-
* A window function awaiting its `OVER (...)`. Call {@link WindowFunction.over |
|
|
333
|
-
* .over} to bind a window and get a {@link WindowExpression}.
|
|
334
|
-
*/
|
|
332
|
+
* A window function awaiting its `OVER (...)`. Call {@link WindowFunction.over |
|
|
333
|
+
* .over} to bind a window and get a {@link WindowExpression}.
|
|
334
|
+
*/
|
|
335
335
|
declare class WindowFunction {
|
|
336
336
|
private readonly callText;
|
|
337
337
|
constructor(callText: string);
|
|
@@ -339,13 +339,13 @@ declare class WindowFunction {
|
|
|
339
339
|
over(spec?: OverSpec): WindowExpression;
|
|
340
340
|
}
|
|
341
341
|
/**
|
|
342
|
-
* Window-function builders. Each returns a {@link WindowFunction}; chain
|
|
343
|
-
* `.over(...)` to bind the window.
|
|
344
|
-
*
|
|
345
|
-
* Ranking: `rowNumber`, `rank`, `denseRank`, `percentRank`, `cumeDist`,
|
|
346
|
-
* `ntile`. Offset/value: `lag`, `lead`, `firstValue`, `lastValue`, `nthValue`.
|
|
347
|
-
* Aggregates used as windows: `sum`, `avg`, `count`, `min`, `max`.
|
|
348
|
-
*/
|
|
342
|
+
* Window-function builders. Each returns a {@link WindowFunction}; chain
|
|
343
|
+
* `.over(...)` to bind the window.
|
|
344
|
+
*
|
|
345
|
+
* Ranking: `rowNumber`, `rank`, `denseRank`, `percentRank`, `cumeDist`,
|
|
346
|
+
* `ntile`. Offset/value: `lag`, `lead`, `firstValue`, `lastValue`, `nthValue`.
|
|
347
|
+
* Aggregates used as windows: `sum`, `avg`, `count`, `min`, `max`.
|
|
348
|
+
*/
|
|
349
349
|
declare const fn: {
|
|
350
350
|
/** `AVG(column) OVER (...)`. */
|
|
351
351
|
avg: (column: Sql | string) => WindowFunction;
|
package/dist/r2sql/index.mjs
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { R2SqlError, createR2Sql } from '../packem_shared/R2SqlError-DlDd_SrE.mjs';
|
|
3
|
-
export { asc, desc, renderOrderTerm } from '../packem_shared/asc-Cur-xO8v.mjs';
|
|
4
|
-
export { default as SetOperation } from '../packem_shared/SetOperation-RDHcxccj.mjs';
|
|
5
|
-
export { Sql, isSql, joinSql, lit, raw, sql, toText } from '../packem_shared/Sql-DceGtcUd.mjs';
|
|
6
|
-
export { WindowFunction, fn } from '../packem_shared/WindowFunction-DA3pGC3N.mjs';
|
|
7
|
-
export { default as WindowExpression } from '../packem_shared/WindowExpression-Cg9s2xcr.mjs';
|
|
1
|
+
import{default as o}from"../packem_shared/SelectBuilder-WMBQ2b4q.mjs";import{R2SqlError as l,createR2Sql as f}from"../packem_shared/R2SqlError-Uaz0RJTR.mjs";import{asc as d,desc as i,renderOrderTerm as n}from"../packem_shared/asc-BsbdtIQU.mjs";import{default as s}from"../packem_shared/SetOperation-BrzMB1Tb.mjs";import{Sql as m,isSql as S,joinSql as q,lit as c,raw as u,sql as w,toText as E}from"../packem_shared/Sql-CwhZl1Q5.mjs";import{WindowFunction as R,fn as T}from"../packem_shared/WindowFunction-rzl4CzYE.mjs";import{default as j}from"../packem_shared/WindowExpression-CxCuEy8V.mjs";export{l as R2SqlError,o as SelectBuilder,s as SetOperation,m as Sql,j as WindowExpression,R as WindowFunction,d as asc,f as createR2Sql,i as desc,T as fn,S as isSql,q as joinSql,c as lit,u as raw,n as renderOrderTerm,w as sql,E as toText};
|