@dealcrawl/sdk 2.1.1 → 2.2.0

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 (85) hide show
  1. package/README.md +147 -14
  2. package/dist/index.d.mts +2769 -0
  3. package/dist/index.d.ts +2748 -37
  4. package/dist/index.js +2529 -64
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +2508 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/package.json +14 -7
  9. package/dist/client.d.ts +0 -285
  10. package/dist/client.d.ts.map +0 -1
  11. package/dist/client.js +0 -336
  12. package/dist/client.js.map +0 -1
  13. package/dist/error.d.ts +0 -55
  14. package/dist/error.d.ts.map +0 -1
  15. package/dist/error.js +0 -128
  16. package/dist/error.js.map +0 -1
  17. package/dist/index.d.ts.map +0 -1
  18. package/dist/resources/account.d.ts +0 -143
  19. package/dist/resources/account.d.ts.map +0 -1
  20. package/dist/resources/account.js +0 -186
  21. package/dist/resources/account.js.map +0 -1
  22. package/dist/resources/crawl.d.ts +0 -101
  23. package/dist/resources/crawl.d.ts.map +0 -1
  24. package/dist/resources/crawl.js +0 -234
  25. package/dist/resources/crawl.js.map +0 -1
  26. package/dist/resources/data.d.ts +0 -157
  27. package/dist/resources/data.d.ts.map +0 -1
  28. package/dist/resources/data.js +0 -245
  29. package/dist/resources/data.js.map +0 -1
  30. package/dist/resources/dork.d.ts +0 -104
  31. package/dist/resources/dork.d.ts.map +0 -1
  32. package/dist/resources/dork.js +0 -163
  33. package/dist/resources/dork.js.map +0 -1
  34. package/dist/resources/extract.d.ts +0 -105
  35. package/dist/resources/extract.d.ts.map +0 -1
  36. package/dist/resources/extract.js +0 -246
  37. package/dist/resources/extract.js.map +0 -1
  38. package/dist/resources/index.d.ts +0 -14
  39. package/dist/resources/index.d.ts.map +0 -1
  40. package/dist/resources/index.js +0 -14
  41. package/dist/resources/index.js.map +0 -1
  42. package/dist/resources/keys.d.ts +0 -124
  43. package/dist/resources/keys.d.ts.map +0 -1
  44. package/dist/resources/keys.js +0 -168
  45. package/dist/resources/keys.js.map +0 -1
  46. package/dist/resources/scrape.d.ts +0 -53
  47. package/dist/resources/scrape.d.ts.map +0 -1
  48. package/dist/resources/scrape.js +0 -85
  49. package/dist/resources/scrape.js.map +0 -1
  50. package/dist/resources/status.d.ts +0 -100
  51. package/dist/resources/status.d.ts.map +0 -1
  52. package/dist/resources/status.js +0 -133
  53. package/dist/resources/status.js.map +0 -1
  54. package/dist/resources/webhooks.d.ts +0 -126
  55. package/dist/resources/webhooks.d.ts.map +0 -1
  56. package/dist/resources/webhooks.js +0 -167
  57. package/dist/resources/webhooks.js.map +0 -1
  58. package/dist/types/config.d.ts +0 -45
  59. package/dist/types/config.d.ts.map +0 -1
  60. package/dist/types/config.js +0 -10
  61. package/dist/types/config.js.map +0 -1
  62. package/dist/types/index.d.ts +0 -8
  63. package/dist/types/index.d.ts.map +0 -1
  64. package/dist/types/index.js +0 -8
  65. package/dist/types/index.js.map +0 -1
  66. package/dist/types/options.d.ts +0 -328
  67. package/dist/types/options.d.ts.map +0 -1
  68. package/dist/types/options.js +0 -6
  69. package/dist/types/options.js.map +0 -1
  70. package/dist/types/responses.d.ts +0 -422
  71. package/dist/types/responses.d.ts.map +0 -1
  72. package/dist/types/responses.js +0 -6
  73. package/dist/types/responses.js.map +0 -1
  74. package/dist/types/shared.d.ts +0 -234
  75. package/dist/types/shared.d.ts.map +0 -1
  76. package/dist/types/shared.js +0 -37
  77. package/dist/types/shared.js.map +0 -1
  78. package/dist/utils/polling.d.ts +0 -57
  79. package/dist/utils/polling.d.ts.map +0 -1
  80. package/dist/utils/polling.js +0 -110
  81. package/dist/utils/polling.js.map +0 -1
  82. package/dist/utils/request.d.ts +0 -47
  83. package/dist/utils/request.d.ts.map +0 -1
  84. package/dist/utils/request.js +0 -192
  85. package/dist/utils/request.js.map +0 -1
