/* * 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"; export type UploadSession = { /** * A unique identifier for an object. */ id?: string | undefined; /** * Indicates if the upload session was completed successfully. */ success?: boolean | undefined; /** * Size in bytes of each part of the file that you will upload. Uploaded parts need to be this size for the upload to be successful. */ partSize?: number | undefined; /** * Indicates if parts of the file can uploaded in parallel. */ parallelUploadSupported?: boolean | undefined; /** * The range of bytes that was successfully uploaded. */ uploadedByteRange?: string | undefined; expiresAt?: Date | null | undefined; }; /** @internal */ export const UploadSession$inboundSchema: z.ZodType< UploadSession, z.ZodTypeDef, unknown > = z.object({ id: z.string().optional(), success: z.boolean().optional(), part_size: z.number().optional(), parallel_upload_supported: z.boolean().optional(), uploaded_byte_range: z.string().optional(), expires_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), }).transform((v) => { return remap$(v, { "part_size": "partSize", "parallel_upload_supported": "parallelUploadSupported", "uploaded_byte_range": "uploadedByteRange", "expires_at": "expiresAt", }); }); /** @internal */ export type UploadSession$Outbound = { id?: string | undefined; success?: boolean | undefined; part_size?: number | undefined; parallel_upload_supported?: boolean | undefined; uploaded_byte_range?: string | undefined; expires_at?: string | null | undefined; }; /** @internal */ export const UploadSession$outboundSchema: z.ZodType< UploadSession$Outbound, z.ZodTypeDef, UploadSession > = z.object({ id: z.string().optional(), success: z.boolean().optional(), partSize: z.number().optional(), parallelUploadSupported: z.boolean().optional(), uploadedByteRange: z.string().optional(), expiresAt: z.nullable(z.date().transform(v => v.toISOString())).optional(), }).transform((v) => { return remap$(v, { partSize: "part_size", parallelUploadSupported: "parallel_upload_supported", uploadedByteRange: "uploaded_byte_range", expiresAt: "expires_at", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace UploadSession$ { /** @deprecated use `UploadSession$inboundSchema` instead. */ export const inboundSchema = UploadSession$inboundSchema; /** @deprecated use `UploadSession$outboundSchema` instead. */ export const outboundSchema = UploadSession$outboundSchema; /** @deprecated use `UploadSession$Outbound` instead. */ export type Outbound = UploadSession$Outbound; } export function uploadSessionToJSON(uploadSession: UploadSession): string { return JSON.stringify(UploadSession$outboundSchema.parse(uploadSession)); } export function uploadSessionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => UploadSession$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UploadSession' from JSON`, ); }