@mendable/firecrawl-js 0.0.17-beta.3 → 0.0.17-beta.4
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 -3
- package/package.json +1 -1
- package/src/index.ts +8 -5
- package/types/index.d.ts +3 -2
package/build/index.js
CHANGED
|
@@ -39,9 +39,12 @@ export default class FirecrawlApp {
|
|
|
39
39
|
if (params) {
|
|
40
40
|
jsonData = Object.assign(Object.assign({}, jsonData), params);
|
|
41
41
|
}
|
|
42
|
-
if (extractorOptions
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
if (extractorOptions) {
|
|
43
|
+
jsonData.extractorOptions = Object.assign({}, extractorOptions);
|
|
44
|
+
}
|
|
45
|
+
if (extractorOptions === null || extractorOptions === void 0 ? void 0 : extractorOptions.extractionSchema) {
|
|
46
|
+
const schema = zodToJsonSchema(extractorOptions.extractionSchema);
|
|
47
|
+
jsonData = Object.assign(Object.assign({}, jsonData), { extractorOptions: Object.assign(Object.assign({}, extractorOptions), { extractionSchema: schema }) });
|
|
45
48
|
}
|
|
46
49
|
try {
|
|
47
50
|
const response = yield axios.post('https://api.firecrawl.dev/v0/scrape', jsonData, { headers });
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -76,18 +76,21 @@ export default class FirecrawlApp {
|
|
|
76
76
|
* @param {Params | null} params - Additional parameters for the scrape request.
|
|
77
77
|
* @returns {Promise<ScrapeResponse>} The response from the scrape operation.
|
|
78
78
|
*/
|
|
79
|
-
async scrapeUrl(url: string, params: Params | null = null, extractorOptions?: {
|
|
79
|
+
async scrapeUrl(url: string, params: Params | null = null, extractorOptions?: { mode: 'llm-extraction'; extractionPrompt?: string; extractionSchema: object }): Promise<ScrapeResponse> {
|
|
80
80
|
const headers: AxiosRequestHeaders = {
|
|
81
81
|
'Content-Type': 'application/json',
|
|
82
82
|
'Authorization': `Bearer ${this.apiKey}`,
|
|
83
83
|
} as AxiosRequestHeaders;
|
|
84
|
-
let jsonData: Params = { url };
|
|
84
|
+
let jsonData: Params & { extractorOptions?: { extractionSchema: z.ZodSchema | any, mode?: 'llm-extraction'; extractionPrompt?: string; } } = { url };
|
|
85
85
|
if (params) {
|
|
86
86
|
jsonData = { ...jsonData, ...params };
|
|
87
87
|
}
|
|
88
|
-
if (extractorOptions
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
if (extractorOptions) {
|
|
89
|
+
jsonData.extractorOptions = { ...extractorOptions };
|
|
90
|
+
}
|
|
91
|
+
if (extractorOptions?.extractionSchema) {
|
|
92
|
+
const schema = zodToJsonSchema(extractorOptions.extractionSchema as z.ZodSchema);
|
|
93
|
+
jsonData = { ...jsonData, extractorOptions: { ...extractorOptions, extractionSchema: schema } };
|
|
91
94
|
}
|
|
92
95
|
try {
|
|
93
96
|
const response: AxiosResponse = await axios.post('https://api.firecrawl.dev/v0/scrape', jsonData, { headers });
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AxiosResponse, AxiosRequestHeaders } from 'axios';
|
|
2
|
-
import { z } from 'zod';
|
|
3
2
|
/**
|
|
4
3
|
* Configuration interface for FirecrawlApp.
|
|
5
4
|
*/
|
|
@@ -64,7 +63,9 @@ export default class FirecrawlApp {
|
|
|
64
63
|
* @returns {Promise<ScrapeResponse>} The response from the scrape operation.
|
|
65
64
|
*/
|
|
66
65
|
scrapeUrl(url: string, params?: Params | null, extractorOptions?: {
|
|
67
|
-
|
|
66
|
+
mode: 'llm-extraction';
|
|
67
|
+
extractionPrompt?: string;
|
|
68
|
+
extractionSchema: object;
|
|
68
69
|
}): Promise<ScrapeResponse>;
|
|
69
70
|
/**
|
|
70
71
|
* Searches for a query using the Firecrawl API.
|