mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
realtime
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import { z } from "zod";
|
||||
import { EntityTable } from 'Dexie';
|
||||
|
||||
export const AttachmentTableSchema = z.object({
|
||||
id: z.string(),
|
||||
$id: z.string(),
|
||||
messageId: z.string(),
|
||||
file: z.string(),
|
||||
})
|
||||
|
||||
export type AttachmentTable = z.infer<typeof AttachmentTableSchema>
|
||||
export type DexieAttachmentsTableSchema = EntityTable<AttachmentTable, '$id'>;
|
||||
export const AttachmentTableColumn = '++$id, id, messageId, file'
|
||||
@@ -1,5 +1,6 @@
|
||||
import { z } from "zod";
|
||||
import { nativeEnum, z } from "zod";
|
||||
import { EntityTable } from 'Dexie';
|
||||
import { MessageAttachmentFileType, MessageAttachmentSource } from "src/app/module/chat/data/dto/message/messageOutputDTO";
|
||||
|
||||
export const MessageTable = z.object({
|
||||
$id: z.number().optional(),
|
||||
@@ -25,7 +26,14 @@ export const MessageTable = z.object({
|
||||
sender: z.object({}),
|
||||
}).array().optional(),
|
||||
info: z.array(z.object({})).optional(),
|
||||
attachments: z.array(z.object({})).optional()
|
||||
attachments: z.array(z.object({
|
||||
fileType: z.nativeEnum(MessageAttachmentFileType),
|
||||
source: z.nativeEnum(MessageAttachmentSource),
|
||||
file: z.string().optional(),
|
||||
fileName: z.string().optional(),
|
||||
applicationId: z.string().optional(),
|
||||
docId: z.string().optional()
|
||||
})).optional()
|
||||
})
|
||||
|
||||
export type MessageTable = z.infer<typeof MessageTable>
|
||||
|
||||
@@ -5,6 +5,7 @@ import { DexieMembersTableSchema, MemberTableColumn } from './schema/members';
|
||||
import { DexieRoomsTableSchema, RoomTableColumn } from './schema/room';
|
||||
import { DexieTypingsTableSchema, TypingTableColumn } from './schema/typing';
|
||||
import { MessageEntity } from '../../../domain/entity/message';
|
||||
import { AttachmentTable, AttachmentTableColumn, DexieAttachmentsTableSchema } from './schema/attachment';
|
||||
// import DexieMemory from 'dexie-in-memory';
|
||||
|
||||
// Database declaration (move this to its own module also)
|
||||
@@ -12,14 +13,16 @@ export const chatDatabase = new Dexie('chat-database-infra') as Dexie & {
|
||||
message: DexieMessageTable,
|
||||
members: DexieMembersTableSchema,
|
||||
room: DexieRoomsTableSchema,
|
||||
typing: DexieTypingsTableSchema
|
||||
typing: DexieTypingsTableSchema,
|
||||
attachment: DexieAttachmentsTableSchema,
|
||||
};
|
||||
|
||||
chatDatabase.version(1).stores({
|
||||
message: messageTableColumn,
|
||||
members: MemberTableColumn,
|
||||
room: RoomTableColumn,
|
||||
typing: TypingTableColumn
|
||||
typing: TypingTableColumn,
|
||||
attachment: AttachmentTableColumn
|
||||
});
|
||||
|
||||
chatDatabase.message.mapToClass(MessageEntity)
|
||||
|
||||
Reference in New Issue
Block a user