@lunora/bindings 1.0.0-alpha.46 → 1.0.0-alpha.47
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/analytics/index.d.mts +8 -1
- package/dist/analytics/index.d.ts +8 -1
- package/dist/analytics/index.mjs +1 -1
- package/dist/packem_shared/AnalyticsSqlError-CeQ3A5Eb.mjs +1 -0
- package/dist/packem_shared/R2SqlError-utivPDyt.mjs +1 -0
- package/dist/packem_shared/cap-error-body-YBKO32BF.mjs +1 -0
- package/dist/r2sql/index.d.mts +5 -2
- package/dist/r2sql/index.d.ts +5 -2
- package/dist/r2sql/index.mjs +1 -1
- package/package.json +3 -3
- package/dist/packem_shared/AnalyticsSqlError-BEKML_Dg.mjs +0 -1
- package/dist/packem_shared/R2SqlError-CJ_zgztT.mjs +0 -1
|
@@ -120,7 +120,14 @@ interface AnalyticsSqlResult {
|
|
|
120
120
|
rowCount: number;
|
|
121
121
|
rows: Record<string, unknown>[];
|
|
122
122
|
}
|
|
123
|
-
/**
|
|
123
|
+
/**
|
|
124
|
+
* Thrown when the SQL API responds with a non-2xx status; a `LunoraError`
|
|
125
|
+
* subclass carrying the HTTP `status` + a capped body preview, with the full
|
|
126
|
+
* body on `cause`.
|
|
127
|
+
*
|
|
128
|
+
* The preview is capped because AE's SQL error text quotes the query back, and
|
|
129
|
+
* `ANALYTICS_SQL_ERROR` is non-internal — the message reaches the browser.
|
|
130
|
+
*/
|
|
124
131
|
declare class AnalyticsSqlError extends LunoraError {
|
|
125
132
|
constructor(status: number, body: string);
|
|
126
133
|
}
|
|
@@ -120,7 +120,14 @@ interface AnalyticsSqlResult {
|
|
|
120
120
|
rowCount: number;
|
|
121
121
|
rows: Record<string, unknown>[];
|
|
122
122
|
}
|
|
123
|
-
/**
|
|
123
|
+
/**
|
|
124
|
+
* Thrown when the SQL API responds with a non-2xx status; a `LunoraError`
|
|
125
|
+
* subclass carrying the HTTP `status` + a capped body preview, with the full
|
|
126
|
+
* body on `cause`.
|
|
127
|
+
*
|
|
128
|
+
* The preview is capped because AE's SQL error text quotes the query back, and
|
|
129
|
+
* `ANALYTICS_SQL_ERROR` is non-internal — the message reaches the browser.
|
|
130
|
+
*/
|
|
124
131
|
declare class AnalyticsSqlError extends LunoraError {
|
|
125
132
|
constructor(status: number, body: string);
|
|
126
133
|
}
|
package/dist/analytics/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createAnalytics as e}from"../packem_shared/createAnalytics-BXTNc57d.mjs";import{AnalyticsSqlError as a,createAnalyticsSqlClient as c}from"../packem_shared/AnalyticsSqlError-
|
|
1
|
+
import{createAnalytics as e}from"../packem_shared/createAnalytics-BXTNc57d.mjs";import{AnalyticsSqlError as a,createAnalyticsSqlClient as c}from"../packem_shared/AnalyticsSqlError-CeQ3A5Eb.mjs";export{a as AnalyticsSqlError,e as createAnalytics,c as createAnalyticsSqlClient};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraError as y}from"@lunora/errors";import{c as h}from"./cap-error-body-YBKO32BF.mjs";const w="https://api.cloudflare.com/client/v4/accounts",S=6e4;class a extends y{constructor(r,o){super("ANALYTICS_SQL_ERROR",`Analytics Engine SQL API returned ${String(r)}: ${h(o)}`,{cause:o,name:"AnalyticsSqlError",status:r})}}const b=e=>{const r=e.fetch??globalThis.fetch,o=`${w}/${encodeURIComponent(e.accountId)}/analytics_engine/sql`,c=e.timeoutMs??S;return{query:async u=>{const n=new AbortController,d=setTimeout(()=>{n.abort()},c);try{const t=await r(o,{body:u,headers:{Authorization:`Bearer ${e.apiToken}`,"Content-Type":"text/plain"},method:"POST",signal:n.signal});if(!t.ok)throw new a(t.status,await t.text().catch(()=>"<error body unavailable: the request deadline fired before it was read>"));let i;try{i=await t.json()}catch(m){throw n.signal.aborted?m:new a(t.status,"Analytics Engine SQL API returned a non-JSON body.")}const s=i,l=s.data??[];return{columns:s.meta??[],rowCount:s.rows??l.length,rows:l}}catch(t){throw n.signal.aborted&&!(t instanceof a)?new a(504,`query timed out after ${String(c)}ms (AnalyticsSqlConfig.timeoutMs)`):t}finally{clearTimeout(d)}}}};export{a as AnalyticsSqlError,b as createAnalyticsSqlClient};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraError as f}from"@lunora/errors";import{c as b}from"./cap-error-body-YBKO32BF.mjs";import R from"./SelectBuilder-Dnqem9T0.mjs";import{ident as m,toText as h}from"./Sql-BfnxRway.mjs";const T="https://api.sql.cloudflarestorage.com/api/v1/accounts",E=6e4,$=e=>e[0]===void 0?[]:Object.keys(e[0]).map(s=>({name:s}));class c extends f{constructor(s,i){super("R2_SQL_ERROR",`R2 SQL query failed (${String(s)}): ${b(i)}`,{cause:i,name:"R2SqlError",status:s})}}const C=e=>{const s=e.fetch??globalThis.fetch,S=`${e.endpoint??T}/${encodeURIComponent(e.accountId)}/r2-sql/query/${encodeURIComponent(e.bucket)}`,p=`${e.accountId}_${e.bucket}`,l=e.timeoutMs??E,n=async t=>{const a=new AbortController,w=setTimeout(()=>{a.abort()},l);try{const r=await s(S,{body:JSON.stringify({query:t,warehouse:p}),headers:{Authorization:`Bearer ${e.apiToken}`,"Content-Type":"application/json"},method:"POST",signal:a.signal});if(!r.ok)throw new c(r.status,await r.text().catch(()=>"<error body unavailable: the request deadline fired before it was read>"));let d;try{d=await r.json()}catch(y){throw a.signal.aborted?y:new c(r.status,"R2 SQL returned a non-JSON body.")}const o=d;if(o.success===!1||o.errors!==void 0&&o.errors.length>0)throw new c(r.status,JSON.stringify(o.errors??o));const u=o.result?.rows??[];return{columns:o.result?.schema??$(u),rowCount:u.length,rows:u}}catch(r){throw a.signal.aborted&&!(r instanceof c)?new c(504,`query timed out after ${String(l)}ms (R2SqlConfig.timeoutMs)`):r}finally{clearTimeout(w)}};return{describe:async t=>n(`DESCRIBE ${m(t)}`),explain:async(t,a)=>n(`EXPLAIN ${a?.format==="json"?"FORMAT JSON ":""}${h(t)}`),from:t=>new R(n,t),query:async t=>n(h(t)),showDatabases:async()=>n("SHOW DATABASES"),showTables:async t=>n(`SHOW TABLES IN ${m(t)}`)}};export{c as R2SqlError,C as createR2Sql};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const _=R=>R.length>256?`${R.slice(0,256)}… (truncated)`:R;export{_ as c};
|
package/dist/r2sql/index.d.mts
CHANGED
|
@@ -273,8 +273,11 @@ declare class SelectBuilder<Row = Record<string, unknown>> implements Queryable<
|
|
|
273
273
|
}
|
|
274
274
|
/**
|
|
275
275
|
* Thrown when R2 SQL responds with a non-2xx status, an `success: false`
|
|
276
|
-
* envelope, or an unparseable body; carries the HTTP `status` and
|
|
277
|
-
* for the caller to surface
|
|
276
|
+
* envelope, or an unparseable body; carries the HTTP `status` and a capped body
|
|
277
|
+
* preview for the caller to surface, with the full body on `cause`.
|
|
278
|
+
*
|
|
279
|
+
* The preview is capped because the engine's SQL error text quotes the query
|
|
280
|
+
* back, and `R2_SQL_ERROR` is non-internal — the message reaches the browser.
|
|
278
281
|
*/
|
|
279
282
|
declare class R2SqlError extends LunoraError {
|
|
280
283
|
constructor(status: number, body: string);
|
package/dist/r2sql/index.d.ts
CHANGED
|
@@ -273,8 +273,11 @@ declare class SelectBuilder<Row = Record<string, unknown>> implements Queryable<
|
|
|
273
273
|
}
|
|
274
274
|
/**
|
|
275
275
|
* Thrown when R2 SQL responds with a non-2xx status, an `success: false`
|
|
276
|
-
* envelope, or an unparseable body; carries the HTTP `status` and
|
|
277
|
-
* for the caller to surface
|
|
276
|
+
* envelope, or an unparseable body; carries the HTTP `status` and a capped body
|
|
277
|
+
* preview for the caller to surface, with the full body on `cause`.
|
|
278
|
+
*
|
|
279
|
+
* The preview is capped because the engine's SQL error text quotes the query
|
|
280
|
+
* back, and `R2_SQL_ERROR` is non-internal — the message reaches the browser.
|
|
278
281
|
*/
|
|
279
282
|
declare class R2SqlError extends LunoraError {
|
|
280
283
|
constructor(status: number, body: string);
|
package/dist/r2sql/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as o}from"../packem_shared/SelectBuilder-Dnqem9T0.mjs";import{R2SqlError as l,createR2Sql as f}from"../packem_shared/R2SqlError-
|
|
1
|
+
import{default as o}from"../packem_shared/SelectBuilder-Dnqem9T0.mjs";import{R2SqlError as l,createR2Sql as f}from"../packem_shared/R2SqlError-utivPDyt.mjs";import{asc as d,desc as i,renderOrderTerm as n}from"../packem_shared/asc-DP_WFiAE.mjs";import{default as s}from"../packem_shared/SetOperation-kiI5Wnlm.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-BfnxRway.mjs";import{WindowFunction as R,fn as T}from"../packem_shared/WindowFunction-CL4jYy2l.mjs";import{default as j}from"../packem_shared/WindowExpression-VX7EEV3h.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};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/bindings",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.47",
|
|
4
4
|
"description": "Lightweight Cloudflare binding helpers for Lunora — ctx.kv, ctx.images, ctx.analytics, ctx.pipelines, ctx.vectors, ctx.r2sql — one install, per-binding subpaths",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"analytics",
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"access": "public"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@lunora/errors": "1.0.0-alpha.
|
|
68
|
-
"@lunora/platform": "1.0.0-alpha.
|
|
67
|
+
"@lunora/errors": "1.0.0-alpha.30",
|
|
68
|
+
"@lunora/platform": "1.0.0-alpha.25"
|
|
69
69
|
},
|
|
70
70
|
"engines": {
|
|
71
71
|
"node": "^22.15.0 || >=24.11.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{LunoraError as h}from"@lunora/errors";const m="https://api.cloudflare.com/client/v4/accounts",w=6e4;class r extends h{constructor(o,a){super("ANALYTICS_SQL_ERROR",`Analytics Engine SQL API returned ${String(o)}: ${a}`,{name:"AnalyticsSqlError",status:o})}}const p=e=>{const o=e.fetch??globalThis.fetch,a=`${m}/${encodeURIComponent(e.accountId)}/analytics_engine/sql`,i=e.timeoutMs??w;return{query:async u=>{const n=new AbortController,d=setTimeout(()=>{n.abort()},i);try{const t=await o(a,{body:u,headers:{Authorization:`Bearer ${e.apiToken}`,"Content-Type":"text/plain"},method:"POST",signal:n.signal});if(!t.ok)throw new r(t.status,await t.text().catch(()=>"<error body unavailable: the request deadline fired before it was read>"));let c;try{c=await t.json()}catch(y){throw n.signal.aborted?y:new r(t.status,"Analytics Engine SQL API returned a non-JSON body.")}const s=c,l=s.data??[];return{columns:s.meta??[],rowCount:s.rows??l.length,rows:l}}catch(t){throw n.signal.aborted&&!(t instanceof r)?new r(504,`query timed out after ${String(i)}ms (AnalyticsSqlConfig.timeoutMs)`):t}finally{clearTimeout(d)}}}};export{r as AnalyticsSqlError,p as createAnalyticsSqlClient};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{LunoraError as b}from"@lunora/errors";import f from"./SelectBuilder-Dnqem9T0.mjs";import{ident as m,toText as h}from"./Sql-BfnxRway.mjs";const R="https://api.sql.cloudflarestorage.com/api/v1/accounts",T=6e4,$=e=>e[0]===void 0?[]:Object.keys(e[0]).map(s=>({name:s}));class c extends b{constructor(s,l){super("R2_SQL_ERROR",`R2 SQL query failed (${String(s)}): ${l}`,{name:"R2SqlError",status:s})}}const O=e=>{const s=e.fetch??globalThis.fetch,S=`${e.endpoint??R}/${encodeURIComponent(e.accountId)}/r2-sql/query/${encodeURIComponent(e.bucket)}`,w=`${e.accountId}_${e.bucket}`,u=e.timeoutMs??T,n=async t=>{const a=new AbortController,y=setTimeout(()=>{a.abort()},u);try{const r=await s(S,{body:JSON.stringify({query:t,warehouse:w}),headers:{Authorization:`Bearer ${e.apiToken}`,"Content-Type":"application/json"},method:"POST",signal:a.signal});if(!r.ok)throw new c(r.status,await r.text().catch(()=>"<error body unavailable: the request deadline fired before it was read>"));let d;try{d=await r.json()}catch(p){throw a.signal.aborted?p:new c(r.status,"R2 SQL returned a non-JSON body.")}const o=d;if(o.success===!1||o.errors!==void 0&&o.errors.length>0)throw new c(r.status,JSON.stringify(o.errors??o));const i=o.result?.rows??[];return{columns:o.result?.schema??$(i),rowCount:i.length,rows:i}}catch(r){throw a.signal.aborted&&!(r instanceof c)?new c(504,`query timed out after ${String(u)}ms (R2SqlConfig.timeoutMs)`):r}finally{clearTimeout(y)}};return{describe:async t=>n(`DESCRIBE ${m(t)}`),explain:async(t,a)=>n(`EXPLAIN ${a?.format==="json"?"FORMAT JSON ":""}${h(t)}`),from:t=>new f(n,t),query:async t=>n(h(t)),showDatabases:async()=>n("SHOW DATABASES"),showTables:async t=>n(`SHOW TABLES IN ${m(t)}`)}};export{c as R2SqlError,O as createR2Sql};
|