@detiq/crawler 1.1.8 → 1.1.9
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/accessibility-auditor.js +74 -54
- package/dist/ai-login.js +249 -227
- package/dist/auth-token-rotator.js +67 -57
- package/dist/auth.js +336 -299
- package/dist/browser-extension.js +142 -104
- package/dist/captcha-solver.js +125 -98
- package/dist/color-contrast.js +89 -77
- package/dist/content-chunker.js +126 -126
- package/dist/content-dedup.js +71 -54
- package/dist/cookie-consent.js +83 -68
- package/dist/cookie-jar.js +60 -53
- package/dist/crawler.js +5345 -4486
- package/dist/custom-js-injector.js +61 -45
- package/dist/dark-mode-capture.js +81 -67
- package/dist/dead-link-detector.js +55 -47
- package/dist/element-hash.js +12 -8
- package/dist/email-otp.js +195 -154
- package/dist/engine-router.js +98 -87
- package/dist/export/bulk-export.js +55 -70
- package/dist/export/vector-export.js +105 -77
- package/dist/extractors/advanced.js +266 -249
- package/dist/extractors/artifact-envelope.js +58 -59
- package/dist/failure-analysis-agent.js +33 -37
- package/dist/feature-flag-detector.js +66 -51
- package/dist/form-detector.js +75 -55
- package/dist/frontier.js +101 -76
- package/dist/gap-pass.js +89 -68
- package/dist/graphql-detector.js +72 -62
- package/dist/http-engine.js +330 -282
- package/dist/incremental-diff.js +87 -54
- package/dist/index.js +28 -67
- package/dist/input-fuzzer.js +97 -93
- package/dist/interactive-probe.js +827 -715
- package/dist/job-queue.js +2169 -2151
- package/dist/js-coverage.js +56 -52
- package/dist/js-router-detector.js +117 -86
- package/dist/language-detector.js +63 -51
- package/dist/link-classifier.js +50 -32
- package/dist/live-view.js +108 -91
- package/dist/locator-extractor.js +187 -151
- package/dist/logger.js +7 -9
- package/dist/markdown-extract.js +61 -48
- package/dist/native-crawler.js +946 -780
- package/dist/network-observer.js +156 -135
- package/dist/network-throttle.js +40 -29
- package/dist/openapi-generator.js +92 -77
- package/dist/pdf-extractor.js +90 -72
- package/dist/performance-metrics.js +102 -80
- package/dist/phash.js +144 -125
- package/dist/pii-scrubber.js +68 -65
- package/dist/playwright-recorder.js +58 -70
- package/dist/policies/crawl-safety.js +34 -31
- package/dist/profiles/domain-profile.js +125 -130
- package/dist/proxy.js +172 -146
- package/dist/rate-limiter.js +65 -58
- package/dist/redirect-tracker.js +64 -60
- package/dist/redis-frontier.js +136 -116
- package/dist/redis-queue.js +144 -157
- package/dist/response-cache.js +140 -127
- package/dist/responsive-detector.js +46 -42
- package/dist/retry-policy.js +50 -46
- package/dist/robots-txt.js +83 -69
- package/dist/screen-reader.js +70 -45
- package/dist/screenshot-masker.js +77 -59
- package/dist/seo-checker.js +107 -88
- package/dist/session-capture.js +212 -192
- package/dist/session-export.js +133 -107
- package/dist/sitemap-writer.js +41 -38
- package/dist/sitemap.js +202 -141
- package/dist/skyvern.js +148 -123
- package/dist/sqs-queue.js +42 -42
- package/dist/sso-token.js +90 -74
- package/dist/stealth/human-behavior.js +173 -156
- package/dist/telemetry.js +82 -68
- package/dist/test-executor.js +335 -309
- package/dist/tls-fingerprint.js +88 -77
- package/dist/url-pattern-completer.js +90 -71
- package/dist/visual-diff-verdict.js +38 -23
- package/dist/webhook-notifier.js +69 -71
- package/dist/websocket-detector.js +68 -56
- package/dist/worker.js +38 -29
- package/package.json +1 -1
|
@@ -1,76 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Bulk export — export crawled screens to CSV / JSON / Markdown digest.
|
|
3
|
+
*
|
|
4
|
+
* Outputs:
|
|
5
|
+
* - CSV: url, name, wordCount, screenshotPath, markdownPath, createdAt — for spreadsheet analysis
|
|
6
|
+
* - JSON: full screen records array — for API integration
|
|
7
|
+
* - Markdown digest: concatenated markdown of all screens — for LLM context windows
|
|
8
|
+
*/
|
|
9
|
+
import * as fs from 'fs/promises';
|
|
10
|
+
import * as path from 'path';
|
|
3
11
|
function escapeCsv(val) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
12
|
+
if (val.includes(',') || val.includes('"') || val.includes('\n')) {
|
|
13
|
+
return `"${val.replace(/"/g, '""')}"`;
|
|
14
|
+
}
|
|
15
|
+
return val;
|
|
8
16
|
}
|
|
9
|
-
async function exportToCsv(screens, outputPath) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
].map(escapeCsv).join(","));
|
|
21
|
-
await fs.mkdir(path.dirname(outputPath), { recursive: true });
|
|
22
|
-
await fs.writeFile(outputPath, [headers.join(","), ...rows].join("\n"), "utf8");
|
|
17
|
+
export async function exportToCsv(screens, outputPath) {
|
|
18
|
+
const headers = ['id', 'name', 'url', 'projectId', 'wordCount', 'screenshotPath', 'markdownPath', 'createdAt'];
|
|
19
|
+
const rows = screens.map(s => [
|
|
20
|
+
s.id, s.name, s.url, s.projectId,
|
|
21
|
+
String(s.wordCount ?? 0),
|
|
22
|
+
s.screenshotPath ?? '',
|
|
23
|
+
s.markdownPath ?? '',
|
|
24
|
+
s.createdAt?.toISOString() ?? '',
|
|
25
|
+
].map(escapeCsv).join(','));
|
|
26
|
+
await fs.mkdir(path.dirname(outputPath), { recursive: true });
|
|
27
|
+
await fs.writeFile(outputPath, [headers.join(','), ...rows].join('\n'), 'utf8');
|
|
23
28
|
}
|
|
24
|
-
async function exportToJson(screens, outputPath) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
export async function exportToJson(screens, outputPath) {
|
|
30
|
+
await fs.mkdir(path.dirname(outputPath), { recursive: true });
|
|
31
|
+
const data = screens.map(s => ({
|
|
32
|
+
id: s.id,
|
|
33
|
+
name: s.name,
|
|
34
|
+
url: s.url,
|
|
35
|
+
projectId: s.projectId,
|
|
36
|
+
wordCount: s.wordCount,
|
|
37
|
+
screenshotPath: s.screenshotPath,
|
|
38
|
+
markdownPath: s.markdownPath,
|
|
39
|
+
createdAt: s.createdAt?.toISOString(),
|
|
40
|
+
updatedAt: s.updatedAt?.toISOString(),
|
|
41
|
+
}));
|
|
42
|
+
await fs.writeFile(outputPath, JSON.stringify(data, null, 2), 'utf8');
|
|
38
43
|
}
|
|
39
|
-
async function exportToMarkdownDigest(screens, outputPath, opts = {}) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
md = await fs.readFile(screen.markdownPath, "utf8").catch(() => "");
|
|
56
|
-
}
|
|
57
|
-
await handle.write(`## ${screen.name}
|
|
58
|
-
|
|
59
|
-
**URL:** ${screen.url}
|
|
60
|
-
|
|
61
|
-
${md.trim()}
|
|
62
|
-
|
|
63
|
-
---
|
|
64
|
-
|
|
65
|
-
`);
|
|
44
|
+
export async function exportToMarkdownDigest(screens, outputPath, opts = {}) {
|
|
45
|
+
const { readMarkdownFromPath = true, maxScreens = 200 } = opts;
|
|
46
|
+
await fs.mkdir(path.dirname(outputPath), { recursive: true });
|
|
47
|
+
const handle = await fs.open(outputPath, 'w');
|
|
48
|
+
try {
|
|
49
|
+
await handle.write(`# ZeTa Crawl Digest\n\nExported: ${new Date().toISOString()}\nScreens: ${Math.min(screens.length, maxScreens)}\n\n---\n\n`);
|
|
50
|
+
for (const screen of screens.slice(0, maxScreens)) {
|
|
51
|
+
let md = screen.markdown ?? '';
|
|
52
|
+
if (!md && readMarkdownFromPath && screen.markdownPath) {
|
|
53
|
+
md = await fs.readFile(screen.markdownPath, 'utf8').catch(() => '');
|
|
54
|
+
}
|
|
55
|
+
await handle.write(`## ${screen.name}\n\n**URL:** ${screen.url}\n\n${md.trim()}\n\n---\n\n`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
await handle.close();
|
|
66
60
|
}
|
|
67
|
-
} finally {
|
|
68
|
-
await handle.close();
|
|
69
|
-
}
|
|
70
61
|
}
|
|
71
|
-
export {
|
|
72
|
-
exportToCsv,
|
|
73
|
-
exportToJson,
|
|
74
|
-
exportToMarkdownDigest
|
|
75
|
-
};
|
|
76
|
-
//# sourceMappingURL=bulk-export.js.map
|
|
@@ -1,85 +1,113 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Vector DB export — convert crawled screens to embedding-ready chunks.
|
|
3
|
+
*
|
|
4
|
+
* Produces a JSONL file where each line is one chunk ready for upsert into
|
|
5
|
+
* Pinecone, Qdrant, Weaviate, or any vector store. The embedding itself is
|
|
6
|
+
* NOT generated here (requires an embedding model at the user's end) — we
|
|
7
|
+
* produce the text chunks + metadata, and the caller embeds them.
|
|
8
|
+
*
|
|
9
|
+
* Format per line (JSONL):
|
|
10
|
+
* {
|
|
11
|
+
* "id": "<screenId>-<chunkIndex>",
|
|
12
|
+
* "text": "<chunk text>",
|
|
13
|
+
* "metadata": {
|
|
14
|
+
* "screenId": "...",
|
|
15
|
+
* "projectId": "...",
|
|
16
|
+
* "tenantId": "...",
|
|
17
|
+
* "url": "...",
|
|
18
|
+
* "screenName": "...",
|
|
19
|
+
* "chunkIndex": 0,
|
|
20
|
+
* "totalChunks": 3,
|
|
21
|
+
* "crawledAt": "2026-...",
|
|
22
|
+
* "wordCount": 142
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
*/
|
|
26
|
+
import * as fs from 'fs/promises';
|
|
27
|
+
import * as path from 'path';
|
|
3
28
|
function splitIntoChunks(text, maxChunkWords = 300) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
29
|
+
const paragraphs = text.split(/\n{2,}/).filter(p => p.trim().length > 0);
|
|
30
|
+
const chunks = [];
|
|
31
|
+
let current = '';
|
|
32
|
+
let wordCount = 0;
|
|
33
|
+
for (const para of paragraphs) {
|
|
34
|
+
const words = para.split(/\s+/).length;
|
|
35
|
+
if (wordCount + words > maxChunkWords && current.length > 0) {
|
|
36
|
+
chunks.push(current.trim());
|
|
37
|
+
current = '';
|
|
38
|
+
wordCount = 0;
|
|
39
|
+
}
|
|
40
|
+
current += (current ? '\n\n' : '') + para;
|
|
41
|
+
wordCount += words;
|
|
14
42
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (current.trim()) chunks.push(current.trim());
|
|
19
|
-
return chunks.length > 0 ? chunks : [text.slice(0, 2e3)];
|
|
43
|
+
if (current.trim())
|
|
44
|
+
chunks.push(current.trim());
|
|
45
|
+
return chunks.length > 0 ? chunks : [text.slice(0, 2000)];
|
|
20
46
|
}
|
|
21
|
-
async function exportScreensToVectorJsonl(screens, outputPath, opts = {}) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
47
|
+
export async function exportScreensToVectorJsonl(screens, outputPath, opts = {}) {
|
|
48
|
+
const { maxChunkWords = 300, readMarkdownFromPath = true } = opts;
|
|
49
|
+
await fs.mkdir(path.dirname(outputPath), { recursive: true });
|
|
50
|
+
const handle = await fs.open(outputPath, 'w');
|
|
51
|
+
let totalChunks = 0;
|
|
52
|
+
let skipped = 0;
|
|
53
|
+
try {
|
|
54
|
+
for (const screen of screens) {
|
|
55
|
+
let markdown = screen.markdown ?? '';
|
|
56
|
+
if (!markdown && readMarkdownFromPath && screen.markdownPath) {
|
|
57
|
+
try {
|
|
58
|
+
markdown = await fs.readFile(screen.markdownPath, 'utf8');
|
|
59
|
+
}
|
|
60
|
+
catch { /* file missing — skip */ }
|
|
61
|
+
}
|
|
62
|
+
if (!markdown || markdown.trim().length < 20) {
|
|
63
|
+
skipped++;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const textChunks = splitIntoChunks(markdown, maxChunkWords);
|
|
67
|
+
for (let i = 0; i < textChunks.length; i++) {
|
|
68
|
+
const chunk = {
|
|
69
|
+
id: `${screen.id}-${i}`,
|
|
70
|
+
text: textChunks[i],
|
|
71
|
+
metadata: {
|
|
72
|
+
screenId: screen.id,
|
|
73
|
+
projectId: screen.projectId,
|
|
74
|
+
tenantId: screen.tenantId,
|
|
75
|
+
url: screen.url,
|
|
76
|
+
screenName: screen.name,
|
|
77
|
+
chunkIndex: i,
|
|
78
|
+
totalChunks: textChunks.length,
|
|
79
|
+
crawledAt: screen.updatedAt?.toISOString() ?? new Date().toISOString(),
|
|
80
|
+
wordCount: textChunks[i].split(/\s+/).length,
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
await handle.write(JSON.stringify(chunk) + '\n');
|
|
84
|
+
totalChunks++;
|
|
85
|
+
}
|
|
34
86
|
}
|
|
35
|
-
}
|
|
36
|
-
if (!markdown || markdown.trim().length < 20) {
|
|
37
|
-
skipped++;
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
const textChunks = splitIntoChunks(markdown, maxChunkWords);
|
|
41
|
-
for (let i = 0; i < textChunks.length; i++) {
|
|
42
|
-
const chunk = {
|
|
43
|
-
id: `${screen.id}-${i}`,
|
|
44
|
-
text: textChunks[i],
|
|
45
|
-
metadata: {
|
|
46
|
-
screenId: screen.id,
|
|
47
|
-
projectId: screen.projectId,
|
|
48
|
-
tenantId: screen.tenantId,
|
|
49
|
-
url: screen.url,
|
|
50
|
-
screenName: screen.name,
|
|
51
|
-
chunkIndex: i,
|
|
52
|
-
totalChunks: textChunks.length,
|
|
53
|
-
crawledAt: screen.updatedAt?.toISOString() ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
54
|
-
wordCount: textChunks[i].split(/\s+/).length
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
await handle.write(JSON.stringify(chunk) + "\n");
|
|
58
|
-
totalChunks++;
|
|
59
|
-
}
|
|
60
87
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
88
|
+
finally {
|
|
89
|
+
await handle.close();
|
|
90
|
+
}
|
|
91
|
+
return { totalChunks, skipped };
|
|
65
92
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
93
|
+
/**
|
|
94
|
+
* Pinecone-compatible upsert batch format.
|
|
95
|
+
* Call this after generating embeddings to produce the final upsert payload.
|
|
96
|
+
*/
|
|
97
|
+
export function toPineconeUpsert(chunks, embeddings, namespace = 'zeta-crawl') {
|
|
98
|
+
return chunks.map((chunk, i) => ({
|
|
99
|
+
id: chunk.id,
|
|
100
|
+
values: embeddings[i],
|
|
101
|
+
metadata: chunk.metadata,
|
|
102
|
+
}));
|
|
72
103
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Qdrant-compatible point format.
|
|
106
|
+
*/
|
|
107
|
+
export function toQdrantPoints(chunks, embeddings) {
|
|
108
|
+
return chunks.map((chunk, i) => ({
|
|
109
|
+
id: chunk.id,
|
|
110
|
+
vector: embeddings[i],
|
|
111
|
+
payload: { ...chunk.metadata, text: chunk.text },
|
|
112
|
+
}));
|
|
79
113
|
}
|
|
80
|
-
export {
|
|
81
|
-
exportScreensToVectorJsonl,
|
|
82
|
-
toPineconeUpsert,
|
|
83
|
-
toQdrantPoints
|
|
84
|
-
};
|
|
85
|
-
//# sourceMappingURL=vector-export.js.map
|