@lunora/d1 1.0.0-alpha.100 → 1.0.0-alpha.102

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.d.mts CHANGED
@@ -261,8 +261,10 @@ interface GlobalTablePage {
261
261
  * `column = value` (or `column IS NULL` when `value` is nullish). `column` is a
262
262
  * displayed column name, validated against the table's columns and mapped to its
263
263
  * physical column (`_id` → `id`) before it is quoted; `value` is the **raw stored
264
- * value** the facet returned (a SQLite scalar), bound as a parameter and never
265
- * interpolated. AND-combined with the other clauses.
264
+ * value** the facet returned (a SQLite scalar including a BLOB, which reaches
265
+ * here as bytes because the facet payload is wire-encoded), normalised by
266
+ * {@link sqliteEncode} and bound as a parameter, never interpolated.
267
+ * AND-combined with the other clauses.
266
268
  */
267
269
  interface GlobalFilterClause {
268
270
  column: string;
@@ -330,6 +332,12 @@ declare const readGlobalTablePage: (exec: SqlCtxExec, schema: SchemaLike, option
330
332
  * redacted `•••` bucket — mirroring the page browser's value redaction so the
331
333
  * facet can't leak credentials. The returned `value` is the raw stored scalar, so
332
334
  * a click feeds it straight back as an eq filter.
335
+ *
336
+ * The payload is wire-encoded on the way out, like the page read's rows: a BLOB
337
+ * column's stored value is bytes, and `Response.json` flattens those to `{}` —
338
+ * which is not a display glitch but a broken drill-down, since the flattened
339
+ * value is what the click sends back as the filter. `needsWireEncoding` leaves a
340
+ * facet over an ordinary text/numeric column untouched.
333
341
  */
334
342
  declare const facetGlobalColumn: (exec: SqlCtxExec, schema: SchemaLike, options: FacetGlobalColumnOptions) => Promise<GlobalFacetResult>;
335
343
  interface Migration {
package/dist/index.d.ts CHANGED
@@ -261,8 +261,10 @@ interface GlobalTablePage {
261
261
  * `column = value` (or `column IS NULL` when `value` is nullish). `column` is a
262
262
  * displayed column name, validated against the table's columns and mapped to its
263
263
  * physical column (`_id` → `id`) before it is quoted; `value` is the **raw stored
264
- * value** the facet returned (a SQLite scalar), bound as a parameter and never
265
- * interpolated. AND-combined with the other clauses.
264
+ * value** the facet returned (a SQLite scalar including a BLOB, which reaches
265
+ * here as bytes because the facet payload is wire-encoded), normalised by
266
+ * {@link sqliteEncode} and bound as a parameter, never interpolated.
267
+ * AND-combined with the other clauses.
266
268
  */
267
269
  interface GlobalFilterClause {
268
270
  column: string;
@@ -330,6 +332,12 @@ declare const readGlobalTablePage: (exec: SqlCtxExec, schema: SchemaLike, option
330
332
  * redacted `•••` bucket — mirroring the page browser's value redaction so the
331
333
  * facet can't leak credentials. The returned `value` is the raw stored scalar, so
332
334
  * a click feeds it straight back as an eq filter.
335
+ *
336
+ * The payload is wire-encoded on the way out, like the page read's rows: a BLOB
337
+ * column's stored value is bytes, and `Response.json` flattens those to `{}` —
338
+ * which is not a display glitch but a broken drill-down, since the flattened
339
+ * value is what the click sends back as the filter. `needsWireEncoding` leaves a
340
+ * facet over an ordinary text/numeric column untouched.
333
341
  */
334
342
  declare const facetGlobalColumn: (exec: SqlCtxExec, schema: SchemaLike, options: FacetGlobalColumnOptions) => Promise<GlobalFacetResult>;
335
343
  interface Migration {
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{exportGlobalRows as o,importGlobalRows as t,selectGlobalTables as a}from"./packem_shared/exportGlobalRows-BvGvq9Jy.mjs";import{D1Client as i,D1Session as n}from"./packem_shared/D1Client-CzS0Qfa6.mjs";import{backfillD1SearchIndexes as D,createD1CtxDb as b,readD1CdcChanges as p,runD1AggregateMigrations as x,runD1CdcMigration as c,runD1GlobalTableMigrations as g,runD1RankMigrations as f,runD1SearchMigrations as m,sweepD1CdcRetention as C}from"./packem_shared/backfillD1SearchIndexes-V-i_kEvG.mjs";import{facetGlobalColumn as d,listGlobalTables as G,readGlobalTablePage as M}from"./packem_shared/facetGlobalColumn-9jJchfud.mjs";import{MigrationRunner as T}from"./packem_shared/MigrationRunner-SadkIbU5.mjs";import{D1TimeoutError as w,isTransientD1Error as S,retryingExec as y,withD1Retry as E}from"./packem_shared/D1TimeoutError-D4YUqZPk.mjs";import{default as q}from"./packem_shared/sqliteDialect-J6_WTDHg.mjs";import{applyCdcChanges as I}from"@lunora/shard-engine";import{createSqlCtxDb as j}from"@lunora/sql-store";export{i as D1Client,n as D1Session,w as D1TimeoutError,T as MigrationRunner,I as applyCdcChanges,D as backfillD1SearchIndexes,b as createD1CtxDb,j as createSqlCtxDb,o as exportGlobalRows,d as facetGlobalColumn,t as importGlobalRows,S as isTransientD1Error,G as listGlobalTables,p as readD1CdcChanges,M as readGlobalTablePage,y as retryingExec,x as runD1AggregateMigrations,c as runD1CdcMigration,g as runD1GlobalTableMigrations,f as runD1RankMigrations,m as runD1SearchMigrations,a as selectGlobalTables,q as sqliteDialect,C as sweepD1CdcRetention,E as withD1Retry};
1
+ import{exportGlobalRows as o,importGlobalRows as t,selectGlobalTables as a}from"./packem_shared/exportGlobalRows-BJF5C9Q_.mjs";import{D1Client as i,D1Session as n}from"./packem_shared/D1Client-CzS0Qfa6.mjs";import{backfillD1SearchIndexes as D,createD1CtxDb as b,readD1CdcChanges as p,runD1AggregateMigrations as x,runD1CdcMigration as c,runD1GlobalTableMigrations as g,runD1RankMigrations as f,runD1SearchMigrations as m,sweepD1CdcRetention as C}from"./packem_shared/backfillD1SearchIndexes-V-i_kEvG.mjs";import{facetGlobalColumn as d,listGlobalTables as G,readGlobalTablePage as M}from"./packem_shared/facetGlobalColumn-FEtvbxMP.mjs";import{MigrationRunner as T}from"./packem_shared/MigrationRunner-SadkIbU5.mjs";import{D1TimeoutError as w,isTransientD1Error as S,retryingExec as y,withD1Retry as E}from"./packem_shared/D1TimeoutError-D4YUqZPk.mjs";import{default as q}from"./packem_shared/sqliteDialect-J6_WTDHg.mjs";import{applyCdcChanges as I}from"@lunora/shard-engine";import{createSqlCtxDb as j}from"@lunora/sql-store";export{i as D1Client,n as D1Session,w as D1TimeoutError,T as MigrationRunner,I as applyCdcChanges,D as backfillD1SearchIndexes,b as createD1CtxDb,j as createSqlCtxDb,o as exportGlobalRows,d as facetGlobalColumn,t as importGlobalRows,S as isTransientD1Error,G as listGlobalTables,p as readD1CdcChanges,M as readGlobalTablePage,y as retryingExec,x as runD1AggregateMigrations,c as runD1CdcMigration,g as runD1GlobalTableMigrations,f as runD1RankMigrations,m as runD1SearchMigrations,a as selectGlobalTables,q as sqliteDialect,C as sweepD1CdcRetention,E as withD1Retry};
@@ -0,0 +1 @@
1
+ import{toErrorBody as p}from"@lunora/errors";import{n as m,e as g,d as E}from"./wire-codec-CZoaQB26.mjs";import{runD1GlobalTableMigrations as w}from"./backfillD1SearchIndexes-V-i_kEvG.mjs";import{quoteIdentifier as u}from"./quoteIdentifier-CObIFRhb.mjs";import{decodeGlobalRow as R}from"@lunora/sql-store";const k=200,y=(t,o)=>{const r=e=>t.tables[e]?.shardMode?.kind==="global";return o&&o.length>0?o.filter(e=>r(e)):Object.keys(t.tables).filter(e=>r(e))},O=(t,o,r)=>{const e=t.tables[o];return e?R(e,r):{_creationTime:r._creationTime,_id:r.id}},h=t=>m(t)?g(t):t,W=async function*(t,o,r){const e=y(o,r.tables),i=r.batchSize??k;await w(t,o);for(const s of e){const n=u(s);let a,l=!0;for(;l;){const c=a===void 0?await t.all(`SELECT * FROM ${n} ORDER BY "id" LIMIT ?`,[i]):await t.all(`SELECT * FROM ${n} WHERE "id" > ? ORDER BY "id" LIMIT ?`,[a,i]);for(const f of c)yield{doc:h(O(o,s,f)),table:s};const d=c.at(-1);d!==void 0&&(a=String(d.id)),l=c.length===i}}},b=t=>t?._meta?.column?.notNull===!1,I=(t,o)=>{const r=new Set;for(const[e,i]of Object.entries(t.shape)){if(o[e]!==null||i.kind!=="optional"||b(i))continue;const s=i._meta?.inner;b(s)||r.add(e)}return r.size===0?o:Object.fromEntries(Object.entries(o).filter(([e])=>!r.has(e)))},T=(t,o,r)=>{const e=t.tables[o];if(!e)return`unknown table: ${o}`;for(const[i,s]of Object.entries(e.shape)){const n=r[i],a=s.kind==="optional";if(n===void 0&&a)continue;const l=s.parse;if(typeof l=="function")try{l(n)}catch(c){const d=c instanceof Error?c.message:String(c);return`field "${i}": ${d}`}}},S=async(t,o,r,e)=>{try{return o?(await o.all(`SELECT 1 AS hit FROM ${u(r)} WHERE "id" = ? LIMIT 1`,[e])).length>0:await t.get(e)!==null}catch{return!1}},_=async(t,o,r,e,i)=>{const{doc:s,table:n}=e;if(typeof n!="string"||n.length===0)return{error:{code:"BAD_ROW",line:i,message:"row is missing `table`",table:n},kind:"error"};if(o.tables[n]?.shardMode?.kind!=="global")return{kind:"skip"};if(!s||typeof s!="object"||Array.isArray(s))return{error:{code:"BAD_ROW",line:i,message:"row is missing or malformed `doc`",table:n},kind:"error"};let a;try{a=E(s)}catch(d){return{error:{code:"BAD_ROW",line:i,message:d instanceof Error?d.message:String(d),table:n},kind:"error"}}a=I(o.tables[n],a);const l=T(o,n,a);if(l!==void 0)return{error:{code:"VALIDATION_ERROR",line:i,message:l,table:n},kind:"error"};const c=typeof a._id=="string"?a._id:void 0;if(c!==void 0&&await S(t,r.exec,n,c))return{kind:"conflict"};try{return await t.insert(n,a,{allowExplicitId:!0}),{inserted:n,kind:"inserted"}}catch(d){const{body:f}=p(d,{fallbackCode:"INSERT_FAILED"});return{error:{code:f.code,line:i,message:f.message,table:n},kind:"error"}}},B=async(t,o,r)=>{const e=[],i={};let s=0,n=(r.startLine??1)-1;for(const a of r.rows){n+=1;const l=a.line??n,c=await _(t,o,r,a,l);switch(c.kind){case"conflict":{s+=1;break}case"error":{e.push(c.error);break}case"inserted":{i[c.inserted]=(i[c.inserted]??0)+1;break}}}return{conflicts:s,errors:e,inserted:i}};export{W as exportGlobalRows,B as importGlobalRows,y as selectGlobalTables};
@@ -0,0 +1 @@
1
+ import{LunoraError as E}from"@lunora/errors";import{sqliteEncode as I,decodeGlobalRow as $}from"@lunora/sql-store";import{n as M,e as v}from"./wire-codec-CZoaQB26.mjs";import{runD1GlobalTableMigrations as S}from"./backfillD1SearchIndexes-V-i_kEvG.mjs";import{quoteIdentifier as i}from"./quoteIdentifier-CObIFRhb.mjs";const C=50,g=500,y=30,U=200,h=(t,o,n)=>Math.min(Math.max(t,o),n),F=/^sqlite_|^_cf_|^d1_|^__cdc|__agg_|__rank_|__fts_/u,k=t=>F.test(t),N=/password|secret|token|hash|salt|credential/iu,p=async t=>(await t.all("SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name",[])).map(n=>String(n.name)).filter(n=>!k(n)),A=async(t,o,n)=>{if(await S(t,o),!(await p(t)).includes(n))throw new E("UNKNOWN_TABLE",`unknown table: ${n}`,{status:404})},T=async(t,o,n="",a=[])=>{const e=await t.all(`SELECT COUNT(*) AS c FROM ${o}${n}`,a);return Number(e[0]?.c??0)},L=(t,o,n)=>t.tables[o]!==void 0&&n==="_id"?"id":n,O=(t,o,n,a)=>{const e=[],r=[];for(const s of a??[]){if(!n.includes(s.column))throw new E("UNKNOWN_COLUMN",`unknown column: ${s.column}`,{status:404});if(t.tables[o]===void 0&&N.test(s.column))throw new E("FORBIDDEN",`cannot filter on a redacted column: ${s.column}`,{status:403});const l=i(L(t,o,s.column));s.value===null||s.value===void 0?e.push(`${l} IS NULL`):(e.push(`${l} = ?`),r.push(I(s.value)))}return{params:r,where:e.length>0?` WHERE ${e.join(" AND ")}`:""}},q=(t,o,n)=>{const a=t.tables[o];if(a)return $(a,n);const e={};for(const[r,s]of Object.entries(n))e[r]=s!=null&&N.test(r)?"•••":s;return e},R=async(t,o,n)=>{const a=o.tables[n];return a?["_id","_creationTime",...Object.keys(a.shape)]:(await t.all(`PRAGMA table_info(${i(n)})`,[])).map(r=>String(r.name))},G=async(t,o,n)=>{if(o.tables[n])return;const a=await t.all(`PRAGMA foreign_key_list(${i(n)})`,[]);if(a.length===0)return;const e={};for(const r of a){const s=String(r.from),l=String(r.table);e[s]??=l}return e},K=async(t,o)=>{await S(t,o);const n=await p(t);return Promise.all(n.map(async a=>({name:a,rowCount:await T(t,i(a))})))},Y=async(t,o,n)=>{const{table:a}=n;await A(t,o,a);const e=h(Math.trunc(n.limit??C),1,g),r=Math.max(0,Math.trunc(n.offset??0)),s=i(a),l=await R(t,o,a),{params:w,where:u}=O(o,a,l,n.filters),f=await T(t,s,u,w),m=(await t.all(`SELECT * FROM ${s}${u} LIMIT ? OFFSET ?`,[...w,e,r])).map(d=>{const c=q(o,a,d);return M(c)?v(c):c}),b=await G(t,o,a);return b===void 0?{columns:l,rows:m,total:f}:{columns:l,refs:b,rows:m,total:f}},H=async(t,o,n)=>{const{column:a,table:e}=n;await A(t,o,e);const r=await R(t,o,e);if(!r.includes(a))throw new E("UNKNOWN_COLUMN",`unknown column: ${a}`,{status:404});const s=i(e),{params:l,where:w}=O(o,e,r,n.filters);if(o.tables[e]===void 0&&N.test(a)){const c=await T(t,s,w,l);return{truncated:!1,values:c===0?[]:[{count:c,value:"•••"}]}}const u=h(Math.trunc(n.limit??y),1,U),f=i(L(o,e,a)),_=await t.all(`SELECT ${f} AS value, COUNT(*) AS count FROM ${s}${w} GROUP BY ${f} ORDER BY count DESC LIMIT ?`,[...l,u+1]),m=_.length>u,d=(m?_.slice(0,u):_).map(c=>({count:Number(c.count),value:c.value}));return{truncated:m,values:M(d)?v(d):d}};export{H as facetGlobalColumn,K as listGlobalTables,Y as readGlobalTablePage};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/d1",
3
- "version": "1.0.0-alpha.100",
3
+ "version": "1.0.0-alpha.102",
4
4
  "description": "D1 adapter for Lunora .global() tables, wrapping the Sessions API for read-your-writes",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -50,10 +50,10 @@
50
50
  "access": "public"
51
51
  },
52
52
  "dependencies": {
53
- "@lunora/errors": "1.0.0-alpha.27",
53
+ "@lunora/errors": "1.0.0-alpha.28",
54
54
  "@lunora/platform": "1.0.0-alpha.23",
55
- "@lunora/shard-engine": "1.0.0-alpha.49",
56
- "@lunora/sql-store": "1.0.0-alpha.102",
55
+ "@lunora/shard-engine": "1.0.0-alpha.51",
56
+ "@lunora/sql-store": "1.0.0-alpha.104",
57
57
  "drizzle-orm": "^0.45.2"
58
58
  },
59
59
  "engines": {
@@ -1 +0,0 @@
1
- import{toErrorBody as u}from"@lunora/errors";import{n as p,e as g,d as m}from"./wire-codec-CZoaQB26.mjs";import{runD1GlobalTableMigrations as E}from"./backfillD1SearchIndexes-V-i_kEvG.mjs";import{quoteIdentifier as b}from"./quoteIdentifier-CObIFRhb.mjs";import{decodeGlobalRow as R}from"@lunora/sql-store";const w=200,k=(e,o)=>{const i=r=>e.tables[r]?.shardMode?.kind==="global";return o&&o.length>0?o.filter(r=>i(r)):Object.keys(e.tables).filter(r=>i(r))},y=(e,o,i)=>{const r=e.tables[o];return r?R(r,i):{_creationTime:i._creationTime,_id:i.id}},I=e=>p(e)?g(e):e,M=async function*(e,o,i){const r=k(o,i.tables),n=i.batchSize??w;await E(e,o);for(const s of r){const t=b(s);let c,d=!0;for(;d;){const a=c===void 0?await e.all(`SELECT * FROM ${t} ORDER BY "id" LIMIT ?`,[n]):await e.all(`SELECT * FROM ${t} WHERE "id" > ? ORDER BY "id" LIMIT ?`,[c,n]);for(const f of a)yield{doc:I(y(o,s,f)),table:s};const l=a.at(-1);l!==void 0&&(c=String(l.id)),d=a.length===n}}},h=(e,o,i)=>{const r=e.tables[o];if(!r)return`unknown table: ${o}`;for(const[n,s]of Object.entries(r.shape)){const t=i[n],c=s.kind==="optional";if(t===void 0&&c)continue;const d=s.parse;if(typeof d=="function")try{d(t)}catch(a){const l=a instanceof Error?a.message:String(a);return`field "${n}": ${l}`}}},T=async(e,o,i,r)=>{try{return o?(await o.all(`SELECT 1 AS hit FROM ${b(i)} WHERE "id" = ? LIMIT 1`,[r])).length>0:await e.get(r)!==null}catch{return!1}},O=async(e,o,i,r,n)=>{const{doc:s,table:t}=r;if(typeof t!="string"||t.length===0)return{error:{code:"BAD_ROW",line:n,message:"row is missing `table`",table:t},kind:"error"};if(o.tables[t]?.shardMode?.kind!=="global")return{kind:"skip"};if(!s||typeof s!="object"||Array.isArray(s))return{error:{code:"BAD_ROW",line:n,message:"row is missing or malformed `doc`",table:t},kind:"error"};let c;try{c=m(s)}catch(l){return{error:{code:"BAD_ROW",line:n,message:l instanceof Error?l.message:String(l),table:t},kind:"error"}}const d=h(o,t,c);if(d!==void 0)return{error:{code:"VALIDATION_ERROR",line:n,message:d,table:t},kind:"error"};const a=typeof c._id=="string"?c._id:void 0;if(a!==void 0&&await T(e,i.exec,t,a))return{kind:"conflict"};try{return await e.insert(t,c,{allowExplicitId:!0}),{inserted:t,kind:"inserted"}}catch(l){const{body:f}=u(l,{fallbackCode:"INSERT_FAILED"});return{error:{code:f.code,line:n,message:f.message,table:t},kind:"error"}}},_=async(e,o,i)=>{const r=[],n={};let s=0,t=(i.startLine??1)-1;for(const c of i.rows){t+=1;const d=c.line??t,a=await O(e,o,i,c,d);switch(a.kind){case"conflict":{s+=1;break}case"error":{r.push(a.error);break}case"inserted":{n[a.inserted]=(n[a.inserted]??0)+1;break}}}return{conflicts:s,errors:r,inserted:n}};export{M as exportGlobalRows,_ as importGlobalRows,k as selectGlobalTables};
@@ -1 +0,0 @@
1
- import{LunoraError as E}from"@lunora/errors";import{n as R,e as p}from"./wire-codec-CZoaQB26.mjs";import{runD1GlobalTableMigrations as M}from"./backfillD1SearchIndexes-V-i_kEvG.mjs";import{quoteIdentifier as i}from"./quoteIdentifier-CObIFRhb.mjs";import{decodeGlobalRow as I}from"@lunora/sql-store";const $=50,C=500,g=30,y=200,v=(t,o,n)=>Math.min(Math.max(t,o),n),U=/^sqlite_|^_cf_|^d1_|^__cdc|__agg_|__rank_|__fts_/u,F=t=>U.test(t),N=/password|secret|token|hash|salt|credential/iu,S=async t=>(await t.all("SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name",[])).map(n=>String(n.name)).filter(n=>!F(n)),h=async(t,o,n)=>{if(await M(t,o),!(await S(t)).includes(n))throw new E("UNKNOWN_TABLE",`unknown table: ${n}`,{status:404})},T=async(t,o,n="",a=[])=>{const e=await t.all(`SELECT COUNT(*) AS c FROM ${o}${n}`,a);return Number(e[0]?.c??0)},A=(t,o,n)=>t.tables[o]!==void 0&&n==="_id"?"id":n,L=(t,o,n,a)=>{const e=[],r=[];for(const s of a??[]){if(!n.includes(s.column))throw new E("UNKNOWN_COLUMN",`unknown column: ${s.column}`,{status:404});if(t.tables[o]===void 0&&N.test(s.column))throw new E("FORBIDDEN",`cannot filter on a redacted column: ${s.column}`,{status:403});const l=i(A(t,o,s.column));s.value===null||s.value===void 0?e.push(`${l} IS NULL`):(e.push(`${l} = ?`),r.push(s.value))}return{params:r,where:e.length>0?` WHERE ${e.join(" AND ")}`:""}},G=(t,o,n)=>{const a=t.tables[o];if(a)return I(a,n);const e={};for(const[r,s]of Object.entries(n))e[r]=s!=null&&N.test(r)?"•••":s;return e},O=async(t,o,n)=>{const a=o.tables[n];return a?["_id","_creationTime",...Object.keys(a.shape)]:(await t.all(`PRAGMA table_info(${i(n)})`,[])).map(r=>String(r.name))},P=async(t,o,n)=>{if(o.tables[n])return;const a=await t.all(`PRAGMA foreign_key_list(${i(n)})`,[]);if(a.length===0)return;const e={};for(const r of a){const s=String(r.from),l=String(r.table);e[s]??=l}return e},j=async(t,o)=>{await M(t,o);const n=await S(t);return Promise.all(n.map(async a=>({name:a,rowCount:await T(t,i(a))})))},K=async(t,o,n)=>{const{table:a}=n;await h(t,o,a);const e=v(Math.trunc(n.limit??$),1,C),r=Math.max(0,Math.trunc(n.offset??0)),s=i(a),l=await O(t,o,a),{params:w,where:u}=L(o,a,l,n.filters),f=await T(t,s,u,w),m=(await t.all(`SELECT * FROM ${s}${u} LIMIT ? OFFSET ?`,[...w,e,r])).map(c=>{const b=G(o,a,c);return R(b)?p(b):b}),_=await P(t,o,a);return _===void 0?{columns:l,rows:m,total:f}:{columns:l,refs:_,rows:m,total:f}},Y=async(t,o,n)=>{const{column:a,table:e}=n;await h(t,o,e);const r=await O(t,o,e);if(!r.includes(a))throw new E("UNKNOWN_COLUMN",`unknown column: ${a}`,{status:404});const s=i(e),{params:l,where:w}=L(o,e,r,n.filters);if(o.tables[e]===void 0&&N.test(a)){const c=await T(t,s,w,l);return{truncated:!1,values:c===0?[]:[{count:c,value:"•••"}]}}const u=v(Math.trunc(n.limit??g),1,y),f=i(A(o,e,a)),d=await t.all(`SELECT ${f} AS value, COUNT(*) AS count FROM ${s}${w} GROUP BY ${f} ORDER BY count DESC LIMIT ?`,[...l,u+1]),m=d.length>u,_=m?d.slice(0,u):d;return{truncated:m,values:_.map(c=>({count:Number(c.count),value:c.value}))}};export{Y as facetGlobalColumn,j as listGlobalTables,K as readGlobalTablePage};