@@ -0,0 +1,2769 @@
1
+ /**
2
+ * Shared types for DealCrawl SDK
3
+ * These types are copied from @dealcrawl/shared to avoid bundling
4
+ * the entire shared package (which includes Redis, etc.)
5
+ */
6
+ interface ApiResponse<T = unknown> {
7
+ success: boolean;
8
+ data?: T;
9
+ error?: ApiError;
10
+ meta?: ResponseMeta;
11
+ }
12
+ interface ApiError {
13
+ code: string;
14
+ message: string;
15
+ details?: Record<string, unknown>;
16
+ }
17
+ interface ResponseMeta {
18
+ requestId: string;
19
+ timestamp: string;
20
+ duration?: number;
21
+ }
22
+ type JobStatus = "pending" | "active" | "completed" | "failed" | "delayed" | "paused";
23
+ interface PaginatedResponse<T> {
24
+ data: T[];
25
+ pagination: {
26
+ page: number;
27
+ limit: number;
28
+ total: number;
29
+ hasMore: boolean;
30
+ };
31
+ }
32
+ interface RateLimitInfo {
33
+ limit: number;
34
+ remaining: number;
35
+ reset: number;
36
+ }
37
+ interface Signal {
38
+ type: string;
39
+ value: string;
40
+ confidence: number;
41
+ metadata?: Record<string, unknown>;
42
+ }
43
+ interface DealSignal extends Signal {
44
+ type: "price" | "original_price" | "discount" | "discount_amount" | "sale_indicator" | "deal_score" | "urgency_level" | "is_legit_deal";
45
+ }
46
+ interface PriceSignal extends DealSignal {
47
+ type: "price" | "original_price";
48
+ metadata: {
49
+ currency: string;
50
+ raw: string;
51
+ source: "json-ld" | "og-meta" | "microdata" | "regex" | "css-selector";
52
+ };
53
+ }
54
+ interface DiscountSignal extends DealSignal {
55
+ type: "discount" | "discount_amount";
56
+ metadata: {
57
+ percent?: number;
58
+ amount?: number;
59
+ currency?: string;
60
+ raw?: string;
61
+ calculated?: boolean;
62
+ source: string;
63
+ };
64
+ }
65
+ interface LinkMetadata {
66
+ total: number;
67
+ internal: string[];
68
+ external: string[];
69
+ }
70
+ interface ImageMetadata {
71
+ total: number;
72
+ urls: string[];
73
+ }
74
+ interface OpenGraphMetadata {
75
+ title?: string;
76
+ description?: string;
77
+ image?: string;
78
+ url?: string;
79
+ siteName?: string;
80
+ type?: string;
81
+ locale?: string;
82
+ localeAlternate?: string[];
83
+ }
84
+ interface ParsedPage {
85
+ url: string;
86
+ depth?: number;
87
+ title?: string;
88
+ description?: string;
89
+ content?: string;
90
+ language?: string;
91
+ /** @deprecated Use linksMetadata instead */
92
+ links?: string[];
93
+ linksMetadata?: LinkMetadata;
94
+ /** @deprecated Use imagesMetadata instead */
95
+ images?: string[];
96
+ imagesMetadata?: ImageMetadata;
97
+ openGraph?: OpenGraphMetadata;
98
+ metadata?: Record<string, unknown>;
99
+ statusCode?: number;
100
+ crawlDurationMs?: number;
101
+ signals?: Signal[];
102
+ }
103
+ interface DealScoreSummary {
104
+ score: number;
105
+ quality: "excellent" | "good" | "average" | "poor" | "very_poor";
106
+ recommendation: "highly_recommended" | "recommended" | "consider" | "skip";
107
+ breakdown: {
108
+ discount: number;
109
+ urgency: number;
110
+ legitimacy: number;
111
+ priceClarity: number;
112
+ productInfo: number;
113
+ };
114
+ }
115
+ interface ScreenshotResult {
116
+ url: string;
117
+ width: number;
118
+ height: number;
119
+ format: "png" | "jpeg" | "webp";
120
+ sizeBytes: number;
121
+ }
122
+ interface AIExtraction {
123
+ summary?: string;
124
+ entities?: Entity[];
125
+ sentiment?: "positive" | "negative" | "neutral";
126
+ topics?: string[];
127
+ raw?: Record<string, unknown>;
128
+ }
129
+ interface Entity {
130
+ type: "person" | "organization" | "location" | "product" | "other";
131
+ value: string;
132
+ confidence: number;
133
+ }
134
+ interface ScrapeResult {
135
+ url: string;
136
+ parsed: ParsedPage;
137
+ signals: Signal[];
138
+ aiExtraction?: AIExtraction;
139
+ dealExtraction?: ExtractedDeal;
140
+ /** Multiple deals extracted from list pages */
141
+ multipleDeals?: ExtractedDeal[];
142
+ /** Metadata for multi-deal extraction */
143
+ multiDealMetadata?: {
144
+ totalFound: number;
145
+ category?: string;
146
+ hasNextPage?: boolean;
147
+ extractionConfidence: number;
148
+ };
149
+ dealScore?: DealScoreSummary;
150
+ screenshot?: string;
151
+ screenshotMetadata?: ScreenshotResult;
152
+ scrapedAt: string;
153
+ }
154
+ type UrgencyLevel = "none" | "low" | "medium" | "high" | "critical";
155
+ interface ExtractedDeal {
156
+ id: string;
157
+ sourceUrl: string;
158
+ product: {
159
+ name: string;
160
+ brand?: string;
161
+ category?: string;
162
+ description?: string;
163
+ imageUrl?: string;
164
+ sku?: string;
165
+ };
166
+ pricing: {
167
+ currentPrice: number;
168
+ originalPrice?: number;
169
+ discountPercent?: number;
170
+ savedAmount?: number;
171
+ currency: string;
172
+ priceConfidence: number;
173
+ };
174
+ quality: {
175
+ dealScore: number;
176
+ urgencyLevel: UrgencyLevel;
177
+ isLegitDeal: boolean;
178
+ legitimacyScore: number;
179
+ };
180
+ merchant: string;
181
+ affiliateEligible?: boolean;
182
+ expiresAt?: string;
183
+ crawledAt: string;
184
+ rawSignals?: Signal[];
185
+ }
186
+ interface CrawlError {
187
+ url: string;
188
+ error: string;
189
+ timestamp: string;
190
+ }
191
+ interface CrawlStats {
192
+ totalUrlsDiscovered?: number;
193
+ urlsSkipped?: number;
194
+ avgDealScore?: number;
195
+ highValuePages?: number;
196
+ pagesScraped?: number;
197
+ totalPagesFound?: number;
198
+ linksFound?: number;
199
+ depth?: number;
200
+ errors?: number;
201
+ }
202
+ interface CrawlResult {
203
+ startUrl: string;
204
+ pagesFound: number;
205
+ pages: ParsedPage[];
206
+ crawledAt: string;
207
+ duration?: number;
208
+ errors?: CrawlError[];
209
+ stats?: CrawlStats;
210
+ }
211
+ interface DorkSearchResult {
212
+ url: string;
213
+ title: string;
214
+ snippet: string;
215
+ position: number;
216
+ metadata?: Record<string, unknown>;
217
+ }
218
+ interface DorkResult {
219
+ query: string;
220
+ site?: string;
221
+ results: DorkSearchResult[];
222
+ totalResults?: number;
223
+ searchedAt: string;
224
+ }
225
+
226
+ /**
227
+ * SDK Configuration options
228
+ */
229
+ interface DealCrawlConfig {
230
+ /** API key for authentication (required) */
231
+ apiKey: string;
232
+ /** Base URL for the API (default: https://api.dealcrawl.dev) */
233
+ baseUrl?: string;
234
+ /** Default timeout for requests in milliseconds (default: 30000) */
235
+ timeout?: number;
236
+ /** Maximum number of retries for failed requests (default: 3) */
237
+ maxRetries?: number;
238
+ /** Delay between retries in milliseconds (default: 1000) */
239
+ retryDelay?: number;
240
+ /** Callback when rate limit is hit */
241
+ onRateLimit?: (info: RateLimitInfo) => void;
242
+ }
243
+ /**
244
+ * Internal request context passed to resources
245
+ */
246
+ interface RequestContext {
247
+ /** Base URL for API requests */
248
+ baseUrl: string;
249
+ /** API key for authentication */
250
+ apiKey: string;
251
+ /** Default timeout in milliseconds */
252
+ timeout: number;
253
+ /** Maximum number of retries */
254
+ maxRetries: number;
255
+ /** Delay between retries in milliseconds */
256
+ retryDelay: number;
257
+ /** Rate limit callback */
258
+ onRateLimit?: (info: RateLimitInfo) => void;
259
+ }
260
+ /**
261
+ * Default configuration values
262
+ */
263
+ declare const DEFAULT_CONFIG: {
264
+ readonly baseUrl: "https://api.dealcrawl.dev";
265
+ readonly timeout: 30000;
266
+ readonly maxRetries: 3;
267
+ readonly retryDelay: 1000;
268
+ };
269
+
270
+ /**
271
+ * SDK Response Types
272
+ * Types for API responses
273
+ */
274
+
275
+ /** Base job response from API */
276
+ interface JobResponse {
277
+ /** Unique job identifier */
278
+ jobId: string;
279
+ /** Current job status */
280
+ status: JobStatus;
281
+ /** URL to check job status */
282
+ statusUrl: string;
283
+ /** Estimated time to completion */
284
+ estimatedTime?: string;
285
+ }
286
+ /** Pagination info */
287
+ interface PaginationInfo {
288
+ page: number;
289
+ limit: number;
290
+ total: number;
291
+ totalPages: number;
292
+ hasMore: boolean;
293
+ }
294
+ /** Scrape job creation response */
295
+ interface ScrapeJobResponse extends JobResponse {
296
+ }
297
+ /** Individual batch scrape result item */
298
+ interface BatchScrapeResultItem {
299
+ /** URL that was scraped */
300
+ url: string;
301
+ /** Reference ID if provided in request */
302
+ ref?: string;
303
+ /** Job ID created for this URL */
304
+ jobId: string;
305
+ /** Status of job creation */
306
+ status: "queued" | "failed";
307
+ /** Error message if job creation failed */
308
+ error?: string;
309
+ }
310
+ /** Batch scrape response */
311
+ interface BatchScrapeResponse {
312
+ /** Batch ID for tracking */
313
+ batchId: string;
314
+ /** Total number of URLs in batch */
315
+ total: number;
316
+ /** Number of jobs successfully queued */
317
+ queued: number;
318
+ /** Number of jobs that failed to queue */
319
+ failed: number;
320
+ /** Individual results per URL */
321
+ results: BatchScrapeResultItem[];
322
+ /** Timestamp when batch was created */
323
+ createdAt: string;
324
+ }
325
+ /** Batch status response */
326
+ interface BatchStatusResponse {
327
+ /** Batch ID */
328
+ batchId: string;
329
+ /** Total URLs in batch */
330
+ total: number;
331
+ /** Number queued */
332
+ queued: number;
333
+ /** Number failed */
334
+ failed: number;
335
+ /** Webhook URL if configured */
336
+ webhookUrl?: string;
337
+ /** Priority level */
338
+ priority: number;
339
+ /** Creation timestamp */
340
+ createdAt: string;
341
+ /** Individual job statuses */
342
+ jobs: Array<{
343
+ id: string;
344
+ status: JobStatus;
345
+ result?: unknown;
346
+ error?: string;
347
+ }>;
348
+ }
349
+ /** Individual search result */
350
+ interface SearchResultItem {
351
+ /** Result title */
352
+ title: string;
353
+ /** Result URL */
354
+ url: string;
355
+ /** Result description/snippet */
356
+ description: string;
357
+ /** Deal score if useDealScoring enabled (0-100) */
358
+ dealScore?: number;
359
+ /** Display URL */
360
+ displayUrl?: string;
361
+ }
362
+ /** Search job response data */
363
+ interface SearchData {
364
+ /** Search results */
365
+ results: SearchResultItem[];
366
+ /** Total results found */
367
+ total: number;
368
+ /** Original query */
369
+ query: string;
370
+ /** AI-optimized query (if useAiOptimization=true) */
371
+ aiOptimizedQuery?: string;
372
+ /** Whether results were from cache */
373
+ cached: boolean;
374
+ /** Search duration in ms */
375
+ durationMs: number;
376
+ /** Job IDs for auto-scraped URLs */
377
+ scrapedJobIds?: string[];
378
+ }
379
+ /** Search job response */
380
+ interface SearchJobResponse {
381
+ /** Success status */
382
+ success: boolean;
383
+ /** Search results data */
384
+ data: SearchData;
385
+ /** Response metadata */
386
+ meta: {
387
+ /** Search provider used */
388
+ provider: "serpapi" | "google";
389
+ /** Number of scrape jobs created */
390
+ scrapeJobsCreated: number;
391
+ };
392
+ }
393
+ /** Search API status response */
394
+ interface SearchStatusResponse {
395
+ /** Whether search is available */
396
+ available: boolean;
397
+ /** Search provider */
398
+ provider: "serpapi" | "google" | "none";
399
+ /** Available features */
400
+ features: {
401
+ /** AI query optimization available */
402
+ aiOptimization: boolean;
403
+ /** Redis caching enabled */
404
+ caching: boolean;
405
+ /** Deal scoring enabled */
406
+ dealScoring: boolean;
407
+ };
408
+ /** Cache TTL */
409
+ cacheTtl: string;
410
+ }
411
+ /** Crawl job creation response */
412
+ interface CrawlJobResponse extends JobResponse {
413
+ }
414
+ /** Crawl analysis response */
415
+ interface CrawlAnalysisResponse {
416
+ url: string;
417
+ domain: string;
418
+ recommendedTemplate?: string;
419
+ estimatedPages: number;
420
+ suggestedSettings: {
421
+ maxDepth: number;
422
+ maxPages: number;
423
+ delayMs: number;
424
+ excludePatterns: string[];
425
+ };
426
+ sitemapFound: boolean;
427
+ robotsTxtRules?: string[];
428
+ }
429
+ /** Extract job creation response */
430
+ interface ExtractJobResponse extends JobResponse {
431
+ }
432
+ /** Dork job creation response */
433
+ interface DorkJobResponse extends JobResponse {
434
+ }
435
+ /** Deal metrics from a job */
436
+ interface DealMetrics {
437
+ totalDeals: number;
438
+ avgScore: number;
439
+ highestScore: number;
440
+ legitDeals: number;
441
+ categories: Record<string, number>;
442
+ }
443
+ /** Checkpoint info for resumable jobs */
444
+ interface CheckpointInfo {
445
+ canResume: boolean;
446
+ lastProcessedUrl?: string;
447
+ urlsProcessed: number;
448
+ urlsRemaining: number;
449
+ savedAt: string;
450
+ }
451
+ /** Job status response */
452
+ interface JobStatusResponse {
453
+ jobId: string;
454
+ status: JobStatus;
455
+ progress?: number;
456
+ createdAt: string;
457
+ completedAt?: string;
458
+ failedAt?: string;
459
+ priorityQueue?: string;
460
+ result?: unknown;
461
+ error?: string;
462
+ dealMetrics?: DealMetrics;
463
+ checkpoint?: CheckpointInfo;
464
+ }
465
+ /** Job deals response */
466
+ interface JobDealsResponse {
467
+ jobId: string;
468
+ deals: DealSummary[];
469
+ count: number;
470
+ metrics?: DealMetrics;
471
+ }
472
+ /** Deal summary from status endpoint */
473
+ interface DealSummary {
474
+ id: string;
475
+ sourceUrl: string;
476
+ productName: string;
477
+ currentPrice: number;
478
+ originalPrice?: number;
479
+ discountPercent?: number;
480
+ dealScore: number;
481
+ category?: string;
482
+ merchant?: string;
483
+ }
484
+ /** Job resume response */
485
+ interface ResumeJobResponse {
486
+ success: boolean;
487
+ originalJobId: string;
488
+ newJobId: string;
489
+ message: string;
490
+ }
491
+ /** Job metrics response */
492
+ interface JobMetricsResponse {
493
+ jobId: string;
494
+ status: JobStatus;
495
+ metrics: {
496
+ totalUrls: number;
497
+ successfulUrls: number;
498
+ failedUrls: number;
499
+ successRate: number;
500
+ avgProcessingTime?: number;
501
+ };
502
+ }
503
+ /** Cancel job response */
504
+ interface CancelJobResponse {
505
+ success: boolean;
506
+ jobId: string;
507
+ message: string;
508
+ }
509
+ /** Job summary in list */
510
+ interface JobSummary {
511
+ id: string;
512
+ type: "scrape" | "crawl" | "dork" | "extract";
513
+ status: JobStatus;
514
+ input: Record<string, unknown>;
515
+ dealsFound?: number;
516
+ avgDealScore?: number;
517
+ highestDealScore?: number;
518
+ createdAt: string;
519
+ updatedAt: string;
520
+ completedAt?: string;
521
+ }
522
+ /** Jobs list response */
523
+ interface ListJobsResponse {
524
+ data: JobSummary[];
525
+ pagination: PaginationInfo;
526
+ }
527
+ /** Product info in deal */
528
+ interface ProductInfo {
529
+ name: string;
530
+ brand?: string;
531
+ category?: string;
532
+ description?: string;
533
+ imageUrl?: string;
534
+ }
535
+ /** Pricing info in deal */
536
+ interface PricingInfo {
537
+ currentPrice: number;
538
+ originalPrice?: number;
539
+ discountPercent?: number;
540
+ currency: string;
541
+ }
542
+ /** Deal in list */
543
+ interface DealItem {
544
+ id: string;
545
+ jobId: string;
546
+ sourceUrl: string;
547
+ product: ProductInfo;
548
+ pricing: PricingInfo;
549
+ dealScore: number;
550
+ urgencyLevel?: string;
551
+ isLegitDeal: boolean;
552
+ merchant?: string;
553
+ affiliateEligible?: boolean;
554
+ syncedToDealup: boolean;
555
+ dealupDealId?: string;
556
+ createdAt: string;
557
+ }
558
+ /** Deals list response */
559
+ interface ListDealsResponse {
560
+ data: DealItem[];
561
+ pagination: PaginationInfo;
562
+ }
563
+ /** Full deal details */
564
+ interface DealDetails extends DealItem {
565
+ rawSignals?: unknown;
566
+ aiExtraction?: unknown;
567
+ updatedAt: string;
568
+ }
569
+ /** Client stats response */
570
+ interface ClientStatsResponse {
571
+ period: string;
572
+ totals: {
573
+ jobs: number;
574
+ deals: number;
575
+ scrapes: number;
576
+ crawls: number;
577
+ dorks: number;
578
+ };
579
+ performance: {
580
+ avgSuccessRate: number;
581
+ avgDealScore: number;
582
+ topCategories: Array<{
583
+ category: string;
584
+ count: number;
585
+ }>;
586
+ };
587
+ }
588
+ /** Webhook in list */
589
+ interface WebhookItem {
590
+ id: string;
591
+ event: string;
592
+ url: string;
593
+ minDealScore: number;
594
+ categories?: string[];
595
+ active: boolean;
596
+ createdAt: string;
597
+ updatedAt: string;
598
+ lastTriggeredAt?: string;
599
+ triggerCount: number;
600
+ failureCount: number;
601
+ }
602
+ /** Create webhook response */
603
+ interface CreateWebhookResponse {
604
+ success: boolean;
605
+ webhookId: string;
606
+ event: string;
607
+ url: string;
608
+ minDealScore: number;
609
+ active: boolean;
610
+ }
611
+ /** List webhooks response */
612
+ interface ListWebhooksResponse {
613
+ webhooks: WebhookItem[];
614
+ count: number;
615
+ }
616
+ /** Update webhook response */
617
+ interface UpdateWebhookResponse {
618
+ success: boolean;
619
+ webhook: WebhookItem;
620
+ }
621
+ /** Delete webhook response */
622
+ interface DeleteWebhookResponse {
623
+ success: boolean;
624
+ webhookId: string;
625
+ message: string;
626
+ }
627
+ /** Test webhook response */
628
+ interface TestWebhookResponse {
629
+ success: boolean;
630
+ webhookId: string;
631
+ delivered: boolean;
632
+ statusCode?: number;
633
+ responseTime?: number;
634
+ error?: string;
635
+ }
636
+ /** API key info (safe, without secret) */
637
+ interface ApiKeyInfo {
638
+ id: string;
639
+ name: string;
640
+ /** Key prefix (e.g., "sk_dev_abc123") */
641
+ keyPrefix: string;
642
+ scopes: string[];
643
+ isActive: boolean;
644
+ expiresAt: string | null;
645
+ lastUsedAt: string | null;
646
+ createdAt: string;
647
+ revokedAt: string | null;
648
+ revokedReason: string | null;
649
+ usageCount: number;
650
+ ipAllowlist: string[] | null;
651
+ }
652
+ /** Created API key (includes secret - only shown once) */
653
+ interface CreatedApiKey {
654
+ id: string;
655
+ /** The full API key - only returned on creation, never stored */
656
+ rawKey: string;
657
+ /** Key prefix for identification */
658
+ keyPrefix: string;
659
+ name: string;
660
+ scopes: string[];
661
+ expiresAt: string | null;
662
+ createdAt: string;
663
+ }
664
+ /** List keys response */
665
+ interface ListKeysResponse {
666
+ keys: ApiKeyInfo[];
667
+ count: number;
668
+ activeCount: number;
669
+ }
670
+ /** Create key response */
671
+ interface CreateKeyResponse extends CreatedApiKey {
672
+ warning: string;
673
+ }
674
+ /** Rotate key response */
675
+ interface RotateKeyResponse {
676
+ oldKeyId: string;
677
+ oldKeyRevoked: boolean;
678
+ newKey: CreateKeyResponse;
679
+ }
680
+ /** Delete key response */
681
+ interface DeleteKeyResponse {
682
+ success: boolean;
683
+ keyId: string;
684
+ message: string;
685
+ }
686
+ /** Key stats response */
687
+ interface KeyStatsResponse {
688
+ keyId: string;
689
+ keyName: string;
690
+ period: string;
691
+ stats: {
692
+ totalRequests: number;
693
+ successfulRequests: number;
694
+ failedRequests: number;
695
+ avgDurationMs: number;
696
+ byEndpoint: Record<string, number>;
697
+ requestsByDay: Record<string, number>;
698
+ };
699
+ }
700
+ /** Usage stats */
701
+ interface UsageStats {
702
+ scrapes: {
703
+ used: number;
704
+ limit: number;
705
+ };
706
+ crawls: {
707
+ used: number;
708
+ limit: number;
709
+ };
710
+ dorks: {
711
+ used: number;
712
+ limit: number;
713
+ };
714
+ period: string;
715
+ resetAt: string;
716
+ }
717
+ /** Client preferences */
718
+ interface ClientPreferences {
719
+ preferredCategories?: string[];
720
+ minDealScore?: number;
721
+ autoSync?: boolean;
722
+ webhookEnabled?: boolean;
723
+ }
724
+ /** Account info response */
725
+ interface AccountInfoResponse {
726
+ id: string;
727
+ name: string;
728
+ tier: "free" | "pro" | "enterprise";
729
+ usage: UsageStats;
730
+ dealMetrics?: DealMetrics;
731
+ preferences: ClientPreferences;
732
+ }
733
+ /** Account metrics response */
734
+ interface AccountMetricsResponse {
735
+ dealMetrics: DealMetrics;
736
+ categoryPerformance: Array<{
737
+ category: string;
738
+ totalDeals: number;
739
+ avgScore: number;
740
+ syncRate: number;
741
+ }>;
742
+ }
743
+ /** DealUp sync metrics */
744
+ interface DealUpMetrics {
745
+ totalSynced: number;
746
+ pendingSync: number;
747
+ syncErrors: number;
748
+ lastSyncAt?: string;
749
+ clicksGenerated: number;
750
+ revenue?: number;
751
+ }
752
+ /** DealUp metrics response */
753
+ interface DealUpMetricsResponse {
754
+ sync: DealUpMetrics;
755
+ tier: string;
756
+ }
757
+ /** Crawl recommendation */
758
+ interface CrawlRecommendation {
759
+ url: string;
760
+ domain: string;
761
+ reason: string;
762
+ estimatedDeals: number;
763
+ confidence: number;
764
+ }
765
+ /** Recommendations response */
766
+ interface RecommendationsResponse {
767
+ recommendations: CrawlRecommendation[];
768
+ count: number;
769
+ }
770
+ /** Preferences response */
771
+ interface PreferencesResponse {
772
+ preferences: ClientPreferences;
773
+ }
774
+ /** Update preferences response */
775
+ interface UpdatePreferencesResponse {
776
+ success: boolean;
777
+ preferences: ClientPreferences;
778
+ }
779
+
780
+ /**
781
+ * Polling Utilities
782
+ * Helpers for waiting on async job completion
783
+ */
784
+
785
+ /** Options for waiting on a job */
786
+ interface WaitOptions {
787
+ /** Polling interval in milliseconds (default: 2000) */
788
+ pollInterval?: number;
789
+ /** Maximum time to wait in milliseconds (default: 300000 = 5 minutes) */
790
+ timeout?: number;
791
+ /** Callback on each poll */
792
+ onProgress?: (status: JobStatusResponse) => void;
793
+ /** Callback on status change */
794
+ onStatusChange?: (newStatus: string, oldStatus: string) => void;
795
+ /** AbortSignal for cancellation */
796
+ signal?: AbortSignal;
797
+ }
798
+ /** Result of waiting for a job */
799
+ interface WaitResult<T = unknown> {
800
+ /** Job ID */
801
+ jobId: string;
802
+ /** Final status */
803
+ status: "completed" | "failed";
804
+ /** Result data (if completed) */
805
+ result?: T;
806
+ /** Error message (if failed) */
807
+ error?: string;
808
+ /** Total time waited in ms */
809
+ waitTime: number;
810
+ }
811
+ /**
812
+ * Wait for a job to complete
813
+ * Polls the status endpoint until the job is done
814
+ */
815
+ declare function waitForResult<T = unknown>(ctx: RequestContext, jobId: string, options?: WaitOptions): Promise<WaitResult<T>>;
816
+ /**
817
+ * Wait for multiple jobs to complete
818
+ * Returns when all jobs are done (either completed or failed)
819
+ */
820
+ declare function waitForAll<T = unknown>(ctx: RequestContext, jobIds: string[], options?: WaitOptions): Promise<WaitResult<T>[]>;
821
+ /**
822
+ * Wait for any job to complete
823
+ * Returns as soon as one job finishes
824
+ */
825
+ declare function waitForAny<T = unknown>(ctx: RequestContext, jobIds: string[], options?: WaitOptions): Promise<WaitResult<T>>;
826
+ /**
827
+ * Poll with custom condition
828
+ * Generic polling utility
829
+ */
830
+ declare function pollUntil<T>(fetchFn: () => Promise<T>, conditionFn: (data: T) => boolean, options?: {
831
+ pollInterval?: number;
832
+ timeout?: number;
833
+ signal?: AbortSignal;
834
+ }): Promise<T>;
835
+
836
+ /**
837
+ * SDK Request Options Types
838
+ * These types define the options for SDK methods
839
+ */
840
+ /** Screenshot capture options */
841
+ interface ScreenshotOptions {
842
+ /** Enable screenshot capture */
843
+ enabled: boolean;
844
+ /** Capture full page or viewport only (default: false) */
845
+ fullPage?: boolean;
846
+ /** Viewport width in pixels (default: 1280, min: 320, max: 3840) */
847
+ width?: number;
848
+ /** Viewport height in pixels (default: 720, min: 240, max: 2160) */
849
+ height?: number;
850
+ /** Image format (default: png) */
851
+ format?: "png" | "jpeg" | "webp";
852
+ /** JPEG/WebP quality 0-100 (default: 80, only for jpeg/webp) */
853
+ quality?: number;
854
+ }
855
+ /** Options for scraping a single page */
856
+ interface ScrapeOptions {
857
+ /** URL to scrape (required) */
858
+ url: string;
859
+ /** Detect signals like prices, discounts, urgency (default: true) */
860
+ detectSignals?: boolean;
861
+ /** Extract content using AI */
862
+ extractWithAI?: boolean;
863
+ /** Extract deal-specific information (product, price, discount, urgency) */
864
+ extractDeal?: boolean;
865
+ /** Extract MULTIPLE deals from list/category pages */
866
+ extractMultipleDeals?: boolean;
867
+ /** Maximum deals to extract from list pages (default: 20, max: 50) */
868
+ maxDeals?: number;
869
+ /** Use advanced AI model (GPT-4o) for complex pages - higher cost, better quality */
870
+ useAdvancedModel?: boolean;
871
+ /** Minimum deal score threshold (0-100) - only returns deals above this score */
872
+ minDealScore?: number;
873
+ /** Screenshot configuration */
874
+ screenshot?: ScreenshotOptions;
875
+ /** HTML tags to exclude from content (e.g., ["nav", "footer", "aside", "script"]) */
876
+ excludeTags?: string[];
877
+ /** CSS selectors to exclude from content (e.g., [".sidebar", "#comments"]) */
878
+ excludeSelectors?: string[];
879
+ /** Only extract main content area (default: true) */
880
+ onlyMainContent?: boolean;
881
+ /** Custom headers for the request */
882
+ headers?: Record<string, string>;
883
+ /** Timeout in milliseconds (default: 30000, max: 120000) */
884
+ timeout?: number;
885
+ }
886
+ /** Individual URL item for batch scraping */
887
+ interface BatchScrapeItem {
888
+ /** URL to scrape */
889
+ url: string;
890
+ /** Optional reference ID for tracking */
891
+ ref?: string;
892
+ /** Override detectSignals for this URL */
893
+ detectSignals?: boolean;
894
+ /** Override extractWithAI for this URL */
895
+ extractWithAI?: boolean;
896
+ /** Override extractDeal for this URL */
897
+ extractDeal?: boolean;
898
+ /** Override screenshot for this URL */
899
+ screenshot?: ScreenshotOptions;
900
+ /** Override headers for this URL */
901
+ headers?: Record<string, string>;
902
+ /** Override timeout for this URL */
903
+ timeout?: number;
904
+ }
905
+ /** Default options applied to all URLs in a batch */
906
+ interface BatchScrapeDefaults {
907
+ /** Don't save scrape results (zero data retention) */
908
+ noStore?: boolean;
909
+ /** Detect signals like prices, discounts, urgency */
910
+ detectSignals?: boolean;
911
+ /** Extract content using AI */
912
+ extractWithAI?: boolean;
913
+ /** Extract deal-specific information */
914
+ extractDeal?: boolean;
915
+ /** Extract multiple deals from list pages */
916
+ extractMultipleDeals?: boolean;
917
+ /** Maximum deals to extract (default: 20, max: 50) */
918
+ maxDeals?: number;
919
+ /** Use advanced AI model (higher cost, better quality) */
920
+ useAdvancedModel?: boolean;
921
+ /** Minimum deal score threshold (0-100) */
922
+ minDealScore?: number;
923
+ /** Screenshot configuration */
924
+ screenshot?: ScreenshotOptions;
925
+ /** HTML tags to exclude */
926
+ excludeTags?: string[];
927
+ /** CSS selectors to exclude */
928
+ excludeSelectors?: string[];
929
+ /** Only extract main content area */
930
+ onlyMainContent?: boolean;
931
+ /** Custom headers for requests */
932
+ headers?: Record<string, string>;
933
+ /** Timeout in milliseconds */
934
+ timeout?: number;
935
+ }
936
+ /** Options for batch scraping multiple URLs */
937
+ interface BatchScrapeOptions {
938
+ /** Array of URLs to scrape (1-100) */
939
+ urls: BatchScrapeItem[];
940
+ /** Default options applied to all URLs */
941
+ defaults?: BatchScrapeDefaults;
942
+ /** Webhook URL for batch completion notification */
943
+ webhookUrl?: string;
944
+ /** Priority for batch jobs (1-10, higher = faster) */
945
+ priority?: number;
946
+ /** Delay between job submissions in ms (0-5000) */
947
+ delay?: number;
948
+ }
949
+ /** AI provider for search optimization */
950
+ type SearchAiProvider = "openai" | "anthropic";
951
+ /** AI model for search optimization */
952
+ type SearchAiModel = "gpt-4o-mini" | "gpt-4o" | "gpt-4o-2024-11-20" | "o1-mini" | "o1-preview" | "claude-3-5-haiku-20241022" | "claude-3-5-sonnet-20241022" | "claude-3-5-sonnet-20240620" | "claude-3-opus-20240229";
953
+ /** Date range filter for search */
954
+ type SearchDateRange = "day" | "week" | "month" | "year" | "all";
955
+ /** Search filters */
956
+ interface SearchFilters {
957
+ /** Country code (e.g., 'fr', 'us') */
958
+ location?: string;
959
+ /** Language code (e.g., 'fr', 'en') */
960
+ language?: string;
961
+ /** Filter by date range */
962
+ dateRange?: SearchDateRange;
963
+ /** Exclude PDF files from results */
964
+ excludePdf?: boolean;
965
+ /** Limit to specific domain */
966
+ domain?: string;
967
+ /** Must contain these deal keywords (OR logic) */
968
+ dealKeywords?: string[];
969
+ }
970
+ /** Options for web search */
971
+ interface SearchOptions {
972
+ /** Search query (required) */
973
+ query: string;
974
+ /** Maximum number of results (1-100, default: 10) */
975
+ maxResults?: number;
976
+ /** Auto-scrape top results */
977
+ autoScrape?: boolean;
978
+ /** Number of results to auto-scrape (1-10, default: 5) */
979
+ autoScrapeLimit?: number;
980
+ /** Use AI to optimize the search query */
981
+ useAiOptimization?: boolean;
982
+ /** AI provider for query optimization */
983
+ aiProvider?: SearchAiProvider;
984
+ /** AI model to use */
985
+ aiModel?: SearchAiModel;
986
+ /** Enable deal scoring for results (0-100) */
987
+ useDealScoring?: boolean;
988
+ /** Skip cache and force fresh search */
989
+ skipCache?: boolean;
990
+ /** Search filters */
991
+ filters?: SearchFilters;
992
+ /** Webhook for async notifications */
993
+ webhook?: {
994
+ url: string;
995
+ headers?: Record<string, string>;
996
+ };
997
+ }
998
+ /** Options for crawling a website */
999
+ interface CrawlOptions {
1000
+ /** Starting URL for the crawl (required) */
1001
+ url: string;
1002
+ /** Alias for url - Starting URL for the crawl */
1003
+ startUrl?: string;
1004
+ /** Prompt to guide the crawl (optional) */
1005
+ prompt?: string;
1006
+ /** Maximum depth to crawl (default: 3, max: 5) */
1007
+ maxDepth?: number;
1008
+ /** Maximum pages to crawl (default: 100, max: 1000) */
1009
+ maxPages?: number;
1010
+ /** Delay between requests in ms (default: 1000, min: 100, max: 10000) */
1011
+ delayMs?: number;
1012
+ /** Detect signals on crawled pages (default: true) */
1013
+ detectSignals?: boolean;
1014
+ /** Extract content using AI */
1015
+ extractWithAI?: boolean;
1016
+ /** Extract deal-specific information from each page */
1017
+ extractDeal?: boolean;
1018
+ /** Minimum deal score threshold (0-100) */
1019
+ minDealScore?: number;
1020
+ /** Prioritize pages likely to contain deals (default: true) */
1021
+ prioritizeDealPages?: boolean;
1022
+ /** Follow links to external domains (default: false) */
1023
+ followExternalLinks?: boolean;
1024
+ /** List of allowed domains to crawl */
1025
+ allowedDomains?: string[];
1026
+ /** URL patterns to exclude from crawling */
1027
+ excludePatterns?: string[];
1028
+ }
1029
+ /** Crawl template identifier */
1030
+ type CrawlTemplateId = "ecommerce" | "blog" | "docs" | "marketplace" | "custom";
1031
+ /** Crawl template definition */
1032
+ interface CrawlTemplate {
1033
+ id: CrawlTemplateId;
1034
+ name: string;
1035
+ description: string;
1036
+ defaultOptions: Partial<CrawlOptions>;
1037
+ }
1038
+ /** LLM model options for extraction */
1039
+ type ExtractModel = "gpt-4o-mini" | "gpt-4o" | "claude-3-haiku" | "claude-3-sonnet";
1040
+ /** Options for structured data extraction */
1041
+ interface ExtractOptions {
1042
+ /** URL to extract data from (required) */
1043
+ url: string;
1044
+ /** JSON Schema for structured extraction */
1045
+ schema?: Record<string, unknown>;
1046
+ /** Natural language prompt for extraction */
1047
+ prompt?: string;
1048
+ /** Extract only main content or full page (default: true) */
1049
+ onlyMainContent?: boolean;
1050
+ /** HTML tags to exclude from content */
1051
+ excludeTags?: string[];
1052
+ /** CSS selectors to exclude from content */
1053
+ excludeSelectors?: string[];
1054
+ /** LLM model to use (default: gpt-4o-mini) */
1055
+ model?: ExtractModel;
1056
+ /** Temperature for LLM (0-1, default: 0.1) */
1057
+ temperature?: number;
1058
+ /** Webhook configuration for async notification */
1059
+ webhook?: {
1060
+ url: string;
1061
+ headers?: Record<string, string>;
1062
+ };
1063
+ /** Custom headers for the scrape request */
1064
+ headers?: Record<string, string>;
1065
+ /** Timeout in milliseconds */
1066
+ timeout?: number;
1067
+ }
1068
+ /** Options for Google Dork searches */
1069
+ interface DorkOptions {
1070
+ /** Search query (required) */
1071
+ query: string;
1072
+ /** Limit search to specific site */
1073
+ site?: string;
1074
+ /** Search for specific file types */
1075
+ fileType?: string;
1076
+ /** Search for term in URL */
1077
+ inUrl?: string;
1078
+ /** Search for term in title */
1079
+ inTitle?: string;
1080
+ /** Maximum results to return (default: 10, max: 100) */
1081
+ maxResults?: number;
1082
+ /** Region code (2 letter ISO code) */
1083
+ region?: string;
1084
+ }
1085
+ /** Options for getting job deals */
1086
+ interface GetDealsOptions {
1087
+ /** Minimum deal score to filter by */
1088
+ minScore?: number;
1089
+ /** Maximum number of deals to return (default: 50, max: 100) */
1090
+ limit?: number;
1091
+ }
1092
+ /** Job status filter options */
1093
+ type JobStatusFilter = "pending" | "active" | "completed" | "failed" | "delayed" | "paused";
1094
+ /** Job type filter options */
1095
+ type JobTypeFilter = "scrape" | "crawl" | "dork" | "extract";
1096
+ /** Sort order */
1097
+ type SortOrder = "asc" | "desc";
1098
+ /** Options for listing jobs */
1099
+ interface ListJobsOptions {
1100
+ /** Page number (default: 1) */
1101
+ page?: number;
1102
+ /** Items per page (default: 20, max: 100) */
1103
+ limit?: number;
1104
+ /** Filter by job status */
1105
+ status?: JobStatusFilter;
1106
+ /** Filter by job type */
1107
+ type?: JobTypeFilter;
1108
+ /** Sort field */
1109
+ sortBy?: "created_at" | "updated_at" | "status";
1110
+ /** Sort order */
1111
+ sortOrder?: SortOrder;
1112
+ /** Filter from date (ISO string) */
1113
+ fromDate?: string;
1114
+ /** Filter to date (ISO string) */
1115
+ toDate?: string;
1116
+ }
1117
+ /** Options for listing deals */
1118
+ interface ListDealsOptions {
1119
+ /** Page number (default: 1) */
1120
+ page?: number;
1121
+ /** Items per page (default: 20, max: 100) */
1122
+ limit?: number;
1123
+ /** Minimum deal score */
1124
+ minScore?: number;
1125
+ /** Maximum price */
1126
+ maxPrice?: number;
1127
+ /** Filter by category */
1128
+ category?: string;
1129
+ /** Filter by merchant name */
1130
+ merchant?: string;
1131
+ /** Filter by sync status to DealUp */
1132
+ synced?: boolean;
1133
+ /** Sort field */
1134
+ sortBy?: "deal_score" | "current_price" | "discount_percent" | "created_at";
1135
+ /** Sort order */
1136
+ sortOrder?: SortOrder;
1137
+ }
1138
+ /** Export format options */
1139
+ type ExportFormat = "json" | "csv";
1140
+ /** Options for exporting jobs */
1141
+ interface ExportJobsOptions {
1142
+ /** Export format (default: json) */
1143
+ format?: ExportFormat;
1144
+ /** Filter by job status */
1145
+ status?: JobStatusFilter;
1146
+ /** Filter by job type */
1147
+ type?: JobTypeFilter;
1148
+ /** Filter from date (ISO string) */
1149
+ fromDate?: string;
1150
+ /** Filter to date (ISO string) */
1151
+ toDate?: string;
1152
+ }
1153
+ /** Options for exporting deals */
1154
+ interface ExportDealsOptions {
1155
+ /** Export format (default: json) */
1156
+ format?: ExportFormat;
1157
+ /** Minimum deal score */
1158
+ minScore?: number;
1159
+ /** Maximum price */
1160
+ maxPrice?: number;
1161
+ /** Filter by category */
1162
+ category?: string;
1163
+ /** Include raw signals in export */
1164
+ includeRawSignals?: boolean;
1165
+ }
1166
+ /** Webhook event types */
1167
+ type WebhookEvent = "deal.found" | "deal.synced" | "crawl.completed" | "crawl.failed";
1168
+ /** Options for creating a webhook */
1169
+ interface CreateWebhookOptions {
1170
+ /** Event type to subscribe to */
1171
+ event: WebhookEvent;
1172
+ /** URL to receive webhook notifications */
1173
+ url: string;
1174
+ /** Secret for signature verification */
1175
+ secret?: string;
1176
+ /** Only notify for deals above this score (default: 70) */
1177
+ minDealScore?: number;
1178
+ /** Filter by product categories */
1179
+ categories?: string[];
1180
+ /** Active status (default: true) */
1181
+ active?: boolean;
1182
+ }
1183
+ /** Options for updating a webhook */
1184
+ interface UpdateWebhookOptions {
1185
+ /** New URL */
1186
+ url?: string;
1187
+ /** New secret */
1188
+ secret?: string;
1189
+ /** New minimum deal score */
1190
+ minDealScore?: number;
1191
+ /** New categories filter */
1192
+ categories?: string[];
1193
+ /** Active status */
1194
+ active?: boolean;
1195
+ }
1196
+ /**
1197
+ * API key scope - Must match @dealcrawl/shared/src/types/api-key.types.ts
1198
+ * These are the actual scopes enforced by the backend via requireScope() middleware
1199
+ */
1200
+ type ApiKeyScope = "scrape" | "crawl" | "dork" | "extract" | "status" | "data:read" | "data:export" | "keys:manage" | "webhooks:manage";
1201
+ /**
1202
+ * All available scopes (for reference and validation)
1203
+ */
1204
+ declare const ALL_API_KEY_SCOPES: ApiKeyScope[];
1205
+ /**
1206
+ * Default scopes for new keys
1207
+ */
1208
+ declare const DEFAULT_API_KEY_SCOPES: ApiKeyScope[];
1209
+ /** Options for creating an API key */
1210
+ interface CreateApiKeyOptions {
1211
+ /** Key name/description */
1212
+ name: string;
1213
+ /** Scopes for the key */
1214
+ scopes?: ApiKeyScope[];
1215
+ /** Days until expiration (optional) */
1216
+ expiresInDays?: number;
1217
+ /** IP allowlist (optional) */
1218
+ ipAllowlist?: string[];
1219
+ }
1220
+ /** Options for rotating an API key */
1221
+ interface RotateApiKeyOptions {
1222
+ /** New name for the rotated key */
1223
+ newName?: string;
1224
+ }
1225
+ /** Options for listing API keys */
1226
+ interface ListApiKeysOptions {
1227
+ /** Include revoked keys */
1228
+ includeRevoked?: boolean;
1229
+ }
1230
+ /** Options for revoking an API key */
1231
+ interface RevokeApiKeyOptions {
1232
+ /** Reason for revocation */
1233
+ reason?: string;
1234
+ }
1235
+ /** Options for getting API key stats */
1236
+ interface GetApiKeyStatsOptions {
1237
+ /** Number of days to get stats for (default: 7, max: 30) */
1238
+ days?: number;
1239
+ }
1240
+ /** Product category */
1241
+ type ProductCategory = "courses" | "software" | "physical" | "services" | "other";
1242
+ /** Options for updating preferences */
1243
+ interface UpdatePreferencesOptions {
1244
+ /** Preferred product categories */
1245
+ preferredCategories?: ProductCategory[];
1246
+ /** Minimum deal score for notifications */
1247
+ minDealScore?: number;
1248
+ /** Auto-sync deals to DealUp */
1249
+ autoSync?: boolean;
1250
+ /** Enable webhook notifications */
1251
+ webhookEnabled?: boolean;
1252
+ }
1253
+
1254
+ /**
1255
+ * Account Resource
1256
+ * Handles account information and preferences
1257
+ */
1258
+
1259
+ /**
1260
+ * Account resource class
1261
+ * Provides methods for account information and preferences
1262
+ */
1263
+ declare class AccountResource {
1264
+ private ctx;
1265
+ constructor(ctx: RequestContext);
1266
+ /**
1267
+ * Get current account information
1268
+ *
1269
+ * @example
1270
+ * ```ts
1271
+ * const account = await client.account.get();
1272
+ * console.log(account.name);
1273
+ * console.log(account.tier);
1274
+ * console.log(account.usage);
1275
+ * ```
1276
+ */
1277
+ get(): Promise<AccountInfoResponse>;
1278
+ /**
1279
+ * Get detailed account metrics
1280
+ *
1281
+ * @example
1282
+ * ```ts
1283
+ * const metrics = await client.account.getMetrics();
1284
+ * console.log(metrics.dealMetrics.totalDeals);
1285
+ * console.log(metrics.categoryPerformance);
1286
+ * ```
1287
+ */
1288
+ getMetrics(): Promise<AccountMetricsResponse>;
1289
+ /**
1290
+ * Get DealUp sync metrics (pro/enterprise only)
1291
+ *
1292
+ * @example
1293
+ * ```ts
1294
+ * const dealup = await client.account.getDealUpMetrics();
1295
+ * console.log(dealup.sync.totalSynced);
1296
+ * console.log(dealup.sync.clicksGenerated);
1297
+ * ```
1298
+ */
1299
+ getDealUpMetrics(): Promise<DealUpMetricsResponse>;
1300
+ /**
1301
+ * Get crawl recommendations
1302
+ * AI-suggested URLs to crawl based on past performance
1303
+ *
1304
+ * @example
1305
+ * ```ts
1306
+ * const recommendations = await client.account.getRecommendations();
1307
+ * recommendations.recommendations.forEach(r => {
1308
+ * console.log(r.url, r.reason, r.estimatedDeals);
1309
+ * });
1310
+ * ```
1311
+ */
1312
+ getRecommendations(): Promise<RecommendationsResponse>;
1313
+ /**
1314
+ * Get current preferences
1315
+ *
1316
+ * @example
1317
+ * ```ts
1318
+ * const prefs = await client.account.getPreferences();
1319
+ * console.log(prefs.preferences.minDealScore);
1320
+ * console.log(prefs.preferences.autoSync);
1321
+ * ```
1322
+ */
1323
+ getPreferences(): Promise<PreferencesResponse>;
1324
+ /**
1325
+ * Update account preferences
1326
+ *
1327
+ * @example
1328
+ * ```ts
1329
+ * const updated = await client.account.updatePreferences({
1330
+ * minDealScore: 70,
1331
+ * autoSync: true,
1332
+ * preferredCategories: ["software", "courses"]
1333
+ * });
1334
+ * ```
1335
+ */
1336
+ updatePreferences(options: UpdatePreferencesOptions): Promise<UpdatePreferencesResponse>;
1337
+ /**
1338
+ * Track a DealUp click (webhook endpoint)
1339
+ * Used internally by DealUp to track click-through
1340
+ *
1341
+ * @example
1342
+ * ```ts
1343
+ * await client.account.trackClick("deal_abc123", "homepage");
1344
+ * ```
1345
+ */
1346
+ trackClick(dealId: string, source?: string): Promise<{
1347
+ success: boolean;
1348
+ }>;
1349
+ /**
1350
+ * Get remaining quota for a resource
1351
+ *
1352
+ * @example
1353
+ * ```ts
1354
+ * const remaining = await client.account.getRemainingQuota("scrapes");
1355
+ * console.log(`${remaining} scrapes left this period`);
1356
+ * ```
1357
+ */
1358
+ getRemainingQuota(resource: "scrapes" | "crawls" | "dorks"): Promise<number>;
1359
+ /**
1360
+ * Check if account has quota for a resource
1361
+ *
1362
+ * @example
1363
+ * ```ts
1364
+ * if (await client.account.hasQuota("crawls", 5)) {
1365
+ * // Safe to start 5 crawls
1366
+ * }
1367
+ * ```
1368
+ */
1369
+ hasQuota(resource: "scrapes" | "crawls" | "dorks", needed?: number): Promise<boolean>;
1370
+ /**
1371
+ * Get account tier
1372
+ *
1373
+ * @example
1374
+ * ```ts
1375
+ * const tier = await client.account.getTier();
1376
+ * if (tier === "enterprise") {
1377
+ * // Enable advanced features
1378
+ * }
1379
+ * ```
1380
+ */
1381
+ getTier(): Promise<"free" | "pro" | "enterprise">;
1382
+ /**
1383
+ * Check if account is pro or enterprise tier
1384
+ *
1385
+ * @example
1386
+ * ```ts
1387
+ * if (await client.account.isPremium()) {
1388
+ * // Show premium features
1389
+ * }
1390
+ * ```
1391
+ */
1392
+ isPremium(): Promise<boolean>;
1393
+ }
1394
+
1395
+ /**
1396
+ * Crawl Resource
1397
+ * Handles website crawling operations
1398
+ */
1399
+
1400
+ /**
1401
+ * Crawl resource class
1402
+ * Provides methods for website crawling
1403
+ */
1404
+ declare class CrawlResource {
1405
+ private ctx;
1406
+ constructor(ctx: RequestContext);
1407
+ /**
1408
+ * Create a new crawl job
1409
+ *
1410
+ * @example
1411
+ * ```ts
1412
+ * const job = await client.crawl.create({
1413
+ * url: "https://example.com",
1414
+ * maxDepth: 3,
1415
+ * maxPages: 100,
1416
+ * extractDeal: true
1417
+ * });
1418
+ * console.log(job.jobId);
1419
+ * ```
1420
+ */
1421
+ create(options: CrawlOptions): Promise<CrawlJobResponse>;
1422
+ /**
1423
+ * Create a crawl job using a template
1424
+ *
1425
+ * @example
1426
+ * ```ts
1427
+ * const job = await client.crawl.withTemplate("ecommerce", {
1428
+ * url: "https://shop.example.com",
1429
+ * maxPages: 200 // Override template default
1430
+ * });
1431
+ * ```
1432
+ */
1433
+ withTemplate(templateId: CrawlTemplateId, options: CrawlOptions): Promise<CrawlJobResponse>;
1434
+ /**
1435
+ * List available crawl templates
1436
+ *
1437
+ * @example
1438
+ * ```ts
1439
+ * const templates = client.crawl.listTemplates();
1440
+ * templates.forEach(t => console.log(t.name, t.description));
1441
+ * ```
1442
+ */
1443
+ listTemplates(): CrawlTemplate[];
1444
+ /**
1445
+ * Get a specific template by ID
1446
+ *
1447
+ * @example
1448
+ * ```ts
1449
+ * const template = client.crawl.getTemplate("ecommerce");
1450
+ * console.log(template.defaultOptions);
1451
+ * ```
1452
+ */
1453
+ getTemplate(templateId: CrawlTemplateId): CrawlTemplate | undefined;
1454
+ /**
1455
+ * Analyze a URL before crawling
1456
+ * Returns recommended settings based on site structure
1457
+ *
1458
+ * @example
1459
+ * ```ts
1460
+ * const analysis = await client.crawl.analyze("https://shop.example.com");
1461
+ * console.log(analysis.recommendedTemplate);
1462
+ * console.log(analysis.estimatedPages);
1463
+ * ```
1464
+ */
1465
+ analyze(url: string): Promise<CrawlAnalysisResponse>;
1466
+ /**
1467
+ * Crawl a URL with deal extraction enabled
1468
+ * Convenience method for e-commerce crawling
1469
+ *
1470
+ * @example
1471
+ * ```ts
1472
+ * const job = await client.crawl.forDeals("https://shop.example.com", {
1473
+ * minDealScore: 70
1474
+ * });
1475
+ * ```
1476
+ */
1477
+ forDeals(url: string, options?: Omit<CrawlOptions, "url" | "extractDeal" | "prioritizeDealPages">): Promise<CrawlJobResponse>;
1478
+ }
1479
+
1480
+ /**
1481
+ * Data Resource
1482
+ * Handles data retrieval, listing, and export operations
1483
+ */
1484
+
1485
+ /**
1486
+ * Data resource class
1487
+ * Provides methods for accessing job and deal data
1488
+ */
1489
+ declare class DataResource {
1490
+ private ctx;
1491
+ constructor(ctx: RequestContext);
1492
+ /**
1493
+ * List all jobs
1494
+ *
1495
+ * @example
1496
+ * ```ts
1497
+ * const jobs = await client.data.listJobs({
1498
+ * status: "completed",
1499
+ * type: "crawl",
1500
+ * page: 1,
1501
+ * limit: 20
1502
+ * });
1503
+ * console.log(jobs.data);
1504
+ * console.log(jobs.pagination.total);
1505
+ * ```
1506
+ */
1507
+ listJobs(options?: ListJobsOptions): Promise<ListJobsResponse>;
1508
+ /**
1509
+ * Get jobs by status
1510
+ * Convenience method for filtering by status
1511
+ *
1512
+ * @example
1513
+ * ```ts
1514
+ * const activeJobs = await client.data.getJobsByStatus("active");
1515
+ * ```
1516
+ */
1517
+ getJobsByStatus(status: ListJobsOptions["status"], options?: Omit<ListJobsOptions, "status">): Promise<ListJobsResponse>;
1518
+ /**
1519
+ * Get jobs by type
1520
+ * Convenience method for filtering by type
1521
+ *
1522
+ * @example
1523
+ * ```ts
1524
+ * const crawlJobs = await client.data.getJobsByType("crawl");
1525
+ * ```
1526
+ */
1527
+ getJobsByType(type: ListJobsOptions["type"], options?: Omit<ListJobsOptions, "type">): Promise<ListJobsResponse>;
1528
+ /**
1529
+ * Get recent jobs
1530
+ * Convenience method for getting latest jobs
1531
+ *
1532
+ * @example
1533
+ * ```ts
1534
+ * const recentJobs = await client.data.getRecentJobs(10);
1535
+ * ```
1536
+ */
1537
+ getRecentJobs(limit?: number): Promise<ListJobsResponse>;
1538
+ /**
1539
+ * List all deals
1540
+ *
1541
+ * @example
1542
+ * ```ts
1543
+ * const deals = await client.data.listDeals({
1544
+ * minScore: 70,
1545
+ * category: "electronics",
1546
+ * sortBy: "deal_score",
1547
+ * sortOrder: "desc"
1548
+ * });
1549
+ * ```
1550
+ */
1551
+ listDeals(options?: ListDealsOptions): Promise<ListDealsResponse>;
1552
+ /**
1553
+ * Get a single deal by ID
1554
+ *
1555
+ * @example
1556
+ * ```ts
1557
+ * const deal = await client.data.getDeal("deal_abc123");
1558
+ * console.log(deal.product.name);
1559
+ * console.log(deal.pricing.discountPercent);
1560
+ * ```
1561
+ */
1562
+ getDeal(dealId: string): Promise<DealDetails>;
1563
+ /**
1564
+ * Get top deals by score
1565
+ * Convenience method for finding best deals
1566
+ *
1567
+ * @example
1568
+ * ```ts
1569
+ * const topDeals = await client.data.getTopDeals(20, 80);
1570
+ * ```
1571
+ */
1572
+ getTopDeals(limit?: number, minScore?: number): Promise<ListDealsResponse>;
1573
+ /**
1574
+ * Get deals by category
1575
+ * Convenience method for filtering by category
1576
+ *
1577
+ * @example
1578
+ * ```ts
1579
+ * const electronicsDeals = await client.data.getDealsByCategory("electronics");
1580
+ async getDealsByCategory(
1581
+ category: string,
1582
+ options?: Omit<ListDealsOptions, "category">
1583
+ ): Promise<ListDealsResponse> {
1584
+ if (!category || !category.trim()) {
1585
+ throw new Error("category is required and cannot be empty");
1586
+ }
1587
+ return this.listDeals({ category, ...options });
1588
+ } return this.listDeals({ category, ...options });
1589
+ }
1590
+
1591
+ /**
1592
+ * Get unsynced deals (not yet sent to DealUp)
1593
+ *
1594
+ * @example
1595
+ * ```ts
1596
+ * const unsyncedDeals = await client.data.getUnsyncedDeals();
1597
+ * ```
1598
+ */
1599
+ getUnsyncedDeals(options?: Omit<ListDealsOptions, "synced">): Promise<ListDealsResponse>;
1600
+ /**
1601
+ * Export jobs data
1602
+ *
1603
+ * @example
1604
+ * ```ts
1605
+ * // Export as JSON
1606
+ * const jsonData = await client.data.exportJobs({ format: "json" });
1607
+ *
1608
+ * // Export as CSV
1609
+ * const csvData = await client.data.exportJobs({ format: "csv" });
1610
+ * ```
1611
+ */
1612
+ exportJobs(options?: ExportJobsOptions): Promise<string | object[]>;
1613
+ /**
1614
+ * Export deals data
1615
+ *
1616
+ * @example
1617
+ * ```ts
1618
+ * // Export as JSON
1619
+ * const jsonData = await client.data.exportDeals({ format: "json" });
1620
+ *
1621
+ * // Export as CSV with filters
1622
+ * const csvData = await client.data.exportDeals({
1623
+ * format: "csv",
1624
+ * minScore: 70,
1625
+ * category: "software"
1626
+ * });
1627
+ * ```
1628
+ */
1629
+ exportDeals(options?: ExportDealsOptions): Promise<string | object[]>;
1630
+ /**
1631
+ * Get client statistics
1632
+ *
1633
+ * @example
1634
+ * ```ts
1635
+ * const stats = await client.data.getStats();
1636
+ * console.log(stats.totals.deals);
1637
+ * console.log(stats.performance.avgDealScore);
1638
+ * ```
1639
+ */
1640
+ getStats(): Promise<ClientStatsResponse>;
1641
+ }
1642
+
1643
+ /**
1644
+ * Dork Resource
1645
+ * Handles Google Dork search operations
1646
+ */
1647
+
1648
+ /**
1649
+ * Dork resource class
1650
+ * Provides methods for Google Dork searches
1651
+ */
1652
+ declare class DorkResource {
1653
+ private ctx;
1654
+ constructor(ctx: RequestContext);
1655
+ /**
1656
+ * Create a new dork search job
1657
+ *
1658
+ * @example
1659
+ * ```ts
1660
+ * const job = await client.dork.create({
1661
+ * query: "discount coupon",
1662
+ * site: "amazon.com",
1663
+ * maxResults: 20
1664
+ * });
1665
+ * console.log(job.jobId);
1666
+ * ```
1667
+ */
1668
+ create(options: DorkOptions): Promise<DorkJobResponse>;
1669
+ /**
1670
+ * Search for deals on a specific site
1671
+ * Convenience method for finding discount pages
1672
+ *
1673
+ * @example
1674
+ * ```ts
1675
+ * const job = await client.dork.findDeals("amazon.com", {
1676
+ * maxResults: 50
1677
+ * });
1678
+ * ```
1679
+ */
1680
+ findDeals(site: string, options?: Omit<DorkOptions, "query" | "site">): Promise<DorkJobResponse>;
1681
+ /**
1682
+ * Search for product pages on a site
1683
+ * Looks for common product URL patterns
1684
+ *
1685
+ * @example
1686
+ * ```ts
1687
+ * const job = await client.dork.findProducts("shop.example.com", {
1688
+ * maxResults: 100
1689
+ * });
1690
+ * ```
1691
+ */
1692
+ findProducts(site: string, options?: Omit<DorkOptions, "query" | "site" | "inUrl">): Promise<DorkJobResponse>;
1693
+ /**
1694
+ * Search for PDFs on a site
1695
+ * Useful for finding manuals, guides, datasheets
1696
+ *
1697
+ * @example
1698
+ * ```ts
1699
+ * const job = await client.dork.findPDFs("docs.example.com", "user guide");
1700
+ * ```
1701
+ */
1702
+ findPDFs(site: string, query?: string, options?: Omit<DorkOptions, "query" | "site" | "fileType">): Promise<DorkJobResponse>;
1703
+ /**
1704
+ * Search with custom title filter
1705
+ * Find pages with specific terms in title
1706
+ *
1707
+ * @example
1708
+ * ```ts
1709
+ * const job = await client.dork.inTitle("Black Friday", {
1710
+ * site: "bestbuy.com",
1711
+ * maxResults: 30
1712
+ * });
1713
+ * ```
1714
+ */
1715
+ inTitle(titleQuery: string, options?: Omit<DorkOptions, "inTitle">): Promise<DorkJobResponse>;
1716
+ /**
1717
+ * Search with custom URL filter
1718
+ * Find pages with specific terms in URL
1719
+ *
1720
+ * @example
1721
+ * ```ts
1722
+ * const job = await client.dork.inUrl("clearance", {
1723
+ * site: "walmart.com"
1724
+ * });
1725
+ * ```
1726
+ */
1727
+ inUrl(urlQuery: string, options?: Omit<DorkOptions, "inUrl">): Promise<DorkJobResponse>;
1728
+ /**
1729
+ * Build a raw Google dork query string
1730
+ * Useful for preview or debugging
1731
+ *
1732
+ * @example
1733
+ * ```ts
1734
+ * const query = client.dork.buildQuery({
1735
+ * query: "laptop deals",
1736
+ * site: "amazon.com",
1737
+ * inTitle: "discount"
1738
+ * });
1739
+ * // Returns: "laptop deals site:amazon.com intitle:discount"
1740
+ * ```
1741
+ */
1742
+ buildQuery(options: DorkOptions): string;
1743
+ }
1744
+
1745
+ /**
1746
+ * Extract Resource
1747
+ * Handles LLM-based structured data extraction
1748
+ */
1749
+
1750
+ /**
1751
+ * Extract resource class
1752
+ * Provides methods for structured data extraction using LLMs
1753
+ */
1754
+ declare class ExtractResource {
1755
+ private ctx;
1756
+ constructor(ctx: RequestContext);
1757
+ /**
1758
+ * Create a new extraction job
1759
+ * Either schema or prompt must be provided
1760
+ *
1761
+ * @example
1762
+ * ```ts
1763
+ * // Schema-based extraction
1764
+ * const job = await client.extract.create({
1765
+ * url: "https://example.com/product",
1766
+ * schema: {
1767
+ * type: "object",
1768
+ * properties: {
1769
+ * name: { type: "string" },
1770
+ * price: { type: "number" },
1771
+ * features: { type: "array", items: { type: "string" } }
1772
+ * }
1773
+ * }
1774
+ * });
1775
+ *
1776
+ * // Prompt-based extraction
1777
+ * const job = await client.extract.create({
1778
+ * url: "https://example.com/article",
1779
+ * prompt: "Extract the main points and author name"
1780
+ * });
1781
+ * ```
1782
+ */
1783
+ create(options: ExtractOptions): Promise<ExtractJobResponse>;
1784
+ /**
1785
+ * Extract data using a JSON Schema
1786
+ * Convenience method for schema-based extraction
1787
+ *
1788
+ * @example
1789
+ * ```ts
1790
+ * const job = await client.extract.withSchema(
1791
+ * "https://example.com/product",
1792
+ * {
1793
+ * type: "object",
1794
+ * properties: {
1795
+ * name: { type: "string" },
1796
+ * price: { type: "number" }
1797
+ * }
1798
+ * }
1799
+ * );
1800
+ * ```
1801
+ */
1802
+ withSchema(url: string, schema: Record<string, unknown>, options?: Omit<ExtractOptions, "url" | "schema" | "prompt">): Promise<ExtractJobResponse>;
1803
+ /**
1804
+ * Extract data using a natural language prompt
1805
+ * Convenience method for prompt-based extraction
1806
+ *
1807
+ * @example
1808
+ * ```ts
1809
+ * const job = await client.extract.withPrompt(
1810
+ * "https://example.com/article",
1811
+ * "Extract the article title, author, publication date, and a brief summary"
1812
+ * );
1813
+ * ```
1814
+ */
1815
+ withPrompt(url: string, prompt: string, options?: Omit<ExtractOptions, "url" | "schema" | "prompt">): Promise<ExtractJobResponse>;
1816
+ /**
1817
+ * Extract product information from a page
1818
+ * Pre-built schema for common e-commerce use case
1819
+ *
1820
+ * @example
1821
+ * ```ts
1822
+ * const job = await client.extract.product("https://shop.example.com/item");
1823
+ * ```
1824
+ */
1825
+ product(url: string, options?: Omit<ExtractOptions, "url" | "schema" | "prompt">): Promise<ExtractJobResponse>;
1826
+ /**
1827
+ * Extract article/blog post information
1828
+ * Pre-built schema for content extraction
1829
+ *
1830
+ * @example
1831
+ * ```ts
1832
+ * const job = await client.extract.article("https://blog.example.com/post");
1833
+ * ```
1834
+ */
1835
+ article(url: string, options?: Omit<ExtractOptions, "url" | "schema" | "prompt">): Promise<ExtractJobResponse>;
1836
+ /**
1837
+ * Extract contact information from a page
1838
+ * Pre-built schema for contact page scraping
1839
+ *
1840
+ * @example
1841
+ * ```ts
1842
+ * const job = await client.extract.contact("https://example.com/contact");
1843
+ * ```
1844
+ */
1845
+ contact(url: string, options?: Omit<ExtractOptions, "url" | "schema" | "prompt">): Promise<ExtractJobResponse>;
1846
+ }
1847
+
1848
+ /**
1849
+ * Keys Resource
1850
+ * Handles API key management operations
1851
+ */
1852
+
1853
+ /**
1854
+ * Keys resource class
1855
+ * Provides methods for managing API keys
1856
+ */
1857
+ declare class KeysResource {
1858
+ private ctx;
1859
+ constructor(ctx: RequestContext);
1860
+ /**
1861
+ * List all API keys
1862
+ *
1863
+ * @example
1864
+ * ```ts
1865
+ * const keys = await client.keys.list();
1866
+ * keys.keys.forEach(k => {
1867
+ * console.log(k.name, k.prefix, k.isActive);
1868
+ * });
1869
+ * ```
1870
+ */
1871
+ list(options?: ListApiKeysOptions): Promise<ListKeysResponse>;
1872
+ /**
1873
+ * Create a new API key
1874
+ *
1875
+ * @example
1876
+ * ```ts
1877
+ * const newKey = await client.keys.create({
1878
+ * name: "Production Key",
1879
+ * scopes: ["scrape", "crawl", "status", "data:read"],
1880
+ * expiresInDays: 365
1881
+ * });
1882
+ *
1883
+ * // IMPORTANT: Save this key immediately - it won't be shown again!
1884
+ * console.log(newKey.key);
1885
+ * ```
1886
+ */
1887
+ create(options: CreateApiKeyOptions): Promise<CreateKeyResponse>;
1888
+ /**
1889
+ * Get details of a specific key
1890
+ *
1891
+ * @example
1892
+ * ```ts
1893
+ * const key = await client.keys.get("key_abc123");
1894
+ * console.log(key.scopes);
1895
+ * console.log(key.lastUsedAt);
1896
+ * ```
1897
+ */
1898
+ get(keyId: string): Promise<ApiKeyInfo>;
1899
+ /**
1900
+ * Get usage statistics for a key
1901
+ *
1902
+ * @example
1903
+ * ```ts
1904
+ * const stats = await client.keys.getStats("key_abc123", { days: 30 });
1905
+ * console.log(stats.stats.totalRequests);
1906
+ * console.log(stats.stats.byEndpoint);
1907
+ * ```
1908
+ */
1909
+ getStats(keyId: string, options?: GetApiKeyStatsOptions): Promise<KeyStatsResponse>;
1910
+ /**
1911
+ * Rotate an API key (revoke old, create new)
1912
+ *
1913
+ * @example
1914
+ * ```ts
1915
+ * const rotated = await client.keys.rotate("key_abc123", {
1916
+ * newName: "Production Key v2"
1917
+ * });
1918
+ *
1919
+ * // Old key is now invalid
1920
+ * console.log(rotated.oldKeyRevoked); // true
1921
+ *
1922
+ * // Save new key immediately!
1923
+ * console.log(rotated.newKey.key);
1924
+ * ```
1925
+ */
1926
+ rotate(keyId: string, options?: RotateApiKeyOptions): Promise<RotateKeyResponse>;
1927
+ /**
1928
+ * Revoke (delete) an API key
1929
+ *
1930
+ * @example
1931
+ * ```ts
1932
+ * // Simple revoke
1933
+ * await client.keys.revoke("key_abc123");
1934
+ *
1935
+ * // With reason
1936
+ * await client.keys.revoke("key_abc123", {
1937
+ * reason: "Key compromised"
1938
+ * });
1939
+ * ```
1940
+ */
1941
+ revoke(keyId: string, options?: RevokeApiKeyOptions): Promise<DeleteKeyResponse>;
1942
+ /**
1943
+ * Revoke all API keys (except the current one)
1944
+ *
1945
+ * @example
1946
+ * ```ts
1947
+ * // Use with caution!
1948
+ * const result = await client.keys.revokeAll();
1949
+ * console.log(`Revoked ${result.count} keys`);
1950
+ * ```
1951
+ */
1952
+ revokeAll(): Promise<{
1953
+ success: boolean;
1954
+ count: number;
1955
+ }>;
1956
+ /**
1957
+ * Get active keys only
1958
+ *
1959
+ * @example
1960
+ * ```ts
1961
+ * const activeKeys = await client.keys.getActive();
1962
+ * ```
1963
+ */
1964
+ getActive(): Promise<ApiKeyInfo[]>;
1965
+ /**
1966
+ * Check if a key is valid (active and not expired)
1967
+ *
1968
+ * @example
1969
+ * ```ts
1970
+ * const isValid = await client.keys.isValid("key_abc123");
1971
+ * ```
1972
+ */
1973
+ isValid(keyId: string): Promise<boolean>;
1974
+ }
1975
+
1976
+ /**
1977
+ * Scrape Resource
1978
+ * Handles single page and batch scraping operations
1979
+ */
1980
+
1981
+ /**
1982
+ * Scrape resource class
1983
+ * Provides methods for single page scraping
1984
+ */
1985
+ declare class ScrapeResource {
1986
+ private ctx;
1987
+ constructor(ctx: RequestContext);
1988
+ /**
1989
+ * Create a new scrape job
1990
+ *
1991
+ * @example
1992
+ * ```ts
1993
+ * const job = await client.scrape.create({
1994
+ * url: "https://example.com/product",
1995
+ * extractDeal: true,
1996
+ * screenshot: { enabled: true, format: "webp" }
1997
+ * });
1998
+ * console.log(job.jobId);
1999
+ * ```
2000
+ */
2001
+ create(options: ScrapeOptions): Promise<ScrapeJobResponse>;
2002
+ /**
2003
+ * Scrape a URL with deal extraction enabled
2004
+ * Convenience method for common use case
2005
+ *
2006
+ * @example
2007
+ * ```ts
2008
+ * const job = await client.scrape.extractDeal("https://example.com/sale");
2009
+ * ```
2010
+ */
2011
+ extractDeal(url: string, options?: Omit<ScrapeOptions, "url" | "extractDeal">): Promise<ScrapeJobResponse>;
2012
+ /**
2013
+ * Scrape a list page and extract multiple deals
2014
+ * Use for category pages, deal lists, search results
2015
+ *
2016
+ * @example
2017
+ * ```ts
2018
+ * const job = await client.scrape.extractDeals(
2019
+ * "https://amazon.fr/deals",
2020
+ * { maxDeals: 30, useAdvancedModel: true }
2021
+ * );
2022
+ * ```
2023
+ */
2024
+ extractDeals(url: string, options?: Omit<ScrapeOptions, "url" | "extractMultipleDeals">): Promise<ScrapeJobResponse>;
2025
+ /**
2026
+ * Scrape a URL with screenshot capture
2027
+ * Convenience method for screenshot capture
2028
+ *
2029
+ * @example
2030
+ * ```ts
2031
+ * const job = await client.scrape.withScreenshot("https://example.com", {
2032
+ * format: "webp",
2033
+ * fullPage: true
2034
+ * });
2035
+ * ```
2036
+ */
2037
+ withScreenshot(url: string, screenshotOptions?: Omit<ScrapeOptions["screenshot"], "enabled">, options?: Omit<ScrapeOptions, "url" | "screenshot">): Promise<ScrapeJobResponse>;
2038
+ /**
2039
+ * Create a batch scrape job for multiple URLs
2040
+ * Scrapes 1-100 URLs in a single request
2041
+ *
2042
+ * @example
2043
+ * ```ts
2044
+ * const batch = await client.scrape.batch({
2045
+ * urls: [
2046
+ * { url: "https://shop1.com/product1" },
2047
+ * { url: "https://shop2.com/deal", extractDeal: true }
2048
+ * ],
2049
+ * defaults: { detectSignals: true }
2050
+ * });
2051
+ * console.log(batch.batchId, batch.results);
2052
+ * ```
2053
+ */
2054
+ batch(options: BatchScrapeOptions): Promise<BatchScrapeResponse>;
2055
+ /**
2056
+ * Get status of a batch scrape operation
2057
+ *
2058
+ * @example
2059
+ * ```ts
2060
+ * const status = await client.scrape.getBatchStatus(batchId);
2061
+ * console.log(`Completed: ${status.completed}/${status.total}`);
2062
+ * ```
2063
+ */
2064
+ getBatchStatus(batchId: string): Promise<BatchStatusResponse>;
2065
+ /**
2066
+ * Batch scrape with deal extraction enabled for all URLs
2067
+ * Convenience method for deal-focused batch scraping
2068
+ *
2069
+ * @example
2070
+ * ```ts
2071
+ * const batch = await client.scrape.batchForDeals([
2072
+ * "https://shop1.com/sale",
2073
+ * "https://shop2.com/deals"
2074
+ * ]);
2075
+ * ```
2076
+ */
2077
+ batchForDeals(urls: string[], options?: Omit<BatchScrapeOptions, "urls">): Promise<BatchScrapeResponse>;
2078
+ }
2079
+
2080
+ /**
2081
+ * Search Resource
2082
+ * Handles web search operations with AI optimization
2083
+ */
2084
+
2085
+ /**
2086
+ * Search resource class
2087
+ * Provides methods for web search with AI optimization
2088
+ */
2089
+ declare class SearchResource {
2090
+ private ctx;
2091
+ constructor(ctx: RequestContext);
2092
+ /**
2093
+ * Create a new search job
2094
+ *
2095
+ * @example
2096
+ * ```ts
2097
+ * const result = await client.search.create({
2098
+ * query: "laptop deals black friday",
2099
+ * maxResults: 20,
2100
+ * useDealScoring: true
2101
+ * });
2102
+ * ```
2103
+ */
2104
+ create(options: SearchOptions): Promise<SearchJobResponse>;
2105
+ /**
2106
+ * Search with AI query optimization
2107
+ * Convenience method for AI-enhanced searches
2108
+ *
2109
+ * @example
2110
+ * ```ts
2111
+ * const result = await client.search.withAI("iphone discount", {
2112
+ * aiProvider: "openai",
2113
+ * aiModel: "gpt-4o-mini"
2114
+ * });
2115
+ * ```
2116
+ */
2117
+ withAI(query: string, options?: Omit<SearchOptions, "query" | "useAiOptimization">): Promise<SearchJobResponse>;
2118
+ /**
2119
+ * Search with deal scoring enabled
2120
+ * Scores each result for deal relevance (0-100)
2121
+ *
2122
+ * @example
2123
+ * ```ts
2124
+ * const result = await client.search.forDeals("gaming laptop");
2125
+ * ```
2126
+ */
2127
+ forDeals(query: string, options?: Omit<SearchOptions, "query" | "useDealScoring">): Promise<SearchJobResponse>;
2128
+ /**
2129
+ * Search and auto-scrape top results
2130
+ * Creates scrape jobs for the best matching URLs
2131
+ *
2132
+ * @example
2133
+ * ```ts
2134
+ * const result = await client.search.andScrape("promo codes", {
2135
+ * autoScrapeLimit: 5
2136
+ * });
2137
+ * console.log(result.data.scrapedJobIds);
2138
+ * ```
2139
+ */
2140
+ andScrape(query: string, options?: Omit<SearchOptions, "query" | "autoScrape">): Promise<SearchJobResponse>;
2141
+ /**
2142
+ * Check search API status
2143
+ * Returns availability and features info
2144
+ *
2145
+ * @example
2146
+ * ```ts
2147
+ * const status = await client.search.getStatus();
2148
+ * if (status.available) {
2149
+ * console.log(`Provider: ${status.provider}`);
2150
+ * }
2151
+ * ```
2152
+ */
2153
+ getStatus(): Promise<SearchStatusResponse>;
2154
+ }
2155
+
2156
+ /**
2157
+ * Status Resource
2158
+ * Handles job status checking and management
2159
+ */
2160
+
2161
+ /**
2162
+ * Status resource class
2163
+ * Provides methods for checking and managing job status
2164
+ */
2165
+ declare class StatusResource {
2166
+ private ctx;
2167
+ constructor(ctx: RequestContext);
2168
+ /**
2169
+ * Get the status of a job
2170
+ *
2171
+ * @example
2172
+ * ```ts
2173
+ * const status = await client.status.get("job_abc123");
2174
+ * console.log(status.status); // "completed"
2175
+ * console.log(status.result);
2176
+ * ```
2177
+ */
2178
+ get(jobId: string): Promise<JobStatusResponse>;
2179
+ /**
2180
+ * Get deals found by a job
2181
+ *
2182
+ * @example
2183
+ * ```ts
2184
+ * const deals = await client.status.getDeals("job_abc123", {
2185
+ * minScore: 70,
2186
+ * limit: 20
2187
+ * });
2188
+ * console.log(deals.deals);
2189
+ * ```
2190
+ */
2191
+ getDeals(jobId: string, options?: GetDealsOptions): Promise<JobDealsResponse>;
2192
+ /**
2193
+ * Resume a paused or failed job from checkpoint
2194
+ *
2195
+ * @example
2196
+ * ```ts
2197
+ * const resumed = await client.status.resume("job_abc123");
2198
+ * console.log(resumed.newJobId);
2199
+ * ```
2200
+ */
2201
+ resume(jobId: string): Promise<ResumeJobResponse>;
2202
+ /**
2203
+ * Get detailed metrics for a job
2204
+ *
2205
+ * @example
2206
+ * ```ts
2207
+ * const metrics = await client.status.getMetrics("job_abc123");
2208
+ * console.log(metrics.metrics.successRate);
2209
+ * ```
2210
+ */
2211
+ getMetrics(jobId: string): Promise<JobMetricsResponse>;
2212
+ /**
2213
+ * Cancel a pending or active job
2214
+ *
2215
+ * @example
2216
+ * ```ts
2217
+ * const cancelled = await client.status.cancel("job_abc123");
2218
+ * console.log(cancelled.success);
2219
+ * ```
2220
+ */
2221
+ cancel(jobId: string): Promise<CancelJobResponse>;
2222
+ /**
2223
+ * Check if a job is complete
2224
+ * Convenience method for polling
2225
+ *
2226
+ * @example
2227
+ * ```ts
2228
+ * const isComplete = await client.status.isComplete("job_abc123");
2229
+ * ```
2230
+ */
2231
+ isComplete(jobId: string): Promise<boolean>;
2232
+ /**
2233
+ * Check if a job succeeded
2234
+ * Convenience method for result checking
2235
+ *
2236
+ * @example
2237
+ * ```ts
2238
+ * const succeeded = await client.status.succeeded("job_abc123");
2239
+ * ```
2240
+ */
2241
+ succeeded(jobId: string): Promise<boolean>;
2242
+ /**
2243
+ * Get the result of a completed job
2244
+ * Throws if job is not complete
2245
+ *
2246
+ * @example
2247
+ * ```ts
2248
+ * const result = await client.status.getResult("job_abc123");
2249
+ * ```
2250
+ */
2251
+ getResult<T = unknown>(jobId: string): Promise<T>;
2252
+ }
2253
+
2254
+ /**
2255
+ * Webhooks Resource
2256
+ * Handles webhook CRUD operations
2257
+ */
2258
+
2259
+ /**
2260
+ * Webhooks resource class
2261
+ * Provides methods for managing webhooks
2262
+ */
2263
+ declare class WebhooksResource {
2264
+ private ctx;
2265
+ constructor(ctx: RequestContext);
2266
+ /**
2267
+ * Create a new webhook
2268
+ *
2269
+ * @example
2270
+ * ```ts
2271
+ * const webhook = await client.webhooks.create({
2272
+ * event: "deal.found",
2273
+ * url: "https://my-server.com/webhooks/deals",
2274
+ * secret: "my-webhook-secret",
2275
+ * minDealScore: 70
2276
+ * });
2277
+ * console.log(webhook.webhookId);
2278
+ * ```
2279
+ */
2280
+ create(options: CreateWebhookOptions): Promise<CreateWebhookResponse>;
2281
+ /**
2282
+ * List all webhooks
2283
+ *
2284
+ * @example
2285
+ * ```ts
2286
+ * const webhooks = await client.webhooks.list();
2287
+ * webhooks.webhooks.forEach(w => {
2288
+ * console.log(w.event, w.url, w.active);
2289
+ * });
2290
+ * ```
2291
+ */
2292
+ list(): Promise<ListWebhooksResponse>;
2293
+ /**
2294
+ * Get a webhook by ID
2295
+ *
2296
+ * @example
2297
+ * ```ts
2298
+ * const webhook = await client.webhooks.get("webhook_abc123");
2299
+ * console.log(webhook.event);
2300
+ * ```
2301
+ */
2302
+ get(webhookId: string): Promise<WebhookItem>;
2303
+ /**
2304
+ * Update a webhook
2305
+ *
2306
+ * @example
2307
+ * ```ts
2308
+ * const updated = await client.webhooks.update("webhook_abc123", {
2309
+ * minDealScore: 80,
2310
+ * active: false
2311
+ * });
2312
+ * ```
2313
+ */
2314
+ update(webhookId: string, options: UpdateWebhookOptions): Promise<UpdateWebhookResponse>;
2315
+ /**
2316
+ * Delete a webhook
2317
+ *
2318
+ * @example
2319
+ * ```ts
2320
+ * await client.webhooks.delete("webhook_abc123");
2321
+ * ```
2322
+ */
2323
+ delete(webhookId: string): Promise<DeleteWebhookResponse>;
2324
+ /**
2325
+ * Test a webhook by sending a test payload
2326
+ *
2327
+ * @example
2328
+ * ```ts
2329
+ * const result = await client.webhooks.test("webhook_abc123");
2330
+ * if (result.delivered) {
2331
+ * console.log(`Delivered in ${result.responseTime}ms`);
2332
+ * } else {
2333
+ * console.log(`Failed: ${result.error}`);
2334
+ * }
2335
+ * ```
2336
+ */
2337
+ test(webhookId: string): Promise<TestWebhookResponse>;
2338
+ /**
2339
+ * Enable a webhook
2340
+ * Convenience method for activating a webhook
2341
+ *
2342
+ * @example
2343
+ * ```ts
2344
+ * await client.webhooks.enable("webhook_abc123");
2345
+ * ```
2346
+ */
2347
+ enable(webhookId: string): Promise<UpdateWebhookResponse>;
2348
+ /**
2349
+ * Disable a webhook
2350
+ * Convenience method for deactivating a webhook
2351
+ *
2352
+ * @example
2353
+ * ```ts
2354
+ * await client.webhooks.disable("webhook_abc123");
2355
+ * ```
2356
+ */
2357
+ disable(webhookId: string): Promise<UpdateWebhookResponse>;
2358
+ /**
2359
+ * Get active webhooks only
2360
+ *
2361
+ * @example
2362
+ * ```ts
2363
+ * const active = await client.webhooks.getActive();
2364
+ * ```
2365
+ */
2366
+ getActive(): Promise<WebhookItem[]>;
2367
+ /**
2368
+ * Get webhooks by event type
2369
+ *
2370
+ * @example
2371
+ * ```ts
2372
+ * const dealWebhooks = await client.webhooks.getByEvent("deal.found");
2373
+ * ```
2374
+ */
2375
+ getByEvent(event: CreateWebhookOptions["event"]): Promise<WebhookItem[]>;
2376
+ }
2377
+
2378
+ /**
2379
+ * DealCrawl SDK Client
2380
+ * Main entry point for the SDK
2381
+ *
2382
+ * @example
2383
+ * ```ts
2384
+ * import { DealCrawl } from "@dealcrawl/sdk";
2385
+ *
2386
+ * const client = new DealCrawl({ apiKey: "sk_xxx" });
2387
+ *
2388
+ * // Scrape a page
2389
+ * const job = await client.scrape.create({
2390
+ * url: "https://example.com/product",
2391
+ * extractDeal: true
2392
+ * });
2393
+ *
2394
+ * // Wait for result
2395
+ * const result = await client.waitForResult(job.jobId);
2396
+ * console.log(result);
2397
+ * ```
2398
+ */
2399
+
2400
+ /**
2401
+ * DealCrawl SDK Client
2402
+ *
2403
+ * Provides access to all DealCrawl API endpoints through
2404
+ * organized resource classes following a Stripe-like pattern.
2405
+ *
2406
+ * @example
2407
+ * ```ts
2408
+ * const client = new DealCrawl({ apiKey: "sk_xxx" });
2409
+ *
2410
+ * // Core operations
2411
+ * await client.scrape.create({ url: "..." });
2412
+ * await client.crawl.create({ url: "...", maxPages: 100 });
2413
+ * await client.extract.create({ url: "...", schema: {...} });
2414
+ * await client.dork.create({ query: "..." });
2415
+ *
2416
+ * // Status & polling
2417
+ * await client.status.get(jobId);
2418
+ * await client.waitForResult(jobId);
2419
+ *
2420
+ * // Data access
2421
+ * await client.data.listJobs();
2422
+ * await client.data.listDeals();
2423
+ *
2424
+ * // Management
2425
+ * await client.webhooks.create({...});
2426
+ * await client.keys.create({...});
2427
+ * await client.account.get();
2428
+ * ```
2429
+ */
2430
+ declare class DealCrawl {
2431
+ /** Internal request context */
2432
+ private readonly ctx;
2433
+ /**
2434
+ * Scrape resource - Single page and batch scraping
2435
+ *
2436
+ * @example
2437
+ * ```ts
2438
+ * // Single page
2439
+ * const job = await client.scrape.create({
2440
+ * url: "https://example.com",
2441
+ * extractDeal: true
2442
+ * });
2443
+ *
2444
+ * // Batch scraping
2445
+ * const batch = await client.scrape.batch({
2446
+ * urls: [{ url: "https://shop1.com" }, { url: "https://shop2.com" }]
2447
+ * });
2448
+ * ```
2449
+ */
2450
+ readonly scrape: ScrapeResource;
2451
+ /**
2452
+ * Search resource - Web search with AI optimization
2453
+ *
2454
+ * @example
2455
+ * ```ts
2456
+ * const result = await client.search.create({
2457
+ * query: "laptop deals",
2458
+ * useDealScoring: true
2459
+ * });
2460
+ *
2461
+ * // With AI optimization
2462
+ * const result = await client.search.withAI("iphone discount");
2463
+ * ```
2464
+ */
2465
+ readonly search: SearchResource;
2466
+ /**
2467
+ * Crawl resource - Website crawling
2468
+ *
2469
+ * @example
2470
+ * ```ts
2471
+ * const job = await client.crawl.create({
2472
+ * url: "https://shop.example.com",
2473
+ * maxPages: 100
2474
+ * });
2475
+ *
2476
+ * // With template
2477
+ * const job = await client.crawl.withTemplate("ecommerce", {
2478
+ * url: "https://shop.example.com"
2479
+ * });
2480
+ * ```
2481
+ */
2482
+ readonly crawl: CrawlResource;
2483
+ /**
2484
+ * Extract resource - LLM-based structured data extraction
2485
+ *
2486
+ * @example
2487
+ * ```ts
2488
+ * const job = await client.extract.create({
2489
+ * url: "https://example.com/product",
2490
+ * schema: { type: "object", properties: {...} }
2491
+ * });
2492
+ * ```
2493
+ */
2494
+ readonly extract: ExtractResource;
2495
+ /**
2496
+ * Dork resource - Google Dork searches
2497
+ *
2498
+ * @example
2499
+ * ```ts
2500
+ * const job = await client.dork.create({
2501
+ * query: "discount coupon",
2502
+ * site: "amazon.com"
2503
+ * });
2504
+ * ```
2505
+ */
2506
+ readonly dork: DorkResource;
2507
+ /**
2508
+ * Status resource - Job status management
2509
+ *
2510
+ * @example
2511
+ * ```ts
2512
+ * const status = await client.status.get(jobId);
2513
+ * const deals = await client.status.getDeals(jobId);
2514
+ * await client.status.cancel(jobId);
2515
+ * ```
2516
+ */
2517
+ readonly status: StatusResource;
2518
+ /**
2519
+ * Data resource - Jobs and deals data access
2520
+ *
2521
+ * @example
2522
+ * ```ts
2523
+ * const jobs = await client.data.listJobs();
2524
+ * const deals = await client.data.listDeals({ minScore: 70 });
2525
+ * const stats = await client.data.getStats();
2526
+ * ```
2527
+ */
2528
+ readonly data: DataResource;
2529
+ /**
2530
+ * Webhooks resource - Webhook management
2531
+ *
2532
+ * @example
2533
+ * ```ts
2534
+ * await client.webhooks.create({
2535
+ * event: "deal.found",
2536
+ * url: "https://..."
2537
+ * });
2538
+ * ```
2539
+ */
2540
+ readonly webhooks: WebhooksResource;
2541
+ /**
2542
+ * Keys resource - API key management
2543
+ *
2544
+ * @example
2545
+ * ```ts
2546
+ * const newKey = await client.keys.create({
2547
+ * name: "Production",
2548
+ * scopes: ["scrape", "status"]
2549
+ * });
2550
+ * ```
2551
+ */
2552
+ readonly keys: KeysResource;
2553
+ /**
2554
+ * Account resource - Account info and preferences
2555
+ *
2556
+ * @example
2557
+ * ```ts
2558
+ * const account = await client.account.get();
2559
+ * await client.account.updatePreferences({
2560
+ * minDealScore: 70
2561
+ * });
2562
+ * ```
2563
+ */
2564
+ readonly account: AccountResource;
2565
+ /**
2566
+ * Create a new DealCrawl client
2567
+ *
2568
+ * @param config - Client configuration
2569
+ *
2570
+ * @example
2571
+ * ```ts
2572
+ * // Minimal config
2573
+ * const client = new DealCrawl({ apiKey: "sk_xxx" });
2574
+ *
2575
+ * // Full config
2576
+ * const client = new DealCrawl({
2577
+ * apiKey: "sk_xxx",
2578
+ * baseUrl: "https://api.dealcrawl.dev",
2579
+ * timeout: 30000,
2580
+ * maxRetries: 3,
2581
+ * retryDelay: 1000,
2582
+ * onRateLimit: (info) => console.log("Rate limited!", info)
2583
+ * });
2584
+ * ```
2585
+ */
2586
+ constructor(config: DealCrawlConfig);
2587
+ /**
2588
+ * Wait for a job to complete
2589
+ * Polls the status endpoint until the job finishes
2590
+ *
2591
+ * @example
2592
+ * ```ts
2593
+ * const job = await client.scrape.create({ url: "..." });
2594
+ *
2595
+ * // Simple wait
2596
+ * const result = await client.waitForResult(job.jobId);
2597
+ *
2598
+ * // With options
2599
+ * const result = await client.waitForResult(job.jobId, {
2600
+ * pollInterval: 1000,
2601
+ * timeout: 60000,
2602
+ * onProgress: (status) => console.log(status.progress)
2603
+ * });
2604
+ * ```
2605
+ */
2606
+ waitForResult<T = unknown>(jobId: string, options?: WaitOptions): Promise<WaitResult<T>>;
2607
+ /**
2608
+ * Wait for multiple jobs to complete
2609
+ * Returns when all jobs are done
2610
+ *
2611
+ * @example
2612
+ * ```ts
2613
+ * const jobs = await Promise.all([
2614
+ * client.scrape.create({ url: "url1" }),
2615
+ * client.scrape.create({ url: "url2" }),
2616
+ * ]);
2617
+ *
2618
+ * const results = await client.waitForAll(jobs.map(j => j.jobId));
2619
+ * ```
2620
+ */
2621
+ waitForAll<T = unknown>(jobIds: string[], options?: WaitOptions): Promise<WaitResult<T>[]>;
2622
+ /**
2623
+ * Wait for any job to complete
2624
+ * Returns as soon as one job finishes
2625
+ *
2626
+ * @example
2627
+ * ```ts
2628
+ * const jobIds = ["job1", "job2", "job3"];
2629
+ * const firstResult = await client.waitForAny(jobIds);
2630
+ * ```
2631
+ */
2632
+ waitForAny<T = unknown>(jobIds: string[], options?: WaitOptions): Promise<WaitResult<T>>;
2633
+ /**
2634
+ * Scrape a URL and wait for result
2635
+ * Combines create and waitForResult
2636
+ *
2637
+ * @example
2638
+ * ```ts
2639
+ * const result = await client.scrapeAndWait({
2640
+ * url: "https://example.com",
2641
+ * extractDeal: true
2642
+ * });
2643
+ * ```
2644
+ */
2645
+ scrapeAndWait<T = unknown>(options: Parameters<ScrapeResource["create"]>[0], waitOptions?: WaitOptions): Promise<WaitResult<T>>;
2646
+ /**
2647
+ * Crawl a URL and wait for result
2648
+ * Combines create and waitForResult
2649
+ *
2650
+ * @example
2651
+ * ```ts
2652
+ * const result = await client.crawlAndWait({
2653
+ * url: "https://shop.example.com",
2654
+ * maxPages: 50
2655
+ * });
2656
+ * ```
2657
+ */
2658
+ crawlAndWait<T = unknown>(options: Parameters<CrawlResource["create"]>[0], waitOptions?: WaitOptions): Promise<WaitResult<T>>;
2659
+ /**
2660
+ * Extract data and wait for result
2661
+ * Combines create and waitForResult
2662
+ *
2663
+ * @example
2664
+ * ```ts
2665
+ * const result = await client.extractAndWait({
2666
+ * url: "https://example.com/product",
2667
+ * schema: { type: "object", properties: {...} }
2668
+ * });
2669
+ * ```
2670
+ */
2671
+ extractAndWait<T = unknown>(options: Parameters<ExtractResource["create"]>[0], waitOptions?: WaitOptions): Promise<WaitResult<T>>;
2672
+ /**
2673
+ * Search and return results directly
2674
+ * Note: Search is synchronous, no waiting needed
2675
+ *
2676
+ * @example
2677
+ * ```ts
2678
+ * const result = await client.searchAndWait({
2679
+ * query: "gaming laptop deals",
2680
+ * useDealScoring: true
2681
+ * });
2682
+ * console.log(result.data.results);
2683
+ * ```
2684
+ */
2685
+ searchAndWait(options: Parameters<SearchResource["create"]>[0]): Promise<ReturnType<SearchResource["create"]>>;
2686
+ }
2687
+
2688
+ /**
2689
+ * Error codes used by DealCrawl API
2690
+ * Copied from @dealcrawl/shared to avoid bundling the entire package
2691
+ */
2692
+ declare const ERROR_CODES: {
2693
+ readonly INVALID_API_KEY: "INVALID_API_KEY";
2694
+ readonly MISSING_API_KEY: "MISSING_API_KEY";
2695
+ readonly API_KEY_EXPIRED: "API_KEY_EXPIRED";
2696
+ readonly ACCOUNT_SUSPENDED: "ACCOUNT_SUSPENDED";
2697
+ readonly RATE_LIMIT_EXCEEDED: "RATE_LIMIT_EXCEEDED";
2698
+ readonly QUOTA_EXCEEDED: "QUOTA_EXCEEDED";
2699
+ readonly INVALID_URL: "INVALID_URL";
2700
+ readonly INVALID_REQUEST: "INVALID_REQUEST";
2701
+ readonly MISSING_REQUIRED_FIELD: "MISSING_REQUIRED_FIELD";
2702
+ readonly JOB_NOT_FOUND: "JOB_NOT_FOUND";
2703
+ readonly JOB_FAILED: "JOB_FAILED";
2704
+ readonly JOB_TIMEOUT: "JOB_TIMEOUT";
2705
+ readonly FETCH_FAILED: "FETCH_FAILED";
2706
+ readonly PARSE_FAILED: "PARSE_FAILED";
2707
+ readonly BLOCKED_BY_ROBOTS: "BLOCKED_BY_ROBOTS";
2708
+ readonly CAPTCHA_DETECTED: "CAPTCHA_DETECTED";
2709
+ readonly SITE_UNREACHABLE: "SITE_UNREACHABLE";
2710
+ readonly INTERNAL_ERROR: "INTERNAL_ERROR";
2711
+ readonly SERVICE_UNAVAILABLE: "SERVICE_UNAVAILABLE";
2712
+ readonly REDIS_ERROR: "REDIS_ERROR";
2713
+ readonly DATABASE_ERROR: "DATABASE_ERROR";
2714
+ };
2715
+ type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];
2716
+ /**
2717
+ * Custom error class for DealCrawl SDK
2718
+ * Provides structured error handling with error codes
2719
+ */
2720
+ declare class DealCrawlError extends Error {
2721
+ /** Error code from ERROR_CODES */
2722
+ readonly code: ErrorCode;
2723
+ /** HTTP status code from the API response */
2724
+ readonly statusCode: number;
2725
+ /** Additional error details */
2726
+ readonly details?: Record<string, unknown>;
2727
+ /** Retry-After header value in seconds (for rate limiting) */
2728
+ readonly retryAfter?: number;
2729
+ constructor(options: {
2730
+ code: ErrorCode;
2731
+ message: string;
2732
+ statusCode?: number;
2733
+ details?: Record<string, unknown>;
2734
+ retryAfter?: number;
2735
+ });
2736
+ /**
2737
+ * Check if the error is retryable
2738
+ * Rate limits and transient errors are retryable
2739
+ */
2740
+ isRetryable(): boolean;
2741
+ /**
2742
+ * Check if the error is due to authentication issues
2743
+ */
2744
+ isAuthError(): boolean;
2745
+ /**
2746
+ * Check if the error is due to rate limiting
2747
+ */
2748
+ isRateLimited(): boolean;
2749
+ /**
2750
+ * Check if the error is due to quota exceeded
2751
+ */
2752
+ isQuotaExceeded(): boolean;
2753
+ /**
2754
+ * Convert error to JSON-serializable object
2755
+ */
2756
+ toJSON(): Record<string, unknown>;
2757
+ /**
2758
+ * Create a DealCrawlError from an API error response
2759
+ */
2760
+ static fromResponse(statusCode: number, body: {
2761
+ code?: string;
2762
+ message?: string;
2763
+ error?: string;
2764
+ details?: Record<string, unknown>;
2765
+ retryAfter?: number;
2766
+ }, retryAfter?: number | string | null): DealCrawlError;
2767
+ }
2768
+
2769
+ export { ALL_API_KEY_SCOPES, type AccountInfoResponse, type AccountMetricsResponse, AccountResource, type ApiError, type ApiKeyInfo, type ApiKeyScope, type ApiResponse, type BatchScrapeDefaults, type BatchScrapeItem, type BatchScrapeOptions, type BatchScrapeResponse, type BatchScrapeResultItem, type BatchStatusResponse, type CancelJobResponse, type CheckpointInfo, type ClientPreferences, type ClientStatsResponse, type CrawlAnalysisResponse, type CrawlJobResponse, type CrawlOptions, type CrawlRecommendation, CrawlResource, type CrawlResult, type CrawlTemplate, type CrawlTemplateId, type CreateApiKeyOptions, type CreateKeyResponse, type CreateWebhookOptions, type CreateWebhookResponse, type CreatedApiKey, DEFAULT_API_KEY_SCOPES, DEFAULT_CONFIG, DataResource, DealCrawl, type DealCrawlConfig, DealCrawlError, type DealDetails, type DealItem, type DealMetrics, type DealScoreSummary, type DealSummary, type DealUpMetrics, type DealUpMetricsResponse, type DeleteKeyResponse, type DeleteWebhookResponse, type DiscountSignal, type DorkJobResponse, type DorkOptions, DorkResource, type DorkResult, ERROR_CODES, type ErrorCode, type ExportDealsOptions, type ExportFormat, type ExportJobsOptions, type ExtractJobResponse, type ExtractModel, type ExtractOptions, ExtractResource, type ExtractedDeal, type GetApiKeyStatsOptions, type GetDealsOptions, type JobDealsResponse, type JobMetricsResponse, type JobResponse, type JobStatus, type JobStatusFilter, type JobStatusResponse, type JobSummary, type JobTypeFilter, type KeyStatsResponse, KeysResource, type ListApiKeysOptions, type ListDealsOptions, type ListDealsResponse, type ListJobsOptions, type ListJobsResponse, type ListKeysResponse, type ListWebhooksResponse, type PaginatedResponse, type PaginationInfo, type ParsedPage, type PreferencesResponse, type PriceSignal, type PricingInfo, type ProductCategory, type ProductInfo, type RateLimitInfo, type RecommendationsResponse, type RequestContext, type ResumeJobResponse, type RevokeApiKeyOptions, type RotateApiKeyOptions, type RotateKeyResponse, type ScrapeJobResponse, type ScrapeOptions, ScrapeResource, type ScrapeResult, type ScreenshotOptions, type SearchAiModel, type SearchAiProvider, type SearchData, type SearchDateRange, type SearchFilters, type SearchJobResponse, type SearchOptions, SearchResource, type SearchResultItem, type SearchStatusResponse, type Signal, type SortOrder, StatusResource, type TestWebhookResponse, type UpdatePreferencesOptions, type UpdatePreferencesResponse, type UpdateWebhookOptions, type UpdateWebhookResponse, type UsageStats, type WaitOptions, type WaitResult, type WebhookEvent, type WebhookItem, WebhooksResource, DealCrawl as default, pollUntil, waitForAll, waitForAny, waitForResult };