@detiq/crawler 1.1.7 → 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.
Files changed (92) hide show
  1. package/dist/accessibility-auditor.js +74 -54
  2. package/dist/ai-login.js +249 -227
  3. package/dist/auth-token-rotator.js +67 -57
  4. package/dist/auth.js +336 -299
  5. package/dist/browser-extension.js +142 -104
  6. package/dist/captcha-solver.js +125 -98
  7. package/dist/color-contrast.js +89 -77
  8. package/dist/content-chunker.js +126 -126
  9. package/dist/content-dedup.js +71 -54
  10. package/dist/cookie-consent.js +83 -68
  11. package/dist/cookie-jar.js +60 -53
  12. package/dist/crawler.js +5345 -4486
  13. package/dist/custom-js-injector.js +61 -45
  14. package/dist/dark-mode-capture.js +81 -67
  15. package/dist/dead-link-detector.js +55 -47
  16. package/dist/element-hash.js +12 -8
  17. package/dist/email-otp.js +195 -154
  18. package/dist/engine-router.js +98 -87
  19. package/dist/export/bulk-export.js +55 -70
  20. package/dist/export/vector-export.js +105 -77
  21. package/dist/extractors/advanced.d.ts +10 -0
  22. package/dist/extractors/advanced.js +266 -249
  23. package/dist/extractors/artifact-envelope.js +58 -59
  24. package/dist/failure-analysis-agent.js +33 -37
  25. package/dist/feature-flag-detector.js +66 -51
  26. package/dist/form-detector.js +75 -55
  27. package/dist/frontier.js +101 -76
  28. package/dist/gap-pass.js +89 -68
  29. package/dist/graphql-detector.js +72 -62
  30. package/dist/http-engine.js +330 -282
  31. package/dist/incremental-diff.js +87 -54
  32. package/dist/index.d.ts +2 -0
  33. package/dist/index.js +28 -63
  34. package/dist/index.js.map +2 -2
  35. package/dist/input-fuzzer.js +97 -93
  36. package/dist/interactive-probe.d.ts +36 -0
  37. package/dist/interactive-probe.js +827 -715
  38. package/dist/job-queue.js +2169 -2151
  39. package/dist/js-coverage.js +56 -52
  40. package/dist/js-router-detector.js +117 -86
  41. package/dist/language-detector.js +63 -51
  42. package/dist/link-classifier.js +50 -32
  43. package/dist/live-view.js +108 -91
  44. package/dist/locator-extractor.d.ts +37 -0
  45. package/dist/locator-extractor.js +199 -0
  46. package/dist/locator-extractor.js.map +7 -0
  47. package/dist/logger.js +7 -9
  48. package/dist/markdown-extract.js +61 -48
  49. package/dist/native-crawler.js +946 -780
  50. package/dist/network-observer.js +156 -135
  51. package/dist/network-throttle.js +40 -29
  52. package/dist/openapi-generator.js +92 -77
  53. package/dist/pdf-extractor.js +90 -72
  54. package/dist/performance-metrics.js +102 -80
  55. package/dist/phash.js +144 -125
  56. package/dist/pii-scrubber.js +68 -65
  57. package/dist/playwright-recorder.js +58 -70
  58. package/dist/policies/crawl-safety.js +34 -31
  59. package/dist/profiles/domain-profile.js +125 -130
  60. package/dist/proxy.js +172 -146
  61. package/dist/rate-limiter.js +65 -58
  62. package/dist/redirect-tracker.js +64 -60
  63. package/dist/redis-frontier.js +136 -116
  64. package/dist/redis-queue.js +144 -157
  65. package/dist/response-cache.js +140 -127
  66. package/dist/responsive-detector.js +46 -42
  67. package/dist/retry-policy.js +50 -46
  68. package/dist/robots-txt.js +83 -69
  69. package/dist/screen-reader.js +70 -45
  70. package/dist/screenshot-masker.js +77 -59
  71. package/dist/seo-checker.js +107 -88
  72. package/dist/session-capture.js +212 -192
  73. package/dist/session-export.js +133 -107
  74. package/dist/sitemap-writer.js +41 -38
  75. package/dist/sitemap.js +202 -141
  76. package/dist/skyvern.js +148 -123
  77. package/dist/sqs-queue.js +42 -42
  78. package/dist/sso-token.js +90 -74
  79. package/dist/stealth/human-behavior.js +173 -156
  80. package/dist/telemetry.js +82 -68
  81. package/dist/test-executor.js +335 -309
  82. package/dist/tls-fingerprint.js +88 -77
  83. package/dist/url-pattern-completer.js +90 -71
  84. package/dist/visual-diff-verdict.js +38 -23
  85. package/dist/webhook-notifier.js +69 -71
  86. package/dist/websocket-detector.js +68 -56
  87. package/dist/worker.js +38 -29
  88. package/package.json +1 -1
  89. package/src/index.ts +2 -0
  90. package/src/locator-extractor.ts +226 -0
  91. package/types/index.d.ts +2 -0
  92. package/types/locator-extractor.d.ts +37 -0
@@ -1,76 +1,61 @@
1
- import * as fs from "fs/promises";
2
- import * as path from "path";
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
- if (val.includes(",") || val.includes('"') || val.includes("\n")) {
5
- return `"${val.replace(/"/g, '""')}"`;
6
- }
7
- return val;
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
- 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");
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
- 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");
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
- 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
- `);
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
- import * as fs from "fs/promises";
2
- import * as path from "path";
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
- 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;
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
- 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)];
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
- 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 {
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
- } finally {
62
- await handle.close();
63
- }
64
- return { totalChunks, skipped };
88
+ finally {
89
+ await handle.close();
90
+ }
91
+ return { totalChunks, skipped };
65
92
  }
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
- }));
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
- 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
- }));
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
@@ -13,11 +13,21 @@ export interface PageMetadata {
13
13
  ogImage: string | null;
14
14
  ogUrl: string | null;
15
15
  ogType: string | null;
16
+ ogSiteName: string | null;
17
+ ogLocale: string | null;
16
18
  twitterCard: string | null;
17
19
  twitterTitle: string | null;
18
20
  twitterDescription: string | null;
21
+ twitterImage: string | null;
22
+ twitterSite: string | null;
19
23
  canonical: string | null;
20
24
  robots: string | null;
25
+ hreflang: Array<{
26
+ lang: string;
27
+ href: string;
28
+ }>;
29
+ themeColor: string | null;
30
+ favicon: string | null;
21
31
  jsonLd: object[];
22
32
  schemaTypes: string[];
23
33
  lang: string | null;