seo 0.17.5 → 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/index.d.ts CHANGED
@@ -19024,7 +19024,7 @@ declare const QUERY_FLAG_METHOD: {
19024
19024
  readonly heuristic: true;
19025
19025
  readonly ranking: "flagged_rows_after_unflagged_rows";
19026
19026
  readonly flags: {
19027
- readonly 'likely-automated': "Snake_case identifier tokens, 20 or more words, or 8 or more ASCII words with no common function word. Such queries often come from scripts, prompts or tools, not people.";
19027
+ readonly 'likely-automated': "A numbered prefix such as \"12264: \", snake_case identifier tokens, 20 or more words, or 8 or more ASCII words with no common function word. Such queries often come from scripts, prompts or tools, not people.";
19028
19028
  readonly 'navigational-other': "Names a domain that is not the property's host, ends with a spoken domain suffix or a login/site/app word, starts with a large platform name and adds no topic word, or is one short ASCII word that is not a brand term. Such queries usually look for another site.";
19029
19029
  };
19030
19030
  };
@@ -19179,7 +19179,7 @@ export declare function ctrUnderperformersReportWith(input: CtrUnderperformersIn
19179
19179
  readonly heuristic: true;
19180
19180
  readonly ranking: "flagged_rows_after_unflagged_rows";
19181
19181
  readonly flags: {
19182
- readonly 'likely-automated': "Snake_case identifier tokens, 20 or more words, or 8 or more ASCII words with no common function word. Such queries often come from scripts, prompts or tools, not people.";
19182
+ readonly 'likely-automated': "A numbered prefix such as \"12264: \", snake_case identifier tokens, 20 or more words, or 8 or more ASCII words with no common function word. Such queries often come from scripts, prompts or tools, not people.";
19183
19183
  readonly 'navigational-other': "Names a domain that is not the property's host, ends with a spoken domain suffix or a login/site/app word, starts with a large platform name and adds no topic word, or is one short ASCII word that is not a brand term. Such queries usually look for another site.";
19184
19184
  };
19185
19185
  };
@@ -20210,6 +20210,7 @@ type StrikingDistanceSelection = {
20210
20210
  belowMinimumRows: number;
20211
20211
  lowActionabilityRows: number;
20212
20212
  brandRows: number;
20213
+ sitelinkRows: number;
20213
20214
  eligibleRows: number;
20214
20215
  likelyAutomatedRows: number;
20215
20216
  navigationalOtherRows: number;
@@ -20290,7 +20291,7 @@ type StrikingDistanceAnalysis = {
20290
20291
  };
20291
20292
  provenance: {
20292
20293
  inputScope: 'provided_rows';
20293
- selectionOrder: readonly ['fragment_and_duplicate_merge', 'valid_row', 'position', 'minimum_impressions', 'query_quality', 'brand', 'query_flag_ranking'];
20294
+ selectionOrder: readonly ['fragment_and_duplicate_merge', 'valid_row', 'position', 'minimum_impressions', 'query_quality', 'brand', 'sitelinks', 'query_flag_ranking'];
20294
20295
  selection: StrikingDistanceSelection;
20295
20296
  };
20296
20297
  summary: {
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __seoCreateRequire } from 'node:module'; const require = __seoCreateRequire(import.meta.url);
2
- import { n as version, t as load } from "./esm-lrKCsK_C.js";
2
+ import { n as version, t as load } from "./esm-D2vwEHEA.js";
3
3
  import { SEO_PROVIDER_API_VERSION } from "./provider-sdk.js";
4
4
  import crypto$1, { createHash, randomUUID, sign } from "node:crypto";
5
5
  import { z } from "zod";
@@ -10649,7 +10649,7 @@ const QUERY_FLAG_METHOD = {
10649
10649
  heuristic: true,
10650
10650
  ranking: "flagged_rows_after_unflagged_rows",
10651
10651
  flags: {
10652
- "likely-automated": "Snake_case identifier tokens, 20 or more words, or 8 or more ASCII words with no common function word. Such queries often come from scripts, prompts or tools, not people.",
10652
+ "likely-automated": "A numbered prefix such as \"12264: \", snake_case identifier tokens, 20 or more words, or 8 or more ASCII words with no common function word. Such queries often come from scripts, prompts or tools, not people.",
10653
10653
  "navigational-other": "Names a domain that is not the property's host, ends with a spoken domain suffix or a login/site/app word, starts with a large platform name and adds no topic word, or is one short ASCII word that is not a brand term. Such queries usually look for another site."
10654
10654
  }
10655
10655
  };
@@ -10713,8 +10713,10 @@ const FUNCTION_WORDS$1 = /* @__PURE__ */ new Set([
10713
10713
  "und"
10714
10714
  ]);
10715
10715
  const IDENTIFIER_TOKEN = /[\p{L}\p{N}]_[\p{L}\p{N}]/u;
10716
+ const NUMBERED_PREFIX = /^\d{4,}:\s+\S/u;
10716
10717
  /** Heuristic: the query looks machine-generated rather than typed by a person. */
10717
10718
  function isLikelyAutomatedQuery(query) {
10719
+ if (NUMBERED_PREFIX.test(query.trim())) return true;
10718
10720
  if (query.trim().split(/\s+/).filter(Boolean).some((token) => IDENTIFIER_TOKEN.test(token))) return true;
10719
10721
  const tokens = tokenize(query);
10720
10722
  if (tokens.length >= 20) return true;
@@ -23362,6 +23364,7 @@ function selectRows(input) {
23362
23364
  belowMinimumRows: 0,
23363
23365
  lowActionabilityRows: 0,
23364
23366
  brandRows: 0,
23367
+ sitelinkRows: 0,
23365
23368
  eligibleRows: 0,
23366
23369
  likelyAutomatedRows: 0,
23367
23370
  navigationalOtherRows: 0,
@@ -23382,16 +23385,23 @@ function selectRows(input) {
23382
23385
  brandTerms: input.brandTerms,
23383
23386
  includeBrand: input.includeBrand
23384
23387
  })) selection.brandRows++;
23385
- else {
23386
- rows.push(row);
23387
- selection.eligibleRows++;
23388
- }
23388
+ else rows.push(row);
23389
23389
  }
