/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; 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"; import { AttachmentReference, AttachmentReference$inboundSchema, AttachmentReference$Outbound, AttachmentReference$outboundSchema, } from "./attachmentreference.js"; import { PassThroughBody, PassThroughBody$inboundSchema, PassThroughBody$Outbound, PassThroughBody$outboundSchema, } from "./passthroughbody.js"; export type Attachment = { /** * A unique identifier for an object. */ id?: string | undefined; /** * The display id of the file */ displayId?: string | null | undefined; /** * The name of the file */ name?: string | null | undefined; /** * The MIME type of the file. */ mimeType?: string | null | undefined; /** * The size of the file in bytes */ size?: number | null | undefined; reference?: AttachmentReference | undefined; /** * Optional description of the file */ description?: string | null | undefined; /** * The folder id where this attachment belong to */ parentFolderId?: string | null | undefined; /** * The user who last updated the object. */ updatedBy?: string | null | undefined; /** * The user who created the object. */ createdBy?: string | null | undefined; /** * The date and time when the object was last updated. */ updatedAt?: Date | null | undefined; /** * The date and time when the object was created. */ createdAt?: Date | null | undefined; /** * The pass_through property allows passing service-specific, custom data or structured modifications in request body when creating or updating resources. */ passThrough?: Array | undefined; }; /** @internal */ export const Attachment$inboundSchema: z.ZodType< Attachment, z.ZodTypeDef, unknown > = z.object({ id: z.string().optional(), display_id: z.nullable(z.string()).optional(), name: z.nullable(z.string()).optional(), mime_type: z.nullable(z.string()).optional(), size: z.nullable(z.number().int()).optional(), reference: AttachmentReference$inboundSchema.optional(), description: z.nullable(z.string()).optional(), parent_folder_id: z.nullable(z.string()).optional(), updated_by: z.nullable(z.string()).optional(), created_by: z.nullable(z.string()).optional(), updated_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), created_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), pass_through: z.array(PassThroughBody$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "display_id": "displayId", "mime_type": "mimeType", "parent_folder_id": "parentFolderId", "updated_by": "updatedBy", "created_by": "createdBy", "updated_at": "updatedAt", "created_at": "createdAt", "pass_through": "passThrough", }); }); /** @internal */ export type Attachment$Outbound = { id?: string | undefined; display_id?: string | null | undefined; name?: string | null | undefined; mime_type?: string | null | undefined; size?: number | null | undefined; reference?: AttachmentReference$Outbound | undefined; description?: string | null | undefined; parent_folder_id?: string | null | undefined; updated_by?: string | null | undefined; created_by?: string | null | undefined; updated_at?: string | null | undefined; created_at?: string | null | undefined; pass_through?: Array | undefined; }; /** @internal */ export const Attachment$outboundSchema: z.ZodType< Attachment$Outbound, z.ZodTypeDef, Attachment > = z.object({ id: z.string().optional(), displayId: z.nullable(z.string()).optional(), name: z.nullable(z.string()).optional(), mimeType: z.nullable(z.string()).optional(), size: z.nullable(z.number().int()).optional(), reference: AttachmentReference$outboundSchema.optional(), description: z.nullable(z.string()).optional(), parentFolderId: z.nullable(z.string()).optional(), updatedBy: z.nullable(z.string()).optional(), createdBy: z.nullable(z.string()).optional(), updatedAt: z.nullable(z.date().transform(v => v.toISOString())).optional(), createdAt: z.nullable(z.date().transform(v => v.toISOString())).optional(), passThrough: z.array(PassThroughBody$outboundSchema).optional(), }).transform((v) => { return remap$(v, { displayId: "display_id", mimeType: "mime_type", parentFolderId: "parent_folder_id", updatedBy: "updated_by", createdBy: "created_by", updatedAt: "updated_at", createdAt: "created_at", passThrough: "pass_through", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Attachment$ { /** @deprecated use `Attachment$inboundSchema` instead. */ export const inboundSchema = Attachment$inboundSchema; /** @deprecated use `Attachment$outboundSchema` instead. */ export const outboundSchema = Attachment$outboundSchema; /** @deprecated use `Attachment$Outbound` instead. */ export type Outbound = Attachment$Outbound; } export function attachmentToJSON(attachment: Attachment): string { return JSON.stringify(Attachment$outboundSchema.parse(attachment)); } export function attachmentFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Attachment$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Attachment' from JSON`, ); }