Update types.ts

This commit is contained in:
Nicolas 2025-01-07 16:55:55 -03:00
parent 9fdcfb9314
commit dd14744850

View File

@ -186,6 +186,10 @@ export const scrapeOptions = z
export type ScrapeOptions = z.infer<typeof scrapeOptions>;
import Ajv from "ajv";
const ajv = new Ajv();
export const extractV1Options = z
.object({
urls: url
@ -193,7 +197,20 @@ export const extractV1Options = z
.max(10, "Maximum of 10 URLs allowed per request while in beta."),
prompt: z.string().optional(),
systemPrompt: z.string().optional(),
schema: z.any().optional(),
schema: z
.any()
.optional()
.refine((val) => {
if (!val) return true; // Allow undefined schema
try {
const validate = ajv.compile(val);
return typeof validate === "function";
} catch (e) {
return false;
}
}, {
message: "Invalid JSON schema.",
}),
limit: z.number().int().positive().finite().safe().optional(),
ignoreSitemap: z.boolean().default(false),
includeSubdomains: z.boolean().default(true),