recker 1.0.79 → 1.0.80-next.70ea84d
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/browser/browser/mini.d.ts +2 -2
- package/dist/browser/browser/recker-mini.d.ts +8 -8
- package/dist/browser/browser/recker.d.ts +11 -8
- package/dist/browser/browser/recker.js +54 -6
- package/dist/browser/core/client.d.ts +15 -10
- package/dist/browser/core/client.js +54 -38
- package/dist/browser/index.iife.min.js +129 -130
- package/dist/browser/index.min.js +129 -130
- package/dist/browser/index.mini.iife.js +5697 -636
- package/dist/browser/index.mini.iife.min.js +47 -48
- package/dist/browser/index.mini.min.js +47 -48
- package/dist/browser/index.mini.umd.js +5697 -636
- package/dist/browser/index.mini.umd.min.js +47 -48
- package/dist/browser/index.umd.min.js +129 -130
- package/dist/browser/mini.d.ts +2 -2
- package/dist/browser/plugins/proxy-rotator.d.ts +2 -2
- package/dist/browser/plugins/proxy-rotator.js +6 -28
- package/dist/browser/recker-mini.d.ts +8 -8
- package/dist/browser/recker.d.ts +11 -8
- package/dist/browser/recker.js +54 -6
- package/dist/browser/scrape/document.js +2 -2
- package/dist/browser/scrape/element.js +7 -1
- package/dist/browser/scrape/parser/nodes/html.js +1 -1
- package/dist/browser/scrape/spider.d.ts +52 -0
- package/dist/browser/scrape/spider.js +620 -38
- package/dist/browser/scrape/types.d.ts +2 -0
- package/dist/browser/search/google.d.ts +26 -1
- package/dist/browser/search/google.js +427 -45
- package/dist/browser/seo/analyzer.d.ts +1 -0
- package/dist/browser/seo/analyzer.js +144 -1
- package/dist/browser/seo/index.d.ts +1 -1
- package/dist/browser/seo/keyword-campaign-analyzer.d.ts +2 -0
- package/dist/browser/seo/keyword-campaign-analyzer.js +538 -0
- package/dist/browser/seo/keyword-campaign-seed-advanced.d.ts +17 -0
- package/dist/browser/seo/keyword-campaign-seed-advanced.js +269 -0
- package/dist/browser/seo/keyword-campaign-seed-core.d.ts +29 -0
- package/dist/browser/seo/keyword-campaign-seed-core.js +525 -0
- package/dist/browser/seo/keyword-campaign-shared.d.ts +165 -0
- package/dist/browser/seo/keyword-campaign-shared.js +59 -0
- package/dist/browser/seo/keyword-campaign.d.ts +4 -107
- package/dist/browser/seo/keyword-campaign.js +2 -380
- package/dist/browser/seo/keywords.js +5 -22
- package/dist/browser/seo/types.d.ts +19 -0
- package/dist/browser/transport/curl.d.ts +5 -1
- package/dist/browser/transport/curl.js +207 -50
- package/dist/browser/transport/undici.d.ts +4 -3
- package/dist/browser/transport/undici.js +123 -49
- package/dist/browser/types/index.d.ts +9 -3
- package/dist/browser/utils/binary-manager.js +26 -3
- package/dist/browser/utils/block-detector.d.ts +8 -0
- package/dist/browser/utils/block-detector.js +542 -7
- package/dist/cli/commands/hls-runner.js +5 -4
- package/dist/cli/commands/live-runner.js +5 -4
- package/dist/cli/commands/loadtest-runner.js +3 -2
- package/dist/cli/commands/search.d.ts +2 -0
- package/dist/cli/commands/search.js +105 -0
- package/dist/cli/commands/seo-runner.js +9 -7
- package/dist/cli/commands/seo.js +140 -1
- package/dist/cli/commands/serve.js +75 -131
- package/dist/cli/commands/server-runner.js +59 -82
- package/dist/cli/commands/spider-runner.d.ts +37 -1
- package/dist/cli/commands/spider-runner.js +134 -10
- package/dist/cli/commands/spider.d.ts +18 -1
- package/dist/cli/commands/spider.js +457 -27
- package/dist/cli/events/handlers/cli.js +30 -1
- package/dist/cli/events/handlers/tui.js +26 -0
- package/dist/cli/events/types.d.ts +27 -0
- package/dist/cli/handler.d.ts +2 -12
- package/dist/cli/handler.js +20 -15
- package/dist/cli/handlers/protocols.js +39 -12
- package/dist/cli/handlers/search.d.ts +2 -0
- package/dist/cli/handlers/search.js +171 -0
- package/dist/cli/handlers/seo-analyze.d.ts +1 -0
- package/dist/cli/handlers/seo-analyze.js +666 -0
- package/dist/cli/handlers/seo-robots.d.ts +1 -0
- package/dist/cli/handlers/seo-robots.js +76 -0
- package/dist/cli/handlers/seo-serp.d.ts +54 -0
- package/dist/cli/handlers/seo-serp.js +243 -0
- package/dist/cli/handlers/seo-sitemap.d.ts +1 -0
- package/dist/cli/handlers/seo-sitemap.js +55 -0
- package/dist/cli/handlers/seo-spider.d.ts +1 -0
- package/dist/cli/handlers/seo-spider.js +334 -0
- package/dist/cli/handlers/seo.d.ts +8 -4
- package/dist/cli/handlers/seo.js +294 -442
- package/dist/cli/handlers/spider.js +94 -17
- package/dist/cli/handlers/streaming.js +5 -1
- package/dist/cli/index.js +11 -2
- package/dist/cli/presets.d.ts +1 -1
- package/dist/cli/presets.js +15 -4
- package/dist/cli/tui/app.js +6 -1
- package/dist/cli/tui/components/rich-response.d.ts +72 -0
- package/dist/cli/tui/components/rich-response.js +117 -0
- package/dist/cli/tui/executor-commands/background.js +30 -24
- package/dist/cli/tui/executor-commands/testing.js +3 -2
- package/dist/cli/tui/hooks/useDomains.d.ts +17 -0
- package/dist/cli/tui/hooks/useHelp.js +15 -2
- package/dist/cli/tui/job-manager.d.ts +4 -4
- package/dist/cli/tui/job-manager.js +5 -1
- package/dist/cli/tui/spider-tui.d.ts +63 -0
- package/dist/cli/tui/spider-tui.js +120 -2
- package/dist/cli/types.d.ts +12 -0
- package/dist/cli/types.js +1 -0
- package/dist/cli/utils/option-helpers.d.ts +10 -0
- package/dist/cli/utils/option-helpers.js +63 -0
- package/dist/cli/utils/score-color.d.ts +11 -0
- package/dist/cli/utils/score-color.js +11 -0
- package/dist/cli/utils/serp-campaign.d.ts +53 -0
- package/dist/cli/utils/serp-campaign.js +53 -0
- package/dist/cli/utils/serp-config.d.ts +26 -0
- package/dist/cli/utils/serp-config.js +125 -0
- package/dist/core/client.d.ts +15 -10
- package/dist/core/client.js +54 -38
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/mcp/cli.js +35 -34
- package/dist/mcp/client.d.ts +2 -2
- package/dist/mcp/client.js +20 -2
- package/dist/mcp/contract.d.ts +1 -1
- package/dist/mcp/profiles.js +5 -1
- package/dist/mcp/prompts/index.js +8 -4
- package/dist/mcp/resources/index.js +46 -23
- package/dist/mcp/server.js +9 -6
- package/dist/mcp/tools/protocols.js +9 -2
- package/dist/mcp/tools/registry.js +13 -3
- package/dist/mcp/tools/seo.js +427 -2
- package/dist/mcp/types.d.ts +5 -1
- package/dist/plugins/proxy-rotator.d.ts +2 -2
- package/dist/plugins/proxy-rotator.js +6 -28
- package/dist/raffel/client.d.ts +38 -0
- package/dist/raffel/client.js +282 -0
- package/dist/raffel/index.d.ts +2 -0
- package/dist/raffel/index.js +2 -0
- package/dist/raffel/types.d.ts +40 -0
- package/dist/raffel/types.js +14 -0
- package/dist/recker.d.ts +13 -7
- package/dist/recker.js +58 -6
- package/dist/scrape/document.js +2 -2
- package/dist/scrape/element.js +7 -1
- package/dist/scrape/parser/nodes/html.js +1 -1
- package/dist/scrape/spider.d.ts +52 -0
- package/dist/scrape/spider.js +620 -38
- package/dist/scrape/types.d.ts +2 -0
- package/dist/search/google.d.ts +26 -1
- package/dist/search/google.js +427 -45
- package/dist/search/index.d.ts +1 -1
- package/dist/seo/analyzer.d.ts +1 -0
- package/dist/seo/analyzer.js +144 -1
- package/dist/seo/index.d.ts +1 -1
- package/dist/seo/keyword-campaign-analyzer.d.ts +2 -0
- package/dist/seo/keyword-campaign-analyzer.js +538 -0
- package/dist/seo/keyword-campaign-seed-advanced.d.ts +17 -0
- package/dist/seo/keyword-campaign-seed-advanced.js +269 -0
- package/dist/seo/keyword-campaign-seed-core.d.ts +29 -0
- package/dist/seo/keyword-campaign-seed-core.js +525 -0
- package/dist/seo/keyword-campaign-shared.d.ts +165 -0
- package/dist/seo/keyword-campaign-shared.js +59 -0
- package/dist/seo/keyword-campaign.d.ts +4 -107
- package/dist/seo/keyword-campaign.js +2 -380
- package/dist/seo/keywords.js +5 -22
- package/dist/seo/types.d.ts +19 -0
- package/dist/template/index.d.ts +1 -1
- package/dist/template/types.d.ts +0 -2
- package/dist/testing/index.d.ts +1 -22
- package/dist/testing/index.js +1 -11
- package/dist/transport/curl.d.ts +5 -1
- package/dist/transport/curl.js +207 -50
- package/dist/transport/undici.d.ts +4 -3
- package/dist/transport/undici.js +123 -49
- package/dist/types/index.d.ts +9 -3
- package/dist/utils/binary-manager.js +26 -3
- package/dist/utils/block-detector.d.ts +8 -0
- package/dist/utils/block-detector.js +542 -7
- package/dist/version.js +1 -1
- package/package.json +12 -1
- package/dist/testing/mock-dns-server.d.ts +0 -69
- package/dist/testing/mock-dns-server.js +0 -269
- package/dist/testing/mock-ftp-server.d.ts +0 -89
- package/dist/testing/mock-ftp-server.js +0 -562
- package/dist/testing/mock-hls-server.d.ts +0 -80
- package/dist/testing/mock-hls-server.js +0 -381
- package/dist/testing/mock-http-server.d.ts +0 -124
- package/dist/testing/mock-http-server.js +0 -343
- package/dist/testing/mock-proxy-server.d.ts +0 -108
- package/dist/testing/mock-proxy-server.js +0 -615
- package/dist/testing/mock-sse-server.d.ts +0 -76
- package/dist/testing/mock-sse-server.js +0 -291
- package/dist/testing/mock-telnet-server.d.ts +0 -59
- package/dist/testing/mock-telnet-server.js +0 -274
- package/dist/testing/mock-udp-server.d.ts +0 -43
- package/dist/testing/mock-udp-server.js +0 -188
- package/dist/testing/mock-websocket-server.d.ts +0 -76
- package/dist/testing/mock-websocket-server.js +0 -334
- package/dist/testing/mock-whois-server.d.ts +0 -56
- package/dist/testing/mock-whois-server.js +0 -234
- package/dist/testing/proxy-certs.d.ts +0 -19
- package/dist/testing/proxy-certs.js +0 -208
|
@@ -0,0 +1,525 @@
|
|
|
1
|
+
import { DEFAULT_SERP_MIN_KEYWORD_LENGTH, normalizeKeyword, tokenizeForLongTail, } from './keyword-campaign-shared.js';
|
|
2
|
+
import { deduplicateKeywordPermutations, extractHeadingPathCompositionSeeds, extractSchemaOrgLongTailSeeds, getSeedWordCount, } from './keyword-campaign-seed-advanced.js';
|
|
3
|
+
export function extractKeywordCampaignSeedsFromReport(report, options = {}) {
|
|
4
|
+
const maxKeywords = options.maxKeywords ?? 24;
|
|
5
|
+
const minKeywordLength = options.minKeywordLength ?? DEFAULT_SERP_MIN_KEYWORD_LENGTH;
|
|
6
|
+
const includeLongTail = options.includeLongTail ?? true;
|
|
7
|
+
const longTailMaxPhrases = options.longTailMaxPhrases ?? Math.max(5, Math.floor(maxKeywords * 1.8));
|
|
8
|
+
const longTailMinWords = options.longTailMinWords ?? 2;
|
|
9
|
+
const longTailMaxWords = options.longTailMaxWords ?? 4;
|
|
10
|
+
const longTailTopAnchors = options.longTailTopAnchors ?? 5;
|
|
11
|
+
const longTailModifierLimit = options.longTailModifierLimit ?? Math.max(8, Math.floor(maxKeywords / 1.25));
|
|
12
|
+
const includeLongTailSectionSignals = options.includeLongTailSectionSignals ?? true;
|
|
13
|
+
const longTailSectionSourceBoost = options.longTailSectionSourceBoost ?? 1.2;
|
|
14
|
+
const includeSchemaSeeds = options.includeSchemaSeeds ?? true;
|
|
15
|
+
const includeHeadingPathSeeds = options.includeHeadingPathSeeds ?? true;
|
|
16
|
+
const topKeywordEntries = (report.keywords?.topKeywords ?? [])
|
|
17
|
+
.map((item) => ({
|
|
18
|
+
word: item.word,
|
|
19
|
+
count: Math.max(1, Math.round(item.count)),
|
|
20
|
+
normalized: normalizeKeyword(item.word),
|
|
21
|
+
}))
|
|
22
|
+
.filter((item) => item.word.trim().length >= minKeywordLength
|
|
23
|
+
&& item.normalized.length >= minKeywordLength
|
|
24
|
+
&& item.count > 0);
|
|
25
|
+
const topKeywordSet = new Set(topKeywordEntries
|
|
26
|
+
.map((item) => item.normalized)
|
|
27
|
+
.flatMap((word) => word.split(/\s+/).filter((token) => token.length >= minKeywordLength)));
|
|
28
|
+
const longTailSeeds = includeLongTail
|
|
29
|
+
? extractLongTailSeedsFromReport(report, {
|
|
30
|
+
maxKeywords,
|
|
31
|
+
longTailTopAnchors,
|
|
32
|
+
longTailModifierLimit,
|
|
33
|
+
topKeywordSet,
|
|
34
|
+
minKeywordLength,
|
|
35
|
+
longTailMaxPhrases,
|
|
36
|
+
longTailMinWords,
|
|
37
|
+
longTailMaxWords,
|
|
38
|
+
includeLongTailSectionSignals,
|
|
39
|
+
longTailSectionSourceBoost,
|
|
40
|
+
}, topKeywordEntries)
|
|
41
|
+
: [];
|
|
42
|
+
const topKeywordsLimit = includeLongTail
|
|
43
|
+
? Math.min(maxKeywords, Math.max(3, Math.floor(maxKeywords / 3)))
|
|
44
|
+
: maxKeywords;
|
|
45
|
+
const topKeywordSeeds = topKeywordEntries
|
|
46
|
+
.slice(0, topKeywordsLimit)
|
|
47
|
+
.map((item) => ({
|
|
48
|
+
keyword: item.word,
|
|
49
|
+
normalizedKeyword: item.normalized,
|
|
50
|
+
source: 'discovered',
|
|
51
|
+
sourcePage: options.sourcePage,
|
|
52
|
+
weight: item.count,
|
|
53
|
+
}));
|
|
54
|
+
const schemaSeeds = includeSchemaSeeds
|
|
55
|
+
? extractSchemaOrgLongTailSeeds(report, {
|
|
56
|
+
minKeywordLength,
|
|
57
|
+
maxPhrases: Math.max(3, Math.floor(maxKeywords / 3)),
|
|
58
|
+
sourcePage: options.sourcePage,
|
|
59
|
+
})
|
|
60
|
+
: [];
|
|
61
|
+
const headingPathSeeds = includeHeadingPathSeeds && includeLongTail
|
|
62
|
+
? extractHeadingPathCompositionSeeds(report, {
|
|
63
|
+
minKeywordLength,
|
|
64
|
+
maxPhrases: Math.max(3, Math.floor(maxKeywords / 2)),
|
|
65
|
+
topKeywordSet,
|
|
66
|
+
sourcePage: options.sourcePage,
|
|
67
|
+
})
|
|
68
|
+
: [];
|
|
69
|
+
const allSeeds = [...topKeywordSeeds, ...schemaSeeds, ...headingPathSeeds, ...longTailSeeds]
|
|
70
|
+
.filter(seed => seed.keyword.trim().length >= minKeywordLength
|
|
71
|
+
&& seed.normalizedKeyword.length >= minKeywordLength
|
|
72
|
+
&& seed.weight > 0);
|
|
73
|
+
return deduplicateKeywordPermutations(allSeeds)
|
|
74
|
+
.sort((a, b) => {
|
|
75
|
+
const aWords = getSeedWordCount(a);
|
|
76
|
+
const bWords = getSeedWordCount(b);
|
|
77
|
+
if (aWords === 1 && bWords > 1)
|
|
78
|
+
return -1;
|
|
79
|
+
if (bWords === 1 && aWords > 1)
|
|
80
|
+
return 1;
|
|
81
|
+
if (b.weight !== a.weight)
|
|
82
|
+
return b.weight - a.weight;
|
|
83
|
+
if (aWords !== bWords)
|
|
84
|
+
return aWords - bWords;
|
|
85
|
+
return a.normalizedKeyword.localeCompare(b.normalizedKeyword);
|
|
86
|
+
})
|
|
87
|
+
.slice(0, maxKeywords);
|
|
88
|
+
}
|
|
89
|
+
function extractLongTailSeedsFromReport(report, options, topKeywords) {
|
|
90
|
+
const textSources = collectLongTailTextSources(report, topKeywords, options.maxKeywords, options.includeLongTailSectionSignals, options.longTailSectionSourceBoost);
|
|
91
|
+
if (textSources.length === 0 || options.topKeywordSet.size === 0) {
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
const anchorEntries = buildLongTailAnchorTokenSet(topKeywords, options.longTailTopAnchors);
|
|
95
|
+
const anchorTokenSet = new Set(anchorEntries.map((entry) => entry.token));
|
|
96
|
+
if (anchorTokenSet.size === 0) {
|
|
97
|
+
return [];
|
|
98
|
+
}
|
|
99
|
+
const globalTokenStats = collectLongTailTokenStats(textSources, anchorTokenSet);
|
|
100
|
+
const modifiers = collectLongTailModifiers(globalTokenStats, options.longTailModifierLimit);
|
|
101
|
+
const phraseCounts = new Map();
|
|
102
|
+
const minWords = Math.max(2, options.longTailMinWords);
|
|
103
|
+
const maxWords = Math.max(minWords, options.longTailMaxWords);
|
|
104
|
+
for (const source of textSources) {
|
|
105
|
+
const tokens = tokenizeForLongTail(source.text);
|
|
106
|
+
if (tokens.length < minWords)
|
|
107
|
+
continue;
|
|
108
|
+
const positionSet = source.source === 'link-anchor' ? options.topKeywordSet : anchorTokenSet;
|
|
109
|
+
const anchorPositions = collectAnchorPositions(tokens, positionSet);
|
|
110
|
+
if (anchorPositions.length === 0)
|
|
111
|
+
continue;
|
|
112
|
+
for (const anchorIndex of anchorPositions) {
|
|
113
|
+
for (let size = minWords; size <= maxWords; size += 1) {
|
|
114
|
+
for (let leftExtra = 0; leftExtra < size; leftExtra += 1) {
|
|
115
|
+
const rightExtra = size - 1 - leftExtra;
|
|
116
|
+
const start = anchorIndex - leftExtra;
|
|
117
|
+
const end = anchorIndex + rightExtra;
|
|
118
|
+
if (start < 0 || end >= tokens.length)
|
|
119
|
+
continue;
|
|
120
|
+
const phraseTokens = tokens.slice(start, end + 1);
|
|
121
|
+
if (!containsCoreKeyword(phraseTokens, options.topKeywordSet))
|
|
122
|
+
continue;
|
|
123
|
+
if (isLowValueLongTail(phraseTokens))
|
|
124
|
+
continue;
|
|
125
|
+
const normalized = normalizeKeyword(phraseTokens.join(' '));
|
|
126
|
+
if (!normalized || normalized.length < options.minKeywordLength)
|
|
127
|
+
continue;
|
|
128
|
+
const proximityBoost = getPhraseProximityBoost(leftExtra, rightExtra, size);
|
|
129
|
+
const weightDelta = source.focusWeight * proximityBoost;
|
|
130
|
+
const current = phraseCounts.get(normalized);
|
|
131
|
+
if (!current) {
|
|
132
|
+
phraseCounts.set(normalized, {
|
|
133
|
+
phrase: phraseTokens.join(' '),
|
|
134
|
+
normalized,
|
|
135
|
+
weight: weightDelta,
|
|
136
|
+
words: size,
|
|
137
|
+
});
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
current.weight += weightDelta;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
applyLongTailCombinationalExpansion({
|
|
146
|
+
anchorEntries,
|
|
147
|
+
modifiers,
|
|
148
|
+
minWords,
|
|
149
|
+
maxWords,
|
|
150
|
+
phraseCounts,
|
|
151
|
+
});
|
|
152
|
+
const ltSeeds = [...phraseCounts.values()]
|
|
153
|
+
.map((entry) => ({
|
|
154
|
+
keyword: entry.phrase,
|
|
155
|
+
normalizedKeyword: entry.normalized,
|
|
156
|
+
source: 'discovered',
|
|
157
|
+
sourcePage: report.url,
|
|
158
|
+
weight: Math.max(1, Math.round(entry.weight * Math.max(1, entry.words))),
|
|
159
|
+
}))
|
|
160
|
+
.filter((seed) => seed.normalizedKeyword.length >= options.minKeywordLength)
|
|
161
|
+
.sort((a, b) => (b.weight - a.weight) || a.normalizedKeyword.localeCompare(b.normalizedKeyword))
|
|
162
|
+
.slice(0, options.longTailMaxPhrases)
|
|
163
|
+
.filter((seed) => !isConnectorBoundaryPhrase(seed.normalizedKeyword))
|
|
164
|
+
.map((seed, index) => ({
|
|
165
|
+
...seed,
|
|
166
|
+
sourcePage: `${seed.sourcePage}#lt-${index}`,
|
|
167
|
+
}));
|
|
168
|
+
const directAnchorSeeds = [];
|
|
169
|
+
if (report.linkAnchorTexts?.length) {
|
|
170
|
+
for (const anchorText of report.linkAnchorTexts.slice(0, Math.max(3, options.maxKeywords))) {
|
|
171
|
+
const tokens = tokenizeForLongTail(anchorText);
|
|
172
|
+
if (tokens.length < minWords || tokens.length > maxWords)
|
|
173
|
+
continue;
|
|
174
|
+
if (tokens.some((t) => t.length < 3))
|
|
175
|
+
continue;
|
|
176
|
+
if (!containsCoreKeyword(tokens, options.topKeywordSet))
|
|
177
|
+
continue;
|
|
178
|
+
if (isLowValueLongTail(tokens))
|
|
179
|
+
continue;
|
|
180
|
+
const normalized = normalizeKeyword(tokens.join(' '));
|
|
181
|
+
if (!normalized || normalized.length < options.minKeywordLength)
|
|
182
|
+
continue;
|
|
183
|
+
if (isConnectorBoundaryPhrase(normalized))
|
|
184
|
+
continue;
|
|
185
|
+
directAnchorSeeds.push({
|
|
186
|
+
keyword: tokens.join(' '),
|
|
187
|
+
normalizedKeyword: normalized,
|
|
188
|
+
source: 'discovered',
|
|
189
|
+
sourcePage: report.url ? `${report.url}#anchor` : undefined,
|
|
190
|
+
weight: 120,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return [...ltSeeds, ...directAnchorSeeds];
|
|
195
|
+
}
|
|
196
|
+
function collectLongTailTextSources(report, topKeywords, maxSources, includeSectionSignals = true, sectionSourceBoost = 1.2) {
|
|
197
|
+
const sources = [];
|
|
198
|
+
if (report.title?.text) {
|
|
199
|
+
sources.push({ source: 'title', text: report.title.text, focusWeight: 3 });
|
|
200
|
+
}
|
|
201
|
+
if (report.metaDescription?.text) {
|
|
202
|
+
sources.push({ source: 'description', text: report.metaDescription.text, focusWeight: 2.5 });
|
|
203
|
+
}
|
|
204
|
+
const urlText = extractReadablePathSegments(report.url);
|
|
205
|
+
if (urlText) {
|
|
206
|
+
sources.push({ source: 'url', text: urlText, focusWeight: 2 });
|
|
207
|
+
}
|
|
208
|
+
if (includeSectionSignals && report.contentSections?.length) {
|
|
209
|
+
const sectionSources = collectLongTailSectionSources(report.contentSections, sectionSourceBoost, Math.max(2, Math.floor(maxSources / 3)));
|
|
210
|
+
sources.push(...sectionSources);
|
|
211
|
+
}
|
|
212
|
+
if (report.headings?.structure?.length) {
|
|
213
|
+
const headingTexts = report.headings.structure
|
|
214
|
+
.map((heading) => heading.text)
|
|
215
|
+
.filter((text) => text.trim().length > 0)
|
|
216
|
+
.slice(0, maxSources);
|
|
217
|
+
for (const text of headingTexts) {
|
|
218
|
+
sources.push({ source: 'heading', text, focusWeight: 1.8 });
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (report.linkAnchorTexts?.length) {
|
|
222
|
+
const linkAnchors = report.linkAnchorTexts
|
|
223
|
+
.map((text) => text.trim())
|
|
224
|
+
.filter((text) => text.length > 0)
|
|
225
|
+
.slice(0, Math.max(3, maxSources));
|
|
226
|
+
for (const text of linkAnchors) {
|
|
227
|
+
sources.push({ source: 'link-anchor', text, focusWeight: 1.4 });
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (report.linkUrlSamples?.length) {
|
|
231
|
+
const linkUrls = report.linkUrlSamples
|
|
232
|
+
.map((text) => text.trim())
|
|
233
|
+
.filter((text) => text.length > 0)
|
|
234
|
+
.slice(0, Math.max(3, Math.floor(maxSources / 2)));
|
|
235
|
+
for (const text of linkUrls) {
|
|
236
|
+
sources.push({ source: 'link-url', text, focusWeight: 1.1 });
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
if (topKeywords.length > 0) {
|
|
240
|
+
const boostedTerms = topKeywords
|
|
241
|
+
.slice(0, maxSources)
|
|
242
|
+
.map((item) => item.word)
|
|
243
|
+
.join(' ');
|
|
244
|
+
if (boostedTerms.length > 0) {
|
|
245
|
+
sources.push({ source: 'top-keywords', text: boostedTerms, focusWeight: 1.5 });
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return sources;
|
|
249
|
+
}
|
|
250
|
+
function collectLongTailSectionSources(sections, sectionSourceBoost, maxSources) {
|
|
251
|
+
const sourceLimit = Math.max(1, maxSources);
|
|
252
|
+
const collected = sections
|
|
253
|
+
.filter((section) => section.text.length >= 12)
|
|
254
|
+
.map((section) => {
|
|
255
|
+
const headingPath = section.headingPath
|
|
256
|
+
.map((part) => part.trim())
|
|
257
|
+
.filter((part) => part.length > 0);
|
|
258
|
+
const pathText = headingPath.length > 0 ? headingPath.join(' ') : '';
|
|
259
|
+
const sourceText = pathText.length > 0
|
|
260
|
+
? `${pathText} ${section.text}`
|
|
261
|
+
: section.text;
|
|
262
|
+
const baseWeight = getSectionSignalWeight(section);
|
|
263
|
+
const adjustedWeight = baseWeight * sectionSourceBoost * (1 - section.linkDensity * 0.45);
|
|
264
|
+
return {
|
|
265
|
+
source: `section:${section.source}`,
|
|
266
|
+
text: sourceText,
|
|
267
|
+
focusWeight: Math.max(0.55, adjustedWeight),
|
|
268
|
+
};
|
|
269
|
+
})
|
|
270
|
+
.filter((source) => source.text.length >= 24)
|
|
271
|
+
.sort((a, b) => b.focusWeight - a.focusWeight || a.text.localeCompare(b.text));
|
|
272
|
+
return collected.slice(0, sourceLimit);
|
|
273
|
+
}
|
|
274
|
+
function getSectionSignalWeight(section) {
|
|
275
|
+
if (section.source === 'heading') {
|
|
276
|
+
const levelWeight = section.headingLevel <= 1 ? 2.8
|
|
277
|
+
: section.headingLevel === 2 ? 2.2
|
|
278
|
+
: section.headingLevel === 3 ? 1.8
|
|
279
|
+
: 1.2;
|
|
280
|
+
return levelWeight * Math.max(0.6, section.weight || 0.95);
|
|
281
|
+
}
|
|
282
|
+
const sourceWeight = section.source === 'list-item'
|
|
283
|
+
? 1.28
|
|
284
|
+
: section.source === 'paragraph'
|
|
285
|
+
? 1.22
|
|
286
|
+
: section.source === 'figure' || section.source === 'table'
|
|
287
|
+
? 1.12
|
|
288
|
+
: 1.05;
|
|
289
|
+
return sourceWeight * Math.max(0.6, section.weight || 0.95);
|
|
290
|
+
}
|
|
291
|
+
function containsCoreKeyword(tokens, topKeywordSet) {
|
|
292
|
+
return tokens.some((token) => topKeywordSet.has(token));
|
|
293
|
+
}
|
|
294
|
+
function buildLongTailAnchorTokenSet(topKeywords, topAnchors) {
|
|
295
|
+
const orderedTokens = new Map();
|
|
296
|
+
for (const entry of [...topKeywords]
|
|
297
|
+
.sort((a, b) => b.count - a.count || b.normalized.localeCompare(a.normalized))
|
|
298
|
+
.slice(0, Math.max(1, topAnchors))) {
|
|
299
|
+
for (const token of entry.normalized.split(/\s+/).filter((value) => value.length >= 2)) {
|
|
300
|
+
const current = orderedTokens.get(token) ?? 0;
|
|
301
|
+
orderedTokens.set(token, Math.max(current, entry.count));
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return [...orderedTokens.entries()]
|
|
305
|
+
.map(([token, weight]) => ({ token, weight }))
|
|
306
|
+
.sort((a, b) => b.weight - a.weight || a.token.localeCompare(b.token))
|
|
307
|
+
.slice(0, Math.max(1, topAnchors * 3));
|
|
308
|
+
}
|
|
309
|
+
function collectAnchorPositions(tokens, anchorTokenSet) {
|
|
310
|
+
const positions = [];
|
|
311
|
+
for (let index = 0; index < tokens.length; index += 1) {
|
|
312
|
+
if (anchorTokenSet.has(tokens[index])) {
|
|
313
|
+
positions.push(index);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return positions;
|
|
317
|
+
}
|
|
318
|
+
function getPhraseProximityBoost(leftExtra, rightExtra, size) {
|
|
319
|
+
const idealCenterOffset = (size - 1) / 2;
|
|
320
|
+
const actualOffset = Math.min(leftExtra, rightExtra);
|
|
321
|
+
const distanceFromCenter = Math.abs(actualOffset - idealCenterOffset);
|
|
322
|
+
return 1 + Math.max(0, 1 - Math.min(1, distanceFromCenter / Math.max(1, idealCenterOffset)));
|
|
323
|
+
}
|
|
324
|
+
const PT_STOP_TOKENS = new Set([
|
|
325
|
+
'de', 'da', 'do', 'das', 'dos', 'para', 'com', 'em', 'na', 'no', 'as', 'os',
|
|
326
|
+
]);
|
|
327
|
+
function collectLongTailTokenStats(textSources, anchorTokenSet) {
|
|
328
|
+
const counters = new Map();
|
|
329
|
+
for (const source of textSources) {
|
|
330
|
+
const tokens = tokenizeForLongTail(source.text);
|
|
331
|
+
for (const token of tokens) {
|
|
332
|
+
if (token.length < 2)
|
|
333
|
+
continue;
|
|
334
|
+
if (token.match(/^\d+$/))
|
|
335
|
+
continue;
|
|
336
|
+
if (anchorTokenSet.has(token))
|
|
337
|
+
continue;
|
|
338
|
+
const normalized = normalizeKeyword(token);
|
|
339
|
+
if (!normalized)
|
|
340
|
+
continue;
|
|
341
|
+
const current = counters.get(normalized);
|
|
342
|
+
if (!current) {
|
|
343
|
+
counters.set(normalized, {
|
|
344
|
+
token,
|
|
345
|
+
normalized,
|
|
346
|
+
count: 1,
|
|
347
|
+
weight: source.focusWeight,
|
|
348
|
+
});
|
|
349
|
+
continue;
|
|
350
|
+
}
|
|
351
|
+
current.count += 1;
|
|
352
|
+
current.weight += source.focusWeight;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return [...counters.values()]
|
|
356
|
+
.sort((a, b) => (b.weight - a.weight) || b.count - a.count || a.token.localeCompare(b.token));
|
|
357
|
+
}
|
|
358
|
+
function collectLongTailModifiers(tokenStats, limit) {
|
|
359
|
+
const minWeight = 1;
|
|
360
|
+
return tokenStats
|
|
361
|
+
.filter((item) => item.count >= 1 && item.weight >= minWeight && !PT_STOP_TOKENS.has(item.normalized))
|
|
362
|
+
.map((item) => ({ token: item.token, weight: item.weight }))
|
|
363
|
+
.slice(0, Math.max(4, Math.min(24, limit)));
|
|
364
|
+
}
|
|
365
|
+
function applyLongTailCombinationalExpansion(options) {
|
|
366
|
+
if (options.anchorEntries.length === 0 || options.modifiers.length === 0)
|
|
367
|
+
return;
|
|
368
|
+
if (options.maxWords < 2)
|
|
369
|
+
return;
|
|
370
|
+
const maxModifiers = Math.max(2, Math.min(8, options.modifiers.length));
|
|
371
|
+
const baseModifiers = options.modifiers.slice(0, maxModifiers);
|
|
372
|
+
const anchors = options.anchorEntries.slice(0, Math.max(2, options.anchorEntries.length));
|
|
373
|
+
const upsert = (phrase, baseWeight, words) => {
|
|
374
|
+
const phraseTokens = phrase.split(' ');
|
|
375
|
+
if (isLowValueLongTail(phraseTokens))
|
|
376
|
+
return;
|
|
377
|
+
const normalized = normalizeKeyword(phrase);
|
|
378
|
+
if (!normalized)
|
|
379
|
+
return;
|
|
380
|
+
const current = options.phraseCounts.get(normalized);
|
|
381
|
+
if (!current) {
|
|
382
|
+
options.phraseCounts.set(normalized, {
|
|
383
|
+
phrase,
|
|
384
|
+
normalized,
|
|
385
|
+
weight: baseWeight,
|
|
386
|
+
words,
|
|
387
|
+
});
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
current.weight += baseWeight;
|
|
391
|
+
};
|
|
392
|
+
for (const { token: anchor, weight: anchorWeight } of anchors) {
|
|
393
|
+
for (let i = 0; i < baseModifiers.length; i += 1) {
|
|
394
|
+
const m1 = baseModifiers[i];
|
|
395
|
+
if (m1.token === anchor)
|
|
396
|
+
continue;
|
|
397
|
+
const phrase2A = `${anchor} ${m1.token}`;
|
|
398
|
+
const phrase2B = `${m1.token} ${anchor}`;
|
|
399
|
+
const baseWeight2 = (anchorWeight + m1.weight) * 0.7;
|
|
400
|
+
upsert(phrase2A, baseWeight2, 2);
|
|
401
|
+
upsert(phrase2B, baseWeight2, 2);
|
|
402
|
+
if (options.maxWords >= 3) {
|
|
403
|
+
for (let j = i + 1; j < Math.min(i + 3, baseModifiers.length); j += 1) {
|
|
404
|
+
const m2 = baseModifiers[j];
|
|
405
|
+
if (m2.token === anchor || m2.token === m1.token)
|
|
406
|
+
continue;
|
|
407
|
+
const phrase3A = `${anchor} ${m1.token} ${m2.token}`;
|
|
408
|
+
const phrase3B = `${m1.token} ${anchor} ${m2.token}`;
|
|
409
|
+
const phrase3C = `${m1.token} ${m2.token} ${anchor}`;
|
|
410
|
+
const baseWeight3 = (anchorWeight + m1.weight + m2.weight) * 0.55;
|
|
411
|
+
upsert(phrase3A, baseWeight3, 3);
|
|
412
|
+
upsert(phrase3B, baseWeight3, 3);
|
|
413
|
+
upsert(phrase3C, baseWeight3, 3);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
if (options.maxWords >= 4) {
|
|
417
|
+
for (let j = i + 1; j < Math.min(i + 2, baseModifiers.length); j += 1) {
|
|
418
|
+
const m2 = baseModifiers[j];
|
|
419
|
+
if (m2.token === anchor || m2.token === m1.token)
|
|
420
|
+
continue;
|
|
421
|
+
for (let k = j + 1; k < Math.min(j + 2, baseModifiers.length); k += 1) {
|
|
422
|
+
const m3 = baseModifiers[k];
|
|
423
|
+
if (m3.token === anchor || m3.token === m1.token || m3.token === m2.token)
|
|
424
|
+
continue;
|
|
425
|
+
const phrase4A = `${anchor} ${m1.token} ${m2.token} ${m3.token}`;
|
|
426
|
+
const phrase4B = `${m1.token} ${anchor} ${m2.token} ${m3.token}`;
|
|
427
|
+
const phrase4C = `${m1.token} ${m2.token} ${anchor} ${m3.token}`;
|
|
428
|
+
const baseWeight4 = (anchorWeight + m1.weight + m2.weight + m3.weight) * 0.42;
|
|
429
|
+
upsert(phrase4A, baseWeight4, 4);
|
|
430
|
+
upsert(phrase4B, baseWeight4, 4);
|
|
431
|
+
upsert(phrase4C, baseWeight4, 4);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
if (options.minWords > 2) {
|
|
438
|
+
for (const key of options.phraseCounts.keys()) {
|
|
439
|
+
const tokens = key.split(' ');
|
|
440
|
+
if (tokens.length < options.minWords) {
|
|
441
|
+
options.phraseCounts.delete(key);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
function isConnectorBoundaryPhrase(normalized) {
|
|
447
|
+
const tokens = normalized.split(/\s+/).filter(Boolean);
|
|
448
|
+
return tokens.length >= 2
|
|
449
|
+
&& (PT_STOP_TOKENS.has(tokens[0]) || PT_STOP_TOKENS.has(tokens[tokens.length - 1]));
|
|
450
|
+
}
|
|
451
|
+
function isLowValueLongTail(tokens) {
|
|
452
|
+
const normalized = tokens.map((token) => normalizeKeyword(token)).filter(Boolean);
|
|
453
|
+
if (normalized.length === 0)
|
|
454
|
+
return true;
|
|
455
|
+
if (normalized.length === 1)
|
|
456
|
+
return true;
|
|
457
|
+
if (new Set(normalized).size === 1)
|
|
458
|
+
return true;
|
|
459
|
+
if (normalized.every((token) => token.length <= 3))
|
|
460
|
+
return true;
|
|
461
|
+
const shortTokenCount = normalized.filter((token) => token.length <= 2).length;
|
|
462
|
+
if (shortTokenCount >= Math.max(1, Math.floor(normalized.length / 2)))
|
|
463
|
+
return true;
|
|
464
|
+
if (normalized.every((token) => token.match(/^\d+$/)))
|
|
465
|
+
return true;
|
|
466
|
+
if (normalized.length >= 3 && normalized.every((token) => token.length <= 4)) {
|
|
467
|
+
return true;
|
|
468
|
+
}
|
|
469
|
+
return normalized.some((token) => token.match(/^\d+$/));
|
|
470
|
+
}
|
|
471
|
+
export const SERP_BLOCK_CONFIDENCE = 0.6;
|
|
472
|
+
export const SERP_CAPTCHA_CONFIDENCE = 0.6;
|
|
473
|
+
export const DEFAULT_SERP_SEARCH_DELAY_MS = 450;
|
|
474
|
+
export const DEFAULT_SERP_SEARCH_JITTER_MS = 250;
|
|
475
|
+
export const DEFAULT_SERP_SEARCH_CAPTCHA_COOLDOWN_MS = 1200;
|
|
476
|
+
export const DEFAULT_SERP_SEARCH_RETRY_COUNT = 1;
|
|
477
|
+
export const DEFAULT_SERP_SEARCH_RETRY_DELAY_MS = 900;
|
|
478
|
+
export const DEFAULT_SERP_MAX_CONSECUTIVE_BLOCKS = 3;
|
|
479
|
+
export function isLikelyBlocked(block) {
|
|
480
|
+
if (!block)
|
|
481
|
+
return false;
|
|
482
|
+
return Boolean(block.blocked) && (block.confidence ?? 0) >= SERP_BLOCK_CONFIDENCE;
|
|
483
|
+
}
|
|
484
|
+
export function isLikelyCaptcha(captcha) {
|
|
485
|
+
if (!captcha)
|
|
486
|
+
return false;
|
|
487
|
+
return Boolean(captcha.detected) && (captcha.confidence ?? 0) >= SERP_CAPTCHA_CONFIDENCE;
|
|
488
|
+
}
|
|
489
|
+
export function sleep(ms) {
|
|
490
|
+
if (ms <= 0)
|
|
491
|
+
return Promise.resolve();
|
|
492
|
+
return new Promise((resolve) => {
|
|
493
|
+
setTimeout(resolve, ms);
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
export function buildSerpBlockReason(block, captcha) {
|
|
497
|
+
const parts = [];
|
|
498
|
+
if (captcha?.provider || captcha?.description) {
|
|
499
|
+
const provider = captcha.provider ? `${captcha.provider}` : 'captcha';
|
|
500
|
+
parts.push(`captcha=${provider}`);
|
|
501
|
+
}
|
|
502
|
+
if (block?.reason || block?.description) {
|
|
503
|
+
const reason = block.reason ? `block:${block.reason}` : 'block';
|
|
504
|
+
const description = block.description ? ` (${block.description})` : '';
|
|
505
|
+
parts.push(`${reason}${description}`);
|
|
506
|
+
}
|
|
507
|
+
return parts.length > 0 ? parts.join(' | ') : undefined;
|
|
508
|
+
}
|
|
509
|
+
function extractReadablePathSegments(url) {
|
|
510
|
+
try {
|
|
511
|
+
const parsed = new URL(url);
|
|
512
|
+
const segments = parsed.pathname
|
|
513
|
+
.split('/')
|
|
514
|
+
.filter((segment) => segment.length > 1)
|
|
515
|
+
.map((segment) => segment.replace(/[-_]/g, ' '))
|
|
516
|
+
.join(' ')
|
|
517
|
+
.replace(/\d+/g, ' ')
|
|
518
|
+
.replace(/\s+/g, ' ')
|
|
519
|
+
.trim();
|
|
520
|
+
return segments;
|
|
521
|
+
}
|
|
522
|
+
catch {
|
|
523
|
+
return '';
|
|
524
|
+
}
|
|
525
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import type { SearchTransport, GoogleSearchAdvancedOptions } from '../search/google.js';
|
|
2
|
+
export type KeywordCampaignSource = 'discovered' | 'preset';
|
|
3
|
+
export type CampaignResultPlacement = 'ad' | 'organic' | 'unknown';
|
|
4
|
+
export interface KeywordCampaignSeedInput {
|
|
5
|
+
keyword: string;
|
|
6
|
+
source?: KeywordCampaignSource;
|
|
7
|
+
sourcePage?: string;
|
|
8
|
+
weight?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface KeywordCampaignSeed {
|
|
11
|
+
keyword: string;
|
|
12
|
+
normalizedKeyword: string;
|
|
13
|
+
source: KeywordCampaignSource;
|
|
14
|
+
sourcePage?: string;
|
|
15
|
+
weight: number;
|
|
16
|
+
}
|
|
17
|
+
export interface KeywordCampaignOptions {
|
|
18
|
+
targetUrl: string;
|
|
19
|
+
discoveredKeywords?: KeywordCampaignSeedInput[] | string[];
|
|
20
|
+
presetKeywords?: string[];
|
|
21
|
+
minKeywordLength?: number;
|
|
22
|
+
maxQueries?: number;
|
|
23
|
+
maxResultsPerQuery?: number;
|
|
24
|
+
transport?: SearchTransport;
|
|
25
|
+
timeout?: number;
|
|
26
|
+
country?: string;
|
|
27
|
+
gl?: string;
|
|
28
|
+
hl?: string;
|
|
29
|
+
searchParams?: Partial<GoogleSearchAdvancedOptions>;
|
|
30
|
+
minWeight?: number;
|
|
31
|
+
searchConcurrency?: number;
|
|
32
|
+
searchDelayMs?: number;
|
|
33
|
+
searchDelayJitterMs?: number;
|
|
34
|
+
searchCaptchaCooldownMs?: number;
|
|
35
|
+
searchRetryCount?: number;
|
|
36
|
+
searchRetryDelayMs?: number;
|
|
37
|
+
searchMaxConsecutiveBlocks?: number;
|
|
38
|
+
}
|
|
39
|
+
export interface KeywordCampaignCompetitorResult {
|
|
40
|
+
domain: string;
|
|
41
|
+
rank: number;
|
|
42
|
+
placement: CampaignResultPlacement;
|
|
43
|
+
placementHint?: string;
|
|
44
|
+
url: string;
|
|
45
|
+
title: string;
|
|
46
|
+
}
|
|
47
|
+
export interface KeywordCampaignResult {
|
|
48
|
+
keyword: string;
|
|
49
|
+
source: KeywordCampaignSource;
|
|
50
|
+
sourcePage?: string;
|
|
51
|
+
sourceWeight: number;
|
|
52
|
+
blocked?: boolean;
|
|
53
|
+
blockReason?: string;
|
|
54
|
+
found: boolean;
|
|
55
|
+
bestPosition: number | null;
|
|
56
|
+
totalChecked: number;
|
|
57
|
+
matchedUrl?: string;
|
|
58
|
+
matchedTitle?: string;
|
|
59
|
+
matchedDisplayUrl?: string;
|
|
60
|
+
placement: CampaignResultPlacement;
|
|
61
|
+
placementHint?: string;
|
|
62
|
+
searchUrl: string;
|
|
63
|
+
searchTransport: SearchTransport;
|
|
64
|
+
competitors: KeywordCampaignCompetitorResult[];
|
|
65
|
+
}
|
|
66
|
+
export interface KeywordCampaignPageStats {
|
|
67
|
+
pageUrl: string;
|
|
68
|
+
tracked: number;
|
|
69
|
+
found: number;
|
|
70
|
+
avgPosition: number | null;
|
|
71
|
+
appearanceRate: number;
|
|
72
|
+
top3: number;
|
|
73
|
+
top10: number;
|
|
74
|
+
}
|
|
75
|
+
export interface KeywordCampaignPageOutperformance {
|
|
76
|
+
pageUrl: string;
|
|
77
|
+
outperformedQueries: number;
|
|
78
|
+
avgTargetPosition: number | null;
|
|
79
|
+
avgCompetitorPosition: number | null;
|
|
80
|
+
avgGap: number | null;
|
|
81
|
+
}
|
|
82
|
+
export interface KeywordCampaignSummary {
|
|
83
|
+
queriesRequested: number;
|
|
84
|
+
queriesExecuted: number;
|
|
85
|
+
queriesFound: number;
|
|
86
|
+
queriesBlocked: number;
|
|
87
|
+
queriesCaptcha: number;
|
|
88
|
+
campaignStopped: boolean;
|
|
89
|
+
campaignStopReason?: string;
|
|
90
|
+
avgTopPosition: number | null;
|
|
91
|
+
top3Count: number;
|
|
92
|
+
top10Count: 0 | number;
|
|
93
|
+
topOrganicCompetitors: KeywordCampaignCompetitorSummary[];
|
|
94
|
+
topPaidCompetitors: KeywordCampaignCompetitorSummary[];
|
|
95
|
+
competitorCoverage: {
|
|
96
|
+
organicUniqueDomains: number;
|
|
97
|
+
paidUniqueDomains: number;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
export interface KeywordCampaignCompetitorSummary {
|
|
101
|
+
domain: string;
|
|
102
|
+
organicQueries: number;
|
|
103
|
+
paidQueries: number;
|
|
104
|
+
bestOrganicRank: number | null;
|
|
105
|
+
bestPaidRank: number | null;
|
|
106
|
+
matchedKeywords: number;
|
|
107
|
+
totalOutperformedQueries: number;
|
|
108
|
+
avgOutperformedGap: number | null;
|
|
109
|
+
avgTargetPositionWhenOutperformed: number | null;
|
|
110
|
+
avgCompetitorPositionWhenOutperformed: number | null;
|
|
111
|
+
outperformedPages: KeywordCampaignPageOutperformance[];
|
|
112
|
+
}
|
|
113
|
+
export interface CampaignActivitySignal {
|
|
114
|
+
active: boolean;
|
|
115
|
+
confidence: 'high' | 'medium' | 'low';
|
|
116
|
+
evidence: string[];
|
|
117
|
+
}
|
|
118
|
+
export interface KeywordCampaignReport {
|
|
119
|
+
targetUrl: string;
|
|
120
|
+
targetDomain: string;
|
|
121
|
+
results: KeywordCampaignResult[];
|
|
122
|
+
summary: KeywordCampaignSummary;
|
|
123
|
+
pageComparison: KeywordCampaignPageStats[];
|
|
124
|
+
campaign: CampaignActivitySignal;
|
|
125
|
+
}
|
|
126
|
+
export declare function normalizeKeyword(value: string): string;
|
|
127
|
+
export declare function normalizeHost(target: string): string;
|
|
128
|
+
export declare function clampNumber(value: number | undefined, fallback: number): number;
|
|
129
|
+
export declare function normalizePlacement(value: string | undefined): CampaignResultPlacement;
|
|
130
|
+
export interface CompetitorTracker {
|
|
131
|
+
organicQueries: number;
|
|
132
|
+
paidQueries: number;
|
|
133
|
+
bestOrganicRank: number | null;
|
|
134
|
+
bestPaidRank: number | null;
|
|
135
|
+
keywords: Set<string>;
|
|
136
|
+
outperformedQueries: number;
|
|
137
|
+
outperformedGapTotal: number;
|
|
138
|
+
outperformedTargetPositionTotal: number;
|
|
139
|
+
outperformedCompetitorPositionTotal: number;
|
|
140
|
+
outperformedComparableQueries: number;
|
|
141
|
+
outperformedByPage: Map<string, {
|
|
142
|
+
outperformedQueries: number;
|
|
143
|
+
gapTotal: number;
|
|
144
|
+
targetTotal: number;
|
|
145
|
+
competitorTotal: number;
|
|
146
|
+
comparableQueries: number;
|
|
147
|
+
}>;
|
|
148
|
+
}
|
|
149
|
+
export declare function toSeedArray(seed?: Array<KeywordCampaignSeedInput | string>): KeywordCampaignSeed[];
|
|
150
|
+
export interface KeywordCampaignExtractionOptions {
|
|
151
|
+
maxKeywords?: number;
|
|
152
|
+
minKeywordLength?: number;
|
|
153
|
+
longTailTopAnchors?: number;
|
|
154
|
+
longTailModifierLimit?: number;
|
|
155
|
+
includeLongTail?: boolean;
|
|
156
|
+
longTailMaxPhrases?: number;
|
|
157
|
+
longTailMinWords?: number;
|
|
158
|
+
longTailMaxWords?: number;
|
|
159
|
+
includeLongTailSectionSignals?: boolean;
|
|
160
|
+
longTailSectionSourceBoost?: number;
|
|
161
|
+
includeSchemaSeeds?: boolean;
|
|
162
|
+
includeHeadingPathSeeds?: boolean;
|
|
163
|
+
}
|
|
164
|
+
export declare const DEFAULT_SERP_MIN_KEYWORD_LENGTH = 2;
|
|
165
|
+
export declare function tokenizeForLongTail(value: string): string[];
|