@gscdump/cli 1.4.0 → 1.4.1

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.
Files changed (54) hide show
  1. package/dist/{_chunks/analysis-local.mjs → analysis-local.mjs} +4 -3
  2. package/dist/{_chunks/auth.mjs → auth.mjs} +2 -2
  3. package/dist/cli.d.mts +1 -19
  4. package/dist/cli.mjs +25 -25
  5. package/dist/{_chunks → commands}/analyze.mjs +3 -3
  6. package/dist/{_chunks/auth2.mjs → commands/auth.mjs} +4 -4
  7. package/dist/commands/compact.mjs +128 -0
  8. package/dist/{_chunks/config2.mjs → commands/config.mjs} +4 -4
  9. package/dist/{_chunks → commands}/doctor.mjs +8 -7
  10. package/dist/{_chunks → commands}/dump.mjs +5 -4
  11. package/dist/{_chunks → commands}/entities.mjs +2 -2
  12. package/dist/commands/export.mjs +76 -0
  13. package/dist/commands/gc.mjs +74 -0
  14. package/dist/{_chunks → commands}/indexing.mjs +3 -3
  15. package/dist/{_chunks → commands}/init.mjs +5 -5
  16. package/dist/{_chunks → commands}/inspect.mjs +3 -3
  17. package/dist/commands/mcp.mjs +57 -0
  18. package/dist/{_chunks → commands}/profile.mjs +7 -17
  19. package/dist/{_chunks → commands}/query.mjs +5 -4
  20. package/dist/{_chunks → commands}/report.mjs +2 -2
  21. package/dist/commands/rollups.mjs +134 -0
  22. package/dist/{_chunks → commands}/sitemaps.mjs +3 -3
  23. package/dist/{_chunks → commands}/sites.mjs +3 -3
  24. package/dist/commands/stats.mjs +118 -0
  25. package/dist/commands/store-purge.mjs +93 -0
  26. package/dist/commands/store.mjs +40 -0
  27. package/dist/{_chunks → commands}/sync.mjs +3 -2
  28. package/dist/config.mjs +43 -0
  29. package/dist/{_chunks/context.mjs → context.mjs} +3 -9
  30. package/dist/{_chunks/env-file.mjs → env-file.mjs} +3 -3
  31. package/dist/{_chunks/environment.mjs → environment.mjs} +1 -1
  32. package/dist/index.d.mts +2 -0
  33. package/dist/index.mjs +2 -0
  34. package/dist/local-store.mjs +7 -0
  35. package/dist/mcp/errors.mjs +85 -0
  36. package/dist/mcp/handlers/analytics.mjs +1 -0
  37. package/dist/mcp/handlers/diagnostics.mjs +134 -0
  38. package/dist/mcp/handlers/index.mjs +7 -0
  39. package/dist/mcp/handlers/indexing.mjs +27 -0
  40. package/dist/mcp/handlers/query.mjs +5 -0
  41. package/dist/mcp/handlers/reports.mjs +72 -0
  42. package/dist/mcp/handlers/sites.mjs +8 -0
  43. package/dist/mcp/server/index.mjs +417 -0
  44. package/dist/mcp/types.mjs +86 -0
  45. package/dist/package.mjs +2 -0
  46. package/dist/runtime.d.mts +20 -0
  47. package/dist/runtime.mjs +38 -0
  48. package/dist/{_chunks/utils.mjs → utils.mjs} +4 -4
  49. package/package.json +8 -8
  50. package/dist/_chunks/config.mjs +0 -93
  51. package/dist/_chunks/mcp.mjs +0 -867
  52. package/dist/_chunks/store.mjs +0 -628
  53. /package/dist/{_chunks/error-handler.mjs → error-handler.mjs} +0 -0
  54. /package/dist/{_chunks/native-duckdb.mjs → native-duckdb.mjs} +0 -0
