fix(js-sdk/batchScrapeUrls): zod support

This commit is contained in:
Gergő Móricz 2024-12-09 18:49:48 +01:00
parent f007f2439e
commit fe6b003fcf
2 changed files with 20 additions and 3 deletions

View File

@ -1,12 +1,12 @@
{
"name": "@mendable/firecrawl-js",
"version": "1.4.4",
"version": "1.9.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@mendable/firecrawl-js",
"version": "1.4.4",
"version": "1.9.1",
"license": "MIT",
"dependencies": {
"axios": "^1.6.8",

View File

@ -577,7 +577,24 @@ export default class FirecrawlApp {
webhook?: CrawlParams["webhook"],
): Promise<BatchScrapeStatusResponse | ErrorResponse> {
const headers = this.prepareHeaders(idempotencyKey);
let jsonData: any = { urls, ...(params ?? {}), webhook };
let jsonData: any = { urls, ...params };
if (jsonData?.extract?.schema) {
let schema = jsonData.extract.schema;
// Try parsing the schema as a Zod schema
try {
schema = zodToJsonSchema(schema);
} catch (error) {
}
jsonData = {
...jsonData,
extract: {
...jsonData.extract,
schema: schema,
},
};
}
try {
const response: AxiosResponse = await this.postRequest(
this.apiUrl + `/v1/batch/scrape`,