/* * 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"; /** * Metadata about the extraction request and execution */ export type ExtractionResponseMetadata = { /** * The model that was used to perform the extraction */ model: string; /** * The name of the file that was processed */ filename: string; /** * The size of the processed file in bytes */ fileSize: number; /** * ISO 8601 timestamp indicating when the extraction was performed */ extractedAt: string; /** * The ID of the extraction schema that was used (only present when using a saved schema) */ schemaId?: string | undefined; /** * The name of the extraction schema that was used (only present when using a saved schema) */ schemaName?: string | undefined; }; /** * Response from the extraction endpoint containing the extracted structured data and metadata about the extraction process. */ export type ExtractionResponse = { /** * Indicates whether the extraction request was successful */ success: boolean; /** * The extracted structured data conforming to the provided JSON Schema. This is the result of analyzing the file and extracting information according to the schema definition. */ data?: any | undefined; /** * Metadata about the extraction request and execution */ metadata: ExtractionResponseMetadata; }; /** @internal */ export const ExtractionResponseMetadata$inboundSchema: z.ZodType< ExtractionResponseMetadata, z.ZodTypeDef, unknown > = z.object({ model: z.string(), filename: z.string(), fileSize: z.number(), extractedAt: z.string(), schemaId: z.string().optional(), schemaName: z.string().optional(), }); /** @internal */ export type ExtractionResponseMetadata$Outbound = { model: string; filename: string; fileSize: number; extractedAt: string; schemaId?: string | undefined; schemaName?: string | undefined; }; /** @internal */ export const ExtractionResponseMetadata$outboundSchema: z.ZodType< ExtractionResponseMetadata$Outbound, z.ZodTypeDef, ExtractionResponseMetadata > = z.object({ model: z.string(), filename: z.string(), fileSize: z.number(), extractedAt: z.string(), schemaId: z.string().optional(), schemaName: z.string().optional(), }); export function extractionResponseMetadataToJSON( extractionResponseMetadata: ExtractionResponseMetadata, ): string { return JSON.stringify( ExtractionResponseMetadata$outboundSchema.parse(extractionResponseMetadata), ); } export function extractionResponseMetadataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ExtractionResponseMetadata$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ExtractionResponseMetadata' from JSON`, ); } /** @internal */ export const ExtractionResponse$inboundSchema: z.ZodType< ExtractionResponse, z.ZodTypeDef, unknown > = z.object({ success: z.boolean(), data: z.any().optional(), metadata: z.lazy(() => ExtractionResponseMetadata$inboundSchema), }); /** @internal */ export type ExtractionResponse$Outbound = { success: boolean; data?: any | undefined; metadata: ExtractionResponseMetadata$Outbound; }; /** @internal */ export const ExtractionResponse$outboundSchema: z.ZodType< ExtractionResponse$Outbound, z.ZodTypeDef, ExtractionResponse > = z.object({ success: z.boolean(), data: z.any().optional(), metadata: z.lazy(() => ExtractionResponseMetadata$outboundSchema), }); export function extractionResponseToJSON( extractionResponse: ExtractionResponse, ): string { return JSON.stringify( ExtractionResponse$outboundSchema.parse(extractionResponse), ); } export function extractionResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ExtractionResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ExtractionResponse' from JSON`, ); }