@detiq/crawler 1.1.9 → 1.1.11

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 (83) hide show
  1. package/dist/accessibility-auditor.js +54 -74
  2. package/dist/ai-login.js +227 -249
  3. package/dist/auth-token-rotator.js +57 -67
  4. package/dist/auth.js +299 -336
  5. package/dist/browser-extension.js +104 -142
  6. package/dist/captcha-solver.js +98 -125
  7. package/dist/color-contrast.js +77 -89
  8. package/dist/content-chunker.js +126 -126
  9. package/dist/content-dedup.js +54 -71
  10. package/dist/cookie-consent.js +68 -83
  11. package/dist/cookie-jar.js +53 -60
  12. package/dist/crawler.js +4494 -5353
  13. package/dist/custom-js-injector.js +45 -61
  14. package/dist/dark-mode-capture.js +67 -81
  15. package/dist/dead-link-detector.js +47 -55
  16. package/dist/element-hash.js +8 -12
  17. package/dist/email-otp.js +154 -195
  18. package/dist/engine-router.js +87 -98
  19. package/dist/export/bulk-export.js +70 -55
  20. package/dist/export/vector-export.js +77 -105
  21. package/dist/extractors/advanced.js +249 -266
  22. package/dist/extractors/artifact-envelope.js +59 -58
  23. package/dist/failure-analysis-agent.js +37 -33
  24. package/dist/feature-flag-detector.js +51 -66
  25. package/dist/form-detector.js +55 -75
  26. package/dist/frontier.js +76 -101
  27. package/dist/gap-pass.js +68 -89
  28. package/dist/graphql-detector.js +62 -72
  29. package/dist/http-engine.js +282 -330
  30. package/dist/incremental-diff.js +54 -87
  31. package/dist/index.js +67 -28
  32. package/dist/input-fuzzer.js +93 -97
  33. package/dist/interactive-probe.js +715 -827
  34. package/dist/job-queue.js +2151 -2169
  35. package/dist/js-coverage.js +52 -56
  36. package/dist/js-router-detector.js +86 -117
  37. package/dist/language-detector.js +51 -63
  38. package/dist/link-classifier.js +32 -50
  39. package/dist/live-view.js +91 -108
  40. package/dist/locator-extractor.js +151 -187
  41. package/dist/logger.js +9 -7
  42. package/dist/markdown-extract.js +48 -61
  43. package/dist/native-crawler.js +780 -946
  44. package/dist/network-observer.js +135 -156
  45. package/dist/network-throttle.js +29 -40
  46. package/dist/openapi-generator.js +77 -92
  47. package/dist/pdf-extractor.js +72 -90
  48. package/dist/performance-metrics.js +80 -102
  49. package/dist/phash.js +125 -144
  50. package/dist/pii-scrubber.js +65 -68
  51. package/dist/playwright-recorder.js +70 -58
  52. package/dist/policies/crawl-safety.js +31 -34
  53. package/dist/profiles/domain-profile.js +130 -125
  54. package/dist/proxy.js +146 -172
  55. package/dist/rate-limiter.js +58 -65
  56. package/dist/redirect-tracker.js +60 -64
  57. package/dist/redis-frontier.js +116 -136
  58. package/dist/redis-queue.js +157 -144
  59. package/dist/response-cache.js +127 -140
  60. package/dist/responsive-detector.js +42 -46
  61. package/dist/retry-policy.js +46 -50
  62. package/dist/robots-txt.js +69 -83
  63. package/dist/screen-reader.js +45 -70
  64. package/dist/screenshot-masker.js +59 -77
  65. package/dist/seo-checker.js +88 -107
  66. package/dist/session-capture.js +192 -212
  67. package/dist/session-export.js +107 -133
  68. package/dist/sitemap-writer.js +38 -41
  69. package/dist/sitemap.js +141 -202
  70. package/dist/skyvern.js +123 -148
  71. package/dist/sqs-queue.js +42 -42
  72. package/dist/sso-token.js +74 -90
  73. package/dist/stealth/human-behavior.js +156 -173
  74. package/dist/telemetry.js +68 -82
  75. package/dist/test-executor.js +309 -335
  76. package/dist/tls-fingerprint.js +77 -88
  77. package/dist/url-pattern-completer.js +71 -90
  78. package/dist/visual-diff-verdict.js +23 -38
  79. package/dist/webhook-notifier.js +71 -69
  80. package/dist/websocket-detector.js +56 -68
  81. package/dist/worker.js +29 -38
  82. package/package.json +1 -1
  83. package/src/job-queue.ts +136 -0