@@ -0,0 +1,86 @@
1
+ import { z } from "zod";
2
+ const periodSchema = z.object({
3
+ start: z.string().describe("Start date (YYYY-MM-DD)"),
4
+ end: z.string().describe("End date (YYYY-MM-DD)")
5
+ }).describe("Date range for the query");
6
+ const siteUrlSchema = z.string().describe("GSC property URL (e.g., sc-domain:example.com or https://example.com/)");
7
+ const queryOptionsSchema = z.object({
8
+ type: z.enum([
9
+ "web",
10
+ "image",
11
+ "video",
12
+ "news",
13
+ "discover",
14
+ "googleNews"
15
+ ]).optional().describe("Data type"),
16
+ dataState: z.enum(["final", "all"]).optional().describe("Data state: final (settled) or all (includes fresh)"),
17
+ aggregationType: z.enum(["byPage", "byProperty"]).optional().describe("Aggregation: byPage or byProperty")
18
+ }).optional();
19
+ const listSitesInput = z.object({});
20
+ const listSitemapsInput = z.object({ siteUrl: siteUrlSchema });
21
+ z.object({
22
+ siteUrl: siteUrlSchema,
23
+ period: periodSchema,
24
+ comparePrevious: z.boolean().optional().describe("Include previous period comparison"),
25
+ options: queryOptionsSchema
26
+ });
27
+ z.object({
28
+ siteUrl: siteUrlSchema,
29
+ period: periodSchema,
30
+ url: z.string().describe("Page URL to fetch details for")
31
+ });
32
+ z.object({
33
+ siteUrl: siteUrlSchema,
34
+ period: periodSchema,
35
+ keyword: z.string().describe("Keyword to fetch details for")
36
+ });
37
+ const inspectUrlInput = z.object({
38
+ siteUrl: siteUrlSchema,
39
+ inspectionUrl: z.string().describe("URL to inspect")
40
+ });
41
+ const requestIndexingInput = z.object({
42
+ url: z.string().describe("URL to request indexing for"),
43
+ type: z.enum(["URL_UPDATED", "URL_DELETED"]).optional().describe("Notification type")
44
+ });
45
+ const getIndexingStatusInput = z.object({ url: z.string().describe("URL to get indexing status for") });
46
+ z.object({
47
+ siteUrl: siteUrlSchema,
48
+ period: periodSchema,
49
+ dimensions: z.array(z.enum([
50
+ "date",
51
+ "query",
52
+ "page",
53
+ "country",
54
+ "device",
55
+ "searchAppearance"
56
+ ])).describe("Dimensions to group by"),
57
+ rowLimit: z.number().optional().describe("Max rows (default 25000)"),
58
+ options: queryOptionsSchema
59
+ });
60
+ const sitemapInput = z.object({
61
+ siteUrl: siteUrlSchema,
62
+ feedpath: z.string().describe("Sitemap URL (e.g., https://example.com/sitemap.xml)")
63
+ });
64
+ const batchRequestIndexingInput = z.object({
65
+ urls: z.array(z.string()).describe("URLs to request indexing for"),
66
+ type: z.enum(["URL_UPDATED", "URL_DELETED"]).optional().describe("Notification type"),
67
+ delayMs: z.number().optional().describe("Delay between requests in ms (default 100)")
68
+ });
69
+ const batchInspectUrlsInput = z.object({
70
+ siteUrl: siteUrlSchema,
71
+ urls: z.array(z.string()).describe("URLs to inspect"),
72
+ delayMs: z.number().optional().describe("Delay between requests in ms (default 200)")
73
+ });
74
+ const listReportsInput = z.object({});
75
+ const runReportInput = z.object({
76
+ siteUrl: siteUrlSchema,
77
+ id: z.string().describe("Report id (e.g. health, movers, opportunities, risks). See list-reports."),
78
+ period: z.string().optional().describe("Window: 7d|28d|30d|90d|180d|365d|mtd|ytd|custom (default per report)."),
79
+ comparison: z.string().optional().describe("Comparison: none|prev-period|yoy (default per report)."),
80
+ start: z.string().optional().describe("Custom window start (YYYY-MM-DD); requires period=custom."),
81
+ end: z.string().optional().describe("Custom window end (YYYY-MM-DD); requires period=custom."),
82
+ prevStart: z.string().optional().describe("Override comparison-window start."),
83
+ prevEnd: z.string().optional().describe("Override comparison-window end."),
84
+ maxFindings: z.number().optional().describe("Cap findings per section (per-report default ~5).")
85
+ });
86
+ export { batchInspectUrlsInput, batchRequestIndexingInput, getIndexingStatusInput, inspectUrlInput, listReportsInput, listSitemapsInput, listSitesInput, periodSchema, queryOptionsSchema, requestIndexingInput, runReportInput, siteUrlSchema, sitemapInput };
@@ -0,0 +1,2 @@
1
+ var version = "1.4.1";
2
+ export { version };
@@ -0,0 +1,20 @@
1
+ import { ConsolaInstance } from "consola";
2
+ type CliEnvironmentSource = Record<string, string | undefined>;
3
+ interface CliRuntime {
4
+ activeProfileOverride: string | null;
5
+ colorEnabled: boolean;
6
+ configDir: string;
7
+ configDirOverridden: boolean;
8
+ environment: CliEnvironmentSource;
9
+ logger: ConsolaInstance;
10
+ quiet: boolean;
11
+ rawArgs: string[];
12
+ }
13
+ interface CreateCliRuntimeOptions {
14
+ configDir?: string;
15
+ environment?: CliEnvironmentSource;
16
+ rawArgs?: readonly string[];
17
+ stderr?: NodeJS.WriteStream;
18
+ }
19
+ declare function createCliRuntime(opts?: CreateCliRuntimeOptions): CliRuntime;
20
+ export { CliEnvironmentSource, CliRuntime, CreateCliRuntimeOptions, createCliRuntime };
@@ -0,0 +1,38 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import process from "node:process";
5
+ import { createConsola } from "consola";
6
+ let runtimeStorage;
7
+ let fallbackRuntime;
8
+ function getRuntimeStorage() {
9
+ runtimeStorage ??= new AsyncLocalStorage();
10
+ return runtimeStorage;
11
+ }
12
+ function createCliRuntime(opts = {}) {
13
+ const stderr = opts.stderr ?? process.stderr;
14
+ const baseLogger = createConsola({
15
+ stdout: stderr,
16
+ stderr
17
+ });
18
+ return {
19
+ activeProfileOverride: null,
20
+ colorEnabled: true,
21
+ configDir: opts.configDir ?? path.join(os.homedir(), ".config", "gscdump"),
22
+ configDirOverridden: false,
23
+ environment: opts.environment ?? process.env,
24
+ logger: baseLogger.withTag("gscdump"),
25
+ quiet: false,
26
+ rawArgs: [...opts.rawArgs ?? process.argv.slice(2)]
27
+ };
28
+ }
29
+ function useCliRuntime() {
30
+ const active = getRuntimeStorage().getStore();
31
+ if (active) return active;
32
+ fallbackRuntime ??= createCliRuntime();
33
+ return fallbackRuntime;
34
+ }
35
+ function runWithCliRuntime(runtime, run) {
36
+ return getRuntimeStorage().run(runtime, run);
37
+ }
38
+ export { createCliRuntime, runWithCliRuntime, useCliRuntime };
@@ -1,10 +1,10 @@
1
- import { useCliRuntime } from "./config.mjs";
1
+ import { useCliRuntime } from "./runtime.mjs";
2
+ import { version } from "./package.mjs";
3
+ import os from "node:os";
2
4
  import process from "node:process";
