/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type Entity = { id: string; createdAt: Date; updatedAt: Date; /** * The ID of the instruction which generated the entity. */ instructionId: string; /** * The ID of the document which the entity was produced from. */ documentId: string; chunkId?: string | null | undefined; data: { [k: string]: any }; }; /** @internal */ export const Entity$inboundSchema: z.ZodType = z .object({ id: z.string(), created_at: z.string().datetime({ offset: true }).transform(v => new Date(v) ), updated_at: z.string().datetime({ offset: true }).transform(v => new Date(v) ), instruction_id: z.string(), document_id: z.string(), chunk_id: z.nullable(z.string()).optional(), data: z.record(z.any()), }).transform((v) => { return remap$(v, { "created_at": "createdAt", "updated_at": "updatedAt", "instruction_id": "instructionId", "document_id": "documentId", "chunk_id": "chunkId", }); }); /** @internal */ export type Entity$Outbound = { id: string; created_at: string; updated_at: string; instruction_id: string; document_id: string; chunk_id?: string | null | undefined; data: { [k: string]: any }; }; /** @internal */ export const Entity$outboundSchema: z.ZodType< Entity$Outbound, z.ZodTypeDef, Entity > = z.object({ id: z.string(), createdAt: z.date().transform(v => v.toISOString()), updatedAt: z.date().transform(v => v.toISOString()), instructionId: z.string(), documentId: z.string(), chunkId: z.nullable(z.string()).optional(), data: z.record(z.any()), }).transform((v) => { return remap$(v, { createdAt: "created_at", updatedAt: "updated_at", instructionId: "instruction_id", documentId: "document_id", chunkId: "chunk_id", }); }); export function entityToJSON(entity: Entity): string { return JSON.stringify(Entity$outboundSchema.parse(entity)); } export function entityFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Entity$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Entity' from JSON`, ); }