@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,94 +1,61 @@
1
- /**
2
- * Incremental crawl diff — compute stable content hashes and skip unchanged screens.
3
- *
4
- * Each crawled page gets a content fingerprint (murmurhash-free, pure JS).
5
- * On the next crawl of the same project, pages with the same fingerprint are
6
- * marked SKIPPED instead of re-processed, drastically reducing crawl time and
7
- * LLM token spend for sites with mostly-static content.
8
- *
9
- * Design: "same content hash" means the meaningful text hasn't changed.
10
- * Layout/CSS/JS changes that don't affect visible text are ignored intentionally.
11
- */
12
- /**
13
- * Compute a stable 64-bit-ish hash from text content.
14
- * djb2 variant — fast, no deps, collision-resistant enough for content fingerprinting.
15
- */
16
- export function hashContent(text) {
17
- let h1 = 5381;
18
- let h2 = 52711;
19
- for (let i = 0; i < text.length; i++) {
20
- const c = text.charCodeAt(i);
21
- h1 = (Math.imul(h1, 33) ^ c) >>> 0;
22
- h2 = (Math.imul(h2, 31) ^ c) >>> 0;
23
- }
24
- return (h1 >>> 0).toString(16).padStart(8, '0') + (h2 >>> 0).toString(16).padStart(8, '0');
1
+ function hashContent(text) {
2
+ let h1 = 5381;
3
+ let h2 = 52711;
4
+ for (let i = 0; i < text.length; i++) {
5
+ const c = text.charCodeAt(i);
6
+ h1 = (Math.imul(h1, 33) ^ c) >>> 0;
7
+ h2 = (Math.imul(h2, 31) ^ c) >>> 0;
8
+ }
9
+ return (h1 >>> 0).toString(16).padStart(8, "0") + (h2 >>> 0).toString(16).padStart(8, "0");
25
10
  }
26
- /**
27
- * Normalize text before hashing — strips whitespace-only lines, trims each line,
28
- * collapses runs of blank lines. Makes hash stable across minor formatting changes.
29
- */
30
- export function normalizeText(text) {
31
- return text
32
- .split('\n')
33
- .map(l => l.trim())
34
- .filter(l => l.length > 0)
35
- .join('\n');
11
+ function normalizeText(text) {
12
+ return text.split("\n").map((l) => l.trim()).filter((l) => l.length > 0).join("\n");
36
13
  }
37
- export function computeContentHash(url, markdownText) {
38
- const normalized = normalizeText(markdownText);
39
- return {
40
- url,
41
- hash: hashContent(normalized),
42
- textLength: normalized.length,
43
- computedAt: new Date().toISOString(),
44
- };
14
+ function computeContentHash(url, markdownText) {
15
+ const normalized = normalizeText(markdownText);
16
+ return {
17
+ url,
18
+ hash: hashContent(normalized),
19
+ textLength: normalized.length,
20
+ computedAt: (/* @__PURE__ */ new Date()).toISOString()
21
+ };
45
22
  }
46
- /**
47
- * Compare a page's current content against prior hashes.
48
- * Returns { changed: false } for unchanged pages — caller should skip re-processing.
49
- */
50
- export function diffContent(url, currentMarkdown, priorHashes) {
51
- const current = computeContentHash(url, currentMarkdown);
52
- const prior = priorHashes.get(url);
53
- if (!prior) {
54
- return { url, changed: true, currentHash: current.hash, reason: 'new' };
55
- }
56
- if (prior === current.hash) {
57
- return { url, changed: false, previousHash: prior, currentHash: current.hash, reason: 'unchanged' };
58
- }
59
- return { url, changed: true, previousHash: prior, currentHash: current.hash, reason: 'changed' };
23
+ function diffContent(url, currentMarkdown, priorHashes) {
24
+ const current = computeContentHash(url, currentMarkdown);
25
+ const prior = priorHashes.get(url);
26
+ if (!prior) {
27
+ return { url, changed: true, currentHash: current.hash, reason: "new" };
28
+ }
29
+ if (prior === current.hash) {
30
+ return { url, changed: false, previousHash: prior, currentHash: current.hash, reason: "unchanged" };
31
+ }
32
+ return { url, changed: true, previousHash: prior, currentHash: current.hash, reason: "changed" };
60
33
  }
61
- /**
62
- * Build a hash map from prior screen records (from DB query result).
63
- * screenRecords: Array<{ url: string; elementHash?: string | null }>
64
- */
65
- export function buildPriorHashMap(screenRecords) {
66
- const map = new Map();
67
- for (const s of screenRecords) {
68
- if (s.url && s.elementHash)
69
- map.set(s.url, s.elementHash);
70
- }
71
- return map;
34
+ function buildPriorHashMap(screenRecords) {
35
+ const map = /* @__PURE__ */ new Map();
36
+ for (const s of screenRecords) {
37
+ if (s.url && s.elementHash) map.set(s.url, s.elementHash);
38
+ }
39
+ return map;
72
40
  }
73
- /**
74
- * Filter a batch of discovered URLs against prior hashes.
75
- * Returns { toProcess, toSkip } — caller enqueues toProcess, logs toSkip count.
76
- *
77
- * Note: filtering at URL level only works if the prior crawl already visited the URL.
78
- * For new URLs, they're always in toProcess.
79
- */
80
- export function partitionByChange(urls, priorHashes) {
81
- const toProcess = [];
82
- const toSkip = [];
83
- for (const url of urls) {
84
- if (priorHashes.has(url)) {
85
- // Can't know if changed without fetching — still needs fetch, but hash after fetch
86
- // will determine skip. Include all — hash check happens post-fetch.
87
- toProcess.push(url);
88
- }
89
- else {
90
- toProcess.push(url);
91
- }
41
+ function partitionByChange(urls, priorHashes) {
42
+ const toProcess = [];
43
+ const toSkip = [];
44
+ for (const url of urls) {
45
+ if (priorHashes.has(url)) {
46
+ toProcess.push(url);
47
+ } else {
48
+ toProcess.push(url);
92
49
  }
93
- return { toProcess, toSkip };
50
+ }
51
+ return { toProcess, toSkip };
94
52
  }
53
+ export {
54
+ buildPriorHashMap,
55
+ computeContentHash,
56
+ diffContent,
57
+ hashContent,
58
+ normalizeText,
59
+ partitionByChange
60
+ };
61
+ //# sourceMappingURL=incremental-diff.js.map
package/dist/index.js CHANGED
@@ -1,28 +1,67 @@
1
- export * from './crawler.js';
2
- export * from './visual-diff-verdict.js';
3
- export * from './auth.js';
4
- export * from './screen-reader.js';
5
- export * from './job-queue.js';
6
- export { startSqsWorker } from './sqs-queue.js';
7
- export * from './session-capture.js';
8
- export * from './session-export.js';
9
- export * from './test-executor.js';
10
- export { startLiveView, getFrame, liveViewNavigate, completeLiveView, closeLiveView, sendInput } from './live-view.js';
11
- export { waitForEmailOTP, getInboxEmail } from './email-otp.js';
12
- export { getSsoToken, getSsoClientCredentialsToken } from './sso-token.js';
13
- export * from './engine-router.js';
14
- export * from './profiles/domain-profile.js';
15
- export * from './policies/crawl-safety.js';
16
- export * from './extractors/artifact-envelope.js';
17
- export * from './network-observer.js';
18
- export { createChromeTlsAgent, probeTlsFingerprint, chromeTlsAgent, CHROME_TLS_HEADERS } from './tls-fingerprint.js';
19
- export { prepareExtensionProfile, adBlockerProfile } from './browser-extension.js';
20
- export { createRedisQueue, maybeCreateRedisQueue, isRedisQueueEnabled } from './redis-queue.js';
21
- export { discoverProjectUrls, discoverSitemapUrls } from './sitemap.js';
22
- export { httpCrawl } from './http-engine.js';
23
- export { extractMarkdown } from './markdown-extract.js';
24
- export { TieredProxyManager } from './proxy.js';
25
- export { RedisCrawlFrontier, isRedisFrontierEnabled } from './redis-frontier.js';
26
- export { startSpan, endSpan, withSpan, increment, flushMetrics } from './telemetry.js';
27
- export { analyzeFailure } from './failure-analysis-agent.js';
28
- export { elementToPlaywrightLocator, elementsToPlaywrightLocators, formatLocatorsForPrompt } from './locator-extractor.js';
1
+ export * from "./crawler.js";
2
+ export * from "./visual-diff-verdict.js";
3
+ export * from "./auth.js";
4
+ export * from "./screen-reader.js";
5
+ export * from "./job-queue.js";
6
+ import { startSqsWorker } from "./sqs-queue.js";
7
+ export * from "./session-capture.js";
8
+ export * from "./session-export.js";
9
+ export * from "./test-executor.js";
10
+ import { startLiveView, getFrame, liveViewNavigate, completeLiveView, closeLiveView, sendInput } from "./live-view.js";
11
+ import { waitForEmailOTP, getInboxEmail } from "./email-otp.js";
12
+ import { getSsoToken, getSsoClientCredentialsToken } from "./sso-token.js";
13
+ export * from "./engine-router.js";
14
+ export * from "./profiles/domain-profile.js";
15
+ export * from "./policies/crawl-safety.js";
16
+ export * from "./extractors/artifact-envelope.js";
17
+ export * from "./network-observer.js";
18
+ import { createChromeTlsAgent, probeTlsFingerprint, chromeTlsAgent, CHROME_TLS_HEADERS } from "./tls-fingerprint.js";
19
+ import { prepareExtensionProfile, adBlockerProfile } from "./browser-extension.js";
20
+ import { createRedisQueue, maybeCreateRedisQueue, isRedisQueueEnabled } from "./redis-queue.js";
21
+ import { discoverProjectUrls, discoverSitemapUrls } from "./sitemap.js";
22
+ import { httpCrawl } from "./http-engine.js";
23
+ import { extractMarkdown } from "./markdown-extract.js";
24
+ import { TieredProxyManager } from "./proxy.js";
25
+ import { RedisCrawlFrontier, isRedisFrontierEnabled } from "./redis-frontier.js";
26
+ import { startSpan, endSpan, withSpan, increment, flushMetrics } from "./telemetry.js";
27
+ import { analyzeFailure } from "./failure-analysis-agent.js";
28
+ import { elementToPlaywrightLocator, elementsToPlaywrightLocators, formatLocatorsForPrompt } from "./locator-extractor.js";
29
+ export {
30
+ CHROME_TLS_HEADERS,
31
+ RedisCrawlFrontier,
32
+ TieredProxyManager,
33
+ adBlockerProfile,
34
+ analyzeFailure,
35
+ chromeTlsAgent,
36
+ closeLiveView,
37
+ completeLiveView,
38
+ createChromeTlsAgent,
39
+ createRedisQueue,
40
+ discoverProjectUrls,
41
+ discoverSitemapUrls,
42
+ elementToPlaywrightLocator,
43
+ elementsToPlaywrightLocators,
44
+ endSpan,
45
+ extractMarkdown,
46
+ flushMetrics,
47
+ formatLocatorsForPrompt,
48
+ getFrame,
49
+ getInboxEmail,
50
+ getSsoClientCredentialsToken,
51
+ getSsoToken,
52
+ httpCrawl,
53
+ increment,
54
+ isRedisFrontierEnabled,
55
+ isRedisQueueEnabled,
56
+ liveViewNavigate,
57
+ maybeCreateRedisQueue,
58
+ prepareExtensionProfile,
59
+ probeTlsFingerprint,
60
+ sendInput,
61
+ startLiveView,
62
+ startSpan,
63
+ startSqsWorker,
64
+ waitForEmailOTP,
65
+ withSpan
66
+ };
67
+ //# sourceMappingURL=index.js.map
@@ -1,109 +1,105 @@
1
- /**
2
- * Input fuzzer — generate test data for form fields.
3
- *
4
- * For each field type, produces a set of test values covering:
5
- * - Happy path (valid, normal input)
6
- * - Boundary (min/max length, min/max value)
7
- * - Edge cases (empty, very long, special chars, SQL injection probe, XSS probe)
8
- * - Type-invalid (wrong type for the field)
9
- *
10
- * This feeds ZeTa's test generator to automatically create form validation tests.
11
- * Values are safe probes (NOT actual exploits) — they test whether the app
12
- * properly rejects/accepts boundary inputs.
13
- */
14
- const LOREM = 'Lorem ipsum dolor sit amet consectetur adipiscing elit';
1
+ const LOREM = "Lorem ipsum dolor sit amet consectetur adipiscing elit";
15
2
  function generateEmailCases() {
16
- return [
17
- { label: 'valid email', value: 'test@example.com', expectedValid: true, category: 'happy' },
18
- { label: 'email with plus', value: 'test+tag@example.com', expectedValid: true, category: 'happy' },
19
- { label: 'missing @', value: 'notanemail.com', expectedValid: false, category: 'invalid' },
20
- { label: 'missing domain', value: 'test@', expectedValid: false, category: 'invalid' },
21
- { label: 'empty', value: '', expectedValid: false, category: 'edge' },
22
- { label: 'very long email', value: 'a'.repeat(100) + '@example.com', expectedValid: false, category: 'boundary' },
23
- { label: 'special chars', value: 'test<script>@example.com', expectedValid: false, category: 'edge' },
24
- ];
3
+ return [
4
+ { label: "valid email", value: "test@example.com", expectedValid: true, category: "happy" },
5
+ { label: "email with plus", value: "test+tag@example.com", expectedValid: true, category: "happy" },
6
+ { label: "missing @", value: "notanemail.com", expectedValid: false, category: "invalid" },
7
+ { label: "missing domain", value: "test@", expectedValid: false, category: "invalid" },
8
+ { label: "empty", value: "", expectedValid: false, category: "edge" },
9
+ { label: "very long email", value: "a".repeat(100) + "@example.com", expectedValid: false, category: "boundary" },
10
+ { label: "special chars", value: "test<script>@example.com", expectedValid: false, category: "edge" }
11
+ ];
25
12
  }
26
13
  function generatePasswordCases(minLength, maxLength) {
27
- const min = minLength ?? 8;
28
- const max = maxLength ?? 128;
29
- return [
30
- { label: 'valid password', value: 'ValidP@ss1', expectedValid: true, category: 'happy' },
31
- { label: 'minimum length', value: 'A'.repeat(min), expectedValid: true, category: 'boundary' },
32
- { label: 'below minimum', value: 'A'.repeat(Math.max(1, min - 1)), expectedValid: false, category: 'boundary' },
33
- { label: 'max length', value: 'Aa1!'.repeat(Math.ceil(max / 4)).slice(0, max), expectedValid: true, category: 'boundary' },
34
- { label: 'empty', value: '', expectedValid: false, category: 'edge' },
35
- { label: 'spaces only', value: ' ', expectedValid: false, category: 'edge' },
36
- ];
14
+ const min = minLength ?? 8;
15
+ const max = maxLength ?? 128;
16
+ return [
17
+ { label: "valid password", value: "ValidP@ss1", expectedValid: true, category: "happy" },
18
+ { label: "minimum length", value: "A".repeat(min), expectedValid: true, category: "boundary" },
19
+ { label: "below minimum", value: "A".repeat(Math.max(1, min - 1)), expectedValid: false, category: "boundary" },
20
+ { label: "max length", value: "Aa1!".repeat(Math.ceil(max / 4)).slice(0, max), expectedValid: true, category: "boundary" },
21
+ { label: "empty", value: "", expectedValid: false, category: "edge" },
22
+ { label: "spaces only", value: " ", expectedValid: false, category: "edge" }
23
+ ];
37
24
  }
38
25
  function generateTextCases(minLength, maxLength, required) {
39
- const cases = [
40
- { label: 'typical text', value: 'Test Input Value', expectedValid: true, category: 'happy' },
41
- { label: 'single char', value: 'A', expectedValid: !minLength || minLength <= 1, category: 'boundary' },
42
- { label: 'empty', value: '', expectedValid: !required, category: 'edge' },
43
- { label: 'spaces only', value: ' ', expectedValid: !required, category: 'edge' },
44
- { label: 'very long text', value: LOREM.repeat(20), expectedValid: !maxLength || maxLength > LOREM.length * 20, category: 'boundary' },
45
- { label: 'unicode', value: '日本語テスト Ünïcödé Emojitest 🎉', expectedValid: true, category: 'edge' },
46
- { label: 'HTML special chars', value: '<script>alert(1)</script>', expectedValid: true, category: 'edge' },
47
- { label: 'SQL probe', value: "' OR '1'='1", expectedValid: true, category: 'edge' },
48
- ];
49
- if (minLength)
50
- cases.push({ label: `below min (${minLength})`, value: 'x'.repeat(Math.max(0, minLength - 1)), expectedValid: false, category: 'boundary' });
51
- if (maxLength)
52
- cases.push({ label: `above max (${maxLength})`, value: 'x'.repeat(maxLength + 1), expectedValid: false, category: 'boundary' });
53
- return cases;
26
+ const cases = [
27
+ { label: "typical text", value: "Test Input Value", expectedValid: true, category: "happy" },
28
+ { label: "single char", value: "A", expectedValid: !minLength || minLength <= 1, category: "boundary" },
29
+ { label: "empty", value: "", expectedValid: !required, category: "edge" },
30
+ { label: "spaces only", value: " ", expectedValid: !required, category: "edge" },
31
+ { label: "very long text", value: LOREM.repeat(20), expectedValid: !maxLength || maxLength > LOREM.length * 20, category: "boundary" },
32
+ { label: "unicode", value: "\u65E5\u672C\u8A9E\u30C6\u30B9\u30C8 \xDCn\xEFc\xF6d\xE9 Emojitest \u{1F389}", expectedValid: true, category: "edge" },
33
+ { label: "HTML special chars", value: "<script>alert(1)</script>", expectedValid: true, category: "edge" },
34
+ { label: "SQL probe", value: "' OR '1'='1", expectedValid: true, category: "edge" }
35
+ ];
36
+ if (minLength) cases.push({ label: `below min (${minLength})`, value: "x".repeat(Math.max(0, minLength - 1)), expectedValid: false, category: "boundary" });
37
+ if (maxLength) cases.push({ label: `above max (${maxLength})`, value: "x".repeat(maxLength + 1), expectedValid: false, category: "boundary" });
38
+ return cases;
54
39
  }
55
40
  function generateNumberCases(min, max) {
56
- const minN = min !== undefined ? parseFloat(min) : undefined;
57
- const maxN = max !== undefined ? parseFloat(max) : undefined;
58
- return [
59
- { label: 'valid number', value: '42', expectedValid: true, category: 'happy' },
60
- { label: 'zero', value: '0', expectedValid: minN === undefined || minN <= 0, category: 'boundary' },
61
- { label: 'negative', value: '-1', expectedValid: minN === undefined || minN < 0, category: 'boundary' },
62
- { label: 'decimal', value: '3.14', expectedValid: true, category: 'happy' },
63
- { label: 'text as number', value: 'notanumber', expectedValid: false, category: 'invalid' },
64
- { label: 'empty', value: '', expectedValid: false, category: 'edge' },
65
- ...(minN !== undefined ? [{ label: `below min (${min})`, value: String(minN - 1), expectedValid: false, category: 'boundary' }] : []),
66
- ...(maxN !== undefined ? [{ label: `above max (${max})`, value: String(maxN + 1), expectedValid: false, category: 'boundary' }] : []),
67
- ];
41
+ const minN = min !== void 0 ? parseFloat(min) : void 0;
42
+ const maxN = max !== void 0 ? parseFloat(max) : void 0;
43
+ return [
44
+ { label: "valid number", value: "42", expectedValid: true, category: "happy" },
45
+ { label: "zero", value: "0", expectedValid: minN === void 0 || minN <= 0, category: "boundary" },
46
+ { label: "negative", value: "-1", expectedValid: minN === void 0 || minN < 0, category: "boundary" },
47
+ { label: "decimal", value: "3.14", expectedValid: true, category: "happy" },
48
+ { label: "text as number", value: "notanumber", expectedValid: false, category: "invalid" },
49
+ { label: "empty", value: "", expectedValid: false, category: "edge" },
50
+ ...minN !== void 0 ? [{ label: `below min (${min})`, value: String(minN - 1), expectedValid: false, category: "boundary" }] : [],
51
+ ...maxN !== void 0 ? [{ label: `above max (${max})`, value: String(maxN + 1), expectedValid: false, category: "boundary" }] : []
52
+ ];
68
53
  }
69
54
  function generateSelectCases(options) {
70
- if (!options?.length)
71
- return [{ label: 'first option', value: '', expectedValid: true, category: 'happy' }];
72
- return [
73
- { label: `first option (${options[0]})`, value: options[0], expectedValid: true, category: 'happy' },
74
- { label: 'invalid option', value: '__INVALID_OPTION__', expectedValid: false, category: 'invalid' },
75
- { label: 'empty selection', value: '', expectedValid: false, category: 'edge' },
76
- ...(options.length > 1 ? [{ label: `last option (${options[options.length - 1]})`, value: options[options.length - 1], expectedValid: true, category: 'happy' }] : []),
77
- ];
55
+ if (!options?.length) return [{ label: "first option", value: "", expectedValid: true, category: "happy" }];
56
+ return [
57
+ { label: `first option (${options[0]})`, value: options[0], expectedValid: true, category: "happy" },
58
+ { label: "invalid option", value: "__INVALID_OPTION__", expectedValid: false, category: "invalid" },
59
+ { label: "empty selection", value: "", expectedValid: false, category: "edge" },
60
+ ...options.length > 1 ? [{ label: `last option (${options[options.length - 1]})`, value: options[options.length - 1], expectedValid: true, category: "happy" }] : []
61
+ ];
78
62
  }
79
- export function generateFieldCases(field) {
80
- switch (field.type) {
81
- case 'email': return generateEmailCases();
82
- case 'password': return generatePasswordCases(field.minLength, field.maxLength);
83
- case 'number': return generateNumberCases(field.min, field.max);
84
- case 'select': return generateSelectCases(field.options);
85
- case 'checkbox': return [
86
- { label: 'checked', value: 'true', expectedValid: true, category: 'happy' },
87
- { label: 'unchecked', value: 'false', expectedValid: !field.required, category: field.required ? 'invalid' : 'happy' },
88
- ];
89
- case 'date': return [
90
- { label: 'valid date', value: '2026-01-15', expectedValid: true, category: 'happy' },
91
- { label: 'invalid date', value: '9999-99-99', expectedValid: false, category: 'invalid' },
92
- { label: 'empty', value: '', expectedValid: !field.required, category: 'edge' },
93
- ];
94
- case 'url': return [
95
- { label: 'valid URL', value: 'https://example.com', expectedValid: true, category: 'happy' },
96
- { label: 'missing protocol', value: 'example.com', expectedValid: false, category: 'invalid' },
97
- { label: 'empty', value: '', expectedValid: !field.required, category: 'edge' },
98
- ];
99
- default:
100
- return generateTextCases(field.minLength, field.maxLength, field.required);
101
- }
63
+ function generateFieldCases(field) {
64
+ switch (field.type) {
65
+ case "email":
66
+ return generateEmailCases();
67
+ case "password":
68
+ return generatePasswordCases(field.minLength, field.maxLength);
69
+ case "number":
70
+ return generateNumberCases(field.min, field.max);
71
+ case "select":
72
+ return generateSelectCases(field.options);
73
+ case "checkbox":
74
+ return [
75
+ { label: "checked", value: "true", expectedValid: true, category: "happy" },
76
+ { label: "unchecked", value: "false", expectedValid: !field.required, category: field.required ? "invalid" : "happy" }
77
+ ];
78
+ case "date":
79
+ return [
80
+ { label: "valid date", value: "2026-01-15", expectedValid: true, category: "happy" },
81
+ { label: "invalid date", value: "9999-99-99", expectedValid: false, category: "invalid" },
82
+ { label: "empty", value: "", expectedValid: !field.required, category: "edge" }
83
+ ];
84
+ case "url":
85
+ return [
86
+ { label: "valid URL", value: "https://example.com", expectedValid: true, category: "happy" },
87
+ { label: "missing protocol", value: "example.com", expectedValid: false, category: "invalid" },
88
+ { label: "empty", value: "", expectedValid: !field.required, category: "edge" }
89
+ ];
90
+ default:
91
+ return generateTextCases(field.minLength, field.maxLength, field.required);
92
+ }
102
93
  }
103
- export function fuzzForm(form) {
104
- return {
105
- formIndex: form.index,
106
- purpose: form.purpose,
107
- fieldCases: form.fields.map(field => ({ field, cases: generateFieldCases(field) })),
108
- };
94
+ function fuzzForm(form) {
95
+ return {
96
+ formIndex: form.index,
97
+ purpose: form.purpose,
98
+ fieldCases: form.fields.map((field) => ({ field, cases: generateFieldCases(field) }))
99
+ };
109
100
  }
101
+ export {
102
+ fuzzForm,
103
+ generateFieldCases
104
+ };
105
+ //# sourceMappingURL=input-fuzzer.js.map