@@ -1,61 +1,76 @@
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';
1
+ import * as fs from "fs/promises";
2
+ import * as path from "path";
11
3
  function escapeCsv(val) {
12
- if (val.includes(',') || val.includes('"') || val.includes('\n')) {
13
- return `"${val.replace(/"/g, '""')}"`;
14
- }
15
- return val;
4
+ if (val.includes(",") || val.includes('"') || val.includes("\n")) {
5
+ return `"${val.replace(/"/g, '""')}"`;
6
+ }
7
+ return val;
16
8
  }
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');
9
+ async function exportToCsv(screens, outputPath) {
10
+ const headers = ["id", "name", "url", "projectId", "wordCount", "screenshotPath", "markdownPath", "createdAt"];
11
+ const rows = screens.map((s) => [
12
+ s.id,
13
+ s.name,
14
+ s.url,
15
+ s.projectId,
16
+ String(s.wordCount ?? 0),
17
+ s.screenshotPath ?? "",
18
+ s.markdownPath ?? "",
19
+ s.createdAt?.toISOString() ?? ""
20
+ ].map(escapeCsv).join(","));
21
+ await fs.mkdir(path.dirname(outputPath), { recursive: true });
22
+ await fs.writeFile(outputPath, [headers.join(","), ...rows].join("\n"), "utf8");
28
23
  }
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');
24
+ async function exportToJson(screens, outputPath) {
25
+ await fs.mkdir(path.dirname(outputPath), { recursive: true });
26
+ const data = screens.map((s) => ({
27
+ id: s.id,
28
+ name: s.name,
29
+ url: s.url,
30
+ projectId: s.projectId,
31
+ wordCount: s.wordCount,
32
+ screenshotPath: s.screenshotPath,
33
+ markdownPath: s.markdownPath,
34
+ createdAt: s.createdAt?.toISOString(),
35
+ updatedAt: s.updatedAt?.toISOString()
36
+ }));
37
+ await fs.writeFile(outputPath, JSON.stringify(data, null, 2), "utf8");
43
38
  }
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();
39
+ async function exportToMarkdownDigest(screens, outputPath, opts = {}) {
40
+ const { readMarkdownFromPath = true, maxScreens = 200 } = opts;
41
+ await fs.mkdir(path.dirname(outputPath), { recursive: true });
42
+ const handle = await fs.open(outputPath, "w");
43
+ try {
44
+ await handle.write(`# ZeTa Crawl Digest
45
+
46
+ Exported: ${(/* @__PURE__ */ new Date()).toISOString()}
47
+ Screens: ${Math.min(screens.length, maxScreens)}
48
+
49
+ ---
50
+
51
+ `);
52
+ for (const screen of screens.slice(0, maxScreens)) {
53
+ let md = screen.markdown ?? "";
54
+ if (!md && readMarkdownFromPath && screen.markdownPath) {
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
+ `);
60
66
  }
67
+ } finally {
68
+ await handle.close();
69
+ }
61
70
  }
71
+ export {
72
+ exportToCsv,
73
+ exportToJson,
74
+ exportToMarkdownDigest
75
+ };
76
+ //# sourceMappingURL=bulk-export.js.map
@@ -1,113 +1,85 @@
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';
1
+ import * as fs from "fs/promises";
2
+ import * as path from "path";
28
3
  function splitIntoChunks(text, maxChunkWords = 300) {
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;
4
+ const paragraphs = text.split(/\n{2,}/).filter((p) => p.trim().length > 0);
5
+ const chunks = [];
6
+ let current = "";
7
+ let wordCount = 0;
8
+ for (const para of paragraphs) {
9
+ const words = para.split(/\s+/).length;
10
+ if (wordCount + words > maxChunkWords && current.length > 0) {
11
+ chunks.push(current.trim());
12
+ current = "";
13
+ wordCount = 0;
42
14
  }
43
- if (current.trim())
44
- chunks.push(current.trim());
45
- return chunks.length > 0 ? chunks : [text.slice(0, 2000)];
15
+ current += (current ? "\n\n" : "") + para;
16
+ wordCount += words;
17
+ }
18
+ if (current.trim()) chunks.push(current.trim());
19
+ return chunks.length > 0 ? chunks : [text.slice(0, 2e3)];
46
20
  }
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
- }
21
+ async function exportScreensToVectorJsonl(screens, outputPath, opts = {}) {
22
+ const { maxChunkWords = 300, readMarkdownFromPath = true } = opts;
23
+ await fs.mkdir(path.dirname(outputPath), { recursive: true });
24
+ const handle = await fs.open(outputPath, "w");
25
+ let totalChunks = 0;
26
+ let skipped = 0;
27
+ try {
28
+ for (const screen of screens) {
29
+ let markdown = screen.markdown ?? "";
30
+ if (!markdown && readMarkdownFromPath && screen.markdownPath) {
31
+ try {
32
+ markdown = await fs.readFile(screen.markdownPath, "utf8");
33
+ } catch {
86
34
  }
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
+ }
87
60
  }
88
- finally {
89
- await handle.close();
90
- }
91
- return { totalChunks, skipped };
61
+ } finally {
62
+ await handle.close();
63
+ }
64
+ return { totalChunks, skipped };
92
65
  }
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
- }));
66
+ function toPineconeUpsert(chunks, embeddings, namespace = "zeta-crawl") {
67
+ return chunks.map((chunk, i) => ({
68
+ id: chunk.id,
69
+ values: embeddings[i],
70
+ metadata: chunk.metadata
71
+ }));
103
72
  }
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
- }));
73
+ function toQdrantPoints(chunks, embeddings) {
74
+ return chunks.map((chunk, i) => ({
75
+ id: chunk.id,
76
+ vector: embeddings[i],
77
+ payload: { ...chunk.metadata, text: chunk.text }
78
+ }));
113
79
  }
80
+ export {
81
+ exportScreensToVectorJsonl,
82
+ toPineconeUpsert,
83
+ toQdrantPoints
84
+ };
85
+ //# sourceMappingURL=vector-export.js.map