@gscdump/cloudflare 0.25.13 → 0.25.14
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/server-tail/index.mjs +18 -4
- package/package.json +9 -9
|
@@ -133,7 +133,7 @@ function buildTopNBreakdown(q) {
|
|
|
133
133
|
const metrics = (q.metrics.includes(q.orderBy.metric) ? q.metrics : [...q.metrics, q.orderBy.metric]).map(metricExpr).join(", ");
|
|
134
134
|
const order = `${q.orderBy.metric} ${q.orderBy.dir.toUpperCase()}`;
|
|
135
135
|
const facet = facetPredicate(q);
|
|
136
|
-
let sql = `SELECT ${col}, ${metrics} FROM ${TABLE_PLACEHOLDER} WHERE ${w.clause}${facet.sql} GROUP BY ${col} ORDER BY ${order} LIMIT ${Math.max(0, Math.floor(q.limit))}`;
|
|
136
|
+
let sql = `SELECT ${col}, ${metrics}${q.includeTotal ? ", COUNT(*) OVER() AS __total" : ""} FROM ${TABLE_PLACEHOLDER} WHERE ${w.clause}${facet.sql} GROUP BY ${col} ORDER BY ${order} LIMIT ${Math.max(0, Math.floor(q.limit))}`;
|
|
137
137
|
if (q.offset && q.offset > 0) sql += ` OFFSET ${Math.floor(q.offset)}`;
|
|
138
138
|
return {
|
|
139
139
|
table,
|
|
@@ -225,6 +225,7 @@ function resolveServerTailEngine(query) {
|
|
|
225
225
|
if (cls === "cloud-only") throw new ServerTailRoutingError(`archetype '${query.archetype}' is cloud-only — not a server-tail query`);
|
|
226
226
|
if (cls === "duckdb") return "duckdb";
|
|
227
227
|
if (query.archetype === "top-n-breakdown" && query.offset && query.offset > 0) return "duckdb";
|
|
228
|
+
if (query.archetype === "top-n-breakdown" && query.includeTotal) return "duckdb";
|
|
228
229
|
const facets = query.facets;
|
|
229
230
|
if (facets && facets.length > 0) return "duckdb";
|
|
230
231
|
return "r2-sql";
|
|
@@ -232,6 +233,17 @@ function resolveServerTailEngine(query) {
|
|
|
232
233
|
function sourceFor(engine) {
|
|
233
234
|
return engine === "r2-sql" ? "server-r2-sql" : "server-duckdb";
|
|
234
235
|
}
|
|
236
|
+
function extractTotal(rows) {
|
|
237
|
+
if (!rows.length || !("__total" in rows[0])) return { rows };
|
|
238
|
+
const totalRows = Number(rows[0].__total) || 0;
|
|
239
|
+
return {
|
|
240
|
+
rows: rows.map((r) => {
|
|
241
|
+
const { __total, ...rest } = r;
|
|
242
|
+
return rest;
|
|
243
|
+
}),
|
|
244
|
+
totalRows
|
|
245
|
+
};
|
|
246
|
+
}
|
|
235
247
|
function createServerTailDispatcher(config) {
|
|
236
248
|
function route(query) {
|
|
237
249
|
return resolveServerTailEngine(query);
|
|
@@ -255,13 +267,15 @@ function createServerTailDispatcher(config) {
|
|
|
255
267
|
};
|
|
256
268
|
}
|
|
257
269
|
const res = await config.duckdb.runArchetype(query);
|
|
270
|
+
const { rows, totalRows } = extractTotal(res.rows);
|
|
258
271
|
return {
|
|
259
272
|
archetype: query.archetype,
|
|
260
|
-
rows
|
|
273
|
+
rows,
|
|
261
274
|
source: sourceFor("duckdb"),
|
|
262
275
|
meta: {
|
|
263
|
-
rowCount:
|
|
264
|
-
queryMs: res.queryMs
|
|
276
|
+
rowCount: rows.length,
|
|
277
|
+
queryMs: res.queryMs,
|
|
278
|
+
...totalRows !== void 0 ? { totalRows } : {}
|
|
265
279
|
}
|
|
266
280
|
};
|
|
267
281
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gscdump/cloudflare",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.25.
|
|
4
|
+
"version": "0.25.14",
|
|
5
5
|
"description": "Cloudflare-Workers-flavored helpers for the gscdump analytics stack: AnalyticsEnv binding contract, R2 SigV4 presigner, size-hint HMAC, DuckDB Workers shims, engine factory.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Harlan Wilton",
|
|
@@ -46,18 +46,18 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@uwdata/flechette": "^2.5.0",
|
|
48
48
|
"aws4fetch": "^1.0.20",
|
|
49
|
-
"@gscdump/
|
|
50
|
-
"@gscdump/
|
|
51
|
-
"@gscdump/
|
|
52
|
-
"gscdump": "0.25.
|
|
53
|
-
"
|
|
49
|
+
"@gscdump/contracts": "0.25.14",
|
|
50
|
+
"@gscdump/engine": "0.25.14",
|
|
51
|
+
"@gscdump/engine-sqlite": "0.25.14",
|
|
52
|
+
"@gscdump/sdk": "0.25.14",
|
|
53
|
+
"gscdump": "0.25.14"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@cloudflare/vitest-pool-workers": "^0.16.
|
|
57
|
-
"@cloudflare/workers-types": "^4.
|
|
56
|
+
"@cloudflare/vitest-pool-workers": "^0.16.11",
|
|
57
|
+
"@cloudflare/workers-types": "^4.20260602.1",
|
|
58
58
|
"h3": "^1.15.11",
|
|
59
59
|
"typescript": "^6.0.3",
|
|
60
|
-
"wrangler": "^4.
|
|
60
|
+
"wrangler": "^4.96.0"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "obuild",
|