summaryrefslogtreecommitdiff
path: root/lib/file-download-log/validation.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/file-download-log/validation.ts')
-rw-r--r--lib/file-download-log/validation.ts37
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/file-download-log/validation.ts b/lib/file-download-log/validation.ts
new file mode 100644
index 00000000..bf888e9c
--- /dev/null
+++ b/lib/file-download-log/validation.ts
@@ -0,0 +1,37 @@
+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<typeof createFileDownloadLogSchema>;