@canonry/canonry 7.128.1 → 7.130.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 +3 -3
- package/assets/assets/{AccessControls-QW1RtXqK.js → AccessControls-B1v2FZPP.js} +1 -1
- package/assets/assets/{AgentSetupPage-BFXD__2X.js → AgentSetupPage-DAu_QuMy.js} +1 -1
- package/assets/assets/{AuditHistoryPanel-Cn9Tnnxo.js → AuditHistoryPanel-D_zRZDy7.js} +1 -1
- package/assets/assets/{BacklinksPage-Bv12EM38.js → BacklinksPage-DMZKWIfa.js} +1 -1
- package/assets/assets/{ChartPrimitives-DIAAi1Eq.js → ChartPrimitives-0854i4GX.js} +1 -1
- package/assets/assets/{HistoryPage-Bfn3nVjo.js → HistoryPage-Ci2llyKV.js} +1 -1
- package/assets/assets/{MeasurementPropertyPage-BuVvdugZ.js → MeasurementPropertyPage-Bml0yUnY.js} +1 -1
- package/assets/assets/{ProjectPage-er2nBpgg.js → ProjectPage-DQgRsgAv.js} +3 -3
- package/assets/assets/{RunsPage-wtzz8XIJ.js → RunsPage-BihA-xXz.js} +1 -1
- package/assets/assets/{ServerTrafficSection-oViiKz3j.js → ServerTrafficSection-B4FdP2Yn.js} +3 -3
- package/assets/assets/{SettingsPage-CVL6mVTM.js → SettingsPage-DuheQKDg.js} +1 -1
- package/assets/assets/{ToneBadge-DSr49xyr.js → ToneBadge-CvjNM6Ls.js} +1 -1
- package/assets/assets/{TrafficPage-drK_F4xY.js → TrafficPage-DiG_i3h4.js} +1 -1
- package/assets/assets/{TrafficSourceDetailPage-BdvprrAg.js → TrafficSourceDetailPage-BRlxEdMd.js} +1 -1
- package/assets/assets/{account-context-CRwUczVQ.js → account-context-DBJg_gVV.js} +1 -1
- package/assets/assets/{agent-trust-copy-DduiTpc0.js → agent-trust-copy-DELKG03R.js} +1 -1
- package/assets/assets/{card-DtN_FyC4.js → card-WjxG7OUP.js} +1 -1
- package/assets/assets/{index-Bh4Hdh7M.js → index-DxQlUSXe.js} +3 -3
- package/assets/assets/{preload-helper-CqQPtzI4.js → preload-helper-CkO9IcjS.js} +1 -1
- package/assets/assets/{query-client-DTIKbVqE.js → query-client-BuEx84KK.js} +1 -1
- package/assets/assets/{react-query-Bt-PaSFW.js → react-query-DF9z4xIx.js} +1 -1
- package/assets/assets/{react-sigma_core.esm.min-DLmrzL1s.js → react-sigma_core.esm.min-C1O8GFwj.js} +1 -1
- package/assets/assets/{server-traffic-BApvbZVl.js → server-traffic-s9vqPEWz.js} +1 -1
- package/assets/assets/{service--wSlHsiA.js → service-ZGP6b4iE.js} +1 -1
- package/assets/index.html +9 -9
- package/dist/activity-VIJVNTMK.js +13 -0
- package/dist/{ads-MMIVXXYK.js → ads-PLZRG4BQ.js} +4 -4
- package/dist/{agent-3N6J7AP5.js → agent-RFRMOTLE.js} +8 -8
- package/dist/{agent-ask-V5NBRKWB.js → agent-ask-CB756SUB.js} +4 -4
- package/dist/{agent-conversations-6ZKNOOGK.js → agent-conversations-RRI7T74B.js} +4 -4
- package/dist/{agent-journeys-R3TB7RS6.js → agent-journeys-PLYAVLGB.js} +4 -4
- package/dist/{agent-memory-VKNEXDCF.js → agent-memory-R5Q7DLRZ.js} +4 -4
- package/dist/{agent-providers-HV3LM656.js → agent-providers-HNMGZ7GY.js} +4 -4
- package/dist/{agent-transcript-5B7ZSNQO.js → agent-transcript-N6ZBTF72.js} +4 -4
- package/dist/{analytics-NRYYKO3D.js → analytics-W6B2FQSA.js} +4 -4
- package/dist/{answerability-BMPIAEV4.js → answerability-BDOOPOJF.js} +4 -4
- package/dist/{apply-52VDVYIV.js → apply-LCANKKT5.js} +4 -4
- package/dist/{backfill-QIXONSLO.js → backfill-E3EVDP2O.js} +11 -11
- package/dist/{backlinks-B4IMH5VN.js → backlinks-ZXSN3XNV.js} +4 -4
- package/dist/{bing-G56ZWW4V.js → bing-FMDKRCXN.js} +4 -4
- package/dist/{bootstrap-74GDJENX.js → bootstrap-IHKKYDBO.js} +11 -11
- package/dist/{cdp-LVPKD5WH.js → cdp-ASPLW35M.js} +8 -8
- package/dist/{chunk-2JW5OBUF.js → chunk-37MF5NMW.js} +5 -5
- package/dist/{chunk-V42NDP4R.js → chunk-4ISL4JNK.js} +4 -4
- package/dist/{chunk-YDVXZWWF.js → chunk-4KITKJPN.js} +5 -5
- package/dist/{chunk-F56XOHE2.js → chunk-52J7GFCK.js} +2 -2
- package/dist/{chunk-4PFBSPFE.js → chunk-5U4HCSI6.js} +4 -4
- package/dist/{chunk-HOR6MC5A.js → chunk-76N4UIAF.js} +387 -378
- package/dist/{chunk-RG5E54VU.js → chunk-7PTUA52C.js} +1 -1
- package/dist/{chunk-KIJCFPN4.js → chunk-ALU56PI7.js} +1 -1
- package/dist/{chunk-PGKT42YN.js → chunk-AP54KLWN.js} +1 -1
- package/dist/{chunk-KZKPWHJA.js → chunk-BERGWPA7.js} +5 -5
- package/dist/{chunk-PM23BRHO.js → chunk-C4JM5HJW.js} +1 -1
- package/dist/{chunk-ETTKN2R4.js → chunk-FGEBFVHB.js} +189 -16
- package/dist/{chunk-DOXBK2KF.js → chunk-FI7HVTO6.js} +13 -5
- package/dist/{chunk-3TCXYRME.js → chunk-GVCL4XBU.js} +3 -3
- package/dist/{chunk-4MEWPJ7A.js → chunk-GXLF45FF.js} +8 -8
- package/dist/{chunk-34CPCOQI.js → chunk-HH6FQW5W.js} +3 -3
- package/dist/{chunk-BHWR4PBF.js → chunk-JMJSAK2H.js} +3 -3
- package/dist/{chunk-YW4K74WM.js → chunk-JUZ4ZCOX.js} +9 -6
- package/dist/{chunk-2GA43I45.js → chunk-KQQERQJ2.js} +3 -3
- package/dist/{chunk-ZXX7DMBJ.js → chunk-LJ65QBRP.js} +1 -1
- package/dist/{chunk-AVLWYL4G.js → chunk-MARIMDMX.js} +4 -4
- package/dist/{chunk-STNPEES2.js → chunk-MI575M4K.js} +59 -42
- package/dist/{chunk-A4NXXWFC.js → chunk-MQFH765X.js} +4 -4
- package/dist/{chunk-WCWWHK7P.js → chunk-NUBJTRIV.js} +352 -223
- package/dist/{chunk-SXLHTMXA.js → chunk-NUYKLS2R.js} +2 -2
- package/dist/{chunk-AT2LRVEB.js → chunk-PABT3HDP.js} +2 -2
- package/dist/{chunk-XTIOFTFS.js → chunk-QHQZ2226.js} +1 -1
- package/dist/{chunk-O6RKXY2P.js → chunk-QRIKJT6Y.js} +1 -1
- package/dist/{chunk-5LBYOWQZ.js → chunk-S6X3HHSN.js} +8 -7
- package/dist/{chunk-UXCNYSAB.js → chunk-VEDGR4LZ.js} +2 -2
- package/dist/{chunk-EOZLVWOC.js → chunk-VON4PHNS.js} +4 -4
- package/dist/{chunk-FQFL223H.js → chunk-VRY5M7CR.js} +2 -2
- package/dist/{chunk-I4ITDPK7.js → chunk-WP76HORO.js} +1 -1
- package/dist/{chunk-G7HRY36G.js → chunk-WZPKPA6I.js} +2 -2
- package/dist/{chunk-7G6PCF4H.js → chunk-XVEPR3ZC.js} +13 -9
- package/dist/{chunk-6RE7O724.js → chunk-Z77D43M5.js} +2 -2
- package/dist/{chunk-5JQHOPNE.js → chunk-ZHWJJVCT.js} +2 -2
- package/dist/{chunk-XMPXMQ5X.js → chunk-ZHXPH7WB.js} +1 -1
- package/dist/{citations-CF7AU3KY.js → citations-YWXR3WBL.js} +5 -5
- package/dist/{cli-catalog-U6WE3BU7.js → cli-catalog-RT3QPDLR.js} +4 -4
- package/dist/cli-commands-6J6A5ULK.js +18 -0
- package/dist/cli.js +14 -14
- package/dist/{competitor-Q7L6HJ5O.js → competitor-6ZTA2SZH.js} +4 -4
- package/dist/{content-5KLBWKCB.js → content-DJYGQ5CP.js} +4 -4
- package/dist/{dashboard-KQ3INTH3.js → dashboard-F7NFKQLL.js} +7 -7
- package/dist/{demo-5YEH32AM.js → demo-653PUOIB.js} +3 -3
- package/dist/{demo-server-25MUI3QS.js → demo-server-PVBLYPC5.js} +13 -13
- package/dist/{discover-ENDRNDS6.js → discover-3E7QM2TL.js} +5 -5
- package/dist/{discover-eval-7LJXSHUM.js → discover-eval-NAZPA6PV.js} +4 -4
- package/dist/{doctor-3N7TEK5G.js → doctor-OFFSPNBK.js} +4 -4
- package/dist/{evidence-MAIUNVWP.js → evidence-VOSSML2G.js} +4 -4
- package/dist/{export-cmd-6FJNHZVJ.js → export-cmd-IVACTDSV.js} +4 -4
- package/dist/{ga-HWFGPMTN.js → ga-BX4C7TPI.js} +4 -4
- package/dist/{gbp-KIPU2NE6.js → gbp-SV3J2VG3.js} +4 -4
- package/dist/{google-PKYUSFRS.js → google-J23OD7TR.js} +5 -5
- package/dist/{google-marketing-NHQ6VSOK.js → google-marketing-TTLXMDMD.js} +2 -2
- package/dist/{health-cmd-OGYIMIFA.js → health-cmd-26AHD5XL.js} +5 -5
- package/dist/{history-5NJOUK2A.js → history-QWBRFDQR.js} +4 -4
- package/dist/index.d.ts +96 -96
- package/dist/index.js +26 -26
- package/dist/{init-3JXUT7VJ.js → init-URQ4E3XR.js} +13 -13
- package/dist/{insights-CWTPGOPF.js → insights-PMTHHZ2H.js} +4 -4
- package/dist/intelligence-service-GPA7IGDX.js +15 -0
- package/dist/{journeys-VP7LL2DS.js → journeys-IA7TF753.js} +4 -4
- package/dist/{keys-VBZG6BWU.js → keys-DOHLZTRI.js} +4 -4
- package/dist/{keyword-M7Y4V5MJ.js → keyword-3C2ZU6OB.js} +4 -4
- package/dist/{logs-NTFQR3S6.js → logs-P7VRVZ5N.js} +4 -4
- package/dist/{mcp-DUN57Q6H.js → mcp-6NA62OAY.js} +5 -5
- package/dist/mcp.js +10 -10
- package/dist/{measurement-plan-SGJ7EDVC.js → measurement-plan-RHKCARVE.js} +6 -6
- package/dist/{notify-4NOHQ6G4.js → notify-ODCY7TD3.js} +4 -4
- package/dist/{organic-evidence-5NWLGCGE.js → organic-evidence-76P5AYB3.js} +4 -4
- package/dist/{overview-EQ3BTXHC.js → overview-5T776SEB.js} +7 -7
- package/dist/{project-J43SI3ZT.js → project-ITMGW45M.js} +4 -4
- package/dist/{project-setup-5WA4RAN3.js → project-setup-A3Q6ZX73.js} +4 -4
- package/dist/{query-NMWKGTJ3.js → query-3QAQITK3.js} +4 -4
- package/dist/{research-UU2JB4JH.js → research-R74N3VRL.js} +4 -4
- package/dist/{results-export-RQMNBKXT.js → results-export-23GY45AY.js} +4 -4
- package/dist/{run-JTIH3ET5.js → run-ID66JYBN.js} +6 -6
- package/dist/{schedule-YVKS4ILU.js → schedule-HZ2CRUAL.js} +4 -4
- package/dist/{search-XCX3SAOT.js → search-DM5WWMTE.js} +4 -4
- package/dist/{serve-GOZOQL67.js → serve-3QDHKCHE.js} +27 -27
- package/dist/{session-H6N6B6RR.js → session-ZN3YZI2D.js} +16 -16
- package/dist/{settings-2GDLWIBA.js → settings-SIEKVYD7.js} +4 -4
- package/dist/{sitemaps-22O75HMK.js → sitemaps-M4IAZLK2.js} +4 -4
- package/dist/{skills-NSUS2XV2.js → skills-J6LWTNU5.js} +3 -3
- package/dist/{snapshot-UCITZQFF.js → snapshot-SM3BVX5M.js} +4 -4
- package/dist/{src-OAVTTKVK.js → src-VGZVLOM3.js} +2 -2
- package/dist/{status-KJZSA6KP.js → status-BHJJOUCK.js} +6 -6
- package/dist/{support-PWLEDLQT.js → support-FPXXXJPZ.js} +2 -2
- package/dist/{technical-aeo-P3R7RR52.js → technical-aeo-4DJWWPUN.js} +4 -4
- package/dist/{telemetry-LA72RJFS.js → telemetry-LKVQUSO7.js} +5 -5
- package/dist/{tools-Q6ITEQ4V.js → tools-Y67PVNIJ.js} +12 -12
- package/dist/{traffic-CRLJJFKS.js → traffic-QSZYZHFW.js} +6 -6
- package/dist/{trends-A7ST3WIY.js → trends-WIHWJVJR.js} +4 -4
- package/dist/{users-4H7IS7WC.js → users-HQOPQRTP.js} +4 -4
- package/dist/{visibility-stats-F2RUTMYR.js → visibility-stats-MCY5CAUC.js} +5 -5
- package/dist/{wordpress-EVNS3SAF.js → wordpress-IB5YOJSM.js} +5 -5
- package/package.json +1 -1
- package/dist/activity-IDVGFHBZ.js +0 -13
- package/dist/cli-commands-DFFJYIZF.js +0 -18
- package/dist/intelligence-service-7DFVBFXY.js +0 -15
|
@@ -19,14 +19,14 @@ import {
|
|
|
19
19
|
normalizeTrafficPathPattern,
|
|
20
20
|
sessionizeJourneyRequests,
|
|
21
21
|
verifyRequestSignature
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-7PTUA52C.js";
|
|
23
23
|
import {
|
|
24
24
|
currentOutcomeAttribution,
|
|
25
25
|
getRequestContext,
|
|
26
26
|
registerRequestContext,
|
|
27
27
|
requestAuditIdentity,
|
|
28
28
|
sanitizeRequestContext
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-C4JM5HJW.js";
|
|
30
30
|
import {
|
|
31
31
|
RawEventSampleEventTypes,
|
|
32
32
|
SentimentIdempotencyConflict,
|
|
@@ -191,7 +191,7 @@ import {
|
|
|
191
191
|
userSessions,
|
|
192
192
|
users,
|
|
193
193
|
writeNegativeReviewMaxStars
|
|
194
|
-
} from "./chunk-
|
|
194
|
+
} from "./chunk-FI7HVTO6.js";
|
|
195
195
|
import {
|
|
196
196
|
ADS_ACTIVATE_SCOPE,
|
|
197
197
|
ADS_ACTIVATION_ABSOLUTE_MAX_ENTITIES,
|
|
@@ -360,6 +360,7 @@ import {
|
|
|
360
360
|
MEASUREMENT_PAGE_DEFAULT_LIMIT,
|
|
361
361
|
MEASUREMENT_PAGE_MAX_LIMIT,
|
|
362
362
|
MEASUREMENT_PLAN_V2_SCHEMA_VERSION,
|
|
363
|
+
MEASUREMENT_PLAN_WRITE_SCOPE,
|
|
363
364
|
MEASUREMENT_PORTFOLIO_ANSWER_SOURCES_LIMIT,
|
|
364
365
|
MEASUREMENT_PORTFOLIO_DEFAULT_LIMIT,
|
|
365
366
|
MEASUREMENT_PORTFOLIO_DEFAULT_ROW_EVIDENCE_LIMIT,
|
|
@@ -704,6 +705,7 @@ import {
|
|
|
704
705
|
compileQueryClassifier,
|
|
705
706
|
computeCompetitorOverlap,
|
|
706
707
|
computeDedupSimilarityStats,
|
|
708
|
+
connectSteps,
|
|
707
709
|
contentGapsResponseDtoSchema,
|
|
708
710
|
contentSourcesResponseDtoSchema,
|
|
709
711
|
contentTargetDismissRequestSchema,
|
|
@@ -852,6 +854,7 @@ import {
|
|
|
852
854
|
googleMarketingOAuthConnectRequestSchema,
|
|
853
855
|
googleMarketingOAuthConnectResponseSchema,
|
|
854
856
|
googleMarketingProviderSchema,
|
|
857
|
+
googleOAuthNotConfigured,
|
|
855
858
|
googleOAuthStartResponseSchema,
|
|
856
859
|
gradedReportMonths,
|
|
857
860
|
groupIsoDateRanges,
|
|
@@ -1077,6 +1080,7 @@ import {
|
|
|
1077
1080
|
normalizeTelemetryStatus,
|
|
1078
1081
|
normalizeUrlPath,
|
|
1079
1082
|
normalizeUserName,
|
|
1083
|
+
notConnectedRefusal,
|
|
1080
1084
|
notFound,
|
|
1081
1085
|
notImplemented,
|
|
1082
1086
|
notificationDtoSchema,
|
|
@@ -1251,6 +1255,7 @@ import {
|
|
|
1251
1255
|
seoCompetitorSortSchema,
|
|
1252
1256
|
seoContextSchema,
|
|
1253
1257
|
seoDomainIntelligenceListSchema,
|
|
1258
|
+
seoEstimateUnusable,
|
|
1254
1259
|
seoEvidenceQuerySchema,
|
|
1255
1260
|
seoKeywordGapKindSchema,
|
|
1256
1261
|
seoKeywordGapListSchema,
|
|
@@ -1263,8 +1268,10 @@ import {
|
|
|
1263
1268
|
seoMarketRankingSortSchema,
|
|
1264
1269
|
seoMarketRankingSummaryQuerySchema,
|
|
1265
1270
|
seoMarketRankingSummarySchema,
|
|
1271
|
+
seoNothingToFetch,
|
|
1266
1272
|
seoOperatorTaskSchema,
|
|
1267
1273
|
seoOverviewSchema,
|
|
1274
|
+
seoPlanRevisionStale,
|
|
1268
1275
|
seoProfileInputSchema,
|
|
1269
1276
|
seoProfileListSchema,
|
|
1270
1277
|
seoProfileSchema,
|
|
@@ -1273,6 +1280,7 @@ import {
|
|
|
1273
1280
|
seoReconcileInputSchema,
|
|
1274
1281
|
seoReconcileResultSchema,
|
|
1275
1282
|
seoRefreshIntentInputSchema,
|
|
1283
|
+
seoRunCostCapExceeded,
|
|
1276
1284
|
seoRunDetailSchema,
|
|
1277
1285
|
seoRunListSchema,
|
|
1278
1286
|
seoRunSchema,
|
|
@@ -1286,6 +1294,7 @@ import {
|
|
|
1286
1294
|
serializeRunError,
|
|
1287
1295
|
settingsDtoSchema,
|
|
1288
1296
|
shareOf,
|
|
1297
|
+
shellQuote,
|
|
1289
1298
|
shiftIsoCalendarDate,
|
|
1290
1299
|
simpleMeasurementCompetitorNames,
|
|
1291
1300
|
simpleMeasurementDefinitionSchema,
|
|
@@ -1350,6 +1359,7 @@ import {
|
|
|
1350
1359
|
telemetryStatusDtoSchema,
|
|
1351
1360
|
templateLinkSource,
|
|
1352
1361
|
textContainsAnyBrandAlias,
|
|
1362
|
+
trackedQueriesLockedByRun,
|
|
1353
1363
|
trafficAnalyticsResponseSchema,
|
|
1354
1364
|
trafficBackfillResponseSchema,
|
|
1355
1365
|
trafficConnectCloudRunRequestSchema,
|
|
@@ -1411,7 +1421,7 @@ import {
|
|
|
1411
1421
|
wordpressSchemaDeployResultDtoSchema,
|
|
1412
1422
|
wordpressSchemaStatusResultDtoSchema,
|
|
1413
1423
|
wordpressStatusDtoSchema
|
|
1414
|
-
} from "./chunk-
|
|
1424
|
+
} from "./chunk-FGEBFVHB.js";
|
|
1415
1425
|
|
|
1416
1426
|
// ../api-routes/src/user-session.ts
|
|
1417
1427
|
import crypto2 from "crypto";
|
|
@@ -6408,15 +6418,25 @@ function requireAdminSession(request) {
|
|
|
6408
6418
|
if (!role || role === UserRoles.admin) return;
|
|
6409
6419
|
throw forbidden(ADMIN_ONLY_MESSAGE);
|
|
6410
6420
|
}
|
|
6421
|
+
var PROJECT_BOUND_CREATE_MESSAGE = "This API key is limited to one project, and cannot create projects for this install.";
|
|
6411
6422
|
function requireSecretExportScope(request) {
|
|
6412
6423
|
requireAdminSession(request);
|
|
6413
6424
|
const principal = request.principal;
|
|
6414
6425
|
if (!principal) return;
|
|
6415
6426
|
if (principal.kind === "user") return;
|
|
6416
6427
|
if (principal.kind === "api-key" && principal.scopes.includes(WILDCARD_SCOPE)) return;
|
|
6417
|
-
throw
|
|
6428
|
+
throw narrowKeyRefused();
|
|
6418
6429
|
}
|
|
6419
6430
|
var NARROW_KEY_DENIED_MESSAGE = "This API key is narrower than the install, so it cannot use an administrator surface.";
|
|
6431
|
+
function narrowKeyRefused() {
|
|
6432
|
+
return forbidden(NARROW_KEY_DENIED_MESSAGE);
|
|
6433
|
+
}
|
|
6434
|
+
function projectCreationRefused() {
|
|
6435
|
+
return forbidden(PROJECT_BOUND_CREATE_MESSAGE);
|
|
6436
|
+
}
|
|
6437
|
+
function otherProjectRefused() {
|
|
6438
|
+
return forbidden("This API key is scoped to a different project.");
|
|
6439
|
+
}
|
|
6420
6440
|
function isInstanceAdministrator(request) {
|
|
6421
6441
|
const principal = request.principal;
|
|
6422
6442
|
if (!principal) return !request.authEnforced;
|
|
@@ -6431,12 +6451,19 @@ function requireInstanceAdministrator(request) {
|
|
|
6431
6451
|
const role = principal.kind === "user" ? principal.role : principal.delegatedUser?.role;
|
|
6432
6452
|
if (role && role !== UserRoles.admin) throw forbidden(ADMIN_ONLY_MESSAGE);
|
|
6433
6453
|
if (isInstanceAdministrator(request)) return;
|
|
6434
|
-
throw
|
|
6454
|
+
throw narrowKeyRefused();
|
|
6435
6455
|
}
|
|
6436
6456
|
function requireOperator(request) {
|
|
6437
6457
|
const principal = request.principal;
|
|
6438
6458
|
if (request.operatorAccess === true && principal?.kind === "api-key" && !principal.viaCookie && !principal.projectId && !principal.delegatedUser) return;
|
|
6439
|
-
throw
|
|
6459
|
+
throw operatorAccessRequired();
|
|
6460
|
+
}
|
|
6461
|
+
function operatorAccessRequired() {
|
|
6462
|
+
const remediation = "Contact the host operator.";
|
|
6463
|
+
return forbidden(
|
|
6464
|
+
`This operation needs a host-approved operator API key, which customer accounts and scopes cannot grant. ${remediation}`,
|
|
6465
|
+
{ reason: "operator-access-required", remediation }
|
|
6466
|
+
);
|
|
6440
6467
|
}
|
|
6441
6468
|
function requirePaidReadScope(request, allowedScopes = [ADS_WRITE_SCOPE, ADS_APPROVE_SCOPE, ADS_ACTIVATE_SCOPE], denialMessage = "This API key was not granted access to OpenAI Ads paid reads.") {
|
|
6442
6469
|
if (!assertPrincipalWhenAuthEnforced(request)) return;
|
|
@@ -6479,7 +6506,7 @@ function assertProjectScope(request, projectId) {
|
|
|
6479
6506
|
if (!assertPrincipalWhenAuthEnforced(request)) return;
|
|
6480
6507
|
const scoped = request.apiKey?.projectId;
|
|
6481
6508
|
if (scoped && scoped !== projectId) {
|
|
6482
|
-
throw
|
|
6509
|
+
throw otherProjectRefused();
|
|
6483
6510
|
}
|
|
6484
6511
|
}
|
|
6485
6512
|
function assertNotProjectScoped(request, what) {
|
|
@@ -6642,10 +6669,22 @@ function applyScopedWriteGates(request) {
|
|
|
6642
6669
|
const scopes = principalScopes(request) ?? [];
|
|
6643
6670
|
const restricted = restrictedWriteScopes(scopes);
|
|
6644
6671
|
if (!restricted) return;
|
|
6645
|
-
const
|
|
6646
|
-
if (
|
|
6672
|
+
const operatorOnly = request.routeOptions.config.operatorOnly === true;
|
|
6673
|
+
if (operatorOnly && request.operatorAccess !== true) throw operatorAccessRequired();
|
|
6674
|
+
const declared = request.routeOptions.config.writeScope;
|
|
6675
|
+
if (declared && restricted.includes(declared)) return;
|
|
6647
6676
|
if (restricted.some((scope) => ADS_MUTATION_SCOPES.has(scope)) && isAdsWriteRoute(request.url.split("?")[0])) return;
|
|
6648
|
-
throw
|
|
6677
|
+
throw narrowCredentialRefused(restricted, declared, operatorOnly);
|
|
6678
|
+
}
|
|
6679
|
+
var CALLER_SCOPE_FOR_CARVE_OUT = {
|
|
6680
|
+
[EMBED_QUERIES_WRITE_SCOPE]: MEASUREMENT_PLAN_WRITE_SCOPE
|
|
6681
|
+
};
|
|
6682
|
+
function narrowCredentialRefused(granted, declared, operatorOnly) {
|
|
6683
|
+
const required2 = declared ? CALLER_SCOPE_FOR_CARVE_OUT[declared] ?? declared : void 0;
|
|
6684
|
+
const holds = granted.map((scope) => `"${scope}"`).join(", ");
|
|
6685
|
+
const message = required2 ? `This credential holds only ${holds}, and this operation needs the "${required2}" scope.` : `This credential holds only ${holds}, which does not cover this operation.`;
|
|
6686
|
+
const remediation = operatorOnly ? `Use a host-approved operator key that holds ${required2 ? `"${required2}" or "*"` : '"*" or the scope this operation needs'}. A new key works here only after the host approves it as an operator key.` : required2 ? `Use a key that holds "${required2}" or "*": \`canonry key create --name <name> --scope ${required2}\`.` : 'Use a key that holds "*" (`canonry key create --name <name>` makes one), or one that holds the scope this operation needs.';
|
|
6687
|
+
return forbidden(`${message} ${remediation}`, { reason: "scope-not-granted", grantedScopes: [...granted], requiredScope: required2 ?? null, remediation });
|
|
6649
6688
|
}
|
|
6650
6689
|
var LAST_USED_THROTTLE_MS = 5 * 6e4;
|
|
6651
6690
|
var lastUsedWrittenByDb = /* @__PURE__ */ new WeakMap();
|
|
@@ -6751,24 +6790,24 @@ async function authPlugin(app, opts = {}) {
|
|
|
6751
6790
|
};
|
|
6752
6791
|
request.operatorAccess = !keyArrivedInCookie && !key.projectId && !key.delegatedUserId && opts.operatorApiKeyIds?.includes(key.id) === true;
|
|
6753
6792
|
assertSameOriginWrite(request);
|
|
6793
|
+
if (key.projectId) applyProjectBoundGates(app, request, key.projectId, url);
|
|
6754
6794
|
applyRoleGates(request);
|
|
6755
6795
|
applyScopedWriteGates(request);
|
|
6756
6796
|
if (isReadOnlyKey(scopes) && WRITE_METHODS2.has(request.method) && !request.readSemanticGrant && !isReadOnlyPreview(request) && !isTransportEnvelopeRoute(request)) {
|
|
6757
6797
|
throw forbidden("This API key is read-only and cannot perform write operations.");
|
|
6758
6798
|
}
|
|
6759
6799
|
enforceEmbedProjectTabs(request, opts.embedProjectTabs);
|
|
6760
|
-
if (key.projectId) {
|
|
6761
|
-
const match = url.match(/\/projects\/([^/?#]+)/);
|
|
6762
|
-
if (match) {
|
|
6763
|
-
const projectName = decodeURIComponent(match[1]);
|
|
6764
|
-
const scoped = app.db.select({ id: projects.id }).from(projects).where(eq10(projects.name, projectName)).get();
|
|
6765
|
-
if (!scoped || scoped.id !== key.projectId) {
|
|
6766
|
-
throw forbidden("This API key is scoped to a different project.");
|
|
6767
|
-
}
|
|
6768
|
-
}
|
|
6769
|
-
}
|
|
6770
6800
|
});
|
|
6771
6801
|
}
|
|
6802
|
+
function applyProjectBoundGates(app, request, projectId, url) {
|
|
6803
|
+
const refusal = request.routeOptions.config.projectBoundRefusal;
|
|
6804
|
+
if (refusal) throw refusal();
|
|
6805
|
+
const match = url.match(/\/projects\/([^/?#]+)/);
|
|
6806
|
+
if (!match) return;
|
|
6807
|
+
const projectName = decodeURIComponent(match[1]);
|
|
6808
|
+
const scoped = app.db.select({ id: projects.id }).from(projects).where(eq10(projects.name, projectName)).get();
|
|
6809
|
+
if (!scoped || scoped.id !== projectId) throw otherProjectRefused();
|
|
6810
|
+
}
|
|
6772
6811
|
|
|
6773
6812
|
// ../api-routes/src/mcp-profile.ts
|
|
6774
6813
|
async function mcpProfileRoutes(app, opts) {
|
|
@@ -6973,7 +7012,7 @@ function registerAgentConversationRoutes(app, opts) {
|
|
|
6973
7012
|
const project = resolveProject(db, request.params.name);
|
|
6974
7013
|
return detail(project.id, project.name, request.params.id);
|
|
6975
7014
|
});
|
|
6976
|
-
app.post("/projects/:name/agent/conversations", async (request) => {
|
|
7015
|
+
app.post("/projects/:name/agent/conversations", { config: { projectBoundRefusal: narrowKeyRefused } }, async (request) => {
|
|
6977
7016
|
requireInstanceAdministrator(request);
|
|
6978
7017
|
const project = resolveProject(db, request.params.name);
|
|
6979
7018
|
const parsed = agentConversationCreateSchema.safeParse(request.body);
|
|
@@ -7000,7 +7039,7 @@ function registerAgentConversationRoutes(app, opts) {
|
|
|
7000
7039
|
runtime.reset(project.name);
|
|
7001
7040
|
return detail(project.id, project.name, id);
|
|
7002
7041
|
});
|
|
7003
|
-
app.post("/projects/:name/agent/conversations/:id/resume", async (request) => {
|
|
7042
|
+
app.post("/projects/:name/agent/conversations/:id/resume", { config: { projectBoundRefusal: narrowKeyRefused } }, async (request) => {
|
|
7004
7043
|
requireInstanceAdministrator(request);
|
|
7005
7044
|
const project = resolveProject(db, request.params.name);
|
|
7006
7045
|
const { id } = request.params;
|
|
@@ -7029,7 +7068,7 @@ function registerAgentConversationRoutes(app, opts) {
|
|
|
7029
7068
|
runtime.reset(project.name);
|
|
7030
7069
|
return detail(project.id, project.name, id);
|
|
7031
7070
|
});
|
|
7032
|
-
app.delete("/projects/:name/agent/conversations/:id", async (request) => {
|
|
7071
|
+
app.delete("/projects/:name/agent/conversations/:id", { config: { projectBoundRefusal: narrowKeyRefused } }, async (request) => {
|
|
7033
7072
|
requireInstanceAdministrator(request);
|
|
7034
7073
|
const project = resolveProject(db, request.params.name);
|
|
7035
7074
|
const { id } = request.params;
|
|
@@ -8709,8 +8748,11 @@ function canAdministerSentiment(request) {
|
|
|
8709
8748
|
if (principal.kind === "user") return principal.role === "admin";
|
|
8710
8749
|
return !principal.projectId && principal.scopes.includes("*") && (!principal.delegatedUser || principal.delegatedUser.role === "admin");
|
|
8711
8750
|
}
|
|
8751
|
+
function sentimentAdministratorRequired() {
|
|
8752
|
+
return forbidden("Sentiment configuration and backfill require an install administrator.");
|
|
8753
|
+
}
|
|
8712
8754
|
function requireSentimentAdministrator(request) {
|
|
8713
|
-
if (!canAdministerSentiment(request)) throw
|
|
8755
|
+
if (!canAdministerSentiment(request)) throw sentimentAdministratorRequired();
|
|
8714
8756
|
}
|
|
8715
8757
|
|
|
8716
8758
|
// ../api-routes/src/sentiment-service.ts
|
|
@@ -9803,7 +9845,7 @@ function parse(schema, value) {
|
|
|
9803
9845
|
async function sentimentRoutes(app, options) {
|
|
9804
9846
|
const service = new SentimentService(app.db, options);
|
|
9805
9847
|
app.get("/projects/:name/sentiment/settings", async (request) => service.settings(resolveProject(app.db, request.params.name).id, canAdministerSentiment(request)));
|
|
9806
|
-
app.put("/projects/:name/sentiment/settings", async (request) => {
|
|
9848
|
+
app.put("/projects/:name/sentiment/settings", { config: { projectBoundRefusal: sentimentAdministratorRequired } }, async (request) => {
|
|
9807
9849
|
requireSentimentAdministrator(request);
|
|
9808
9850
|
const project = resolveProject(app.db, request.params.name);
|
|
9809
9851
|
const result = service.configure(project.id, parse(sentimentSettingsUpdateSchema, request.body), request.principal?.delegatedUser?.id ?? request.principal?.id ?? "local");
|
|
@@ -9822,7 +9864,7 @@ async function sentimentRoutes(app, options) {
|
|
|
9822
9864
|
return service.compare(resolveProject(app.db, request.params.name).id, selection, fromRunId, toRunId);
|
|
9823
9865
|
});
|
|
9824
9866
|
app.get("/projects/:name/sentiment/backfill-preview", async (request) => service.preview(resolveProject(app.db, request.params.name).id, parse(sentimentBackfillSelectionSchema, request.query)));
|
|
9825
|
-
app.post("/projects/:name/sentiment/backfills", async (request) => {
|
|
9867
|
+
app.post("/projects/:name/sentiment/backfills", { config: { projectBoundRefusal: sentimentAdministratorRequired } }, async (request) => {
|
|
9826
9868
|
requireSentimentAdministrator(request);
|
|
9827
9869
|
const body = parse(sentimentBackfillRequestSchema, request.body);
|
|
9828
9870
|
const project = resolveProject(app.db, request.params.name);
|
|
@@ -9994,7 +10036,7 @@ function grade(ctx, spec, newestDate) {
|
|
|
9994
10036
|
// longer than any schedule would leave them.
|
|
9995
10037
|
...age >= spec.staleDays && (syncAge === null || syncAge >= NOT_SYNCING_URGENT_DAYS) ? { urgent: true } : {},
|
|
9996
10038
|
summary: `No ${spec.label} sync has completed in ${syncAge === null ? "any recorded run" : `${syncAge} days`}, and stored data ends ${newestDate}.`,
|
|
9997
|
-
remediation: `Run \`${sync}\`, or set a data-refresh schedule: \`canonry schedule set ${projectName} --kind data-refresh --preset daily\`.`,
|
|
10039
|
+
remediation: `Run \`${sync}\`, or set a data-refresh schedule: \`canonry schedule set ${shellQuote(projectName)} --kind data-refresh --preset daily\`.`,
|
|
9998
10040
|
details
|
|
9999
10041
|
};
|
|
10000
10042
|
}
|
|
@@ -10016,7 +10058,7 @@ var GA_SPEC = {
|
|
|
10016
10058
|
agingDays: GA_DATA_AGING_DAYS,
|
|
10017
10059
|
staleDays: GA_DATA_STALE_DAYS,
|
|
10018
10060
|
syncKind: RunKinds["ga-sync"],
|
|
10019
|
-
syncCommand: (name) => `canonry ga sync ${name}`,
|
|
10061
|
+
syncCommand: (name) => `canonry ga sync ${shellQuote(name)}`,
|
|
10020
10062
|
quietExplanation: "GA4 omits days with no sessions, so a genuinely quiet period clears itself on the next visit.",
|
|
10021
10063
|
brokenExplanation: "If the site did have visitors, check that the GA4 tag or its Tag Manager container is still on the live site."
|
|
10022
10064
|
};
|
|
@@ -10027,7 +10069,7 @@ var GSC_SPEC = {
|
|
|
10027
10069
|
staleDays: GSC_DATA_STALE_DAYS,
|
|
10028
10070
|
timeZone: GSC_REPORTING_TIME_ZONE,
|
|
10029
10071
|
syncKind: RunKinds["gsc-sync"],
|
|
10030
|
-
syncCommand: (name) => `canonry google sync ${name}`,
|
|
10072
|
+
syncCommand: (name) => `canonry google sync ${shellQuote(name)}`,
|
|
10031
10073
|
quietExplanation: "Search Console omits days with no impressions and reports two to three days behind, so a quiet period clears itself.",
|
|
10032
10074
|
brokenExplanation: "If the site did have impressions, check that the property still lists this site and the connected account still has access."
|
|
10033
10075
|
};
|
|
@@ -10112,7 +10154,7 @@ var SPECS = [
|
|
|
10112
10154
|
label: "Google Ads",
|
|
10113
10155
|
kind: RunKinds["google-ads-sync"],
|
|
10114
10156
|
connection: googleMarketingConnection("googleAds"),
|
|
10115
|
-
syncCommand: (name) => `canonry google-ads sync ${name}`,
|
|
10157
|
+
syncCommand: (name) => `canonry google-ads sync ${shellQuote(name)}`,
|
|
10116
10158
|
causeCheckIds: ["google-ads.auth.connection", "google-ads.auth.scopes", "google-ads.account.context", "google-ads.api.reachable"]
|
|
10117
10159
|
},
|
|
10118
10160
|
{
|
|
@@ -10120,16 +10162,16 @@ var SPECS = [
|
|
|
10120
10162
|
label: "Google Tag Manager",
|
|
10121
10163
|
kind: RunKinds["gtm-sync"],
|
|
10122
10164
|
connection: googleMarketingConnection("gtm"),
|
|
10123
|
-
syncCommand: (name) => `canonry gtm sync ${name}`,
|
|
10165
|
+
syncCommand: (name) => `canonry gtm sync ${shellQuote(name)}`,
|
|
10124
10166
|
causeCheckIds: ["gtm.auth.connection", "gtm.auth.scopes", "gtm.container.context", "gtm.api.reachable"],
|
|
10125
|
-
notFoundRemediation: (name) => `The selected account or container no longer exists, or this login can no longer see it. List what it can see with \`canonry gtm accounts ${name}\`, then choose again with \`canonry gtm select ${name} --account <id> --container <id>\`.`
|
|
10167
|
+
notFoundRemediation: (name) => `The selected account or container no longer exists, or this login can no longer see it. List what it can see with \`canonry gtm accounts ${shellQuote(name)}\`, then choose again with \`canonry gtm select ${shellQuote(name)} --account <id> --container <id>\`.`
|
|
10126
10168
|
},
|
|
10127
10169
|
{
|
|
10128
10170
|
prefix: "gbp",
|
|
10129
10171
|
label: "Google Business Profile",
|
|
10130
10172
|
kind: RunKinds["gbp-sync"],
|
|
10131
10173
|
connection: gbpConnection,
|
|
10132
|
-
syncCommand: (name) => `canonry gbp sync ${name}`,
|
|
10174
|
+
syncCommand: (name) => `canonry gbp sync ${shellQuote(name)}`,
|
|
10133
10175
|
causeCheckIds: ["gbp.auth.connection", "gbp.auth.scopes", "gbp.account.access", "gbp.api.reachable"],
|
|
10134
10176
|
// `gbp_locations` does not record when a location was selected, so the
|
|
10135
10177
|
// runs from before the selection are recognized by the error they stored.
|
|
@@ -10140,7 +10182,7 @@ var SPECS = [
|
|
|
10140
10182
|
label: "GA4",
|
|
10141
10183
|
kind: RunKinds["ga-sync"],
|
|
10142
10184
|
connection: gaConnection,
|
|
10143
|
-
syncCommand: (name) => `canonry ga sync ${name}`,
|
|
10185
|
+
syncCommand: (name) => `canonry ga sync ${shellQuote(name)}`,
|
|
10144
10186
|
causeCheckIds: ["ga.auth.connection", "ga.api.reachable"]
|
|
10145
10187
|
},
|
|
10146
10188
|
{
|
|
@@ -10148,7 +10190,7 @@ var SPECS = [
|
|
|
10148
10190
|
label: "Bing data",
|
|
10149
10191
|
kind: RunKinds["bing-sync"],
|
|
10150
10192
|
connection: bingConnection,
|
|
10151
|
-
syncCommand: (name) => `canonry bing sync ${name}`,
|
|
10193
|
+
syncCommand: (name) => `canonry bing sync ${shellQuote(name)}`,
|
|
10152
10194
|
causeCheckIds: ["bing.auth.connection", "bing.auth.site-access"]
|
|
10153
10195
|
},
|
|
10154
10196
|
{
|
|
@@ -10156,7 +10198,7 @@ var SPECS = [
|
|
|
10156
10198
|
label: "Search Console",
|
|
10157
10199
|
kind: RunKinds["gsc-sync"],
|
|
10158
10200
|
connection: gscConnection,
|
|
10159
|
-
syncCommand: (name) => `canonry google sync ${name}`,
|
|
10201
|
+
syncCommand: (name) => `canonry google sync ${shellQuote(name)}`,
|
|
10160
10202
|
causeCheckIds: ["google.auth.connection", "google.auth.property-access", "google.auth.scopes", "gsc.api.reachable"]
|
|
10161
10203
|
}
|
|
10162
10204
|
];
|
|
@@ -10308,9 +10350,9 @@ function recentDataRemediation(sources, lastSyncedAt) {
|
|
|
10308
10350
|
return "Confirm the Cloudflare Worker is deployed on the zone route and forwarding to canonry; reconnect Cloudflare to regenerate the Worker if needed.";
|
|
10309
10351
|
}
|
|
10310
10352
|
if (hasCloudflare && hasPullSource) {
|
|
10311
|
-
return "Run `canonry traffic sync <project>` for pull-based
|
|
10353
|
+
return "Run `canonry traffic sync <project> --source <id>` for each pull-based source, and confirm the Cloudflare Worker is deployed on the zone route and forwarding to canonry.";
|
|
10312
10354
|
}
|
|
10313
|
-
return lastSyncedAt ? `Last sync: ${lastSyncedAt}. Run \`canonry traffic sync <project>\` to refresh, or check the source connection.` : "Run `canonry traffic sync <project>` to pull recent events.";
|
|
10355
|
+
return lastSyncedAt ? `Last sync: ${lastSyncedAt}. Run \`canonry traffic sync <project> --source <id>\` to refresh, or check the source connection.` : "Run `canonry traffic sync <project> --source <id>` to pull recent events.";
|
|
10314
10356
|
}
|
|
10315
10357
|
function skippedNoProject() {
|
|
10316
10358
|
return {
|
|
@@ -10349,7 +10391,10 @@ function unrecoveredAlert(projectName, unrecovered) {
|
|
|
10349
10391
|
const through = unrecovered.map((m) => m.skippedThroughAt).sort().at(-1);
|
|
10350
10392
|
const day = formatCalendarDay(through.slice(0, 10));
|
|
10351
10393
|
const wordpress = unrecovered.filter((m) => m.sourceType === TrafficSourceTypes.wordpress);
|
|
10352
|
-
const
|
|
10394
|
+
const project = shellQuote(projectName);
|
|
10395
|
+
const declare = (source) => `\`cnry traffic declare-gap ${project} --source ${source}\``;
|
|
10396
|
+
const backfill = (source) => `\`cnry traffic backfill ${project} --source ${source} --days N\``;
|
|
10397
|
+
const next = unrecovered.length === 1 ? wordpress.length === 1 ? `Record it as lost with ${declare(unrecovered[0].id)}.` : `Backfill it with ${backfill(unrecovered[0].id)}.` : wordpress.length === unrecovered.length ? `Record each as lost with ${declare("<id>")}.` : wordpress.length === 0 ? `Backfill each with ${backfill("<id>")}.` : `Record each WordPress gap with ${declare("<id>")}, and backfill the others with ${backfill("<id>")}.`;
|
|
10353
10398
|
const names = unrecovered.map((m) => m.displayName).join(", ");
|
|
10354
10399
|
return {
|
|
10355
10400
|
label: `Traffic gap before ${day}`,
|
|
@@ -10358,7 +10403,8 @@ function unrecoveredAlert(projectName, unrecovered) {
|
|
|
10358
10403
|
};
|
|
10359
10404
|
}
|
|
10360
10405
|
var CREDENTIALS_REJECTED = /\bHTTP 40[13]\b/;
|
|
10361
|
-
function failingSourceNext(
|
|
10406
|
+
function failingSourceNext(projectName, failing) {
|
|
10407
|
+
const project = shellQuote(projectName);
|
|
10362
10408
|
if (failing.some((s) => s.lastError && CREDENTIALS_REJECTED.test(s.lastError))) {
|
|
10363
10409
|
return `The provider rejected the saved token or key, so every sync will fail until it is replaced. Reconnect the source with a new one (\`cnry traffic sources ${project}\` shows its settings), then run a backfill for the missing days before the provider stops keeping those logs.`;
|
|
10364
10410
|
}
|
|
@@ -10913,13 +10959,13 @@ function queueResidualCause(stopReasons, projectName, sourceId) {
|
|
|
10913
10959
|
return {
|
|
10914
10960
|
cause: "The last sync failed before the Queue was empty.",
|
|
10915
10961
|
remediation: `Fix the sync error, then run \`canonry traffic sync <project> --source <id>\`. ${readRuns}`,
|
|
10916
|
-
next: `Fix the sync error, then run \`cnry traffic sync ${projectName} --source ${sourceId ?? "<id>"}\`.`
|
|
10962
|
+
next: `Fix the sync error, then run \`cnry traffic sync ${shellQuote(projectName)} --source ${sourceId ?? "<id>"}\`.`
|
|
10917
10963
|
};
|
|
10918
10964
|
}
|
|
10919
10965
|
return {
|
|
10920
10966
|
cause: "The last sync stopped before the Queue was empty.",
|
|
10921
10967
|
remediation: `${readRuns} If it hit its time limit, shorten the traffic-sync schedule interval or raise \`CANONRY_CLOUDFLARE_QUEUE_SYNC_DEADLINE_MS\` (default 4 minutes per sync).`,
|
|
10922
|
-
next: `See why the last sync stopped with \`cnry runs ${projectName} --kind traffic-sync\`.`
|
|
10968
|
+
next: `See why the last sync stopped with \`cnry runs ${shellQuote(projectName)} --kind traffic-sync\`.`
|
|
10923
10969
|
};
|
|
10924
10970
|
}
|
|
10925
10971
|
var queueBacklogCheck = {
|
|
@@ -10998,11 +11044,12 @@ var queueBacklogCheck = {
|
|
|
10998
11044
|
}
|
|
10999
11045
|
};
|
|
11000
11046
|
function cloudflareReconnectCommand(projectName, source) {
|
|
11001
|
-
const
|
|
11047
|
+
const project = shellQuote(projectName);
|
|
11048
|
+
const base = `cnry traffic connect cloudflare ${project}`;
|
|
11002
11049
|
if (!isCloudflareQueuePull(source)) return `\`${base}\``;
|
|
11003
11050
|
const parsed = cloudflareQueuePullTrafficSourceConfigSchema.safeParse(source.configJson);
|
|
11004
11051
|
if (!parsed.success) {
|
|
11005
|
-
return `\`${base} --delivery-mode queue-pull\` with its Queue options (\`cnry traffic sources ${
|
|
11052
|
+
return `\`${base} --delivery-mode queue-pull\` with its Queue options (\`cnry traffic sources ${project}\`)`;
|
|
11006
11053
|
}
|
|
11007
11054
|
const config = parsed.data;
|
|
11008
11055
|
const options = [
|
|
@@ -13160,7 +13207,7 @@ function previewManualRun(db, params) {
|
|
|
13160
13207
|
function providersFailingError(projectName, failures) {
|
|
13161
13208
|
const named = Object.entries(failures.providers).map(([provider, code]) => `${provider} (${code})`).join(", ");
|
|
13162
13209
|
return providersFailing(
|
|
13163
|
-
`Not starting a run for '${projectName}': every provider it would call failed on its account (a rejected key, denied access, or no credit left) in each of its last ${failures.consecutiveRuns} runs: ${named}. Fix it in the provider's console or settings. Saving a new key, model or endpoint for the provider (canonry settings provider <name>) lets the next run through; otherwise one run is let through after ${failures.retryAfter}. Pass force (canonry run --force)
|
|
13210
|
+
`Not starting a run for '${projectName}': every provider it would call failed on its account (a rejected key, denied access, or no credit left) in each of its last ${failures.consecutiveRuns} runs: ${named}. Fix it in the provider's console or settings. Saving a new key, model or endpoint for the provider (\`canonry settings provider <name> --api-key <key>\`, or \`--model <model>\` or \`--base-url <url>\` in place of the key) lets the next run through; otherwise one run is let through after ${failures.retryAfter}. Pass force to run now (\`canonry run ${shellQuote(projectName)} --force\`).`,
|
|
13164
13211
|
{ projectName, ...failures }
|
|
13165
13212
|
);
|
|
13166
13213
|
}
|
|
@@ -13494,7 +13541,7 @@ var adsConnectionCheck = {
|
|
|
13494
13541
|
status: CheckStatuses.fail,
|
|
13495
13542
|
code: "ads.auth.missing-key",
|
|
13496
13543
|
summary: "An ads connection row exists but no SDK key is stored in the local config.",
|
|
13497
|
-
remediation: `Re-run \`canonry ads connect ${ctx.project.name} --api-key <sdk-key>\` to restore the credential.`,
|
|
13544
|
+
remediation: `Re-run \`canonry ads connect ${shellQuote(ctx.project.name)} --api-key <sdk-key>\` to restore the credential.`,
|
|
13498
13545
|
details: { adAccountId: row.adAccountId }
|
|
13499
13546
|
};
|
|
13500
13547
|
}
|
|
@@ -13535,7 +13582,7 @@ var adsRecentSyncCheck = {
|
|
|
13535
13582
|
status: CheckStatuses.warn,
|
|
13536
13583
|
code: "ads.data.never-synced",
|
|
13537
13584
|
summary: "The connected ad account has never been synced.",
|
|
13538
|
-
remediation: `Run \`canonry ads sync ${ctx.project.name}\` (and schedule it: \`canonry schedule set ${ctx.project.name} --kind ads-sync --preset daily\`).`
|
|
13585
|
+
remediation: `Run \`canonry ads sync ${shellQuote(ctx.project.name)}\` (and schedule it: \`canonry schedule set ${shellQuote(ctx.project.name)} --kind ads-sync --preset daily\`).`
|
|
13539
13586
|
};
|
|
13540
13587
|
}
|
|
13541
13588
|
const syncedAtMs = new Date(row.lastSyncedAt).getTime();
|
|
@@ -13546,7 +13593,7 @@ var adsRecentSyncCheck = {
|
|
|
13546
13593
|
status: CheckStatuses.fail,
|
|
13547
13594
|
code: "ads.data.stale",
|
|
13548
13595
|
summary: `Last ads sync was ${Math.round(ageDays2)} days ago (> ${ADS_RECENT_SYNC_FAIL_DAYS}d).`,
|
|
13549
|
-
remediation: `Run \`canonry ads sync ${ctx.project.name}\` and check the ads-sync schedule.`,
|
|
13596
|
+
remediation: `Run \`canonry ads sync ${shellQuote(ctx.project.name)}\` and check the ads-sync schedule.`,
|
|
13550
13597
|
details
|
|
13551
13598
|
};
|
|
13552
13599
|
}
|
|
@@ -13555,7 +13602,7 @@ var adsRecentSyncCheck = {
|
|
|
13555
13602
|
status: CheckStatuses.warn,
|
|
13556
13603
|
code: "ads.data.aging",
|
|
13557
13604
|
summary: `Last ads sync was ${Math.round(ageDays2)} days ago (> ${ADS_RECENT_SYNC_WARN_DAYS}d).`,
|
|
13558
|
-
remediation: `Schedule daily syncs: \`canonry schedule set ${ctx.project.name} --kind ads-sync --preset daily\`.`,
|
|
13605
|
+
remediation: `Schedule daily syncs: \`canonry schedule set ${shellQuote(ctx.project.name)} --kind ads-sync --preset daily\`.`,
|
|
13559
13606
|
details
|
|
13560
13607
|
};
|
|
13561
13608
|
}
|
|
@@ -14826,7 +14873,7 @@ async function resolveGbpToken(ctx) {
|
|
|
14826
14873
|
status: CheckStatuses.skipped,
|
|
14827
14874
|
code: "gbp.auth.not-connected",
|
|
14828
14875
|
summary: `${ctx.project.name} has not connected Google Business Profile.`,
|
|
14829
|
-
remediation: `Optional: run \`canonry gbp connect ${ctx.project.name}\` to track a Business Profile.`
|
|
14876
|
+
remediation: `Optional: run \`canonry gbp connect ${shellQuote(ctx.project.name)}\` to track a Business Profile.`
|
|
14830
14877
|
}
|
|
14831
14878
|
};
|
|
14832
14879
|
}
|
|
@@ -14849,11 +14896,11 @@ async function resolveGbpToken(ctx) {
|
|
|
14849
14896
|
status: CheckStatuses.fail,
|
|
14850
14897
|
code: "gbp.auth.no-connection",
|
|
14851
14898
|
summary: `No Google Business Profile connection for ${ctx.project.canonicalDomain}, but ${ctx.project.name} still has selected locations.`,
|
|
14852
|
-
remediation: `Run \`canonry gbp connect ${ctx.project.name}\` to authorize.`,
|
|
14899
|
+
remediation: `Run \`canonry gbp connect ${shellQuote(ctx.project.name)}\` to authorize.`,
|
|
14853
14900
|
alert: {
|
|
14854
14901
|
label: "Business Profile not connected",
|
|
14855
14902
|
line: `Business Profile isn't connected for ${ctx.project.canonicalDomain}, but locations are still selected.`,
|
|
14856
|
-
next: `Connect it with \`cnry gbp connect ${ctx.project.name}\`, or deselect its locations.`
|
|
14903
|
+
next: `Connect it with \`cnry gbp connect ${shellQuote(ctx.project.name)}\`, or deselect its locations.`
|
|
14857
14904
|
}
|
|
14858
14905
|
}
|
|
14859
14906
|
};
|
|
@@ -14865,7 +14912,7 @@ async function resolveGbpToken(ctx) {
|
|
|
14865
14912
|
status: CheckStatuses.fail,
|
|
14866
14913
|
code: "gbp.auth.no-refresh-token",
|
|
14867
14914
|
summary: "GBP connection exists but has no refresh token stored.",
|
|
14868
|
-
remediation: `Run \`canonry gbp connect ${ctx.project.name}\` to re-authorize and capture a refresh token.`,
|
|
14915
|
+
remediation: `Run \`canonry gbp connect ${shellQuote(ctx.project.name)}\` to re-authorize and capture a refresh token.`,
|
|
14869
14916
|
details: { domain: conn.domain }
|
|
14870
14917
|
}
|
|
14871
14918
|
};
|
|
@@ -14899,7 +14946,7 @@ async function resolveGbpToken(ctx) {
|
|
|
14899
14946
|
status: CheckStatuses.fail,
|
|
14900
14947
|
code: "gbp.auth.refresh-failed",
|
|
14901
14948
|
summary: "Refresh token rejected by Google.",
|
|
14902
|
-
remediation: `Run \`canonry gbp connect ${ctx.project.name}\` to re-authorize. Refresh tokens are revoked if the user changes their password or the OAuth client is rotated.`,
|
|
14949
|
+
remediation: `Run \`canonry gbp connect ${shellQuote(ctx.project.name)}\` to re-authorize. Refresh tokens are revoked if the user changes their password or the OAuth client is rotated.`,
|
|
14903
14950
|
details: { domain: conn.domain, error: message }
|
|
14904
14951
|
}
|
|
14905
14952
|
};
|
|
@@ -14953,7 +15000,7 @@ var scopesCheck2 = {
|
|
|
14953
15000
|
status: CheckStatuses.fail,
|
|
14954
15001
|
code: "gbp.auth.required-scope-missing",
|
|
14955
15002
|
summary: "The required business.manage scope is not granted.",
|
|
14956
|
-
remediation: `Reconnect to grant the scope: \`canonry gbp connect ${ctx.project.name}\`.`,
|
|
15003
|
+
remediation: `Reconnect to grant the scope: \`canonry gbp connect ${shellQuote(ctx.project.name)}\`.`,
|
|
14957
15004
|
details: { granted: [...granted], missing: [GBP_SCOPE] }
|
|
14958
15005
|
};
|
|
14959
15006
|
}
|
|
@@ -14981,7 +15028,7 @@ var accountAccessCheck = {
|
|
|
14981
15028
|
status: CheckStatuses.fail,
|
|
14982
15029
|
code: "gbp.account.none-selected",
|
|
14983
15030
|
summary: "GBP connection has no account selected for this project.",
|
|
14984
|
-
remediation: `Run \`canonry gbp locations discover ${ctx.project.name} --account accounts/<id>\` to pick the account this project tracks.`
|
|
15031
|
+
remediation: `Run \`canonry gbp locations discover ${shellQuote(ctx.project.name)} --account accounts/<id>\` to pick the account this project tracks.`
|
|
14985
15032
|
};
|
|
14986
15033
|
}
|
|
14987
15034
|
const resolved = await resolveGbpToken(ctx);
|
|
@@ -15003,7 +15050,7 @@ var accountAccessCheck = {
|
|
|
15003
15050
|
status: CheckStatuses.fail,
|
|
15004
15051
|
code: "gbp.account.scope-insufficient",
|
|
15005
15052
|
summary: "The OAuth token is missing the business.manage scope.",
|
|
15006
|
-
remediation: `Reconnect with the business.manage scope: \`canonry gbp connect ${ctx.project.name}\`.`,
|
|
15053
|
+
remediation: `Reconnect with the business.manage scope: \`canonry gbp connect ${shellQuote(ctx.project.name)}\`.`,
|
|
15007
15054
|
details: { reason: err.reason }
|
|
15008
15055
|
};
|
|
15009
15056
|
}
|
|
@@ -15049,7 +15096,7 @@ var accountAccessCheck = {
|
|
|
15049
15096
|
status: CheckStatuses.fail,
|
|
15050
15097
|
code: "gbp.account.not-accessible",
|
|
15051
15098
|
summary: `Tracked account "${conn.gbpAccountName}" is not in the authorized user's accessible accounts.`,
|
|
15052
|
-
remediation: `Either reconnect with a Google account that manages "${conn.gbpAccountName}", or re-point the project: \`canonry gbp locations discover ${ctx.project.name} --account <accounts/id> --switch-account\`.`,
|
|
15099
|
+
remediation: `Either reconnect with a Google account that manages "${conn.gbpAccountName}", or re-point the project: \`canonry gbp locations discover ${shellQuote(ctx.project.name)} --account <accounts/id> --switch-account\`.`,
|
|
15053
15100
|
details: {
|
|
15054
15101
|
trackedAccount: conn.gbpAccountName,
|
|
15055
15102
|
accessibleAccounts: accounts.map((a) => a.name)
|
|
@@ -15087,7 +15134,7 @@ var recentSyncCheck = {
|
|
|
15087
15134
|
status: CheckStatuses.warn,
|
|
15088
15135
|
code: "gbp.data.never-synced",
|
|
15089
15136
|
summary: `${selected.length} selected location(s) have never been synced.`,
|
|
15090
|
-
remediation: `Run \`canonry gbp sync ${ctx.project.name}\` to pull performance + local signals.`,
|
|
15137
|
+
remediation: `Run \`canonry gbp sync ${shellQuote(ctx.project.name)}\` to pull performance + local signals.`,
|
|
15091
15138
|
details: { selectedLocations: selected.length }
|
|
15092
15139
|
};
|
|
15093
15140
|
}
|
|
@@ -15099,7 +15146,7 @@ var recentSyncCheck = {
|
|
|
15099
15146
|
status: CheckStatuses.fail,
|
|
15100
15147
|
code: "gbp.data.stale",
|
|
15101
15148
|
summary: `Most recent GBP sync was ${Math.round(ageDays2)} days ago (> ${RECENT_SYNC_FAIL_DAYS}d).`,
|
|
15102
|
-
remediation: `Run \`canonry gbp sync ${ctx.project.name}\` or set a gbp-sync schedule.`,
|
|
15149
|
+
remediation: `Run \`canonry gbp sync ${shellQuote(ctx.project.name)}\` or set a gbp-sync schedule.`,
|
|
15103
15150
|
details
|
|
15104
15151
|
};
|
|
15105
15152
|
}
|
|
@@ -15108,7 +15155,7 @@ var recentSyncCheck = {
|
|
|
15108
15155
|
status: CheckStatuses.warn,
|
|
15109
15156
|
code: "gbp.data.aging",
|
|
15110
15157
|
summary: `Most recent GBP sync was ${Math.round(ageDays2)} days ago (> ${RECENT_SYNC_WARN_DAYS}d).`,
|
|
15111
|
-
remediation: `Run \`canonry gbp sync ${ctx.project.name}\` or set a gbp-sync schedule to keep data fresh.`,
|
|
15158
|
+
remediation: `Run \`canonry gbp sync ${shellQuote(ctx.project.name)}\` or set a gbp-sync schedule to keep data fresh.`,
|
|
15112
15159
|
details
|
|
15113
15160
|
};
|
|
15114
15161
|
}
|
|
@@ -15386,11 +15433,11 @@ var ANSWERABILITY_NEXT_STEPS = {
|
|
|
15386
15433
|
refresh: () => `Sync Bing (canonry_bing_sync, ${APPROVAL}).`
|
|
15387
15434
|
},
|
|
15388
15435
|
"server-traffic": {
|
|
15389
|
-
setUp: (project) => `Connect a traffic source (canonry_traffic_connect_cloud_run, canonry_traffic_connect_vercel or canonry_traffic_connect_wordpress; Cloudflare only from the CLI: canonry traffic connect cloudflare ${project}).`,
|
|
15436
|
+
setUp: (project) => `Connect a traffic source (canonry_traffic_connect_cloud_run, canonry_traffic_connect_vercel or canonry_traffic_connect_wordpress; Cloudflare only from the CLI: \`canonry traffic connect cloudflare ${shellQuote(project)} --zone-id <id> --account-id <id>\`).`,
|
|
15390
15437
|
refresh: () => `Sync the source (canonry_traffic_sync, ${APPROVAL}).`
|
|
15391
15438
|
},
|
|
15392
15439
|
"business-profile": {
|
|
15393
|
-
setUp: (project) => `Connect Business Profile (canonry gbp connect ${project}), then select locations (canonry_gbp_location_select).`,
|
|
15440
|
+
setUp: (project) => `Connect Business Profile (\`canonry gbp connect ${shellQuote(project)}\`), then select locations (canonry_gbp_location_select).`,
|
|
15394
15441
|
refresh: () => `Sync Business Profile (canonry_gbp_sync, ${APPROVAL}).`
|
|
15395
15442
|
},
|
|
15396
15443
|
"agent-readiness": {
|
|
@@ -15402,19 +15449,19 @@ var ANSWERABILITY_NEXT_STEPS = {
|
|
|
15402
15449
|
refresh: () => "Refresh SEO evidence (canonry_seo_refresh_intent, then canonry_seo_sync; paid, " + APPROVAL + ")."
|
|
15403
15450
|
},
|
|
15404
15451
|
backlinks: {
|
|
15405
|
-
setUp: () => "Sync a Common Crawl release for the install (canonry backlinks sync
|
|
15406
|
-
refresh: (project) => `Extract this project's backlinks (canonry backlinks extract ${project}).`
|
|
15452
|
+
setUp: () => "Sync a Common Crawl release for the install (`canonry backlinks sync`, a large download).",
|
|
15453
|
+
refresh: (project) => `Extract this project's backlinks (\`canonry backlinks extract ${shellQuote(project)}\`).`
|
|
15407
15454
|
},
|
|
15408
15455
|
"chatgpt-ads": {
|
|
15409
|
-
setUp: (project) => `Connect the ad account (canonry ads connect ${project}).`,
|
|
15456
|
+
setUp: (project) => `Connect the ad account with its Ads Manager SDK key (\`canonry ads connect ${shellQuote(project)} --api-key <sdk-key>\`).`,
|
|
15410
15457
|
refresh: () => `Sync ads (canonry_ads_sync, ${APPROVAL}).`
|
|
15411
15458
|
},
|
|
15412
15459
|
"google-ads": {
|
|
15413
|
-
setUp: (project) => `Connect Google Ads on the project's Conversions page, then select a customer (canonry google-ads select ${project}).`,
|
|
15460
|
+
setUp: (project) => `Connect Google Ads on the project's Conversions page, then select a customer (\`canonry google-ads select ${shellQuote(project)} --customer <customer-id>\`).`,
|
|
15414
15461
|
refresh: () => `Sync Google Ads (canonry_google_ads_sync, ${APPROVAL}).`
|
|
15415
15462
|
},
|
|
15416
15463
|
"tag-manager": {
|
|
15417
|
-
setUp: (project) => `Connect Tag Manager on the project's Conversions page, then select a container (canonry gtm select ${project}).`,
|
|
15464
|
+
setUp: (project) => `Connect Tag Manager on the project's Conversions page, then select a container (\`canonry gtm select ${shellQuote(project)} --account <account-id> --container <container-id>\`).`,
|
|
15418
15465
|
refresh: () => `Sync Tag Manager (canonry_gtm_sync, ${APPROVAL}).`
|
|
15419
15466
|
}
|
|
15420
15467
|
};
|
|
@@ -16919,7 +16966,7 @@ function unrecognizedAgentView(payload) {
|
|
|
16919
16966
|
title: single ? `${project.name}: new bot, ${single.name}` : `${project.name}: ${agents.length} new bots`,
|
|
16920
16967
|
body: `Bots or agents Canonry does not recognize yet.
|
|
16921
16968
|
${single ? line(single) : bulletList(agents.map(line))}`,
|
|
16922
|
-
fields: [{ label: AlertFieldLabels.next, value: `cnry traffic unrecognized ${project.name}` }],
|
|
16969
|
+
fields: [{ label: AlertFieldLabels.next, value: `cnry traffic unrecognized ${shellQuote(project.name)}` }],
|
|
16923
16970
|
url: payload.dashboardUrl,
|
|
16924
16971
|
footer: project.canonicalDomain,
|
|
16925
16972
|
timestamp: agents.reduce((latest, agent) => agent.lastSeenAt > latest ? agent.lastSeenAt : latest, agents[0]?.lastSeenAt ?? "")
|
|
@@ -16941,7 +16988,7 @@ function siteHealthView(payload) {
|
|
|
16941
16988
|
title: single ? `${project.name}: ${single.title} on ${pages(single.newPages)}` : `${project.name}: ${issues.length} new Site Health problems`,
|
|
16942
16989
|
body: `A site audit found problems that were not reported before.${scope}
|
|
16943
16990
|
${single ? line(single) : bulletList(issues.map(line))}`,
|
|
16944
|
-
fields: [{ label: AlertFieldLabels.next, value: `cnry technical-aeo issues ${project.name} --run-id ${payload.run.id}` }],
|
|
16991
|
+
fields: [{ label: AlertFieldLabels.next, value: `cnry technical-aeo issues ${shellQuote(project.name)} --run-id ${payload.run.id}` }],
|
|
16945
16992
|
url: payload.dashboardUrl,
|
|
16946
16993
|
footer: project.canonicalDomain,
|
|
16947
16994
|
...payload.run.finishedAt ? { timestamp: payload.run.finishedAt } : {}
|
|
@@ -16962,7 +17009,7 @@ function sentimentView(payload) {
|
|
|
16962
17009
|
// Evidence reads one query class at a time, so each class present gets its own command.
|
|
16963
17010
|
fields: [{
|
|
16964
17011
|
label: AlertFieldLabels.next,
|
|
16965
|
-
value: [...new Set(answers.map((answer) => answer.queryClass))].sort().map((queryClass) => `cnry sentiment evidence ${project.name} --run-id ${payload.run.id} --query-class ${queryClass} --outcome unfavorable`).join("\n")
|
|
17012
|
+
value: [...new Set(answers.map((answer) => answer.queryClass))].sort().map((queryClass) => `cnry sentiment evidence ${shellQuote(project.name)} --run-id ${payload.run.id} --query-class ${queryClass} --outcome unfavorable`).join("\n")
|
|
16966
17013
|
}],
|
|
16967
17014
|
url: payload.dashboardUrl,
|
|
16968
17015
|
footer: project.canonicalDomain,
|
|
@@ -17591,7 +17638,7 @@ async function settingsRoutes(app, opts) {
|
|
|
17591
17638
|
requireInstanceAdministrator(request);
|
|
17592
17639
|
return connection(request.params.name);
|
|
17593
17640
|
});
|
|
17594
|
-
app.delete("/settings/providers/:name", connectionRoute(app, (request) => providerConnectionSubject(request.params.name, ConnectionActions.disconnect), async (request, _reply, attempt) => {
|
|
17641
|
+
app.delete("/settings/providers/:name", { config: { projectBoundRefusal: narrowKeyRefused } }, connectionRoute(app, (request) => providerConnectionSubject(request.params.name, ConnectionActions.disconnect), async (request, _reply, attempt) => {
|
|
17595
17642
|
requireScope(request, SETTINGS_WRITE_SCOPE);
|
|
17596
17643
|
requireInstanceAdministrator(request);
|
|
17597
17644
|
const parsed = providerDisconnectRequestSchema.safeParse(request.body ?? {});
|
|
@@ -17684,7 +17731,7 @@ async function settingsRoutes(app, opts) {
|
|
|
17684
17731
|
}
|
|
17685
17732
|
return providerSummaryEntryDtoSchema.parse(result);
|
|
17686
17733
|
}));
|
|
17687
|
-
app.post("/settings/providers/reload", async (request) => withFeatureOutcome(app, { feature: "providers", operation: "reload" }, async (settle) => {
|
|
17734
|
+
app.post("/settings/providers/reload", { config: { projectBoundRefusal: narrowKeyRefused } }, async (request) => withFeatureOutcome(app, { feature: "providers", operation: "reload" }, async (settle) => {
|
|
17688
17735
|
requireScope(request, SETTINGS_WRITE_SCOPE);
|
|
17689
17736
|
requireInstanceAdministrator(request);
|
|
17690
17737
|
const parsed = providerReloadRequestSchema.safeParse(request.body ?? {});
|
|
@@ -17704,7 +17751,7 @@ async function settingsRoutes(app, opts) {
|
|
|
17704
17751
|
return providerReloadResponseDtoSchema.parse({ reloaded: true, providers });
|
|
17705
17752
|
}, (err) => err instanceof AppError && err.code === "NOT_IMPLEMENTED" ? OutcomeReasonCodes.UNSUPPORTED : void 0));
|
|
17706
17753
|
const testsInFlight = /* @__PURE__ */ new Set();
|
|
17707
|
-
app.post("/settings/providers/:name/test", connectionRoute(app, (request) => providerConnectionSubject(request.params.name, ConnectionActions.test), async (request, _reply, attempt) => {
|
|
17754
|
+
app.post("/settings/providers/:name/test", { config: { projectBoundRefusal: narrowKeyRefused } }, connectionRoute(app, (request) => providerConnectionSubject(request.params.name, ConnectionActions.test), async (request, _reply, attempt) => {
|
|
17708
17755
|
requireAdminSession(request);
|
|
17709
17756
|
requirePaidReadScope(request, [SETTINGS_WRITE_SCOPE], `Testing a provider connection calls the provider with its saved key, which requires the "${SETTINGS_WRITE_SCOPE}" scope on your API key.`);
|
|
17710
17757
|
requireInstanceAdministrator(request);
|
|
@@ -17884,11 +17931,9 @@ async function projectRoutes(app, opts) {
|
|
|
17884
17931
|
app.log.error({ error, projectId, projectName }, "Project-created callback failed after commit");
|
|
17885
17932
|
}
|
|
17886
17933
|
};
|
|
17887
|
-
app.post("/projects", async (request, reply) => {
|
|
17934
|
+
app.post("/projects", { config: { writeScope: PROJECTS_WRITE_SCOPE, projectBoundRefusal: projectCreationRefused } }, async (request, reply) => {
|
|
17888
17935
|
requireAdminSession(request);
|
|
17889
|
-
if (request.principal?.projectId)
|
|
17890
|
-
throw forbidden("This API key is limited to one project, and cannot create projects for this install.");
|
|
17891
|
-
}
|
|
17936
|
+
if (request.principal?.projectId) throw projectCreationRefused();
|
|
17892
17937
|
requireScope(request, PROJECTS_WRITE_SCOPE);
|
|
17893
17938
|
const parsedBody = projectCreateRequestSchema.safeParse(request.body);
|
|
17894
17939
|
if (!parsedBody.success) {
|
|
@@ -18581,7 +18626,13 @@ function changedQueryIdsForReplace(diff) {
|
|
|
18581
18626
|
}
|
|
18582
18627
|
function assertQueryCatalogMutationAllowed(tx, scope, affectedQueryIds, addsQueries = false) {
|
|
18583
18628
|
if (affectedQueryIds.length === 0 && !addsQueries) return;
|
|
18584
|
-
const
|
|
18629
|
+
const heldBy = /* @__PURE__ */ new Map();
|
|
18630
|
+
const protect = (queryId, holder) => {
|
|
18631
|
+
const holders = heldBy.get(queryId) ?? /* @__PURE__ */ new Set();
|
|
18632
|
+
holders.add(holder);
|
|
18633
|
+
heldBy.set(queryId, holders);
|
|
18634
|
+
};
|
|
18635
|
+
let planSchemaVersion = null;
|
|
18585
18636
|
const activePlan = tx.select({ activeVersionId: measurementPlans.activeVersionId }).from(measurementPlans).where(eq42(measurementPlans.projectId, scope.projectId)).get();
|
|
18586
18637
|
if (activePlan) {
|
|
18587
18638
|
const version = tx.select({ canonicalJson: measurementPlanVersions.canonicalJson }).from(measurementPlanVersions).where(and35(
|
|
@@ -18597,13 +18648,14 @@ function assertQueryCatalogMutationAllowed(tx, scope, affectedQueryIds, addsQuer
|
|
|
18597
18648
|
} catch {
|
|
18598
18649
|
throw validationError("Tracked queries cannot be changed because the active measurement plan is unavailable. Reload and try again.");
|
|
18599
18650
|
}
|
|
18600
|
-
|
|
18651
|
+
planSchemaVersion = plan.schemaVersion;
|
|
18652
|
+
for (const snapshot of plan.querySnapshots) protect(snapshot.queryId, "plan");
|
|
18601
18653
|
if (plan.schemaVersion === 1) {
|
|
18602
18654
|
for (const selection of plan.targetQuerySelections) {
|
|
18603
|
-
for (const queryId of selection.queryIds)
|
|
18655
|
+
for (const queryId of selection.queryIds) protect(queryId, "plan");
|
|
18604
18656
|
}
|
|
18605
18657
|
} else {
|
|
18606
|
-
for (const assignment of plan.assignments)
|
|
18658
|
+
for (const assignment of plan.assignments) protect(assignment.queryId, "plan");
|
|
18607
18659
|
}
|
|
18608
18660
|
}
|
|
18609
18661
|
const draft = tx.select({ authoringJson: measurementPlanDrafts.authoringJson }).from(measurementPlanDrafts).where(eq42(measurementPlanDrafts.projectId, scope.projectId)).get();
|
|
@@ -18614,14 +18666,10 @@ function assertQueryCatalogMutationAllowed(tx, scope, affectedQueryIds, addsQuer
|
|
|
18614
18666
|
} catch {
|
|
18615
18667
|
throw validationError("Tracked queries cannot be changed because the measurement draft is unavailable. Reload and try again.");
|
|
18616
18668
|
}
|
|
18617
|
-
for (const assignment of authoring.assignments)
|
|
18618
|
-
}
|
|
18619
|
-
if (affectedQueryIds.some((queryId) => protectedIds.has(queryId))) {
|
|
18620
|
-
throw validationError(
|
|
18621
|
-
"This query is assigned to a measurement plan or draft. Use Queries to change its assignments first.",
|
|
18622
|
-
{ displayToOperator: true }
|
|
18623
|
-
);
|
|
18669
|
+
for (const assignment of authoring.assignments) protect(assignment.queryId, "draft");
|
|
18624
18670
|
}
|
|
18671
|
+
const held = [...new Set(affectedQueryIds)].filter((queryId) => heldBy.has(queryId));
|
|
18672
|
+
if (held.length > 0) throw queriesHeldByMeasurement(tx, scope, held, heldBy, planSchemaVersion);
|
|
18625
18673
|
assertNoActivePlanlessSweep(tx, scope);
|
|
18626
18674
|
}
|
|
18627
18675
|
function assertNoActivePlanlessSweep(tx, scope) {
|
|
@@ -18631,7 +18679,41 @@ function assertNoActivePlanlessSweep(tx, scope) {
|
|
|
18631
18679
|
inArray19(runs.status, [RunStatuses.queued, RunStatuses.running]),
|
|
18632
18680
|
isNull8(runs.measurementPlanVersionId)
|
|
18633
18681
|
)).get();
|
|
18634
|
-
if (activeRun) throw
|
|
18682
|
+
if (activeRun) throw trackedQueriesLockedByRun(scope.projectName, activeRun.id);
|
|
18683
|
+
}
|
|
18684
|
+
var HELD_QUERY_MESSAGE_LIMIT = 3;
|
|
18685
|
+
var HELD_QUERY_DETAIL_LIMIT = 50;
|
|
18686
|
+
function heldQueryRemediation(projectName, heldCount, holders, planSchemaVersion) {
|
|
18687
|
+
const project = shellQuote(projectName);
|
|
18688
|
+
const advanced = (operation, input) => `\`canonry measurement-plan advanced ${project} ${operation}${input ? ` ${input}` : ""}\``;
|
|
18689
|
+
const workspaceChange = `preview and commit the change with ${advanced("query-preview", "<change.json>")} and ${advanced("query-commit", "<change.json>")}. The change file holds the removals or edits and expectedWorkspaceVersion (the workspaceVersion from ${advanced("query-workspace")}); for the commit, add the previewToken and reviewedAt the preview returns.`;
|
|
18690
|
+
if (holders.has("plan") && planSchemaVersion === 1) {
|
|
18691
|
+
return `The published plan uses schema v1, which holds every query it measures, so republish the setup first: choose Republish setup under Advanced measurement in the project's Settings, publish it, then make this change in Queries. From the CLI: republish with ${advanced("draft-action", "<action.json>")} (the create, compile-preview and publish actions, in turn), then ${workspaceChange}`;
|
|
18692
|
+
}
|
|
18693
|
+
if (holders.has("plan")) {
|
|
18694
|
+
return `Make this change in Queries, which updates the query and the plan together. From the CLI: ${workspaceChange}`;
|
|
18695
|
+
}
|
|
18696
|
+
const openDraft = planSchemaVersion === 1 ? "Republish setup" : "Continue setup";
|
|
18697
|
+
return `Remove ${heldCount === 1 ? "its" : "their"} assignments from the measurement draft, or discard the draft, then retry: choose ${openDraft} under Advanced measurement in the project's Settings. From the CLI: ${advanced("draft-action", "<action.json>")} with the remove-assignment or discard action and the etag that ${advanced("draft")} returns.`;
|
|
18698
|
+
}
|
|
18699
|
+
function queriesHeldByMeasurement(tx, scope, held, heldBy, planSchemaVersion) {
|
|
18700
|
+
const textById = new Map(tx.select({ id: queries.id, text: queries.query }).from(queries).where(and35(eq42(queries.projectId, scope.projectId), inArray19(queries.id, held.slice(0, HELD_QUERY_DETAIL_LIMIT)))).all().map((row) => [row.id, row.text]));
|
|
18701
|
+
const named = held.slice(0, HELD_QUERY_MESSAGE_LIMIT).map((queryId) => `"${textById.get(queryId) ?? queryId}"`);
|
|
18702
|
+
const more = held.length - named.length;
|
|
18703
|
+
const holders = new Set(held.flatMap((queryId) => [...heldBy.get(queryId)]));
|
|
18704
|
+
const where = holders.size === 2 ? "the published measurement plan and its draft" : holders.has("plan") ? "the published measurement plan" : "the measurement draft";
|
|
18705
|
+
const remediation = heldQueryRemediation(scope.projectName, held.length, holders, planSchemaVersion);
|
|
18706
|
+
return validationError(
|
|
18707
|
+
`${held.length === 1 ? "This query is" : `${held.length} of these queries are`} assigned to ${where}: ${named.join(", ")}${more > 0 ? ` and ${more} more` : ""}. ${remediation}`,
|
|
18708
|
+
{
|
|
18709
|
+
displayToOperator: true,
|
|
18710
|
+
reason: "query-assigned-to-measurement",
|
|
18711
|
+
queries: held.slice(0, HELD_QUERY_DETAIL_LIMIT).map((queryId) => ({ queryId, query: textById.get(queryId) ?? null, heldBy: [...heldBy.get(queryId)].sort() })),
|
|
18712
|
+
heldCount: held.length,
|
|
18713
|
+
planSchemaVersion,
|
|
18714
|
+
remediation
|
|
18715
|
+
}
|
|
18716
|
+
);
|
|
18635
18717
|
}
|
|
18636
18718
|
function assertQueryReplacementAllowed(tx, scope, incomingTexts) {
|
|
18637
18719
|
const existing = tx.select({ id: queries.id, text: queries.query }).from(queries).where(eq42(queries.projectId, scope.projectId)).all();
|
|
@@ -21060,7 +21142,7 @@ async function competitorRoutes(app, opts = {}) {
|
|
|
21060
21142
|
const curatedKeys = new Set(target2.curated.map(brandKeyFromText));
|
|
21061
21143
|
const curated = names.filter((name) => curatedKeys.has(brandKeyFromText(name)));
|
|
21062
21144
|
if (curated.length > 0) {
|
|
21063
|
-
const remove = target2.market ? `Change a market competitor's plan names in a measurement draft (markets: ${target2.market.marketKeys.join(", ")}).` : `Remove a curated alias with
|
|
21145
|
+
const remove = target2.market ? `Change a market competitor's plan names in a measurement draft (markets: ${target2.market.marketKeys.join(", ")}).` : `Remove a curated alias with \`canonry competitor aliases ${shellQuote(project.name)} ${target2.domain} --remove <name>\`.`;
|
|
21064
21146
|
throw validationError(
|
|
21065
21147
|
`${curated.map((name) => `"${name}"`).join(", ")} ${curated.length === 1 ? "is a curated alias" : "are curated aliases"} of ${target2.domain}; blocking only stops auto-detection. ${remove}`,
|
|
21066
21148
|
{ domain: target2.domain, curated }
|
|
@@ -22130,7 +22212,7 @@ function resolveScope2(db, projectId, input) {
|
|
|
22130
22212
|
if (input.scope.kind !== SeoScopeKinds.project || input.scope.key || input.scope.expectedPlanRevision !== void 0) throw validationError("This project supports project SEO scope only.");
|
|
22131
22213
|
return { mode: "simple", scope: input.scope };
|
|
22132
22214
|
}
|
|
22133
|
-
if (input.scope.expectedPlanRevision !== active.version.revision) throw
|
|
22215
|
+
if (input.scope.expectedPlanRevision !== active.version.revision) throw seoPlanRevisionStale(input.scope.expectedPlanRevision ?? null, active.version.revision);
|
|
22134
22216
|
if (active.plan.schemaVersion !== 2) throw validationError("Publish a current Advanced Measurement plan before using scoped SEO profiles.");
|
|
22135
22217
|
const plan = active.plan;
|
|
22136
22218
|
const option = planScopeOptions(plan, { marketLinks: true }).find((option2) => option2.kind === input.scope.kind && (option2.kind === SeoScopeKinds.project ? !input.scope.key : option2.id === input.scope.key));
|
|
@@ -22322,7 +22404,9 @@ function planSeoTasks(opts, input, rankings = NO_MARKET_RANKINGS) {
|
|
|
22322
22404
|
throw validationError("The SEO provider could not prepare this request. Check its input requirements or contact the host operator.");
|
|
22323
22405
|
}
|
|
22324
22406
|
const total = planned.reduce((sum, task) => sum + task.reservedMicros, 0);
|
|
22325
|
-
if (!planned.length
|
|
22407
|
+
if (!planned.length) throw seoNothingToFetch();
|
|
22408
|
+
if (planned.some((task) => !Number.isSafeInteger(task.reservedMicros) || task.reservedMicros <= 0) || !Number.isSafeInteger(total)) throw seoEstimateUnusable();
|
|
22409
|
+
if (total > runtime.policy.maxRunCostMicros) throw seoRunCostCapExceeded(planned.length);
|
|
22326
22410
|
const intentHash = hash2(JSON.stringify({ provider: connection.adapter.provider, account: connection.adapter.accountKey, policy: runtime.policy, tasks: planned.map((task) => ({ request: task.request, estimate: { maxCostMicros: task.reservedMicros, catalogRevision: task.catalogRevision } })) }));
|
|
22327
22411
|
return { ...runtime, connection, planned, intentHash };
|
|
22328
22412
|
}
|
|
@@ -22430,13 +22514,13 @@ async function seoRoutes(app, opts) {
|
|
|
22430
22514
|
return { available, reason: available ? null : "SEO execution is not configured on this host.", capabilities: [...new Set(runtime?.connections.flatMap((connection) => [...connection.adapter.capabilities]) ?? [])], profileCount: profiles(projectId).length, latestRunId: latest?.id ?? null, latestRunStatus: latest?.status ?? null, lastCompletedAt: last?.finishedAt ?? null };
|
|
22431
22515
|
};
|
|
22432
22516
|
const planTasks = (projectId, input) => planSeoTasks(opts, input, marketRankingPlan(app.db, projectId, input));
|
|
22433
|
-
app.get("/seo/operator/tasks/:id", async (request) => {
|
|
22517
|
+
app.get("/seo/operator/tasks/:id", { config: { operatorOnly: true } }, async (request) => {
|
|
22434
22518
|
requireOperator(request);
|
|
22435
22519
|
const task = app.db.select().from(seoTasks).where(eq55(seoTasks.id, request.params.id)).get();
|
|
22436
22520
|
if (!task) throw notFound("SEO task", request.params.id);
|
|
22437
22521
|
return { id: task.id, runId: task.jobId, status: task.status, reservedCostMicros: task.reservedMicros, actualCostMicros: task.actualMicros, receipts: task.receipts };
|
|
22438
22522
|
});
|
|
22439
|
-
app.post("/seo/operator/tasks/:id/reconcile", { config: { writeScope: SEO_RUN_SCOPE } }, async (request) => {
|
|
22523
|
+
app.post("/seo/operator/tasks/:id/reconcile", { config: { writeScope: SEO_RUN_SCOPE, operatorOnly: true } }, async (request) => {
|
|
22440
22524
|
requireOperator(request);
|
|
22441
22525
|
requireScope(request, SEO_RUN_SCOPE);
|
|
22442
22526
|
const parsed = seoReconcileInputSchema.safeParse(request.body);
|
|
@@ -27936,7 +28020,6 @@ function notifyMarketPinWrite(hooks, project, effect) {
|
|
|
27936
28020
|
}
|
|
27937
28021
|
|
|
27938
28022
|
// ../api-routes/src/measurement-plan.ts
|
|
27939
|
-
var MEASUREMENT_PLAN_WRITE_SCOPE = "measurement-plan.write";
|
|
27940
28023
|
function parseStoredPlanAnyVersion(canonicalJson3) {
|
|
27941
28024
|
return parseStoredMeasurementPlanAnyVersion(canonicalJson3);
|
|
27942
28025
|
}
|
|
@@ -28202,7 +28285,7 @@ async function measurementPlanRoutes(app, opts) {
|
|
|
28202
28285
|
}
|
|
28203
28286
|
if (activeVersion && activeVersion.schemaVersion !== 1) {
|
|
28204
28287
|
throw validationError(
|
|
28205
|
-
`The active measurement plan is schema v${activeVersion.schemaVersion}; this legacy endpoint publishes only schema v1 and would downgrade it. Publish through the draft flow instead: POST /projects/:name/measurement-plan/draft/actions/publish (CLI: canonry measurement-plan advanced <project> draft-action
|
|
28288
|
+
`The active measurement plan is schema v${activeVersion.schemaVersion}; this legacy endpoint publishes only schema v1 and would downgrade it. Publish through the draft flow instead: POST /projects/:name/measurement-plan/draft/actions/publish (CLI: canonry measurement-plan advanced <project> draft-action <action.json>; MCP: canonry_measurement_draft_action).`
|
|
28206
28289
|
);
|
|
28207
28290
|
}
|
|
28208
28291
|
if (activeVersion && activeVersion.checksum === checksum) return { kind: "existing", version: activeVersion };
|
|
@@ -47215,6 +47298,7 @@ var routeCatalog = [
|
|
|
47215
47298
|
},
|
|
47216
47299
|
responses: {
|
|
47217
47300
|
200: jsonResponse("Query suggestions returned.", "QueryGenerateResponse"),
|
|
47301
|
+
400: errorResponse("Invalid request, an unknown provider, or a provider that is not configured. The message names the command that adds one."),
|
|
47218
47302
|
501: errorResponse("Query generation is not available.")
|
|
47219
47303
|
}
|
|
47220
47304
|
},
|
|
@@ -48497,7 +48581,8 @@ var routeCatalog = [
|
|
|
48497
48581
|
responses: {
|
|
48498
48582
|
200: jsonResponse("Snapshot report returned.", "SnapshotReportDto"),
|
|
48499
48583
|
400: errorResponse("Invalid snapshot input."),
|
|
48500
|
-
501: errorResponse("Snapshot reporting is not supported.")
|
|
48584
|
+
501: errorResponse("Snapshot reporting is not supported."),
|
|
48585
|
+
503: errorResponse("No answer provider that runs snapshots is configured. The message names the command that adds one.")
|
|
48501
48586
|
}
|
|
48502
48587
|
},
|
|
48503
48588
|
{
|
|
@@ -48908,7 +48993,7 @@ var routeCatalog = [
|
|
|
48908
48993
|
responses: {
|
|
48909
48994
|
// TODO: Add `CdpScreenshotResultDto` Zod schema in contracts.
|
|
48910
48995
|
200: rawJsonResponse("CDP screenshot results returned.", looseObjectSchema),
|
|
48911
|
-
400: errorResponse("Invalid CDP screenshot request."),
|
|
48996
|
+
400: errorResponse("Invalid CDP screenshot request, or Chrome is not connected. The message names how to connect it."),
|
|
48912
48997
|
501: errorResponse("CDP screenshot support is not available.")
|
|
48913
48998
|
}
|
|
48914
48999
|
},
|
|
@@ -53789,7 +53874,8 @@ var canonryLocalRouteCatalog = [
|
|
|
53789
53874
|
200: { description: "SSE stream of AgentEvent frames.", content: { "text/event-stream": { schema: { type: "string" } } } },
|
|
53790
53875
|
400: errorResponse("Missing or empty prompt."),
|
|
53791
53876
|
404: errorResponse("Project not found."),
|
|
53792
|
-
409: errorResponse("Another Aero turn is already in flight.")
|
|
53877
|
+
409: errorResponse("Another Aero turn is already in flight."),
|
|
53878
|
+
422: errorResponse("No agent LLM provider has a key. The message names where to add one.")
|
|
53793
53879
|
}
|
|
53794
53880
|
}
|
|
53795
53881
|
];
|
|
@@ -54051,11 +54137,12 @@ function toUserDto(row) {
|
|
|
54051
54137
|
function countAdmins(app) {
|
|
54052
54138
|
return app.db.select({ id: users.id }).from(users).where(eq92(users.role, UserRoles.admin)).all().length;
|
|
54053
54139
|
}
|
|
54140
|
+
function installAccountsRefused() {
|
|
54141
|
+
return forbidden("This API key is limited to one project, and accounts are shared by the whole install.");
|
|
54142
|
+
}
|
|
54054
54143
|
function refuseProjectScopedKey(request) {
|
|
54055
54144
|
if (!request.principal?.projectId) return;
|
|
54056
|
-
throw
|
|
54057
|
-
"This API key is limited to one project, and accounts are shared by the whole install."
|
|
54058
|
-
);
|
|
54145
|
+
throw installAccountsRefused();
|
|
54059
54146
|
}
|
|
54060
54147
|
async function userRoutes(app, opts = {}) {
|
|
54061
54148
|
app.get("/users", async (request) => {
|
|
@@ -54066,7 +54153,7 @@ async function userRoutes(app, opts = {}) {
|
|
|
54066
54153
|
const rows = app.db.select().from(users).orderBy(asc19(users.createdAt)).all();
|
|
54067
54154
|
return { users: rows.map(toUserDto) };
|
|
54068
54155
|
});
|
|
54069
|
-
app.post("/users", async (request, reply) => {
|
|
54156
|
+
app.post("/users", { config: { projectBoundRefusal: installAccountsRefused } }, async (request, reply) => {
|
|
54070
54157
|
refuseProjectScopedKey(request);
|
|
54071
54158
|
requireAdminSession(request);
|
|
54072
54159
|
requireBroadInstanceKey(request);
|
|
@@ -54116,7 +54203,7 @@ async function userRoutes(app, opts = {}) {
|
|
|
54116
54203
|
lastLoginAt: null
|
|
54117
54204
|
}));
|
|
54118
54205
|
});
|
|
54119
|
-
app.delete("/users/:name", async (request) => {
|
|
54206
|
+
app.delete("/users/:name", { config: { projectBoundRefusal: installAccountsRefused } }, async (request) => {
|
|
54120
54207
|
refuseProjectScopedKey(request);
|
|
54121
54208
|
requireAdminSession(request);
|
|
54122
54209
|
requireBroadInstanceKey(request);
|
|
@@ -54158,10 +54245,11 @@ function invitationStatus(row, now) {
|
|
|
54158
54245
|
if (Date.parse(row.expiresAt) <= now) return UserInvitationStatuses.expired;
|
|
54159
54246
|
return UserInvitationStatuses.pending;
|
|
54160
54247
|
}
|
|
54248
|
+
function installInvitationsRefused() {
|
|
54249
|
+
return forbidden("This API key is limited to one project, and invitations are shared by the whole install.");
|
|
54250
|
+
}
|
|
54161
54251
|
function authorize(request, scope) {
|
|
54162
|
-
if (request.principal?.projectId)
|
|
54163
|
-
throw forbidden("This API key is limited to one project, and invitations are shared by the whole install.");
|
|
54164
|
-
}
|
|
54252
|
+
if (request.principal?.projectId) throw installInvitationsRefused();
|
|
54165
54253
|
requireAdminSession(request);
|
|
54166
54254
|
requireBroadInstanceKey(request);
|
|
54167
54255
|
requireScope(request, scope);
|
|
@@ -54185,7 +54273,7 @@ async function userInvitationRoutes(app) {
|
|
|
54185
54273
|
const rows = app.db.select().from(userInvitations).orderBy(desc42(userInvitations.createdAt)).all();
|
|
54186
54274
|
return { invitations: rows.map(toDto) };
|
|
54187
54275
|
});
|
|
54188
|
-
app.post("/users/invitations", async (request, reply) => {
|
|
54276
|
+
app.post("/users/invitations", { config: { projectBoundRefusal: installInvitationsRefused } }, async (request, reply) => {
|
|
54189
54277
|
authorize(request, USERS_WRITE_SCOPE);
|
|
54190
54278
|
const parsed = createUserInvitationRequestSchema.safeParse(request.body);
|
|
54191
54279
|
if (!parsed.success) throw validationError("That invitation could not be created.", { issues: parsed.error.issues });
|
|
@@ -54230,7 +54318,7 @@ async function userInvitationRoutes(app) {
|
|
|
54230
54318
|
});
|
|
54231
54319
|
return reply.status(201).send(toDto(row));
|
|
54232
54320
|
});
|
|
54233
|
-
app.delete("/users/invitations/:id", async (request) => {
|
|
54321
|
+
app.delete("/users/invitations/:id", { config: { projectBoundRefusal: installInvitationsRefused } }, async (request) => {
|
|
54234
54322
|
authorize(request, USERS_WRITE_SCOPE);
|
|
54235
54323
|
const row = app.db.select().from(userInvitations).where(eq93(userInvitations.id, request.params.id)).get();
|
|
54236
54324
|
if (!row) throw notFound("Invitation", request.params.id);
|
|
@@ -55356,14 +55444,14 @@ async function snapshotRoutes(app, opts) {
|
|
|
55356
55444
|
|
|
55357
55445
|
// ../api-routes/src/telemetry.ts
|
|
55358
55446
|
async function telemetryRoutes(app, opts) {
|
|
55359
|
-
app.get("/telemetry", async (request) => {
|
|
55447
|
+
app.get("/telemetry", { config: { operatorOnly: true } }, async (request) => {
|
|
55360
55448
|
requireOperator(request);
|
|
55361
55449
|
if (!opts.getTelemetryStatus) {
|
|
55362
55450
|
throw notImplemented("Telemetry status is not available in this deployment");
|
|
55363
55451
|
}
|
|
55364
55452
|
return normalizeTelemetryStatus(opts.getTelemetryStatus());
|
|
55365
55453
|
});
|
|
55366
|
-
app.put("/telemetry", async (request) => {
|
|
55454
|
+
app.put("/telemetry", { config: { writeScope: SETTINGS_WRITE_SCOPE, operatorOnly: true } }, async (request) => {
|
|
55367
55455
|
requireOperator(request);
|
|
55368
55456
|
requireScope(request, SETTINGS_WRITE_SCOPE);
|
|
55369
55457
|
if (!opts.setTelemetryEnabled) {
|
|
@@ -55451,7 +55539,7 @@ async function feedbackRoutes(app, opts) {
|
|
|
55451
55539
|
|
|
55452
55540
|
// ../api-routes/src/operational-logs.ts
|
|
55453
55541
|
async function operationalLogsRoutes(app, opts = {}) {
|
|
55454
|
-
app.get("/operations/logs", async (request, reply) => {
|
|
55542
|
+
app.get("/operations/logs", { config: { operatorOnly: true } }, async (request, reply) => {
|
|
55455
55543
|
requireOperator(request);
|
|
55456
55544
|
requireScope(request, "logs.read");
|
|
55457
55545
|
if (request.apiKey?.projectId) {
|
|
@@ -58501,6 +58589,18 @@ async function fetchSearchLandingPages(accessToken, propertyId, options = {}) {
|
|
|
58501
58589
|
|
|
58502
58590
|
// ../api-routes/src/google.ts
|
|
58503
58591
|
var GOOGLE_INTEGRATIONS = { gsc: "gsc", ga4: "ga4", gbp: "gbp" };
|
|
58592
|
+
function gscPropertyNotSet(projectName) {
|
|
58593
|
+
const project = shellQuote(projectName);
|
|
58594
|
+
const remediation = `Pick one in the project's Search Console section and choose Save property. From the CLI: \`canonry google properties ${project}\` lists them, then \`canonry google set-property ${project} <url>\`.`;
|
|
58595
|
+
return validationError(`No GSC property configured for this connection. ${remediation}`, { reason: "gsc-property-not-set", remediation });
|
|
58596
|
+
}
|
|
58597
|
+
function gscReadOnlyScope(projectName) {
|
|
58598
|
+
const remediation = connectSteps("gsc", projectName, { reconnect: true });
|
|
58599
|
+
return validationError(
|
|
58600
|
+
`This GSC connection has the read-only webmasters scope, which cannot submit sitemaps; a new connection asks for the full scope. ${remediation}`,
|
|
58601
|
+
{ reason: "gsc-scope-read-only", remediation }
|
|
58602
|
+
);
|
|
58603
|
+
}
|
|
58504
58604
|
function googleIntegration(type) {
|
|
58505
58605
|
return typeof type === "string" && Object.hasOwn(GOOGLE_INTEGRATIONS, type) ? GOOGLE_INTEGRATIONS[type] : void 0;
|
|
58506
58606
|
}
|
|
@@ -58744,7 +58844,7 @@ async function googleRoutes(app, opts) {
|
|
|
58744
58844
|
}, async (request, _reply, attempt) => {
|
|
58745
58845
|
const { clientId: googleClientId, clientSecret: googleClientSecret } = getAuthConfig();
|
|
58746
58846
|
if (!googleClientId || !googleClientSecret) {
|
|
58747
|
-
throw
|
|
58847
|
+
throw googleOAuthNotConfigured(googleIntegration(request.body?.type) ?? "gsc");
|
|
58748
58848
|
}
|
|
58749
58849
|
const { type, propertyId, publicUrl } = request.body ?? {};
|
|
58750
58850
|
if (!type || type !== "gsc" && type !== "ga4" && type !== "gbp") {
|
|
@@ -58976,7 +59076,7 @@ async function googleRoutes(app, opts) {
|
|
|
58976
59076
|
requireGooglePropertyDiscovery(request);
|
|
58977
59077
|
const { clientId: googleClientId, clientSecret: googleClientSecret } = getAuthConfig();
|
|
58978
59078
|
if (!googleClientId || !googleClientSecret) {
|
|
58979
|
-
throw
|
|
59079
|
+
throw googleOAuthNotConfigured();
|
|
58980
59080
|
}
|
|
58981
59081
|
const store = requireConnectionStore();
|
|
58982
59082
|
const project = resolveProject(app.db, request.params.name);
|
|
@@ -58993,7 +59093,7 @@ async function googleRoutes(app, opts) {
|
|
|
58993
59093
|
const project = resolveProject(app.db, request.params.name);
|
|
58994
59094
|
const conn = store.getConnection(project.canonicalDomain, "gsc");
|
|
58995
59095
|
if (!conn) {
|
|
58996
|
-
throw integrationNotConnected
|
|
59096
|
+
throw notConnectedRefusal(integrationNotConnected, "No GSC connection found for this domain.", "gsc", project.name);
|
|
58997
59097
|
}
|
|
58998
59098
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
58999
59099
|
const runId = crypto47.randomUUID();
|
|
@@ -59281,7 +59381,7 @@ async function googleRoutes(app, opts) {
|
|
|
59281
59381
|
app.post("/projects/:name/google/gsc/inspect", async (request) => {
|
|
59282
59382
|
const { clientId: googleClientId, clientSecret: googleClientSecret } = getAuthConfig();
|
|
59283
59383
|
if (!googleClientId || !googleClientSecret) {
|
|
59284
|
-
throw
|
|
59384
|
+
throw googleOAuthNotConfigured();
|
|
59285
59385
|
}
|
|
59286
59386
|
const store = requireConnectionStore();
|
|
59287
59387
|
const project = resolveProject(app.db, request.params.name);
|
|
@@ -59294,7 +59394,7 @@ async function googleRoutes(app, opts) {
|
|
|
59294
59394
|
try {
|
|
59295
59395
|
const { accessToken, propertyId } = await getValidToken(store, project.canonicalDomain, "gsc", googleClientId, googleClientSecret);
|
|
59296
59396
|
if (!propertyId) {
|
|
59297
|
-
throw outcome2.refuse(OutcomeReasonCodes.PROPERTY_NOT_FOUND,
|
|
59397
|
+
throw outcome2.refuse(OutcomeReasonCodes.PROPERTY_NOT_FOUND, gscPropertyNotSet(project.name));
|
|
59298
59398
|
}
|
|
59299
59399
|
result = await inspectUrl(accessToken, url, propertyId);
|
|
59300
59400
|
if (!isSameSearchSite(store.getConnection(project.canonicalDomain, "gsc")?.propertyId, propertyId)) {
|
|
@@ -59517,13 +59617,13 @@ async function googleRoutes(app, opts) {
|
|
|
59517
59617
|
app.get("/projects/:name/google/gsc/sitemaps", async (request) => {
|
|
59518
59618
|
const { clientId: googleClientId, clientSecret: googleClientSecret } = getAuthConfig();
|
|
59519
59619
|
if (!googleClientId || !googleClientSecret) {
|
|
59520
|
-
throw
|
|
59620
|
+
throw googleOAuthNotConfigured();
|
|
59521
59621
|
}
|
|
59522
59622
|
const store = requireConnectionStore();
|
|
59523
59623
|
const project = resolveProject(app.db, request.params.name);
|
|
59524
59624
|
const conn = store.getConnection(project.canonicalDomain, "gsc");
|
|
59525
59625
|
if (!conn?.propertyId) {
|
|
59526
|
-
throw
|
|
59626
|
+
throw gscPropertyNotSet(project.name);
|
|
59527
59627
|
}
|
|
59528
59628
|
const sitemapIndex = request.query.sitemapIndex;
|
|
59529
59629
|
if (sitemapIndex && !isSitemapOwnedByProperty(sitemapIndex, conn.propertyId, project.canonicalDomain)) {
|
|
@@ -59532,7 +59632,7 @@ async function googleRoutes(app, opts) {
|
|
|
59532
59632
|
try {
|
|
59533
59633
|
const { accessToken, propertyId } = await getValidToken(store, project.canonicalDomain, "gsc", googleClientId, googleClientSecret);
|
|
59534
59634
|
if (!propertyId) {
|
|
59535
|
-
throw
|
|
59635
|
+
throw gscPropertyNotSet(project.name);
|
|
59536
59636
|
}
|
|
59537
59637
|
const entries = await listSitemaps(accessToken, propertyId, sitemapIndex);
|
|
59538
59638
|
const sitemaps = sitemapIndex ? entries.map((sitemap) => ({ ...sitemap, parentSitemapUrl: sitemapIndex })) : entries;
|
|
@@ -59557,12 +59657,12 @@ async function googleRoutes(app, opts) {
|
|
|
59557
59657
|
const outcome2 = startRouteOutcome(app, FeatureNames.search_console, "sitemap_submit");
|
|
59558
59658
|
const conn = store.getConnection(project.canonicalDomain, "gsc");
|
|
59559
59659
|
if (!conn) {
|
|
59560
|
-
throw outcome2.refuse(OutcomeReasonCodes.NOT_CONNECTED, validationError
|
|
59660
|
+
throw outcome2.refuse(OutcomeReasonCodes.NOT_CONNECTED, notConnectedRefusal(validationError, "No GSC connection found for this domain.", "gsc", project.name));
|
|
59561
59661
|
}
|
|
59562
59662
|
if (!conn.propertyId) {
|
|
59563
59663
|
throw outcome2.refuse(
|
|
59564
59664
|
OutcomeReasonCodes.PROPERTY_NOT_FOUND,
|
|
59565
|
-
|
|
59665
|
+
gscPropertyNotSet(project.name)
|
|
59566
59666
|
);
|
|
59567
59667
|
}
|
|
59568
59668
|
const invalidUrls = sitemapUrls.filter((url) => !isSitemapOwnedByProperty(url, conn.propertyId, project.canonicalDomain));
|
|
@@ -59575,12 +59675,12 @@ async function googleRoutes(app, opts) {
|
|
|
59575
59675
|
if (!(conn.scopes ?? []).includes(GSC_SCOPE)) {
|
|
59576
59676
|
throw outcome2.refuse(
|
|
59577
59677
|
OutcomeReasonCodes.PERMISSION_MISSING,
|
|
59578
|
-
|
|
59678
|
+
gscReadOnlyScope(project.name)
|
|
59579
59679
|
);
|
|
59580
59680
|
}
|
|
59581
59681
|
const { clientId: googleClientId, clientSecret: googleClientSecret } = getAuthConfig();
|
|
59582
59682
|
if (!googleClientId || !googleClientSecret) {
|
|
59583
|
-
throw outcome2.refuse(OutcomeReasonCodes.NOT_CONNECTED,
|
|
59683
|
+
throw outcome2.refuse(OutcomeReasonCodes.NOT_CONNECTED, googleOAuthNotConfigured());
|
|
59584
59684
|
}
|
|
59585
59685
|
let accessToken;
|
|
59586
59686
|
try {
|
|
@@ -59617,16 +59717,16 @@ async function googleRoutes(app, opts) {
|
|
|
59617
59717
|
app.post("/projects/:name/google/gsc/discover-sitemaps", async (request) => {
|
|
59618
59718
|
const { clientId: googleClientId, clientSecret: googleClientSecret } = getAuthConfig();
|
|
59619
59719
|
if (!googleClientId || !googleClientSecret) {
|
|
59620
|
-
throw
|
|
59720
|
+
throw googleOAuthNotConfigured();
|
|
59621
59721
|
}
|
|
59622
59722
|
const store = requireConnectionStore();
|
|
59623
59723
|
const project = resolveProject(app.db, request.params.name);
|
|
59624
59724
|
const conn = store.getConnection(project.canonicalDomain, "gsc");
|
|
59625
59725
|
if (!conn) {
|
|
59626
|
-
throw validationError
|
|
59726
|
+
throw notConnectedRefusal(validationError, "No GSC connection found for this domain.", "gsc", project.name);
|
|
59627
59727
|
}
|
|
59628
59728
|
if (!conn.propertyId) {
|
|
59629
|
-
throw
|
|
59729
|
+
throw gscPropertyNotSet(project.name);
|
|
59630
59730
|
}
|
|
59631
59731
|
let sitemaps;
|
|
59632
59732
|
try {
|
|
@@ -59636,9 +59736,8 @@ async function googleRoutes(app, opts) {
|
|
|
59636
59736
|
throw gscErrorToAppError(err, "Failed to discover Search Console sitemaps");
|
|
59637
59737
|
}
|
|
59638
59738
|
if (sitemaps.length === 0) {
|
|
59639
|
-
|
|
59640
|
-
|
|
59641
|
-
);
|
|
59739
|
+
const remediation = `Submit one from the project's Search Console section, then retry. From the CLI: \`canonry google submit-sitemap ${shellQuote(project.name)} <url>\`.`;
|
|
59740
|
+
throw validationError(`No sitemaps found for this GSC property. ${remediation}`, { reason: "gsc-no-sitemaps", remediation });
|
|
59642
59741
|
}
|
|
59643
59742
|
const primary = sitemaps.find((s) => s.isSitemapsIndex) ?? sitemaps[0];
|
|
59644
59743
|
const sitemapUrl = primary.path;
|
|
@@ -59667,10 +59766,10 @@ async function googleRoutes(app, opts) {
|
|
|
59667
59766
|
const project = resolveProject(app.db, request.params.name);
|
|
59668
59767
|
const conn = store.getConnection(project.canonicalDomain, "gsc");
|
|
59669
59768
|
if (!conn) {
|
|
59670
|
-
throw validationError
|
|
59769
|
+
throw notConnectedRefusal(validationError, "No GSC connection found for this domain.", "gsc", project.name);
|
|
59671
59770
|
}
|
|
59672
59771
|
if (!conn.propertyId) {
|
|
59673
|
-
throw
|
|
59772
|
+
throw gscPropertyNotSet(project.name);
|
|
59674
59773
|
}
|
|
59675
59774
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
59676
59775
|
const runId = crypto47.randomUUID();
|
|
@@ -59737,7 +59836,7 @@ async function googleRoutes(app, opts) {
|
|
|
59737
59836
|
app.post("/projects/:name/google/indexing/request", async (request) => {
|
|
59738
59837
|
const { clientId: googleClientId, clientSecret: googleClientSecret } = getAuthConfig();
|
|
59739
59838
|
if (!googleClientId || !googleClientSecret) {
|
|
59740
|
-
throw
|
|
59839
|
+
throw googleOAuthNotConfigured();
|
|
59741
59840
|
}
|
|
59742
59841
|
const store = requireConnectionStore();
|
|
59743
59842
|
const project = resolveProject(app.db, request.params.name);
|
|
@@ -59763,8 +59862,10 @@ async function googleRoutes(app, opts) {
|
|
|
59763
59862
|
unindexedUrls.push(url);
|
|
59764
59863
|
}
|
|
59765
59864
|
if (unindexedUrls.length === 0) {
|
|
59865
|
+
const remediation = `If the sitemap has not been inspected recently, inspect it from the project's Search Console section first. From the CLI: \`canonry google inspect-sitemap ${shellQuote(project.name)}\`.`;
|
|
59766
59866
|
throw validationError(
|
|
59767
|
-
skippedOtherHost > 0 ? `No unindexed URLs found on "${project.canonicalDomain}" (skipped ${skippedOtherHost} on other hosts).
|
|
59867
|
+
skippedOtherHost > 0 ? `No unindexed URLs found on "${project.canonicalDomain}" (skipped ${skippedOtherHost} on other hosts). ${remediation}` : `No unindexed URLs found. ${remediation}`,
|
|
59868
|
+
{ reason: "no-unindexed-urls", remediation }
|
|
59768
59869
|
);
|
|
59769
59870
|
}
|
|
59770
59871
|
urlsToNotify = unindexedUrls;
|
|
@@ -59813,8 +59914,10 @@ async function googleRoutes(app, opts) {
|
|
|
59813
59914
|
});
|
|
59814
59915
|
function gbpErrorToAppError(err, context) {
|
|
59815
59916
|
if (err.reason === "ACCESS_TOKEN_SCOPE_INSUFFICIENT") {
|
|
59917
|
+
const remediation = connectSteps("gbp", void 0, { reconnect: true });
|
|
59816
59918
|
return validationError(
|
|
59817
|
-
`${context}: OAuth token is missing the business.manage scope.
|
|
59919
|
+
`${context}: OAuth token is missing the business.manage scope. ${remediation}`,
|
|
59920
|
+
{ reason: "gbp-scope-missing", remediation }
|
|
59818
59921
|
);
|
|
59819
59922
|
}
|
|
59820
59923
|
if (err.reason === "RATE_LIMIT_EXCEEDED" || /quota/i.test(err.message)) {
|
|
@@ -59899,7 +60002,7 @@ async function googleRoutes(app, opts) {
|
|
|
59899
60002
|
app.post("/projects/:name/gbp/locations/discover", async (request) => {
|
|
59900
60003
|
const { clientId: googleClientId, clientSecret: googleClientSecret } = getAuthConfig();
|
|
59901
60004
|
if (!googleClientId || !googleClientSecret) {
|
|
59902
|
-
throw
|
|
60005
|
+
throw googleOAuthNotConfigured("gbp");
|
|
59903
60006
|
}
|
|
59904
60007
|
const project = resolveProject(app.db, request.params.name);
|
|
59905
60008
|
const store = requireConnectionStore();
|
|
@@ -59930,7 +60033,8 @@ async function googleRoutes(app, opts) {
|
|
|
59930
60033
|
if (requestedAccount) {
|
|
59931
60034
|
const accounts = await fetchAccounts();
|
|
59932
60035
|
if (!accounts.some((a) => a.name === requestedAccount)) {
|
|
59933
|
-
|
|
60036
|
+
const remediation = `List the accounts it can see from the CLI: \`canonry gbp accounts ${shellQuote(project.name)}\`.`;
|
|
60037
|
+
throw validationError(`GBP account "${requestedAccount}" is not accessible to this connection. ${remediation}`, { reason: "gbp-account-not-accessible", remediation });
|
|
59934
60038
|
}
|
|
59935
60039
|
accountName = requestedAccount;
|
|
59936
60040
|
} else {
|
|
@@ -59947,7 +60051,8 @@ async function googleRoutes(app, opts) {
|
|
|
59947
60051
|
}
|
|
59948
60052
|
const switching = current !== null && current !== accountName;
|
|
59949
60053
|
if (switching && !switchAccount) {
|
|
59950
|
-
|
|
60054
|
+
const remediation = `Send switchAccount=true to confirm (from the CLI: \`canonry gbp locations discover ${shellQuote(project.name)} --account ${shellQuote(accountName)} --switch-account\`), or disconnect Google Business Profile from the project first (from the CLI: \`canonry gbp disconnect ${shellQuote(project.name)}\`).`;
|
|
60055
|
+
throw validationError(`This project currently tracks GBP account "${current}". Re-pointing it at "${accountName}" would replace its locations and all synced data. ${remediation}`, { reason: "gbp-account-switch-unconfirmed", remediation });
|
|
59951
60056
|
}
|
|
59952
60057
|
let remoteLocations;
|
|
59953
60058
|
try {
|
|
@@ -60011,13 +60116,13 @@ async function googleRoutes(app, opts) {
|
|
|
60011
60116
|
assertNotProjectScoped(request, "listing Business Profile accounts");
|
|
60012
60117
|
const { clientId: googleClientId, clientSecret: googleClientSecret } = getAuthConfig();
|
|
60013
60118
|
if (!googleClientId || !googleClientSecret) {
|
|
60014
|
-
throw
|
|
60119
|
+
throw googleOAuthNotConfigured("gbp");
|
|
60015
60120
|
}
|
|
60016
60121
|
const project = resolveProject(app.db, request.params.name);
|
|
60017
60122
|
const store = requireConnectionStore();
|
|
60018
60123
|
const conn = store.getConnection(project.canonicalDomain, "gbp");
|
|
60019
60124
|
if (!conn) {
|
|
60020
|
-
throw integrationNotConnected
|
|
60125
|
+
throw notConnectedRefusal(integrationNotConnected, "No GBP connection found for this project.", "gbp", project.name);
|
|
60021
60126
|
}
|
|
60022
60127
|
const { accessToken } = await getValidToken(
|
|
60023
60128
|
store,
|
|
@@ -60106,7 +60211,7 @@ async function googleRoutes(app, opts) {
|
|
|
60106
60211
|
const store = requireConnectionStore();
|
|
60107
60212
|
const conn = store.getConnection(project.canonicalDomain, "gbp");
|
|
60108
60213
|
if (!conn) {
|
|
60109
|
-
throw integrationNotConnected
|
|
60214
|
+
throw notConnectedRefusal(integrationNotConnected, "No GBP connection found for this project.", "gbp", project.name);
|
|
60110
60215
|
}
|
|
60111
60216
|
const parsed = gbpSyncRequestSchema.safeParse(request.body ?? {});
|
|
60112
60217
|
if (!parsed.success) {
|
|
@@ -61166,6 +61271,7 @@ async function googleMarketingRoutes(app, opts) {
|
|
|
61166
61271
|
authorizationUrl = await adapter.authorizationUrl({ provider, redirectUri, state, scopes });
|
|
61167
61272
|
new URL(authorizationUrl);
|
|
61168
61273
|
} catch (err) {
|
|
61274
|
+
if (err instanceof AppError) throw err;
|
|
61169
61275
|
throw discoveryFailure(app, "Google Marketing OAuth start", err);
|
|
61170
61276
|
}
|
|
61171
61277
|
pendingOAuthFlows.create({
|
|
@@ -65146,7 +65252,7 @@ function errorDetails(err) {
|
|
|
65146
65252
|
async function resolveAdsOperator(app, opts, project, verification) {
|
|
65147
65253
|
const connection = opts.adsCredentialStore?.getConnection(project.name);
|
|
65148
65254
|
if (!connection?.apiKey) {
|
|
65149
|
-
throw integrationNotConnected
|
|
65255
|
+
throw notConnectedRefusal(integrationNotConnected, "No ads connection for this project.", "openai-ads", project.name);
|
|
65150
65256
|
}
|
|
65151
65257
|
if (!connection.adAccountId) {
|
|
65152
65258
|
throw validationError("Reconnect this project to bind its verified OpenAI ad account before mutating ads");
|
|
@@ -66610,7 +66716,7 @@ async function adsRoutes(app, opts) {
|
|
|
66610
66716
|
const project = resolveProject(app.db, request.params.name);
|
|
66611
66717
|
const row = app.db.select().from(adsConnections).where(eq103(adsConnections.projectId, project.id)).get();
|
|
66612
66718
|
if (!row) {
|
|
66613
|
-
throw integrationNotConnected
|
|
66719
|
+
throw notConnectedRefusal(integrationNotConnected, "No ads connection for this project.", "openai-ads", project.name);
|
|
66614
66720
|
}
|
|
66615
66721
|
const inFlight2 = app.db.select({ id: runs.id, status: runs.status }).from(runs).where(and87(
|
|
66616
66722
|
eq103(runs.projectId, project.id),
|
|
@@ -66840,7 +66946,7 @@ async function adsRoutes(app, opts) {
|
|
|
66840
66946
|
const { campaignId, lookbackDays } = parsed.data;
|
|
66841
66947
|
const connection = app.db.select().from(adsConnections).where(eq103(adsConnections.projectId, project.id)).get();
|
|
66842
66948
|
if (!connection) {
|
|
66843
|
-
throw integrationNotConnected
|
|
66949
|
+
throw notConnectedRefusal(integrationNotConnected, "No ads connection for this project.", "openai-ads", project.name);
|
|
66844
66950
|
}
|
|
66845
66951
|
const { apiKey, reader } = resolveAdsLiveDeliveryReader(opts, project.name);
|
|
66846
66952
|
const verifyAdsAccount = opts.verifyAdsAccount;
|
|
@@ -66852,6 +66958,7 @@ async function adsRoutes(app, opts) {
|
|
|
66852
66958
|
const lastAttemptAtMs = liveDeliveryLastAttemptAtMs.get(throttleKey);
|
|
66853
66959
|
const remainingIntervalMs = liveDeliveryMinIntervalMs > 0 && lastAttemptAtMs !== void 0 ? lastAttemptAtMs + liveDeliveryMinIntervalMs - fetchedAtMs : 0;
|
|
66854
66960
|
if (liveDeliveryInFlight.has(project.id) || liveDeliveryInFlight.has(throttleKey)) {
|
|
66961
|
+
const remediation = "Wait for it to finish, then retry.";
|
|
66855
66962
|
throw quotaExceeded("OpenAI Ads live delivery reads", {
|
|
66856
66963
|
reason: "read-in-flight",
|
|
66857
66964
|
minIntervalMs: liveDeliveryMinIntervalMs,
|
|
@@ -66859,15 +66966,18 @@ async function adsRoutes(app, opts) {
|
|
|
66859
66966
|
// much longer the running walk needs is unknowable from here, so once
|
|
66860
66967
|
// it has outlived the interval there is no honest number to give and
|
|
66861
66968
|
// the field is absent rather than guessed.
|
|
66862
|
-
...remainingIntervalMs > 0 ? { retryAfterMs: remainingIntervalMs } : {}
|
|
66863
|
-
|
|
66969
|
+
...remainingIntervalMs > 0 ? { retryAfterMs: remainingIntervalMs } : {},
|
|
66970
|
+
remediation
|
|
66971
|
+
}, `A live OpenAI Ads delivery read for this project is still running. ${remediation}`);
|
|
66864
66972
|
}
|
|
66865
66973
|
if (remainingIntervalMs > 0) {
|
|
66974
|
+
const remediation = `Retry in ${Math.ceil(remainingIntervalMs / 1e3)} s.`;
|
|
66866
66975
|
throw quotaExceeded("OpenAI Ads live delivery reads", {
|
|
66867
66976
|
reason: "min-interval",
|
|
66868
66977
|
minIntervalMs: liveDeliveryMinIntervalMs,
|
|
66869
|
-
retryAfterMs: remainingIntervalMs
|
|
66870
|
-
|
|
66978
|
+
retryAfterMs: remainingIntervalMs,
|
|
66979
|
+
remediation
|
|
66980
|
+
}, `Live OpenAI Ads delivery reads are limited to one every ${Math.ceil(liveDeliveryMinIntervalMs / 1e3)} s for each project and caller. ${remediation}`);
|
|
66871
66981
|
}
|
|
66872
66982
|
liveDeliveryInFlight.add(project.id);
|
|
66873
66983
|
liveDeliveryInFlight.add(throttleKey);
|
|
@@ -68250,14 +68360,17 @@ async function bingRoutes(app, opts) {
|
|
|
68250
68360
|
function requireConnection(store, domain) {
|
|
68251
68361
|
const conn = store.getConnection(domain);
|
|
68252
68362
|
if (!conn) {
|
|
68253
|
-
throw integrationNotConnected
|
|
68363
|
+
throw notConnectedRefusal(integrationNotConnected, "No Bing connection found for this domain.", "bing");
|
|
68254
68364
|
}
|
|
68255
68365
|
return conn;
|
|
68256
68366
|
}
|
|
68257
|
-
|
|
68367
|
+
function bingSiteNotSet() {
|
|
68368
|
+
const remediation = "Pick the site in the project's Bing section and choose Set Site. From the CLI: `canonry bing sites <project>` lists them, then `canonry bing set-site <project> <url>`.";
|
|
68369
|
+
return validationError(`No Bing site configured. ${remediation}`, { reason: "bing-site-not-set", remediation });
|
|
68370
|
+
}
|
|
68258
68371
|
function requireSite(domain) {
|
|
68259
68372
|
const conn = requireConnection(requireConnectionStore(), domain);
|
|
68260
|
-
if (!conn.siteUrl) throw
|
|
68373
|
+
if (!conn.siteUrl) throw bingSiteNotSet();
|
|
68261
68374
|
return { apiKey: conn.apiKey, siteUrl: conn.siteUrl };
|
|
68262
68375
|
}
|
|
68263
68376
|
await bingDataRoutes(app, {
|
|
@@ -68542,7 +68655,7 @@ async function bingRoutes(app, opts) {
|
|
|
68542
68655
|
const outcome2 = startRouteOutcome(app, FeatureNames.bing, "inspect", { operationKind: OutcomeOperationKinds["url-inspection"], projectId: project.id });
|
|
68543
68656
|
const conn = outcome2.guard(OutcomeReasonCodes.NOT_CONNECTED, () => requireConnection(store, project.canonicalDomain));
|
|
68544
68657
|
if (!conn.siteUrl) {
|
|
68545
|
-
throw outcome2.refuse(OutcomeReasonCodes.PROPERTY_NOT_FOUND,
|
|
68658
|
+
throw outcome2.refuse(OutcomeReasonCodes.PROPERTY_NOT_FOUND, bingSiteNotSet());
|
|
68546
68659
|
}
|
|
68547
68660
|
const { url } = request.body ?? {};
|
|
68548
68661
|
if (!url) {
|
|
@@ -68683,7 +68796,8 @@ async function bingRoutes(app, opts) {
|
|
|
68683
68796
|
}
|
|
68684
68797
|
}
|
|
68685
68798
|
if (unindexedUrls.length === 0) {
|
|
68686
|
-
|
|
68799
|
+
const remediation = `If no URL has been inspected yet, inspect URLs from the project's Bing section first. From the CLI: \`canonry bing inspect ${shellQuote(project.name)} <url>\`.`;
|
|
68800
|
+
throw validationError(`No unindexed or unknown URLs found. ${remediation}`, { reason: "no-unindexed-urls", remediation });
|
|
68687
68801
|
}
|
|
68688
68802
|
urlsToSubmit = unindexedUrls;
|
|
68689
68803
|
}
|
|
@@ -70098,7 +70212,7 @@ async function refreshOAuthTokenIfNeeded(googleStore, authConfig, canonicalDomai
|
|
|
70098
70212
|
const fiveMinutes = 5 * 60 * 1e3;
|
|
70099
70213
|
if (Date.now() > expiresAt - fiveMinutes) {
|
|
70100
70214
|
if (!authConfig.clientId || !authConfig.clientSecret) {
|
|
70101
|
-
throw
|
|
70215
|
+
throw googleOAuthNotConfigured("ga4");
|
|
70102
70216
|
}
|
|
70103
70217
|
const tokens = await refreshAccessToken(authConfig.clientId, authConfig.clientSecret, oauthConn.refreshToken);
|
|
70104
70218
|
const newExpiresAt = new Date(Date.now() + tokens.expires_in * 1e3).toISOString();
|
|
@@ -70118,9 +70232,10 @@ function ga4ErrorToAppError(err, context) {
|
|
|
70118
70232
|
return quotaExceeded("Google Analytics Admin API (rate limited; retries exhausted)");
|
|
70119
70233
|
}
|
|
70120
70234
|
if (err.status === 401 || err.status === 403) {
|
|
70235
|
+
const remediation = connectSteps("ga4", void 0, { reconnect: true });
|
|
70121
70236
|
return forbidden(
|
|
70122
|
-
`${context}: the connected Google account was rejected by Google (${err.status}).
|
|
70123
|
-
{ reason: "ga4-upstream-auth", upstreamStatus: err.status }
|
|
70237
|
+
`${context}: the connected Google account was rejected by Google (${err.status}). ${remediation}`,
|
|
70238
|
+
{ reason: "ga4-upstream-auth", upstreamStatus: err.status, remediation }
|
|
70124
70239
|
);
|
|
70125
70240
|
}
|
|
70126
70241
|
return providerError(`${context}: ${err.message}`);
|
|
@@ -70185,7 +70300,7 @@ function requireGa4Connection(opts, projectName, canonicalDomain) {
|
|
|
70185
70300
|
const saConn = opts.ga4CredentialStore?.getConnection(projectName);
|
|
70186
70301
|
const oauthConn = opts.googleConnectionStore?.getConnection(canonicalDomain, "ga4");
|
|
70187
70302
|
if (!saConn && !(oauthConn?.accessToken && oauthConn?.propertyId)) {
|
|
70188
|
-
throw validationError
|
|
70303
|
+
throw notConnectedRefusal(validationError, "No GA4 connection found.", "ga4", projectName);
|
|
70189
70304
|
}
|
|
70190
70305
|
}
|
|
70191
70306
|
async function ga4Routes(app, opts) {
|
|
@@ -70359,9 +70474,7 @@ async function ga4Routes(app, opts) {
|
|
|
70359
70474
|
const googleStore = opts.googleConnectionStore;
|
|
70360
70475
|
const authConfig = opts.getGoogleAuthConfig?.();
|
|
70361
70476
|
if (!googleStore || !authConfig) {
|
|
70362
|
-
throw
|
|
70363
|
-
"Google OAuth is not configured on this instance. Configure it before listing GA4 properties."
|
|
70364
|
-
);
|
|
70477
|
+
throw googleOAuthNotConfigured("ga4");
|
|
70365
70478
|
}
|
|
70366
70479
|
const oauthConn = googleStore.getConnection(project.canonicalDomain, "ga4");
|
|
70367
70480
|
if (!oauthConn?.accessToken || !oauthConn?.refreshToken) {
|
|
@@ -70412,7 +70525,7 @@ async function ga4Routes(app, opts) {
|
|
|
70412
70525
|
if (!serviceAccount && !oauth) {
|
|
70413
70526
|
const auth = opts.ga4CredentialStore ? void 0 : opts.getGoogleAuthConfig?.();
|
|
70414
70527
|
if (opts.ga4CredentialStore || opts.googleConnectionStore && auth?.clientId && auth.clientSecret) {
|
|
70415
|
-
const error = integrationNotConnected
|
|
70528
|
+
const error = notConnectedRefusal(integrationNotConnected, "No GA4 connection found.", "ga4", project.name);
|
|
70416
70529
|
outcome2.report({ status: OutcomeStatuses.failed, ...classifyOutcomeError(error) });
|
|
70417
70530
|
throw error;
|
|
70418
70531
|
}
|
|
@@ -72674,7 +72787,7 @@ async function wordpressRoutes(app, opts) {
|
|
|
72674
72787
|
const connection = store.getConnection(projectName);
|
|
72675
72788
|
if (!connection) {
|
|
72676
72789
|
settle?.({ status: OutcomeStatuses.failed, reasonCode: OutcomeReasonCodes.NOT_CONNECTED });
|
|
72677
|
-
throw validationError
|
|
72790
|
+
throw notConnectedRefusal(validationError, `No WordPress connection found for project "${projectName}".`, "wordpress", projectName);
|
|
72678
72791
|
}
|
|
72679
72792
|
return guarded(connection);
|
|
72680
72793
|
}
|
|
@@ -75634,6 +75747,17 @@ function compareTrafficEventGroups(a, b) {
|
|
|
75634
75747
|
}
|
|
75635
75748
|
|
|
75636
75749
|
// ../api-routes/src/traffic.ts
|
|
75750
|
+
var TRAFFIC_CONNECT_INTEGRATIONS = {
|
|
75751
|
+
[TrafficSourceTypes["cloud-run"]]: "traffic-cloud-run",
|
|
75752
|
+
[TrafficSourceTypes.wordpress]: "traffic-wordpress",
|
|
75753
|
+
[TrafficSourceTypes.vercel]: "traffic-vercel",
|
|
75754
|
+
[TrafficSourceTypes.cloudflare]: "traffic-cloudflare"
|
|
75755
|
+
};
|
|
75756
|
+
function trafficSourceArchived(sourceId, sourceType, projectName) {
|
|
75757
|
+
const integration = TRAFFIC_CONNECT_INTEGRATIONS[sourceType];
|
|
75758
|
+
const remediation = integration ? connectSteps(integration, projectName) : "Connect a new source from the project's Server traffic tab.";
|
|
75759
|
+
return validationError(`Traffic source "${sourceId}" is archived and no longer syncs. ${remediation}`, { reason: "traffic-source-archived", sourceType, remediation });
|
|
75760
|
+
}
|
|
75637
75761
|
function sameCloudRunTarget(saved, config) {
|
|
75638
75762
|
return saved.authMode === config.authMode && saved.gcpProjectId === config.gcpProjectId && (saved.serviceName ?? null) === (config.serviceName ?? null) && (saved.location ?? null) === (config.location ?? null);
|
|
75639
75763
|
}
|
|
@@ -76187,7 +76311,7 @@ async function runBackfillTaskHoldingLease(options, signal) {
|
|
|
76187
76311
|
}
|
|
76188
76312
|
};
|
|
76189
76313
|
if (sourceRow2.sourceType === TrafficSourceTypes.wordpress) {
|
|
76190
|
-
markFailed(`Generic WordPress replace backfill is unavailable because retained coverage is unproven. Record a span that cannot be recovered with \`canonry traffic declare-gap ${project.name} --source ${sourceRow2.id}\`.`);
|
|
76314
|
+
markFailed(`Generic WordPress replace backfill is unavailable because retained coverage is unproven. Record a span that cannot be recovered with \`canonry traffic declare-gap ${shellQuote(project.name)} --source ${sourceRow2.id}\`.`);
|
|
76191
76315
|
reportBackfill({ status: OutcomeStatuses.failed, reasonCode: OutcomeReasonCodes.UNSUPPORTED });
|
|
76192
76316
|
return;
|
|
76193
76317
|
}
|
|
@@ -77331,7 +77455,7 @@ async function trafficRoutes(app, opts) {
|
|
|
77331
77455
|
...cloudflarePageViewInstructions(forwardPageViews, CloudflareTrafficDeliveryModes["direct-push"]),
|
|
77332
77456
|
"",
|
|
77333
77457
|
`Source id: ${sourceRow2.id}`,
|
|
77334
|
-
"After deploy, check `canonry doctor --project " + project.name + "` to confirm events are arriving."
|
|
77458
|
+
"After deploy, check `canonry doctor --project " + shellQuote(project.name) + "` to confirm events are arriving."
|
|
77335
77459
|
].join("\n");
|
|
77336
77460
|
return {
|
|
77337
77461
|
sourceId: sourceRow2.id,
|
|
@@ -78024,9 +78148,7 @@ async function trafficRoutes(app, opts) {
|
|
|
78024
78148
|
const credential = credentialStore.getConnection(project.name);
|
|
78025
78149
|
if (!credential) {
|
|
78026
78150
|
app.db.delete(runs).where(eq116(runs.id, runId)).run();
|
|
78027
|
-
throw validationError
|
|
78028
|
-
`No WordPress credential found for project "${project.name}". Run "canonry traffic connect wordpress" first.`
|
|
78029
|
-
);
|
|
78151
|
+
throw notConnectedRefusal(validationError, `No WordPress credential found for project "${project.name}".`, "traffic-wordpress", project.name);
|
|
78030
78152
|
}
|
|
78031
78153
|
if (sourceRow2.lastCursor && !sourceRow2.wordpressPendingUntil) {
|
|
78032
78154
|
const message = "WordPress source has a legacy continuation cursor without a bounded pending window. Reset it explicitly before resuming sync.";
|
|
@@ -78130,9 +78252,7 @@ async function trafficRoutes(app, opts) {
|
|
|
78130
78252
|
const credential = credentialStore.getConnection(project.name);
|
|
78131
78253
|
if (!credential) {
|
|
78132
78254
|
app.db.delete(runs).where(eq116(runs.id, runId)).run();
|
|
78133
|
-
throw validationError
|
|
78134
|
-
`No Vercel credential found for project "${project.name}". Run "canonry traffic connect vercel" first.`
|
|
78135
|
-
);
|
|
78255
|
+
throw notConnectedRefusal(validationError, `No Vercel credential found for project "${project.name}".`, "traffic-vercel", project.name);
|
|
78136
78256
|
}
|
|
78137
78257
|
const config = parseSourceConfig(sourceRow2);
|
|
78138
78258
|
const vercelProjectId = config.projectId ?? credential.projectId;
|
|
@@ -78615,7 +78735,7 @@ async function trafficRoutes(app, opts) {
|
|
|
78615
78735
|
}
|
|
78616
78736
|
if (sourceRow2.sourceType !== TrafficSourceTypes["cloud-run"] && sourceRow2.sourceType !== TrafficSourceTypes.wordpress && sourceRow2.sourceType !== TrafficSourceTypes.vercel) {
|
|
78617
78737
|
throw validationError(
|
|
78618
|
-
`Backfill for source type "${sourceRow2.sourceType}" is not implemented yet \u2014 generic replace backfill supports only cloud-run and vercel; a WordPress gap is recorded with \`canonry traffic declare-gap
|
|
78738
|
+
`Backfill for source type "${sourceRow2.sourceType}" is not implemented yet \u2014 generic replace backfill supports only cloud-run and vercel; a WordPress gap is recorded with \`canonry traffic declare-gap <project> --source <id>\`.`
|
|
78619
78739
|
);
|
|
78620
78740
|
}
|
|
78621
78741
|
if (!isAuthoritativeTrafficSource(app.db, sourceRow2)) {
|
|
@@ -78623,7 +78743,7 @@ async function trafficRoutes(app, opts) {
|
|
|
78623
78743
|
}
|
|
78624
78744
|
if (sourceRow2.sourceType === TrafficSourceTypes.wordpress) {
|
|
78625
78745
|
throw validationError(
|
|
78626
|
-
`Generic WordPress replace backfill is unavailable because retained coverage is unproven. Record a span that cannot be recovered with \`canonry traffic declare-gap ${project.name} --source ${sourceRow2.id}\`.`
|
|
78746
|
+
`Generic WordPress replace backfill is unavailable because retained coverage is unproven. Record a span that cannot be recovered with \`canonry traffic declare-gap ${shellQuote(project.name)} --source ${sourceRow2.id}\`.`
|
|
78627
78747
|
);
|
|
78628
78748
|
}
|
|
78629
78749
|
const requestedDays = request.body?.days ?? DEFAULT_BACKFILL_DAYS;
|
|
@@ -78669,9 +78789,7 @@ async function trafficRoutes(app, opts) {
|
|
|
78669
78789
|
}
|
|
78670
78790
|
const credential = credentialStore.getConnection(project.name);
|
|
78671
78791
|
if (!credential) {
|
|
78672
|
-
throw validationError
|
|
78673
|
-
`No Vercel credential found for project "${project.name}". Run "canonry traffic connect vercel" first.`
|
|
78674
|
-
);
|
|
78792
|
+
throw notConnectedRefusal(validationError, `No Vercel credential found for project "${project.name}".`, "traffic-vercel", project.name);
|
|
78675
78793
|
}
|
|
78676
78794
|
const config = parseSourceConfig(sourceRow2);
|
|
78677
78795
|
const vercelProjectId = config.projectId ?? credential.projectId;
|
|
@@ -78859,9 +78977,7 @@ async function trafficRoutes(app, opts) {
|
|
|
78859
78977
|
throw notFound("traffic source", request.params.id);
|
|
78860
78978
|
}
|
|
78861
78979
|
if (sourceRow2.status === TrafficSourceStatuses.archived) {
|
|
78862
|
-
throw
|
|
78863
|
-
`Traffic source "${sourceRow2.id}" is archived. Re-connect via "canonry traffic connect ..." to start tracking it again.`
|
|
78864
|
-
);
|
|
78980
|
+
throw trafficSourceArchived(sourceRow2.id, sourceRow2.sourceType, project.name);
|
|
78865
78981
|
}
|
|
78866
78982
|
if (sourceRow2.status === TrafficSourceStatuses.paused) {
|
|
78867
78983
|
throw validationError(
|
|
@@ -79590,7 +79706,7 @@ var reportModelsCheck = {
|
|
|
79590
79706
|
status: excluded.length || insufficient.length ? CheckStatuses.warn : CheckStatuses.ok,
|
|
79591
79707
|
code: excluded.length ? "report.models.excluded" : insufficient.length ? "report.models.insufficient" : "report.models.continuous",
|
|
79592
79708
|
summary: excluded.length ? `Monthly comparison excludes ${excluded.join("; ")}.` : insufficient.length ? `No common query/provider evidence establishes model continuity for ${insufficient.map(frameLabel).join(", ")}.` : "All compared providers have continuous snapshot model evidence.",
|
|
79593
|
-
remediation: excluded.length || insufficient.length ? `Inspect canonry visibility-compare ${ctx.project.name} --from ${flagged.previousMonth} --to ${flagged.month} --format json
|
|
79709
|
+
remediation: excluded.length || insufficient.length ? `Inspect \`canonry visibility-compare ${shellQuote(ctx.project.name)} --from ${flagged.previousMonth} --to ${flagged.month} --format json\`; do not pool excluded providers into a trend.` : null,
|
|
79594
79710
|
details: { months }
|
|
79595
79711
|
};
|
|
79596
79712
|
}
|
|
@@ -79700,7 +79816,7 @@ var reportDailyDataCheck = {
|
|
|
79700
79816
|
const gaUnknown = sources.some((source) => source.source === "ga" && source.unknownDays > 0);
|
|
79701
79817
|
const oldest = months[0].month;
|
|
79702
79818
|
const days = inclusiveDayCount(calendarMonthBounds(oldest).since.slice(0, 10), (/* @__PURE__ */ new Date()).toISOString().slice(0, 10)) ?? 1;
|
|
79703
|
-
const commands = [...new Set(sources.filter((source) => source.unknownDays > 0).map((source) => source.source === "ga" ? `canonry ga sync ${ctx.project.name} --days ${Math.min(90, days)}` : `canonry google sync ${ctx.project.name} --days ${Math.min(480, days)}`))];
|
|
79819
|
+
const commands = [...new Set(sources.filter((source) => source.unknownDays > 0).map((source) => source.source === "ga" ? `canonry ga sync ${shellQuote(ctx.project.name)} --days ${Math.min(90, days)}` : `canonry google sync ${shellQuote(ctx.project.name)} --days ${Math.min(480, days)}`))];
|
|
79704
79820
|
return {
|
|
79705
79821
|
status: unknown ? CheckStatuses.warn : mature ? CheckStatuses.ok : CheckStatuses.skipped,
|
|
79706
79822
|
code: unknown ? "report.daily-data.unknown" : mature ? "report.daily-data.observed" : "report.daily-data.pending",
|
|
@@ -79747,7 +79863,7 @@ var REFERRAL_ASSESSMENT_CHECKS = [{
|
|
|
79747
79863
|
status: CheckStatuses.warn,
|
|
79748
79864
|
code: "report.ai-referral-bursts.bursts",
|
|
79749
79865
|
summary: `${bursts.map((month) => `${month.month}: ${month.suspected.total} suspected hits in ${month.candidateGroups} candidate group${month.candidateGroups === 1 ? "" : "s"}`).join("; ")}. Raw headlines are unchanged; review before quoting AI referral totals.`,
|
|
79750
|
-
remediation: `Inspect canonry traffic referral-assessment ${ctx.project.name} --start
|
|
79866
|
+
remediation: `Inspect \`canonry traffic referral-assessment ${shellQuote(ctx.project.name)} --start ${first.month}-01 --end ${calendarMonthBounds(first.month).until.slice(0, 10)} --format json\`. A candidate group is one source, product, normalized path and UTC hour whose countable hits reach the threshold; it is not confirmed automation. Current records cannot verify complete server intervals or the GA reporting timezone. Keep raw counts and GA evidence separate; a high quotient does not confirm automation.`,
|
|
79751
79867
|
details: { months }
|
|
79752
79868
|
};
|
|
79753
79869
|
}
|
|
@@ -80116,7 +80232,7 @@ var BACKLINKS_CHECKS = [
|
|
|
80116
80232
|
status: CheckStatuses.warn,
|
|
80117
80233
|
code: "backlinks.source.none",
|
|
80118
80234
|
summary: state.hasCurrentReadyRelease ? `A Common Crawl release is synced, but no backlinks have been extracted for ${ctx.project.name} yet.` : `No backlinks have been extracted for ${ctx.project.name} yet, and no Common Crawl release is currently ready.`,
|
|
80119
|
-
remediation: state.hasCurrentReadyRelease ? `Run \`canonry backlinks extract ${ctx.project.name}\` to extract this project's backlinks from the synced release.` : "Run `canonry backlinks sync` to make a Common Crawl release ready and extract the workspace projects.",
|
|
80235
|
+
remediation: state.hasCurrentReadyRelease ? `Run \`canonry backlinks extract ${shellQuote(ctx.project.name)}\` to extract this project's backlinks from the synced release.` : "Run `canonry backlinks sync` to make a Common Crawl release ready and extract the workspace projects.",
|
|
80120
80236
|
details
|
|
80121
80237
|
};
|
|
80122
80238
|
}
|
|
@@ -80179,14 +80295,14 @@ var BING_AUTH_CHECKS = [
|
|
|
80179
80295
|
status: CheckStatuses.skipped,
|
|
80180
80296
|
code: "bing.auth.not-connected",
|
|
80181
80297
|
summary: `${ctx.project.name} has not connected Bing Webmaster Tools.`,
|
|
80182
|
-
remediation: `Optional: run \`canonry bing connect ${ctx.project.name} --api-key <key>\` to track Bing indexing.`
|
|
80298
|
+
remediation: `Optional: run \`canonry bing connect ${shellQuote(ctx.project.name)} --api-key <key>\` to track Bing indexing.`
|
|
80183
80299
|
};
|
|
80184
80300
|
}
|
|
80185
80301
|
return {
|
|
80186
80302
|
status: CheckStatuses.fail,
|
|
80187
80303
|
code: "bing.auth.no-connection",
|
|
80188
80304
|
summary: `No Bing connection for ${ctx.project.canonicalDomain}, but ${ctx.project.name} has stored Bing data from an earlier connection.`,
|
|
80189
|
-
remediation: `Run \`canonry bing connect ${ctx.project.name} --api-key <key>\` to authorize.`
|
|
80305
|
+
remediation: `Run \`canonry bing connect ${shellQuote(ctx.project.name)} --api-key <key>\` to authorize.`
|
|
80190
80306
|
};
|
|
80191
80307
|
}
|
|
80192
80308
|
if (!conn.apiKey) {
|
|
@@ -80194,7 +80310,7 @@ var BING_AUTH_CHECKS = [
|
|
|
80194
80310
|
status: CheckStatuses.fail,
|
|
80195
80311
|
code: "bing.auth.no-api-key",
|
|
80196
80312
|
summary: "Bing connection exists but has no API key stored.",
|
|
80197
|
-
remediation: `Run \`canonry bing connect ${ctx.project.name} --api-key <key>\` to re-authorize.`
|
|
80313
|
+
remediation: `Run \`canonry bing connect ${shellQuote(ctx.project.name)} --api-key <key>\` to re-authorize.`
|
|
80198
80314
|
};
|
|
80199
80315
|
}
|
|
80200
80316
|
try {
|
|
@@ -80254,7 +80370,7 @@ var BING_AUTH_CHECKS = [
|
|
|
80254
80370
|
status: CheckStatuses.fail,
|
|
80255
80371
|
code: "bing.auth.no-site-selected",
|
|
80256
80372
|
summary: "Bing connection has no site URL selected.",
|
|
80257
|
-
remediation: `Run \`canonry bing sites ${ctx.project.name}\` to see available sites, then \`canonry bing set-site ${ctx.project.name} <url>\`.`
|
|
80373
|
+
remediation: `Run \`canonry bing sites ${shellQuote(ctx.project.name)}\` to see available sites, then \`canonry bing set-site ${shellQuote(ctx.project.name)} <url>\`.`
|
|
80258
80374
|
};
|
|
80259
80375
|
}
|
|
80260
80376
|
try {
|
|
@@ -80265,7 +80381,7 @@ var BING_AUTH_CHECKS = [
|
|
|
80265
80381
|
status: CheckStatuses.fail,
|
|
80266
80382
|
code: "bing.auth.site-not-found",
|
|
80267
80383
|
summary: `Configured site "${conn.siteUrl}" is not in the authorized account's site list.`,
|
|
80268
|
-
remediation: `Add and verify "${conn.siteUrl}" in Bing Webmaster Tools, or pick an existing site using \`canonry bing set-site ${ctx.project.name}
|
|
80384
|
+
remediation: `Add and verify "${conn.siteUrl}" in Bing Webmaster Tools, or pick an existing site using \`canonry bing set-site ${shellQuote(ctx.project.name)} <url>\`.`,
|
|
80269
80385
|
details: {
|
|
80270
80386
|
configuredSite: conn.siteUrl,
|
|
80271
80387
|
availableSites: sites.map((s) => s.Url)
|
|
@@ -80350,7 +80466,7 @@ var winnabilityCoverageCheck = {
|
|
|
80350
80466
|
status: CheckStatuses.skipped,
|
|
80351
80467
|
code: "content.winnability.no-cited-surface",
|
|
80352
80468
|
summary: "No non-owned cited-surface domains in recent content evidence, so the winnability gate has nothing to classify yet.",
|
|
80353
|
-
remediation: `Run \`canonry run ${ctx.project.name}\` to capture fresh answer-engine citations before checking discovery coverage.`,
|
|
80469
|
+
remediation: `Run \`canonry run ${shellQuote(ctx.project.name)}\` to capture fresh answer-engine citations before checking discovery coverage.`,
|
|
80354
80470
|
details: {
|
|
80355
80471
|
citedSurfaceDomainCount: 0,
|
|
80356
80472
|
classifiedDomainCount: input.domainClasses.size
|
|
@@ -80374,7 +80490,7 @@ var winnabilityCoverageCheck = {
|
|
|
80374
80490
|
unclassifiedDomains: unclassifiedDomains.slice(0, UNCLASSIFIED_DOMAIN_SAMPLE_LIMIT)
|
|
80375
80491
|
};
|
|
80376
80492
|
const hasIcp = Boolean(project.icpDescription && project.icpDescription.trim().length > 0);
|
|
80377
|
-
const discoverRemediation = hasIcp ? `Run \`canonry discover run ${ctx.project.name} --wait\` to classify the unrecognized domains before relying on ownable/ceded content targets.` : `This project has no ICP, which discovery requires. Run \`canonry discover run ${ctx.project.name} --icp "<who the project sells to>" --wait\` (or set \`spec.icpDescription\`) to classify the unrecognized domains.`;
|
|
80493
|
+
const discoverRemediation = hasIcp ? `Run \`canonry discover run ${shellQuote(ctx.project.name)} --wait\` to classify the unrecognized domains before relying on ownable/ceded content targets.` : `This project has no ICP, which discovery requires. Run \`canonry discover run ${shellQuote(ctx.project.name)} --icp "<who the project sells to>" --wait\` (or set \`spec.icpDescription\`) to classify the unrecognized domains.`;
|
|
80378
80494
|
if (coveredDomains.length === 0) {
|
|
80379
80495
|
return {
|
|
80380
80496
|
status: CheckStatuses.warn,
|
|
@@ -80473,7 +80589,7 @@ async function checkOAuthConnection(ctx, projectName, conn) {
|
|
|
80473
80589
|
status: CheckStatuses.fail,
|
|
80474
80590
|
code: "ga.auth.no-property-selected",
|
|
80475
80591
|
summary: "GA4 OAuth connection has no property selected.",
|
|
80476
|
-
remediation: `Run \`canonry google connect ${projectName} --type ga4\` to select a property.`
|
|
80592
|
+
remediation: `Run \`canonry google connect ${shellQuote(projectName)} --type ga4\` to select a property.`
|
|
80477
80593
|
};
|
|
80478
80594
|
}
|
|
80479
80595
|
if (!conn.refreshToken) {
|
|
@@ -80481,7 +80597,7 @@ async function checkOAuthConnection(ctx, projectName, conn) {
|
|
|
80481
80597
|
status: CheckStatuses.fail,
|
|
80482
80598
|
code: "ga.auth.no-refresh-token",
|
|
80483
80599
|
summary: "GA4 OAuth connection has no refresh token stored.",
|
|
80484
|
-
remediation: `Run \`canonry google connect ${projectName} --type ga4\` to re-authorize and capture a refresh token.`,
|
|
80600
|
+
remediation: `Run \`canonry google connect ${shellQuote(projectName)} --type ga4\` to re-authorize and capture a refresh token.`,
|
|
80485
80601
|
details: { propertyId: conn.propertyId }
|
|
80486
80602
|
};
|
|
80487
80603
|
}
|
|
@@ -80507,7 +80623,7 @@ async function checkOAuthConnection(ctx, projectName, conn) {
|
|
|
80507
80623
|
status: CheckStatuses.fail,
|
|
80508
80624
|
code: "ga.auth.refresh-failed",
|
|
80509
80625
|
summary: "GA4 OAuth refresh token rejected by Google.",
|
|
80510
|
-
remediation: `Run \`canonry google connect ${projectName} --type ga4\` to re-authorize.`,
|
|
80626
|
+
remediation: `Run \`canonry google connect ${shellQuote(projectName)} --type ga4\` to re-authorize.`,
|
|
80511
80627
|
details: { propertyId: conn.propertyId, error: message, authMethod: "oauth" }
|
|
80512
80628
|
};
|
|
80513
80629
|
}
|
|
@@ -80522,7 +80638,7 @@ async function checkOAuthConnection(ctx, projectName, conn) {
|
|
|
80522
80638
|
status: CheckStatuses.fail,
|
|
80523
80639
|
code: "ga.auth.verify-failed",
|
|
80524
80640
|
summary: "GA4 OAuth token cannot reach the configured property.",
|
|
80525
|
-
remediation: `Verify the authorized Google account has access to property ${conn.propertyId}, or run \`canonry google connect ${projectName} --type ga4\` to re-authorize.`,
|
|
80641
|
+
remediation: `Verify the authorized Google account has access to property ${conn.propertyId}, or run \`canonry google connect ${shellQuote(projectName)} --type ga4\` to re-authorize.`,
|
|
80526
80642
|
details: { propertyId: conn.propertyId, error: message, authMethod: "oauth" }
|
|
80527
80643
|
};
|
|
80528
80644
|
}
|
|
@@ -80566,7 +80682,7 @@ var ga4ConnectionCheck = {
|
|
|
80566
80682
|
status: CheckStatuses.warn,
|
|
80567
80683
|
code: "ga.auth.no-connection",
|
|
80568
80684
|
summary: "No GA4 connection configured for this project.",
|
|
80569
|
-
remediation: `Run \`canonry google connect ${ctx.project.name} --type ga4\` to authorize via OAuth, or set up a service account in ~/.canonry/config.yaml under \`ga4.connections\`.`
|
|
80685
|
+
remediation: `Run \`canonry google connect ${shellQuote(ctx.project.name)} --type ga4\` to authorize via OAuth, or set up a service account in ~/.canonry/config.yaml under \`ga4.connections\`.`
|
|
80570
80686
|
};
|
|
80571
80687
|
}
|
|
80572
80688
|
};
|
|
@@ -80577,7 +80693,7 @@ import { and as and105, asc as asc29, desc as desc56, eq as eq123, gt as gt10, i
|
|
|
80577
80693
|
var GRACE_DAYS = 2;
|
|
80578
80694
|
var DAY_MS9 = 24 * 60 * 60 * 1e3;
|
|
80579
80695
|
var FIRING_SPAN_MS = 6e4;
|
|
80580
|
-
var REASON_LIMIT =
|
|
80696
|
+
var REASON_LIMIT = 1e3;
|
|
80581
80697
|
function skipped3(code, summary3) {
|
|
80582
80698
|
return { status: CheckStatuses.skipped, code, summary: summary3, remediation: null };
|
|
80583
80699
|
}
|
|
@@ -80620,6 +80736,19 @@ function unsettledRuns(ctx, projectId, firing, profiles) {
|
|
|
80620
80736
|
});
|
|
80621
80737
|
}
|
|
80622
80738
|
var COUNT_LIST = new Intl.ListFormat("en", { style: "long", type: "conjunction" });
|
|
80739
|
+
function summaryReasons(reasons) {
|
|
80740
|
+
const shown = [];
|
|
80741
|
+
let length = 0;
|
|
80742
|
+
for (const reason of reasons) {
|
|
80743
|
+
const added = (shown.length > 0 ? 1 : 0) + reason.length;
|
|
80744
|
+
if (shown.length > 0 && length + added > REASON_LIMIT) break;
|
|
80745
|
+
shown.push(reason);
|
|
80746
|
+
length += added;
|
|
80747
|
+
}
|
|
80748
|
+
const text = shown[0].length > REASON_LIMIT ? `${truncateUtf16(shown[0], REASON_LIMIT)}...` : shown.join(" ");
|
|
80749
|
+
const more = reasons.length - shown.length;
|
|
80750
|
+
return more > 0 ? `${text} ${more} more ${more === 1 ? "reason is" : "reasons are"} in details.latestScheduledRuns.` : text;
|
|
80751
|
+
}
|
|
80623
80752
|
function refreshReason(ctx, run) {
|
|
80624
80753
|
const stored = parseRunError(run.error);
|
|
80625
80754
|
if (stored) return formatRunErrorOneLine(stored);
|
|
@@ -80646,7 +80775,7 @@ function gradeSeoRefresh(ctx, project) {
|
|
|
80646
80775
|
const schedule = ctx.db.select().from(schedules).where(and105(eq123(schedules.projectId, project.id), eq123(schedules.kind, SchedulableRunKinds["seo-sync"]))).get();
|
|
80647
80776
|
if (!schedule) return skipped3("seo.data.not-scheduled", "No SEO refresh schedule is set for this project.");
|
|
80648
80777
|
if (!schedule.enabled) return skipped3("seo.data.not-scheduled", "The SEO refresh schedule is disabled.");
|
|
80649
|
-
const name = project.name;
|
|
80778
|
+
const name = shellQuote(project.name);
|
|
80650
80779
|
const day = (iso2) => formatIsoDateInTimeZone(iso2, schedule.timezone);
|
|
80651
80780
|
const now = Date.now();
|
|
80652
80781
|
const timing = scheduleTiming(schedule);
|
|
@@ -80686,7 +80815,7 @@ function gradeSeoRefresh(ctx, project) {
|
|
|
80686
80815
|
alert: {
|
|
80687
80816
|
label: "SEO schedule invalid",
|
|
80688
80817
|
line: "The SEO refresh schedule has no time it can run, so SEO data never refreshes.",
|
|
80689
|
-
next: `Set it again with canonry schedule set ${name} --kind seo-sync
|
|
80818
|
+
next: `Set it again with \`canonry schedule set ${name} --kind seo-sync --cron <expr>\`.`
|
|
80690
80819
|
}
|
|
80691
80820
|
};
|
|
80692
80821
|
}
|
|
@@ -80696,8 +80825,7 @@ function gradeSeoRefresh(ctx, project) {
|
|
|
80696
80825
|
if (newestFired && unsettled.length > 0) {
|
|
80697
80826
|
const failed = unsettled.some((run) => run.status === RunStatuses.failed);
|
|
80698
80827
|
const firedOn = day(newestFired.createdAt);
|
|
80699
|
-
const
|
|
80700
|
-
const reason = reasons.length > REASON_LIMIT ? `${truncateUtf16(reasons, REASON_LIMIT)}...` : reasons;
|
|
80828
|
+
const reason = summaryReasons([...new Set(unsettled.map((run) => refreshReason(ctx, run)))]);
|
|
80701
80829
|
const outcome2 = firing.length === 1 ? `The scheduled SEO refresh on ${firedOn} ${failed ? "failed" : "only partly completed"}` : `${unsettled.length} of ${firing.length} profile refreshes in the scheduled SEO refresh on ${firedOn} did not fully complete`;
|
|
80702
80830
|
const line = firing.length > 1 ? `${outcome2}.` : unsettled[0].error ? reason : `${outcome2}: ${reason}`;
|
|
80703
80831
|
const next = nextAt ? ` on ${day(nextAt)}` : "";
|
|
@@ -80705,7 +80833,7 @@ function gradeSeoRefresh(ctx, project) {
|
|
|
80705
80833
|
status: CheckStatuses.warn,
|
|
80706
80834
|
code: failed ? "seo.data.refresh-failed" : "seo.data.refresh-partial",
|
|
80707
80835
|
summary: `${outcome2}. Reason: ${reason} ${last ? `The last completed SEO refresh was on ${day(last.at)}.` : "No SEO refresh has completed yet."}`,
|
|
80708
|
-
remediation: `Fix what the reason names, then refresh now with \`canonry seo refresh-intent ${name} <profile-id>\` and \`canonry seo sync
|
|
80836
|
+
remediation: `Fix what the reason names, then refresh now with \`canonry seo refresh-intent ${name} <profile-id>\` and \`canonry seo sync ${name} --intent-token <token> --idempotency-key <key>\` (the token the intent returns and a key you choose), or wait for the next scheduled refresh${next}. A completed refresh of the same profile clears this warning.`,
|
|
80709
80837
|
details,
|
|
80710
80838
|
alert: {
|
|
80711
80839
|
label: failed ? "SEO refresh failed" : "SEO refresh incomplete",
|
|
@@ -80722,7 +80850,7 @@ function gradeSeoRefresh(ctx, project) {
|
|
|
80722
80850
|
status: CheckStatuses.warn,
|
|
80723
80851
|
code: "seo.data.overdue",
|
|
80724
80852
|
summary: `${since} ${missed}${active ? ` A refresh started ${day(active.createdAt)} has not finished, and scheduled refreshes wait for it.` : ""}`,
|
|
80725
|
-
remediation: active ? `Check that refresh with \`canonry seo run show ${name} ${active.id}\`, and cancel it with \`canonry seo run cancel ${name} ${active.id}\` if it is stuck.` : `Check that the server was running on ${day(dueAt)} and what \`canonry runs ${name} --kind seo-sync\` shows for that day. To refresh now, run \`canonry seo refresh-intent ${name} <profile-id>\`, then \`canonry seo sync
|
|
80853
|
+
remediation: active ? `Check that refresh with \`canonry seo run show ${name} ${active.id}\`, and cancel it with \`canonry seo run cancel ${name} ${active.id}\` if it is stuck.` : `Check that the server was running on ${day(dueAt)} and what \`canonry runs ${name} --kind seo-sync\` shows for that day. To refresh now, run \`canonry seo refresh-intent ${name} <profile-id>\`, then \`canonry seo sync ${name} --intent-token <token> --idempotency-key <key>\` with the token it returns and a key you choose.`,
|
|
80726
80854
|
details: { ...details, activeRunId: active?.id ?? null },
|
|
80727
80855
|
alert: {
|
|
80728
80856
|
label: "SEO refresh overdue",
|
|
@@ -81177,7 +81305,7 @@ async function grade2(prefix, ctx) {
|
|
|
81177
81305
|
status: CheckStatuses.fail,
|
|
81178
81306
|
code: `${id}.dns-blocked`,
|
|
81179
81307
|
summary: `${dnsBlocked.host} resolved to ${dnsBlocked.addresses.join(", ") || "no address"}; every ${prefix} sync fails before connecting.`,
|
|
81180
|
-
remediation: `Allow ${dnsBlocked.host} in this server's DNS filter or remove its hosts-file entry, then re-run \`canonry doctor --project ${ctx.project.name} --check ${checkId}\` and \`canonry ${syncCommand(prefix)} ${ctx.project.name}\`.`,
|
|
81308
|
+
remediation: `Allow ${dnsBlocked.host} in this server's DNS filter or remove its hosts-file entry, then re-run \`canonry doctor --project ${shellQuote(ctx.project.name)} --check ${checkId}\` and \`canonry ${syncCommand(prefix)} ${shellQuote(ctx.project.name)}\`.`,
|
|
81181
81309
|
details
|
|
81182
81310
|
};
|
|
81183
81311
|
}
|
|
@@ -81229,7 +81357,7 @@ var apiKeyCheck = {
|
|
|
81229
81357
|
status: CheckStatuses.skipped,
|
|
81230
81358
|
code: "gbp.places.no-gbp-connection",
|
|
81231
81359
|
summary: "No Google Business Profile connection; Places enrichment does not apply.",
|
|
81232
|
-
remediation: `Connect GBP first: \`canonry gbp connect ${ctx.project.name}\`.`
|
|
81360
|
+
remediation: `Connect GBP first: \`canonry gbp connect ${shellQuote(ctx.project.name)}\`.`
|
|
81233
81361
|
};
|
|
81234
81362
|
}
|
|
81235
81363
|
if (!cfg.apiKey) {
|
|
@@ -81255,7 +81383,7 @@ var apiKeyCheck = {
|
|
|
81255
81383
|
status: CheckStatuses.warn,
|
|
81256
81384
|
code: "gbp.places.no-place-ids",
|
|
81257
81385
|
summary: `None of the ${selected.length} selected location(s) have a Maps place id, so Places enrichment can't run.`,
|
|
81258
|
-
remediation: `Run \`canonry gbp locations discover ${ctx.project.name}\` to capture place ids from location metadata.`,
|
|
81386
|
+
remediation: `Run \`canonry gbp locations discover ${shellQuote(ctx.project.name)}\` to capture place ids from location metadata.`,
|
|
81259
81387
|
details
|
|
81260
81388
|
};
|
|
81261
81389
|
}
|
|
@@ -81276,7 +81404,7 @@ var PLACES_CHECK_BY_ID = Object.fromEntries(
|
|
|
81276
81404
|
// ../api-routes/src/doctor/checks/gbp-reviews.ts
|
|
81277
81405
|
import { and as and106, desc as desc57, eq as eq126, gte as gte33, inArray as inArray56, sql as sql54 } from "drizzle-orm";
|
|
81278
81406
|
var REVIEW_EVENTS = /* @__PURE__ */ new Set(["review.negative", "review.rating-dropped"]);
|
|
81279
|
-
var V4_ACCESS_REMEDIATION = "Business Profile reviews use the legacy My Business API (mybusiness.googleapis.com), which Google enables per Cloud project only on request; the API Library and `gcloud services enable` cannot turn it on. Open the enable link in the API access approval email as the approved account, or reply to the access-request thread asking Google to enable mybusiness.googleapis.com for your project number, then run `canonry gbp sync
|
|
81407
|
+
var V4_ACCESS_REMEDIATION = "Business Profile reviews use the legacy My Business API (mybusiness.googleapis.com), which Google enables per Cloud project only on request; the API Library and `gcloud services enable` cannot turn it on. Open the enable link in the API access approval email as the approved account, or reply to the access-request thread asking Google to enable mybusiness.googleapis.com for your project number, then run `canonry gbp sync <project>`.";
|
|
81280
81408
|
var reviewsAccessCheck = {
|
|
81281
81409
|
id: "gbp.reviews.access",
|
|
81282
81410
|
category: CheckCategories.integrations,
|
|
@@ -81293,7 +81421,7 @@ var reviewsAccessCheck = {
|
|
|
81293
81421
|
status: CheckStatuses.skipped,
|
|
81294
81422
|
code: "gbp.reviews.no-gbp-connection",
|
|
81295
81423
|
summary: "No Google Business Profile connection; review alerts do not apply.",
|
|
81296
|
-
remediation: `Connect GBP first: \`canonry gbp connect ${project.name}\`.`
|
|
81424
|
+
remediation: `Connect GBP first: \`canonry gbp connect ${shellQuote(project.name)}\`.`
|
|
81297
81425
|
};
|
|
81298
81426
|
}
|
|
81299
81427
|
const locations = ctx.db.select({
|
|
@@ -81308,7 +81436,7 @@ var reviewsAccessCheck = {
|
|
|
81308
81436
|
status: CheckStatuses.skipped,
|
|
81309
81437
|
code: "gbp.reviews.no-locations",
|
|
81310
81438
|
summary: "No selected GBP locations.",
|
|
81311
|
-
remediation: `Discover and select locations: \`canonry gbp locations discover ${project.name}\`.`
|
|
81439
|
+
remediation: `Discover and select locations: \`canonry gbp locations discover ${shellQuote(project.name)}\`.`
|
|
81312
81440
|
};
|
|
81313
81441
|
}
|
|
81314
81442
|
if (!locations.some((loc) => loc.reviewsCheckedAt)) {
|
|
@@ -81316,7 +81444,7 @@ var reviewsAccessCheck = {
|
|
|
81316
81444
|
status: CheckStatuses.skipped,
|
|
81317
81445
|
code: "gbp.reviews.not-checked",
|
|
81318
81446
|
summary: "Review access has not been checked yet.",
|
|
81319
|
-
remediation: `Run \`canonry gbp sync ${project.name}\`.`
|
|
81447
|
+
remediation: `Run \`canonry gbp sync ${shellQuote(project.name)}\`.`
|
|
81320
81448
|
};
|
|
81321
81449
|
}
|
|
81322
81450
|
const places = ctx.getPlacesConfig?.();
|
|
@@ -81478,7 +81606,7 @@ async function resolveAccessToken(ctx) {
|
|
|
81478
81606
|
status: CheckStatuses.fail,
|
|
81479
81607
|
code: "google.auth.no-connection",
|
|
81480
81608
|
summary: `No GSC connection for ${ctx.project.canonicalDomain}.`,
|
|
81481
|
-
remediation: `Run \`canonry google connect ${ctx.project.name} --type gsc\` to authorize.`
|
|
81609
|
+
remediation: `Run \`canonry google connect ${shellQuote(ctx.project.name)} --type gsc\` to authorize.`
|
|
81482
81610
|
}
|
|
81483
81611
|
};
|
|
81484
81612
|
}
|
|
@@ -81489,7 +81617,7 @@ async function resolveAccessToken(ctx) {
|
|
|
81489
81617
|
status: CheckStatuses.fail,
|
|
81490
81618
|
code: "google.auth.no-refresh-token",
|
|
81491
81619
|
summary: "GSC connection exists but has no refresh token stored.",
|
|
81492
|
-
remediation: `Run \`canonry google connect ${ctx.project.name} --type gsc\` to re-authorize and capture a refresh token.`,
|
|
81620
|
+
remediation: `Run \`canonry google connect ${shellQuote(ctx.project.name)} --type gsc\` to re-authorize and capture a refresh token.`,
|
|
81493
81621
|
details: { domain: conn.domain }
|
|
81494
81622
|
}
|
|
81495
81623
|
};
|
|
@@ -81523,7 +81651,7 @@ async function resolveAccessToken(ctx) {
|
|
|
81523
81651
|
status: CheckStatuses.fail,
|
|
81524
81652
|
code: "google.auth.refresh-failed",
|
|
81525
81653
|
summary: "Refresh token rejected by Google.",
|
|
81526
|
-
remediation: `Run \`canonry google connect ${ctx.project.name} --type gsc\` to re-authorize. Refresh tokens are revoked if the user changes their password or the OAuth client is rotated.`,
|
|
81654
|
+
remediation: `Run \`canonry google connect ${shellQuote(ctx.project.name)} --type gsc\` to re-authorize. Refresh tokens are revoked if the user changes their password or the OAuth client is rotated.`,
|
|
81527
81655
|
details: { domain: conn.domain, error: message }
|
|
81528
81656
|
}
|
|
81529
81657
|
};
|
|
@@ -81583,7 +81711,7 @@ var propertyAccessCheck = {
|
|
|
81583
81711
|
status: CheckStatuses.fail,
|
|
81584
81712
|
code: "google.auth.no-property-selected",
|
|
81585
81713
|
summary: "GSC connection has no property selected.",
|
|
81586
|
-
remediation: `Run \`canonry google properties ${ctx.project.name}\` to list available properties, then \`canonry google set-property ${ctx.project.name} <siteUrl>\`.`
|
|
81714
|
+
remediation: `Run \`canonry google properties ${shellQuote(ctx.project.name)}\` to list available properties, then \`canonry google set-property ${shellQuote(ctx.project.name)} <siteUrl>\`.`
|
|
81587
81715
|
};
|
|
81588
81716
|
}
|
|
81589
81717
|
const resolved = await resolveAccessToken(ctx);
|
|
@@ -81604,7 +81732,7 @@ var propertyAccessCheck = {
|
|
|
81604
81732
|
status: CheckStatuses.fail,
|
|
81605
81733
|
code: "google.auth.principal-forbidden",
|
|
81606
81734
|
summary: "The authorized Google account is forbidden from listing GSC sites.",
|
|
81607
|
-
remediation: `Reconnect with a Google account that has access in Search Console: \`canonry google connect ${ctx.project.name} --type gsc\`.`,
|
|
81735
|
+
remediation: `Reconnect with a Google account that has access in Search Console: \`canonry google connect ${shellQuote(ctx.project.name)} --type gsc\`.`,
|
|
81608
81736
|
details: { error: err.message }
|
|
81609
81737
|
};
|
|
81610
81738
|
}
|
|
@@ -81633,7 +81761,7 @@ var propertyAccessCheck = {
|
|
|
81633
81761
|
status: CheckStatuses.fail,
|
|
81634
81762
|
code: "google.auth.property-not-accessible",
|
|
81635
81763
|
summary: `Selected property "${conn.propertyId}" is not in the authorized account's accessible sites list.`,
|
|
81636
|
-
remediation: `Either grant the authorizing Google account access to "${conn.propertyId}" in Search Console, or run \`canonry google set-property ${ctx.project.name} <siteUrl>\` to pick an accessible site.`,
|
|
81764
|
+
remediation: `Either grant the authorizing Google account access to "${conn.propertyId}" in Search Console, or run \`canonry google set-property ${shellQuote(ctx.project.name)} <siteUrl>\` to pick an accessible site.`,
|
|
81637
81765
|
details: {
|
|
81638
81766
|
selectedProperty: conn.propertyId,
|
|
81639
81767
|
accessibleSites: sites.map((s) => s.siteUrl)
|
|
@@ -81645,7 +81773,7 @@ var propertyAccessCheck = {
|
|
|
81645
81773
|
status: CheckStatuses.fail,
|
|
81646
81774
|
code: "google.auth.property-unverified",
|
|
81647
81775
|
summary: `Selected property "${conn.propertyId}" is present but unverified (permission: siteUnverifiedUser); Search Console reads will 403.`,
|
|
81648
|
-
remediation: `Re-verify the property in Search Console for the authorizing account (for a sc-domain property this is a google-site-verification DNS TXT record), then re-run \`canonry google sync ${ctx.project.name}\`.`,
|
|
81776
|
+
remediation: `Re-verify the property in Search Console for the authorizing account (for a sc-domain property this is a google-site-verification DNS TXT record), then re-run \`canonry google sync ${shellQuote(ctx.project.name)}\`.`,
|
|
81649
81777
|
details: {
|
|
81650
81778
|
selectedProperty: conn.propertyId,
|
|
81651
81779
|
permissionLevel: match.permissionLevel
|
|
@@ -81752,7 +81880,7 @@ var scopesCheck3 = {
|
|
|
81752
81880
|
status: CheckStatuses.fail,
|
|
81753
81881
|
code: "google.auth.required-scope-missing",
|
|
81754
81882
|
summary: "Neither the full nor read-only Search Console scope is granted, so GSC reads will fail.",
|
|
81755
|
-
remediation: `Reconnect to grant a Search Console scope: \`canonry google connect ${ctx.project.name} --type gsc\`.`,
|
|
81883
|
+
remediation: `Reconnect to grant a Search Console scope: \`canonry google connect ${shellQuote(ctx.project.name)} --type gsc\`.`,
|
|
81756
81884
|
details: { granted: [...granted], missing: [GSC_SCOPE, GSC_READONLY_SCOPE] }
|
|
81757
81885
|
};
|
|
81758
81886
|
}
|
|
@@ -81771,15 +81899,15 @@ var scopesCheck3 = {
|
|
|
81771
81899
|
status: CheckStatuses.warn,
|
|
81772
81900
|
code: "google.auth.sitemap-write-scope-missing",
|
|
81773
81901
|
summary: hasIndexingScope ? "The read-only Search Console scope supports existing GSC reads, but sitemap submission is unavailable." : "The read-only Search Console scope supports existing GSC reads, but sitemap submission and the Indexing API are unavailable.",
|
|
81774
|
-
remediation: `Reconnect to grant the full Search Console webmasters scope: \`canonry google connect ${ctx.project.name} --type gsc\`.`,
|
|
81902
|
+
remediation: `Reconnect to grant the full Search Console webmasters scope: \`canonry google connect ${shellQuote(ctx.project.name)} --type gsc\`.`,
|
|
81775
81903
|
details: { granted: [...granted], missing }
|
|
81776
81904
|
};
|
|
81777
81905
|
}
|
|
81778
81906
|
return {
|
|
81779
81907
|
status: CheckStatuses.warn,
|
|
81780
81908
|
code: "google.auth.indexing-scope-missing",
|
|
81781
|
-
summary:
|
|
81782
|
-
remediation: `Reconnect to grant missing scopes: \`canonry google connect ${ctx.project.name} --type gsc\`.`,
|
|
81909
|
+
summary: `Indexing API scope is not granted \u2014 \`canonry google request-indexing ${shellQuote(ctx.project.name)}\` will fail.`,
|
|
81910
|
+
remediation: `Reconnect to grant missing scopes: \`canonry google connect ${shellQuote(ctx.project.name)} --type gsc\`.`,
|
|
81783
81911
|
details: { granted: [...granted], missing: [INDEXING_SCOPE] }
|
|
81784
81912
|
};
|
|
81785
81913
|
}
|
|
@@ -82127,7 +82255,7 @@ var WORDPRESS_PUBLISH_CHECKS = [
|
|
|
82127
82255
|
status: CheckStatuses.skipped,
|
|
82128
82256
|
code: "wordpress.publish.not-configured",
|
|
82129
82257
|
summary: `No WordPress publishing connection configured for ${ctx.project.name}.`,
|
|
82130
|
-
remediation: `If this project publishes to WordPress, run \`canonry wordpress connect ${ctx.project.name} --url <url> --user <user>\`.`
|
|
82258
|
+
remediation: `If this project publishes to WordPress, run \`canonry wordpress connect ${shellQuote(ctx.project.name)} --url <url> --user <user> --app-password <password>\`.`
|
|
82131
82259
|
};
|
|
82132
82260
|
}
|
|
82133
82261
|
try {
|
|
@@ -82152,7 +82280,7 @@ var WORDPRESS_PUBLISH_CHECKS = [
|
|
|
82152
82280
|
status: CheckStatuses.fail,
|
|
82153
82281
|
code: "wordpress.publish.unauthorized",
|
|
82154
82282
|
summary: "WordPress rejected the stored application password.",
|
|
82155
|
-
remediation: `Regenerate the Application Password in wp-admin (Users \u2192 Profile \u2192 Application Passwords), then reconnect with \`canonry wordpress connect ${ctx.project.name} --url <url> --user <user>\`.`,
|
|
82283
|
+
remediation: `Regenerate the Application Password in wp-admin (Users \u2192 Profile \u2192 Application Passwords), then reconnect with \`canonry wordpress connect ${shellQuote(ctx.project.name)} --url <url> --user <user> --app-password <password>\`.`,
|
|
82156
82284
|
details: { error: err.message }
|
|
82157
82285
|
};
|
|
82158
82286
|
}
|
|
@@ -84559,6 +84687,7 @@ export {
|
|
|
84559
84687
|
resolveUserSession,
|
|
84560
84688
|
LoginAttemptLimiter,
|
|
84561
84689
|
createCredentialChecker,
|
|
84690
|
+
narrowKeyRefused,
|
|
84562
84691
|
requireInstanceAdministrator,
|
|
84563
84692
|
hashApiKey,
|
|
84564
84693
|
MCP_DELEGATED_KEY_MAX_AGE_MS,
|