@canonry/canonry 7.125.1 → 7.125.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/dist/activity-MYEOLXH7.js +13 -0
  2. package/dist/{ads-5EFVWQAT.js → ads-CKWRWWUL.js} +4 -4
  3. package/dist/{agent-P5WEU72Q.js → agent-ESSNC46H.js} +8 -8
  4. package/dist/{agent-ask-DQBDMPXP.js → agent-ask-37D6WCPX.js} +4 -4
  5. package/dist/{agent-conversations-K6IX3LQW.js → agent-conversations-GKY7Q2IO.js} +4 -4
  6. package/dist/{agent-journeys-72PYZCJH.js → agent-journeys-FIH4K5PI.js} +4 -4
  7. package/dist/{agent-memory-6GVOIDFK.js → agent-memory-FXWCBJRP.js} +4 -4
  8. package/dist/{agent-providers-TZJL475J.js → agent-providers-5AKSFZHC.js} +4 -4
  9. package/dist/{agent-transcript-L4IIMHXD.js → agent-transcript-F4HO6LWW.js} +4 -4
  10. package/dist/{analytics-7XKDB5OX.js → analytics-GJRUFRVW.js} +4 -4
  11. package/dist/{answerability-PE6Z2QHX.js → answerability-L5MS4AKC.js} +4 -4
  12. package/dist/{apply-LP2QYAOJ.js → apply-ZZQIJN4W.js} +4 -4
  13. package/dist/{backfill-FWKKCPH4.js → backfill-WK2FPQA7.js} +11 -11
  14. package/dist/{backlinks-GOQOLXYQ.js → backlinks-53DXYL4A.js} +4 -4
  15. package/dist/{bing-URWLP36H.js → bing-6G7LXZDT.js} +4 -4
  16. package/dist/{bootstrap-3D7WYMAK.js → bootstrap-ESCW4ZGJ.js} +11 -11
  17. package/dist/{cdp-HTUSJ3YA.js → cdp-BR54QYDW.js} +8 -8
  18. package/dist/{chunk-4JPL2SDU.js → chunk-27MI43WQ.js} +17 -5
  19. package/dist/{chunk-FJ22V5ED.js → chunk-2JMNIWOG.js} +7 -6
  20. package/dist/{chunk-ZJ6HMVLQ.js → chunk-2T4IZBIB.js} +1 -1
  21. package/dist/{chunk-O4S75UQI.js → chunk-6E7BS7BA.js} +5 -5
  22. package/dist/{chunk-PDWNORKC.js → chunk-6ZL5ILQI.js} +3 -3
  23. package/dist/{chunk-NVFFBVJJ.js → chunk-73ANFHPL.js} +5 -5
  24. package/dist/{chunk-PR5TQK3X.js → chunk-7Q5OVRVX.js} +3 -3
  25. package/dist/{chunk-XCJSH2FJ.js → chunk-7V3V5H7L.js} +5 -5
  26. package/dist/{chunk-HPRUS76O.js → chunk-B63ZO4TX.js} +6 -6
  27. package/dist/{chunk-GUPHVIGW.js → chunk-C7IGAN7U.js} +1 -1
  28. package/dist/{chunk-QE5LQD2D.js → chunk-DFEVW234.js} +83 -29
  29. package/dist/{chunk-FHJU7QBM.js → chunk-EEYFNSVL.js} +1 -1
  30. package/dist/{chunk-F7ZJX5O5.js → chunk-EWJKPCIT.js} +3 -3
  31. package/dist/{chunk-U73NIQKU.js → chunk-FBVCBRXQ.js} +4 -4
  32. package/dist/{chunk-LPQYGKS4.js → chunk-FJHPA47P.js} +4 -4
  33. package/dist/{chunk-VO3SF4M7.js → chunk-FM56GWUC.js} +377 -375
  34. package/dist/{chunk-IM3LJ45S.js → chunk-G46YLF5X.js} +2 -2
  35. package/dist/{chunk-GZHLGRVL.js → chunk-HN6UIFHO.js} +2 -2
  36. package/dist/{chunk-TNV7DLA7.js → chunk-J3C4XFWJ.js} +1 -1
  37. package/dist/{chunk-AVJIEIAV.js → chunk-JXKRQ63F.js} +2 -2
  38. package/dist/{chunk-5LZJGJFF.js → chunk-LEW6WFYV.js} +4 -0
  39. package/dist/{chunk-LUA7YIQG.js → chunk-MXDKDPRJ.js} +1 -1
  40. package/dist/{chunk-7M5QTA7T.js → chunk-OC35PZAC.js} +1 -1
  41. package/dist/{chunk-BH4562RA.js → chunk-ODEDQ4Z7.js} +2 -2
  42. package/dist/{chunk-472IO3E7.js → chunk-OXM2WUTJ.js} +1 -1
  43. package/dist/{chunk-KUO2TYF4.js → chunk-OZRJ73XU.js} +2 -2
  44. package/dist/{chunk-CSU4E5KJ.js → chunk-P2RFC35A.js} +5 -5
  45. package/dist/{chunk-5QR5GEGS.js → chunk-P42TP4BJ.js} +1 -1
  46. package/dist/{chunk-4A2GKNEM.js → chunk-QFGEFEKV.js} +4 -4
  47. package/dist/{chunk-6SFT25SX.js → chunk-R2F5JHCB.js} +2 -2
  48. package/dist/{chunk-KAFKHQCB.js → chunk-SP44JHI4.js} +4 -4
  49. package/dist/{chunk-CQXIA6T6.js → chunk-TZ5ALARK.js} +2 -2
  50. package/dist/{chunk-OTMAY3N2.js → chunk-WHH3XSRE.js} +2 -2
  51. package/dist/{chunk-WTAL4GJ4.js → chunk-XLJWITPC.js} +8 -8
  52. package/dist/{chunk-IN7LINUI.js → chunk-Y7Y3GDOM.js} +1 -1
  53. package/dist/{chunk-RSNOILNQ.js → chunk-YKB75BPD.js} +4 -4
  54. package/dist/{chunk-BEJWFEEJ.js → chunk-Z7TP2GD4.js} +1 -1
  55. package/dist/{chunk-3PPQMBTA.js → chunk-ZI5JGJFY.js} +121 -112
  56. package/dist/{citations-M7RCHTBO.js → citations-ZIDSGKRU.js} +5 -5
  57. package/dist/{cli-catalog-7WND6LOK.js → cli-catalog-6LW7C6JJ.js} +4 -4
  58. package/dist/cli-commands-MAM3MHKR.js +18 -0
  59. package/dist/cli.js +14 -14
  60. package/dist/{competitor-4J3V4SNA.js → competitor-SL756CGS.js} +4 -4
  61. package/dist/{content-LN27FEUU.js → content-K57ZUYTK.js} +4 -4
  62. package/dist/{dashboard-ZYVYVNTW.js → dashboard-XKP2Z7NL.js} +7 -7
  63. package/dist/{demo-OKZN2MIB.js → demo-3KROYDH3.js} +3 -3
  64. package/dist/{demo-server-JWBH7TVQ.js → demo-server-E7LTZ55I.js} +13 -13
  65. package/dist/{discover-AY7NU3SN.js → discover-RWVSCRJU.js} +5 -5
  66. package/dist/{discover-eval-OYO6HI5F.js → discover-eval-N4M5JU6F.js} +4 -4
  67. package/dist/{doctor-XZOIPYYT.js → doctor-NW4FDB77.js} +4 -4
  68. package/dist/{evidence-H3VPFFOR.js → evidence-FMUJNJSJ.js} +4 -4
  69. package/dist/{export-cmd-4SQREQZL.js → export-cmd-VALOYBEX.js} +4 -4
  70. package/dist/{ga-DYT6WOA4.js → ga-DPMYKD4B.js} +4 -4
  71. package/dist/{gbp-JDFCLW5K.js → gbp-AVZSBYRE.js} +4 -4
  72. package/dist/{google-KQAOZ5JT.js → google-YU4U7NGP.js} +5 -5
  73. package/dist/{google-marketing-HQPW42FL.js → google-marketing-6QVRXGBM.js} +2 -2
  74. package/dist/{health-cmd-LDQC4ICZ.js → health-cmd-WWLJRTUO.js} +5 -5
  75. package/dist/{history-3S77KY77.js → history-TTA7FGQW.js} +4 -4
  76. package/dist/index.d.ts +78 -78
  77. package/dist/index.js +26 -26
  78. package/dist/{init-FKTI62AC.js → init-7HJIOE4N.js} +13 -13
  79. package/dist/{insights-GUM2MK47.js → insights-Q5D55GAR.js} +4 -4
  80. package/dist/intelligence-service-EIVZPZDC.js +15 -0
  81. package/dist/{journeys-AG4425RQ.js → journeys-6TQ4XKFU.js} +4 -4
  82. package/dist/{keys-TWC2GRJX.js → keys-GEKZTCDB.js} +4 -4
  83. package/dist/{keyword-WKM3BZCJ.js → keyword-RFOYIC3F.js} +4 -4
  84. package/dist/{logs-7FHQF7UK.js → logs-JVV3JWBY.js} +4 -4
  85. package/dist/{mcp-NRESCMDK.js → mcp-F5UBBUYS.js} +5 -5
  86. package/dist/mcp.js +10 -10
  87. package/dist/{measurement-plan-2TJFII53.js → measurement-plan-3MBPWMKF.js} +6 -6
  88. package/dist/{notify-VQJKWE7U.js → notify-I6PK7D5F.js} +4 -4
  89. package/dist/{organic-evidence-UROWCQFB.js → organic-evidence-XGMEFGZV.js} +4 -4
  90. package/dist/{overview-6CY6EEYZ.js → overview-3CXTYKPK.js} +7 -7
  91. package/dist/{project-6G7FIFIX.js → project-NODDRMYN.js} +4 -4
  92. package/dist/{project-setup-3MPRV226.js → project-setup-O2ZHNOQA.js} +4 -4
  93. package/dist/{query-CXUVUGB3.js → query-FS5JMNWT.js} +4 -4
  94. package/dist/{research-5OFFBHNJ.js → research-PAQYTNO7.js} +4 -4
  95. package/dist/{results-export-WQ3ZI2RN.js → results-export-SXJ7QORQ.js} +4 -4
  96. package/dist/{run-7IWLOX3K.js → run-AKHP63FR.js} +6 -6
  97. package/dist/{schedule-7LTYEBTO.js → schedule-4UJCAZRL.js} +4 -4
  98. package/dist/{search-UIGFCJOH.js → search-M6F2BKN5.js} +4 -4
  99. package/dist/{serve-FAQV2N7V.js → serve-M5CIAJQP.js} +27 -27
  100. package/dist/{session-XCMWUFDH.js → session-FTWUJBXC.js} +14 -14
  101. package/dist/{settings-HNL5MRNK.js → settings-UYXGO73G.js} +4 -4
  102. package/dist/{sitemaps-C6QXTFX7.js → sitemaps-UFZAM5AM.js} +4 -4
  103. package/dist/{skills-4SATHKAZ.js → skills-CST64NUF.js} +3 -3
  104. package/dist/{snapshot-77XTVMTM.js → snapshot-R7M77CR2.js} +4 -4
  105. package/dist/{src-6UWY43K7.js → src-NPY2WNGF.js} +2 -2
  106. package/dist/{status-GK5N7DBQ.js → status-NWAVNBJC.js} +6 -6
  107. package/dist/{support-TLV5QQGD.js → support-AJYIPDYH.js} +2 -2
  108. package/dist/{technical-aeo-BY5K3WCE.js → technical-aeo-HNEUXZZ4.js} +4 -4
  109. package/dist/{telemetry-3CK2V5EZ.js → telemetry-4HMLYE5C.js} +5 -5
  110. package/dist/{tools-F2UCM5HU.js → tools-HQ5AFHJ2.js} +12 -12
  111. package/dist/{traffic-LVMK6SEY.js → traffic-MGZDVEAM.js} +6 -6
  112. package/dist/{trends-7JVT5AIN.js → trends-NMJFTKOE.js} +4 -4
  113. package/dist/{users-DMCJOD2L.js → users-HWBPRVSG.js} +4 -4
  114. package/dist/{visibility-stats-UWKATLY6.js → visibility-stats-DALS5MUL.js} +5 -5
  115. package/dist/{wordpress-TRWQSNRK.js → wordpress-23RX6PVT.js} +4 -4
  116. package/package.json +1 -1
  117. package/dist/activity-TDCPSQZ6.js +0 -13
  118. package/dist/cli-commands-CRYAJ6CX.js +0 -18
  119. package/dist/intelligence-service-7GKHJ3B4.js +0 -15
