@gscdump/cloudflare 0.25.6 → 0.25.7
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 +1 -29
- package/package.json +6 -6
|
@@ -156,34 +156,6 @@ function buildMultiSeriesStackedDaily(q) {
|
|
|
156
156
|
sql: `SELECT date, ${col}, ${metricExpr(q.metric)} FROM ${TABLE_PLACEHOLDER} WHERE ${w.clause} GROUP BY date, ${col} ORDER BY date ASC`
|
|
157
157
|
};
|
|
158
158
|
}
|
|
159
|
-
function buildPresetAnalyzer(q) {
|
|
160
|
-
const params = q.params ?? {};
|
|
161
|
-
const minImpressions = Number(params.minImpressions ?? 100);
|
|
162
|
-
const limit = Math.max(1, Math.floor(Number(params.limit ?? 1e3)));
|
|
163
|
-
const w = partitionWhere(q);
|
|
164
|
-
const wp = [...w.params];
|
|
165
|
-
let having;
|
|
166
|
-
switch (q.presetId) {
|
|
167
|
-
case "striking-distance":
|
|
168
|
-
having = `HAVING SUM(impressions) >= ? AND (SUM(sum_position) / NULLIF(SUM(impressions), 0)) BETWEEN ? AND ?`;
|
|
169
|
-
wp.push(minImpressions, Number(params.minPosition ?? 11), Number(params.maxPosition ?? 20));
|
|
170
|
-
break;
|
|
171
|
-
case "opportunity":
|
|
172
|
-
having = `HAVING SUM(impressions) >= ? AND SUM(clicks) = 0`;
|
|
173
|
-
wp.push(minImpressions);
|
|
174
|
-
break;
|
|
175
|
-
case "zero-click":
|
|
176
|
-
having = `HAVING SUM(impressions) >= ? AND SUM(clicks) = 0`;
|
|
177
|
-
wp.push(minImpressions);
|
|
178
|
-
break;
|
|
179
|
-
default: throw new Error(`preset-analyzer: preset '${q.presetId}' is not R2-SQL-safe — window-function presets must be sent as archetype 'arbitrary-sql'`);
|
|
180
|
-
}
|
|
181
|
-
return {
|
|
182
|
-
table: "page_queries",
|
|
183
|
-
params: wp,
|
|
184
|
-
sql: `SELECT url, query, SUM(clicks) AS clicks, SUM(impressions) AS impressions, SUM(clicks) / NULLIF(SUM(impressions), 0) AS ctr, SUM(sum_position) / NULLIF(SUM(impressions), 0) AS position FROM ${TABLE_PLACEHOLDER} WHERE ${w.clause} GROUP BY url, query ${having} ORDER BY SUM(impressions) DESC LIMIT ${limit}`
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
159
|
function buildTwoDimensionDetail(q) {
|
|
188
160
|
const w = partitionWhere(q);
|
|
189
161
|
const params = [...w.params];
|
|
@@ -213,7 +185,6 @@ function buildArchetypeSql(query) {
|
|
|
213
185
|
case "top-n-breakdown": return buildTopNBreakdown(query);
|
|
214
186
|
case "single-row-lookup": return buildSingleRowLookup(query);
|
|
215
187
|
case "multi-series-stacked-daily": return buildMultiSeriesStackedDaily(query);
|
|
216
|
-
case "preset-analyzer": return buildPresetAnalyzer(query);
|
|
217
188
|
case "two-dimension-detail": return buildTwoDimensionDetail(query);
|
|
218
189
|
case "arbitrary-sql": throw new Error("buildArchetypeSql: arbitrary-sql carries caller SQL — the DuckDB executor runs it verbatim");
|
|
219
190
|
case "aux-cloud-only": throw new Error("buildArchetypeSql: aux-cloud-only is not an Iceberg query");
|
|
@@ -227,6 +198,7 @@ function resolveServerTailEngine(query) {
|
|
|
227
198
|
if (cls === "cloud-only") throw new ServerTailRoutingError(`archetype '${query.archetype}' is cloud-only — not a server-tail query`);
|
|
228
199
|
if (cls === "duckdb") return "duckdb";
|
|
229
200
|
if (query.archetype === "top-n-breakdown" && query.offset && query.offset > 0) return "duckdb";
|
|
201
|
+
if (query.facets && query.facets.length > 0) return "duckdb";
|
|
230
202
|
return "r2-sql";
|
|
231
203
|
}
|
|
232
204
|
function sourceFor(engine) {
|
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.7",
|
|
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,11 +46,11 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@uwdata/flechette": "^2.5.0",
|
|
48
48
|
"aws4fetch": "^1.0.20",
|
|
49
|
-
"@gscdump/
|
|
50
|
-
"@gscdump/
|
|
51
|
-
"@gscdump/engine-sqlite": "0.25.
|
|
52
|
-
"gscdump": "0.25.
|
|
53
|
-
"
|
|
49
|
+
"@gscdump/contracts": "0.25.7",
|
|
50
|
+
"@gscdump/engine": "0.25.7",
|
|
51
|
+
"@gscdump/engine-sqlite": "0.25.7",
|
|
52
|
+
"@gscdump/sdk": "0.25.7",
|
|
53
|
+
"gscdump": "0.25.7"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@cloudflare/vitest-pool-workers": "^0.16.10",
|