@koda-sl/baker-cli 0.15.0 → 0.18.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.
Files changed (85) hide show
  1. package/README.md +469 -5
  2. package/dist/cli.js +5 -1
  3. package/dist/cli.js.map +1 -1
  4. package/dist/client.d.ts +3 -1
  5. package/dist/client.d.ts.map +1 -1
  6. package/dist/client.js +4 -3
  7. package/dist/client.js.map +1 -1
  8. package/dist/commands/ads/google/accounts.d.ts.map +1 -1
  9. package/dist/commands/ads/google/accounts.js +7 -4
  10. package/dist/commands/ads/google/accounts.js.map +1 -1
  11. package/dist/commands/ads/google/index.d.ts.map +1 -1
  12. package/dist/commands/ads/google/index.js +5 -1
  13. package/dist/commands/ads/google/index.js.map +1 -1
  14. package/dist/commands/ads/google/library/index.d.ts +2 -0
  15. package/dist/commands/ads/google/library/index.d.ts.map +1 -0
  16. package/dist/commands/ads/google/library/index.js +271 -0
  17. package/dist/commands/ads/google/library/index.js.map +1 -0
  18. package/dist/commands/ads/output.d.ts +1 -0
  19. package/dist/commands/ads/output.d.ts.map +1 -1
  20. package/dist/commands/ads/output.js +18 -15
  21. package/dist/commands/ads/output.js.map +1 -1
  22. package/dist/commands/ga4/audit.d.ts +13 -0
  23. package/dist/commands/ga4/audit.d.ts.map +1 -0
  24. package/dist/commands/ga4/audit.js +67 -0
  25. package/dist/commands/ga4/audit.js.map +1 -0
  26. package/dist/commands/ga4/index.d.ts +2 -0
  27. package/dist/commands/ga4/index.d.ts.map +1 -0
  28. package/dist/commands/ga4/index.js +26 -0
  29. package/dist/commands/ga4/index.js.map +1 -0
  30. package/dist/commands/ga4/presets.d.ts +8 -0
  31. package/dist/commands/ga4/presets.d.ts.map +1 -0
  32. package/dist/commands/ga4/presets.js +33 -0
  33. package/dist/commands/ga4/presets.js.map +1 -0
  34. package/dist/commands/ga4/properties.d.ts +14 -0
  35. package/dist/commands/ga4/properties.d.ts.map +1 -0
  36. package/dist/commands/ga4/properties.js +61 -0
  37. package/dist/commands/ga4/properties.js.map +1 -0
  38. package/dist/commands/ga4/query.d.ts +69 -0
  39. package/dist/commands/ga4/query.d.ts.map +1 -0
  40. package/dist/commands/ga4/query.js +184 -0
  41. package/dist/commands/ga4/query.js.map +1 -0
  42. package/dist/commands/ga4/resolve.d.ts +2 -0
  43. package/dist/commands/ga4/resolve.d.ts.map +1 -0
  44. package/dist/commands/ga4/resolve.js +57 -0
  45. package/dist/commands/ga4/resolve.js.map +1 -0
  46. package/dist/commands/gsc/index.d.ts +2 -0
  47. package/dist/commands/gsc/index.d.ts.map +1 -0
  48. package/dist/commands/gsc/index.js +26 -0
  49. package/dist/commands/gsc/index.js.map +1 -0
  50. package/dist/commands/gsc/presets.d.ts +9 -0
  51. package/dist/commands/gsc/presets.d.ts.map +1 -0
  52. package/dist/commands/gsc/presets.js +34 -0
  53. package/dist/commands/gsc/presets.js.map +1 -0
  54. package/dist/commands/gsc/query.d.ts +79 -0
  55. package/dist/commands/gsc/query.d.ts.map +1 -0
  56. package/dist/commands/gsc/query.js +196 -0
  57. package/dist/commands/gsc/query.js.map +1 -0
  58. package/dist/commands/gsc/resolve.d.ts +2 -0
  59. package/dist/commands/gsc/resolve.d.ts.map +1 -0
  60. package/dist/commands/gsc/resolve.js +57 -0
  61. package/dist/commands/gsc/resolve.js.map +1 -0
  62. package/dist/commands/gsc/sitemaps.d.ts +19 -0
  63. package/dist/commands/gsc/sitemaps.d.ts.map +1 -0
  64. package/dist/commands/gsc/sitemaps.js +65 -0
  65. package/dist/commands/gsc/sitemaps.js.map +1 -0
  66. package/dist/commands/gsc/sites.d.ts +14 -0
  67. package/dist/commands/gsc/sites.d.ts.map +1 -0
  68. package/dist/commands/gsc/sites.js +61 -0
  69. package/dist/commands/gsc/sites.js.map +1 -0
  70. package/dist/commands/research/index.d.ts.map +1 -1
  71. package/dist/commands/research/index.js +7 -5
  72. package/dist/commands/research/index.js.map +1 -1
  73. package/dist/commands/research/web.d.ts +19 -0
  74. package/dist/commands/research/web.d.ts.map +1 -0
  75. package/dist/commands/research/web.js +112 -0
  76. package/dist/commands/research/web.js.map +1 -0
  77. package/dist/env.d.ts +2 -0
  78. package/dist/env.d.ts.map +1 -1
  79. package/dist/env.js +2 -0
  80. package/dist/env.js.map +1 -1
  81. package/dist/error-handler.d.ts +8 -0
  82. package/dist/error-handler.d.ts.map +1 -0
  83. package/dist/error-handler.js +37 -0
  84. package/dist/error-handler.js.map +1 -0
  85. package/package.json +1 -1
