@mendable/firecrawl 1.2.2 → 1.18.1
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.
- package/README.md +40 -0
- package/dist/index.cjs +778 -0
- package/dist/index.d.cts +452 -0
- package/dist/index.d.ts +452 -0
- package/dist/index.js +742 -0
- package/package.json +12 -14
- package/src/__tests__/index.test.ts +18 -9
- package/src/__tests__/v1/e2e_withAuth/index.test.ts +226 -113
- package/src/index.ts +1100 -130
- package/tsconfig.json +19 -105
- package/tsup.config.ts +9 -0
- package/build/cjs/index.js +0 -354
- package/build/cjs/package.json +0 -1
- package/build/esm/index.js +0 -346
- package/build/esm/package.json +0 -1
- package/types/index.d.ts +0 -260
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
import { AxiosRequestHeaders, AxiosResponse } from 'axios';
|
|
2
|
+
import * as zt from 'zod';
|
|
3
|
+
import { TypedEventTarget } from 'typescript-event-target';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Configuration interface for FirecrawlApp.
|
|
7
|
+
* @param apiKey - Optional API key for authentication.
|
|
8
|
+
* @param apiUrl - Optional base URL of the API; defaults to 'https://api.firecrawl.dev'.
|
|
9
|
+
*/
|
|
10
|
+
interface FirecrawlAppConfig {
|
|
11
|
+
apiKey?: string | null;
|
|
12
|
+
apiUrl?: string | null;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Metadata for a Firecrawl document.
|
|
16
|
+
* Includes various optional properties for document metadata.
|
|
17
|
+
*/
|
|
18
|
+
interface FirecrawlDocumentMetadata {
|
|
19
|
+
title?: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
language?: string;
|
|
22
|
+
keywords?: string;
|
|
23
|
+
robots?: string;
|
|
24
|
+
ogTitle?: string;
|
|
25
|
+
ogDescription?: string;
|
|
26
|
+
ogUrl?: string;
|
|
27
|
+
ogImage?: string;
|
|
28
|
+
ogAudio?: string;
|
|
29
|
+
ogDeterminer?: string;
|
|
30
|
+
ogLocale?: string;
|
|
31
|
+
ogLocaleAlternate?: string[];
|
|
32
|
+
ogSiteName?: string;
|
|
33
|
+
ogVideo?: string;
|
|
34
|
+
dctermsCreated?: string;
|
|
35
|
+
dcDateCreated?: string;
|
|
36
|
+
dcDate?: string;
|
|
37
|
+
dctermsType?: string;
|
|
38
|
+
dcType?: string;
|
|
39
|
+
dctermsAudience?: string;
|
|
40
|
+
dctermsSubject?: string;
|
|
41
|
+
dcSubject?: string;
|
|
42
|
+
dcDescription?: string;
|
|
43
|
+
dctermsKeywords?: string;
|
|
44
|
+
modifiedTime?: string;
|
|
45
|
+
publishedTime?: string;
|
|
46
|
+
articleTag?: string;
|
|
47
|
+
articleSection?: string;
|
|
48
|
+
sourceURL?: string;
|
|
49
|
+
statusCode?: number;
|
|
50
|
+
error?: string;
|
|
51
|
+
[key: string]: any;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Document interface for Firecrawl.
|
|
55
|
+
* Represents a document retrieved or processed by Firecrawl.
|
|
56
|
+
*/
|
|
57
|
+
interface FirecrawlDocument<T = any, ActionsSchema extends (ActionsResult | never) = never> {
|
|
58
|
+
url?: string;
|
|
59
|
+
markdown?: string;
|
|
60
|
+
html?: string;
|
|
61
|
+
rawHtml?: string;
|
|
62
|
+
links?: string[];
|
|
63
|
+
extract?: T;
|
|
64
|
+
screenshot?: string;
|
|
65
|
+
metadata?: FirecrawlDocumentMetadata;
|
|
66
|
+
actions: ActionsSchema;
|
|
67
|
+
title?: string;
|
|
68
|
+
description?: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Parameters for scraping operations.
|
|
72
|
+
* Defines the options and configurations available for scraping web content.
|
|
73
|
+
*/
|
|
74
|
+
interface CrawlScrapeOptions {
|
|
75
|
+
formats: ("markdown" | "html" | "rawHtml" | "content" | "links" | "screenshot" | "screenshot@fullPage" | "extract")[];
|
|
76
|
+
headers?: Record<string, string>;
|
|
77
|
+
includeTags?: string[];
|
|
78
|
+
excludeTags?: string[];
|
|
79
|
+
onlyMainContent?: boolean;
|
|
80
|
+
waitFor?: number;
|
|
81
|
+
timeout?: number;
|
|
82
|
+
location?: {
|
|
83
|
+
country?: string;
|
|
84
|
+
languages?: string[];
|
|
85
|
+
};
|
|
86
|
+
mobile?: boolean;
|
|
87
|
+
skipTlsVerification?: boolean;
|
|
88
|
+
removeBase64Images?: boolean;
|
|
89
|
+
}
|
|
90
|
+
type Action = {
|
|
91
|
+
type: "wait";
|
|
92
|
+
milliseconds?: number;
|
|
93
|
+
selector?: string;
|
|
94
|
+
} | {
|
|
95
|
+
type: "click";
|
|
96
|
+
selector: string;
|
|
97
|
+
} | {
|
|
98
|
+
type: "screenshot";
|
|
99
|
+
fullPage?: boolean;
|
|
100
|
+
} | {
|
|
101
|
+
type: "write";
|
|
102
|
+
text: string;
|
|
103
|
+
} | {
|
|
104
|
+
type: "press";
|
|
105
|
+
key: string;
|
|
106
|
+
} | {
|
|
107
|
+
type: "scroll";
|
|
108
|
+
direction?: "up" | "down";
|
|
109
|
+
selector?: string;
|
|
110
|
+
} | {
|
|
111
|
+
type: "scrape";
|
|
112
|
+
} | {
|
|
113
|
+
type: "executeJavascript";
|
|
114
|
+
script: string;
|
|
115
|
+
};
|
|
116
|
+
interface ScrapeParams<LLMSchema extends zt.ZodSchema = any, ActionsSchema extends (Action[] | undefined) = undefined> extends CrawlScrapeOptions {
|
|
117
|
+
extract?: {
|
|
118
|
+
prompt?: string;
|
|
119
|
+
schema?: LLMSchema;
|
|
120
|
+
systemPrompt?: string;
|
|
121
|
+
};
|
|
122
|
+
actions?: ActionsSchema;
|
|
123
|
+
}
|
|
124
|
+
interface ActionsResult {
|
|
125
|
+
screenshots: string[];
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Response interface for scraping operations.
|
|
129
|
+
* Defines the structure of the response received after a scraping operation.
|
|
130
|
+
*/
|
|
131
|
+
interface ScrapeResponse<LLMResult = any, ActionsSchema extends (ActionsResult | never) = never> extends FirecrawlDocument<LLMResult, ActionsSchema> {
|
|
132
|
+
success: true;
|
|
133
|
+
warning?: string;
|
|
134
|
+
error?: string;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Parameters for crawling operations.
|
|
138
|
+
* Includes options for both scraping and mapping during a crawl.
|
|
139
|
+
*/
|
|
140
|
+
interface CrawlParams {
|
|
141
|
+
includePaths?: string[];
|
|
142
|
+
excludePaths?: string[];
|
|
143
|
+
maxDepth?: number;
|
|
144
|
+
limit?: number;
|
|
145
|
+
allowBackwardLinks?: boolean;
|
|
146
|
+
allowExternalLinks?: boolean;
|
|
147
|
+
ignoreSitemap?: boolean;
|
|
148
|
+
scrapeOptions?: CrawlScrapeOptions;
|
|
149
|
+
webhook?: string | {
|
|
150
|
+
url: string;
|
|
151
|
+
headers?: Record<string, string>;
|
|
152
|
+
metadata?: Record<string, string>;
|
|
153
|
+
};
|
|
154
|
+
deduplicateSimilarURLs?: boolean;
|
|
155
|
+
ignoreQueryParameters?: boolean;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Response interface for crawling operations.
|
|
159
|
+
* Defines the structure of the response received after initiating a crawl.
|
|
160
|
+
*/
|
|
161
|
+
interface CrawlResponse {
|
|
162
|
+
id?: string;
|
|
163
|
+
url?: string;
|
|
164
|
+
success: true;
|
|
165
|
+
error?: string;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Response interface for batch scrape operations.
|
|
169
|
+
* Defines the structure of the response received after initiating a crawl.
|
|
170
|
+
*/
|
|
171
|
+
interface BatchScrapeResponse {
|
|
172
|
+
id?: string;
|
|
173
|
+
url?: string;
|
|
174
|
+
success: true;
|
|
175
|
+
error?: string;
|
|
176
|
+
invalidURLs?: string[];
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Response interface for job status checks.
|
|
180
|
+
* Provides detailed status of a crawl job including progress and results.
|
|
181
|
+
*/
|
|
182
|
+
interface CrawlStatusResponse {
|
|
183
|
+
success: true;
|
|
184
|
+
status: "scraping" | "completed" | "failed" | "cancelled";
|
|
185
|
+
completed: number;
|
|
186
|
+
total: number;
|
|
187
|
+
creditsUsed: number;
|
|
188
|
+
expiresAt: Date;
|
|
189
|
+
next?: string;
|
|
190
|
+
data: FirecrawlDocument<undefined>[];
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Response interface for batch scrape job status checks.
|
|
194
|
+
* Provides detailed status of a batch scrape job including progress and results.
|
|
195
|
+
*/
|
|
196
|
+
interface BatchScrapeStatusResponse {
|
|
197
|
+
success: true;
|
|
198
|
+
status: "scraping" | "completed" | "failed" | "cancelled";
|
|
199
|
+
completed: number;
|
|
200
|
+
total: number;
|
|
201
|
+
creditsUsed: number;
|
|
202
|
+
expiresAt: Date;
|
|
203
|
+
next?: string;
|
|
204
|
+
data: FirecrawlDocument<undefined>[];
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Parameters for mapping operations.
|
|
208
|
+
* Defines options for mapping URLs during a crawl.
|
|
209
|
+
*/
|
|
210
|
+
interface MapParams {
|
|
211
|
+
search?: string;
|
|
212
|
+
ignoreSitemap?: boolean;
|
|
213
|
+
includeSubdomains?: boolean;
|
|
214
|
+
sitemapOnly?: boolean;
|
|
215
|
+
limit?: number;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Response interface for mapping operations.
|
|
219
|
+
* Defines the structure of the response received after a mapping operation.
|
|
220
|
+
*/
|
|
221
|
+
interface MapResponse {
|
|
222
|
+
success: true;
|
|
223
|
+
links?: string[];
|
|
224
|
+
error?: string;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Parameters for extracting information from URLs.
|
|
228
|
+
* Defines options for extracting information from URLs.
|
|
229
|
+
*/
|
|
230
|
+
interface ExtractParams<LLMSchema extends zt.ZodSchema = any> {
|
|
231
|
+
prompt?: string;
|
|
232
|
+
schema?: LLMSchema | object;
|
|
233
|
+
systemPrompt?: string;
|
|
234
|
+
allowExternalLinks?: boolean;
|
|
235
|
+
includeSubdomains?: boolean;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Response interface for extracting information from URLs.
|
|
239
|
+
* Defines the structure of the response received after extracting information from URLs.
|
|
240
|
+
*/
|
|
241
|
+
interface ExtractResponse<LLMSchema extends zt.ZodSchema = any> {
|
|
242
|
+
success: boolean;
|
|
243
|
+
data: LLMSchema;
|
|
244
|
+
error?: string;
|
|
245
|
+
warning?: string;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Error response interface.
|
|
249
|
+
* Defines the structure of the response received when an error occurs.
|
|
250
|
+
*/
|
|
251
|
+
interface ErrorResponse {
|
|
252
|
+
success: false;
|
|
253
|
+
error: string;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Custom error class for Firecrawl.
|
|
257
|
+
* Extends the built-in Error class to include a status code.
|
|
258
|
+
*/
|
|
259
|
+
declare class FirecrawlError extends Error {
|
|
260
|
+
statusCode: number;
|
|
261
|
+
constructor(message: string, statusCode: number);
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Parameters for search operations.
|
|
265
|
+
* Defines options for searching and scraping search results.
|
|
266
|
+
*/
|
|
267
|
+
interface SearchParams {
|
|
268
|
+
limit?: number;
|
|
269
|
+
tbs?: string;
|
|
270
|
+
filter?: string;
|
|
271
|
+
lang?: string;
|
|
272
|
+
country?: string;
|
|
273
|
+
location?: string;
|
|
274
|
+
origin?: string;
|
|
275
|
+
timeout?: number;
|
|
276
|
+
scrapeOptions?: ScrapeParams;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Response interface for search operations.
|
|
280
|
+
* Defines the structure of the response received after a search operation.
|
|
281
|
+
*/
|
|
282
|
+
interface SearchResponse {
|
|
283
|
+
success: boolean;
|
|
284
|
+
data: FirecrawlDocument<undefined>[];
|
|
285
|
+
warning?: string;
|
|
286
|
+
error?: string;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Main class for interacting with the Firecrawl API.
|
|
290
|
+
* Provides methods for scraping, searching, crawling, and mapping web content.
|
|
291
|
+
*/
|
|
292
|
+
declare class FirecrawlApp {
|
|
293
|
+
apiKey: string;
|
|
294
|
+
apiUrl: string;
|
|
295
|
+
private isCloudService;
|
|
296
|
+
/**
|
|
297
|
+
* Initializes a new instance of the FirecrawlApp class.
|
|
298
|
+
* @param config - Configuration options for the FirecrawlApp instance.
|
|
299
|
+
*/
|
|
300
|
+
constructor({ apiKey, apiUrl }: FirecrawlAppConfig);
|
|
301
|
+
/**
|
|
302
|
+
* Scrapes a URL using the Firecrawl API.
|
|
303
|
+
* @param url - The URL to scrape.
|
|
304
|
+
* @param params - Additional parameters for the scrape request.
|
|
305
|
+
* @returns The response from the scrape operation.
|
|
306
|
+
*/
|
|
307
|
+
scrapeUrl<T extends zt.ZodSchema, ActionsSchema extends (Action[] | undefined) = undefined>(url: string, params?: ScrapeParams<T, ActionsSchema>): Promise<ScrapeResponse<zt.infer<T>, ActionsSchema extends Action[] ? ActionsResult : never> | ErrorResponse>;
|
|
308
|
+
/**
|
|
309
|
+
* Searches using the Firecrawl API and optionally scrapes the results.
|
|
310
|
+
* @param query - The search query string.
|
|
311
|
+
* @param params - Optional parameters for the search request.
|
|
312
|
+
* @returns The response from the search operation.
|
|
313
|
+
*/
|
|
314
|
+
search(query: string, params?: SearchParams | Record<string, any>): Promise<SearchResponse>;
|
|
315
|
+
/**
|
|
316
|
+
* Initiates a crawl job for a URL using the Firecrawl API.
|
|
317
|
+
* @param url - The URL to crawl.
|
|
318
|
+
* @param params - Additional parameters for the crawl request.
|
|
319
|
+
* @param pollInterval - Time in seconds for job status checks.
|
|
320
|
+
* @param idempotencyKey - Optional idempotency key for the request.
|
|
321
|
+
* @returns The response from the crawl operation.
|
|
322
|
+
*/
|
|
323
|
+
crawlUrl(url: string, params?: CrawlParams, pollInterval?: number, idempotencyKey?: string): Promise<CrawlStatusResponse | ErrorResponse>;
|
|
324
|
+
asyncCrawlUrl(url: string, params?: CrawlParams, idempotencyKey?: string): Promise<CrawlResponse | ErrorResponse>;
|
|
325
|
+
/**
|
|
326
|
+
* Checks the status of a crawl job using the Firecrawl API.
|
|
327
|
+
* @param id - The ID of the crawl operation.
|
|
328
|
+
* @param getAllData - Paginate through all the pages of documents, returning the full list of all documents. (default: `false`)
|
|
329
|
+
* @returns The response containing the job status.
|
|
330
|
+
*/
|
|
331
|
+
checkCrawlStatus(id?: string, getAllData?: boolean): Promise<CrawlStatusResponse | ErrorResponse>;
|
|
332
|
+
/**
|
|
333
|
+
* Cancels a crawl job using the Firecrawl API.
|
|
334
|
+
* @param id - The ID of the crawl operation.
|
|
335
|
+
* @returns The response from the cancel crawl operation.
|
|
336
|
+
*/
|
|
337
|
+
cancelCrawl(id: string): Promise<ErrorResponse>;
|
|
338
|
+
/**
|
|
339
|
+
* Initiates a crawl job and returns a CrawlWatcher to monitor the job via WebSocket.
|
|
340
|
+
* @param url - The URL to crawl.
|
|
341
|
+
* @param params - Additional parameters for the crawl request.
|
|
342
|
+
* @param idempotencyKey - Optional idempotency key for the request.
|
|
343
|
+
* @returns A CrawlWatcher instance to monitor the crawl job.
|
|
344
|
+
*/
|
|
345
|
+
crawlUrlAndWatch(url: string, params?: CrawlParams, idempotencyKey?: string): Promise<CrawlWatcher>;
|
|
346
|
+
/**
|
|
347
|
+
* Maps a URL using the Firecrawl API.
|
|
348
|
+
* @param url - The URL to map.
|
|
349
|
+
* @param params - Additional parameters for the map request.
|
|
350
|
+
* @returns The response from the map operation.
|
|
351
|
+
*/
|
|
352
|
+
mapUrl(url: string, params?: MapParams): Promise<MapResponse | ErrorResponse>;
|
|
353
|
+
/**
|
|
354
|
+
* Initiates a batch scrape job for multiple URLs using the Firecrawl API.
|
|
355
|
+
* @param url - The URLs to scrape.
|
|
356
|
+
* @param params - Additional parameters for the scrape request.
|
|
357
|
+
* @param pollInterval - Time in seconds for job status checks.
|
|
358
|
+
* @param idempotencyKey - Optional idempotency key for the request.
|
|
359
|
+
* @param webhook - Optional webhook for the batch scrape.
|
|
360
|
+
* @returns The response from the crawl operation.
|
|
361
|
+
*/
|
|
362
|
+
batchScrapeUrls(urls: string[], params?: ScrapeParams, pollInterval?: number, idempotencyKey?: string, webhook?: CrawlParams["webhook"], ignoreInvalidURLs?: boolean): Promise<BatchScrapeStatusResponse | ErrorResponse>;
|
|
363
|
+
asyncBatchScrapeUrls(urls: string[], params?: ScrapeParams, idempotencyKey?: string, webhook?: CrawlParams["webhook"], ignoreInvalidURLs?: boolean): Promise<BatchScrapeResponse | ErrorResponse>;
|
|
364
|
+
/**
|
|
365
|
+
* Initiates a batch scrape job and returns a CrawlWatcher to monitor the job via WebSocket.
|
|
366
|
+
* @param urls - The URL to scrape.
|
|
367
|
+
* @param params - Additional parameters for the scrape request.
|
|
368
|
+
* @param idempotencyKey - Optional idempotency key for the request.
|
|
369
|
+
* @returns A CrawlWatcher instance to monitor the crawl job.
|
|
370
|
+
*/
|
|
371
|
+
batchScrapeUrlsAndWatch(urls: string[], params?: ScrapeParams, idempotencyKey?: string, webhook?: CrawlParams["webhook"], ignoreInvalidURLs?: boolean): Promise<CrawlWatcher>;
|
|
372
|
+
/**
|
|
373
|
+
* Checks the status of a batch scrape job using the Firecrawl API.
|
|
374
|
+
* @param id - The ID of the batch scrape operation.
|
|
375
|
+
* @param getAllData - Paginate through all the pages of documents, returning the full list of all documents. (default: `false`)
|
|
376
|
+
* @returns The response containing the job status.
|
|
377
|
+
*/
|
|
378
|
+
checkBatchScrapeStatus(id?: string, getAllData?: boolean): Promise<BatchScrapeStatusResponse | ErrorResponse>;
|
|
379
|
+
/**
|
|
380
|
+
* Extracts information from URLs using the Firecrawl API.
|
|
381
|
+
* Currently in Beta. Expect breaking changes on future minor versions.
|
|
382
|
+
* @param url - The URL to extract information from.
|
|
383
|
+
* @param params - Additional parameters for the extract request.
|
|
384
|
+
* @returns The response from the extract operation.
|
|
385
|
+
*/
|
|
386
|
+
extract<T extends zt.ZodSchema = any>(urls: string[], params?: ExtractParams<T>): Promise<ExtractResponse<zt.infer<T>> | ErrorResponse>;
|
|
387
|
+
/**
|
|
388
|
+
* Prepares the headers for an API request.
|
|
389
|
+
* @param idempotencyKey - Optional key to ensure idempotency.
|
|
390
|
+
* @returns The prepared headers.
|
|
391
|
+
*/
|
|
392
|
+
prepareHeaders(idempotencyKey?: string): AxiosRequestHeaders;
|
|
393
|
+
/**
|
|
394
|
+
* Sends a POST request to the specified URL.
|
|
395
|
+
* @param url - The URL to send the request to.
|
|
396
|
+
* @param data - The data to send in the request.
|
|
397
|
+
* @param headers - The headers for the request.
|
|
398
|
+
* @returns The response from the POST request.
|
|
399
|
+
*/
|
|
400
|
+
postRequest(url: string, data: any, headers: AxiosRequestHeaders): Promise<AxiosResponse>;
|
|
401
|
+
/**
|
|
402
|
+
* Sends a GET request to the specified URL.
|
|
403
|
+
* @param url - The URL to send the request to.
|
|
404
|
+
* @param headers - The headers for the request.
|
|
405
|
+
* @returns The response from the GET request.
|
|
406
|
+
*/
|
|
407
|
+
getRequest(url: string, headers: AxiosRequestHeaders): Promise<AxiosResponse>;
|
|
408
|
+
/**
|
|
409
|
+
* Sends a DELETE request to the specified URL.
|
|
410
|
+
* @param url - The URL to send the request to.
|
|
411
|
+
* @param headers - The headers for the request.
|
|
412
|
+
* @returns The response from the DELETE request.
|
|
413
|
+
*/
|
|
414
|
+
deleteRequest(url: string, headers: AxiosRequestHeaders): Promise<AxiosResponse>;
|
|
415
|
+
/**
|
|
416
|
+
* Monitors the status of a crawl job until completion or failure.
|
|
417
|
+
* @param id - The ID of the crawl operation.
|
|
418
|
+
* @param headers - The headers for the request.
|
|
419
|
+
* @param checkInterval - Interval in seconds for job status checks.
|
|
420
|
+
* @param checkUrl - Optional URL to check the status (used for v1 API)
|
|
421
|
+
* @returns The final job status or data.
|
|
422
|
+
*/
|
|
423
|
+
monitorJobStatus(id: string, headers: AxiosRequestHeaders, checkInterval: number): Promise<CrawlStatusResponse | ErrorResponse>;
|
|
424
|
+
/**
|
|
425
|
+
* Handles errors from API responses.
|
|
426
|
+
* @param {AxiosResponse} response - The response from the API.
|
|
427
|
+
* @param {string} action - The action being performed when the error occurred.
|
|
428
|
+
*/
|
|
429
|
+
handleError(response: AxiosResponse, action: string): void;
|
|
430
|
+
}
|
|
431
|
+
interface CrawlWatcherEvents {
|
|
432
|
+
document: CustomEvent<FirecrawlDocument<undefined>>;
|
|
433
|
+
done: CustomEvent<{
|
|
434
|
+
status: CrawlStatusResponse["status"];
|
|
435
|
+
data: FirecrawlDocument<undefined>[];
|
|
436
|
+
}>;
|
|
437
|
+
error: CustomEvent<{
|
|
438
|
+
status: CrawlStatusResponse["status"];
|
|
439
|
+
data: FirecrawlDocument<undefined>[];
|
|
440
|
+
error: string;
|
|
441
|
+
}>;
|
|
442
|
+
}
|
|
443
|
+
declare class CrawlWatcher extends TypedEventTarget<CrawlWatcherEvents> {
|
|
444
|
+
private ws;
|
|
445
|
+
data: FirecrawlDocument<undefined>[];
|
|
446
|
+
status: CrawlStatusResponse["status"];
|
|
447
|
+
id: string;
|
|
448
|
+
constructor(id: string, app: FirecrawlApp);
|
|
449
|
+
close(): void;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
export { type Action, type ActionsResult, type BatchScrapeResponse, type BatchScrapeStatusResponse, type CrawlParams, type CrawlResponse, type CrawlScrapeOptions, type CrawlStatusResponse, CrawlWatcher, type ErrorResponse, type ExtractParams, type ExtractResponse, type FirecrawlAppConfig, type FirecrawlDocument, type FirecrawlDocumentMetadata, FirecrawlError, type MapParams, type MapResponse, type ScrapeParams, type ScrapeResponse, type SearchParams, type SearchResponse, FirecrawlApp as default };
|