augmenttoolkit / shared /src /file /file.schema.ts
Leon4gr45's picture
Upload folder using huggingface_hub (part 7)
98fbc6d verified
Raw
History Blame Contribute Delete
1.25 kB
import { z } from 'zod';
/**
* File + photo API contract.
*
* Files live under /api/trips/:tripId/files (upload, metadata, star, trash,
* reservation links, authenticated download). Photos live under /api/photos
* (thumbnail/original streaming + info) and are global, not trip-scoped.
*
* Uploads are multipart/form-data so the file itself isn't modelled here; these
* schemas pin the JSON-ish metadata fields that ride along or come as request
* bodies. The bespoke 400/403/404 controller messages pin the rest.
*/
const nullableIdField = z.union([z.string(), z.number()]).nullable().optional();
export const fileUpdateRequestSchema = z.object({
description: z.string().optional(),
place_id: nullableIdField,
reservation_id: nullableIdField,
});
export type FileUpdateRequest = z.infer<typeof fileUpdateRequestSchema>;
export const fileLinkRequestSchema = z.object({
reservation_id: nullableIdField,
assignment_id: nullableIdField,
place_id: nullableIdField,
});
export type FileLinkRequest = z.infer<typeof fileLinkRequestSchema>;
/** Variants the photo streaming endpoints accept. */
export const photoVariantSchema = z.enum(['thumbnail', 'original']);
export type PhotoVariant = z.infer<typeof photoVariantSchema>;