@dealcrawl/sdk 2.1.0 → 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 +13 -5
  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
@@ -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,IAAI,CAAC;IACrB,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,cAAc;QAClB,MAAM,MAAM,GAAG,MAAM,GAAG,CACtB,IAAI,CAAC,GAAG,EACR,wBAAwB,CACzB,CAAC;QACF,OAAO,MAAM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AO,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"}
@@ -1,234 +0,0 @@
1
- /**
2
- * Crawl Resource
3
- * Handles website crawling operations
4
- */
5
- import { post } from "../utils/request";
6
- /**
7
- * Predefined crawl templates with optimized settings
8
- */
9
- const CRAWL_TEMPLATES = {
10
- ecommerce: {
11
- id: "ecommerce",
12
- name: "E-commerce",
13
- description: "Optimized for product pages and online stores",
14
- defaultOptions: {
15
- maxDepth: 3,
16
- maxPages: 500,
17
- delayMs: 1500,
18
- extractDeal: true,
19
- prioritizeDealPages: true,
20
- excludePatterns: [
21
- "*/cart*",
22
- "*/checkout*",
23
- "*/account*",
24
- "*/login*",
25
- "*/register*",
26
- "*/wishlist*",
27
- "*/compare*",
28
- ],
29
- },
30
- },
31
- blog: {
32
- id: "blog",
33
- name: "Blog",
34
- description: "Optimized for blog posts and articles",
35
- defaultOptions: {
36
- maxDepth: 2,
37
- maxPages: 200,
38
- delayMs: 1000,
39
- extractDeal: false,
40
- prioritizeDealPages: false,
41
- excludePatterns: ["*/tag/*", "*/category/*", "*/author/*", "*/page/*"],
42
- },
43
- },
44
- docs: {
45
- id: "docs",
46
- name: "Documentation",
47
- description: "Optimized for documentation sites",
48
- defaultOptions: {
49
- maxDepth: 4,
50
- maxPages: 300,
51
- delayMs: 500,
52
- extractDeal: false,
53
- prioritizeDealPages: false,
54
- },
55
- },
56
- marketplace: {
57
- id: "marketplace",
58
- name: "Marketplace",
59
- description: "Optimized for multi-vendor marketplaces",
60
- defaultOptions: {
61
- maxDepth: 3,
62
- maxPages: 1000,
63
- delayMs: 2000,
64
- extractDeal: true,
65
- prioritizeDealPages: true,
66
- followExternalLinks: false,
67
- excludePatterns: [
68
- "*/seller/*",
69
- "*/vendor/*",
70
- "*/shop/*",
71
- "*/reviews*",
72
- "*/questions*",
73
- ],
74
- },
75
- },
76
- custom: {
77
- id: "custom",
78
- name: "Custom",
79
- description: "No preset - use your own settings",
80
- defaultOptions: {},
81
- },
82
- };
83
- /**
84
- * Crawl resource class
85
- * Provides methods for website crawling
86
- */
87
- export class CrawlResource {
88
- ctx;
89
- constructor(ctx) {
90
- this.ctx = ctx;
91
- }
92
- /**
93
- * Create a new crawl job
94
- *
95
- * @example
96
- * ```ts
97
- * // Basic crawl
98
- * const job = await client.crawl.create({
99
- * url: "https://example.com",
100
- * maxDepth: 3,
101
- * maxPages: 100,
102
- * extractDeal: true
103
- * });
104
- *
105
- * // Advanced crawl with deal filtering
106
- * const advancedJob = await client.crawl.create({
107
- * url: "https://shop.example.com",
108
- * categories: ["software", "courses"],
109
- * priceRange: { min: 10, max: 100 },
110
- * minDealScore: 70,
111
- * syncToDealup: true,
112
- * webhookUrl: "https://your-webhook.com/deals"
113
- * });
114
- *
115
- * console.log(advancedJob.jobId);
116
- * console.log(advancedJob.priority); // "high" | "medium" | "low"
117
- * console.log(advancedJob.features);
118
- * ```
119
- */
120
- async create(options) {
121
- const body = {
122
- // Basic options
123
- startUrl: options.url || options.startUrl,
124
- prompt: options.prompt,
125
- maxDepth: options.maxDepth,
126
- maxPages: options.maxPages,
127
- detectSignals: options.detectSignals,
128
- extractWithAI: options.extractWithAI,
129
- // Deal-specific parameters
130
- minDealScore: options.minDealScore,
131
- categories: options.categories,
132
- priceRange: options.priceRange,
133
- // Engine selection hints
134
- preferStatic: options.preferStatic,
135
- requireJS: options.requireJS,
136
- bypassAntiBot: options.bypassAntiBot,
137
- // Quality thresholds
138
- onlyHighQuality: options.onlyHighQuality,
139
- // Merchant filtering
140
- allowedMerchants: options.allowedMerchants,
141
- blockedMerchants: options.blockedMerchants,
142
- // Notifications & sync
143
- webhookUrl: options.webhookUrl,
144
- syncToDealup: options.syncToDealup,
145
- // Priority & routing
146
- priority: options.priority,
147
- siteConfig: options.siteConfig,
148
- template: options.template,
149
- useSmartRouting: options.useSmartRouting,
150
- };
151
- const result = await post(this.ctx, "/v1/crawl", body);
152
- return result.data;
153
- }
154
- /**
155
- * Create a crawl job using a template
156
- *
157
- * @example
158
- * ```ts
159
- * const job = await client.crawl.withTemplate("ecommerce", {
160
- * url: "https://shop.example.com",
161
- * maxPages: 200 // Override template default
162
- * });
163
- * ```
164
- */
165
- async withTemplate(templateId, options) {
166
- const template = CRAWL_TEMPLATES[templateId];
167
- if (!template) {
168
- throw new Error(`Invalid crawl templateId: ${templateId}. Available templates: ${Object.keys(CRAWL_TEMPLATES).join(", ")}`);
169
- }
170
- return this.create({
171
- ...template.defaultOptions,
172
- ...options,
173
- });
174
- }
175
- /**
176
- * List available crawl templates
177
- *
178
- * @example
179
- * ```ts
180
- * const templates = client.crawl.listTemplates();
181
- * templates.forEach(t => console.log(t.name, t.description));
182
- * ```
183
- */
184
- listTemplates() {
185
- return Object.values(CRAWL_TEMPLATES);
186
- }
187
- /**
188
- * Get a specific template by ID
189
- *
190
- * @example
191
- * ```ts
192
- * const template = client.crawl.getTemplate("ecommerce");
193
- * console.log(template.defaultOptions);
194
- * ```
195
- */
196
- getTemplate(templateId) {
197
- return CRAWL_TEMPLATES[templateId];
198
- }
199
- /**
200
- * Analyze a URL before crawling
201
- * Returns recommended settings and template suggestions based on site structure
202
- *
203
- * @example
204
- * ```ts
205
- * const analysis = await client.crawl.analyze("https://shop.example.com");
206
- * console.log(analysis.matchedTemplate);
207
- * console.log(analysis.recommendation);
208
- * ```
209
- */
210
- async analyze(url) {
211
- const result = await post(this.ctx, "/v1/crawl/analyze", { url });
212
- return result.data;
213
- }
214
- /**
215
- * Crawl a URL with deal extraction enabled
216
- * Convenience method for e-commerce crawling
217
- *
218
- * @example
219
- * ```ts
220
- * const job = await client.crawl.forDeals("https://shop.example.com", {
221
- * minDealScore: 70
222
- * });
223
- * ```
224
- */
225
- async forDeals(url, options) {
226
- return this.withTemplate("ecommerce", {
227
- url,
228
- extractDeal: true,
229
- prioritizeDealPages: true,
230
- ...options,
231
- });
232
- }
233
- }
234
- //# sourceMappingURL=crawl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"crawl.js","sourceRoot":"","sources":["../../src/resources/crawl.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH,OAAO,EAAO,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7C;;GAEG;AACH,MAAM,eAAe,GAA2C;IAC9D,SAAS,EAAE;QACT,EAAE,EAAE,WAAW;QACf,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE,+CAA+C;QAC5D,cAAc,EAAE;YACd,QAAQ,EAAE,CAAC;YACX,QAAQ,EAAE,GAAG;YACb,OAAO,EAAE,IAAI;YACb,WAAW,EAAE,IAAI;YACjB,mBAAmB,EAAE,IAAI;YACzB,eAAe,EAAE;gBACf,SAAS;gBACT,aAAa;gBACb,YAAY;gBACZ,UAAU;gBACV,aAAa;gBACb,aAAa;gBACb,YAAY;aACb;SACF;KACF;IACD,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM;QACV,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,uCAAuC;QACpD,cAAc,EAAE;YACd,QAAQ,EAAE,CAAC;YACX,QAAQ,EAAE,GAAG;YACb,OAAO,EAAE,IAAI;YACb,WAAW,EAAE,KAAK;YAClB,mBAAmB,EAAE,KAAK;YAC1B,eAA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C,cAAc;YAC1B,GAAG,OAAO;SACX,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;OAQG;IACH,aAAa;QACX,OAAO,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IACxC,CAAC;IAED;;;;;;;;OAQG;IACH,WAAW,CAAC,UAA2B;QACrC,OAAO,eAAe,CAAC,UAAU,CAAC,CAAC;IACrC,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,OAAO,CAAC,GAAW;QACvB,MAAM,MAAM,GAAG,MAAM,IAAI,CACvB,IAAI,CAAC,GAAG,EACR,mBAAmB,EACnB,EAAE,GAAG,EAAE,CACR,CAAC;QACF,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,QAAQ,CACZ,GAAW,EACX,OAA2E;QAE3E,OAAO,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE;YACpC,GAAG;YACH,WAAW,EAAE,IAAI;YACjB,mBAAmB,EAAE,IAAI;YACzB,GAAG,OAAO;SACX,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -1,157 +0,0 @@
1
- /**
2
- * Data Resource
3
- * Handles data retrieval, listing, and export operations
4
- */
5
- import type { RequestContext } from "../types/config";
6
- import type { ExportDealsOptions, ExportJobsOptions, ListDealsOptions, ListJobsOptions } from "../types/options";
7
- import type { ClientStatsResponse, DealDetails, ListDealsResponse, ListJobsResponse } from "../types/responses";
8
- /**
9
- * Data resource class
10
- * Provides methods for accessing job and deal data
11
- */
12
- export declare class DataResource {
13
- private ctx;
14
- constructor(ctx: RequestContext);
15
- /**
16
- * List all jobs
17
- *
18
- * @example
19
- * ```ts
20
- * const jobs = await client.data.listJobs({
21
- * status: "completed",
22
- * type: "crawl",
23
- * page: 1,
24
- * limit: 20
25
- * });
26
- * console.log(jobs.data);
27
- * console.log(jobs.pagination.total);
28
- * ```
29
- */
30
- listJobs(options?: ListJobsOptions): Promise<ListJobsResponse>;
31
- /**
32
- * Get jobs by status
33
- * Convenience method for filtering by status
34
- *
35
- * @example
36
- * ```ts
37
- * const activeJobs = await client.data.getJobsByStatus("active");
38
- * ```
39
- */
40
- getJobsByStatus(status: ListJobsOptions["status"], options?: Omit<ListJobsOptions, "status">): Promise<ListJobsResponse>;
41
- /**
42
- * Get jobs by type
43
- * Convenience method for filtering by type
44
- *
45
- * @example
46
- * ```ts
47
- * const crawlJobs = await client.data.getJobsByType("crawl");
48
- * ```
49
- */
50
- getJobsByType(type: ListJobsOptions["type"], options?: Omit<ListJobsOptions, "type">): Promise<ListJobsResponse>;
51
- /**
52
- * Get recent jobs
53
- * Convenience method for getting latest jobs
54
- *
55
- * @example
56
- * ```ts
57
- * const recentJobs = await client.data.getRecentJobs(10);
58
- * ```
59
- */
60
- getRecentJobs(limit?: number): Promise<ListJobsResponse>;
61
- /**
62
- * List all deals
63
- *
64
- * @example
65
- * ```ts
66
- * const deals = await client.data.listDeals({
67
- * minScore: 70,
68
- * category: "electronics",
69
- * sortBy: "deal_score",
70
- * sortOrder: "desc"
71
- * });
72
- * ```
73
- */
74
- listDeals(options?: ListDealsOptions): Promise<ListDealsResponse>;
75
- /**
76
- * Get a single deal by ID
77
- *
78
- * @example
79
- * ```ts
80
- * const deal = await client.data.getDeal("deal_abc123");
81
- * console.log(deal.product.name);
82
- * console.log(deal.pricing.discountPercent);
83
- * ```
84
- */
85
- getDeal(dealId: string): Promise<DealDetails>;
86
- /**
87
- * Get top deals by score
88
- * Convenience method for finding best deals
89
- *
90
- * @example
91
- * ```ts
92
- * const topDeals = await client.data.getTopDeals(20, 80);
93
- * ```
94
- */
95
- getTopDeals(limit?: number, minScore?: number): Promise<ListDealsResponse>;
96
- /**
97
- * Get deals by category
98
- * Convenience method for filtering by category
99
- *
100
- * @example
101
- * ```ts
102
- * const electronicsDeals = await client.data.getDealsByCategory("electronics");
103
- * ```
104
- */
105
- getDealsByCategory(category: string, options?: Omit<ListDealsOptions, "category">): Promise<ListDealsResponse>;
106
- /**
107
- * Get unsynced deals (not yet sent to DealUp)
108
- *
109
- * @example
110
- * ```ts
111
- * const unsyncedDeals = await client.data.getUnsyncedDeals();
112
- * ```
113
- */
114
- getUnsyncedDeals(options?: Omit<ListDealsOptions, "synced">): Promise<ListDealsResponse>;
115
- /**
116
- * Export jobs data
117
- *
118
- * @example
119
- * ```ts
120
- * // Export as JSON
121
- * const jsonData = await client.data.exportJobs({ format: "json" });
122
- *
123
- * // Export as CSV
124
- * const csvData = await client.data.exportJobs({ format: "csv" });
125
- * ```
126
- */
127
- exportJobs(options?: ExportJobsOptions): Promise<string | object[]>;
128
- /**
129
- * Export deals data
130
- *
131
- * @example
132
- * ```ts
133
- * // Export as JSON
134
- * const jsonData = await client.data.exportDeals({ format: "json" });
135
- *
136
- * // Export as CSV with filters
137
- * const csvData = await client.data.exportDeals({
138
- * format: "csv",
139
- * minScore: 70,
140
- * category: "software"
141
- * });
142
- * ```
143
- */
144
- exportDeals(options?: ExportDealsOptions): Promise<string | object[]>;
145
- /**
146
- * Get client statistics
147
- *
148
- * @example
149
- * ```ts
150
- * const stats = await client.data.getStats();
151
- * console.log(stats.totals.deals);
152
- * console.log(stats.performance.avgDealScore);
153
- * ```
154
- */
155
- getStats(): Promise<ClientStatsResponse>;
156
- }
157
- //# sourceMappingURL=data.d.ts.map