2024-08-13 10:52:35 +01:00
|
|
|
import { z } from "zod";
|
|
|
|
|
import { EntityTable } from 'Dexie';
|
2024-08-13 17:05:46 +01:00
|
|
|
import { zodDataUrlSchema } from "src/app/utils/zod";
|
2024-08-27 23:36:24 +01:00
|
|
|
import { MessageAttachmentFileType, MessageAttachmentSource } from "src/app/core/chat/entity/message";
|
2024-08-13 10:52:35 +01:00
|
|
|
|
|
|
|
|
export const AttachmentTableSchema = z.object({
|
2024-08-13 17:05:46 +01:00
|
|
|
$id: z.number().optional(), // local id
|
2024-09-04 22:48:29 +01:00
|
|
|
$messageId: z.string(),
|
2024-08-13 17:05:46 +01:00
|
|
|
attachmentId: z.string().optional(),
|
2024-08-29 12:13:15 +01:00
|
|
|
file: z.instanceof(Blob),
|
|
|
|
|
base64: zodDataUrlSchema.nullable().optional(),
|
2024-08-17 22:05:57 +01:00
|
|
|
//
|
|
|
|
|
fileType: z.nativeEnum(MessageAttachmentFileType),
|
|
|
|
|
source: z.nativeEnum(MessageAttachmentSource),
|
|
|
|
|
fileName: z.string().optional(),
|
|
|
|
|
applicationId: z.number().optional(),
|
|
|
|
|
docId: z.string().optional(),
|
|
|
|
|
mimeType: z.string().optional(),
|
2024-09-01 14:27:32 +01:00
|
|
|
id: z.string().uuid().optional(),
|
2024-08-20 16:34:47 +01:00
|
|
|
description: z.string().optional()
|
2024-08-13 10:52:35 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
export type AttachmentTable = z.infer<typeof AttachmentTableSchema>
|
|
|
|
|
export type DexieAttachmentsTableSchema = EntityTable<AttachmentTable, '$id'>;
|
2024-08-13 17:05:46 +01:00
|
|
|
export const AttachmentTableColumn = '++$id, id, $messageId, messageId, file'
|