import { z } from "zod";
import { EntityId } from "./entities";

export const FileCategory = z.enum(["image", "video", "audio", "pdf", "document", "archive", "text"]);
export type FileCategory = z.infer<typeof FileCategory>;

export const Attachment = z.object({
  id: EntityId,
  workspaceId: EntityId,
  channelId: EntityId,
  messageId: EntityId.nullable(),
  uploadedBy: EntityId,
  name: z.string(),
  type: z.string(),
  size: z.number().int().nonnegative(),
  category: FileCategory,
  createdAt: z.string().datetime(),
});
export type Attachment = z.infer<typeof Attachment>;

export const PresignFileUploadRequest = z.object({
  name: z.string().min(1).max(180),
  type: z.string().min(1).max(200),
  size: z.number().int().positive(),
});
export type PresignFileUploadRequest = z.infer<typeof PresignFileUploadRequest>;

export const BrowseFilesQuery = z.object({
  q: z.string().max(200).optional(),
  category: FileCategory.optional(),
  channelId: EntityId.optional(),
  cursor: EntityId.optional(),
  limit: z.coerce.number().int().min(1).max(100).default(30),
});
export type BrowseFilesQuery = z.infer<typeof BrowseFilesQuery>;
