@mendable/firecrawl-js 1.4.0 → 1.4.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/dist/index.d.cts +16 -18
- package/dist/index.d.ts +16 -18
- package/package.json +1 -1
- package/src/index.ts +18 -21
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosRequestHeaders, AxiosResponse } from 'axios';
|
|
2
|
-
import { ZodSchema
|
|
2
|
+
import { ZodSchema } from 'zod';
|
|
3
3
|
import { TypedEventTarget } from 'typescript-event-target';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -54,13 +54,13 @@ interface FirecrawlDocumentMetadata {
|
|
|
54
54
|
* Document interface for Firecrawl.
|
|
55
55
|
* Represents a document retrieved or processed by Firecrawl.
|
|
56
56
|
*/
|
|
57
|
-
interface FirecrawlDocument
|
|
57
|
+
interface FirecrawlDocument {
|
|
58
58
|
url?: string;
|
|
59
59
|
markdown?: string;
|
|
60
60
|
html?: string;
|
|
61
61
|
rawHtml?: string;
|
|
62
62
|
links?: string[];
|
|
63
|
-
extract?:
|
|
63
|
+
extract?: Record<any, any>;
|
|
64
64
|
screenshot?: string;
|
|
65
65
|
metadata?: FirecrawlDocumentMetadata;
|
|
66
66
|
}
|
|
@@ -68,27 +68,25 @@ interface FirecrawlDocument<T> {
|
|
|
68
68
|
* Parameters for scraping operations.
|
|
69
69
|
* Defines the options and configurations available for scraping web content.
|
|
70
70
|
*/
|
|
71
|
-
interface
|
|
71
|
+
interface ScrapeParams {
|
|
72
72
|
formats: ("markdown" | "html" | "rawHtml" | "content" | "links" | "screenshot" | "extract" | "full@scrennshot")[];
|
|
73
73
|
headers?: Record<string, string>;
|
|
74
74
|
includeTags?: string[];
|
|
75
75
|
excludeTags?: string[];
|
|
76
76
|
onlyMainContent?: boolean;
|
|
77
|
-
waitFor?: number;
|
|
78
|
-
timeout?: number;
|
|
79
|
-
}
|
|
80
|
-
interface ScrapeParams<LLMSchema extends ZodSchema> extends CrawlScrapeOptions {
|
|
81
77
|
extract?: {
|
|
82
78
|
prompt?: string;
|
|
83
|
-
schema?:
|
|
79
|
+
schema?: ZodSchema | any;
|
|
84
80
|
systemPrompt?: string;
|
|
85
81
|
};
|
|
82
|
+
waitFor?: number;
|
|
83
|
+
timeout?: number;
|
|
86
84
|
}
|
|
87
85
|
/**
|
|
88
86
|
* Response interface for scraping operations.
|
|
89
87
|
* Defines the structure of the response received after a scraping operation.
|
|
90
88
|
*/
|
|
91
|
-
interface ScrapeResponse
|
|
89
|
+
interface ScrapeResponse extends FirecrawlDocument {
|
|
92
90
|
success: true;
|
|
93
91
|
warning?: string;
|
|
94
92
|
error?: string;
|
|
@@ -105,7 +103,7 @@ interface CrawlParams {
|
|
|
105
103
|
allowBackwardLinks?: boolean;
|
|
106
104
|
allowExternalLinks?: boolean;
|
|
107
105
|
ignoreSitemap?: boolean;
|
|
108
|
-
scrapeOptions?:
|
|
106
|
+
scrapeOptions?: ScrapeParams;
|
|
109
107
|
webhook?: string;
|
|
110
108
|
}
|
|
111
109
|
/**
|
|
@@ -130,7 +128,7 @@ interface CrawlStatusResponse {
|
|
|
130
128
|
creditsUsed: number;
|
|
131
129
|
expiresAt: Date;
|
|
132
130
|
next?: string;
|
|
133
|
-
data: FirecrawlDocument
|
|
131
|
+
data: FirecrawlDocument[];
|
|
134
132
|
}
|
|
135
133
|
/**
|
|
136
134
|
* Parameters for mapping operations.
|
|
@@ -177,7 +175,7 @@ declare class FirecrawlApp {
|
|
|
177
175
|
* @param params - Additional parameters for the scrape request.
|
|
178
176
|
* @returns The response from the scrape operation.
|
|
179
177
|
*/
|
|
180
|
-
scrapeUrl
|
|
178
|
+
scrapeUrl(url: string, params?: ScrapeParams): Promise<ScrapeResponse | ErrorResponse>;
|
|
181
179
|
/**
|
|
182
180
|
* This method is intended to search for a query using the Firecrawl API. However, it is not supported in version 1 of the API.
|
|
183
181
|
* @param query - The search query string.
|
|
@@ -242,23 +240,23 @@ declare class FirecrawlApp {
|
|
|
242
240
|
handleError(response: AxiosResponse, action: string): void;
|
|
243
241
|
}
|
|
244
242
|
interface CrawlWatcherEvents {
|
|
245
|
-
document: CustomEvent<FirecrawlDocument
|
|
243
|
+
document: CustomEvent<FirecrawlDocument>;
|
|
246
244
|
done: CustomEvent<{
|
|
247
245
|
status: CrawlStatusResponse["status"];
|
|
248
|
-
data: FirecrawlDocument
|
|
246
|
+
data: FirecrawlDocument[];
|
|
249
247
|
}>;
|
|
250
248
|
error: CustomEvent<{
|
|
251
249
|
status: CrawlStatusResponse["status"];
|
|
252
|
-
data: FirecrawlDocument
|
|
250
|
+
data: FirecrawlDocument[];
|
|
253
251
|
error: string;
|
|
254
252
|
}>;
|
|
255
253
|
}
|
|
256
254
|
declare class CrawlWatcher extends TypedEventTarget<CrawlWatcherEvents> {
|
|
257
255
|
private ws;
|
|
258
|
-
data: FirecrawlDocument
|
|
256
|
+
data: FirecrawlDocument[];
|
|
259
257
|
status: CrawlStatusResponse["status"];
|
|
260
258
|
constructor(id: string, app: FirecrawlApp);
|
|
261
259
|
close(): void;
|
|
262
260
|
}
|
|
263
261
|
|
|
264
|
-
export { type CrawlParams, type CrawlResponse, type
|
|
262
|
+
export { type CrawlParams, type CrawlResponse, type CrawlStatusResponse, CrawlWatcher, type ErrorResponse, type FirecrawlAppConfig, type FirecrawlDocument, type FirecrawlDocumentMetadata, type MapParams, type MapResponse, type ScrapeParams, type ScrapeResponse, FirecrawlApp as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosRequestHeaders, AxiosResponse } from 'axios';
|
|
2
|
-
import { ZodSchema
|
|
2
|
+
import { ZodSchema } from 'zod';
|
|
3
3
|
import { TypedEventTarget } from 'typescript-event-target';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -54,13 +54,13 @@ interface FirecrawlDocumentMetadata {
|
|
|
54
54
|
* Document interface for Firecrawl.
|
|
55
55
|
* Represents a document retrieved or processed by Firecrawl.
|
|
56
56
|
*/
|
|
57
|
-
interface FirecrawlDocument
|
|
57
|
+
interface FirecrawlDocument {
|
|
58
58
|
url?: string;
|
|
59
59
|
markdown?: string;
|
|
60
60
|
html?: string;
|
|
61
61
|
rawHtml?: string;
|
|
62
62
|
links?: string[];
|
|
63
|
-
extract?:
|
|
63
|
+
extract?: Record<any, any>;
|
|
64
64
|
screenshot?: string;
|
|
65
65
|
metadata?: FirecrawlDocumentMetadata;
|
|
66
66
|
}
|
|
@@ -68,27 +68,25 @@ interface FirecrawlDocument<T> {
|
|
|
68
68
|
* Parameters for scraping operations.
|
|
69
69
|
* Defines the options and configurations available for scraping web content.
|
|
70
70
|
*/
|
|
71
|
-
interface
|
|
71
|
+
interface ScrapeParams {
|
|
72
72
|
formats: ("markdown" | "html" | "rawHtml" | "content" | "links" | "screenshot" | "extract" | "full@scrennshot")[];
|
|
73
73
|
headers?: Record<string, string>;
|
|
74
74
|
includeTags?: string[];
|
|
75
75
|
excludeTags?: string[];
|
|
76
76
|
onlyMainContent?: boolean;
|
|
77
|
-
waitFor?: number;
|
|
78
|
-
timeout?: number;
|
|
79
|
-
}
|
|
80
|
-
interface ScrapeParams<LLMSchema extends ZodSchema> extends CrawlScrapeOptions {
|
|
81
77
|
extract?: {
|
|
82
78
|
prompt?: string;
|
|
83
|
-
schema?:
|
|
79
|
+
schema?: ZodSchema | any;
|
|
84
80
|
systemPrompt?: string;
|
|
85
81
|
};
|
|
82
|
+
waitFor?: number;
|
|
83
|
+
timeout?: number;
|
|
86
84
|
}
|
|
87
85
|
/**
|
|
88
86
|
* Response interface for scraping operations.
|
|
89
87
|
* Defines the structure of the response received after a scraping operation.
|
|
90
88
|
*/
|
|
91
|
-
interface ScrapeResponse
|
|
89
|
+
interface ScrapeResponse extends FirecrawlDocument {
|
|
92
90
|
success: true;
|
|
93
91
|
warning?: string;
|
|
94
92
|
error?: string;
|
|
@@ -105,7 +103,7 @@ interface CrawlParams {
|
|
|
105
103
|
allowBackwardLinks?: boolean;
|
|
106
104
|
allowExternalLinks?: boolean;
|
|
107
105
|
ignoreSitemap?: boolean;
|
|
108
|
-
scrapeOptions?:
|
|
106
|
+
scrapeOptions?: ScrapeParams;
|
|
109
107
|
webhook?: string;
|
|
110
108
|
}
|
|
111
109
|
/**
|
|
@@ -130,7 +128,7 @@ interface CrawlStatusResponse {
|
|
|
130
128
|
creditsUsed: number;
|
|
131
129
|
expiresAt: Date;
|
|
132
130
|
next?: string;
|
|
133
|
-
data: FirecrawlDocument
|
|
131
|
+
data: FirecrawlDocument[];
|
|
134
132
|
}
|
|
135
133
|
/**
|
|
136
134
|
* Parameters for mapping operations.
|
|
@@ -177,7 +175,7 @@ declare class FirecrawlApp {
|
|
|
177
175
|
* @param params - Additional parameters for the scrape request.
|
|
178
176
|
* @returns The response from the scrape operation.
|
|
179
177
|
*/
|
|
180
|
-
scrapeUrl
|
|
178
|
+
scrapeUrl(url: string, params?: ScrapeParams): Promise<ScrapeResponse | ErrorResponse>;
|
|
181
179
|
/**
|
|
182
180
|
* This method is intended to search for a query using the Firecrawl API. However, it is not supported in version 1 of the API.
|
|
183
181
|
* @param query - The search query string.
|
|
@@ -242,23 +240,23 @@ declare class FirecrawlApp {
|
|
|
242
240
|
handleError(response: AxiosResponse, action: string): void;
|
|
243
241
|
}
|
|
244
242
|
interface CrawlWatcherEvents {
|
|
245
|
-
document: CustomEvent<FirecrawlDocument
|
|
243
|
+
document: CustomEvent<FirecrawlDocument>;
|
|
246
244
|
done: CustomEvent<{
|
|
247
245
|
status: CrawlStatusResponse["status"];
|
|
248
|
-
data: FirecrawlDocument
|
|
246
|
+
data: FirecrawlDocument[];
|
|
249
247
|
}>;
|
|
250
248
|
error: CustomEvent<{
|
|
251
249
|
status: CrawlStatusResponse["status"];
|
|
252
|
-
data: FirecrawlDocument
|
|
250
|
+
data: FirecrawlDocument[];
|
|
253
251
|
error: string;
|
|
254
252
|
}>;
|
|
255
253
|
}
|
|
256
254
|
declare class CrawlWatcher extends TypedEventTarget<CrawlWatcherEvents> {
|
|
257
255
|
private ws;
|
|
258
|
-
data: FirecrawlDocument
|
|
256
|
+
data: FirecrawlDocument[];
|
|
259
257
|
status: CrawlStatusResponse["status"];
|
|
260
258
|
constructor(id: string, app: FirecrawlApp);
|
|
261
259
|
close(): void;
|
|
262
260
|
}
|
|
263
261
|
|
|
264
|
-
export { type CrawlParams, type CrawlResponse, type
|
|
262
|
+
export { type CrawlParams, type CrawlResponse, type CrawlStatusResponse, CrawlWatcher, type ErrorResponse, type FirecrawlAppConfig, type FirecrawlDocument, type FirecrawlDocumentMetadata, type MapParams, type MapResponse, type ScrapeParams, type ScrapeResponse, FirecrawlApp as default };
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import axios, { type AxiosResponse, type AxiosRequestHeaders } from "axios";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ZodSchema } from "zod";
|
|
3
3
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
4
4
|
import { WebSocket } from "isows";
|
|
5
5
|
import { TypedEventTarget } from "typescript-event-target";
|
|
@@ -58,13 +58,13 @@ export interface FirecrawlDocumentMetadata {
|
|
|
58
58
|
* Document interface for Firecrawl.
|
|
59
59
|
* Represents a document retrieved or processed by Firecrawl.
|
|
60
60
|
*/
|
|
61
|
-
export interface FirecrawlDocument
|
|
61
|
+
export interface FirecrawlDocument {
|
|
62
62
|
url?: string;
|
|
63
63
|
markdown?: string;
|
|
64
64
|
html?: string;
|
|
65
65
|
rawHtml?: string;
|
|
66
66
|
links?: string[];
|
|
67
|
-
extract?:
|
|
67
|
+
extract?: Record<any, any>;
|
|
68
68
|
screenshot?: string;
|
|
69
69
|
metadata?: FirecrawlDocumentMetadata;
|
|
70
70
|
}
|
|
@@ -73,29 +73,26 @@ export interface FirecrawlDocument<T> {
|
|
|
73
73
|
* Parameters for scraping operations.
|
|
74
74
|
* Defines the options and configurations available for scraping web content.
|
|
75
75
|
*/
|
|
76
|
-
export interface
|
|
76
|
+
export interface ScrapeParams {
|
|
77
77
|
formats: ("markdown" | "html" | "rawHtml" | "content" | "links" | "screenshot" | "extract" | "full@scrennshot")[];
|
|
78
78
|
headers?: Record<string, string>;
|
|
79
79
|
includeTags?: string[];
|
|
80
80
|
excludeTags?: string[];
|
|
81
81
|
onlyMainContent?: boolean;
|
|
82
|
-
waitFor?: number;
|
|
83
|
-
timeout?: number;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export interface ScrapeParams<LLMSchema extends ZodSchema> extends CrawlScrapeOptions {
|
|
87
82
|
extract?: {
|
|
88
83
|
prompt?: string;
|
|
89
|
-
schema?:
|
|
84
|
+
schema?: ZodSchema | any;
|
|
90
85
|
systemPrompt?: string;
|
|
91
86
|
};
|
|
87
|
+
waitFor?: number;
|
|
88
|
+
timeout?: number;
|
|
92
89
|
}
|
|
93
90
|
|
|
94
91
|
/**
|
|
95
92
|
* Response interface for scraping operations.
|
|
96
93
|
* Defines the structure of the response received after a scraping operation.
|
|
97
94
|
*/
|
|
98
|
-
export interface ScrapeResponse
|
|
95
|
+
export interface ScrapeResponse extends FirecrawlDocument {
|
|
99
96
|
success: true;
|
|
100
97
|
warning?: string;
|
|
101
98
|
error?: string;
|
|
@@ -113,7 +110,7 @@ export interface CrawlParams {
|
|
|
113
110
|
allowBackwardLinks?: boolean;
|
|
114
111
|
allowExternalLinks?: boolean;
|
|
115
112
|
ignoreSitemap?: boolean;
|
|
116
|
-
scrapeOptions?:
|
|
113
|
+
scrapeOptions?: ScrapeParams;
|
|
117
114
|
webhook?: string;
|
|
118
115
|
}
|
|
119
116
|
|
|
@@ -140,7 +137,7 @@ export interface CrawlStatusResponse {
|
|
|
140
137
|
creditsUsed: number;
|
|
141
138
|
expiresAt: Date;
|
|
142
139
|
next?: string;
|
|
143
|
-
data: FirecrawlDocument
|
|
140
|
+
data: FirecrawlDocument[];
|
|
144
141
|
};
|
|
145
142
|
|
|
146
143
|
/**
|
|
@@ -200,10 +197,10 @@ export default class FirecrawlApp {
|
|
|
200
197
|
* @param params - Additional parameters for the scrape request.
|
|
201
198
|
* @returns The response from the scrape operation.
|
|
202
199
|
*/
|
|
203
|
-
async scrapeUrl
|
|
200
|
+
async scrapeUrl(
|
|
204
201
|
url: string,
|
|
205
|
-
params?: ScrapeParams
|
|
206
|
-
): Promise<ScrapeResponse
|
|
202
|
+
params?: ScrapeParams
|
|
203
|
+
): Promise<ScrapeResponse | ErrorResponse> {
|
|
207
204
|
const headers: AxiosRequestHeaders = {
|
|
208
205
|
"Content-Type": "application/json",
|
|
209
206
|
Authorization: `Bearer ${this.apiKey}`,
|
|
@@ -531,21 +528,21 @@ export default class FirecrawlApp {
|
|
|
531
528
|
}
|
|
532
529
|
|
|
533
530
|
interface CrawlWatcherEvents {
|
|
534
|
-
document: CustomEvent<FirecrawlDocument
|
|
531
|
+
document: CustomEvent<FirecrawlDocument>,
|
|
535
532
|
done: CustomEvent<{
|
|
536
533
|
status: CrawlStatusResponse["status"];
|
|
537
|
-
data: FirecrawlDocument
|
|
534
|
+
data: FirecrawlDocument[];
|
|
538
535
|
}>,
|
|
539
536
|
error: CustomEvent<{
|
|
540
537
|
status: CrawlStatusResponse["status"],
|
|
541
|
-
data: FirecrawlDocument
|
|
538
|
+
data: FirecrawlDocument[],
|
|
542
539
|
error: string,
|
|
543
540
|
}>,
|
|
544
541
|
}
|
|
545
542
|
|
|
546
543
|
export class CrawlWatcher extends TypedEventTarget<CrawlWatcherEvents> {
|
|
547
544
|
private ws: WebSocket;
|
|
548
|
-
public data: FirecrawlDocument
|
|
545
|
+
public data: FirecrawlDocument[];
|
|
549
546
|
public status: CrawlStatusResponse["status"];
|
|
550
547
|
|
|
551
548
|
constructor(id: string, app: FirecrawlApp) {
|
|
@@ -566,7 +563,7 @@ export class CrawlWatcher extends TypedEventTarget<CrawlWatcherEvents> {
|
|
|
566
563
|
|
|
567
564
|
type DocumentMessage = {
|
|
568
565
|
type: "document",
|
|
569
|
-
data: FirecrawlDocument
|
|
566
|
+
data: FirecrawlDocument,
|
|
570
567
|
}
|
|
571
568
|
|
|
572
569
|
type DoneMessage = { type: "done" }
|