@canonry/canonry 7.51.5 → 7.52.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/assets/agent-workspace/skills/canonry/references/canonry-cli.md +8 -0
- package/assets/assets/{AccessControls-B5TqDgeq.js → AccessControls-CteIuEGI.js} +1 -1
- package/assets/assets/{AuditHistoryPanel-DgxiizOW.js → AuditHistoryPanel-DqJGiLsf.js} +1 -1
- package/assets/assets/{BacklinksPage-Ay6pdphx.js → BacklinksPage-DotWEPQt.js} +1 -1
- package/assets/assets/{HistoryPage-B11eFH21.js → HistoryPage-aOd198dT.js} +1 -1
- package/assets/assets/MeasurementPropertyPage-CuaKVK8x.js +4 -0
- package/assets/assets/{ProjectPage-DoY0hftd.js → ProjectPage-O9oufMgi.js} +4 -4
- package/assets/assets/{RunsPage-BPBmuQAS.js → RunsPage-DIXMrc-N.js} +1 -1
- package/assets/assets/{SettingsPage-ClKnP8xy.js → SettingsPage-BuGb6AGa.js} +1 -1
- package/assets/assets/SiteHealthSection-CweaKjCo.js +2 -0
- package/assets/assets/TrafficPage-B7MaQalp.js +40 -0
- package/assets/assets/{TrafficSourceDetailPage-DQu0YNt2.js → TrafficSourceDetailPage-BPtjnF9s.js} +1 -1
- package/assets/assets/{card-DYMyvhB9.js → card-DoV-8Txo.js} +1 -1
- package/assets/assets/{extract-error-message-BRM1I_3L.js → extract-error-message-DKQJJlZ-.js} +1 -1
- package/assets/assets/{format-helpers-DrkFERj3.js → format-helpers-BWnMmkiO.js} +1 -1
- package/assets/assets/index-Z63c4PeO.js +39 -0
- package/assets/assets/{query-client-gRFnU4VF.js → query-client-vB35tVTz.js} +1 -1
- package/assets/assets/{react-query-lH82FULK.js → react-query-BI0567qs.js} +1 -1
- package/assets/assets/{react-sigma_core.esm.min-D09H4byP.js → react-sigma_core.esm.min-hGyOC4V_.js} +1 -1
- package/assets/assets/{service-Cx0HSnE9.js → service-c4YvpVKX.js} +1 -1
- package/assets/index.html +6 -6
- package/dist/ads-MREK2AGL.js +544 -0
- package/dist/agent-4RUZ3MC4.js +70 -0
- package/dist/agent-ask-YLTYBEYH.js +139 -0
- package/dist/agent-conversations-QA6IKDGR.js +52 -0
- package/dist/agent-memory-MEQAJOB3.js +92 -0
- package/dist/agent-providers-AXYPDJHL.js +55 -0
- package/dist/agent-transcript-SMNQNYCD.js +77 -0
- package/dist/analytics-4OR64IGV.js +240 -0
- package/dist/apply-CQXCFXAH.js +175 -0
- package/dist/backfill-TMXCNVOB.js +41 -0
- package/dist/backlinks-6KFAQGYV.js +303 -0
- package/dist/bing-HFCACTAC.js +418 -0
- package/dist/bootstrap-SQVQXOJC.js +326 -0
- package/dist/cdp-IACL7EXU.js +162 -0
- package/dist/chunk-4MJYGB56.js +124 -0
- package/dist/chunk-5N6245R7.js +1160 -0
- package/dist/chunk-6BPZHNDC.js +617 -0
- package/dist/chunk-6GO5VVAC.js +15 -0
- package/dist/chunk-7244X3K6.js +609 -0
- package/dist/chunk-7XE2IRBG.js +204 -0
- package/dist/chunk-AOJU5LKX.js +8 -0
- package/dist/chunk-AWCWIQAU.js +2686 -0
- package/dist/{chunk-JBZZEIM2.js → chunk-BBOHY2DQ.js} +2 -13
- package/dist/{chunk-AZFPA7JV.js → chunk-BU3VAG5J.js} +6 -4
- package/dist/{chunk-4YCGZGA3.js → chunk-BYOK6Z4F.js} +2 -2
- package/dist/chunk-DSNSD5J3.js +971 -0
- package/dist/chunk-EGIZNSDA.js +94 -0
- package/dist/chunk-ELCLGWUT.js +83 -0
- package/dist/chunk-FC4XND45.js +38 -0
- package/dist/chunk-GNKOBKPW.js +58 -0
- package/dist/chunk-HEGXGCGL.js +524 -0
- package/dist/chunk-I6KNMZ77.js +232 -0
- package/dist/{chunk-HLVEB5TB.js → chunk-IIOEAJTV.js} +7 -5
- package/dist/chunk-ILDT4LPB.js +1273 -0
- package/dist/chunk-JY3RLZGB.js +30 -0
- package/dist/{chunk-PLYJX67A.js → chunk-K5I45PZI.js} +8084 -13939
- package/dist/chunk-KXAOMTXN.js +1034 -0
- package/dist/chunk-LK2BG6EX.js +145 -0
- package/dist/chunk-MJNUSPO4.js +15 -0
- package/dist/chunk-MKAC7HKH.js +9178 -0
- package/dist/chunk-MLKGABMK.js +9 -0
- package/dist/{chunk-SFMWHPMX.js → chunk-O4RMPA6H.js} +13765 -13737
- package/dist/chunk-O77IBNVO.js +8264 -0
- package/dist/chunk-OFL4PTYU.js +644 -0
- package/dist/chunk-QLPLENDT.js +133 -0
- package/dist/chunk-R2J4SNKF.js +78 -0
- package/dist/{chunk-KEATAHXH.js → chunk-RVUCY4ZV.js} +358 -581
- package/dist/chunk-SNFBJKAW.js +530 -0
- package/dist/chunk-TALC5DX5.js +420 -0
- package/dist/chunk-TSENU4GG.js +18 -0
- package/dist/{chunk-HAHXPJQ5.js → chunk-V5D4XNWV.js} +16 -1684
- package/dist/chunk-VJWDBFSL.js +69 -0
- package/dist/chunk-XEBKF4N5.js +8 -0
- package/dist/chunk-Y4GK7GCV.js +15376 -0
- package/dist/{chunk-A3WSAAQS.js → chunk-YSEC6TIB.js} +7917 -33199
- package/dist/chunk-Z7IUAJOF.js +13 -0
- package/dist/citations-NSBBWRZ4.js +106 -0
- package/dist/{cli-catalog-MO6Z2CIZ.js → cli-catalog-OFWJMNMD.js} +5 -3
- package/dist/cli-commands-WVBL337U.js +19 -0
- package/dist/cli.js +35 -29
- package/dist/competitor-V4OHORBC.js +561 -0
- package/dist/content-RUXRI5IC.js +257 -0
- package/dist/dashboard-JXB2YAQJ.js +71 -0
- package/dist/demo-55ZNUOXU.js +75 -0
- package/dist/{demo-server-GIWDJGJX.js → demo-server-XO7PHM4I.js} +22 -9
- package/dist/discover-JJQ564HS.js +372 -0
- package/dist/discover-eval-KLEKZ6U4.js +282 -0
- package/dist/doctor-JAMQZCMZ.js +152 -0
- package/dist/evidence-YRSB7GFE.js +57 -0
- package/dist/export-cmd-MHML4OYU.js +49 -0
- package/dist/ga-LSXPE2MN.js +911 -0
- package/dist/gbp-RMKMLOC7.js +370 -0
- package/dist/google-JQ4T6JTQ.js +946 -0
- package/dist/google-marketing-J6SEODYC.js +403 -0
- package/dist/health-cmd-MV2JM2C3.js +64 -0
- package/dist/history-SRRH7A2E.js +90 -0
- package/dist/index.d.ts +43 -4
- package/dist/index.js +29 -6
- package/dist/init-ZJZFUERV.js +432 -0
- package/dist/insights-PMMGNWZH.js +63 -0
- package/dist/intelligence-service-KCSU6ZUJ.js +15 -0
- package/dist/keys-TS7NZANS.js +116 -0
- package/dist/keyword-VNCKDUGC.js +164 -0
- package/dist/logs-VH3WOTZJ.js +30 -0
- package/dist/mcp-DG2RROB3.js +14 -0
- package/dist/mcp.js +14 -5
- package/dist/measurement-plan-4T35TUGG.js +42 -0
- package/dist/notify-BWHUSKL7.js +125 -0
- package/dist/organic-evidence-QX4SXXJP.js +53 -0
- package/dist/overview-7IHUTKUV.js +213 -0
- package/dist/project-JXLSWDE2.js +460 -0
- package/dist/query-S75EL25H.js +211 -0
- package/dist/research-KFTV3IP4.js +200 -0
- package/dist/results-export-GTKVBU34.js +27 -0
- package/dist/run-26HDIRHF.js +31 -0
- package/dist/schedule-N6G4SVHQ.js +177 -0
- package/dist/search-MI32EPYM.js +42 -0
- package/dist/serve-XLGE42AG.js +598 -0
- package/dist/session-W5DXWIYM.js +47 -0
- package/dist/settings-T7WI2UVE.js +107 -0
- package/dist/skills-F3WPKPTK.js +33 -0
- package/dist/snapshot-PD3EAVEX.js +538 -0
- package/dist/src-XDUXMJC3.js +316 -0
- package/dist/status-PUH7JFZ4.js +126 -0
- package/dist/support-ARF4HER7.js +24 -0
- package/dist/technical-aeo-AUFWWJIP.js +625 -0
- package/dist/telemetry-XBYT7G2K.js +118 -0
- package/dist/tools-GVHIRWSN.js +41 -0
- package/dist/traffic-B3HW2ZWG.js +1295 -0
- package/dist/users-M5HNQZYI.js +170 -0
- package/dist/visibility-stats-Y7GJKMHN.js +241 -0
- package/dist/wordpress-GCIURYPN.js +600 -0
- package/package.json +1 -1
- package/assets/assets/MeasurementPropertyPage-1UYI7mzP.js +0 -4
- package/assets/assets/SiteHealthSection-PWjKMmEn.js +0 -2
- package/assets/assets/TrafficPage-DkfGiJXR.js +0 -40
- package/assets/assets/index-CG1Jox52.js +0 -39
- package/dist/chunk-4QQYYRHV.js +0 -23082
- package/dist/cli-commands-FOJR3HHU.js +0 -15
- package/dist/intelligence-service-XQCNWAPL.js +0 -9
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createApiClient
|
|
3
|
+
} from "./chunk-V5D4XNWV.js";
|
|
4
|
+
import "./chunk-OFL4PTYU.js";
|
|
5
|
+
import "./chunk-AOJU5LKX.js";
|
|
6
|
+
import {
|
|
7
|
+
CliError,
|
|
8
|
+
isEndpointMissing,
|
|
9
|
+
isMachineFormat
|
|
10
|
+
} from "./chunk-HGMYEDAQ.js";
|
|
11
|
+
import {
|
|
12
|
+
describeError
|
|
13
|
+
} from "./chunk-O4RMPA6H.js";
|
|
14
|
+
import "./chunk-MLKGABMK.js";
|
|
15
|
+
|
|
16
|
+
// src/commands/apply.ts
|
|
17
|
+
import fs from "fs";
|
|
18
|
+
import { parseAllDocuments } from "yaml";
|
|
19
|
+
function previewValue(value) {
|
|
20
|
+
const encoded = JSON.stringify(value);
|
|
21
|
+
return encoded === void 0 ? String(value) : encoded;
|
|
22
|
+
}
|
|
23
|
+
function describeApplyError(error) {
|
|
24
|
+
const message = describeError(error);
|
|
25
|
+
const details = error instanceof CliError ? error.details : void 0;
|
|
26
|
+
const issues = Array.isArray(details?.issues) ? details.issues : [];
|
|
27
|
+
const formatted = issues.flatMap((issue) => {
|
|
28
|
+
if (!issue || typeof issue !== "object") return [];
|
|
29
|
+
const record = issue;
|
|
30
|
+
const path = Array.isArray(record.path) ? record.path.join(".") : typeof record.path === "string" ? record.path : "";
|
|
31
|
+
const issueMessage = typeof record.message === "string" ? record.message : "";
|
|
32
|
+
return path && issueMessage ? [`${path}: ${issueMessage}`] : [];
|
|
33
|
+
});
|
|
34
|
+
return formatted.length > 0 ? `${message} (${formatted.join("; ")})` : message;
|
|
35
|
+
}
|
|
36
|
+
async function applyConfigFile(filePath, options = {}) {
|
|
37
|
+
if (!fs.existsSync(filePath)) {
|
|
38
|
+
throw new Error(`File not found: ${filePath}`);
|
|
39
|
+
}
|
|
40
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
41
|
+
const docs = parseAllDocuments(content);
|
|
42
|
+
const client = createApiClient();
|
|
43
|
+
const errors = [];
|
|
44
|
+
const applied = [];
|
|
45
|
+
const previews = [];
|
|
46
|
+
const dryRun = options.dryRun === true;
|
|
47
|
+
for (let i = 0; i < docs.length; i++) {
|
|
48
|
+
const doc = docs[i];
|
|
49
|
+
if (doc.errors.length > 0) {
|
|
50
|
+
errors.push(`Document ${i + 1}: YAML parse error - ${doc.errors[0]?.message}`);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const config = doc.toJSON();
|
|
54
|
+
if (!config || typeof config !== "object") continue;
|
|
55
|
+
try {
|
|
56
|
+
if (dryRun) previews.push(await client.previewApply(config));
|
|
57
|
+
else applied.push(await client.apply(config));
|
|
58
|
+
} catch (err) {
|
|
59
|
+
if (dryRun && isEndpointMissing(err)) {
|
|
60
|
+
throw new CliError({
|
|
61
|
+
code: "APPLY_PREVIEW_UNSUPPORTED",
|
|
62
|
+
message: "The connected server does not support apply preview.",
|
|
63
|
+
displayMessage: "Apply preview is unavailable on the connected server. Upgrade the server or remove --dry-run.",
|
|
64
|
+
details: { filePath }
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
const msg = describeApplyError(err);
|
|
68
|
+
errors.push(`Document ${i + 1}: ${msg}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return dryRun ? { filePath, previews, errors } : { filePath, applied, errors };
|
|
72
|
+
}
|
|
73
|
+
async function applyConfigs(filePaths, format, options = {}) {
|
|
74
|
+
if (options.dryRun) {
|
|
75
|
+
const files2 = [];
|
|
76
|
+
for (const filePath of filePaths) {
|
|
77
|
+
let result;
|
|
78
|
+
try {
|
|
79
|
+
result = await applyConfigFile(filePath, { dryRun: true });
|
|
80
|
+
} catch (err) {
|
|
81
|
+
if (err instanceof CliError && err.code === "APPLY_PREVIEW_UNSUPPORTED") throw err;
|
|
82
|
+
result = { filePath, previews: [], errors: [describeApplyError(err)] };
|
|
83
|
+
}
|
|
84
|
+
files2.push(result);
|
|
85
|
+
if (!isMachineFormat(format)) {
|
|
86
|
+
console.log(`
|
|
87
|
+
${filePath}`);
|
|
88
|
+
for (const preview of result.previews) {
|
|
89
|
+
console.log(`${preview.action} ${preview.project.name}: ${preview.changed ? "changes detected" : "no changes"}`);
|
|
90
|
+
for (const [field, change] of Object.entries(preview.fields)) {
|
|
91
|
+
console.log(` ~ ${field}: ${previewValue(change.before)} -> ${previewValue(change.after)}`);
|
|
92
|
+
}
|
|
93
|
+
if (!preview.queries.managed) console.log(" queries: not managed by this file");
|
|
94
|
+
else {
|
|
95
|
+
for (const query of preview.queries.added) console.log(` + query: ${query}`);
|
|
96
|
+
for (const query of preview.queries.removed) console.log(` - query: ${query}`);
|
|
97
|
+
console.log(` queries: +${preview.queries.added.length} -${preview.queries.removed.length}`);
|
|
98
|
+
}
|
|
99
|
+
if (!preview.competitors.managed) console.log(" competitors: not managed by this file");
|
|
100
|
+
else {
|
|
101
|
+
for (const domain of preview.competitors.added) console.log(` + competitor: ${domain}`);
|
|
102
|
+
for (const domain of preview.competitors.removed) console.log(` - competitor: ${domain}`);
|
|
103
|
+
for (const change of preview.competitors.aliasChanges) console.log(` ~ competitor aliases ${change.domain}: ${previewValue(change.before)} -> ${previewValue(change.after)}`);
|
|
104
|
+
for (const dropped of preview.competitors.droppedAliases) console.log(` - dropped alias: ${dropped.domain} ${dropped.alias} (${dropped.reason})`);
|
|
105
|
+
console.log(` competitors: +${preview.competitors.added.length} -${preview.competitors.removed.length}`);
|
|
106
|
+
}
|
|
107
|
+
if (!preview.schedule.managed) console.log(" schedule: not managed by this file");
|
|
108
|
+
else console.log(` schedule: ${preview.schedule.action}`);
|
|
109
|
+
if (!preview.notifications.managed) console.log(" notifications: not managed by this file");
|
|
110
|
+
else {
|
|
111
|
+
for (const notification of preview.notifications.added) console.log(` + notification: ${notification.urlHost} (${notification.events.join(", ")})`);
|
|
112
|
+
for (const notification of preview.notifications.removed) console.log(` - notification: ${notification.urlHost} (${notification.events.join(", ")})`);
|
|
113
|
+
for (const notification of preview.notifications.kept) {
|
|
114
|
+
const urlChange = notification.urlChanged ? " (URL changed)" : "";
|
|
115
|
+
console.log(` ~ notification ${notification.urlHost}${urlChange}: ${notification.eventsBefore.join(", ")} -> ${notification.eventsAfter.join(", ")}`);
|
|
116
|
+
}
|
|
117
|
+
console.log(` notifications: +${preview.notifications.added.length} -${preview.notifications.removed.length}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const summary2 = {
|
|
123
|
+
dryRun: true,
|
|
124
|
+
files: files2,
|
|
125
|
+
changedCount: files2.reduce((count, file) => count + file.previews.filter((preview) => preview.changed).length, 0),
|
|
126
|
+
errorCount: files2.reduce((count, file) => count + file.errors.length, 0)
|
|
127
|
+
};
|
|
128
|
+
if (isMachineFormat(format)) console.log(JSON.stringify(summary2, null, 2));
|
|
129
|
+
else if (summary2.errorCount === 0) console.log("No DB writes performed. Re-run without --dry-run to apply.");
|
|
130
|
+
if (summary2.errorCount > 0) {
|
|
131
|
+
throw new CliError({ code: "APPLY_FAILED", message: `${summary2.errorCount} document(s) failed during apply`, displayMessage: files2.flatMap((file) => file.errors).join("\n"), details: summary2 });
|
|
132
|
+
}
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const files = [];
|
|
136
|
+
for (const filePath of filePaths) {
|
|
137
|
+
let result;
|
|
138
|
+
try {
|
|
139
|
+
result = await applyConfigFile(filePath);
|
|
140
|
+
} catch (err) {
|
|
141
|
+
const message = describeApplyError(err);
|
|
142
|
+
result = {
|
|
143
|
+
filePath,
|
|
144
|
+
applied: [],
|
|
145
|
+
errors: [message]
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
files.push(result);
|
|
149
|
+
if (!isMachineFormat(format)) {
|
|
150
|
+
for (const applied of result.applied) {
|
|
151
|
+
console.log(`Applied config for "${applied.name}" (revision ${applied.configRevision})`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const summary = {
|
|
156
|
+
files,
|
|
157
|
+
appliedCount: files.reduce((count, file) => count + file.applied.length, 0),
|
|
158
|
+
errorCount: files.reduce((count, file) => count + file.errors.length, 0)
|
|
159
|
+
};
|
|
160
|
+
if (summary.errorCount > 0) {
|
|
161
|
+
throw new CliError({
|
|
162
|
+
code: "APPLY_FAILED",
|
|
163
|
+
message: `${summary.errorCount} document(s) failed during apply`,
|
|
164
|
+
displayMessage: files.flatMap((file) => file.errors).join("\n"),
|
|
165
|
+
details: summary
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
if (isMachineFormat(format)) {
|
|
169
|
+
console.log(JSON.stringify(summary, null, 2));
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
export {
|
|
173
|
+
applyConfigFile,
|
|
174
|
+
applyConfigs
|
|
175
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
activeQueriesAt,
|
|
3
|
+
backfillAiReferralPaths,
|
|
4
|
+
backfillAiReferralPathsCommand,
|
|
5
|
+
backfillAnswerMentionsCommand,
|
|
6
|
+
backfillAnswerVisibilityCommand,
|
|
7
|
+
backfillInsightsCommand,
|
|
8
|
+
backfillNormalizedPaths,
|
|
9
|
+
backfillNormalizedPathsCommand,
|
|
10
|
+
backfillSnapshotAttributionCommand,
|
|
11
|
+
backfillTrafficClassificationCommand,
|
|
12
|
+
replayQueryAuditLog
|
|
13
|
+
} from "./chunk-DSNSD5J3.js";
|
|
14
|
+
import "./chunk-AWCWIQAU.js";
|
|
15
|
+
import "./chunk-OFL4PTYU.js";
|
|
16
|
+
import "./chunk-HGMYEDAQ.js";
|
|
17
|
+
import "./chunk-FC4XND45.js";
|
|
18
|
+
import {
|
|
19
|
+
backfillProjectAnswerMentions,
|
|
20
|
+
backfillProjectAnswerMentionsInChunks
|
|
21
|
+
} from "./chunk-YSEC6TIB.js";
|
|
22
|
+
import "./chunk-Y4GK7GCV.js";
|
|
23
|
+
import "./chunk-QLPLENDT.js";
|
|
24
|
+
import "./chunk-MKAC7HKH.js";
|
|
25
|
+
import "./chunk-O4RMPA6H.js";
|
|
26
|
+
import "./chunk-MLKGABMK.js";
|
|
27
|
+
export {
|
|
28
|
+
activeQueriesAt,
|
|
29
|
+
backfillAiReferralPaths,
|
|
30
|
+
backfillAiReferralPathsCommand,
|
|
31
|
+
backfillAnswerMentionsCommand,
|
|
32
|
+
backfillAnswerVisibilityCommand,
|
|
33
|
+
backfillInsightsCommand,
|
|
34
|
+
backfillNormalizedPaths,
|
|
35
|
+
backfillNormalizedPathsCommand,
|
|
36
|
+
backfillProjectAnswerMentions,
|
|
37
|
+
backfillProjectAnswerMentionsInChunks,
|
|
38
|
+
backfillSnapshotAttributionCommand,
|
|
39
|
+
backfillTrafficClassificationCommand,
|
|
40
|
+
replayQueryAuditLog
|
|
41
|
+
};
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createApiClient
|
|
3
|
+
} from "./chunk-V5D4XNWV.js";
|
|
4
|
+
import "./chunk-OFL4PTYU.js";
|
|
5
|
+
import {
|
|
6
|
+
emitJsonl
|
|
7
|
+
} from "./chunk-Z7IUAJOF.js";
|
|
8
|
+
import "./chunk-AOJU5LKX.js";
|
|
9
|
+
import {
|
|
10
|
+
CliError,
|
|
11
|
+
isMachineFormat
|
|
12
|
+
} from "./chunk-HGMYEDAQ.js";
|
|
13
|
+
import {
|
|
14
|
+
BacklinkSources,
|
|
15
|
+
CcReleaseSyncStatuses,
|
|
16
|
+
RunStatuses,
|
|
17
|
+
backlinkSourceSchema,
|
|
18
|
+
formatPercent,
|
|
19
|
+
formatRunErrorOneLine
|
|
20
|
+
} from "./chunk-O4RMPA6H.js";
|
|
21
|
+
import "./chunk-MLKGABMK.js";
|
|
22
|
+
|
|
23
|
+
// src/commands/backlinks.ts
|
|
24
|
+
function parseSourceFlag(value) {
|
|
25
|
+
if (value === void 0) return void 0;
|
|
26
|
+
const parsed = backlinkSourceSchema.safeParse(value);
|
|
27
|
+
if (!parsed.success) {
|
|
28
|
+
throw new CliError({
|
|
29
|
+
code: "VALIDATION_ERROR",
|
|
30
|
+
message: `Invalid --source "${value}". Expected one of: ${Object.values(BacklinkSources).join(", ")}.`
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return parsed.data;
|
|
34
|
+
}
|
|
35
|
+
function getClient() {
|
|
36
|
+
return createApiClient();
|
|
37
|
+
}
|
|
38
|
+
function printJson(value) {
|
|
39
|
+
console.log(JSON.stringify(value, null, 2));
|
|
40
|
+
}
|
|
41
|
+
function formatInstallStatus(status) {
|
|
42
|
+
const lines = [];
|
|
43
|
+
lines.push(status.duckdbInstalled ? "DuckDB: installed" : "DuckDB: not installed");
|
|
44
|
+
if (status.duckdbVersion) lines.push(`Version: ${status.duckdbVersion}`);
|
|
45
|
+
lines.push(`Spec: ${status.duckdbSpec}`);
|
|
46
|
+
lines.push(`Plugin: ${status.pluginDir}`);
|
|
47
|
+
if (!status.duckdbInstalled) {
|
|
48
|
+
lines.push("");
|
|
49
|
+
lines.push("Run `canonry backlinks install` to enable backlinks.");
|
|
50
|
+
}
|
|
51
|
+
return lines.join("\n");
|
|
52
|
+
}
|
|
53
|
+
function formatSync(sync) {
|
|
54
|
+
const lines = [];
|
|
55
|
+
lines.push(`Release: ${sync.release}`);
|
|
56
|
+
lines.push(`Status: ${sync.status}`);
|
|
57
|
+
if (sync.phaseDetail) lines.push(`Phase: ${sync.phaseDetail}`);
|
|
58
|
+
if (typeof sync.projectsProcessed === "number") lines.push(`Projects: ${sync.projectsProcessed}`);
|
|
59
|
+
if (typeof sync.domainsDiscovered === "number") lines.push(`Domains: ${sync.domainsDiscovered}`);
|
|
60
|
+
if (sync.error) lines.push(`Error: ${sync.error}`);
|
|
61
|
+
return lines.join("\n");
|
|
62
|
+
}
|
|
63
|
+
function formatSummaryAndDomains(project, response) {
|
|
64
|
+
const lines = [];
|
|
65
|
+
lines.push(`Project: ${project}`);
|
|
66
|
+
lines.push(`Source: ${response.source}`);
|
|
67
|
+
if (!response.summary) {
|
|
68
|
+
const hint = response.source === BacklinkSources["bing-webmaster"] ? "No stored Bing backlink history." : "No ready release \u2014 run `canonry backlinks sync --release <id>` first.";
|
|
69
|
+
lines.push(hint);
|
|
70
|
+
return lines.join("\n");
|
|
71
|
+
}
|
|
72
|
+
const s = response.summary;
|
|
73
|
+
lines.push(`Release: ${s.release}`);
|
|
74
|
+
lines.push(`Target: ${s.targetDomain}`);
|
|
75
|
+
lines.push(`Linking domains: ${s.totalLinkingDomains}`);
|
|
76
|
+
lines.push(`Total hosts: ${s.totalHosts}`);
|
|
77
|
+
lines.push(`Top-10 share: ${formatPercent(Number(s.top10HostsShare))}`);
|
|
78
|
+
if (s.excludedLinkingDomains !== void 0 && s.excludedLinkingDomains > 0) {
|
|
79
|
+
lines.push(`Excluded: ${s.excludedLinkingDomains} crawler/proxy domains (${s.excludedHosts ?? 0} hosts)`);
|
|
80
|
+
}
|
|
81
|
+
if (response.rows.length > 0) {
|
|
82
|
+
lines.push("");
|
|
83
|
+
lines.push(`Top ${response.rows.length} linking domains (of ${response.total}):`);
|
|
84
|
+
for (const r of response.rows) {
|
|
85
|
+
lines.push(` ${String(r.numHosts).padStart(9)} ${r.linkingDomain}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return lines.join("\n");
|
|
89
|
+
}
|
|
90
|
+
function formatCachedReleases(rows) {
|
|
91
|
+
if (rows.length === 0) return "No cached releases.";
|
|
92
|
+
const lines = [];
|
|
93
|
+
lines.push("Release Status Bytes Last used");
|
|
94
|
+
for (const r of rows) {
|
|
95
|
+
const status = (r.syncStatus ?? "unknown").padEnd(12);
|
|
96
|
+
const bytes = String(r.bytes).padStart(12);
|
|
97
|
+
const lastUsed = r.lastUsedAt ?? "-";
|
|
98
|
+
lines.push(`${r.release.padEnd(30)} ${status} ${bytes} ${lastUsed}`);
|
|
99
|
+
}
|
|
100
|
+
return lines.join("\n");
|
|
101
|
+
}
|
|
102
|
+
function formatInstallResult(result) {
|
|
103
|
+
if (result.alreadyPresent) {
|
|
104
|
+
return `DuckDB already installed (${result.version}) at ${result.path}`;
|
|
105
|
+
}
|
|
106
|
+
return `DuckDB installed (${result.version}) at ${result.path}`;
|
|
107
|
+
}
|
|
108
|
+
async function pollSync(id, format) {
|
|
109
|
+
const client = getClient();
|
|
110
|
+
const terminal = /* @__PURE__ */ new Set([
|
|
111
|
+
CcReleaseSyncStatuses.ready,
|
|
112
|
+
CcReleaseSyncStatuses.failed
|
|
113
|
+
]);
|
|
114
|
+
while (true) {
|
|
115
|
+
const syncs = await client.backlinksListSyncs();
|
|
116
|
+
const row = syncs.find((s) => s.id === id);
|
|
117
|
+
if (!row) throw new Error(`Release sync ${id} not found`);
|
|
118
|
+
if (terminal.has(row.status)) return row;
|
|
119
|
+
if (format !== "json") {
|
|
120
|
+
process.stderr.write(`\r${row.status}${row.phaseDetail ? ": " + row.phaseDetail : ""}`.padEnd(80));
|
|
121
|
+
}
|
|
122
|
+
await new Promise((r) => setTimeout(r, 2e3));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
async function pollRun(runId, format) {
|
|
126
|
+
const client = getClient();
|
|
127
|
+
const terminal = /* @__PURE__ */ new Set([
|
|
128
|
+
RunStatuses.completed,
|
|
129
|
+
RunStatuses.failed,
|
|
130
|
+
RunStatuses.partial
|
|
131
|
+
]);
|
|
132
|
+
while (true) {
|
|
133
|
+
const run = await client.getRun(runId);
|
|
134
|
+
if (terminal.has(run.status)) return run;
|
|
135
|
+
if (format !== "json") {
|
|
136
|
+
process.stderr.write(`\r${run.status}`.padEnd(40));
|
|
137
|
+
}
|
|
138
|
+
await new Promise((r) => setTimeout(r, 2e3));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
async function backlinksInstall(opts = {}) {
|
|
142
|
+
const result = await getClient().backlinksInstall();
|
|
143
|
+
if (isMachineFormat(opts.format)) {
|
|
144
|
+
printJson(result);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
console.log(formatInstallResult(result));
|
|
148
|
+
}
|
|
149
|
+
async function backlinksDoctor(opts = {}) {
|
|
150
|
+
const status = await getClient().backlinksStatus();
|
|
151
|
+
if (isMachineFormat(opts.format)) {
|
|
152
|
+
printJson(status);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
console.log(formatInstallStatus(status));
|
|
156
|
+
}
|
|
157
|
+
async function backlinksSync(opts) {
|
|
158
|
+
const client = getClient();
|
|
159
|
+
const sync = await client.backlinksTriggerSync(opts.release);
|
|
160
|
+
const final = opts.wait ? await pollSync(sync.id, opts.format) : sync;
|
|
161
|
+
if (isMachineFormat(opts.format)) {
|
|
162
|
+
printJson(final);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (opts.wait) process.stderr.write("\n");
|
|
166
|
+
if (!opts.release) {
|
|
167
|
+
process.stderr.write(`Auto-discovered release: ${sync.release}
|
|
168
|
+
`);
|
|
169
|
+
}
|
|
170
|
+
console.log(formatSync(final));
|
|
171
|
+
}
|
|
172
|
+
function formatBytesShort(n) {
|
|
173
|
+
if (n === null) return "\u2014";
|
|
174
|
+
if (n >= 1e9) return `${(n / 1e9).toFixed(1)} GB`;
|
|
175
|
+
if (n >= 1e6) return `${(n / 1e6).toFixed(1)} MB`;
|
|
176
|
+
if (n >= 1e3) return `${(n / 1e3).toFixed(1)} KB`;
|
|
177
|
+
return `${n} B`;
|
|
178
|
+
}
|
|
179
|
+
function formatLatestRelease(result) {
|
|
180
|
+
if (!result) return "No release discovered (Common Crawl probe returned no candidates).";
|
|
181
|
+
const lines = [];
|
|
182
|
+
lines.push(`Release: ${result.release}`);
|
|
183
|
+
lines.push(`Vertex: ${result.vertexUrl}`);
|
|
184
|
+
lines.push(` ${formatBytesShort(result.vertexBytes)}`);
|
|
185
|
+
lines.push(`Edges: ${result.edgesUrl}`);
|
|
186
|
+
lines.push(` ${formatBytesShort(result.edgesBytes)}`);
|
|
187
|
+
if (result.lastModified) lines.push(`Last modified: ${result.lastModified}`);
|
|
188
|
+
return lines.join("\n");
|
|
189
|
+
}
|
|
190
|
+
async function backlinksLatestRelease(opts = {}) {
|
|
191
|
+
const result = await getClient().backlinksLatestRelease();
|
|
192
|
+
if (isMachineFormat(opts.format)) {
|
|
193
|
+
printJson(result);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
console.log(formatLatestRelease(result));
|
|
197
|
+
}
|
|
198
|
+
async function backlinksStatus(opts = {}) {
|
|
199
|
+
const sync = await getClient().backlinksLatestSync();
|
|
200
|
+
if (isMachineFormat(opts.format)) {
|
|
201
|
+
printJson(sync);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
if (!sync) {
|
|
205
|
+
console.log("No release syncs yet.");
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
console.log(formatSync(sync));
|
|
209
|
+
}
|
|
210
|
+
async function backlinksList(opts) {
|
|
211
|
+
const client = getClient();
|
|
212
|
+
const response = await client.backlinksDomains(opts.project, {
|
|
213
|
+
limit: opts.limit ?? 50,
|
|
214
|
+
release: opts.release,
|
|
215
|
+
excludeCrawlers: opts.excludeCrawlers,
|
|
216
|
+
source: opts.source
|
|
217
|
+
});
|
|
218
|
+
if (opts.format === "json") {
|
|
219
|
+
printJson(response);
|
|
220
|
+
return;
|
|
221
|
+
} else if (opts.format === "jsonl") {
|
|
222
|
+
const release = response.summary?.release ?? null;
|
|
223
|
+
const targetDomain = response.summary?.targetDomain ?? null;
|
|
224
|
+
emitJsonl(response.rows.map((row) => ({ project: opts.project, release, targetDomain, ...row })));
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
console.log(formatSummaryAndDomains(opts.project, response));
|
|
228
|
+
}
|
|
229
|
+
function formatSourceAvailability(project, res) {
|
|
230
|
+
const lines = [];
|
|
231
|
+
lines.push(`Project: ${res.projectId} Target: ${res.targetDomain}`);
|
|
232
|
+
lines.push("");
|
|
233
|
+
lines.push("Source Connected Data Linking domains Latest window");
|
|
234
|
+
for (const s of res.sources) {
|
|
235
|
+
lines.push(
|
|
236
|
+
`${s.source.padEnd(15)} ${(s.connected ? "yes" : "no").padEnd(10)} ${(s.hasData ? "yes" : "no").padEnd(6)} ${String(s.totalLinkingDomains).padStart(15)} ${s.latestRelease ?? "\u2014"}`
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
if (!res.anyConnected) {
|
|
240
|
+
lines.push("");
|
|
241
|
+
lines.push("No active backlink source is set up. Run `canonry backlinks sync` to download a");
|
|
242
|
+
lines.push(`Common Crawl release, or \`canonry backlinks extract ${project}\` when one is already synced.`);
|
|
243
|
+
}
|
|
244
|
+
return lines.join("\n");
|
|
245
|
+
}
|
|
246
|
+
async function backlinksSources(opts) {
|
|
247
|
+
const res = await getClient().backlinksSources(opts.project, { excludeCrawlers: opts.excludeCrawlers });
|
|
248
|
+
if (opts.format === "json") {
|
|
249
|
+
printJson(res);
|
|
250
|
+
return;
|
|
251
|
+
} else if (opts.format === "jsonl") {
|
|
252
|
+
emitJsonl(res.sources.map((s) => ({ project: opts.project, targetDomain: res.targetDomain, ...s })));
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
console.log(formatSourceAvailability(opts.project, res));
|
|
256
|
+
}
|
|
257
|
+
async function backlinksReleases(opts = {}) {
|
|
258
|
+
const rows = await getClient().backlinksCachedReleases();
|
|
259
|
+
if (opts.format === "json") {
|
|
260
|
+
printJson(rows);
|
|
261
|
+
return;
|
|
262
|
+
} else if (opts.format === "jsonl") {
|
|
263
|
+
emitJsonl(rows);
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
console.log(formatCachedReleases(rows));
|
|
267
|
+
}
|
|
268
|
+
async function backlinksExtract(opts) {
|
|
269
|
+
const client = getClient();
|
|
270
|
+
const run = await client.backlinksExtract(opts.project, opts.release);
|
|
271
|
+
const final = opts.wait ? await pollRun(run.id, opts.format) : run;
|
|
272
|
+
if (isMachineFormat(opts.format)) {
|
|
273
|
+
printJson(final);
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
if (opts.wait) process.stderr.write("\n");
|
|
277
|
+
console.log(`Run ${final.id} (${final.status})${final.error ? " \u2014 " + formatRunErrorOneLine(final.error) : ""}`);
|
|
278
|
+
}
|
|
279
|
+
async function backlinksCachePrune(opts) {
|
|
280
|
+
if (!opts.release) {
|
|
281
|
+
throw new Error("Usage: canonry backlinks cache prune --release <id>");
|
|
282
|
+
}
|
|
283
|
+
const result = await getClient().backlinksPruneCache(opts.release);
|
|
284
|
+
if (isMachineFormat(opts.format)) {
|
|
285
|
+
printJson({ pruned: opts.release, ...result });
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
console.log(`Pruned cache for ${opts.release}`);
|
|
289
|
+
}
|
|
290
|
+
export {
|
|
291
|
+
backlinksCachePrune,
|
|
292
|
+
backlinksDoctor,
|
|
293
|
+
backlinksExtract,
|
|
294
|
+
backlinksInstall,
|
|
295
|
+
backlinksLatestRelease,
|
|
296
|
+
backlinksList,
|
|
297
|
+
backlinksReleases,
|
|
298
|
+
backlinksSources,
|
|
299
|
+
backlinksStatus,
|
|
300
|
+
backlinksSync,
|
|
301
|
+
formatLatestRelease,
|
|
302
|
+
parseSourceFlag
|
|
303
|
+
};
|