@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
@@ -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;AAC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AAmB,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
@@ -1 +0,0 @@
1
- {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../src/resources/data.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EACV,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAG5B;;;GAGG;AACH,qBAAa,YAAY;IACX,OAAO,CAAC,GAAG;gBAAH,GAAG,EAAE,cAAc;IAMvC;;;;;;;;;;;;;;OAcG;IACG,QAAQ,CAAC,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAcxE;;;;;;;;OAQG;IACG,eAAe,CACnB,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC,EACjC,OAAO,CAAC,EAAE,IAAI,CAAC,eAAe,EAAE,QAAQ,CAAC,GACxC,OAAO,CAAC,gBAAgB,CAAC;IAI5B;;;;;;;;OAQG;IACG,aAAa,CACjB,IAAI,EAAE,eAAe,CAAC,MAAM,CAAC,EAC7B,OAAO,CAAC,EAAE,IAAI,CAAC,eAAe,EAAE,MAAM,CAAC,GACtC,OAAO,CAAC,gBAAgB,CAAC;IAI5B;;;;;;;;OAQG;IACG,aAAa,CAAC,KAAK,GAAE,MAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAYlE;;;;;;;;;;;;OAYG;IACG,SAAS,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAe3E;;;;;;;;;OASG;IACG,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAOnD;;;;;;;;OAQG;IACG,WAAW,CACf,KAAK,GAAE,MAAW,EAClB,QAAQ,GAAE,MAAW,GACpB,OAAO,CAAC,iBAAiB,CAAC;IAS7B;;;;;;;;OAQG;IACG,kBAAkB,CACtB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,GAC3C,OAAO,CAAC,iBAAiB,CAAC;IAO7B;;;;;;;OAOG;IACG,gBAAgB,CACpB,OAAO,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAC,GACzC,OAAO,CAAC,iBAAiB,CAAC;IAQ7B;;;;;;;;;;;OAWG;IACG,UAAU,CACd,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC;IAe7B;;;;;;;;;;;;;;;OAeG;IACG,WAAW,CACf,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC;IAmB7B;;;;;;;;;OASG;IACG,QAAQ,IAAI,OAAO,CAAC,mBAAmB,CAAC;CAI/C"}
@@ -1,245 +0,0 @@
1
- /**
2
- * Data Resource
3
- * Handles data retrieval, listing, and export operations
4
- */
5
- import { get } from "../utils/request";
6
- /**
7
- * Data resource class
8
- * Provides methods for accessing job and deal data
9
- */
10
- export class DataResource {
11
- ctx;
12
- constructor(ctx) {
13
- this.ctx = ctx;
14
- }
15
- // ============================================
16
- // JOBS
17
- // ============================================
18
- /**
19
- * List all jobs
20
- *
21
- * @example
22
- * ```ts
23
- * const jobs = await client.data.listJobs({
24
- * status: "completed",
25
- * type: "crawl",
26
- * page: 1,
27
- * limit: 20
28
- * });
29
- * console.log(jobs.data);
30
- * console.log(jobs.pagination.total);
31
- * ```
32
- */
33
- async listJobs(options = {}) {
34
- const result = await get(this.ctx, "/v1/data/jobs", {
35
- page: options.page,
36
- limit: options.limit,
37
- status: options.status,
38
- type: options.type,
39
- sortBy: options.sortBy,
40
- sortOrder: options.sortOrder,
41
- fromDate: options.fromDate,
42
- toDate: options.toDate,
43
- });
44
- return result.data;
45
- }
46
- /**
47
- * Get jobs by status
48
- * Convenience method for filtering by status
49
- *
50
- * @example
51
- * ```ts
52
- * const activeJobs = await client.data.getJobsByStatus("active");
53
- * ```
54
- */
55
- async getJobsByStatus(status, options) {
56
- return this.listJobs({ status, ...options });
57
- }
58
- /**
59
- * Get jobs by type
60
- * Convenience method for filtering by type
61
- *
62
- * @example
63
- * ```ts
64
- * const crawlJobs = await client.data.getJobsByType("crawl");
65
- * ```
66
- */
67
- async getJobsByType(type, options) {
68
- return this.listJobs({ type, ...options });
69
- }
70
- /**
71
- * Get recent jobs
72
- * Convenience method for getting latest jobs
73
- *
74
- * @example
75
- * ```ts
76
- * const recentJobs = await client.data.getRecentJobs(10);
77
- * ```
78
- */
79
- async getRecentJobs(limit = 10) {
80
- return this.listJobs({
81
- limit,
82
- sortBy: "created_at",
83
- sortOrder: "desc",
84
- });
85
- }
86
- // ============================================
87
- // DEALS
88
- // ============================================
89
- /**
90
- * List all deals
91
- *
92
- * @example
93
- * ```ts
94
- * const deals = await client.data.listDeals({
95
- * minScore: 70,
96
- * category: "electronics",
97
- * sortBy: "deal_score",
98
- * sortOrder: "desc"
99
- * });
100
- * ```
101
- */
102
- async listDeals(options = {}) {
103
- const result = await get(this.ctx, "/v1/data/deals", {
104
- page: options.page,
105
- limit: options.limit,
106
- minScore: options.minScore,
107
- maxPrice: options.maxPrice,
108
- category: options.category,
109
- merchant: options.merchant,
110
- synced: options.synced?.toString(),
111
- sortBy: options.sortBy,
112
- sortOrder: options.sortOrder,
113
- });
114
- return result.data;
115
- }
116
- /**
117
- * Get a single deal by ID
118
- *
119
- * @example
120
- * ```ts
121
- * const deal = await client.data.getDeal("deal_abc123");
122
- * console.log(deal.product.name);
123
- * console.log(deal.pricing.discountPercent);
124
- * ```
125
- */
126
- async getDeal(dealId) {
127
- if (!dealId || !dealId.trim()) {
128
- throw new Error("dealId is required and cannot be empty");
129
- }
130
- const result = await get(this.ctx, `/v1/data/deals/${dealId}`);
131
- return result.data;
132
- }
133
- /**
134
- * Get top deals by score
135
- * Convenience method for finding best deals
136
- *
137
- * @example
138
- * ```ts
139
- * const topDeals = await client.data.getTopDeals(20, 80);
140
- * ```
141
- */
142
- async getTopDeals(limit = 20, minScore = 70) {
143
- return this.listDeals({
144
- limit,
145
- minScore,
146
- sortBy: "deal_score",
147
- sortOrder: "desc",
148
- });
149
- }
150
- /**
151
- * Get deals by category
152
- * Convenience method for filtering by category
153
- *
154
- * @example
155
- * ```ts
156
- * const electronicsDeals = await client.data.getDealsByCategory("electronics");
157
- * ```
158
- */
159
- async getDealsByCategory(category, options) {
160
- if (!category || !category.trim()) {
161
- throw new Error("category is required and cannot be empty");
162
- }
163
- return this.listDeals({ category, ...options });
164
- }
165
- /**
166
- * Get unsynced deals (not yet sent to DealUp)
167
- *
168
- * @example
169
- * ```ts
170
- * const unsyncedDeals = await client.data.getUnsyncedDeals();
171
- * ```
172
- */
173
- async getUnsyncedDeals(options) {
174
- return this.listDeals({ synced: false, ...options });
175
- }
176
- // ============================================
177
- // EXPORT
178
- // ============================================
179
- /**
180
- * Export jobs data
181
- *
182
- * @example
183
- * ```ts
184
- * // Export as JSON
185
- * const jsonData = await client.data.exportJobs({ format: "json" });
186
- *
187
- * // Export as CSV
188
- * const csvData = await client.data.exportJobs({ format: "csv" });
189
- * ```
190
- */
191
- async exportJobs(options = {}) {
192
- const result = await get(this.ctx, "/v1/data/export/jobs", {
193
- format: options.format || "json",
194
- status: options.status,
195
- type: options.type,
196
- fromDate: options.fromDate,
197
- toDate: options.toDate,
198
- });
199
- return result.data;
200
- }
201
- /**
202
- * Export deals data
203
- *
204
- * @example
205
- * ```ts
206
- * // Export as JSON
207
- * const jsonData = await client.data.exportDeals({ format: "json" });
208
- *
209
- * // Export as CSV with filters
210
- * const csvData = await client.data.exportDeals({
211
- * format: "csv",
212
- * minScore: 70,
213
- * category: "software"
214
- * });
215
- * ```
216
- */
217
- async exportDeals(options = {}) {
218
- const result = await get(this.ctx, "/v1/data/export/deals", {
219
- format: options.format || "json",
220
- minScore: options.minScore,
221
- maxPrice: options.maxPrice,
222
- category: options.category,
223
- includeRawSignals: options.includeRawSignals,
224
- });
225
- return result.data;
226
- }
227
- // ============================================
228
- // STATS
229
- // ============================================
230
- /**
231
- * Get client statistics
232
- *
233
- * @example
234
- * ```ts
235
- * const stats = await client.data.getStats();
236
- * console.log(stats.totals.deals);
237
- * console.log(stats.performance.avgDealScore);
238
- * ```
239
- */
240
- async getStats() {
241
- const result = await get(this.ctx, "/v1/data/stats");
242
- return result.data;
243
- }
244
- }
245
- //# sourceMappingURL=data.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"data.js","sourceRoot":"","sources":["../../src/resources/data.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAeH,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAEvC;;;GAGG;AACH,MAAM,OAAO,YAAY;IACH;IAApB,YAAoB,GAAmB;QAAnB,QAAG,GAAH,GAAG,CAAgB;IAAG,CAAC;IAE3C,+CAA+C;IAC/C,OAAO;IACP,+CAA+C;IAE/C;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,QAAQ,CAAC,UAA2B,EAAE;QAC1C,MAAM,MAAM,GAAG,MAAM,GAAG,CAAmB,IAAI,CAAC,GAAG,EAAE,eAAe,EAAE;YACpE,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5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