@canonry/canonry 7.51.4 → 7.51.6

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 (172) hide show
  1. package/assets/assets/AccessControls-B5TqDgeq.js +1 -0
  2. package/assets/assets/AuditHistoryPanel-DgxiizOW.js +1 -0
  3. package/assets/assets/BacklinksPage-Ay6pdphx.js +1 -0
  4. package/assets/assets/ChartPrimitives-DIEeZdrs.js +1 -0
  5. package/assets/assets/Hint-Cn4lh0Do.js +1 -0
  6. package/assets/assets/HistoryPage-B11eFH21.js +1 -0
  7. package/assets/assets/InfoTooltip-TIx9qM5h.js +1 -0
  8. package/assets/assets/MeasurementPropertyPage-1UYI7mzP.js +4 -0
  9. package/assets/assets/ProjectPage-DoY0hftd.js +8 -0
  10. package/assets/assets/RunsPage-BPBmuQAS.js +1 -0
  11. package/assets/assets/SettingsPage-ClKnP8xy.js +1 -0
  12. package/assets/assets/SiteHealthSection-PWjKMmEn.js +2 -0
  13. package/assets/assets/TrafficPage-DkfGiJXR.js +40 -0
  14. package/assets/assets/TrafficSourceDetailPage-DQu0YNt2.js +1 -0
  15. package/assets/assets/async-handler-Bj3TnIRw.js +1 -0
  16. package/assets/assets/card-DYMyvhB9.js +60 -0
  17. package/assets/assets/extract-error-message-BRM1I_3L.js +1 -0
  18. package/assets/assets/format-helpers-DrkFERj3.js +3 -0
  19. package/assets/assets/index-CG1Jox52.js +39 -0
  20. package/assets/assets/index-CsPsaUr7.css +1 -0
  21. package/assets/assets/query-client-gRFnU4VF.js +1 -0
  22. package/assets/assets/react-query-lH82FULK.js +1 -0
  23. package/assets/assets/react-sigma_core.esm.min-D09H4byP.js +3225 -0
  24. package/assets/assets/rolldown-runtime-XKyaHtl9.js +1 -0
  25. package/assets/assets/service-Cx0HSnE9.js +1 -0
  26. package/assets/assets/vendor-lucide-BjvO55Hk.js +1 -0
  27. package/assets/assets/vendor-markdown-DWjffpgb.js +29 -0
  28. package/assets/assets/vendor-radix-BU76HM0G.js +41 -0
  29. package/assets/assets/vendor-recharts-CsHBXoK8.js +59 -0
  30. package/assets/assets/vendor-tanstack-QhOrDhIL.js +2 -0
  31. package/assets/assets/vendor-yaml-Y43rmNgW.js +105 -0
  32. package/assets/index.html +16 -8
  33. package/dist/ads-ABAT3K4K.js +544 -0
  34. package/dist/agent-5G4DRLYX.js +70 -0
  35. package/dist/agent-ask-UDVCZRO7.js +139 -0
  36. package/dist/agent-conversations-5E4JP2QZ.js +52 -0
  37. package/dist/agent-memory-7IIJ4HGZ.js +92 -0
  38. package/dist/agent-providers-BOXPUXZ4.js +55 -0
  39. package/dist/agent-transcript-4O56G6PQ.js +77 -0
  40. package/dist/analytics-PKMWX5XL.js +240 -0
  41. package/dist/apply-OK4XEBDA.js +175 -0
  42. package/dist/backfill-2OT56CX2.js +41 -0
  43. package/dist/backlinks-547WCHND.js +303 -0
  44. package/dist/bing-ZVBV4ZD5.js +418 -0
  45. package/dist/bootstrap-HUB7XQ73.js +326 -0
  46. package/dist/cdp-KQKQ4PWJ.js +162 -0
  47. package/dist/chunk-2G6IP3MO.js +517 -0
  48. package/dist/chunk-42D2LE2B.js +1273 -0
  49. package/dist/chunk-4MJYGB56.js +124 -0
  50. package/dist/chunk-63ISSSGX.js +9150 -0
  51. package/dist/{chunk-HHRM3H3L.js → chunk-6G6FTDWC.js} +8082 -13941
  52. package/dist/chunk-6GO5VVAC.js +15 -0
  53. package/dist/{chunk-6GNV6VF4.js → chunk-73P65KPW.js} +2 -2
  54. package/dist/chunk-7B2Q4NJE.js +133 -0
  55. package/dist/{chunk-KU4TPVZV.js → chunk-7WZ2FPB4.js} +2 -13
  56. package/dist/chunk-AOJU5LKX.js +8 -0
  57. package/dist/chunk-B2FR2ZQ4.js +420 -0
  58. package/dist/chunk-B5J675KK.js +6557 -0
  59. package/dist/{chunk-YOGHHIGE.js → chunk-D6COIM3U.js} +17155 -17164
  60. package/dist/{chunk-KUS7M65J.js → chunk-DGVUTH7W.js} +6809 -32243
  61. package/dist/chunk-ELCLGWUT.js +83 -0
  62. package/dist/chunk-GO2J7SYT.js +1034 -0
  63. package/dist/chunk-HACZUMGM.js +145 -0
  64. package/dist/chunk-HM4NNKLG.js +94 -0
  65. package/dist/chunk-I3A56PFP.js +58 -0
  66. package/dist/chunk-I77PLCWG.js +961 -0
  67. package/dist/chunk-ISOQPVPY.js +232 -0
  68. package/dist/chunk-KFT5LOP2.js +610 -0
  69. package/dist/chunk-MLKGABMK.js +9 -0
  70. package/dist/chunk-MMEO22MF.js +38 -0
  71. package/dist/chunk-NHQ2U5I4.js +78 -0
  72. package/dist/chunk-PCXRFT3N.js +530 -0
  73. package/dist/chunk-PITHTCAX.js +15376 -0
  74. package/dist/chunk-QWKPSFGL.js +30 -0
  75. package/dist/chunk-RKIXES2B.js +609 -0
  76. package/dist/chunk-TSENU4GG.js +18 -0
  77. package/dist/{chunk-P6D6P337.js → chunk-TUTKNUMV.js} +7 -5
  78. package/dist/chunk-U3AHE2RT.js +1160 -0
  79. package/dist/chunk-UQ3MOZGC.js +644 -0
  80. package/dist/{chunk-35QQMVO6.js → chunk-VBCE4CLX.js} +6 -4
  81. package/dist/chunk-VJWDBFSL.js +69 -0
  82. package/dist/chunk-VYMZ3QXG.js +8264 -0
  83. package/dist/chunk-WAULJDKO.js +2686 -0
  84. package/dist/chunk-WDFI5YMD.js +204 -0
  85. package/dist/chunk-XEBKF4N5.js +8 -0
  86. package/dist/chunk-Z7IUAJOF.js +13 -0
  87. package/dist/{chunk-RUWELF3K.js → chunk-ZWJRY5UI.js} +358 -581
  88. package/dist/chunk-ZXUAWVWM.js +15 -0
  89. package/dist/citations-UYB2RU5U.js +106 -0
  90. package/dist/{cli-catalog-KTQ6BHEU.js → cli-catalog-F6FI7NB2.js} +5 -3
  91. package/dist/cli-commands-ZG5ILKDA.js +19 -0
  92. package/dist/cli.js +35 -29
  93. package/dist/competitor-EKP4R7YY.js +561 -0
  94. package/dist/content-DREE6JF3.js +257 -0
  95. package/dist/dashboard-ZALEOLLU.js +71 -0
  96. package/dist/demo-JG4Y22O4.js +75 -0
  97. package/dist/{demo-server-26UUDUM7.js → demo-server-3A4J2C65.js} +22 -9
  98. package/dist/discover-W6GMD2HS.js +372 -0
  99. package/dist/discover-eval-CKFZHRBW.js +282 -0
  100. package/dist/doctor-TNGBSUMA.js +152 -0
  101. package/dist/evidence-3H2GFQBZ.js +57 -0
  102. package/dist/export-cmd-WUIKU5GK.js +49 -0
  103. package/dist/ga-JI6REFO4.js +911 -0
  104. package/dist/gbp-4ENDM5NS.js +370 -0
  105. package/dist/google-HKQSCLOC.js +946 -0
  106. package/dist/google-marketing-KQR5J2S4.js +403 -0
  107. package/dist/health-cmd-TS7EMMCS.js +64 -0
  108. package/dist/history-MSD5DK6K.js +90 -0
  109. package/dist/index.d.ts +194 -60
  110. package/dist/index.js +29 -6
  111. package/dist/init-L6WAEOWX.js +432 -0
  112. package/dist/insights-RTZ3IZTD.js +63 -0
  113. package/dist/intelligence-service-TH52PCNJ.js +15 -0
  114. package/dist/keys-625DZBRM.js +116 -0
  115. package/dist/keyword-CW46RNRR.js +164 -0
  116. package/dist/logs-V33SHBIW.js +30 -0
  117. package/dist/mcp-DFEDPSEG.js +14 -0
  118. package/dist/mcp.js +14 -5
  119. package/dist/measurement-plan-6W37RUOP.js +42 -0
  120. package/dist/notify-DSUOT7WO.js +125 -0
  121. package/dist/organic-evidence-BMN6L4OB.js +53 -0
  122. package/dist/overview-WRRMBZ6S.js +213 -0
  123. package/dist/project-2GJIU3FE.js +460 -0
  124. package/dist/query-3XPMGJUA.js +211 -0
  125. package/dist/research-V433CKJ4.js +200 -0
  126. package/dist/results-export-RGBU7QQQ.js +27 -0
  127. package/dist/run-NIAC6OJN.js +31 -0
  128. package/dist/schedule-KDWXRIE7.js +177 -0
  129. package/dist/search-626MPUJN.js +42 -0
  130. package/dist/serve-73SMMASI.js +557 -0
  131. package/dist/session-7WWOETZB.js +47 -0
  132. package/dist/settings-VKFQO6F2.js +107 -0
  133. package/dist/skills-5HC5H7TE.js +33 -0
  134. package/dist/snapshot-BSJUHFBC.js +538 -0
  135. package/dist/src-F6HM73TN.js +316 -0
  136. package/dist/status-V4OWP7LZ.js +126 -0
  137. package/dist/support-ARF4HER7.js +24 -0
  138. package/dist/technical-aeo-TG7CGU3F.js +625 -0
  139. package/dist/telemetry-O2IUNUBW.js +118 -0
  140. package/dist/tools-2GJIDKND.js +41 -0
  141. package/dist/traffic-XV4I3UPH.js +1295 -0
  142. package/dist/users-VGBLDL5K.js +170 -0
  143. package/dist/visibility-stats-UKJYJ6PP.js +241 -0
  144. package/dist/wordpress-JZA7CGC6.js +600 -0
  145. package/package.json +30 -30
  146. package/assets/assets/AuditHistoryPanel-CtWNkC6F.js +0 -1
  147. package/assets/assets/BacklinksPage-Cs3_j55C.js +0 -1
  148. package/assets/assets/ChartPrimitives-B6ryduMN.js +0 -1
  149. package/assets/assets/Hint-DICI5Jq9.js +0 -1
  150. package/assets/assets/HistoryPage-_5Vwj01m.js +0 -1
  151. package/assets/assets/MeasurementPropertyPage-B2yBTUZd.js +0 -4
  152. package/assets/assets/ProjectPage-hs-9PcoS.js +0 -8
  153. package/assets/assets/RunsPage-B_mhz9vj.js +0 -1
  154. package/assets/assets/SettingsPage-D1Lzcw03.js +0 -1
  155. package/assets/assets/SiteHealthSection-CGlrPdrk.js +0 -4
  156. package/assets/assets/TrafficPage-C27a0rQp.js +0 -40
  157. package/assets/assets/TrafficSourceDetailPage-DOSoQySv.js +0 -1
  158. package/assets/assets/extract-error-message-itBoiivg.js +0 -1
  159. package/assets/assets/index-Br2WtEIO.css +0 -1
  160. package/assets/assets/index-CdAuyP-X.js +0 -86
  161. package/assets/assets/react-sigma_core.esm.min-CPYhSQFc.js +0 -312
  162. package/assets/assets/v2-overview-adapter-DQXWmK0B.js +0 -1
  163. package/assets/assets/vendor-lucide-Y6jANGfG.js +0 -1
  164. package/assets/assets/vendor-markdown-B4giJcws.js +0 -29
  165. package/assets/assets/vendor-radix-twS1M3FF.js +0 -45
  166. package/assets/assets/vendor-recharts-D_R6YxjS.js +0 -36
  167. package/assets/assets/vendor-tanstack-ZXXkndVj.js +0 -1
  168. package/assets/assets/vendor-yaml-GWJz5H2G.js +0 -131
  169. package/dist/chunk-EQTVQIM2.js +0 -23082
  170. package/dist/chunk-GZPJ7TSE.js +0 -10872
  171. package/dist/cli-commands-5ZODWR4I.js +0 -15
  172. package/dist/intelligence-service-ZGDBVFDE.js +0 -9
