seo 0.17.6 → 0.17.7

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/dist/mcp.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __seoCreateRequire } from 'node:module'; const require = __seoCreateRequire(import.meta.url);
2
- import { i as __toESM, n as version, r as __commonJSMin, t as load } from "./esm-D7vj4X6E.js";
2
+ import { i as __toESM, n as version, r as __commonJSMin, t as load } from "./esm-D2vwEHEA.js";
3
3
  import { createHash, randomUUID, sign } from "node:crypto";
4
4
  import { ZodOptional, z } from "zod";
5
5
  import { arch, homedir, platform, tmpdir, totalmem } from "node:os";
@@ -44072,6 +44072,59 @@ const DIMENSIONS = [
44072
44072
  "device",
44073
44073
  "searchAppearance"
44074
44074
  ];
44075
+ const REGEX_MAX_CHARS = 4096;
44076
+ const QUERY_PRESETS = {
44077
+ questions: "^(who|what|where|when|why|how|is|are|can|does|do|should)\\b",
44078
+ long_tail: "^(\\S+\\s+){7,}\\S+$",
44079
+ comparisons: "\\b(vs|versus|alternatives?)\\b"
44080
+ };
44081
+ const QUERY_PRESET_NAMES = Object.keys(QUERY_PRESETS);
44082
+ function rowTextFilters(input) {
44083
+ return [
44084
+ [
44085
+ "page",
44086
+ "contains",
44087
+ input.page
44088
+ ],
44089
+ [
44090
+ "query",
44091
+ "contains",
44092
+ input.query
44093
+ ],
44094
+ [
44095
+ "page",
44096
+ "includingRegex",
44097
+ input.pageRegex
44098
+ ],
44099
+ [
44100
+ "query",
44101
+ "includingRegex",
44102
+ input.queryRegex
44103
+ ],
44104
+ [
44105
+ "query",
44106
+ "includingRegex",
44107
+ input.queryPreset && QUERY_PRESETS[input.queryPreset]
44108
+ ],
44109
+ [
44110
+ "query",
44111
+ "excludingRegex",
44112
+ input.excludeQueryRegex
44113
+ ]
44114
+ ].flatMap(([dimension, operator, expression]) => {
44115
+ if (!expression) return [];
44116
+ if (operator !== "contains") checkRegex(expression);
44117
+ return [{
44118
+ dimension,
44119
+ operator,
44120
+ expression
44121
+ }];
44122
+ });
44123
+ }
44124
+ function checkRegex(expression) {
44125
+ if (expression.length > 4096) throw new SeoError("INVALID_INPUT", `Search Console takes regular expressions of at most ${REGEX_MAX_CHARS} characters.`);
44126
+ if (/\(\?<?[=!]|\\[1-9]/.test(expression)) throw new SeoError("INVALID_INPUT", `Search Console uses RE2, which has no lookarounds such as (?=...) or (?!...) and no backreferences such as \\1. Use an exclude filter instead of a negative lookahead: ${expression}`);
44127
+ }
44075
44128
  const ROWS$1 = 25e3;
44076
44129
  async function runRows(input, deps) {
44077
44130
  const dimensions = input.dimensions?.length ? input.dimensions : ["query"];
@@ -49503,13 +49556,17 @@ const SHARED_TOOLS = [
49503
49556
  name: "seo_data",
49504
49557
  command: "data",
49505
49558
  title: "Raw rows",
49506
- description: `Raw rows for questions the report does not answer. search_console (default): rows for any dimensions, each with the previous period and the change; page and query narrow to rows whose URL or query contains that text. google_analytics: landing pages for visits from search, with Google Analytics’ own metric names. bing: Bing Webmaster query or page rows (first dimension) for the same site, by week. clicky: landing-page visits, traffic sources and search engines from a Clicky site the person saved (site is its domain or Clicky site ID; at most 31 days).`,
49559
+ description: `Raw rows for questions the report does not answer. search_console (default): rows for any dimensions, each with the previous period and the change; page and query narrow to rows whose URL or query contains that text; query_preset picks questions, long_tail (8+ words) or comparisons; *_regex take RE2 (no lookarounds). google_analytics: landing pages for visits from search, with Google Analytics’ own metric names. bing: Bing Webmaster query or page rows (first dimension) for the same site, by week. clicky: landing-page visits, traffic sources and search engines from a Clicky site the person saved (site is its domain or Clicky site ID; at most 31 days).`,
49507
49560
  input: z.object({
49508
49561
  source: z.enum(DATA_SOURCES).default("search_console"),
49509
49562
  site: z.string().min(1).describe("search_console and bing: the property or site. google_analytics: numeric property id from seo_sites. clicky: the site or its Clicky site ID."),
49510
49563
  dimensions: z.array(z.enum(DIMENSIONS)).max(4).default(["query"]).describe("search_console; bing uses the first, query or page."),
49511
49564
  page: z.string().min(1).optional().describe("search_console only: URL text, such as /blog/."),
49512
49565
  query: z.string().min(1).optional().describe("search_console only: query text."),
49566
+ query_preset: z.enum(QUERY_PRESET_NAMES).optional(),
49567
+ page_regex: z.string().min(1).max(REGEX_MAX_CHARS).optional().describe("search_console only: RE2 the page URL must match."),
49568
+ query_regex: z.string().min(1).max(REGEX_MAX_CHARS).optional().describe("search_console only: RE2 the query must match."),
49569
+ exclude_query_regex: z.string().min(1).max(REGEX_MAX_CHARS).optional().describe("search_console only: RE2 for queries to leave out, such as the brand."),
49513
49570
  ...dates,
49514
49571
  ...detail
49515
49572
  }),
@@ -49546,15 +49603,14 @@ const SHARED_TOOLS = [
49546
49603
  return runRows({
49547
49604
  site: await surface.resolveSite(input.site),
49548
49605
  dimensions: input.dimensions,
49549
- filters: [...input.page ? [{
49550
- dimension: "page",
49551
- operator: "contains",
49552
- expression: input.page
49553
- }] : [], ...input.query ? [{
49554
- dimension: "query",
49555
- operator: "contains",
49556
- expression: input.query
49557
- }] : []],
49606
+ filters: rowTextFilters({
49607
+ page: input.page,
49608
+ query: input.query,
49609
+ pageRegex: input.page_regex,
49610
+ queryRegex: input.query_regex,
49611
+ queryPreset: input.query_preset,
49612
+ excludeQueryRegex: input.exclude_query_regex
49613
+ }),
49558
49614
  startDate: input.start_date,
49559
49615
  endDate: input.end_date,
49560
49616
  detail: input.detail,