23390
+ const kept = withoutSitelinkRows(rows);
23391
+ selection.sitelinkRows = rows.length - kept.length;
23392
+ selection.eligibleRows = kept.length;
23390
23393
  return {
23391
- rows,
23394
+ rows: kept,
23392
23395
  selection
23393
23396
  };
23394
23397
  }
23398
+ const SITELINK_MINIMUM_PAGES = 3;
23399
+ function withoutSitelinkRows(rows) {
23400
+ const counts = /* @__PURE__ */ new Map();
23401
+ const key = (row) => `${row.keys[0]?.trim()}\n${row.impressions}\n${row.position}`;
23402
+ for (const row of rows) counts.set(key(row), (counts.get(key(row)) ?? 0) + 1);
23403
+ return rows.filter((row) => (counts.get(key(row)) ?? 0) < SITELINK_MINIMUM_PAGES);
23404
+ }
23395
23405
  function analyzeStrikingDistanceRows(input) {
23396
23406
  const collapsed = collapseFragmentPageRows(input.rows, { pageKeyIndex: 1 });
23397
23407
  const minImpressionsPolicy = resolveMinImpressionsPolicy({
@@ -23466,6 +23476,7 @@ function analyzeStrikingDistanceRows(input) {
23466
23476
  "minimum_impressions",
23467
23477
  "query_quality",
23468
23478
  "brand",
23479
+ "sitelinks",
23469
23480
  "query_flag_ranking"
23470
23481
  ],
23471
23482
  selection: selected.selection
@@ -23629,6 +23640,7 @@ async function strikingDistanceWith(input, dependencies) {
23629
23640
  `Brand queries: ${analysis.brand.filtering}. Brand terms used: ${analysis.brand.terms.join(", ") || "none"} (${analysis.brand.source === "provided" ? "provided" : "host forms, plus the bare domain stem only when Search Console shows the site is its navigational answer"}).`,
23630
23641
  analysis.selection.fragmentRows ? `${countLabel(analysis.selection.fragmentRows, "source row")} with a #fragment URL merged into the base URL.` : "",
23631
23642
  analysis.selection.flaggedRows ? `${countLabel(analysis.selection.flaggedRows, "eligible row")} carry heuristic query flags (likely-automated or navigational-other) and rank after unflagged rows.` : "",
23643
+ analysis.selection.sitelinkRows ? `${countLabel(analysis.selection.sitelinkRows, "row")} left out as sitelinks: three or more pages for the same query with the same impressions and average position, which is one result shown with its sitelinks. A heuristic.` : "",
23632
23644
  "Position is GSC average position for the property's topmost result per impression; it does not prove a URL ranked on a literal second results page every time.",
23633
23645
  "Search Analytics exposes retained query rows only. Anonymized and lower-value queries can be absent even when pagination is exhausted.",
23634
23646
  "Priority is a demand-and-position heuristic, not an estimated click lift or proof that a change will improve rankings.",
@@ -34271,6 +34283,59 @@ const DIMENSIONS = [
34271
34283
  "device",
34272
34284
  "searchAppearance"
34273
34285
  ];
34286
+ const REGEX_MAX_CHARS = 4096;
34287
+ const QUERY_PRESETS = {
34288
+ questions: "^(who|what|where|when|why|how|is|are|can|does|do|should)\\b",
34289
+ long_tail: "^(\\S+\\s+){7,}\\S+$",
34290
+ comparisons: "\\b(vs|versus|alternatives?)\\b"
34291
+ };
34292
+ const QUERY_PRESET_NAMES = Object.keys(QUERY_PRESETS);
34293
+ function rowTextFilters(input) {
34294
+ return [
34295
+ [
34296
+ "page",
34297
+ "contains",
34298
+ input.page
34299
+ ],
34300
+ [
34301
+ "query",
34302
+ "contains",
34303
+ input.query
34304
+ ],
34305
+ [
34306
+ "page",
34307
+ "includingRegex",
34308
+ input.pageRegex
34309
+ ],
34310
+ [
34311
+ "query",
34312
+ "includingRegex",
34313
+ input.queryRegex
34314
+ ],
34315
+ [
34316
+ "query",
34317
+ "includingRegex",
34318
+ input.queryPreset && QUERY_PRESETS[input.queryPreset]
34319
+ ],
34320
+ [
34321
+ "query",
34322
+ "excludingRegex",
34323
+ input.excludeQueryRegex
34324
+ ]
34325
+ ].flatMap(([dimension, operator, expression]) => {
34326
+ if (!expression) return [];
34327
+ if (operator !== "contains") checkRegex(expression);
34328
+ return [{
34329
+ dimension,
34330
+ operator,
34331
+ expression
34332
+ }];
34333
+ });
34334
+ }
34335
+ function checkRegex(expression) {
34336
+ if (expression.length > 4096) throw new SeoError("INVALID_INPUT", `Search Console takes regular expressions of at most ${REGEX_MAX_CHARS} characters.`);
34337
+ 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}`);
34338
+ }
34274
34339
  const ROWS$1 = 25e3;
34275
34340
  async function runRows(input, deps) {
34276
34341
  const dimensions = input.dimensions?.length ? input.dimensions : ["query"];
@@ -39620,13 +39685,17 @@ const SHARED_TOOLS = [
39620
39685
  name: "seo_data",
39621
39686
  command: "data",
39622
39687
  title: "Raw rows",
39623
- 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).`,
39688
+ 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).`,
39624
39689
  input: z.object({
39625
39690
  source: z.enum(DATA_SOURCES).default("search_console"),
39626
39691
  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."),
39627
39692
  dimensions: z.array(z.enum(DIMENSIONS)).max(4).default(["query"]).describe("search_console; bing uses the first, query or page."),
39628
39693
  page: z.string().min(1).optional().describe("search_console only: URL text, such as /blog/."),
39629
39694
  query: z.string().min(1).optional().describe("search_console only: query text."),
39695
+ query_preset: z.enum(QUERY_PRESET_NAMES).optional(),
39696
+ page_regex: z.string().min(1).max(REGEX_MAX_CHARS).optional().describe("search_console only: RE2 the page URL must match."),
39697
+ query_regex: z.string().min(1).max(REGEX_MAX_CHARS).optional().describe("search_console only: RE2 the query must match."),
39698
+ 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."),
39630
39699
  ...dates,
39631
39700
  ...detail
39632
39701
  }),
@@ -39663,15 +39732,14 @@ const SHARED_TOOLS = [
39663
39732
  return runRows({
39664
39733
  site: await surface.resolveSite(input.site),
39665
39734
  dimensions: input.dimensions,
39666
- filters: [...input.page ? [{
39667
- dimension: "page",
39668
- operator: "contains",
39669
- expression: input.page
39670
- }] : [], ...input.query ? [{
39671
- dimension: "query",
39672
- operator: "contains",
39673
- expression: input.query
39674
- }] : []],
39735
+ filters: rowTextFilters({
39736
+ page: input.page,
39737
+ query: input.query,
39738
+ pageRegex: input.page_regex,
39739
+ queryRegex: input.query_regex,
39740
+ queryPreset: input.query_preset,
39741
+ excludeQueryRegex: input.exclude_query_regex
39742
+ }),
39675
39743
  startDate: input.start_date,
39676
39744
  endDate: input.end_date,
39677
39745
  detail: input.detail,