mirror of
https://git.mirrors.martin98.com/https://github.com/mendableai/firecrawl
synced 2025-08-14 22:55:59 +08:00
fix(js-sdk/batchScrapeUrls): zod support
This commit is contained in:
parent
f007f2439e
commit
fe6b003fcf
4
apps/js-sdk/firecrawl/package-lock.json
generated
4
apps/js-sdk/firecrawl/package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@mendable/firecrawl-js",
|
"name": "@mendable/firecrawl-js",
|
||||||
"version": "1.4.4",
|
"version": "1.9.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@mendable/firecrawl-js",
|
"name": "@mendable/firecrawl-js",
|
||||||
"version": "1.4.4",
|
"version": "1.9.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.6.8",
|
"axios": "^1.6.8",
|
||||||
|
@ -577,7 +577,24 @@ export default class FirecrawlApp {
|
|||||||
webhook?: CrawlParams["webhook"],
|
webhook?: CrawlParams["webhook"],
|
||||||
): Promise<BatchScrapeStatusResponse | ErrorResponse> {
|
): Promise<BatchScrapeStatusResponse | ErrorResponse> {
|
||||||
const headers = this.prepareHeaders(idempotencyKey);
|
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 {
|
try {
|
||||||
const response: AxiosResponse = await this.postRequest(
|
const response: AxiosResponse = await this.postRequest(
|
||||||
this.apiUrl + `/v1/batch/scrape`,
|
this.apiUrl + `/v1/batch/scrape`,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user