@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.
Files changed (82) 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.js +266 -249
  22. package/dist/extractors/artifact-envelope.js +58 -59
  23. package/dist/failure-analysis-agent.js +33 -37
  24. package/dist/feature-flag-detector.js +66 -51
  25. package/dist/form-detector.js +75 -55
  26. package/dist/frontier.js +101 -76
  27. package/dist/gap-pass.js +89 -68
  28. package/dist/graphql-detector.js +72 -62
  29. package/dist/http-engine.js +330 -282
  30. package/dist/incremental-diff.js +87 -54
  31. package/dist/index.js +28 -67
  32. package/dist/input-fuzzer.js +97 -93
  33. package/dist/interactive-probe.js +827 -715
  34. package/dist/job-queue.js +2169 -2151
  35. package/dist/js-coverage.js +56 -52
  36. package/dist/js-router-detector.js +117 -86
  37. package/dist/language-detector.js +63 -51
  38. package/dist/link-classifier.js +50 -32
  39. package/dist/live-view.js +108 -91
  40. package/dist/locator-extractor.js +187 -151
  41. package/dist/logger.js +7 -9
  42. package/dist/markdown-extract.js +61 -48
  43. package/dist/native-crawler.js +946 -780
  44. package/dist/network-observer.js +156 -135
  45. package/dist/network-throttle.js +40 -29
  46. package/dist/openapi-generator.js +92 -77
  47. package/dist/pdf-extractor.js +90 -72
  48. package/dist/performance-metrics.js +102 -80
  49. package/dist/phash.js +144 -125
  50. package/dist/pii-scrubber.js +68 -65
  51. package/dist/playwright-recorder.js +58 -70
  52. package/dist/policies/crawl-safety.js +34 -31
  53. package/dist/profiles/domain-profile.js +125 -130
  54. package/dist/proxy.js +172 -146
  55. package/dist/rate-limiter.js +65 -58
  56. package/dist/redirect-tracker.js +64 -60
  57. package/dist/redis-frontier.js +136 -116
  58. package/dist/redis-queue.js +144 -157
  59. package/dist/response-cache.js +140 -127
  60. package/dist/responsive-detector.js +46 -42
  61. package/dist/retry-policy.js +50 -46
  62. package/dist/robots-txt.js +83 -69
  63. package/dist/screen-reader.js +70 -45
  64. package/dist/screenshot-masker.js +77 -59
  65. package/dist/seo-checker.js +107 -88
  66. package/dist/session-capture.js +212 -192
  67. package/dist/session-export.js +133 -107
  68. package/dist/sitemap-writer.js +41 -38
  69. package/dist/sitemap.js +202 -141
  70. package/dist/skyvern.js +148 -123
  71. package/dist/sqs-queue.js +42 -42
  72. package/dist/sso-token.js +90 -74
  73. package/dist/stealth/human-behavior.js +173 -156
  74. package/dist/telemetry.js +82 -68
  75. package/dist/test-executor.js +335 -309
  76. package/dist/tls-fingerprint.js +88 -77
  77. package/dist/url-pattern-completer.js +90 -71
  78. package/dist/visual-diff-verdict.js +38 -23
  79. package/dist/webhook-notifier.js +69 -71
  80. package/dist/websocket-detector.js +68 -56
  81. package/dist/worker.js +38 -29
  82. package/package.json +1 -1
@@ -1,61 +1,94 @@
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");
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');
10
25
  }
11
- function normalizeText(text) {
12
- return text.split("\n").map((l) => l.trim()).filter((l) => l.length > 0).join("\n");
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');
13
36
  }
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
- };
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
+ };
22
45
  }
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" };
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' };
33
60
  }
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;
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;
40
72
  }
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);
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
+ }
49
92
  }
50
- }
51
- return { toProcess, toSkip };
93
+ return { toProcess, toSkip };
52
94
  }
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,67 +1,28 @@
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
+ 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,105 +1,109 @@
1
- const LOREM = "Lorem ipsum dolor sit amet consectetur adipiscing elit";
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';
2
15
  function generateEmailCases() {
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
- ];
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
+ ];
12
25
  }
13
26
  function generatePasswordCases(minLength, maxLength) {
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
- ];
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
+ ];
24
37
  }
25
38
  function generateTextCases(minLength, maxLength, required) {
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;
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;
39
54
  }
40
55
  function generateNumberCases(min, max) {
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
- ];
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
+ ];
53
68
  }
54
69
  function generateSelectCases(options) {
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
- ];
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
+ ];
62
78
  }
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
- }
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
+ }
93
102
  }
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
- };
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
+ };
100
109
  }
101
- export {
102
- fuzzForm,
103
- generateFieldCases
104
- };
105
- //# sourceMappingURL=input-fuzzer.js.map