@@ -0,0 +1,370 @@
1
+ import {
2
+ createApiClient
3
+ } from "./chunk-B5J675KK.js";
4
+ import "./chunk-UQ3MOZGC.js";
5
+ import "./chunk-AOJU5LKX.js";
6
+ import {
7
+ isMachineFormat
8
+ } from "./chunk-HGMYEDAQ.js";
9
+ import {
10
+ formatGbpMetricLabel,
11
+ formatPercent
12
+ } from "./chunk-D6COIM3U.js";
13
+ import "./chunk-MLKGABMK.js";
14
+
15
+ // src/commands/gbp.ts
16
+ function getClient() {
17
+ return createApiClient();
18
+ }
19
+ function formatLocationsTable(response) {
20
+ if (response.locations.length === 0) {
21
+ return "No GBP locations discovered yet. Run `canonry gbp locations discover <project>` first.";
22
+ }
23
+ const lines = [];
24
+ lines.push(`Discovered ${response.totalDiscovered} location(s), ${response.totalSelected} selected for sync:
25
+ `);
26
+ for (const loc of response.locations) {
27
+ const flag = loc.selected ? "\u2713" : " ";
28
+ const category = loc.primaryCategoryDisplayName ?? "unknown";
29
+ lines.push(` [${flag}] ${loc.locationName.padEnd(18)} ${loc.displayName} (${category})`);
30
+ }
31
+ return lines.join("\n");
32
+ }
33
+ async function gbpConnect(project, opts) {
34
+ const client = getClient();
35
+ const { authUrl, redirectUri } = await client.googleConnect(project, {
36
+ type: "gbp",
37
+ publicUrl: opts.publicUrl
38
+ });
39
+ if (isMachineFormat(opts.format)) {
40
+ console.log(JSON.stringify({ project, type: "gbp", authUrl, redirectUri: redirectUri ?? null }, null, 2));
41
+ return;
42
+ }
43
+ console.log("\nOpen this URL in your browser to authorize Google Business Profile access:\n");
44
+ console.log(` ${authUrl}
45
+ `);
46
+ if (redirectUri) {
47
+ console.log(`Redirect URI: ${redirectUri}`);
48
+ console.log("(Ensure this URI is listed in your Google Cloud Console OAuth client's authorized redirect URIs)\n");
49
+ }
50
+ console.log("After authorizing, run `canonry gbp locations discover <project>` to fetch your locations.");
51
+ }
52
+ async function gbpDisconnect(project, opts) {
53
+ const client = getClient();
54
+ await client.disconnectGbp(project);
55
+ if (isMachineFormat(opts.format)) {
56
+ console.log(JSON.stringify({ project, disconnected: true }, null, 2));
57
+ return;
58
+ }
59
+ console.log(`Disconnected GBP from project "${project}" and removed all discovered locations.`);
60
+ }
61
+ async function gbpLocationsList(project, opts) {
62
+ const client = getClient();
63
+ const response = await client.listGbpLocations(
64
+ project,
65
+ opts.selectedOnly ? { selected: true } : void 0
66
+ );
67
+ if (isMachineFormat(opts.format)) {
68
+ console.log(JSON.stringify(response, null, 2));
69
+ return;
70
+ }
71
+ console.log(formatLocationsTable(response));
72
+ }
73
+ async function gbpAccounts(project, opts) {
74
+ const client = getClient();
75
+ const response = await client.listGbpAccounts(project);
76
+ if (isMachineFormat(opts.format)) {
77
+ console.log(JSON.stringify(response, null, 2));
78
+ return;
79
+ }
80
+ console.log(formatAccountsTable(response));
81
+ }
82
+ function formatAccountsTable(response) {
83
+ if (response.accounts.length === 0) {
84
+ return "No GBP accounts visible to this connection. Confirm the OAuth user has manager/owner access on the target Business Profile.";
85
+ }
86
+ const lines = [];
87
+ lines.push(`${response.total} account(s) accessible to this connection:
88
+ `);
89
+ for (const acc of response.accounts) {
90
+ const label = acc.accountName ?? "(unnamed)";
91
+ const meta = [acc.type, acc.role].filter(Boolean).join(", ");
92
+ lines.push(` ${acc.name.padEnd(22)} ${label}${meta ? ` (${meta})` : ""}`);
93
+ }
94
+ lines.push("\nDiscover a specific account into a project with:");
95
+ lines.push(" canonry gbp locations discover <project> --account <accounts/{n}>");
96
+ return lines.join("\n");
97
+ }
98
+ async function gbpLocationsDiscover(project, opts) {
99
+ const client = getClient();
100
+ const hasBody = opts.selectAllNew !== void 0 || opts.account !== void 0 || opts.switchAccount;
101
+ const body = hasBody ? {
102
+ ...opts.selectAllNew === void 0 ? {} : { selectAllNew: opts.selectAllNew },
103
+ ...opts.account === void 0 ? {} : { accountName: opts.account },
104
+ ...opts.switchAccount ? { switchAccount: true } : {}
105
+ } : void 0;
106
+ const response = await client.discoverGbpLocations(project, body);
107
+ if (isMachineFormat(opts.format)) {
108
+ console.log(JSON.stringify(response, null, 2));
109
+ return;
110
+ }
111
+ console.log(`
112
+ Discovered ${response.totalDiscovered} location(s); ${response.totalSelected} selected for sync.`);
113
+ console.log(formatLocationsTable(response));
114
+ }
115
+ async function gbpLocationSelect(project, opts) {
116
+ const client = getClient();
117
+ const updated = await client.setGbpLocationSelection(project, opts.location, true);
118
+ if (isMachineFormat(opts.format)) {
119
+ console.log(JSON.stringify(updated, null, 2));
120
+ return;
121
+ }
122
+ console.log(`Selected ${opts.location} ("${updated.displayName}") for sync.`);
123
+ }
124
+ async function gbpLocationDeselect(project, opts) {
125
+ const client = getClient();
126
+ const updated = await client.setGbpLocationSelection(project, opts.location, false);
127
+ if (isMachineFormat(opts.format)) {
128
+ console.log(JSON.stringify(updated, null, 2));
129
+ return;
130
+ }
131
+ console.log(`Deselected ${opts.location} ("${updated.displayName}"). Future syncs will skip this location.`);
132
+ }
133
+ async function gbpSync(project, opts) {
134
+ const client = getClient();
135
+ const { runId, status } = await client.triggerGbpSync(project, {
136
+ locationNames: opts.location ? [opts.location] : void 0,
137
+ daysOfMetrics: opts.days,
138
+ monthsOfKeywords: opts.months
139
+ });
140
+ if (!opts.wait) {
141
+ if (isMachineFormat(opts.format)) {
142
+ console.log(JSON.stringify({ runId, status }, null, 2));
143
+ return;
144
+ }
145
+ console.log(`GBP sync started (run ${runId}). Use \`canonry runs get ${runId}\` to check status, or pass --wait.`);
146
+ return;
147
+ }
148
+ const terminal = /* @__PURE__ */ new Set(["completed", "partial", "failed", "cancelled"]);
149
+ const start = Date.now();
150
+ const timeoutMs = 10 * 60 * 1e3;
151
+ if (!isMachineFormat(opts.format)) process.stderr.write("Syncing");
152
+ let final = status;
153
+ while (Date.now() - start < timeoutMs) {
154
+ await new Promise((r) => setTimeout(r, 2e3));
155
+ const run = await client.getRun(runId);
156
+ if (!isMachineFormat(opts.format)) process.stderr.write(".");
157
+ if (terminal.has(run.status)) {
158
+ final = run.status;
159
+ break;
160
+ }
161
+ }
162
+ if (!isMachineFormat(opts.format)) process.stderr.write("\n");
163
+ if (isMachineFormat(opts.format)) {
164
+ console.log(JSON.stringify({ runId, status: final }, null, 2));
165
+ return;
166
+ }
167
+ console.log(`GBP sync ${final} (run ${runId}).`);
168
+ }
169
+ async function gbpMetrics(project, opts) {
170
+ const client = getClient();
171
+ const response = await client.listGbpMetrics(project, { locationName: opts.location, metric: opts.metric });
172
+ if (isMachineFormat(opts.format)) {
173
+ console.log(JSON.stringify(response, null, 2));
174
+ return;
175
+ }
176
+ if (response.metrics.length === 0) {
177
+ console.log("No GBP metrics stored. Run `canonry gbp sync <project>` first.");
178
+ return;
179
+ }
180
+ const totals = /* @__PURE__ */ new Map();
181
+ for (const m of response.metrics) totals.set(m.metric, (totals.get(m.metric) ?? 0) + m.value);
182
+ console.log(`${response.total} metric row(s). Totals by metric:`);
183
+ for (const [metric, total] of [...totals.entries()].sort((a, b) => b[1] - a[1])) {
184
+ console.log(` ${formatGbpMetricLabel(metric).padEnd(28)} ${total}`);
185
+ }
186
+ }
187
+ async function gbpKeywords(project, opts) {
188
+ const client = getClient();
189
+ const response = await client.listGbpKeywords(project, { locationName: opts.location });
190
+ if (isMachineFormat(opts.format)) {
191
+ console.log(JSON.stringify(response, null, 2));
192
+ return;
193
+ }
194
+ if (response.keywords.length === 0) {
195
+ console.log("No GBP keyword impressions stored. Run `canonry gbp sync <project>` first.");
196
+ return;
197
+ }
198
+ console.log(`${response.total} keyword(s), ${formatPercent(response.thresholdedPct, "percent")} privacy-thresholded. Top by impressions:`);
199
+ for (const k of response.keywords.slice(0, 15)) {
200
+ const val = k.valueCount !== null ? String(k.valueCount) : `<${k.valueThreshold ?? "?"}`;
201
+ console.log(` ${val.padStart(8)} ${k.keyword}`);
202
+ }
203
+ }
204
+ async function gbpPlaceActions(project, opts) {
205
+ const client = getClient();
206
+ const response = await client.listGbpPlaceActions(project, { locationName: opts.location });
207
+ if (isMachineFormat(opts.format)) {
208
+ console.log(JSON.stringify(response, null, 2));
209
+ return;
210
+ }
211
+ if (response.placeActions.length === 0) {
212
+ console.log("No place action links (booking/reservation CTAs) configured. For many businesses this is an AEO gap.");
213
+ return;
214
+ }
215
+ console.log(`${response.total} place action link(s):`);
216
+ for (const pa of response.placeActions) {
217
+ const provider = pa.providerType === "MERCHANT" ? "direct" : pa.providerType === "AGGREGATOR" ? "aggregator" : pa.providerType ?? "?";
218
+ console.log(` ${pa.placeActionType.padEnd(14)} ${provider.padEnd(11)} ${pa.uri ?? ""}`);
219
+ }
220
+ }
221
+ async function gbpLodging(project, opts) {
222
+ const client = getClient();
223
+ const response = await client.listGbpLodging(project, { locationName: opts.location });
224
+ if (isMachineFormat(opts.format)) {
225
+ console.log(JSON.stringify(response, null, 2));
226
+ return;
227
+ }
228
+ if (response.lodging.length === 0) {
229
+ console.log("No lodging data \u2014 none of the selected locations are lodging-category properties.");
230
+ return;
231
+ }
232
+ console.log(`${response.total} lodging profile(s):`);
233
+ for (const l of response.lodging) {
234
+ const note = l.populatedGroupCount === 0 ? ' (none readable via the Lodging API; verify the "Hotel details" panel, often set there but not exposed by the API)' : "";
235
+ console.log(` ${l.locationName} ${l.populatedGroupCount} attribute group(s)${note}`);
236
+ }
237
+ }
238
+ async function gbpAttributes(project, opts) {
239
+ const client = getClient();
240
+ const response = await client.listGbpAttributes(project, { locationName: opts.location });
241
+ if (isMachineFormat(opts.format)) {
242
+ console.log(JSON.stringify(response, null, 2));
243
+ return;
244
+ }
245
+ if (response.attributes.length === 0) {
246
+ console.log('No attributes data. Run "canonry gbp sync" to capture owner-set attributes.');
247
+ return;
248
+ }
249
+ console.log(`${response.total} location(s) with owner-set attributes:`);
250
+ for (const a of response.attributes) {
251
+ console.log(` ${a.locationName} ${a.attributeCount} attribute(s)`);
252
+ for (const attr of a.attributes) {
253
+ const key = attr.name.replace(/^attributes\//, "");
254
+ const val = [
255
+ ...attr.values.map(String),
256
+ ...attr.unsetValues.map((v) => `unset:${v}`),
257
+ ...attr.uris
258
+ ].join(", ");
259
+ console.log(` ${key}: ${val}`);
260
+ }
261
+ }
262
+ }
263
+ async function gbpPlaces(project, opts) {
264
+ const client = getClient();
265
+ const response = await client.listGbpPlaces(project, { locationName: opts.location });
266
+ if (isMachineFormat(opts.format)) {
267
+ console.log(JSON.stringify(response, null, 2));
268
+ return;
269
+ }
270
+ if (response.places.length === 0) {
271
+ console.log('No Places data \u2014 set a Places API key (places.apiKey / GOOGLE_PLACES_API_KEY) and run "canonry gbp sync" for lodging locations.');
272
+ return;
273
+ }
274
+ console.log(`${response.total} Places listing snapshot(s) \u2014 the amenities Google's public listing advertises:`);
275
+ for (const p of response.places) {
276
+ const amenities = p.amenities.length > 0 ? p.amenities.join(", ") : "(none detected)";
277
+ console.log(` ${p.locationName} [${p.tier}] ${amenities}`);
278
+ }
279
+ }
280
+ async function gbpReviews(project, opts) {
281
+ const client = getClient();
282
+ const response = await client.listGbpReviews(project, {
283
+ locationName: opts.location,
284
+ ...opts.negative ? { negative: true } : {},
285
+ ...opts.limit !== void 0 ? { limit: opts.limit } : {}
286
+ });
287
+ if (isMachineFormat(opts.format)) {
288
+ console.log(JSON.stringify(response, null, 2));
289
+ return;
290
+ }
291
+ if (response.locations.length === 0 && response.reviews.length === 0) {
292
+ console.log('No reviews yet. Run "canonry gbp sync" first.');
293
+ return;
294
+ }
295
+ const names = new Map(response.locations.map((loc) => [loc.locationName, loc.displayName]));
296
+ for (const loc of response.locations) {
297
+ const rating = loc.rating !== null ? `${Number(loc.rating.toFixed(2))} from ${loc.reviewCount ?? "?"} reviews (${loc.ratingOrigin === "gbp" ? "Business Profile" : "public listing"})` : "no rating yet";
298
+ const access = loc.reviewsAccess === "ok" ? "every review" : loc.reviewsAccess === null ? "review access not checked yet" : `Business Profile reviews ${loc.reviewsAccess}${loc.reviewsAccessReason ? ` (${loc.reviewsAccessReason})` : ""}`;
299
+ console.log(`${loc.displayName} ${loc.locationName}`);
300
+ console.log(` ${rating}; ${access}`);
301
+ }
302
+ const label = opts.negative ? "negative review(s)" : "review(s)";
303
+ if (response.reviews.length === 0) {
304
+ console.log(`
305
+ No ${label} stored.`);
306
+ return;
307
+ }
308
+ const shown = response.reviews.length < response.total ? `, newest ${response.reviews.length} shown` : "";
309
+ console.log(`
310
+ ${response.total} ${label}${shown}:`);
311
+ const manyLocations = response.locations.length > 1;
312
+ for (const r of response.reviews) {
313
+ const stars = r.starRating !== null ? `${r.starRating}\u2605` : "--";
314
+ const where = manyLocations ? ` ${names.get(r.locationName) ?? r.locationName}` : "";
315
+ const text = r.comment ? `"${r.comment.length > 80 ? `${r.comment.slice(0, 79)}\u2026` : r.comment}"` : "(rating only)";
316
+ console.log(` ${r.updateTime.slice(0, 10)} ${stars}${where} ${r.reviewerName ?? "Anonymous"} ${text} [${r.origin}, ${r.alertState}]`);
317
+ }
318
+ }
319
+ function fmtDelta(pct) {
320
+ if (pct === null) return "n/a";
321
+ return `${pct >= 0 ? "+" : ""}${formatPercent(pct, "percent")}`;
322
+ }
323
+ async function gbpSummary(project, opts) {
324
+ const client = getClient();
325
+ const s = await client.getGbpSummary(project, { locationName: opts.location });
326
+ if (isMachineFormat(opts.format)) {
327
+ console.log(JSON.stringify(s, null, 2));
328
+ return;
329
+ }
330
+ const scopeLabel = s.scope.locationName ?? `${s.scope.locationCount} selected location(s)`;
331
+ console.log(`GBP local-AEO summary \u2014 ${scopeLabel}`);
332
+ if (s.freshness.dataThroughDate) {
333
+ const pending = s.freshness.pendingDays > 0 ? ` \xB7 ${s.freshness.pendingDays}d pending` : "";
334
+ console.log(`Data through ${s.freshness.dataThroughDate}${pending}`);
335
+ }
336
+ console.log("");
337
+ console.log("Performance (totals, last-7d vs prior-7d over complete days):");
338
+ const metrics = Object.keys(s.performance.totals).sort((a, b) => formatGbpMetricLabel(a).localeCompare(formatGbpMetricLabel(b)));
339
+ if (metrics.length === 0) {
340
+ console.log(" (no performance data \u2014 run `canonry gbp sync` first)");
341
+ } else {
342
+ for (const m of metrics) {
343
+ console.log(` ${formatGbpMetricLabel(m).padEnd(28)} ${String(s.performance.totals[m]).padStart(8)} ${fmtDelta(s.performance.deltaPct[m] ?? null)}`);
344
+ }
345
+ }
346
+ console.log(`
347
+ Keywords: ${s.keywords.total} tracked, ${formatPercent(s.keywords.thresholdedPct, "percent")} privacy-thresholded`);
348
+ console.log(`Place actions: ${s.placeActions.total} CTA(s) \u2014 reservation:${s.placeActions.hasReservationCta ? "yes" : "no"} booking:${s.placeActions.hasBookingCta ? "yes" : "no"} direct-merchant:${s.placeActions.hasDirectMerchantCta ? "yes" : "no"}`);
349
+ console.log(`Lodging API: ${s.lodging.lodgingLocationCount} profile(s), ${s.lodging.populatedLodgingCount} with readable groups, ${s.lodging.emptyLodgingCount} with 0 readable groups`);
350
+ const pc = s.profileCompleteness;
351
+ console.log(`Profile completeness (${pc.locationCount} location(s)): ${pc.withSecondaryCategories} w/ secondary categories (${pc.secondaryCategoryTotal} total), ${pc.withDescription} w/ description, ${pc.withServiceArea} w/ service area, ${pc.withHours} w/ hours, ${pc.withPrimaryPhone} w/ phone` + (pc.permanentlyClosed || pc.temporarilyClosed ? `; closed: ${pc.permanentlyClosed} permanently, ${pc.temporarilyClosed} temporarily` : ""));
352
+ }
353
+ export {
354
+ gbpAccounts,
355
+ gbpAttributes,
356
+ gbpConnect,
357
+ gbpDisconnect,
358
+ gbpKeywords,
359
+ gbpLocationDeselect,
360
+ gbpLocationSelect,
361
+ gbpLocationsDiscover,
362
+ gbpLocationsList,
363
+ gbpLodging,
364
+ gbpMetrics,
365
+ gbpPlaceActions,
366
+ gbpPlaces,
367
+ gbpReviews,
368
+ gbpSummary,
369
+ gbpSync
370
+ };