@dealcrawl/sdk 2.1.1 → 2.1.3

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