@@ -19,14 +19,14 @@ import {
19
19
  normalizeTrafficPathPattern,
20
20
  sessionizeJourneyRequests,
21
21
  verifyRequestSignature
22
- } from "./chunk-ZJ6HMVLQ.js";
22
+ } from "./chunk-2T4IZBIB.js";
23
23
  import {
24
24
  currentOutcomeAttribution,
25
25
  getRequestContext,
26
26
  registerRequestContext,
27
27
  requestAuditIdentity,
28
28
  sanitizeRequestContext
29
- } from "./chunk-TNV7DLA7.js";
29
+ } from "./chunk-J3C4XFWJ.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-7M5QTA7T.js";
194
+ } from "./chunk-OC35PZAC.js";
195
195
  import {
196
196
  ADS_ACTIVATE_SCOPE,
197
197
  ADS_ACTIVATION_ABSOLUTE_MAX_ENTITIES,
@@ -885,6 +885,7 @@ import {
885
885
  indexingRequestResponseDtoSchema,
886
886
  insightActionGroupByType,
887
887
  instanceStatusDtoSchema,
888
+ integrationNotConnected,
888
889
  integrationSettingsSummaryDtoSchema,
889
890
  internalError,
890
891
  intersectScopes,
@@ -1405,7 +1406,7 @@ import {
1405
1406
  wordpressSchemaDeployResultDtoSchema,
1406
1407
  wordpressSchemaStatusResultDtoSchema,
1407
1408
  wordpressStatusDtoSchema
1408
- } from "./chunk-5LZJGJFF.js";
1409
+ } from "./chunk-LEW6WFYV.js";
1409
1410
 
1410
1411
  // ../api-routes/src/user-session.ts
1411
1412
  import crypto2 from "crypto";
@@ -21290,7 +21291,7 @@ async function competitorSuggestionRoutes(app) {
21290
21291
  import crypto25 from "crypto";
21291
21292
  import { and as and45, eq as eq55, ne as ne9, asc as asc10, desc as desc19, inArray as inArray27, notInArray as notInArray3, or as or8, sql as sql21 } from "drizzle-orm";
21292
21293
  import { z as z4 } from "zod";
21293
- import { gte as gte12 } from "drizzle-orm";
21294
+ import { gte as gte12, lte as lte10 } from "drizzle-orm";
21294
21295
 
21295
21296
  // ../api-routes/src/run-fill.ts
21296
21297
  import crypto23 from "crypto";
@@ -22708,8 +22709,10 @@ async function runRoutes(app, opts) {
22708
22709
  const limit = Number.isNaN(parsedLimit) || parsedLimit <= 0 ? void 0 : parsedLimit;
22709
22710
  const { kind, excludeKind, excludeKinds, status } = parseListFilters(request.query);
22710
22711
  const filters = [eq55(runs.projectId, project.id)];
22711
- const since = parseListSince(request.query.since);
22712
+ const since = parseListTimestamp(request.query.since, "since");
22712
22713
  if (since) filters.push(gte12(runs.createdAt, since));
22714
+ const until = parseListTimestamp(request.query.until, "until");
22715
+ if (until) filters.push(lte10(runs.createdAt, until));
22713
22716
  if (kind) filters.push(eq55(runs.kind, kind));
22714
22717
  if (excludeKind) filters.push(ne9(runs.kind, excludeKind));
22715
22718
  if (excludeKinds?.length) filters.push(notInArray3(runs.kind, excludeKinds));
@@ -22766,7 +22769,7 @@ async function runRoutes(app, opts) {
22766
22769
  });
22767
22770
  app.get("/runs", async (request, reply) => {
22768
22771
  const limit = parseListLimit(request.query.limit, 500, 5e3);
22769
- const since = parseListSince(request.query.since, new Date(Date.now() - 30 * 24 * 60 * 60 * 1e3).toISOString());
22772
+ const since = parseListTimestamp(request.query.since, "since", new Date(Date.now() - 30 * 24 * 60 * 60 * 1e3).toISOString());
22770
22773
  const includeProbe = request.query.includeProbe === "1" || request.query.includeProbe === "true";
22771
22774
  const { kind, excludeKind, excludeKinds, status } = parseListFilters(request.query);
22772
22775
  const filters = [gte12(runs.createdAt, since)];
@@ -22781,7 +22784,7 @@ async function runRoutes(app, opts) {
22781
22784
  return reply.send(rows.map(formatRun));
22782
22785
  });
22783
22786
  app.get("/runs/attention", async (request, reply) => {
22784
- const since = parseListSince(request.query.since, new Date(Date.now() - OVERVIEW_ACTIVITY_DEFAULT_DAYS * 24 * 60 * 60 * 1e3).toISOString());
22787
+ const since = parseListTimestamp(request.query.since, "since", new Date(Date.now() - OVERVIEW_ACTIVITY_DEFAULT_DAYS * 24 * 60 * 60 * 1e3).toISOString());
22785
22788
  const filters = [gte12(runs.createdAt, since), notProbeRun(), notInArray3(runs.kind, [...OVERVIEW_ACTIVITY_EXCLUDED_KINDS])];
22786
22789
  const scopedProjectId = request.apiKey?.projectId;
22787
22790
  if (scopedProjectId) filters.push(eq55(runs.projectId, scopedProjectId));
@@ -23098,11 +23101,11 @@ function parseListFilters(query2) {
23098
23101
  const message = invalid.length > 0 ? invalid.map((field) => `"${field}" must be one of: ${RUN_LIST_FILTER_OPTIONS[field].join(", ")}`).join("; ") : "Invalid run list filters";
23099
23102
  throw validationError(message, { invalid: Object.fromEntries(invalid.map((field) => [field, query2[field]])) });
23100
23103
  }
23101
- function parseListSince(raw, fallback) {
23104
+ function parseListTimestamp(raw, field, fallback) {
23102
23105
  if (raw === void 0) return fallback;
23103
23106
  const date = new Date(raw);
23104
23107
  if (Number.isNaN(date.getTime())) {
23105
- throw validationError('"since" must be a valid ISO 8601 timestamp');
23108
+ throw validationError(`"${field}" must be a valid ISO 8601 timestamp`);
23106
23109
  }
23107
23110
  return date.toISOString();
23108
23111
  }
@@ -25899,7 +25902,7 @@ async function technicalAeoRoutes(app, opts) {
25899
25902
 
25900
25903
  // ../api-routes/src/visibility-report.ts
25901
25904
  import { createHash as createHash6 } from "crypto";
25902
- import { and as and48, desc as desc21, eq as eq58, gte as gte14, inArray as inArray29, isNotNull as isNotNull9, isNull as isNull12, lt as lt12, lte as lte10, or as or10 } from "drizzle-orm";
25905
+ import { and as and48, desc as desc21, eq as eq58, gte as gte14, inArray as inArray29, isNotNull as isNotNull9, isNull as isNull12, lt as lt12, lte as lte11, or as or10 } from "drizzle-orm";
25903
25906
 
25904
25907
  // ../api-routes/src/visibility-report-reader.ts
25905
25908
  import { createHash as createHash5 } from "crypto";
@@ -27142,7 +27145,7 @@ function completedVisibilityRuns(db, projectId, planless, query2) {
27142
27145
  query2.runId === void 0 ? notScopedRun() : void 0,
27143
27146
  query2.runId === void 0 ? void 0 : eq58(runs.id, query2.runId),
27144
27147
  query2.from === void 0 ? void 0 : gte14(runs.createdAt, query2.from),
27145
- query2.to === void 0 ? void 0 : lte10(runs.createdAt, query2.to)
27148
+ query2.to === void 0 ? void 0 : lte11(runs.createdAt, query2.to)
27146
27149
  )).orderBy(desc21(runs.createdAt), desc21(runs.id)).limit(VISIBILITY_REPORT_MAX_RUNS).all();
27147
27150
  }
27148
27151
  function previousEligibleVisibilityRun(db, projectId, planless, selected) {
@@ -27454,7 +27457,7 @@ function readVisibilityComparisonRuns(db, projectId, since, until, includeEviden
27454
27457
  isNotNull9(runs.measurementPlanVersionId),
27455
27458
  notScopedRun(),
27456
27459
  gte14(runs.createdAt, since),
27457
- lte10(runs.createdAt, until)
27460
+ lte11(runs.createdAt, until)
27458
27461
  )).all();
27459
27462
  const versionRows = db.select().from(measurementPlanVersions).where(eq58(measurementPlanVersions.projectId, projectId)).all();
27460
27463
  const rowsById = new Map(versionRows.map((version) => [version.id, version]));
@@ -36993,7 +36996,7 @@ async function applyRoutes(app, opts) {
36993
36996
  }
36994
36997
 
36995
36998
  // ../api-routes/src/history.ts
36996
- import { and as and59, asc as asc15, count as count7, getTableColumns as getTableColumns2, desc as desc27, eq as eq70, gte as gte15, inArray as inArray35, like as like3, lte as lte11, ne as ne11, notInArray as notInArray4, or as or12, sql as sql26 } from "drizzle-orm";
36999
+ import { and as and59, asc as asc15, count as count7, getTableColumns as getTableColumns2, desc as desc27, eq as eq70, gte as gte15, inArray as inArray35, like as like3, lte as lte12, ne as ne11, notInArray as notInArray4, or as or12, sql as sql26 } from "drizzle-orm";
36997
37000
  async function historyRoutes(app) {
36998
37001
  app.post("/projects/:name/results/clear", async (request) => {
36999
37002
  requireAdminSession(request);
@@ -37350,7 +37353,7 @@ function parseAuditHistoryQuery(query2) {
37350
37353
  }
37351
37354
  function addAuditHistoryFilters(filters, query2) {
37352
37355
  if (query2.since) filters.push(gte15(auditLog.createdAt, new Date(query2.since).toISOString()));
37353
- if (query2.until) filters.push(lte11(auditLog.createdAt, new Date(query2.until).toISOString()));
37356
+ if (query2.until) filters.push(lte12(auditLog.createdAt, new Date(query2.until).toISOString()));
37354
37357
  if (query2.actionPrefix) filters.push(sql26`${auditLog.action} LIKE ${escapeLikePattern(query2.actionPrefix) + "%"} ESCAPE '\\'`);
37355
37358
  if (query2.entityId) filters.push(eq70(auditLog.entityId, query2.entityId));
37356
37359
  if (query2.excludeEntityTypes?.length) filters.push(notInArray4(auditLog.entityType, query2.excludeEntityTypes));
@@ -38612,7 +38615,7 @@ async function intelligenceRoutes(app) {
38612
38615
  }
38613
38616
 
38614
38617
  // ../api-routes/src/traffic-analytics.ts
38615
- import { and as and64, desc as desc31, eq as eq74, gte as gte17, lt as lt16, lte as lte12, ne as ne12, sql as sql29 } from "drizzle-orm";
38618
+ import { and as and64, desc as desc31, eq as eq74, gte as gte17, lt as lt16, lte as lte13, ne as ne12, sql as sql29 } from "drizzle-orm";
38616
38619
 
38617
38620
  // ../api-routes/src/ai-referral-status.ts
38618
38621
  import { and as and62, sql as sql27 } from "drizzle-orm";
@@ -38711,7 +38714,7 @@ function readTrafficActivity(db, projectId, windowDays2) {
38711
38714
  eq74(crawlerEventsHourly.projectId, projectId),
38712
38715
  eq74(crawlerEventsHourly.verificationStatus, VerificationStatuses.verified),
38713
38716
  gte17(crawlerEventsHourly.tsHour, windowStartIso),
38714
- exclusiveEnd ? lt16(crawlerEventsHourly.tsHour, windowEndIso) : lte12(crawlerEventsHourly.tsHour, windowEndIso)
38717
+ exclusiveEnd ? lt16(crawlerEventsHourly.tsHour, windowEndIso) : lte13(crawlerEventsHourly.tsHour, windowEndIso)
38715
38718
  )
38716
38719
  ).get()?.total ?? 0
38717
38720
  );
@@ -38721,7 +38724,7 @@ function readTrafficActivity(db, projectId, windowDays2) {
38721
38724
  eq74(crawlerEventsHourly.projectId, projectId),
38722
38725
  ne12(crawlerEventsHourly.verificationStatus, VerificationStatuses.verified),
38723
38726
  gte17(crawlerEventsHourly.tsHour, windowStartIso),
38724
- exclusiveEnd ? lt16(crawlerEventsHourly.tsHour, windowEndIso) : lte12(crawlerEventsHourly.tsHour, windowEndIso)
38727
+ exclusiveEnd ? lt16(crawlerEventsHourly.tsHour, windowEndIso) : lte13(crawlerEventsHourly.tsHour, windowEndIso)
38725
38728
  )
38726
38729
  ).get()?.total ?? 0
38727
38730
  );
@@ -38735,7 +38738,7 @@ function readTrafficActivity(db, projectId, windowDays2) {
38735
38738
  eq74(aiReferralEventsHourly.projectId, projectId),
38736
38739
  countableReferralCondition(),
38737
38740
  gte17(aiReferralEventsHourly.tsHour, windowStartIso),
38738
- exclusiveEnd ? lt16(aiReferralEventsHourly.tsHour, windowEndIso) : lte12(aiReferralEventsHourly.tsHour, windowEndIso)
38741
+ exclusiveEnd ? lt16(aiReferralEventsHourly.tsHour, windowEndIso) : lte13(aiReferralEventsHourly.tsHour, windowEndIso)
38739
38742
  )
38740
38743
  ).get();
38741
38744
  return aiReferralClassCounts(Number(row?.total ?? 0), Number(row?.paid ?? 0), Number(row?.organic ?? 0));
@@ -38745,7 +38748,7 @@ function readTrafficActivity(db, projectId, windowDays2) {
38745
38748
  and64(
38746
38749
  eq74(aiUserFetchEventsHourly.projectId, projectId),
38747
38750
  gte17(aiUserFetchEventsHourly.tsHour, windowStartIso),
38748
- exclusiveEnd ? lt16(aiUserFetchEventsHourly.tsHour, windowEndIso) : lte12(aiUserFetchEventsHourly.tsHour, windowEndIso)
38751
+ exclusiveEnd ? lt16(aiUserFetchEventsHourly.tsHour, windowEndIso) : lte13(aiUserFetchEventsHourly.tsHour, windowEndIso)
38749
38752
  )
38750
38753
  ).get()?.total ?? 0
38751
38754
  );
@@ -38762,7 +38765,7 @@ function readTrafficActivity(db, projectId, windowDays2) {
38762
38765
  eq74(aiReferralEventsHourly.projectId, projectId),
38763
38766
  nonSubresourceReferralPathCondition(),
38764
38767
  gte17(aiReferralEventsHourly.tsHour, headlineStart),
38765
- lte12(aiReferralEventsHourly.tsHour, headlineEnd)
38768
+ lte13(aiReferralEventsHourly.tsHour, headlineEnd)
38766
38769
  )
38767
38770
  ).get()?.total ?? 0
38768
38771
  );
@@ -38776,7 +38779,7 @@ function readTrafficActivity(db, projectId, windowDays2) {
38776
38779
  and64(
38777
38780
  eq74(crawlerEventsHourly.projectId, projectId),
38778
38781
  gte17(crawlerEventsHourly.tsHour, headlineStart),
38779
- lte12(crawlerEventsHourly.tsHour, headlineEnd)
38782
+ lte13(crawlerEventsHourly.tsHour, headlineEnd)
38780
38783
  )
38781
38784
  ).groupBy(crawlerEventsHourly.operator, crawlerEventsHourly.verificationStatus).all();
38782
38785
  const crawlerByOperatorPriorRows = db.select({
@@ -38797,7 +38800,7 @@ function readTrafficActivity(db, projectId, windowDays2) {
38797
38800
  eq74(aiReferralEventsHourly.projectId, projectId),
38798
38801
  countableReferralCondition(),
38799
38802
  gte17(aiReferralEventsHourly.tsHour, headlineStart),
38800
- lte12(aiReferralEventsHourly.tsHour, headlineEnd)
38803
+ lte13(aiReferralEventsHourly.tsHour, headlineEnd)
38801
38804
  )
38802
38805
  ).groupBy(aiReferralEventsHourly.operator).all();
38803
38806
  const userFetchByOperatorRows = db.select({
@@ -38807,7 +38810,7 @@ function readTrafficActivity(db, projectId, windowDays2) {
38807
38810
  and64(
38808
38811
  eq74(aiUserFetchEventsHourly.projectId, projectId),
38809
38812
  gte17(aiUserFetchEventsHourly.tsHour, headlineStart),
38810
- lte12(aiUserFetchEventsHourly.tsHour, headlineEnd)
38813
+ lte13(aiUserFetchEventsHourly.tsHour, headlineEnd)
38811
38814
  )
38812
38815
  ).groupBy(aiUserFetchEventsHourly.operator).all();
38813
38816
  const operatorAgg = /* @__PURE__ */ new Map();
@@ -38852,7 +38855,7 @@ function readTrafficActivity(db, projectId, windowDays2) {
38852
38855
  and64(
38853
38856
  eq74(crawlerEventsHourly.projectId, projectId),
38854
38857
  gte17(crawlerEventsHourly.tsHour, headlineStart),
38855
- lte12(crawlerEventsHourly.tsHour, headlineEnd)
38858
+ lte13(crawlerEventsHourly.tsHour, headlineEnd)
38856
38859
  )
38857
38860
  ).groupBy(crawlerEventsHourly.pathNormalized).orderBy(desc31(sql29`SUM(${crawlerEventsHourly.hits})`)).limit(SERVER_ACTIVITY_TOP_PATHS_LIMIT).all();
38858
38861
  const topCrawledPaths = topPathsRows.map((r) => ({
@@ -38870,7 +38873,7 @@ function readTrafficActivity(db, projectId, windowDays2) {
38870
38873
  eq74(aiReferralEventsHourly.projectId, projectId),
38871
38874
  countableReferralCondition(),
38872
38875
  gte17(aiReferralEventsHourly.tsHour, headlineStart),
38873
- lte12(aiReferralEventsHourly.tsHour, headlineEnd)
38876
+ lte13(aiReferralEventsHourly.tsHour, headlineEnd)
38874
38877
  )
38875
38878
  ).groupBy(aiReferralEventsHourly.product).orderBy(desc31(sql29`SUM(${aiReferralEventsHourly.sessionsOrHits})`)).all();
38876
38879
  const referralProducts = referralProductsRows.map((r) => ({
@@ -38887,7 +38890,7 @@ function readTrafficActivity(db, projectId, windowDays2) {
38887
38890
  eq74(aiReferralEventsHourly.projectId, projectId),
38888
38891
  countableReferralCondition(),
38889
38892
  gte17(aiReferralEventsHourly.tsHour, headlineStart),
38890
- lte12(aiReferralEventsHourly.tsHour, headlineEnd)
38893
+ lte13(aiReferralEventsHourly.tsHour, headlineEnd)
38891
38894
  )
38892
38895
  ).groupBy(aiReferralEventsHourly.landingPathNormalized).orderBy(desc31(sql29`SUM(${aiReferralEventsHourly.sessionsOrHits})`)).limit(SERVER_ACTIVITY_TOP_PATHS_LIMIT).all();
38893
38896
  const topReferralLandingPaths = topReferralRows.map((r) => ({
@@ -38903,7 +38906,7 @@ function readTrafficActivity(db, projectId, windowDays2) {
38903
38906
  and64(
38904
38907
  eq74(crawlerEventsHourly.projectId, projectId),
38905
38908
  gte17(crawlerEventsHourly.tsHour, trendStart),
38906
- lte12(crawlerEventsHourly.tsHour, headlineEnd)
38909
+ lte13(crawlerEventsHourly.tsHour, headlineEnd)
38907
38910
  )
38908
38911
  ).groupBy(sql29`SUBSTR(${crawlerEventsHourly.tsHour}, 1, 10)`).all();
38909
38912
  const referralTrendRows = db.select({
@@ -38914,7 +38917,7 @@ function readTrafficActivity(db, projectId, windowDays2) {
38914
38917
  eq74(aiReferralEventsHourly.projectId, projectId),
38915
38918
  countableReferralCondition(),
38916
38919
  gte17(aiReferralEventsHourly.tsHour, trendStart),
38917
- lte12(aiReferralEventsHourly.tsHour, headlineEnd)
38920
+ lte13(aiReferralEventsHourly.tsHour, headlineEnd)
38918
38921
  )
38919
38922
  ).groupBy(sql29`SUBSTR(${aiReferralEventsHourly.tsHour}, 1, 10)`).all();
38920
38923
  const userFetchTrendRows = db.select({
@@ -38924,7 +38927,7 @@ function readTrafficActivity(db, projectId, windowDays2) {
38924
38927
  and64(
38925
38928
  eq74(aiUserFetchEventsHourly.projectId, projectId),
38926
38929
  gte17(aiUserFetchEventsHourly.tsHour, trendStart),
38927
- lte12(aiUserFetchEventsHourly.tsHour, headlineEnd)
38930
+ lte13(aiUserFetchEventsHourly.tsHour, headlineEnd)
38928
38931
  )
38929
38932
  ).groupBy(sql29`SUBSTR(${aiUserFetchEventsHourly.tsHour}, 1, 10)`).all();
38930
38933
  const emptyTrendEntry = () => ({ verifiedCrawlerHits: 0, unverifiedCrawlerHits: 0, userFetchHits: 0, referralArrivals: 0 });
@@ -39010,7 +39013,7 @@ async function trafficAnalyticsRoutes(app) {
39010
39013
  }
39011
39014
 
39012
39015
  // ../api-routes/src/traffic-samples.ts
39013
- import { and as and65, count as count8, desc as desc32, eq as eq75, gte as gte18, inArray as inArray39, lte as lte13, sql as sql30 } from "drizzle-orm";
39016
+ import { and as and65, count as count8, desc as desc32, eq as eq75, gte as gte18, inArray as inArray39, lte as lte14, sql as sql30 } from "drizzle-orm";
39014
39017
  var storedKind = {
39015
39018
  [TrafficSampleKinds.crawler]: RawEventSampleEventTypes.crawler,
39016
39019
  [TrafficSampleKinds["ai-user-fetch"]]: RawEventSampleEventTypes.aiUserFetch,
@@ -39032,7 +39035,7 @@ async function trafficSamplesRoutes(app) {
39032
39035
  if (windowStart > windowEnd) throw validationError("since must not be after until", { reason: "invalid-window" });
39033
39036
  const limit = query2.limit ?? 100;
39034
39037
  const offset = query2.offset ?? 0;
39035
- const filters = [eq75(rawEventSamples.projectId, project.id), gte18(rawEventSamples.ts, windowStart), lte13(rawEventSamples.ts, windowEnd)];
39038
+ const filters = [eq75(rawEventSamples.projectId, project.id), gte18(rawEventSamples.ts, windowStart), lte14(rawEventSamples.ts, windowEnd)];
39036
39039
  filters.push(query2.kind && query2.kind !== "all" ? eq75(rawEventSamples.eventType, storedKind[query2.kind]) : inArray39(rawEventSamples.eventType, [storedKind[TrafficSampleKinds.crawler], storedKind[TrafficSampleKinds["ai-user-fetch"]], storedKind[TrafficSampleKinds["ai-referral"]]]));
39037
39040
  if (query2.sourceId) filters.push(eq75(rawEventSamples.sourceId, query2.sourceId));
39038
39041
  if (query2.path !== void 0) filters.push(sql30`${rawEventSamples.pathNormalized} LIKE ${escapeLikePattern(query2.path) + "%"} ESCAPE '\\'`);
@@ -39055,7 +39058,7 @@ async function trafficSamplesRoutes(app) {
39055
39058
  }
39056
39059
 
39057
39060
  // ../api-routes/src/traffic-unrecognized-agents.ts
39058
- import { and as and66, eq as eq76, gte as gte19, lte as lte14 } from "drizzle-orm";
39061
+ import { and as and66, eq as eq76, gte as gte19, lte as lte15 } from "drizzle-orm";
39059
39062
  var DEFAULT_WINDOW_MS = 30 * 864e5;
39060
39063
  var DEFAULT_LIMIT4 = 100;
39061
39064
  function hourFloor(iso2) {
@@ -39077,7 +39080,7 @@ async function trafficUnrecognizedAgentsRoutes(app) {
39077
39080
  if (windowStart > windowEnd) throw validationError("since must not be after until", { reason: "invalid-window" });
39078
39081
  const scope = [eq76(unrecognizedAgentEventsHourly.projectId, project.id)];
39079
39082
  if (query2.sourceId) scope.push(eq76(unrecognizedAgentEventsHourly.sourceId, query2.sourceId));
39080
- const rows = app.db.select().from(unrecognizedAgentEventsHourly).where(and66(...scope, gte19(unrecognizedAgentEventsHourly.tsHour, hourFloor(windowStart)), lte14(unrecognizedAgentEventsHourly.tsHour, windowEnd))).all();
39083
+ const rows = app.db.select().from(unrecognizedAgentEventsHourly).where(and66(...scope, gte19(unrecognizedAgentEventsHourly.tsHour, hourFloor(windowStart)), lte15(unrecognizedAgentEventsHourly.tsHour, windowEnd))).all();
39081
39084
  const byName = /* @__PURE__ */ new Map();
39082
39085
  for (const row of rows) {
39083
39086
  const agent = byName.get(row.agentName);
@@ -39120,7 +39123,7 @@ async function trafficUnrecognizedAgentsRoutes(app) {
39120
39123
  }
39121
39124
 
39122
39125
  // ../api-routes/src/agent-journeys.ts
39123
- import { and as and67, asc as asc16, eq as eq77, gte as gte20, lte as lte15, sql as sql31 } from "drizzle-orm";
39126
+ import { and as and67, asc as asc16, eq as eq77, gte as gte20, lte as lte16, sql as sql31 } from "drizzle-orm";
39124
39127
  var DAY_MS5 = 864e5;
39125
39128
  var BROWSER_AGENT_NAMES = new Intl.ListFormat("en", { style: "long", type: "conjunction" }).format(DEFAULT_AI_CRAWLER_RULES.filter((rule) => rule.browser).map((rule) => rule.product));
39126
39129
  var BROWSER_AGENT_LIMITATION = `Browser agent journeys (${BROWSER_AGENT_NAMES}) keep page loads, form posts and failed requests (HTTP 400-599). They leave out the files and data or API calls their pages made, ?_rsc= prefetches and client-side navigations, beacons, and HEAD and OPTIONS requests.`;
@@ -39226,17 +39229,17 @@ function readSequences(db, name, query2, recordingEnabled) {
39226
39229
  const targets = active ? active.plan.schemaVersion === 2 ? active.plan.targets.map((target) => ({ stableKey: target.stableKey, label: target.label, urls: target.urlMatchers })) : active.plan.targets.map((target) => ({ stableKey: target.stableKey, label: target.label, urls: target.urls })) : [];
39227
39230
  if (query2.targetKey && !targets.some((target) => target.stableKey === query2.targetKey)) throw validationError("Select a Property from the current measurement plan.", { reason: "unknown-target" });
39228
39231
  const retentionCutoff = new Date(Date.now() - AGENT_JOURNEY_RETENTION_DAYS * DAY_MS5).toISOString();
39229
- const filters = [eq77(agentJourneyEvents.projectId, project.id), gte20(agentJourneyEvents.ts, windowStart), gte20(agentJourneyEvents.ts, retentionCutoff), lte15(agentJourneyEvents.ts, windowEnd)];
39232
+ const filters = [eq77(agentJourneyEvents.projectId, project.id), gte20(agentJourneyEvents.ts, windowStart), gte20(agentJourneyEvents.ts, retentionCutoff), lte16(agentJourneyEvents.ts, windowEnd)];
39230
39233
  if (query2.sourceId) filters.push(eq77(agentJourneyEvents.sourceId, query2.sourceId));
39231
39234
  if (query2.agentId) filters.push(eq77(agentJourneyEvents.agentId, query2.agentId));
39232
39235
  const rows = db.select().from(agentJourneyEvents).where(and67(...filters)).orderBy(asc16(agentJourneyEvents.ts), asc16(agentJourneyEvents.id)).limit(AGENT_JOURNEY_READ_EVENT_LIMIT + 1).all();
39233
39236
  if (rows.length > AGENT_JOURNEY_READ_EVENT_LIMIT) throw validationError("This selection exceeds 20,000 requests. Narrow the time window, source, or agent.", { reason: "agent-journey-read-limit", limit: AGENT_JOURNEY_READ_EVENT_LIMIT });
39234
- const capFilters = [eq77(agentJourneyCaptureDays.projectId, project.id), eq77(agentJourneyCaptureDays.capped, true), gte20(agentJourneyCaptureDays.day, windowStart.slice(0, 10)), lte15(agentJourneyCaptureDays.day, windowEnd.slice(0, 10))];
39237
+ const capFilters = [eq77(agentJourneyCaptureDays.projectId, project.id), eq77(agentJourneyCaptureDays.capped, true), gte20(agentJourneyCaptureDays.day, windowStart.slice(0, 10)), lte16(agentJourneyCaptureDays.day, windowEnd.slice(0, 10))];
39235
39238
  if (query2.sourceId) capFilters.push(eq77(agentJourneyCaptureDays.sourceId, query2.sourceId));
39236
39239
  const cappedSourceDays = db.select({ sourceId: agentJourneyCaptureDays.sourceId, day: agentJourneyCaptureDays.day }).from(agentJourneyCaptureDays).where(and67(...capFilters)).orderBy(asc16(agentJourneyCaptureDays.day), asc16(agentJourneyCaptureDays.sourceId)).all();
39237
39240
  let likelyFakeRequests = null;
39238
39241
  if (!query2.targetKey) {
39239
- const fakeFilters = [eq77(aiUserFetchLikelyFakeHourly.projectId, project.id), gte20(aiUserFetchLikelyFakeHourly.tsHour, hourStart(windowStart)), lte15(aiUserFetchLikelyFakeHourly.tsHour, windowEnd)];
39242
+ const fakeFilters = [eq77(aiUserFetchLikelyFakeHourly.projectId, project.id), gte20(aiUserFetchLikelyFakeHourly.tsHour, hourStart(windowStart)), lte16(aiUserFetchLikelyFakeHourly.tsHour, windowEnd)];
39240
39243
  if (query2.sourceId) fakeFilters.push(eq77(aiUserFetchLikelyFakeHourly.sourceId, query2.sourceId));
39241
39244
  if (query2.agentId) fakeFilters.push(eq77(aiUserFetchLikelyFakeHourly.botId, query2.agentId));
39242
39245
  likelyFakeRequests = Number(db.select({ total: sql31`COALESCE(SUM(${aiUserFetchLikelyFakeHourly.hits}), 0)` }).from(aiUserFetchLikelyFakeHourly).where(and67(...fakeFilters)).get()?.total ?? 0);
@@ -39321,7 +39324,7 @@ async function agentJourneyRoutes(app, opts) {
39321
39324
  }
39322
39325
 
39323
39326
  // ../api-routes/src/referral-assessment.ts
39324
- import { and as and68, desc as desc33, eq as eq78, gte as gte21, lte as lte16, ne as ne13, sql as sql32 } from "drizzle-orm";
39327
+ import { and as and68, desc as desc33, eq as eq78, gte as gte21, lte as lte17, ne as ne13, sql as sql32 } from "drizzle-orm";
39325
39328
 
39326
39329
  // ../api-routes/src/ga-referral-groups.ts
39327
39330
  var CHART_SERIES_LIMIT = 5;
@@ -39570,7 +39573,7 @@ function latestGaSyncQueriedWindow(db, projectId, startDate, endDate) {
39570
39573
  const leftByAnotherSync = db.select({ id: gaAiReferrals.id }).from(gaAiReferrals).where(and68(
39571
39574
  eq78(gaAiReferrals.projectId, projectId),
39572
39575
  gte21(gaAiReferrals.date, summary3.start),
39573
- lte16(gaAiReferrals.date, summary3.end),
39576
+ lte17(gaAiReferrals.date, summary3.end),
39574
39577
  ne13(gaAiReferrals.syncedAt, summary3.syncedAt)
39575
39578
  )).limit(1).get();
39576
39579
  return leftByAnotherSync === void 0;
@@ -39588,7 +39591,7 @@ function buildReferralAssessment(db, projectName, input) {
39588
39591
  const where = and68(
39589
39592
  eq78(aiReferralEventsHourly.projectId, project.id),
39590
39593
  gte21(aiReferralEventsHourly.tsHour, `${query2.startDate}T00:00:00.000Z`),
39591
- lte16(aiReferralEventsHourly.tsHour, `${query2.endDate}T23:59:59.999Z`),
39594
+ lte17(aiReferralEventsHourly.tsHour, `${query2.endDate}T23:59:59.999Z`),
39592
39595
  query2.sourceId ? eq78(aiReferralEventsHourly.sourceId, query2.sourceId) : void 0
39593
39596
  );
39594
39597
  const burstThreshold = query2.burstThreshold ?? DEFAULT_BURST_THRESHOLD;
@@ -39641,7 +39644,7 @@ function buildReferralAssessment(db, projectName, input) {
39641
39644
  sourceDimension: gaAiReferrals.sourceDimension,
39642
39645
  channelGroup: gaAiReferrals.channelGroup,
39643
39646
  sessions: sql32`sum(${gaAiReferrals.sessions})`
39644
- }).from(gaAiReferrals).where(and68(eq78(gaAiReferrals.projectId, project.id), gte21(gaAiReferrals.date, query2.startDate), lte16(gaAiReferrals.date, query2.endDate))).groupBy(gaAiReferrals.date, gaAiReferrals.source, gaAiReferrals.medium, gaAiReferrals.trafficClass, gaAiReferrals.sourceDimension, gaAiReferrals.channelGroup).all();
39647
+ }).from(gaAiReferrals).where(and68(eq78(gaAiReferrals.projectId, project.id), gte21(gaAiReferrals.date, query2.startDate), lte17(gaAiReferrals.date, query2.endDate))).groupBy(gaAiReferrals.date, gaAiReferrals.source, gaAiReferrals.medium, gaAiReferrals.trafficClass, gaAiReferrals.sourceDimension, gaAiReferrals.channelGroup).all();
39645
39648
  const gaSessions = gaRows.length ? resolveWinningDimensions(gaRows).reduce((sum, row) => sum + row.paidSessions + row.organicSessions, 0) : latestGaSyncQueriedWindow(db, project.id, query2.startDate, query2.endDate) ? 0 : null;
39646
39649
  const observedRatio = observedRows > 0 && gaSessions !== null && gaSessions > 0 ? Math.round(countable.total / gaSessions * 100) / 100 : null;
39647
39650
  const reasons = ["server-coverage-unproven", "ga-coverage-unproven", "ga-time-zone-unknown", "server-and-ga-units-differ"];
@@ -39683,7 +39686,7 @@ async function referralAssessmentRoutes(app) {
39683
39686
  }
39684
39687
 
39685
39688
  // ../api-routes/src/organic-evidence.ts
39686
- import { and as and70, desc as desc34, eq as eq80, gte as gte23, lte as lte18, or as or15, sql as sql35 } from "drizzle-orm";
39689
+ import { and as and70, desc as desc34, eq as eq80, gte as gte23, lte as lte19, or as or15, sql as sql35 } from "drizzle-orm";
39687
39690
 
39688
39691
  // ../api-routes/src/path-prefix-condition.ts
39689
39692
  import { or as or13, sql as sql33 } from "drizzle-orm";
@@ -39692,7 +39695,7 @@ function literalPathPrefixCondition(path8, prefix) {
39692
39695
  }
39693
39696
 
39694
39697
  // ../api-routes/src/ga-measurement-analysis.ts
39695
- import { and as and69, eq as eq79, gte as gte22, inArray as inArray40, lte as lte17, or as or14, sql as sql34 } from "drizzle-orm";
39698
+ import { and as and69, eq as eq79, gte as gte22, inArray as inArray40, lte as lte18, or as or14, sql as sql34 } from "drizzle-orm";
39696
39699
 
39697
39700
  // ../api-routes/src/ga-lead-rate.ts
39698
39701
  function resolveLeadEvents(measurement, state) {
@@ -40028,15 +40031,15 @@ function buildGaMeasurementAnalysis(db, projectName, options = {}) {
40028
40031
  const gaAnchor = [acquisitionAnchor, leadAnchor].filter((date) => date !== null).sort().at(-1) ?? null;
40029
40032
  const gaPeriods = gaAnchor ? buildPeriods(gaAnchor, days) : [];
40030
40033
  const gaStartDate = gaPeriods[0]?.startDate;
40031
- const acquisitionRows = gaStartDate ? db.select().from(gaAcquisitionDaily).where(and69(eq79(gaAcquisitionDaily.projectId, project.id), gte22(gaAcquisitionDaily.date, gaStartDate), lte17(gaAcquisitionDaily.date, gaAnchor))).all() : [];
40032
- const leadRows = gaStartDate && leadEventCondition !== null ? db.select().from(gaLeadEventsDaily).where(and69(eq79(gaLeadEventsDaily.projectId, project.id), leadEventCondition, gte22(gaLeadEventsDaily.date, gaStartDate), lte17(gaLeadEventsDaily.date, gaAnchor))).all() : [];
40034
+ const acquisitionRows = gaStartDate ? db.select().from(gaAcquisitionDaily).where(and69(eq79(gaAcquisitionDaily.projectId, project.id), gte22(gaAcquisitionDaily.date, gaStartDate), lte18(gaAcquisitionDaily.date, gaAnchor))).all() : [];
40035
+ const leadRows = gaStartDate && leadEventCondition !== null ? db.select().from(gaLeadEventsDaily).where(and69(eq79(gaLeadEventsDaily.projectId, project.id), leadEventCondition, gte22(gaLeadEventsDaily.date, gaStartDate), lte18(gaLeadEventsDaily.date, gaAnchor))).all() : [];
40033
40036
  const engagementAnchor = db.select({ date: sql34`max(${gaDailyTotals.date})` }).from(gaDailyTotals).where(eq79(gaDailyTotals.projectId, project.id)).get()?.date ?? null;
40034
40037
  const engagementPeriodWindow = engagementAnchor ? buildPeriods(engagementAnchor, days) : [];
40035
40038
  const engagementStartDate = engagementPeriodWindow[0]?.startDate;
40036
40039
  const engagementRows = engagementStartDate ? db.select().from(gaDailyTotals).where(and69(
40037
40040
  eq79(gaDailyTotals.projectId, project.id),
40038
40041
  gte22(gaDailyTotals.date, engagementStartDate),
40039
- lte17(gaDailyTotals.date, engagementAnchor)
40042
+ lte18(gaDailyTotals.date, engagementAnchor)
40040
40043
  )).all() : [];
40041
40044
  const engagementAvailableFrom = db.select({
40042
40045
  date: sql34`min(${gaDailyTotals.date})`
@@ -40050,9 +40053,9 @@ function buildGaMeasurementAnalysis(db, projectName, options = {}) {
40050
40053
  const gscAnchor = db.select({ date: sql34`max(${gscDailyTotals.date})` }).from(gscDailyTotals).where(eq79(gscDailyTotals.projectId, project.id)).get()?.date ?? null;
40051
40054
  const gscPeriods = gscAnchor ? buildPeriods(gscAnchor, days) : [];
40052
40055
  const gscStartDate = gscPeriods[0]?.startDate;
40053
- const propertyRows = gscStartDate ? db.select().from(gscDailyTotals).where(and69(eq79(gscDailyTotals.projectId, project.id), gte22(gscDailyTotals.date, gscStartDate), lte17(gscDailyTotals.date, gscAnchor))).all() : [];
40054
- const queryRows2 = gscStartDate ? db.select().from(gscQueryDailyTotals).where(and69(eq79(gscQueryDailyTotals.projectId, project.id), gte22(gscQueryDailyTotals.date, gscStartDate), lte17(gscQueryDailyTotals.date, gscAnchor))).all() : [];
40055
- const rawPageRows = gscStartDate ? db.select().from(gscSearchData).where(and69(eq79(gscSearchData.projectId, project.id), gte22(gscSearchData.date, gscStartDate), lte17(gscSearchData.date, gscAnchor))).all() : [];
40056
+ const propertyRows = gscStartDate ? db.select().from(gscDailyTotals).where(and69(eq79(gscDailyTotals.projectId, project.id), gte22(gscDailyTotals.date, gscStartDate), lte18(gscDailyTotals.date, gscAnchor))).all() : [];
40057
+ const queryRows2 = gscStartDate ? db.select().from(gscQueryDailyTotals).where(and69(eq79(gscQueryDailyTotals.projectId, project.id), gte22(gscQueryDailyTotals.date, gscStartDate), lte18(gscQueryDailyTotals.date, gscAnchor))).all() : [];
40058
+ const rawPageRows = gscStartDate ? db.select().from(gscSearchData).where(and69(eq79(gscSearchData.projectId, project.id), gte22(gscSearchData.date, gscStartDate), lte18(gscSearchData.date, gscAnchor))).all() : [];
40056
40059
  const acquisition = acquisitionRows.filter((row) => {
40057
40060
  const landingPage = normalizeLandingPage(row.landingPageNormalized ?? row.landingPage);
40058
40061
  return hostIsIncluded(row.hostName) && pageIsIncluded(landingPage);
@@ -40461,17 +40464,17 @@ function buildOrganicEvidence(db, projectName, periodDays) {
40461
40464
  const gscRows = gscStartDate && gscEndDate ? db.select().from(gscDailyTotals).where(and70(
40462
40465
  eq80(gscDailyTotals.projectId, project.id),
40463
40466
  gte23(gscDailyTotals.date, gscStartDate),
40464
- lte18(gscDailyTotals.date, gscEndDate)
40467
+ lte19(gscDailyTotals.date, gscEndDate)
40465
40468
  )).all() : [];
40466
40469
  const gaRows = gaStartDate && gaEndDate ? db.select().from(gaTrafficSnapshots).where(and70(
40467
40470
  eq80(gaTrafficSnapshots.projectId, project.id),
40468
40471
  gte23(gaTrafficSnapshots.date, gaStartDate),
40469
- lte18(gaTrafficSnapshots.date, gaEndDate)
40472
+ lte19(gaTrafficSnapshots.date, gaEndDate)
40470
40473
  )).all() : [];
40471
40474
  const nativeAcquisitionRows = nativeAcquisitionActive && nativeStartDate && nativeEndDate ? db.select().from(gaAcquisitionDaily).where(and70(
40472
40475
  eq80(gaAcquisitionDaily.projectId, project.id),
40473
40476
  gte23(gaAcquisitionDaily.date, nativeStartDate),
40474
- lte18(gaAcquisitionDaily.date, nativeEndDate)
40477
+ lte19(gaAcquisitionDaily.date, nativeEndDate)
40475
40478
  )).all().filter((row) => matchesMarketingHost(row.hostName, marketingHosts)) : [];
40476
40479
  const nativeOrganicRows = nativeAcquisitionRows.filter((row) => row.channelGroup === "Organic Search");
40477
40480
  const nativeWindowOrganicRows = nativeOrganicRows;
@@ -40510,7 +40513,7 @@ function buildOrganicEvidence(db, projectName, periodDays) {
40510
40513
  const namedRows = db.select().from(gscQueryDailyTotals).where(and70(
40511
40514
  eq80(gscQueryDailyTotals.projectId, project.id),
40512
40515
  gte23(gscQueryDailyTotals.date, startDate),
40513
- lte18(gscQueryDailyTotals.date, endDate)
40516
+ lte19(gscQueryDailyTotals.date, endDate)
40514
40517
  )).all();
40515
40518
  for (const row of namedRows) {
40516
40519
  const isBrand = categorizeQueryByIntent(row.query, brandTokens) === "brand";
@@ -40536,7 +40539,7 @@ function buildOrganicEvidence(db, projectName, periodDays) {
40536
40539
  totals: sumSearchRows(gscRows.filter((row) => inRange(row.date, cohort.startDate, cohort.endDate)))
40537
40540
  }))
40538
40541
  } : null;
40539
- const pageSearchRows = db.select().from(gscSearchData).where(and70(eq80(gscSearchData.projectId, project.id), gte23(gscSearchData.date, startDate), lte18(gscSearchData.date, endDate))).all().filter((row) => pageMatchesMarketingHost(row.page, marketingHosts));
40542
+ const pageSearchRows = db.select().from(gscSearchData).where(and70(eq80(gscSearchData.projectId, project.id), gte23(gscSearchData.date, startDate), lte19(gscSearchData.date, endDate))).all().filter((row) => pageMatchesMarketingHost(row.page, marketingHosts));
40540
40543
  const gaWindow = gaStartDate && gaEndDate ? gaRows.filter((row) => inRange(row.date, gaStartDate, gaEndDate)) : [];
40541
40544
  const legacyGaCohorts = gaCohorts.map((cohort) => ({
40542
40545
  ...cohort,
@@ -40563,7 +40566,7 @@ function buildOrganicEvidence(db, projectName, periodDays) {
40563
40566
  }))
40564
40567
  };
40565
40568
  }
40566
- const allGaAiRows = db.select().from(gaAiReferrals).where(and70(eq80(gaAiReferrals.projectId, project.id), gte23(gaAiReferrals.date, gaStartDate ?? startDate), lte18(gaAiReferrals.date, gaEndDate ?? endDate))).all().filter((row) => row.sourceDimension === "session");
40569
+ const allGaAiRows = db.select().from(gaAiReferrals).where(and70(eq80(gaAiReferrals.projectId, project.id), gte23(gaAiReferrals.date, gaStartDate ?? startDate), lte19(gaAiReferrals.date, gaEndDate ?? endDate))).all().filter((row) => row.sourceDimension === "session");
40567
40570
  const aiRows = gaStartDate && gaEndDate ? allGaAiRows.filter((row) => inRange(row.date, gaStartDate, gaEndDate)) : [];
40568
40571
  const gaAiReferralSummary = allGaAiRows.length ? {
40569
40572
  paidSessions: aiRows.filter((row) => row.trafficClass === AiReferralTrafficClasses.paid).reduce((count12, row) => count12 + row.sessions, 0),
@@ -40572,9 +40575,9 @@ function buildOrganicEvidence(db, projectName, periodDays) {
40572
40575
  const serverSources = db.select().from(trafficSources).where(eq80(trafficSources.projectId, project.id)).all();
40573
40576
  const serverStart = `${startDate}T00:00:00`;
40574
40577
  const serverEnd = `${endDate}T23:59:59.999Z`;
40575
- const allCrawlers = db.select().from(crawlerEventsHourly).where(and70(eq80(crawlerEventsHourly.projectId, project.id), gte23(crawlerEventsHourly.tsHour, serverStart), lte18(crawlerEventsHourly.tsHour, serverEnd))).all();
40576
- const allFetches = db.select().from(aiUserFetchEventsHourly).where(and70(eq80(aiUserFetchEventsHourly.projectId, project.id), gte23(aiUserFetchEventsHourly.tsHour, serverStart), lte18(aiUserFetchEventsHourly.tsHour, serverEnd))).all();
40577
- const allReferrals = db.select().from(aiReferralEventsHourly).where(and70(eq80(aiReferralEventsHourly.projectId, project.id), countableReferralCondition(), gte23(aiReferralEventsHourly.tsHour, serverStart), lte18(aiReferralEventsHourly.tsHour, serverEnd))).all();
40578
+ const allCrawlers = db.select().from(crawlerEventsHourly).where(and70(eq80(crawlerEventsHourly.projectId, project.id), gte23(crawlerEventsHourly.tsHour, serverStart), lte19(crawlerEventsHourly.tsHour, serverEnd))).all();
40579
+ const allFetches = db.select().from(aiUserFetchEventsHourly).where(and70(eq80(aiUserFetchEventsHourly.projectId, project.id), gte23(aiUserFetchEventsHourly.tsHour, serverStart), lte19(aiUserFetchEventsHourly.tsHour, serverEnd))).all();
40580
+ const allReferrals = db.select().from(aiReferralEventsHourly).where(and70(eq80(aiReferralEventsHourly.projectId, project.id), countableReferralCondition(), gte23(aiReferralEventsHourly.tsHour, serverStart), lte19(aiReferralEventsHourly.tsHour, serverEnd))).all();
40578
40581
  const [serverCoverageRow] = db.all(sql35`
40579
40582
  select
40580
40583
  min(day) as startDate,
@@ -42012,7 +42015,7 @@ function readVisibilityContinuity(db, projectName, months) {
42012
42015
  }
42013
42016
 
42014
42017
  // ../api-routes/src/results-export.ts
42015
- import { and as and74, asc as asc17, eq as eq84, gte as gte24, lte as lte19 } from "drizzle-orm";
42018
+ import { and as and74, asc as asc17, eq as eq84, gte as gte24, lte as lte20 } from "drizzle-orm";
42016
42019
  var CSV_COLUMNS = [
42017
42020
  "export_schema_version",
42018
42021
  "project_id",
@@ -42156,7 +42159,7 @@ async function resultsExportRoutes(app) {
42156
42159
  eq84(runs.kind, RunKinds["answer-visibility"]),
42157
42160
  ...includeProbes ? [] : [notProbeRun()],
42158
42161
  ...sinceIso ? [gte24(runs.createdAt, sinceIso)] : [],
42159
- ...untilIso ? [lte19(runs.createdAt, untilIso)] : []
42162
+ ...untilIso ? [lte20(runs.createdAt, untilIso)] : []
42160
42163
  ];
42161
42164
  const rows = app.db.select({
42162
42165
  runId: runs.id,
@@ -43345,7 +43348,7 @@ import crypto37 from "crypto";
43345
43348
  import { and as and78, desc as desc40, eq as eq89 } from "drizzle-orm";
43346
43349
 
43347
43350
  // ../api-routes/src/content-data.ts
43348
- import { and as and77, eq as eq88, desc as desc39, gte as gte25, inArray as inArray46, lte as lte20 } from "drizzle-orm";
43351
+ import { and as and77, eq as eq88, desc as desc39, gte as gte25, inArray as inArray46, lte as lte21 } from "drizzle-orm";
43349
43352
  var RECENT_RUNS_WINDOW = 5;
43350
43353
  function loadOrchestratorInput(db, project, locationFilter = void 0, gscWindowDays = DEFAULT_CONTENT_GSC_WINDOW_DAYS) {
43351
43354
  const projectId = project.id;
@@ -43514,7 +43517,7 @@ function buildGaTrafficByPage(db, projectId, window2) {
43514
43517
  }).from(gaTrafficSnapshots).where(and77(
43515
43518
  eq88(gaTrafficSnapshots.projectId, projectId),
43516
43519
  gte25(gaTrafficSnapshots.date, window2.startDate),
43517
- lte20(gaTrafficSnapshots.date, window2.endDate)
43520
+ lte21(gaTrafficSnapshots.date, window2.endDate)
43518
43521
  )).all();
43519
43522
  const map = /* @__PURE__ */ new Map();
43520
43523
  for (const row of rows) {
@@ -43541,7 +43544,7 @@ function sumAiReferralSessions(db, projectId, window2) {
43541
43544
  // opportunity score, so a lifetime total quietly weights the ranking
43542
43545
  // toward whatever was true months ago.
43543
43546
  gte25(gaAiReferrals.date, window2.startDate),
43544
- lte20(gaAiReferrals.date, window2.endDate)
43547
+ lte21(gaAiReferrals.date, window2.endDate)
43545
43548
  )
43546
43549
  ).all();
43547
43550
  return rows.reduce((acc, r) => acc + (r.sessions ?? 0), 0);
@@ -43564,7 +43567,7 @@ function buildCandidateQueries(opts) {
43564
43567
  const pageRows = gscWindow ? opts.db.select().from(gscSearchData).where(and77(
43565
43568
  eq88(gscSearchData.projectId, opts.projectId),
43566
43569
  gte25(gscSearchData.date, gscWindow.startDate),
43567
- lte20(gscSearchData.date, gscWindow.endDate)
43570
+ lte21(gscSearchData.date, gscWindow.endDate)
43568
43571
  )).all() : [];
43569
43572
  const gscByQuery = aggregateGscByQuery(
43570
43573
  pageRows,
@@ -44976,6 +44979,12 @@ var projectRunsSinceQueryParameter = {
44976
44979
  description: "Only return runs created at or after this ISO 8601 timestamp. Omitted means no lower bound.",
44977
44980
  schema: stringSchema
44978
44981
  };
44982
+ var projectRunsUntilQueryParameter = {
44983
+ name: "until",
44984
+ in: "query",
44985
+ description: "Only return runs created at or before this ISO 8601 timestamp, applied before the limit. Omitted means no upper bound.",
44986
+ schema: stringSchema
44987
+ };
44979
44988
  var runsListIncludeProbeQueryParameter = {
44980
44989
  name: "includeProbe",
44981
44990
  in: "query",
@@ -47410,7 +47419,7 @@ var routeCatalog = [
47410
47419
  path: "/api/v1/projects/{name}/runs",
47411
47420
  summary: "List project runs",
47412
47421
  tags: ["runs"],
47413
- parameters: [nameParameter, limitQueryParameter, runsListKindQueryParameter, runsListExcludeKindQueryParameter, runsListExcludeKindsQueryParameter, runsListStatusQueryParameter, projectRunsSinceQueryParameter],
47422
+ parameters: [nameParameter, limitQueryParameter, runsListKindQueryParameter, runsListExcludeKindQueryParameter, runsListExcludeKindsQueryParameter, runsListStatusQueryParameter, projectRunsSinceQueryParameter, projectRunsUntilQueryParameter],
47414
47423
  responses: {
47415
47424
  200: jsonArrayResponse("Runs returned.", "RunDto")
47416
47425
  }
@@ -54010,7 +54019,7 @@ async function userInvitationRoutes(app) {
54010
54019
 
54011
54020
  // ../api-routes/src/chatgpt-accounts.ts
54012
54021
  import crypto42 from "crypto";
54013
- import { and as and80, eq as eq93, isNull as isNull16, lte as lte21 } from "drizzle-orm";
54022
+ import { and as and80, eq as eq93, isNull as isNull16, lte as lte22 } from "drizzle-orm";
54014
54023
 
54015
54024
  // ../api-routes/src/chatgpt-oidc.ts
54016
54025
  import crypto41 from "crypto";
@@ -54461,7 +54470,7 @@ var ChatGptAccounts = class {
54461
54470
  const scopes = this.requestedScopes();
54462
54471
  const nowMs = this.now();
54463
54472
  const nowIso = new Date(nowMs).toISOString();
54464
- this.opts.db.delete(chatgptLoginTransactions).where(lte21(chatgptLoginTransactions.expiresAt, nowIso)).run();
54473
+ this.opts.db.delete(chatgptLoginTransactions).where(lte22(chatgptLoginTransactions.expiresAt, nowIso)).run();
54465
54474
  this.opts.db.insert(chatgptLoginTransactions).values({
54466
54475
  stateHash: sha2563(state),
54467
54476
  browserHash: sha2563(binding),
@@ -59773,7 +59782,7 @@ async function googleRoutes(app, opts) {
59773
59782
  const store = requireConnectionStore();
59774
59783
  const conn = store.getConnection(project.canonicalDomain, "gbp");
59775
59784
  if (!conn) {
59776
- throw validationError('No GBP connection found for this project. Run "canonry gbp connect" first.');
59785
+ throw integrationNotConnected('No GBP connection found for this project. Run "canonry gbp connect" first.');
59777
59786
  }
59778
59787
  const { accessToken } = await getValidToken(
59779
59788
  store,
@@ -59862,7 +59871,7 @@ async function googleRoutes(app, opts) {
59862
59871
  const store = requireConnectionStore();
59863
59872
  const conn = store.getConnection(project.canonicalDomain, "gbp");
59864
59873
  if (!conn) {
59865
- throw validationError('No GBP connection found for this project. Run "canonry gbp connect" first.');
59874
+ throw integrationNotConnected('No GBP connection found for this project. Run "canonry gbp connect" first.');
59866
59875
  }
59867
59876
  const parsed = gbpSyncRequestSchema.safeParse(request.body ?? {});
59868
59877
  if (!parsed.success) {
@@ -60305,7 +60314,7 @@ function normalizeConversionTrackingContractWrite(input) {
60305
60314
  function requiredCredential(opts, project, provider) {
60306
60315
  const credential = opts.googleMarketingCredentialStore?.get(project, provider);
60307
60316
  if (!credential?.accessToken) {
60308
- throw validationError(`No ${provider === GoogleMarketingProviders["google-ads"] ? "Google Ads" : "Google Tag Manager"} OAuth connection is available for this project.`);
60317
+ throw integrationNotConnected(`No ${provider === GoogleMarketingProviders["google-ads"] ? "Google Ads" : "Google Tag Manager"} OAuth connection is available for this project.`);
60309
60318
  }
60310
60319
  return credential;
60311
60320
  }
@@ -61765,7 +61774,7 @@ async function googleMarketingRoutes(app, opts) {
61765
61774
 
61766
61775
  // ../api-routes/src/ads.ts
61767
61776
  import crypto51 from "crypto";
61768
- import { eq as eq102, and as and87, asc as asc22, desc as desc45, gt as gt8, gte as gte26, lt as lt18, lte as lte23, ne as ne15, inArray as inArray49, or as or19, isNull as isNull19, isNotNull as isNotNull12, sql as sql41 } from "drizzle-orm";
61777
+ import { eq as eq102, and as and87, asc as asc22, desc as desc45, gt as gt8, gte as gte26, lt as lt18, lte as lte24, ne as ne15, inArray as inArray49, or as or19, isNull as isNull19, isNotNull as isNotNull12, sql as sql41 } from "drizzle-orm";
61769
61778
 
61770
61779
  // ../api-routes/src/ads-activation.ts
61771
61780
  import crypto49 from "crypto";
@@ -63151,7 +63160,7 @@ async function executeApprovedAdsActivation(dependencies, request) {
63151
63160
 
63152
63161
  // ../api-routes/src/ads-activation-routes.ts
63153
63162
  import crypto50 from "crypto";
63154
- import { and as and86, asc as asc21, eq as eq101, gt as gt7, isNotNull as isNotNull11, isNull as isNull18, lte as lte22, or as or18, sql as sql40 } from "drizzle-orm";
63163
+ import { and as and86, asc as asc21, eq as eq101, gt as gt7, isNotNull as isNotNull11, isNull as isNull18, lte as lte23, or as or18, sql as sql40 } from "drizzle-orm";
63155
63164
  var MAX_ACTIVATION_GRANT_LIFETIME_MS = 24 * 60 * 60 * 1e3;
63156
63165
  var ACTIVATION_LEASE_MS = 5 * 6e4;
63157
63166
  var ACTIVATION_REVOCATION_SETTLEMENT_MS = ACTIVATION_LEASE_MS;
@@ -63281,7 +63290,7 @@ function createActivationStore(app, request) {
63281
63290
  isNull18(adsOperations.leaseOwner),
63282
63291
  eq101(adsOperations.leaseOwner, input.leaseOwner),
63283
63292
  isNull18(adsOperations.leaseExpiresAt),
63284
- lte22(adsOperations.leaseExpiresAt, input.now)
63293
+ lte23(adsOperations.leaseExpiresAt, input.now)
63285
63294
  )
63286
63295
  )).run();
63287
63296
  const resumed = loadCanonicalActivation(tx, grant.id, existing.id);
@@ -63741,7 +63750,7 @@ function selectWatchdogOperations(app, nowIso, batchSize, allowLiveRevocationLea
63741
63750
  const leaseAvailable = or18(
63742
63751
  isNull18(adsOperations.leaseOwner),
63743
63752
  isNull18(adsOperations.leaseExpiresAt),
63744
- lte22(adsOperations.leaseExpiresAt, nowIso)
63753
+ lte23(adsOperations.leaseExpiresAt, nowIso)
63745
63754
  );
63746
63755
  const campaignHasMutationEvidence = or18(
63747
63756
  eq101(adsOperationSteps.state, AdsOperationStepStates.executing),
@@ -63937,7 +63946,7 @@ async function sweepStaleAdsActivationsOnce(app, opts) {
63937
63946
  or18(
63938
63947
  isNull18(adsOperations.leaseOwner),
63939
63948
  isNull18(adsOperations.leaseExpiresAt),
63940
- lte22(adsOperations.leaseExpiresAt, nowIso)
63949
+ lte23(adsOperations.leaseExpiresAt, nowIso)
63941
63950
  )
63942
63951
  )
63943
63952
  )
@@ -63974,7 +63983,7 @@ async function sweepStaleAdsActivationsOnce(app, opts) {
63974
63983
  or18(
63975
63984
  isNull18(adsOperations.leaseOwner),
63976
63985
  isNull18(adsOperations.leaseExpiresAt),
63977
- lte22(adsOperations.leaseExpiresAt, failedAt)
63986
+ lte23(adsOperations.leaseExpiresAt, failedAt)
63978
63987
  )
63979
63988
  )
63980
63989
  )
@@ -64897,7 +64906,7 @@ function errorDetails(err) {
64897
64906
  async function resolveAdsOperator(app, opts, project, verification) {
64898
64907
  const connection = opts.adsCredentialStore?.getConnection(project.name);
64899
64908
  if (!connection?.apiKey) {
64900
- throw validationError('No ads connection for this project. Run "canonry ads connect" first.');
64909
+ throw integrationNotConnected('No ads connection for this project. Run "canonry ads connect" first.');
64901
64910
  }
64902
64911
  if (!connection.adAccountId) {
64903
64912
  throw validationError("Reconnect this project to bind its verified OpenAI ad account before mutating ads");
@@ -65184,13 +65193,13 @@ function claimOperationForReconciliation(app, row, leaseOwner, now, leaseMs, pol
65184
65193
  const unknownCutoff = new Date(now.getTime() - backoffMs).toISOString();
65185
65194
  const claimableState = row.state === AdsOperationStates.pending ? and87(
65186
65195
  eq102(adsOperations.state, AdsOperationStates.pending),
65187
- lte23(adsOperations.updatedAt, pendingCutoff)
65196
+ lte24(adsOperations.updatedAt, pendingCutoff)
65188
65197
  ) : row.state === AdsOperationStates.unknown ? and87(
65189
65198
  eq102(adsOperations.state, AdsOperationStates.unknown),
65190
- enforceBackoff ? lte23(adsOperations.updatedAt, unknownCutoff) : void 0
65199
+ enforceBackoff ? lte24(adsOperations.updatedAt, unknownCutoff) : void 0
65191
65200
  ) : and87(
65192
65201
  eq102(adsOperations.state, AdsOperationStates.reconciling),
65193
- or19(isNull19(adsOperations.leaseExpiresAt), lte23(adsOperations.leaseExpiresAt, nowIso))
65202
+ or19(isNull19(adsOperations.leaseExpiresAt), lte24(adsOperations.leaseExpiresAt, nowIso))
65194
65203
  );
65195
65204
  const claimed = app.db.update(adsOperations).set({
65196
65205
  state: AdsOperationStates.reconciling,
@@ -65528,14 +65537,14 @@ async function sweepAdsOperationsOnce(app, opts, config) {
65528
65537
  const backoffMs = config.policy.backoffBaseMs * 2 ** Math.max(0, reconcileAttempts - 1);
65529
65538
  return and87(
65530
65539
  eq102(adsOperations.reconcileAttempts, reconcileAttempts),
65531
- lte23(adsOperations.updatedAt, new Date(now.getTime() - backoffMs).toISOString())
65540
+ lte24(adsOperations.updatedAt, new Date(now.getTime() - backoffMs).toISOString())
65532
65541
  );
65533
65542
  }
65534
65543
  );
65535
65544
  const retryableStateWhere = or19(
65536
65545
  and87(
65537
65546
  eq102(adsOperations.state, AdsOperationStates.pending),
65538
- lte23(adsOperations.updatedAt, pendingCutoff)
65547
+ lte24(adsOperations.updatedAt, pendingCutoff)
65539
65548
  ),
65540
65549
  and87(
65541
65550
  eq102(adsOperations.state, AdsOperationStates.unknown),
@@ -65543,7 +65552,7 @@ async function sweepAdsOperationsOnce(app, opts, config) {
65543
65552
  ),
65544
65553
  and87(
65545
65554
  eq102(adsOperations.state, AdsOperationStates.reconciling),
65546
- or19(isNull19(adsOperations.leaseExpiresAt), lte23(adsOperations.leaseExpiresAt, nowIso))
65555
+ or19(isNull19(adsOperations.leaseExpiresAt), lte24(adsOperations.leaseExpiresAt, nowIso))
65547
65556
  )
65548
65557
  );
65549
65558
  const staleReconcileWhere = and87(
@@ -65570,12 +65579,12 @@ async function sweepAdsOperationsOnce(app, opts, config) {
65570
65579
  or19(
65571
65580
  and87(
65572
65581
  eq102(adsOperations.state, AdsOperationStates.pending),
65573
- lte23(adsOperations.updatedAt, pendingCutoff)
65582
+ lte24(adsOperations.updatedAt, pendingCutoff)
65574
65583
  ),
65575
65584
  eq102(adsOperations.state, AdsOperationStates.unknown),
65576
65585
  and87(
65577
65586
  eq102(adsOperations.state, AdsOperationStates.reconciling),
65578
- or19(isNull19(adsOperations.leaseExpiresAt), lte23(adsOperations.leaseExpiresAt, nowIso))
65587
+ or19(isNull19(adsOperations.leaseExpiresAt), lte24(adsOperations.leaseExpiresAt, nowIso))
65579
65588
  )
65580
65589
  ),
65581
65590
  or19(
@@ -66361,7 +66370,7 @@ async function adsRoutes(app, opts) {
66361
66370
  const project = resolveProject(app.db, request.params.name);
66362
66371
  const row = app.db.select().from(adsConnections).where(eq102(adsConnections.projectId, project.id)).get();
66363
66372
  if (!row) {
66364
- throw validationError('No ads connection for this project. Run "canonry ads connect" first.');
66373
+ throw integrationNotConnected('No ads connection for this project. Run "canonry ads connect" first.');
66365
66374
  }
66366
66375
  const inFlight2 = app.db.select({ id: runs.id, status: runs.status }).from(runs).where(and87(
66367
66376
  eq102(runs.projectId, project.id),
@@ -66462,7 +66471,7 @@ async function adsRoutes(app, opts) {
66462
66471
  if (parsedLevel) conditions.push(eq102(adsInsightsDaily.level, parsedLevel));
66463
66472
  if (entityId) conditions.push(eq102(adsInsightsDaily.entityId, entityId));
66464
66473
  if (from) conditions.push(gte26(adsInsightsDaily.date, from));
66465
- if (to) conditions.push(lte23(adsInsightsDaily.date, to));
66474
+ if (to) conditions.push(lte24(adsInsightsDaily.date, to));
66466
66475
  const rows = app.db.select().from(adsInsightsDaily).where(and87(...conditions)).orderBy(asc22(adsInsightsDaily.date)).all();
66467
66476
  const conn = app.db.select().from(adsConnections).where(eq102(adsConnections.projectId, project.id)).get();
66468
66477
  const accountToday = adsAccountToday(conn?.timezone, (/* @__PURE__ */ new Date()).toISOString());
@@ -66591,7 +66600,7 @@ async function adsRoutes(app, opts) {
66591
66600
  const { campaignId, lookbackDays } = parsed.data;
66592
66601
  const connection = app.db.select().from(adsConnections).where(eq102(adsConnections.projectId, project.id)).get();
66593
66602
  if (!connection) {
66594
- throw validationError('No ads connection for this project. Run "canonry ads connect" first.');
66603
+ throw integrationNotConnected('No ads connection for this project. Run "canonry ads connect" first.');
66595
66604
  }
66596
66605
  const { apiKey, reader } = resolveAdsLiveDeliveryReader(opts, project.name);
66597
66606
  const verifyAdsAccount = opts.verifyAdsAccount;
@@ -67452,7 +67461,7 @@ function isBlockingCrawlIssue(issueType) {
67452
67461
 
67453
67462
  // ../api-routes/src/bing-data.ts
67454
67463
  import crypto54 from "crypto";
67455
- import { and as and88, asc as asc23, desc as desc46, eq as eq103, gte as gte27, lte as lte24, sql as sql42 } from "drizzle-orm";
67464
+ import { and as and88, asc as asc23, desc as desc46, eq as eq103, gte as gte27, lte as lte25, sql as sql42 } from "drizzle-orm";
67456
67465
  var BING_DEFAULT_WINDOW_DAYS = 28;
67457
67466
  var MAX_WINDOW_DAYS = 3660;
67458
67467
  var DEFAULT_LIST_LIMIT = 100;
@@ -67620,7 +67629,7 @@ async function bingDataRoutes(app, opts) {
67620
67629
  const fetchStart = priorWindowIsSynced ? priorStart : window2.startDate;
67621
67630
  const conditions = [eq103(bingTrafficDaily.projectId, project.id)];
67622
67631
  if (fetchStart) conditions.push(gte27(bingTrafficDaily.date, fetchStart));
67623
- if (window2.endDate) conditions.push(lte24(bingTrafficDaily.date, window2.endDate));
67632
+ if (window2.endDate) conditions.push(lte25(bingTrafficDaily.date, window2.endDate));
67624
67633
  const fetched = latest === null && !request.query.startDate ? [] : app.db.select().from(bingTrafficDaily).where(and88(...conditions)).orderBy(asc23(bingTrafficDaily.date)).all();
67625
67634
  const rows = window2.startDate ? fetched.filter((row) => row.date >= window2.startDate) : fetched;
67626
67635
  const clicks = rows.reduce((sum, row) => sum + row.clicks, 0);
@@ -67664,7 +67673,7 @@ async function bingDataRoutes(app, opts) {
67664
67673
  const between = (startDate, endDate) => {
67665
67674
  const conditions = [...filters];
67666
67675
  if (startDate) conditions.push(gte27(table.date, startDate));
67667
- if (endDate) conditions.push(lte24(table.date, endDate));
67676
+ if (endDate) conditions.push(lte25(table.date, endDate));
67668
67677
  return and88(...conditions);
67669
67678
  };
67670
67679
  const where = between(window2.startDate, window2.endDate);
@@ -67739,7 +67748,7 @@ async function bingDataRoutes(app, opts) {
67739
67748
  const window2 = resolveBingWindow(request.query, latest);
67740
67749
  const conditions = [eq103(bingCrawlStats.projectId, project.id)];
67741
67750
  if (window2.startDate) conditions.push(gte27(bingCrawlStats.date, window2.startDate));
67742
- if (window2.endDate) conditions.push(lte24(bingCrawlStats.date, window2.endDate));
67751
+ if (window2.endDate) conditions.push(lte25(bingCrawlStats.date, window2.endDate));
67743
67752
  const rows = latest === null && !request.query.startDate ? [] : app.db.select().from(bingCrawlStats).where(and88(...conditions)).orderBy(desc46(bingCrawlStats.date)).all();
67744
67753
  return {
67745
67754
  rows: rows.map(({ id: _id, projectId: _projectId, syncRunId: _syncRunId, syncedAt: _syncedAt, ...day }) => day),
@@ -69379,7 +69388,7 @@ function keptGaWindows(windows, failures) {
69379
69388
 
69380
69389
  // ../api-routes/src/ga-search-landing-pages.ts
69381
69390
  import crypto56 from "crypto";
69382
- import { and as and94, asc as asc25, count as count9, desc as desc49, eq as eq109, gte as gte28, lte as lte25, sql as sql45 } from "drizzle-orm";
69391
+ import { and as and94, asc as asc25, count as count9, desc as desc49, eq as eq109, gte as gte28, lte as lte26, sql as sql45 } from "drizzle-orm";
69383
69392
  function searchLandingWindowsToFetch(db, projectId, propertyId, timeZone, requestedAt) {
69384
69393
  const state = db.select().from(gaMeasurementSyncStates).where(eq109(gaMeasurementSyncStates.projectId, projectId)).get();
69385
69394
  if (!timeZone || state?.searchLandingStatus !== "ready") return [...GA_SEARCH_LANDING_WINDOWS];
@@ -69561,7 +69570,7 @@ function searchConsoleLinkFor(db, projectId, total, windowStart, windowEnd) {
69561
69570
  const stored = db.select({
69562
69571
  days: count9(),
69563
69572
  impressions: sql45`sum(${gscDailyTotals.impressions})`
69564
- }).from(gscDailyTotals).where(and94(eq109(gscDailyTotals.projectId, projectId), gte28(gscDailyTotals.date, windowStart), lte25(gscDailyTotals.date, windowEnd))).get();
69573
+ }).from(gscDailyTotals).where(and94(eq109(gscDailyTotals.projectId, projectId), gte28(gscDailyTotals.date, windowStart), lte26(gscDailyTotals.date, windowEnd))).get();
69565
69574
  const searchConsoleImpressions = stored && stored.days > 0 ? Number(stored.impressions ?? 0) : null;
69566
69575
  if (gaSearchLandingHasSearchData(total)) return { state: "has-data", searchConsoleImpressions };
69567
69576
  if (searchConsoleImpressions === null) return { state: "unknown", searchConsoleImpressions };
@@ -71129,7 +71138,7 @@ async function ga4Routes(app, opts) {
71129
71138
  }
71130
71139
 
71131
71140
  // ../api-routes/src/ga-acquisition.ts
71132
- import { and as and96, asc as asc26, count as count10, desc as desc51, eq as eq111, gte as gte29, lte as lte26, sql as sql47 } from "drizzle-orm";
71141
+ import { and as and96, asc as asc26, count as count10, desc as desc51, eq as eq111, gte as gte29, lte as lte27, sql as sql47 } from "drizzle-orm";
71133
71142
  async function gaAcquisitionRoutes(app) {
71134
71143
  app.get("/projects/:name/ga/acquisition", async (request) => {
71135
71144
  const project = resolveProject(app.db, request.params.name);
@@ -71154,7 +71163,7 @@ async function gaAcquisitionRoutes(app) {
71154
71163
  };
71155
71164
  const windowFilters = [eq111(gaAcquisitionDaily.projectId, project.id)];
71156
71165
  if (range.startDate) windowFilters.push(gte29(gaAcquisitionDaily.date, range.startDate));
71157
- if (range.endDate) windowFilters.push(lte26(gaAcquisitionDaily.date, range.endDate));
71166
+ if (range.endDate) windowFilters.push(lte27(gaAcquisitionDaily.date, range.endDate));
71158
71167
  const filters = [...windowFilters];
71159
71168
  if (query2.channel !== void 0) filters.push(sql47`lower(${gaAcquisitionDaily.channelGroup}) = lower(${query2.channel})`);
71160
71169
  if (query2.hostName !== void 0) filters.push(sql47`lower(${gaAcquisitionDaily.hostName}) = lower(${query2.hostName})`);
@@ -73775,7 +73784,7 @@ async function backlinksRoutes(app, opts) {
73775
73784
  import crypto62 from "crypto";
73776
73785
  import { isIP as isIP3 } from "net";
73777
73786
  import { isDeepStrictEqual } from "util";
73778
- import { and as and100, desc as desc54, eq as eq115, gt as gt9, gte as gte30, inArray as inArray53, lt as lt20, lte as lte28, sql as sql50 } from "drizzle-orm";
73787
+ import { and as and100, desc as desc54, eq as eq115, gt as gt9, gte as gte30, inArray as inArray53, lt as lt20, lte as lte29, sql as sql50 } from "drizzle-orm";
73779
73788
 
73780
73789
  // ../integration-cloud-run/src/auth.ts
73781
73790
  import crypto60 from "crypto";
@@ -75113,7 +75122,7 @@ async function ackCloudflareQueueMessages(client, options) {
75113
75122
  }
75114
75123
 
75115
75124
  // ../api-routes/src/traffic-sync-lease.ts
75116
- import { and as and99, eq as eq113, isNull as isNull20, lte as lte27, or as or20 } from "drizzle-orm";
75125
+ import { and as and99, eq as eq113, isNull as isNull20, lte as lte28, or as or20 } from "drizzle-orm";
75117
75126
  function leaseExpiresAt(now, ttlMs) {
75118
75127
  const nowMs = Date.parse(now);
75119
75128
  if (!Number.isFinite(nowMs)) throw new RangeError("Traffic sync lease now must be an ISO instant");
@@ -75130,7 +75139,7 @@ function tryClaimTrafficSyncLease(input) {
75130
75139
  eq113(trafficSources.id, input.sourceId),
75131
75140
  or20(
75132
75141
  isNull20(trafficSources.syncLeaseOwner),
75133
- lte27(trafficSources.syncLeaseExpiresAt, input.now),
75142
+ lte28(trafficSources.syncLeaseExpiresAt, input.now),
75134
75143
  eq113(trafficSources.syncLeaseOwner, input.owner)
75135
75144
  )
75136
75145
  )).run();
@@ -75948,14 +75957,14 @@ async function runBackfillTaskHoldingLease(options, signal) {
75948
75957
  and100(
75949
75958
  eq115(crawlerEventsHourly.sourceId, sourceRow2.id),
75950
75959
  gte30(crawlerEventsHourly.tsHour, windowStartIso),
75951
- lte28(crawlerEventsHourly.tsHour, windowEndIso)
75960
+ lte29(crawlerEventsHourly.tsHour, windowEndIso)
75952
75961
  )
75953
75962
  ).run();
75954
75963
  tx.delete(aiUserFetchEventsHourly).where(
75955
75964
  and100(
75956
75965
  eq115(aiUserFetchEventsHourly.sourceId, sourceRow2.id),
75957
75966
  gte30(aiUserFetchEventsHourly.tsHour, windowStartIso),
75958
- lte28(aiUserFetchEventsHourly.tsHour, windowEndIso)
75967
+ lte29(aiUserFetchEventsHourly.tsHour, windowEndIso)
75959
75968
  )
75960
75969
  ).run();
75961
75970
  clearLikelyFakeAgentHits(tx, { sourceId: sourceRow2.id, windowStart: windowStartIso, windowEnd: windowEndIso });
@@ -75963,21 +75972,21 @@ async function runBackfillTaskHoldingLease(options, signal) {
75963
75972
  and100(
75964
75973
  eq115(aiReferralEventsHourly.sourceId, sourceRow2.id),
75965
75974
  gte30(aiReferralEventsHourly.tsHour, windowStartIso),
75966
- lte28(aiReferralEventsHourly.tsHour, windowEndIso)
75975
+ lte29(aiReferralEventsHourly.tsHour, windowEndIso)
75967
75976
  )
75968
75977
  ).run();
75969
75978
  tx.delete(rawEventSamples).where(
75970
75979
  and100(
75971
75980
  eq115(rawEventSamples.sourceId, sourceRow2.id),
75972
75981
  gte30(rawEventSamples.ts, windowStartIso),
75973
- lte28(rawEventSamples.ts, windowEndIso)
75982
+ lte29(rawEventSamples.ts, windowEndIso)
75974
75983
  )
75975
75984
  ).run();
75976
75985
  tx.delete(unrecognizedAgentEventsHourly).where(
75977
75986
  and100(
75978
75987
  eq115(unrecognizedAgentEventsHourly.sourceId, sourceRow2.id),
75979
75988
  gte30(unrecognizedAgentEventsHourly.tsHour, windowStartIso),
75980
- lte28(unrecognizedAgentEventsHourly.tsHour, windowEndIso)
75989
+ lte29(unrecognizedAgentEventsHourly.tsHour, windowEndIso)
75981
75990
  )
75982
75991
  ).run();
75983
75992
  for (const bucket of report.crawlerEventsHourly) {
@@ -78732,7 +78741,7 @@ async function trafficRoutes(app, opts) {
78732
78741
  const crawlerFilters = [
78733
78742
  eq115(crawlerEventsHourly.projectId, project.id),
78734
78743
  gte30(crawlerEventsHourly.tsHour, sinceIso),
78735
- lte28(crawlerEventsHourly.tsHour, untilIso)
78744
+ lte29(crawlerEventsHourly.tsHour, untilIso)
78736
78745
  ];
78737
78746
  if (sourceIdParam) crawlerFilters.push(eq115(crawlerEventsHourly.sourceId, sourceIdParam));
78738
78747
  crawlerFilters.push(...trafficEventFilterPredicates(TRAFFIC_EVENT_TABLES.crawler, readFilters));
@@ -78814,7 +78823,7 @@ async function trafficRoutes(app, opts) {
78814
78823
  const userFetchFilters = [
78815
78824
  eq115(aiUserFetchEventsHourly.projectId, project.id),
78816
78825
  gte30(aiUserFetchEventsHourly.tsHour, sinceIso),
78817
- lte28(aiUserFetchEventsHourly.tsHour, untilIso)
78826
+ lte29(aiUserFetchEventsHourly.tsHour, untilIso)
78818
78827
  ];
78819
78828
  if (sourceIdParam) userFetchFilters.push(eq115(aiUserFetchEventsHourly.sourceId, sourceIdParam));
78820
78829
  userFetchFilters.push(...trafficEventFilterPredicates(TRAFFIC_EVENT_TABLES["ai-user-fetch"], readFilters));
@@ -78860,7 +78869,7 @@ async function trafficRoutes(app, opts) {
78860
78869
  const aiFilters = [
78861
78870
  eq115(aiReferralEventsHourly.projectId, project.id),
78862
78871
  gte30(aiReferralEventsHourly.tsHour, sinceIso),
78863
- lte28(aiReferralEventsHourly.tsHour, untilIso)
78872
+ lte29(aiReferralEventsHourly.tsHour, untilIso)
78864
78873
  ];
78865
78874
  if (sourceIdParam) aiFilters.push(eq115(aiReferralEventsHourly.sourceId, sourceIdParam));
78866
78875
  aiFilters.push(...trafficEventFilterPredicates(TRAFFIC_EVENT_TABLES["ai-referral"], readFilters));
@@ -79065,7 +79074,7 @@ async function trafficRoutes(app, opts) {
79065
79074
  }
79066
79075
 
79067
79076
  // ../api-routes/src/doctor/checks/report-sweeps.ts
79068
- import { and as and101, asc as asc28, eq as eq116, gte as gte31, lte as lte29 } from "drizzle-orm";
79077
+ import { and as and101, asc as asc28, eq as eq116, gte as gte31, lte as lte30 } from "drizzle-orm";
79069
79078
 
79070
79079
  // ../api-routes/src/visibility-attribution.ts
79071
79080
  function buildQueryAttribution2(projectQueries) {
@@ -79187,7 +79196,7 @@ var reportSweepsCheck = {
79187
79196
  const graded = gradedReportMonths(reportMonths, now);
79188
79197
  const months = reportMonths.map((month) => {
79189
79198
  const bounds = calendarMonthBounds(month);
79190
- const monthRuns = ctx.db.select().from(runs).where(and101(eq116(runs.projectId, ctx.project.id), eq116(runs.kind, RunKinds["answer-visibility"]), notProbeRun(), gte31(runs.createdAt, bounds.since), lte29(runs.createdAt, bounds.until))).orderBy(asc28(runs.createdAt), asc28(runs.id)).all();
79199
+ const monthRuns = ctx.db.select().from(runs).where(and101(eq116(runs.projectId, ctx.project.id), eq116(runs.kind, RunKinds["answer-visibility"]), notProbeRun(), gte31(runs.createdAt, bounds.since), lte30(runs.createdAt, bounds.until))).orderBy(asc28(runs.createdAt), asc28(runs.id)).all();
79191
79200
  const evidence = monthRuns.map((run) => inspectSweep(ctx, run));
79192
79201
  return {
79193
79202
  month,
@@ -79210,7 +79219,7 @@ var reportSweepsCheck = {
79210
79219
  };
79211
79220
 
79212
79221
  // ../api-routes/src/doctor/checks/report-models.ts
79213
- import { and as and102, eq as eq117, gte as gte32, inArray as inArray54, lte as lte30 } from "drizzle-orm";
79222
+ import { and as and102, eq as eq117, gte as gte32, inArray as inArray54, lte as lte31 } from "drizzle-orm";
79214
79223
  var reportModelsCheck = {
79215
79224
  id: "report.models",
79216
79225
  category: CheckCategories.providers,
@@ -79225,7 +79234,7 @@ var reportModelsCheck = {
79225
79234
  const months = reportMonths.flatMap((month) => {
79226
79235
  const bounds = calendarMonthBounds(month);
79227
79236
  const previous = new Date(Date.parse(bounds.since) - 1).toISOString().slice(0, 7);
79228
- const observations = ctx.db.select({ provider: querySnapshots.provider, model: querySnapshots.model, at: runs.createdAt }).from(querySnapshots).innerJoin(runs, eq117(runs.id, querySnapshots.runId)).where(and102(eq117(runs.projectId, ctx.project.id), eq117(runs.kind, RunKinds["answer-visibility"]), inArray54(runs.status, [RunStatuses.completed, RunStatuses.partial]), notProbeRun(), gte32(runs.createdAt, bounds.since), lte30(runs.createdAt, bounds.until))).all();
79237
+ const observations = ctx.db.select({ provider: querySnapshots.provider, model: querySnapshots.model, at: runs.createdAt }).from(querySnapshots).innerJoin(runs, eq117(runs.id, querySnapshots.runId)).where(and102(eq117(runs.projectId, ctx.project.id), eq117(runs.kind, RunKinds["answer-visibility"]), inArray54(runs.status, [RunStatuses.completed, RunStatuses.partial]), notProbeRun(), gte32(runs.createdAt, bounds.since), lte31(runs.createdAt, bounds.until))).all();
79229
79238
  return readVisibilityContinuity(ctx.db, ctx.project.name, { from: previous, to: month }).map(({ frame, continuity: continuity2 }) => ({
79230
79239
  month,
79231
79240
  previousMonth: previous,