@mendable/firecrawl-js 0.0.17-beta.3 → 0.0.17-beta.5
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/build/index.js +6 -8
- package/package.json +1 -1
- package/src/index.ts +10 -8
- package/types/index.d.ts +6 -3
package/build/index.js
CHANGED
|
@@ -30,18 +30,16 @@ export default class FirecrawlApp {
|
|
|
30
30
|
* @returns {Promise<ScrapeResponse>} The response from the scrape operation.
|
|
31
31
|
*/
|
|
32
32
|
scrapeUrl(url_1) {
|
|
33
|
-
return __awaiter(this, arguments, void 0, function* (url, params = null
|
|
33
|
+
return __awaiter(this, arguments, void 0, function* (url, params = null) {
|
|
34
|
+
var _a;
|
|
34
35
|
const headers = {
|
|
35
36
|
'Content-Type': 'application/json',
|
|
36
37
|
'Authorization': `Bearer ${this.apiKey}`,
|
|
37
38
|
};
|
|
38
|
-
let jsonData = { url };
|
|
39
|
-
if (params) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (extractorOptions === null || extractorOptions === void 0 ? void 0 : extractorOptions.schema) {
|
|
43
|
-
const schema = zodToJsonSchema(extractorOptions.schema);
|
|
44
|
-
jsonData = Object.assign(Object.assign({}, jsonData), { extractorOptions: Object.assign(Object.assign({}, extractorOptions), { schema }) });
|
|
39
|
+
let jsonData = Object.assign({ url }, params);
|
|
40
|
+
if ((_a = params === null || params === void 0 ? void 0 : params.extractorOptions) === null || _a === void 0 ? void 0 : _a.extractionSchema) {
|
|
41
|
+
const schema = zodToJsonSchema(params.extractorOptions.extractionSchema);
|
|
42
|
+
jsonData = Object.assign(Object.assign({}, jsonData), { extractorOptions: Object.assign(Object.assign({}, params.extractorOptions), { extractionSchema: schema }) });
|
|
45
43
|
}
|
|
46
44
|
try {
|
|
47
45
|
const response = yield axios.post('https://api.firecrawl.dev/v0/scrape', jsonData, { headers });
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -13,6 +13,11 @@ export interface FirecrawlAppConfig {
|
|
|
13
13
|
*/
|
|
14
14
|
export interface Params {
|
|
15
15
|
[key: string]: any;
|
|
16
|
+
extractorOptions?: {
|
|
17
|
+
extractionSchema: z.ZodSchema | any;
|
|
18
|
+
mode?: 'llm-extraction';
|
|
19
|
+
extractionPrompt?: string;
|
|
20
|
+
};
|
|
16
21
|
}
|
|
17
22
|
|
|
18
23
|
/**
|
|
@@ -76,18 +81,15 @@ export default class FirecrawlApp {
|
|
|
76
81
|
* @param {Params | null} params - Additional parameters for the scrape request.
|
|
77
82
|
* @returns {Promise<ScrapeResponse>} The response from the scrape operation.
|
|
78
83
|
*/
|
|
79
|
-
async scrapeUrl(url: string, params: Params | null = null
|
|
84
|
+
async scrapeUrl(url: string, params: Params | null = null): Promise<ScrapeResponse> {
|
|
80
85
|
const headers: AxiosRequestHeaders = {
|
|
81
86
|
'Content-Type': 'application/json',
|
|
82
87
|
'Authorization': `Bearer ${this.apiKey}`,
|
|
83
88
|
} as AxiosRequestHeaders;
|
|
84
|
-
let jsonData: Params = { url };
|
|
85
|
-
if (params) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (extractorOptions?.schema) {
|
|
89
|
-
const schema = zodToJsonSchema(extractorOptions.schema);
|
|
90
|
-
jsonData = { ...jsonData, extractorOptions: { ...extractorOptions, schema } };
|
|
89
|
+
let jsonData: Params = { url, ...params };
|
|
90
|
+
if (params?.extractorOptions?.extractionSchema) {
|
|
91
|
+
const schema = zodToJsonSchema(params.extractorOptions.extractionSchema as z.ZodSchema);
|
|
92
|
+
jsonData = { ...jsonData, extractorOptions: { ...params.extractorOptions, extractionSchema: schema } };
|
|
91
93
|
}
|
|
92
94
|
try {
|
|
93
95
|
const response: AxiosResponse = await axios.post('https://api.firecrawl.dev/v0/scrape', jsonData, { headers });
|
package/types/index.d.ts
CHANGED
|
@@ -11,6 +11,11 @@ export interface FirecrawlAppConfig {
|
|
|
11
11
|
*/
|
|
12
12
|
export interface Params {
|
|
13
13
|
[key: string]: any;
|
|
14
|
+
extractorOptions?: {
|
|
15
|
+
extractionSchema: z.ZodSchema | any;
|
|
16
|
+
mode?: 'llm-extraction';
|
|
17
|
+
extractionPrompt?: string;
|
|
18
|
+
};
|
|
14
19
|
}
|
|
15
20
|
/**
|
|
16
21
|
* Response interface for scraping operations.
|
|
@@ -63,9 +68,7 @@ export default class FirecrawlApp {
|
|
|
63
68
|
* @param {Params | null} params - Additional parameters for the scrape request.
|
|
64
69
|
* @returns {Promise<ScrapeResponse>} The response from the scrape operation.
|
|
65
70
|
*/
|
|
66
|
-
scrapeUrl(url: string, params?: Params | null
|
|
67
|
-
schema?: z.ZodType<any, any>;
|
|
68
|
-
}): Promise<ScrapeResponse>;
|
|
71
|
+
scrapeUrl(url: string, params?: Params | null): Promise<ScrapeResponse>;
|
|
69
72
|
/**
|
|
70
73
|
* Searches for a query using the Firecrawl API.
|
|
71
74
|
* @param {string} query - The query to search for.
|