/* * 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 ConversationObject = { /** * The unique ID of the conversation */ id: string; /** * The object type, always 'conversation' */ object: "conversation"; /** * Unix timestamp of when the conversation was created */ createdAt: number; /** * Set of 16 key-value pairs. Keys max 64 chars, values max 512 chars. */ metadata?: { [k: string]: string } | null | undefined; /** * Identity of the conversation owner. Either a SHA256 hash or raw userId:externalUserId depending on IDENTITY_MODE. */ identity?: string | undefined; /** * Unix timestamp of when the conversation was soft-deleted, or null if not deleted. */ deletedAt: number | null; }; /** @internal */ export const ConversationObject$inboundSchema: z.ZodType< ConversationObject, z.ZodTypeDef, unknown > = z.object({ id: z.string(), object: z.literal("conversation"), created_at: z.number(), metadata: z.nullable(z.record(z.string())).optional(), identity: z.string().optional(), deleted_at: z.nullable(z.number()), }).transform((v) => { return remap$(v, { "created_at": "createdAt", "deleted_at": "deletedAt", }); }); /** @internal */ export type ConversationObject$Outbound = { id: string; object: "conversation"; created_at: number; metadata?: { [k: string]: string } | null | undefined; identity?: string | undefined; deleted_at: number | null; }; /** @internal */ export const ConversationObject$outboundSchema: z.ZodType< ConversationObject$Outbound, z.ZodTypeDef, ConversationObject > = z.object({ id: z.string(), object: z.literal("conversation"), createdAt: z.number(), metadata: z.nullable(z.record(z.string())).optional(), identity: z.string().optional(), deletedAt: z.nullable(z.number()), }).transform((v) => { return remap$(v, { createdAt: "created_at", deletedAt: "deleted_at", }); }); export function conversationObjectToJSON( conversationObject: ConversationObject, ): string { return JSON.stringify( ConversationObject$outboundSchema.parse(conversationObject), ); } export function conversationObjectFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ConversationObject$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ConversationObject' from JSON`, ); }