import { fileDownloadLogs } from "@/db/schema"; import { createInsertSchema, createSelectSchema } from "drizzle-zod"; import { z } from 'zod'; // Zod 스키마 export const fileDownloadLogInsertSchema = createInsertSchema(fileDownloadLogs); export const fileDownloadLogSelectSchema = createSelectSchema(fileDownloadLogs); export type FileDownloadLog = typeof fileDownloadLogs.$inferSelect; export type NewFileDownloadLog = typeof fileDownloadLogs.$inferInsert; // validation.ts에 추가할 타입 interface FileInfo { fileName?: string; filePath?: string; fileSize?: number; } // 수정된 입력 스키마 export const createFileDownloadLogSchema = z.object({ fileId: z.number(), success: z.boolean(), errorMessage: z.string().optional(), requestId: z.string().optional(), downloadDurationMs: z.number().optional(), // 파일 정보를 직접 받을 수 있도록 추가 fileInfo: z.object({ fileName: z.string().optional(), filePath: z.string().optional(), fileSize: z.number().optional(), }).optional(), // 또는 다른 테이블에서 조회할 수 있도록 fileSource: z.enum(['rfqAttachments', 'documents', 'uploads']).optional(), }); export type CreateFileDownloadLogInput = z.infer;