fix(js-sdk/extract): fix zod type check with zod version discrepancy

This commit is contained in:
Gergő Móricz 2025-03-12 16:02:44 +01:00
parent 4cc33e1e8d
commit 0154e40685
2 changed files with 3 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@mendable/firecrawl-js", "name": "@mendable/firecrawl-js",
"version": "1.19.0", "version": "1.19.1",
"description": "JavaScript SDK for Firecrawl API", "description": "JavaScript SDK for Firecrawl API",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",

View File

@ -1130,8 +1130,8 @@ export default class FirecrawlApp {
try { try {
if (!params?.schema) { if (!params?.schema) {
jsonSchema = undefined; jsonSchema = undefined;
} else if (params.schema instanceof zt.ZodType) { } else if (typeof params.schema === "object" && params.schema !== null && Object.getPrototypeOf(params.schema)?.constructor?.name?.startsWith("Zod")) {
jsonSchema = zodToJsonSchema(params.schema); jsonSchema = zodToJsonSchema(params.schema as zt.ZodType);
} else { } else {
jsonSchema = params.schema; jsonSchema = params.schema;
} }
@ -1139,7 +1139,6 @@ export default class FirecrawlApp {
throw new FirecrawlError("Invalid schema. Schema must be either a valid Zod schema or JSON schema object.", 400); throw new FirecrawlError("Invalid schema. Schema must be either a valid Zod schema or JSON schema object.", 400);
} }
try { try {
const response: AxiosResponse = await this.postRequest( const response: AxiosResponse = await this.postRequest(
this.apiUrl + `/v1/extract`, this.apiUrl + `/v1/extract`,