/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Schema definition for creating a reusable extraction template. Extraction schemas define the structure and validation rules for data extraction from files. */ export type ExtractionSchema = { /** * Name of the extraction schema. Must be between 1 and 100 characters. Used to identify and reference the schema. */ name: string; /** * Optional description of the schema. Maximum 500 characters. Helps document the purpose and usage of the schema. */ description?: string | undefined; /** * JSON Schema object defining the structure of data to extract. Specifies the fields, types, and validation rules for the extracted data. */ schema: { [k: string]: any }; /** * Optional metadata for the schema. Can store additional information like version, author, or custom properties. */ metadata?: { [k: string]: any } | undefined; }; /** @internal */ export const ExtractionSchema$inboundSchema: z.ZodType< ExtractionSchema, z.ZodTypeDef, unknown > = z.object({ name: z.string(), description: z.string().optional(), schema: z.record(z.any()), metadata: z.record(z.any()).optional(), }); /** @internal */ export type ExtractionSchema$Outbound = { name: string; description?: string | undefined; schema: { [k: string]: any }; metadata?: { [k: string]: any } | undefined; }; /** @internal */ export const ExtractionSchema$outboundSchema: z.ZodType< ExtractionSchema$Outbound, z.ZodTypeDef, ExtractionSchema > = z.object({ name: z.string(), description: z.string().optional(), schema: z.record(z.any()), metadata: z.record(z.any()).optional(), }); export function extractionSchemaToJSON( extractionSchema: ExtractionSchema, ): string { return JSON.stringify( ExtractionSchema$outboundSchema.parse(extractionSchema), ); } export function extractionSchemaFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ExtractionSchema$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ExtractionSchema' from JSON`, ); }