@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
@@ -1,246 +0,0 @@
1
- /**
2
- * Extract Resource
3
- * Handles LLM-based structured data extraction
4
- */
5
- import { post } from "../utils/request";
6
- /**
7
- * Extract resource class
8
- * Provides methods for structured data extraction using LLMs
9
- */
10
- export class ExtractResource {
11
- ctx;
12
- constructor(ctx) {
13
- this.ctx = ctx;
14
- }
15
- /**
16
- * Create a new extraction job
17
- * Either schema or prompt must be provided
18
- *
19
- * @example
20
- * ```ts
21
- * // Schema-based extraction
22
- * const job = await client.extract.create({
23
- * url: "https://example.com/product",
24
- * schema: {
25
- * type: "object",
26
- * properties: {
27
- * name: { type: "string" },
28
- * price: { type: "number" },
29
- * features: { type: "array", items: { type: "string" } }
30
- * }
31
- * }
32
- * });
33
- *
34
- * // Prompt-based extraction
35
- * const job = await client.extract.create({
36
- * url: "https://example.com/article",
37
- * prompt: "Extract the main points and author name"
38
- * });
39
- * ```
40
- */
41
- async create(options) {
42
- if (!options.schema && !options.prompt) {
43
- throw new Error("Either 'schema' or 'prompt' must be provided");
44
- }
45
- const body = {
46
- url: options.url,
47
- schema: options.schema,
48
- prompt: options.prompt,
49
- onlyMainContent: options.onlyMainContent,
50
- excludeTags: options.excludeTags,
51
- excludeSelectors: options.excludeSelectors,
52
- model: options.model,
53
- temperature: options.temperature,
54
- webhook: options.webhook,
55
- headers: options.headers,
56
- timeout: options.timeout,
57
- };
58
- const result = await post(this.ctx, "/v1/extract", body);
59
- return result.data;
60
- }
61
- /**
62
- * Extract data using a JSON Schema
63
- * Convenience method for schema-based extraction
64
- *
65
- * @example
66
- * ```ts
67
- * const job = await client.extract.withSchema(
68
- * "https://example.com/product",
69
- * {
70
- * type: "object",
71
- * properties: {
72
- * name: { type: "string" },
73
- * price: { type: "number" }
74
- * }
75
- * }
76
- * );
77
- * ```
78
- */
79
- async withSchema(url, schema, options) {
80
- return this.create({
81
- url,
82
- schema,
83
- ...options,
84
- });
85
- }
86
- /**
87
- * Extract data using a natural language prompt
88
- * Convenience method for prompt-based extraction
89
- *
90
- * @example
91
- * ```ts
92
- * const job = await client.extract.withPrompt(
93
- * "https://example.com/article",
94
- * "Extract the article title, author, publication date, and a brief summary"
95
- * );
96
- * ```
97
- */
98
- async withPrompt(url, prompt, options) {
99
- return this.create({
100
- url,
101
- prompt,
102
- ...options,
103
- });
104
- }
105
- /**
106
- * Extract product information from a page
107
- * Pre-built schema for common e-commerce use case
108
- *
109
- * @example
110
- * ```ts
111
- * const job = await client.extract.product("https://shop.example.com/item");
112
- * ```
113
- */
114
- async product(url, options) {
115
- const productSchema = {
116
- type: "object",
117
- properties: {
118
- name: { type: "string", description: "Product name" },
119
- brand: { type: "string", description: "Brand name" },
120
- price: { type: "number", description: "Current price" },
121
- originalPrice: {
122
- type: "number",
123
- description: "Original price before discount",
124
- },
125
- currency: {
126
- type: "string",
127
- description: "Currency code (USD, EUR, etc.)",
128
- },
129
- description: { type: "string", description: "Product description" },
130
- features: {
131
- type: "array",
132
- items: { type: "string" },
133
- description: "List of product features",
134
- },
135
- images: {
136
- type: "array",
137
- items: { type: "string" },
138
- description: "Product image URLs",
139
- },
140
- availability: {
141
- type: "string",
142
- description: "In stock, out of stock, etc.",
143
- },
144
- rating: { type: "number", description: "Average rating" },
145
- reviewCount: { type: "number", description: "Number of reviews" },
146
- },
147
- required: ["name", "price"],
148
- };
149
- return this.create({
150
- url,
151
- schema: productSchema,
152
- model: "gpt-4o-mini",
153
- ...options,
154
- });
155
- }
156
- /**
157
- * Extract article/blog post information
158
- * Pre-built schema for content extraction
159
- *
160
- * @example
161
- * ```ts
162
- * const job = await client.extract.article("https://blog.example.com/post");
163
- * ```
164
- */
165
- async article(url, options) {
166
- const articleSchema = {
167
- type: "object",
168
- properties: {
169
- title: { type: "string", description: "Article title" },
170
- author: { type: "string", description: "Author name" },
171
- publishedAt: { type: "string", description: "Publication date" },
172
- summary: {
173
- type: "string",
174
- description: "Brief summary of the article",
175
- },
176
- content: { type: "string", description: "Main article content" },
177
- tags: {
178
- type: "array",
179
- items: { type: "string" },
180
- description: "Article tags or categories",
181
- },
182
- readingTime: {
183
- type: "number",
184
- description: "Estimated reading time in minutes",
185
- },
186
- },
187
- required: ["title", "content"],
188
- };
189
- return this.create({
190
- url,
191
- schema: articleSchema,
192
- onlyMainContent: true,
193
- ...options,
194
- });
195
- }
196
- /**
197
- * Extract contact information from a page
198
- * Pre-built schema for contact page scraping
199
- *
200
- * @example
201
- * ```ts
202
- * const job = await client.extract.contact("https://example.com/contact");
203
- * ```
204
- */
205
- async contact(url, options) {
206
- const contactSchema = {
207
- type: "object",
208
- properties: {
209
- companyName: {
210
- type: "string",
211
- description: "Company or organization name",
212
- },
213
- email: { type: "string", description: "Contact email address" },
214
- phone: { type: "string", description: "Phone number" },
215
- address: {
216
- type: "object",
217
- properties: {
218
- street: { type: "string" },
219
- city: { type: "string" },
220
- state: { type: "string" },
221
- postalCode: { type: "string" },
222
- country: { type: "string" },
223
- },
224
- description: "Physical address",
225
- },
226
- socialMedia: {
227
- type: "object",
228
- properties: {
229
- twitter: { type: "string" },
230
- linkedin: { type: "string" },
231
- facebook: { type: "string" },
232
- instagram: { type: "string" },
233
- },
234
- description: "Social media links",
235
- },
236
- },
237
- };
238
- return this.create({
239
- url,
240
- schema: contactSchema,
241
- onlyMainContent: false, // Contact info might be in footer
242
- ...options,
243
- });
244
- }
245
- }
246
- //# sourceMappingURL=extract.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extract.js","sourceRoot":"","sources":["../../src/resources/extract.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC;;;GAGG;AACH,MAAM,OAAO,eAAe;IACN;IAApB,YAAoB,GAAmB;QAAnB,QAAG,GAAH,GAAG,CAAgB;IAAG,CAAC;IAE3C;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,KAAK,CAAC,MAAM,CAAC,OAAuB;QAClC,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;QAClE,CAA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wBACxB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;wBACzB,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;wBAC9B,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;qBAC5B;oBACD,WAAW,EAAE,kBAAkB;iBAChC;gBACD,WAAW,EAAE;oBACX,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;wBAC3B,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;wBAC5B,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;wBAC5B,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;qBAC9B;oBACD,WAAW,EAAE,oBAAoB;iBAClC;aACF;SACF,CAAC;QAEF,OAAO,IAAI,CAAC,MAAM,CAAC;YACjB,GAAG;YACH,MAAM,EAAE,aAAa;YACrB,eAAe,EAAE,KAAK,EAAE,kCAAkC;YAC1D,GAAG,OAAO;SACX,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -1,14 +0,0 @@
1
- /**
2
- * Resources barrel export
3
- * Re-exports all resource classes
4
- */
5
- export { ScrapeResource } from "./scrape";
6
- export { CrawlResource } from "./crawl";
7
- export { ExtractResource } from "./extract";
8
- export { DorkResource } from "./dork";
9
- export { StatusResource } from "./status";
10
- export { DataResource } from "./data";
11
- export { WebhooksResource } from "./webhooks";
12
- export { KeysResource } from "./keys";
13
- export { AccountResource } from "./account";
14
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/resources/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC"}
@@ -1,14 +0,0 @@
1
- /**
2
- * Resources barrel export
3
- * Re-exports all resource classes
4
- */
5
- export { ScrapeResource } from "./scrape";
6
- export { CrawlResource } from "./crawl";
7
- export { ExtractResource } from "./extract";
8
- export { DorkResource } from "./dork";
9
- export { StatusResource } from "./status";
10
- export { DataResource } from "./data";
11
- export { WebhooksResource } from "./webhooks";
12
- export { KeysResource } from "./keys";
13
- export { AccountResource } from "./account";
14
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/resources/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC"}
@@ -1,124 +0,0 @@
1
- /**
2
- * Keys Resource
3
- * Handles API key management operations
4
- */
5
- import type { RequestContext } from "../types/config";
6
- import type { CreateApiKeyOptions, RotateApiKeyOptions, ListApiKeysOptions, GetApiKeyStatsOptions } from "../types/options";
7
- import type { ListKeysResponse, CreateKeyResponse, ApiKeyInfo, RotateKeyResponse, DeleteKeyResponse, KeyStatsResponse } from "../types/responses";
8
- /**
9
- * Keys resource class
10
- * Provides methods for managing API keys
11
- */
12
- export declare class KeysResource {
13
- private ctx;
14
- constructor(ctx: RequestContext);
15
- /**
16
- * List all API keys
17
- *
18
- * @example
19
- * ```ts
20
- * const keys = await client.keys.list();
21
- * keys.keys.forEach(k => {
22
- * console.log(k.name, k.prefix, k.isActive);
23
- * });
24
- * ```
25
- */
26
- list(options?: ListApiKeysOptions): Promise<ListKeysResponse>;
27
- /**
28
- * Create a new API key
29
- *
30
- * @example
31
- * ```ts
32
- * const newKey = await client.keys.create({
33
- * name: "Production Key",
34
- * scopes: ["scrape", "crawl", "status", "data:read"],
35
- * expiresInDays: 365
36
- * });
37
- *
38
- * // IMPORTANT: Save this key immediately - it won't be shown again!
39
- * console.log(newKey.key);
40
- * ```
41
- */
42
- create(options: CreateApiKeyOptions): Promise<CreateKeyResponse>;
43
- /**
44
- * Get details of a specific key
45
- *
46
- * @example
47
- * ```ts
48
- * const key = await client.keys.get("key_abc123");
49
- * console.log(key.scopes);
50
- * console.log(key.lastUsedAt);
51
- * ```
52
- */
53
- get(keyId: string): Promise<ApiKeyInfo>;
54
- /**
55
- * Get usage statistics for a key
56
- *
57
- * @example
58
- * ```ts
59
- * const stats = await client.keys.getStats("key_abc123", { days: 30 });
60
- * console.log(stats.stats.totalRequests);
61
- * console.log(stats.stats.byEndpoint);
62
- * ```
63
- */
64
- getStats(keyId: string, options?: GetApiKeyStatsOptions): Promise<KeyStatsResponse>;
65
- /**
66
- * Rotate an API key (revoke old, create new)
67
- *
68
- * @example
69
- * ```ts
70
- * const rotated = await client.keys.rotate("key_abc123", {
71
- * newName: "Production Key v2"
72
- * });
73
- *
74
- * // Old key is now invalid
75
- * console.log(rotated.oldKeyRevoked); // true
76
- *
77
- * // Save new key immediately!
78
- * console.log(rotated.newKey.key);
79
- * ```
80
- */
81
- rotate(keyId: string, options?: RotateApiKeyOptions): Promise<RotateKeyResponse>;
82
- /**
83
- * Revoke (delete) an API key
84
- *
85
- * @example
86
- * ```ts
87
- * await client.keys.revoke("key_abc123");
88
- * ```
89
- */
90
- revoke(keyId: string): Promise<DeleteKeyResponse>;
91
- /**
92
- * Revoke all API keys (except the current one)
93
- *
94
- * @example
95
- * ```ts
96
- * // Use with caution!
97
- * const result = await client.keys.revokeAll();
98
- * console.log(`Revoked ${result.count} keys`);
99
- * ```
100
- */
101
- revokeAll(): Promise<{
102
- success: boolean;
103
- count: number;
104
- }>;
105
- /**
106
- * Get active keys only
107
- *
108
- * @example
109
- * ```ts
110
- * const activeKeys = await client.keys.getActive();
111
- * ```
112
- */
113
- getActive(): Promise<ApiKeyInfo[]>;
114
- /**
115
- * Check if a key is valid (active and not expired)
116
- *
117
- * @example
118
- * ```ts
119
- * const isValid = await client.keys.isValid("key_abc123");
120
- * ```
121
- */
122
- isValid(keyId: string): Promise<boolean>;
123
- }
124
- //# sourceMappingURL=keys.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/resources/keys.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAG5B;;;GAGG;AACH,qBAAa,YAAY;IACX,OAAO,CAAC,GAAG;gBAAH,GAAG,EAAE,cAAc;IAEvC;;;;;;;;;;OAUG;IACG,IAAI,CAAC,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAOvE;;;;;;;;;;;;;;OAcG;IACG,MAAM,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAUtE;;;;;;;;;OASG;IACG,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAK7C;;;;;;;;;OASG;IACG,QAAQ,CACZ,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,gBAAgB,CAAC;IAW5B;;;;;;;;;;;;;;;OAeG;IACG,MAAM,CACV,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,iBAAiB,CAAC;IAW7B;;;;;;;OAOG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAKvD;;;;;;;;;OASG;IACG,SAAS,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAQ/D;;;;;;;OAOG;IACG,SAAS,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;IAKxC;;;;;;;OAOG;IACG,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAU/C"}
@@ -1,168 +0,0 @@
1
- /**
2
- * Keys Resource
3
- * Handles API key management operations
4
- */
5
- import { get, post, del } from "../utils/request";
6
- /**
7
- * Keys resource class
8
- * Provides methods for managing API keys
9
- */
10
- export class KeysResource {
11
- ctx;
12
- constructor(ctx) {
13
- this.ctx = ctx;
14
- }
15
- /**
16
- * List all API keys
17
- *
18
- * @example
19
- * ```ts
20
- * const keys = await client.keys.list();
21
- * keys.keys.forEach(k => {
22
- * console.log(k.name, k.prefix, k.isActive);
23
- * });
24
- * ```
25
- */
26
- async list(options = {}) {
27
- const result = await get(this.ctx, "/v1/keys", {
28
- includeRevoked: options.includeRevoked,
29
- });
30
- return result.data;
31
- }
32
- /**
33
- * Create a new API key
34
- *
35
- * @example
36
- * ```ts
37
- * const newKey = await client.keys.create({
38
- * name: "Production Key",
39
- * scopes: ["scrape", "crawl", "status", "data:read"],
40
- * expiresInDays: 365
41
- * });
42
- *
43
- * // IMPORTANT: Save this key immediately - it won't be shown again!
44
- * console.log(newKey.key);
45
- * ```
46
- */
47
- async create(options) {
48
- const result = await post(this.ctx, "/v1/keys", {
49
- name: options.name,
50
- scopes: options.scopes,
51
- expiresInDays: options.expiresInDays,
52
- ipAllowlist: options.ipAllowlist,
53
- });
54
- return result.data;
55
- }
56
- /**
57
- * Get details of a specific key
58
- *
59
- * @example
60
- * ```ts
61
- * const key = await client.keys.get("key_abc123");
62
- * console.log(key.scopes);
63
- * console.log(key.lastUsedAt);
64
- * ```
65
- */
66
- async get(keyId) {
67
- const result = await get(this.ctx, `/v1/keys/${keyId}`);
68
- return result.data;
69
- }
70
- /**
71
- * Get usage statistics for a key
72
- *
73
- * @example
74
- * ```ts
75
- * const stats = await client.keys.getStats("key_abc123", { days: 30 });
76
- * console.log(stats.stats.totalRequests);
77
- * console.log(stats.stats.byEndpoint);
78
- * ```
79
- */
80
- async getStats(keyId, options = {}) {
81
- const result = await get(this.ctx, `/v1/keys/${keyId}/stats`, {
82
- days: options.days,
83
- });
84
- return result.data;
85
- }
86
- /**
87
- * Rotate an API key (revoke old, create new)
88
- *
89
- * @example
90
- * ```ts
91
- * const rotated = await client.keys.rotate("key_abc123", {
92
- * newName: "Production Key v2"
93
- * });
94
- *
95
- * // Old key is now invalid
96
- * console.log(rotated.oldKeyRevoked); // true
97
- *
98
- * // Save new key immediately!
99
- * console.log(rotated.newKey.key);
100
- * ```
101
- */
102
- async rotate(keyId, options = {}) {
103
- const result = await post(this.ctx, `/v1/keys/${keyId}/rotate`, {
104
- newName: options.newName,
105
- });
106
- return result.data;
107
- }
108
- /**
109
- * Revoke (delete) an API key
110
- *
111
- * @example
112
- * ```ts
113
- * await client.keys.revoke("key_abc123");
114
- * ```
115
- */
116
- async revoke(keyId) {
117
- const result = await del(this.ctx, `/v1/keys/${keyId}`);
118
- return result.data;
119
- }
120
- /**
121
- * Revoke all API keys (except the current one)
122
- *
123
- * @example
124
- * ```ts
125
- * // Use with caution!
126
- * const result = await client.keys.revokeAll();
127
- * console.log(`Revoked ${result.count} keys`);
128
- * ```
129
- */
130
- async revokeAll() {
131
- const result = await del(this.ctx, "/v1/keys/all");
132
- return result.data;
133
- }
134
- /**
135
- * Get active keys only
136
- *
137
- * @example
138
- * ```ts
139
- * const activeKeys = await client.keys.getActive();
140
- * ```
141
- */
142
- async getActive() {
143
- const all = await this.list({ includeRevoked: false });
144
- return all.keys.filter((k) => k.isActive);
145
- }
146
- /**
147
- * Check if a key is valid (active and not expired)
148
- *
149
- * @example
150
- * ```ts
151
- * const isValid = await client.keys.isValid("key_abc123");
152
- * ```
153
- */
154
- async isValid(keyId) {
155
- try {
156
- const key = await this.get(keyId);
157
- if (!key.isActive)
158
- return false;
159
- if (key.expiresAt && new Date(key.expiresAt) < new Date())
160
- return false;
161
- return true;
162
- }
163
- catch {
164
- return false;
165
- }
166
- }
167
- }
168
- //# sourceMappingURL=keys.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../src/resources/keys.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAiBH,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;GAGG;AACH,MAAM,OAAO,YAAY;IACH;IAApB,YAAoB,GAAmB;QAAnB,QAAG,GAAH,GAAG,CAAgB;IAAG,CAAC;IAE3C;;;;;;;;;;OAUG;IACH,KAAK,CAAC,IAAI,CAAC,UAA8B,EAAE;QACzC,MAAM,MAAM,GAAG,MAAM,GAAG,CAAmB,IAAI,CAAC,GAAG,EAAE,UAAU,EAAE;YAC/D,cAAc,EAAE,OAAO,CAAC,cAAc;SACvC,CAAC,CAAC;QACH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C,GAAG,EAAE,YAAY,KAAK,EAAE,CAAC,CAAC;QAC3E,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,SAAS;QACb,MAAM,MAAM,GAAG,MAAM,GAAG,CACtB,IAAI,CAAC,GAAG,EACR,cAAc,CACf,CAAC;QACF,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,SAAS;QACb,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,CAAC;QACvD,OAAO,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,OAAO,CAAC,KAAa;QACzB,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAClC,IAAI,CAAC,GAAG,CAAC,QAAQ;gBAAE,OAAO,KAAK,CAAC;YAChC,IAAI,GAAG,CAAC,SAAS,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,IAAI,IAAI,EAAE;gBAAE,OAAO,KAAK,CAAC;YACxE,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF"}
@@ -1,53 +0,0 @@
1
- /**
2
- * Scrape Resource
3
- * Handles single page scraping operations
4
- */
5
- import type { RequestContext } from "../types/config";
6
- import type { ScrapeOptions } from "../types/options";
7
- import type { ScrapeJobResponse } from "../types/responses";
8
- /**
9
- * Scrape resource class
10
- * Provides methods for single page scraping
11
- */
12
- export declare class ScrapeResource {
13
- private ctx;
14
- constructor(ctx: RequestContext);
15
- /**
16
- * Create a new scrape job
17
- *
18
- * @example
19
- * ```ts
20
- * const job = await client.scrape.create({
21
- * url: "https://example.com/product",
22
- * extractDeal: true,
23
- * screenshot: { enabled: true, format: "webp" }
24
- * });
25
- * console.log(job.jobId);
26
- * ```
27
- */
28
- create(options: ScrapeOptions): Promise<ScrapeJobResponse>;
29
- /**
30
- * Scrape a URL with deal extraction enabled
31
- * Convenience method for common use case
32
- *
33
- * @example
34
- * ```ts
35
- * const job = await client.scrape.extractDeal("https://example.com/sale");
36
- * ```
37
- */
38
- extractDeal(url: string, options?: Omit<ScrapeOptions, "url" | "extractDeal">): Promise<ScrapeJobResponse>;
39
- /**
40
- * Scrape a URL with screenshot capture
41
- * Convenience method for screenshot capture
42
- *
43
- * @example
44
- * ```ts
45
- * const job = await client.scrape.withScreenshot("https://example.com", {
46
- * format: "webp",
47
- * fullPage: true
48
- * });
49
- * ```
50
- */
51
- withScreenshot(url: string, screenshotOptions?: Omit<ScrapeOptions["screenshot"], "enabled">, options?: Omit<ScrapeOptions, "url" | "screenshot">): Promise<ScrapeJobResponse>;
52
- }
53
- //# sourceMappingURL=scrape.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scrape.d.ts","sourceRoot":"","sources":["../../src/resources/scrape.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAG5D;;;GAGG;AACH,qBAAa,cAAc;IACb,OAAO,CAAC,GAAG;gBAAH,GAAG,EAAE,cAAc;IAEvC;;;;;;;;;;;;OAYG;IACG,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAoBhE;;;;;;;;OAQG;IACG,WAAW,CACf,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,GAAG,aAAa,CAAC,GACnD,OAAO,CAAC,iBAAiB,CAAC;IAQ7B;;;;;;;;;;;OAWG;IACG,cAAc,CAClB,GAAG,EAAE,MAAM,EACX,iBAAiB,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,EAAE,SAAS,CAAC,EAChE,OAAO,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,GAAG,YAAY,CAAC,GAClD,OAAO,CAAC,iBAAiB,CAAC;CAU9B"}