@gscdump/cli 0.28.3 → 0.30.0
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.mjs +20 -11
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -20,11 +20,12 @@ import { createConsola } from "consola";
|
|
|
20
20
|
import { SearchTypes, and, between, contains, country, date, device, eq, gsc, hour, isQueryError, notRegex, page, query, regex, searchAppearance } from "gscdump/query";
|
|
21
21
|
import { createNodeHarness } from "@gscdump/engine/node";
|
|
22
22
|
import { TABLE_DIMS, transformGscRow } from "@gscdump/engine/ingest";
|
|
23
|
-
import { allTables, inferTable } from "@gscdump/engine/schema";
|
|
23
|
+
import { allTables, dateColumnsFor, inferTable } from "@gscdump/engine/schema";
|
|
24
24
|
import { isAnalysisError } from "@gscdump/analysis/errors";
|
|
25
25
|
import { isEngineError } from "@gscdump/engine/errors";
|
|
26
26
|
import { DuckDBInstance } from "@duckdb/node-api";
|
|
27
27
|
import { sqlEscape } from "@gscdump/engine/sql";
|
|
28
|
+
import { dateReplaceClause } from "@gscdump/engine/sql-fragments";
|
|
28
29
|
import { createEmptyTypesStore, createIndexingMetadataStore, createInspectionStore, createSitemapStore } from "@gscdump/engine/entities";
|
|
29
30
|
import { daysAgo, getDateRange, progressBar } from "gscdump";
|
|
30
31
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
@@ -33,7 +34,7 @@ import { z } from "zod";
|
|
|
33
34
|
import { defaultReportRegistry, dryRunReport, formatReport, runReport } from "@gscdump/analysis/report";
|
|
34
35
|
import { resolveWindow } from "@gscdump/engine/period";
|
|
35
36
|
import { collectSpans, inferLegacyTier } from "@gscdump/engine";
|
|
36
|
-
import { DEFAULT_ROLLUPS, rebuildRollups } from "@gscdump/engine/rollups";
|
|
37
|
+
import { CANONICAL_ROLLUPS, DEFAULT_ROLLUPS, rebuildRollups } from "@gscdump/engine/rollups";
|
|
37
38
|
import { filesystemStats } from "@gscdump/engine/filesystem";
|
|
38
39
|
var __defProp = Object.defineProperty;
|
|
39
40
|
var __exportAll = (all, no_symbols) => {
|
|
@@ -135,7 +136,7 @@ function loadEnvFromCwd() {
|
|
|
135
136
|
}
|
|
136
137
|
return applied;
|
|
137
138
|
}
|
|
138
|
-
var version = "0.
|
|
139
|
+
var version = "0.30.0";
|
|
139
140
|
const ALL_SEARCH_TYPES$1 = Object.values(SearchTypes);
|
|
140
141
|
const VERSION = version;
|
|
141
142
|
function noSubcommandSelected(parent, subNames) {
|
|
@@ -2061,7 +2062,7 @@ const VALID_KEYS = [
|
|
|
2061
2062
|
"defaultDataState",
|
|
2062
2063
|
"serviceAccountPath"
|
|
2063
2064
|
];
|
|
2064
|
-
const NUMERIC_KEYS = new Set(["defaultLimit"]);
|
|
2065
|
+
const NUMERIC_KEYS = /* @__PURE__ */ new Set(["defaultLimit"]);
|
|
2065
2066
|
const configCommand = defineCommand({
|
|
2066
2067
|
meta: {
|
|
2067
2068
|
name: "config",
|
|
@@ -2785,7 +2786,7 @@ async function dumpRowFormat(store, entries, outDir, siteUrl, format) {
|
|
|
2785
2786
|
let files = 0;
|
|
2786
2787
|
let totalRows = 0;
|
|
2787
2788
|
for (const [table, tableEntries] of byTable) {
|
|
2788
|
-
const rows = await readTableRows(tableEntries.map((e) => path.join(store.dataDir, e.objectKey)));
|
|
2789
|
+
const rows = await readTableRows(tableEntries.map((e) => path.join(store.dataDir, e.objectKey)), table);
|
|
2789
2790
|
const ext = format === "csv" ? "csv" : format === "ndjson" ? "ndjson" : "json";
|
|
2790
2791
|
const target = path.join(siteDir, `${table}.${ext}`);
|
|
2791
2792
|
let body;
|
|
@@ -2801,12 +2802,13 @@ async function dumpRowFormat(store, entries, outDir, siteUrl, format) {
|
|
|
2801
2802
|
rows: totalRows
|
|
2802
2803
|
};
|
|
2803
2804
|
}
|
|
2804
|
-
async function readTableRows(filePaths) {
|
|
2805
|
+
async function readTableRows(filePaths, table) {
|
|
2805
2806
|
const instance = await DuckDBInstance.create(":memory:");
|
|
2806
2807
|
const conn = await instance.connect();
|
|
2807
2808
|
try {
|
|
2808
2809
|
const fileList = filePaths.map((p) => `'${sqlEscape(p)}'`).join(", ");
|
|
2809
|
-
|
|
2810
|
+
const replace = dateReplaceClause(dateColumnsFor(table), "string");
|
|
2811
|
+
return (await conn.runAndReadAll(`SELECT * ${replace} FROM read_parquet([${fileList}], union_by_name=true)`)).getRowObjects();
|
|
2810
2812
|
} finally {
|
|
2811
2813
|
conn.closeSync();
|
|
2812
2814
|
instance.closeSync();
|
|
@@ -6204,7 +6206,8 @@ async function exportToDuckDB(opts) {
|
|
|
6204
6206
|
});
|
|
6205
6207
|
if (entries.length === 0) continue;
|
|
6206
6208
|
const fileList = entries.map((e) => path.join(opts.dataDir, e.objectKey)).map((p) => `'${sqlEscape(p)}'`).join(", ");
|
|
6207
|
-
|
|
6209
|
+
const replace = dateReplaceClause(dateColumnsFor(table), "date");
|
|
6210
|
+
await conn.run(`CREATE OR REPLACE TABLE ${table} AS SELECT * ${replace} FROM read_parquet([${fileList}], union_by_name=true)`);
|
|
6208
6211
|
const rows = (await conn.runAndReadAll(`SELECT count(*)::BIGINT AS n FROM ${table}`)).getRowObjects();
|
|
6209
6212
|
const rowCount = Number(rows[0]?.n ?? 0);
|
|
6210
6213
|
tables.push({
|
|
@@ -6356,14 +6359,20 @@ const rollupsCommand = defineCommand({
|
|
|
6356
6359
|
},
|
|
6357
6360
|
args: {
|
|
6358
6361
|
...OUTPUT_ARGS,
|
|
6359
|
-
site: {
|
|
6362
|
+
"site": {
|
|
6360
6363
|
type: "string",
|
|
6361
6364
|
alias: "s",
|
|
6362
6365
|
description: "Restrict to a single site (default: all sites with local data)"
|
|
6366
|
+
},
|
|
6367
|
+
"with-canonical": {
|
|
6368
|
+
type: "boolean",
|
|
6369
|
+
description: "Also build the opt-in canonical-primary rollups (query_canonical_variants, query_canonical_daily)",
|
|
6370
|
+
default: false
|
|
6363
6371
|
}
|
|
6364
6372
|
},
|
|
6365
6373
|
async run({ args }) {
|
|
6366
6374
|
const { json } = applyOutputMode(args);
|
|
6375
|
+
const defs = args["with-canonical"] ? [...DEFAULT_ROLLUPS, ...CANONICAL_ROLLUPS] : DEFAULT_ROLLUPS;
|
|
6367
6376
|
const store = (await createCommandContext({ needsStore: true })).store;
|
|
6368
6377
|
const explicitSiteId = args.site ? store.siteIdFor(String(args.site)) : void 0;
|
|
6369
6378
|
const allSiteIds = /* @__PURE__ */ new Set();
|
|
@@ -6386,7 +6395,7 @@ const rollupsCommand = defineCommand({
|
|
|
6386
6395
|
const summary = [];
|
|
6387
6396
|
let totalBytes = 0;
|
|
6388
6397
|
for (const siteId of allSiteIds) {
|
|
6389
|
-
logger.info(`Rebuilding rollups for [${siteId}] (${
|
|
6398
|
+
logger.info(`Rebuilding rollups for [${siteId}] (${defs.length} rollups)`);
|
|
6390
6399
|
const results = await rebuildRollups({
|
|
6391
6400
|
engine: {
|
|
6392
6401
|
runSQL: (opts) => store.engine.runSQL(opts),
|
|
@@ -6407,7 +6416,7 @@ const rollupsCommand = defineCommand({
|
|
|
6407
6416
|
userId: store.userId,
|
|
6408
6417
|
siteId
|
|
6409
6418
|
},
|
|
6410
|
-
defs
|
|
6419
|
+
defs
|
|
6411
6420
|
});
|
|
6412
6421
|
const site = {
|
|
6413
6422
|
siteId,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gscdump/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.30.0",
|
|
5
5
|
"description": "CLI for Google Search Console - dump, query, and run MCP server",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Harlan Wilton",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"dist"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@clack/prompts": "^1.
|
|
38
|
+
"@clack/prompts": "^1.6.0",
|
|
39
39
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
40
40
|
"citty": "^0.2.2",
|
|
41
41
|
"consola": "^3.4.2",
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
"ofetch": "^1.5.1",
|
|
44
44
|
"open": "^11.0.0",
|
|
45
45
|
"zod": "^4.4.3",
|
|
46
|
-
"@gscdump/
|
|
47
|
-
"
|
|
48
|
-
"@gscdump/engine-gsc-api": "0.
|
|
49
|
-
"gscdump": "0.
|
|
46
|
+
"@gscdump/engine": "0.30.0",
|
|
47
|
+
"gscdump": "0.30.0",
|
|
48
|
+
"@gscdump/engine-gsc-api": "0.30.0",
|
|
49
|
+
"@gscdump/analysis": "0.30.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@duckdb/node-api": "1.5.1-r.2",
|