mirror of
https://github.com/mendableai/firecrawl.git
synced 2025-06-27 00:41:33 +00:00
fix(js-sdk/extract): use same zod fallback logic (#1711)
This commit is contained in:
parent
3d04c2087e
commit
f4714f4849
3
.github/workflows/test-server-self-host.yml
vendored
3
.github/workflows/test-server-self-host.yml
vendored
@ -4,9 +4,6 @@ on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- apps/api/**
|
||||
- apps/playwright-service-ts/**
|
||||
|
||||
env:
|
||||
PORT: 3002
|
||||
|
4
.github/workflows/test-server.yml
vendored
4
.github/workflows/test-server.yml
vendored
@ -4,10 +4,6 @@ on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- apps/api/**
|
||||
# schedule:
|
||||
# - cron: '0 */4 * * *'
|
||||
|
||||
env:
|
||||
BULL_AUTH_KEY: ${{ secrets.BULL_AUTH_KEY }}
|
||||
|
@ -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",
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user