@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
package/dist/error.js DELETED
@@ -1,128 +0,0 @@
1
- import { ERROR_CODES, } from "./types/shared";
2
- /**
3
- * Custom error class for DealCrawl SDK
4
- * Provides structured error handling with error codes
5
- */
6
- export class DealCrawlError extends Error {
7
- /** Error code from ERROR_CODES */
8
- code;
9
- /** HTTP status code from the API response */
10
- statusCode;
11
- /** Additional error details */
12
- details;
13
- /** Retry-After header value in seconds (for rate limiting) */
14
- retryAfter;
15
- constructor(options) {
16
- super(options.message);
17
- this.name = "DealCrawlError";
18
- this.code = options.code;
19
- this.statusCode = options.statusCode ?? 500;
20
- this.details = options.details;
21
- this.retryAfter = options.retryAfter;
22
- // Maintains proper stack trace for where our error was thrown
23
- if (Error.captureStackTrace) {
24
- Error.captureStackTrace(this, DealCrawlError);
25
- }
26
- }
27
- /**
28
- * Check if the error is retryable
29
- * Rate limits and transient errors are retryable
30
- */
31
- isRetryable() {
32
- const retryableCodes = [
33
- ERROR_CODES.RATE_LIMIT_EXCEEDED,
34
- ERROR_CODES.SERVICE_UNAVAILABLE,
35
- ERROR_CODES.REDIS_ERROR,
36
- ERROR_CODES.DATABASE_ERROR,
37
- ];
38
- return retryableCodes.includes(this.code);
39
- }
40
- /**
41
- * Check if the error is due to authentication issues
42
- */
43
- isAuthError() {
44
- const authCodes = [
45
- ERROR_CODES.INVALID_API_KEY,
46
- ERROR_CODES.MISSING_API_KEY,
47
- ERROR_CODES.API_KEY_EXPIRED,
48
- ERROR_CODES.ACCOUNT_SUSPENDED,
49
- ];
50
- return authCodes.includes(this.code);
51
- }
52
- /**
53
- * Check if the error is due to rate limiting
54
- */
55
- isRateLimited() {
56
- return this.code === ERROR_CODES.RATE_LIMIT_EXCEEDED;
57
- }
58
- /**
59
- * Check if the error is due to quota exceeded
60
- */
61
- isQuotaExceeded() {
62
- return this.code === ERROR_CODES.QUOTA_EXCEEDED;
63
- }
64
- /**
65
- * Convert error to JSON-serializable object
66
- */
67
- toJSON() {
68
- return {
69
- name: this.name,
70
- code: this.code,
71
- message: this.message,
72
- statusCode: this.statusCode,
73
- details: this.details,
74
- retryAfter: this.retryAfter,
75
- };
76
- }
77
- /**
78
- * Create a DealCrawlError from an API error response
79
- */
80
- static fromResponse(statusCode, body, retryAfter) {
81
- const code = body.code || mapStatusCodeToErrorCode(statusCode);
82
- const message = body.message || body.error || "An error occurred";
83
- // Parse retryAfter from parameter or body
84
- let parsedRetryAfter;
85
- if (retryAfter !== null && retryAfter !== undefined) {
86
- parsedRetryAfter =
87
- typeof retryAfter === "string" ? parseInt(retryAfter, 10) : retryAfter;
88
- if (isNaN(parsedRetryAfter)) {
89
- parsedRetryAfter = undefined;
90
- }
91
- }
92
- else if (body.retryAfter !== undefined) {
93
- parsedRetryAfter = body.retryAfter;
94
- }
95
- return new DealCrawlError({
96
- code,
97
- message,
98
- statusCode,
99
- details: body.details,
100
- retryAfter: parsedRetryAfter,
101
- });
102
- }
103
- }
104
- /**
105
- * Map HTTP status codes to error codes
106
- */
107
- function mapStatusCodeToErrorCode(statusCode) {
108
- switch (statusCode) {
109
- case 400:
110
- return ERROR_CODES.INVALID_REQUEST;
111
- case 401:
112
- return ERROR_CODES.INVALID_API_KEY;
113
- case 403:
114
- return ERROR_CODES.ACCOUNT_SUSPENDED;
115
- case 404:
116
- return ERROR_CODES.JOB_NOT_FOUND;
117
- case 429:
118
- return ERROR_CODES.RATE_LIMIT_EXCEEDED;
119
- case 500:
120
- return ERROR_CODES.INTERNAL_ERROR;
121
- case 503:
122
- return ERROR_CODES.SERVICE_UNAVAILABLE;
123
- default:
124
- return ERROR_CODES.INTERNAL_ERROR;
125
- }
126
- }
127
- export { ERROR_CODES };
128
- //# sourceMappingURL=error.js.map
package/dist/error.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,GAEZ,MAAM,gBAAgB,CAAC;AAExB;;;GAGG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,kCAAkC;IACzB,IAAI,CAAY;IAEzB,6CAA6C;IACpC,UAAU,CAAS;I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O,EAAE,SAAS,IAAI,OAAO,EAAE,MAAM,UAAU,CAAC"}
@@ -1,143 +0,0 @@
1
- /**
2
- * Account Resource
3
- * Handles account information and preferences
4
- */
5
- import type { RequestContext } from "../types/config";
6
- import type { UpdatePreferencesOptions } from "../types/options";
7
- import type { AccountInfoResponse, AccountMetricsResponse, DealUpMetricsResponse, RecommendationsResponse, PreferencesResponse, UpdatePreferencesResponse } from "../types/responses";
8
- /**
9
- * Account resource class
10
- * Provides methods for account information and preferences
11
- */
12
- export declare class AccountResource {
13
- private ctx;
14
- constructor(ctx: RequestContext);
15
- /**
16
- * Get current account information
17
- *
18
- * @example
19
- * ```ts
20
- * const account = await client.account.get();
21
- * console.log(account.name);
22
- * console.log(account.tier);
23
- * console.log(account.usage);
24
- * ```
25
- */
26
- get(): Promise<AccountInfoResponse>;
27
- /**
28
- * Get detailed account metrics
29
- *
30
- * @example
31
- * ```ts
32
- * const metrics = await client.account.getMetrics();
33
- * console.log(metrics.dealMetrics.totalDeals);
34
- * console.log(metrics.categoryPerformance);
35
- * ```
36
- */
37
- getMetrics(): Promise<AccountMetricsResponse>;
38
- /**
39
- * Get DealUp sync metrics (pro/enterprise only)
40
- *
41
- * @example
42
- * ```ts
43
- * const dealup = await client.account.getDealUpMetrics();
44
- * console.log(dealup.sync.totalSynced);
45
- * console.log(dealup.sync.clicksGenerated);
46
- * ```
47
- */
48
- getDealUpMetrics(): Promise<DealUpMetricsResponse>;
49
- /**
50
- * Get crawl recommendations
51
- * AI-suggested URLs to crawl based on past performance
52
- *
53
- * @example
54
- * ```ts
55
- * const recommendations = await client.account.getRecommendations();
56
- * recommendations.recommendations.forEach(r => {
57
- * console.log(r.url, r.reason, r.estimatedDeals);
58
- * });
59
- * ```
60
- */
61
- getRecommendations(): Promise<RecommendationsResponse>;
62
- /**
63
- * Get current preferences
64
- *
65
- * @example
66
- * ```ts
67
- * const prefs = await client.account.getPreferences();
68
- * console.log(prefs.preferences.minDealScore);
69
- * console.log(prefs.preferences.autoSync);
70
- * ```
71
- */
72
- getPreferences(): Promise<PreferencesResponse>;
73
- /**
74
- * Update account preferences
75
- *
76
- * @example
77
- * ```ts
78
- * const updated = await client.account.updatePreferences({
79
- * minDealScore: 70,
80
- * autoSync: true,
81
- * preferredCategories: ["software", "courses"]
82
- * });
83
- * ```
84
- */
85
- updatePreferences(options: UpdatePreferencesOptions): Promise<UpdatePreferencesResponse>;
86
- /**
87
- * Track a DealUp click (webhook endpoint)
88
- * Used internally by DealUp to track click-through
89
- *
90
- * @example
91
- * ```ts
92
- * await client.account.trackClick("deal_abc123", "homepage");
93
- * ```
94
- */
95
- trackClick(dealId: string, source?: string): Promise<{
96
- success: boolean;
97
- }>;
98
- /**
99
- * Get remaining quota for a resource
100
- *
101
- * @example
102
- * ```ts
103
- * const remaining = await client.account.getRemainingQuota("scrapes");
104
- * console.log(`${remaining} scrapes left this period`);
105
- * ```
106
- */
107
- getRemainingQuota(resource: "scrapes" | "crawls" | "dorks"): Promise<number>;
108
- /**
109
- * Check if account has quota for a resource
110
- *
111
- * @example
112
- * ```ts
113
- * if (await client.account.hasQuota("crawls", 5)) {
114
- * // Safe to start 5 crawls
115
- * }
116
- * ```
117
- */
118
- hasQuota(resource: "scrapes" | "crawls" | "dorks", needed?: number): Promise<boolean>;
119
- /**
120
- * Get account tier
121
- *
122
- * @example
123
- * ```ts
124
- * const tier = await client.account.getTier();
125
- * if (tier === "enterprise") {
126
- * // Enable advanced features
127
- * }
128
- * ```
129
- */
130
- getTier(): Promise<"free" | "pro" | "enterprise">;
131
- /**
132
- * Check if account is pro or enterprise tier
133
- *
134
- * @example
135
- * ```ts
136
- * if (await client.account.isPremium()) {
137
- * // Show premium features
138
- * }
139
- * ```
140
- */
141
- isPremium(): Promise<boolean>;
142
- }
143
- //# sourceMappingURL=account.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/resources/account.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OA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AY,CAAC;IAKvD;;;;;;;;;OASG;IACG,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;CAIpC"}
@@ -1,186 +0,0 @@
1
- /**
2
- * Account Resource
3
- * Handles account information and preferences
4
- */
5
- import { get, patch, post } from "../utils/request";
6
- /**
7
- * Account resource class
8
- * Provides methods for account information and preferences
9
- */
10
- export class AccountResource {
11
- ctx;
12
- constructor(ctx) {
13
- this.ctx = ctx;
14
- }
15
- /**
16
- * Get current account information
17
- *
18
- * @example
19
- * ```ts
20
- * const account = await client.account.get();
21
- * console.log(account.name);
22
- * console.log(account.tier);
23
- * console.log(account.usage);
24
- * ```
25
- */
26
- async get() {
27
- const result = await get(this.ctx, "/v1/client");
28
- return result.data;
29
- }
30
- /**
31
- * Get detailed account metrics
32
- *
33
- * @example
34
- * ```ts
35
- * const metrics = await client.account.getMetrics();
36
- * console.log(metrics.dealMetrics.totalDeals);
37
- * console.log(metrics.categoryPerformance);
38
- * ```
39
- */
40
- async getMetrics() {
41
- const result = await get(this.ctx, "/v1/client/metrics");
42
- return result.data;
43
- }
44
- /**
45
- * Get DealUp sync metrics (pro/enterprise only)
46
- *
47
- * @example
48
- * ```ts
49
- * const dealup = await client.account.getDealUpMetrics();
50
- * console.log(dealup.sync.totalSynced);
51
- * console.log(dealup.sync.clicksGenerated);
52
- * ```
53
- */
54
- async getDealUpMetrics() {
55
- const result = await get(this.ctx, "/v1/client/dealup");
56
- return result.data;
57
- }
58
- /**
59
- * Get crawl recommendations
60
- * AI-suggested URLs to crawl based on past performance
61
- *
62
- * @example
63
- * ```ts
64
- * const recommendations = await client.account.getRecommendations();
65
- * recommendations.recommendations.forEach(r => {
66
- * console.log(r.url, r.reason, r.estimatedDeals);
67
- * });
68
- * ```
69
- */
70
- async getRecommendations() {
71
- const result = await get(this.ctx, "/v1/client/recommendations");
72
- return result.data;
73
- }
74
- /**
75
- * Get current preferences
76
- *
77
- * @example
78
- * ```ts
79
- * const prefs = await client.account.getPreferences();
80
- * console.log(prefs.preferences.minDealScore);
81
- * console.log(prefs.preferences.autoSync);
82
- * ```
83
- */
84
- async getPreferences() {
85
- const result = await get(this.ctx, "/v1/client/preferences");
86
- return result.data;
87
- }
88
- /**
89
- * Update account preferences
90
- *
91
- * @example
92
- * ```ts
93
- * const updated = await client.account.updatePreferences({
94
- * minDealScore: 70,
95
- * autoSync: true,
96
- * preferredCategories: ["software", "courses"]
97
- * });
98
- * ```
99
- */
100
- async updatePreferences(options) {
101
- const result = await patch(this.ctx, "/v1/client/preferences", {
102
- preferredCategories: options.preferredCategories,
103
- minDealScore: options.minDealScore,
104
- autoSync: options.autoSync,
105
- webhookEnabled: options.webhookEnabled,
106
- });
107
- return result.data;
108
- }
109
- /**
110
- * Track a DealUp click (webhook endpoint)
111
- * Used internally by DealUp to track click-through
112
- *
113
- * @example
114
- * ```ts
115
- * await client.account.trackClick("deal_abc123", "homepage");
116
- * ```
117
- */
118
- async trackClick(dealId, source) {
119
- const result = await post(this.ctx, "/v1/client/dealup/click", {
120
- dealId,
121
- source,
122
- });
123
- return result.data;
124
- }
125
- // ============================================
126
- // CONVENIENCE METHODS
127
- // ============================================
128
- /**
129
- * Get remaining quota for a resource
130
- *
131
- * @example
132
- * ```ts
133
- * const remaining = await client.account.getRemainingQuota("scrapes");
134
- * console.log(`${remaining} scrapes left this period`);
135
- * ```
136
- */
137
- async getRemainingQuota(resource) {
138
- const account = await this.get();
139
- const usage = account.usage[resource];
140
- return usage.limit - usage.used;
141
- }
142
- /**
143
- * Check if account has quota for a resource
144
- *
145
- * @example
146
- * ```ts
147
- * if (await client.account.hasQuota("crawls", 5)) {
148
- * // Safe to start 5 crawls
149
- * }
150
- * ```
151
- */
152
- async hasQuota(resource, needed = 1) {
153
- const remaining = await this.getRemainingQuota(resource);
154
- return remaining >= needed;
155
- }
156
- /**
157
- * Get account tier
158
- *
159
- * @example
160
- * ```ts
161
- * const tier = await client.account.getTier();
162
- * if (tier === "enterprise") {
163
- * // Enable advanced features
164
- * }
165
- * ```
166
- */
167
- async getTier() {
168
- const account = await this.get();
169
- return account.tier;
170
- }
171
- /**
172
- * Check if account is pro or enterprise tier
173
- *
174
- * @example
175
- * ```ts
176
- * if (await client.account.isPremium()) {
177
- * // Show premium features
178
- * }
179
- * ```
180
- */
181
- async isPremium() {
182
- const tier = await this.getTier();
183
- return tier === "pro" || tier === "enterprise";
184
- }
185
- }
186
- //# sourceMappingURL=account.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/resources/account.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;;GAGG;AACH,MAAM,OAAO,eAAe;IACN;IAApB,YAAoB,GAAmB;QAAnB,QAAG,GAAH,GAAG,CAAgB;IAAG,CAAC;IAE3C;;;;;;;;;;OAUG;IACH,KAAK,CAAC,GAAG;QACP,MAAM,MAAM,GAAG,MAAM,GAAG,CAAsB,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;QACtE,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,UAAU;QACd,MAAM,MAAM,GAAG,MAAM,GAAG,CACtB,IAAI,CAAC,GAAG,EACR,oBAAoB,CACrB,CAAC;QACF,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,gBAAgB;QACpB,MAAM,MAAM,GAAG,MAAM,GAAG,CACtB,IAAI,CAAC,GAAG,EACR,mBAAmB,CACpB,CAAC;QACF,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,kBAAkB;QACtB,MAAM,MAAM,GAAG,MAAM,GAAG,CACtB,IAAI,CAAC,GAAG,EACR,4BAA4B,CAC7B,CAAC;QACF,OAAO,MAAM,CAAC,IAA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C;QACzD,OAAO,SAAS,IAAI,MAAM,CAAC;IAC7B,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,OAAO;QACX,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC;QACjC,OAAO,OAAO,CAAC,IAAI,CAAC;IACtB,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,SAAS;QACb,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QAClC,OAAO,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,YAAY,CAAC;IACjD,CAAC;CACF"}
@@ -1,101 +0,0 @@
1
- /**
2
- * Crawl Resource
3
- * Handles website crawling operations
4
- */
5
- import type { RequestContext } from "../types/config";
6
- import type { CrawlOptions, CrawlTemplate, CrawlTemplateId } from "../types/options";
7
- import type { CrawlAnalysisResponse, CrawlJobResponse } from "../types/responses";
8
- /**
9
- * Crawl resource class
10
- * Provides methods for website crawling
11
- */
12
- export declare class CrawlResource {
13
- private ctx;
14
- constructor(ctx: RequestContext);
15
- /**
16
- * Create a new crawl job
17
- *
18
- * @example
19
- * ```ts
20
- * // Basic crawl
21
- * const job = await client.crawl.create({
22
- * url: "https://example.com",
23
- * maxDepth: 3,
24
- * maxPages: 100,
25
- * extractDeal: true
26
- * });
27
- *
28
- * // Advanced crawl with deal filtering
29
- * const advancedJob = await client.crawl.create({
30
- * url: "https://shop.example.com",
31
- * categories: ["software", "courses"],
32
- * priceRange: { min: 10, max: 100 },
33
- * minDealScore: 70,
34
- * syncToDealup: true,
35
- * webhookUrl: "https://your-webhook.com/deals"
36
- * });
37
- *
38
- * console.log(advancedJob.jobId);
39
- * console.log(advancedJob.priority); // "high" | "medium" | "low"
40
- * console.log(advancedJob.features);
41
- * ```
42
- */
43
- create(options: CrawlOptions): Promise<CrawlJobResponse>;
44
- /**
45
- * Create a crawl job using a template
46
- *
47
- * @example
48
- * ```ts
49
- * const job = await client.crawl.withTemplate("ecommerce", {
50
- * url: "https://shop.example.com",
51
- * maxPages: 200 // Override template default
52
- * });
53
- * ```
54
- */
55
- withTemplate(templateId: CrawlTemplateId, options: CrawlOptions): Promise<CrawlJobResponse>;
56
- /**
57
- * List available crawl templates
58
- *
59
- * @example
60
- * ```ts
61
- * const templates = client.crawl.listTemplates();
62
- * templates.forEach(t => console.log(t.name, t.description));
63
- * ```
64
- */
65
- listTemplates(): CrawlTemplate[];
66
- /**
67
- * Get a specific template by ID
68
- *
69
- * @example
70
- * ```ts
71
- * const template = client.crawl.getTemplate("ecommerce");
72
- * console.log(template.defaultOptions);
73
- * ```
74
- */
75
- getTemplate(templateId: CrawlTemplateId): CrawlTemplate | undefined;
76
- /**
77
- * Analyze a URL before crawling
78
- * Returns recommended settings and template suggestions based on site structure
79
- *
80
- * @example
81
- * ```ts
82
- * const analysis = await client.crawl.analyze("https://shop.example.com");
83
- * console.log(analysis.matchedTemplate);
84
- * console.log(analysis.recommendation);
85
- * ```
86
- */
87
- analyze(url: string): Promise<CrawlAnalysisResponse>;
88
- /**
89
- * Crawl a URL with deal extraction enabled
90
- * Convenience method for e-commerce crawling
91
- *
92
- * @example
93
- * ```ts
94
- * const job = await client.crawl.forDeals("https://shop.example.com", {
95
- * minDealScore: 70
96
- * });
97
- * ```
98
- */
99
- forDeals(url: string, options?: Omit<CrawlOptions, "url" | "extractDeal" | "prioritizeDealPages">): Promise<CrawlJobResponse>;
100
- }
101
- //# sourceMappingURL=crawl.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"crawl.d.ts","sourceRoot":"","sources":["../../src/resources/crawl.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EACV,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAiF5B;;;GAGG;AACH,qBAAa,aAAa;IACZ,OAAO,CAAC,GAAG;gBAAH,GAAG,EAAE,cAAc;IAEvC;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACG,MAAM,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA0C9D;;;;;;;;;;OAUG;IACG,YAAY,CAChB,UAAU,EAAE,eAAe,EAC3B,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,gBAAgB,CAAC;IAe5B;;;;;;;;OAQG;IACH,aAAa,IAAI,aAAa,EAAE;IAIhC;;;;;;;;OAQG;IACH,WAAW,CAAC,UAAU,EAAE,eAAe,GAAG,aAAa,GAAG,SAAS;IAInE;;;;;;;;;;OAUG;IACG,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAS1D;;;;;;;;;;OAUG;IACG,QAAQ,CACZ,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,KAAK,GAAG,aAAa,GAAG,qBAAqB,CAAC,GAC1E,OAAO,CAAC,gBAAgB,CAAC;CAQ7B"}