3
5
  import fs from "node:fs/promises";
4
- import os from "node:os";
5
6
  import { Buffer } from "node:buffer";
6
7
  import { SearchTypes } from "gscdump/query";
7
- var version = "1.4.0";
8
8
  const ALL_SEARCH_TYPES = Object.values(SearchTypes);
9
9
  const VERSION = version;
10
10
  function noSubcommandSelected(parent, subNames) {
@@ -212,4 +212,4 @@ function exportToCSV(output) {
212
212
  ])}`);
213
213
  return sections.join("\n\n");
214
214
  }
215
- export { ALL_SEARCH_TYPES, OUTPUT_ARGS, VERSION, applyOutputMode, clearLine, configureColor, displayPath, exportToCSV, formatAge, logger, noSubcommandSelected, parseSearchType, progressBar, readUrlList, runWithConcurrency, showSplash, toCSV, withConfiguredOutput };
215
+ export { ALL_SEARCH_TYPES, OUTPUT_ARGS, VERSION, applyOutputMode, clearLine, color, configureColor, cyan, dim, displayPath, exportToCSV, formatAge, isColorEnabled, logger, noSubcommandSelected, parseSearchType, progressBar, readUrlList, runWithConcurrency, setNoColor, setQuiet, showSplash, toCSV, withConfiguredOutput };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gscdump/cli",
3
3
  "type": "module",
4
- "version": "1.4.0",
4
+ "version": "1.4.1",
5
5
  "description": "CLI for Google Search Console - dump, query, and run MCP server",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",
@@ -31,9 +31,9 @@
31
31
  "sideEffects": false,
32
32
  "exports": {
33
33
  ".": {
34
- "types": "./dist/cli.d.mts",
35
- "import": "./dist/cli.mjs",
36
- "default": "./dist/cli.mjs"
34
+ "types": "./dist/index.d.mts",
35
+ "import": "./dist/index.mjs",
36
+ "default": "./dist/index.mjs"
37
37
  }
38
38
  },
39
39
  "bin": {
@@ -56,10 +56,10 @@
56
56
  "ofetch": "^1.5.1",
57
57
  "open": "^11.0.0",
58
58
  "zod": "^4.4.3",
59
- "@gscdump/analysis": "^1.4.0",
60
- "@gscdump/engine": "^1.4.0",
61
- "@gscdump/engine-gsc-api": "^1.4.0",
62
- "gscdump": "^1.4.0"
59
+ "@gscdump/analysis": "^1.4.1",
60
+ "@gscdump/engine": "^1.4.1",
61
+ "@gscdump/engine-gsc-api": "^1.4.1",
62
+ "gscdump": "^1.4.1"
63
63
  },
64
64
  "devDependencies": {
65
65
  "vitest": "^4.1.10"
@@ -1,93 +0,0 @@
1
- import process from "node:process";
2
- import fs from "node:fs/promises";
3
- import os from "node:os";
4
- import path from "node:path";
5
- import { AsyncLocalStorage } from "node:async_hooks";
6
- import { createConsola } from "consola";
7
- var __defProp = Object.defineProperty;
8
- var __exportAll = (all, no_symbols) => {
9
- let target = {};
10
- for (var name in all) __defProp(target, name, {
11
- get: all[name],
12
- enumerable: true
13
- });
14
- if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
15
- return target;
16
- };
17
- const runtimeStorage = new AsyncLocalStorage();
18
- let fallbackRuntime;
19
- function createCliRuntime(opts = {}) {
20
- const stderr = opts.stderr ?? process.stderr;
21
- const baseLogger = createConsola({
22
- stdout: stderr,
23
- stderr
24
- });
25
- return {
26
- activeProfileOverride: null,
27
- colorEnabled: true,
28
- configDir: opts.configDir ?? path.join(os.homedir(), ".config", "gscdump"),
29
- configDirOverridden: false,
30
- environment: opts.environment ?? process.env,
31
- logger: baseLogger.withTag("gscdump"),
32
- quiet: false,
33
- rawArgs: [...opts.rawArgs ?? process.argv.slice(2)]
34
- };
35
- }
36
- function useCliRuntime() {
37
- const active = runtimeStorage.getStore();
38
- if (active) return active;
39
- fallbackRuntime ??= createCliRuntime();
40
- return fallbackRuntime;
41
- }
42
- function runWithCliRuntime(runtime, run) {
43
- return runtimeStorage.run(runtime, run);
44
- }
45
- var config_exports = /* @__PURE__ */ __exportAll({
46
- defaultDataDir: () => defaultDataDir,
47
- getConfigDir: () => getConfigDir,
48
- getConfigPath: () => getConfigPath,
49
- loadConfig: () => loadConfig,
50
- loadResolvedConfig: () => loadResolvedConfig,
51
- resolveDataDir: () => resolveDataDir,
52
- saveConfig: () => saveConfig,
53
- setConfigDir: () => setConfigDir
54
- });
55
- function setConfigDir(dir) {
56
- useCliRuntime().configDir = dir;
57
- }
58
- function getConfigDir() {
59
- return useCliRuntime().configDir;
60
- }
61
- function defaultDataDir() {
62
- return path.join(os.homedir(), ".gscdump", "data");
63
- }
64
- function resolveDataDir(config) {
65
- return expandTilde(config.dataDir ?? defaultDataDir());
66
- }
67
- function expandTilde(p) {
68
- if (p === "~") return os.homedir();
69
- if (p.startsWith("~/")) return path.join(os.homedir(), p.slice(2));
70
- return p;
71
- }
72
- async function loadConfig() {
73
- return fs.readFile(path.join(getConfigDir(), "config.json"), "utf-8").then((data) => JSON.parse(data)).catch(() => ({}));
74
- }
75
- async function loadResolvedConfig() {
76
- const config = await loadConfig();
77
- return {
78
- config,
79
- dataDir: resolveDataDir(config)
80
- };
81
- }
82
- async function saveConfig(config) {
83
- const configDir = getConfigDir();
84
- await fs.mkdir(configDir, {
85
- recursive: true,
86
- mode: 448
87
- });
88
- await fs.writeFile(path.join(configDir, "config.json"), JSON.stringify(config, null, 2), { mode: 384 });
89
- }
90
- function getConfigPath() {
91
- return path.join(getConfigDir(), "config.json");
92
- }
93
- export { __exportAll, config_exports, createCliRuntime, defaultDataDir, getConfigDir, getConfigPath, loadConfig, loadResolvedConfig, runWithCliRuntime, saveConfig, setConfigDir, useCliRuntime };