fix(js-sdk/extract): use same zod fallback logic (#1711)

This commit is contained in:
Gergő Móricz 2025-06-25 19:59:58 +02:00 committed by GitHub
parent 3d04c2087e
commit f4714f4849
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 13 additions and 14 deletions

View File

@ -4,9 +4,6 @@ on:
pull_request:
branches:
- main
paths:
- apps/api/**
- apps/playwright-service-ts/**
env:
PORT: 3002

View File

@ -4,10 +4,6 @@ on:
pull_request:
branches:
- main
paths:
- apps/api/**
# schedule:
# - cron: '0 */4 * * *'
env:
BULL_AUTH_KEY: ${{ secrets.BULL_AUTH_KEY }}

View File

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

View File

@ -1244,10 +1244,12 @@ export default class FirecrawlApp {
try {
if (!params?.schema) {
jsonSchema = undefined;
} else if (typeof params.schema === "object" && params.schema !== null && Object.getPrototypeOf(params.schema)?.constructor?.name?.startsWith("Zod")) {
jsonSchema = zodToJsonSchema(params.schema as zt.ZodType);
} else {
jsonSchema = params.schema;
try {
jsonSchema = zodToJsonSchema(params.schema as zt.ZodType);
} catch (_) {
jsonSchema = params.schema;
}
}
} catch (error: any) {
throw new FirecrawlError("Invalid schema. Schema must be either a valid Zod schema or JSON schema object.", 400);
@ -1312,10 +1314,14 @@ export default class FirecrawlApp {
let jsonSchema: any;
try {
if (params?.schema instanceof zt.ZodType) {
jsonSchema = zodToJsonSchema(params.schema);
if (!params?.schema) {
jsonSchema = undefined;
} else {
jsonSchema = params?.schema;
try {
jsonSchema = zodToJsonSchema(params.schema as zt.ZodType);
} catch (_) {
jsonSchema = params.schema;
}
}
} catch (error: any) {
throw new FirecrawlError("Invalid schema. Schema must be either a valid Zod schema or JSON schema object.", 400);