@@ -0,0 +1,61 @@
1
+ import { defineCommand } from "citty";
2
+ import { ApiError, apiGet } from "../../client.js";
3
+ import { registerSchema } from "../../schemas.js";
4
+ import { cacheGet, cacheSet } from "../ads/cache.js";
5
+ import { writeAdsOutput, writeJsonEnvelope } from "../ads/output.js";
6
+ registerSchema({
7
+ command: "ga4.properties",
8
+ description: "List all accessible GA4 properties. Returns property IDs needed for query and audit commands. Run this first to find property IDs.",
9
+ args: {
10
+ "no-cache": { type: "boolean", description: "Skip cache, hit API directly", required: false },
11
+ },
12
+ });
13
+ import { handleConnectionError } from "../../error-handler.js";
14
+ export const propertiesCommand = defineCommand({
15
+ meta: {
16
+ name: "properties",
17
+ description: `List accessible GA4 properties.
18
+
19
+ Examples:
20
+ baker ga4 properties`,
21
+ },
22
+ args: {
23
+ "no-cache": { type: "boolean", description: "Skip cache", required: false },
24
+ output: { type: "string", description: "Format: json|csv|md", required: false, default: "json" },
25
+ },
26
+ run: async ({ args }) => {
27
+ const useCache = !args["no-cache"];
28
+ if (useCache) {
29
+ const cached = cacheGet("ga4-properties", "list");
30
+ if (cached) {
31
+ writeJsonEnvelope({ ok: true, data: cached.data, cached: true });
32
+ return;
33
+ }
34
+ }
35
+ try {
36
+ const params = !useCache ? { "skip-cache": "true" } : undefined;
37
+ const data = await apiGet("/api/ga4/properties", params);
38
+ if (useCache) {
39
+ cacheSet("ga4-properties", "list", data, 60 * 60 * 1000);
40
+ }
41
+ const format = args.output || "json";
42
+ if (format !== "json") {
43
+ writeAdsOutput(data, format);
44
+ return;
45
+ }
46
+ writeJsonEnvelope({ ok: true, data });
47
+ }
48
+ catch (err) {
49
+ if (err instanceof ApiError) {
50
+ if (err.code === "UNAUTHORIZED" || err.code === "NOT_FOUND") {
51
+ handleConnectionError("ga4", err.message);
52
+ }
53
+ writeJsonEnvelope({ ok: false, error: { code: err.code, message: err.message } });
54
+ process.exit(1);
55
+ }
56
+ writeJsonEnvelope({ ok: false, error: { code: "NETWORK_ERROR", message: "Unexpected error" } });
57
+ process.exit(1);
58
+ }
59
+ },
60
+ });
61
+ //# sourceMappingURL=properties.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"properties.js","sourceRoot":"","sources":["../../../src/commands/ga4/properties.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErE,cAAc,CAAC;IACb,OAAO,EAAE,gBAAgB;IACzB,WAAW,EACT,oIAAoI;IACtI,IAAI,EAAE;QACJ,UAAU,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,8BAA8B,EAAE,QAAQ,EAAE,KAAK,EAAE;KAC9F;CACF,CAAC,CAAC;AAOH,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAC;IAC7C,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE;;;uBAGM;KACpB;IACD,IAAI,EAAE;QACJ,UAAU,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,YA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,GAAG,YAAY,QAAQ,EAAE,CAAC;gBAC5B,IAAI,GAAG,CAAC,IAAI,KAAK,cAAc,IAAI,GAAG,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;oBAC5D,qBAAqB,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;gBAC5C,CAAC;gBACD,iBAAiB,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;gBAClF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC;YACD,iBAAiB,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,kBAAkB,EAAE,EAAE,CAAC,CAAC;YAChG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,69 @@
1
+ export declare const queryCommand: import("citty").CommandDef<{
2
+ readonly "property-id": {
3
+ readonly type: "string";
4
+ readonly description: "GA4 property ID";
5
+ readonly required: false;
6
+ };
7
+ readonly preset: {
8
+ readonly type: "string";
9
+ readonly description: "Named preset";
10
+ readonly required: false;
11
+ };
12
+ readonly dimensions: {
13
+ readonly type: "string";
14
+ readonly description: "Comma-separated dimensions";
15
+ readonly required: false;
16
+ };
17
+ readonly metrics: {
18
+ readonly type: "string";
19
+ readonly description: "Comma-separated metrics";
20
+ readonly required: false;
21
+ };
22
+ readonly days: {
23
+ readonly type: "string";
24
+ readonly description: "Lookback days (default: 30)";
25
+ readonly required: false;
26
+ };
27
+ readonly "start-date": {
28
+ readonly type: "string";
29
+ readonly description: "Start date override";
30
+ readonly required: false;
31
+ };
32
+ readonly "end-date": {
33
+ readonly type: "string";
34
+ readonly description: "End date override";
35
+ readonly required: false;
36
+ };
37
+ readonly limit: {
38
+ readonly type: "string";
39
+ readonly description: "Max rows (default: 1000)";
40
+ readonly required: false;
41
+ };
42
+ readonly "list-presets": {
43
+ readonly type: "boolean";
44
+ readonly description: "List presets";
45
+ readonly required: false;
46
+ };
47
+ readonly out: {
48
+ readonly type: "string";
49
+ readonly description: "Output file path";
50
+ readonly required: false;
51
+ };
52
+ readonly append: {
53
+ readonly type: "boolean";
54
+ readonly description: "Append to file";
55
+ readonly required: false;
56
+ };
57
+ readonly output: {
58
+ readonly type: "string";
59
+ readonly description: "Format: json|csv|jsonl|md";
60
+ readonly required: false;
61
+ readonly default: "json";
62
+ };
63
+ readonly "no-cache": {
64
+ readonly type: "boolean";
65
+ readonly description: "Skip cache";
66
+ readonly required: false;
67
+ };
68
+ }>;
69
+ //# sourceMappingURL=query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/commands/ga4/query.ts"],"names":[],"mappings":"AAgIA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwEvB,CAAC"}
@@ -0,0 +1,184 @@
1
+ import { appendFileSync, existsSync, readFileSync, writeFileSync } from "node:fs";
2
+ import { resolve } from "node:path";
3
+ import { defineCommand } from "citty";
4
+ import { ApiError, apiPost } from "../../client.js";
5
+ import { registerSchema } from "../../schemas.js";
6
+ import { buildQueryCacheKey, cacheGet, cacheSet, getQueryTtl } from "../ads/cache.js";
7
+ import { toCsvRow, writeAdsOutput, writeJsonEnvelope } from "../ads/output.js";
8
+ import { GA4_PRESETS } from "./presets.js";
9
+ import { resolvePropertyId } from "./resolve.js";
10
+ registerSchema({
11
+ command: "ga4.query",
12
+ description: "Run GA4 Data API reports. Use --preset for playbook-aligned queries (primary usage) or --dimensions/--metrics for free-form queries.",
13
+ args: {
14
+ "property-id": { type: "string", description: "GA4 property ID (auto-resolved if not provided)", required: false },
15
+ preset: {
16
+ type: "string",
17
+ description: "Named preset (tracking-health, lp-performance, traffic-quality, funnel-leakage, first-touch, traffic-overview)",
18
+ required: false,
19
+ },
20
+ dimensions: { type: "string", description: "Comma-separated dimension names (escape hatch)", required: false },
21
+ metrics: { type: "string", description: "Comma-separated metric names (escape hatch)", required: false },
22
+ days: { type: "string", description: "Lookback window in days (default: 30)", required: false },
23
+ "start-date": {
24
+ type: "string",
25
+ description: "Explicit start date (YYYY-MM-DD or GA4 relative like '30daysAgo')",
26
+ required: false,
27
+ },
28
+ "end-date": { type: "string", description: "Explicit end date (YYYY-MM-DD or 'yesterday')", required: false },
29
+ limit: { type: "string", description: "Max rows (default: 1000)", required: false },
30
+ "list-presets": { type: "boolean", description: "List available presets", required: false },
31
+ out: { type: "string", description: "Write data to file (.csv, .jsonl, .json)", required: false },
32
+ append: { type: "boolean", description: "Append to existing file", required: false },
33
+ output: { type: "string", description: "Format: json|csv|jsonl|md", required: false, default: "json" },
34
+ "no-cache": { type: "boolean", description: "Skip cache", required: false },
35
+ },
36
+ });
37
+ function extractFields(rows) {
38
+ const first = rows[0];
39
+ return first ? Object.keys(first) : [];
40
+ }
41
+ function writeRowsToFile(filePath, rows, append) {
42
+ const fields = extractFields(rows);
43
+ const ext = filePath.split(".").pop()?.toLowerCase();
44
+ if (ext === "csv") {
45
+ if (!append || !existsSync(filePath)) {
46
+ writeFileSync(filePath, `${toCsvRow(fields)}\n`, "utf-8");
47
+ }
48
+ const csvRows = rows.map((row) => toCsvRow(fields.map((f) => String(row[f] ?? ""))));
49
+ appendFileSync(filePath, `${csvRows.join("\n")}\n`, "utf-8");
50
+ }
51
+ else if (ext === "jsonl") {
52
+ const lines = rows.map((row) => JSON.stringify(row));
53
+ const content = `${lines.join("\n")}\n`;
54
+ if (append && existsSync(filePath)) {
55
+ appendFileSync(filePath, content, "utf-8");
56
+ }
57
+ else {
58
+ writeFileSync(filePath, content, "utf-8");
59
+ }
60
+ }
61
+ else if (append && existsSync(filePath)) {
62
+ const existing = JSON.parse(readFileSync(filePath, "utf-8"));
63
+ writeFileSync(filePath, JSON.stringify([...existing, ...rows], null, 2), "utf-8");
64
+ }
65
+ else {
66
+ writeFileSync(filePath, JSON.stringify(rows, null, 2), "utf-8");
67
+ }
68
+ }
69
+ function outputRows(rows, args, response, cached) {
70
+ if (args.out) {
71
+ const filePath = resolve(args.out);
72
+ writeRowsToFile(filePath, rows, !!args.append);
73
+ writeJsonEnvelope({ ok: true, file: filePath, rows: rows.length, ...(cached && { cached: true }) });
74
+ return;
75
+ }
76
+ const format = args.output || "json";
77
+ if (format !== "json") {
78
+ writeAdsOutput(rows, format);
79
+ return;
80
+ }
81
+ writeJsonEnvelope({ ...response, ...(cached && { cached: true }) });
82
+ }
83
+ function buildRequestBody(args, propertyId, useCache) {
84
+ const body = { propertyId };
85
+ if (args.preset)
86
+ body.preset = args.preset;
87
+ if (args.dimensions)
88
+ body.dimensions = args.dimensions.split(",").map((d) => d.trim());
89
+ if (args.metrics)
90
+ body.metrics = args.metrics.split(",").map((m) => m.trim());
91
+ if (args.days)
92
+ body.days = Number(args.days);
93
+ if (args["start-date"])
94
+ body.startDate = args["start-date"];
95
+ if (args["end-date"])
96
+ body.endDate = args["end-date"];
97
+ if (args.limit)
98
+ body.limit = Number(args.limit);
99
+ if (!useCache)
100
+ body.skipCache = true;
101
+ return body;
102
+ }
103
+ function handleError(err) {
104
+ if (err instanceof ApiError) {
105
+ writeJsonEnvelope({ ok: false, error: { code: err.code, message: err.message } });
106
+ process.exit(1);
107
+ }
108
+ writeJsonEnvelope({
109
+ ok: false,
110
+ error: { code: "NETWORK_ERROR", message: err instanceof Error ? err.message : "Unexpected error" },
111
+ });
112
+ process.exit(1);
113
+ }
114
+ export const queryCommand = defineCommand({
115
+ meta: {
116
+ name: "query",
117
+ description: `Run GA4 Data API reports. Preset-first with free-form escape hatch.
118
+
119
+ Presets (primary usage):
120
+ baker ga4 query --preset tracking-health
121
+ baker ga4 query --preset lp-performance --days 14
122
+ baker ga4 query --list-presets
123
+
124
+ Free-form (escape hatch):
125
+ baker ga4 query --dimensions "date,sessionSourceMedium" --metrics "sessions,conversions"
126
+ baker ga4 query --metrics "eventCount" --dimensions "eventName" --days 7`,
127
+ },
128
+ args: {
129
+ "property-id": { type: "string", description: "GA4 property ID", required: false },
130
+ preset: { type: "string", description: "Named preset", required: false },
131
+ dimensions: { type: "string", description: "Comma-separated dimensions", required: false },
132
+ metrics: { type: "string", description: "Comma-separated metrics", required: false },
133
+ days: { type: "string", description: "Lookback days (default: 30)", required: false },
134
+ "start-date": { type: "string", description: "Start date override", required: false },
135
+ "end-date": { type: "string", description: "End date override", required: false },
136
+ limit: { type: "string", description: "Max rows (default: 1000)", required: false },
137
+ "list-presets": { type: "boolean", description: "List presets", required: false },
138
+ out: { type: "string", description: "Output file path", required: false },
139
+ append: { type: "boolean", description: "Append to file", required: false },
140
+ output: { type: "string", description: "Format: json|csv|jsonl|md", required: false, default: "json" },
141
+ "no-cache": { type: "boolean", description: "Skip cache", required: false },
142
+ },
143
+ run: async ({ args }) => {
144
+ if (args["list-presets"]) {
145
+ writeJsonEnvelope({
146
+ ok: true,
147
+ data: GA4_PRESETS.map((p) => ({ name: p.name, description: p.description, playbook: p.playbook })),
148
+ });
149
+ return;
150
+ }
151
+ if (!args.preset && !args.metrics) {
152
+ writeJsonEnvelope({
153
+ ok: false,
154
+ error: {
155
+ code: "VALIDATION_ERROR",
156
+ message: "Provide --preset or --metrics. Run --list-presets to see options.",
157
+ },
158
+ });
159
+ process.exit(1);
160
+ }
161
+ const propertyId = await resolvePropertyId(args);
162
+ const useCache = !args["no-cache"];
163
+ const body = buildRequestBody(args, propertyId, useCache);
164
+ const cacheKey = buildQueryCacheKey(propertyId, JSON.stringify(body));
165
+ if (useCache) {
166
+ const cached = cacheGet("ga4-queries", cacheKey);
167
+ if (cached) {
168
+ outputRows(cached.data.data ?? [], args, cached.data, true);
169
+ return;
170
+ }
171
+ }
172
+ try {
173
+ const response = await apiPost("/api/ga4/query", body);
174
+ if (useCache) {
175
+ cacheSet("ga4-queries", cacheKey, response, getQueryTtl(JSON.stringify(body)));
176
+ }
177
+ outputRows(response.data ?? [], args, response, false);
178
+ }
179
+ catch (err) {
180
+ handleError(err);
181
+ }
182
+ },
183
+ });
184
+ //# sourceMappingURL=query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.js","sourceRoot":"","sources":["../../../src/commands/ga4/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAClF,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACtF,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,cAAc,CAAC;IACb,OAAO,EAAE,WAAW;IACpB,WAAW,EACT,sIAAsI;IACxI,IAAI,EAAE;QACJ,aAAa,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,iDAAiD,EAAE,QAAQ,EAAE,KAAK,EAAE;QAClH,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,WAAW,EACT,gHAAgH;YAClH,QAAQ,EAAE,KAAK;SAChB;QACD,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,gDAAgD,EAAE,QAAQ,EAAE,KAAK,E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AC;IACH,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function resolvePropertyId(args: Record<string, unknown>): Promise<string>;
2
+ //# sourceMappingURL=resolve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../src/commands/ga4/resolve.ts"],"names":[],"mappings":"AAyBA,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAsCtF"}
@@ -0,0 +1,57 @@
1
+ import { apiGet } from "../../client.js";
2
+ import { getEnv } from "../../env.js";
3
+ import { cacheGet, cacheSet } from "../ads/cache.js";
4
+ import { writeJsonEnvelope } from "../ads/output.js";
5
+ async function fetchProperties(useCache = true) {
6
+ if (useCache) {
7
+ const cached = cacheGet("ga4-properties", "list");
8
+ if (cached)
9
+ return cached.data;
10
+ }
11
+ const params = !useCache ? { "skip-cache": "true" } : undefined;
12
+ const data = await apiGet("/api/ga4/properties", params);
13
+ if (useCache) {
14
+ cacheSet("ga4-properties", "list", data, 60 * 60 * 1000);
15
+ }
16
+ return data;
17
+ }
18
+ import { handleConnectionError } from "../../error-handler.js";
19
+ export async function resolvePropertyId(args) {
20
+ const fromArgs = args["property-id"];
21
+ const fromEnv = getEnv().BAKER_GA4_PROPERTY_ID;
22
+ const propertyId = fromArgs || fromEnv;
23
+ if (propertyId)
24
+ return propertyId;
25
+ const useCache = !args["no-cache"];
26
+ try {
27
+ const properties = await fetchProperties(useCache);
28
+ const [single] = properties;
29
+ if (properties.length === 1 && single) {
30
+ process.stderr.write(`Using property "${single.name}" (${single.externalId})\n`);
31
+ return single.externalId;
32
+ }
33
+ if (properties.length === 0) {
34
+ handleConnectionError("ga4");
35
+ }
36
+ const list = properties.map((p) => ` ${p.externalId} ${p.name}`).join("\n");
37
+ writeJsonEnvelope({
38
+ ok: false,
39
+ error: {
40
+ code: "MULTIPLE_PROPERTIES",
41
+ message: `Multiple properties found. Pass --property-id or set BAKER_GA4_PROPERTY_ID:\n${list}`,
42
+ },
43
+ });
44
+ process.exit(1);
45
+ }
46
+ catch {
47
+ writeJsonEnvelope({
48
+ ok: false,
49
+ error: {
50
+ code: "RESOLUTION_ERROR",
51
+ message: "Could not auto-detect property. Pass --property-id or set BAKER_GA4_PROPERTY_ID.",
52
+ },
53
+ });
54
+ process.exit(1);
55
+ }
56
+ }
57
+ //# sourceMappingURL=resolve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../../src/commands/ga4/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAOrD,KAAK,UAAU,eAAe,CAAC,QAAQ,GAAG,IAAI;IAC5C,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,MAAM,GAAG,QAAQ,CAAgB,gBAAgB,EAAE,MAAM,CAAC,CAAC;QACjE,IAAI,MAAM;YAAE,OAAO,MAAM,CAAC,IAAI,CAAC;IACjC,CAAC;IACD,MAAM,MAAM,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IAChE,MAAM,IAAI,GAAG,MAAM,MAAM,CAAgB,qBAAqB,EAAE,MAAM,CAAC,CAAC;IACxE,IAAI,QAAQ,EAAE,CAAC;QACb,QAAQ,CAAC,gBAAgB,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,OAAO,EAAE,qBAAqB,EAAE,M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AAE,EAAE,KAAK;YACT,KAAK,EAAE;gBACL,IAAI,EAAE,kBAAkB;gBACxB,OAAO,EAAE,kFAAkF;aAC5F;SACF,CAAC,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const gscCommand: import("citty").CommandDef<import("citty").ArgsDef>;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/gsc/index.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,UAAU,qDAoBrB,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { defineCommand } from "citty";
2
+ import { queryCommand } from "./query.js";
3
+ import { sitemapsCommand } from "./sitemaps.js";
4
+ import { sitesCommand } from "./sites.js";
5
+ export const gscCommand = defineCommand({
6
+ meta: {
7
+ name: "gsc",
8
+ description: `Google Search Console commands. PPC-SEO arbitrage, brand halo analysis, negative keyword discovery.
9
+
10
+ Start here:
11
+ baker gsc sites — list verified sites
12
+ baker gsc query --list-presets — see available query presets
13
+
14
+ Examples:
15
+ baker gsc query --preset cannibalization — find PPC-SEO overlap
16
+ baker gsc query --preset brand-halo --brand "Acme" --days 90 — brand search trends
17
+ baker gsc query --dimensions "query,page" --days 28 — free-form query
18
+ baker gsc sitemaps — check sitemap health`,
19
+ },
20
+ subCommands: {
21
+ sites: sitesCommand,
22
+ query: queryCommand,
23
+ sitemaps: sitemapsCommand,
24
+ },
25
+ });
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/gsc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAC;IACtC,IAAI,EAAE;QACJ,IAAI,EAAE,KAAK;QACX,WAAW,EAAE;;;;;;;;;;2FAU0E;KACxF;IACD,WAAW,EAAE;QACX,KAAK,EAAE,YAAY;QACnB,KAAK,EAAE,YAAY;QACnB,QAAQ,EAAE,eAAe;KAC1B;CACF,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ interface GscPreset {
2
+ name: string;
3
+ description: string;
4
+ playbook: string;
5
+ requiresBrand?: boolean;
6
+ }
7
+ export declare const GSC_PRESETS: GscPreset[];
8
+ export {};
9
+ //# sourceMappingURL=presets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presets.d.ts","sourceRoot":"","sources":["../../../src/commands/gsc/presets.ts"],"names":[],"mappings":"AAAA,UAAU,SAAS;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,eAAO,MAAM,WAAW,EAAE,SAAS,EAgClC,CAAC"}
@@ -0,0 +1,34 @@
1
+ export const GSC_PRESETS = [
2
+ {
3
+ name: "cannibalization",
4
+ description: "PPC-SEO arbitrage — find queries ranking #1-2 organically where you also pay for ads",
5
+ playbook: "[05] PPC-SEO Arbitrage",
6
+ },
7
+ {
8
+ name: "missed-revenue",
9
+ description: "High-impression queries with no PPC coverage (position > 10)",
10
+ playbook: "[05] Opportunity Finder",
11
+ },
12
+ {
13
+ name: "brand-halo",
14
+ description: "Brand search volume trends — proves upper-funnel awareness lift",
15
+ playbook: "[21] YouTube/DG ROI",
16
+ requiresBrand: true,
17
+ },
18
+ {
19
+ name: "negative-keywords",
20
+ description: "Discover negative keyword candidates (login, support, cancel queries)",
21
+ playbook: "Negative Keyword Discovery",
22
+ },
23
+ {
24
+ name: "top-pages",
25
+ description: "Top performing pages by clicks",
26
+ playbook: "General",
27
+ },
28
+ {
29
+ name: "top-queries",
30
+ description: "Top search queries by clicks",
31
+ playbook: "General",
32
+ },
33
+ ];
34
+ //# sourceMappingURL=presets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presets.js","sourceRoot":"","sources":["../../../src/commands/gsc/presets.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,WAAW,GAAgB;IACtC;QACE,IAAI,EAAE,iBAAiB;QACvB,WAAW,EAAE,sFAAsF;QACnG,QAAQ,EAAE,wBAAwB;KACnC;IACD;QACE,IAAI,EAAE,gBAAgB;QACtB,WAAW,EAAE,8DAA8D;QAC3E,QAAQ,EAAE,yBAAyB;KACpC;IACD;QACE,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE,iEAAiE;QAC9E,QAAQ,EAAE,qBAAqB;QAC/B,aAAa,EAAE,IAAI;KACpB;IACD;QACE,IAAI,EAAE,mBAAmB;QACzB,WAAW,EAAE,uEAAuE;QACpF,QAAQ,EAAE,4BAA4B;KACvC;IACD;QACE,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,gCAAgC;QAC7C,QAAQ,EAAE,SAAS;KACpB;IACD;QACE,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE,8BAA8B;QAC3C,QAAQ,EAAE,SAAS;KACpB;CACF,CAAC"}
@@ -0,0 +1,79 @@
1
+ export declare const queryCommand: import("citty").CommandDef<{
2
+ readonly "site-url": {
3
+ readonly type: "string";
4
+ readonly description: "Site URL";
5
+ readonly required: false;
6
+ };
7
+ readonly preset: {
8
+ readonly type: "string";
9
+ readonly description: "Named preset";
10
+ readonly required: false;
11
+ };
12
+ readonly brand: {
13
+ readonly type: "string";
14
+ readonly description: "Brand name for brand-halo preset";
15
+ readonly required: false;
16
+ };
17
+ readonly dimensions: {
18
+ readonly type: "string";
19
+ readonly description: "Comma-separated dimensions";
20
+ readonly required: false;
21
+ };
22
+ readonly days: {
23
+ readonly type: "string";
24
+ readonly description: "Lookback days (default: 28)";
25
+ readonly required: false;
26
+ };
27
+ readonly "start-date": {
28
+ readonly type: "string";
29
+ readonly description: "Start date override";
30
+ readonly required: false;
31
+ };
32
+ readonly "end-date": {
33
+ readonly type: "string";
34
+ readonly description: "End date override";
35
+ readonly required: false;
36
+ };
37
+ readonly "row-limit": {
38
+ readonly type: "string";
39
+ readonly description: "Max rows (default: 1000)";
40
+ readonly required: false;
41
+ };
42
+ readonly type: {
43
+ readonly type: "string";
44
+ readonly description: "Search type (default: web)";
45
+ readonly required: false;
46
+ };
47
+ readonly filter: {
48
+ readonly type: "string";
49
+ readonly description: "Filter JSON";
50
+ readonly required: false;
51
+ };
52
+ readonly "list-presets": {
53
+ readonly type: "boolean";
54
+ readonly description: "List presets";
55
+ readonly required: false;
56
+ };
57
+ readonly out: {
58
+ readonly type: "string";
59
+ readonly description: "Output file path";
60
+ readonly required: false;
61
+ };
62
+ readonly append: {
63
+ readonly type: "boolean";
64
+ readonly description: "Append to file";
65
+ readonly required: false;
66
+ };
67
+ readonly output: {
68
+ readonly type: "string";
69
+ readonly description: "Format: json|csv|jsonl|md";
70
+ readonly required: false;
71
+ readonly default: "json";
72
+ };
73
+ readonly "no-cache": {
74
+ readonly type: "boolean";
75
+ readonly description: "Skip cache";
76
+ readonly required: false;
77
+ };
78
+ }>;
79
+ //# sourceMappingURL=query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/commands/gsc/query.ts"],"names":[],"mappings":"AA6HA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+EvB,CAAC"}