2024-08-07 19:30:20 +01:00
|
|
|
import { z } from "zod";
|
|
|
|
|
import { EntityTable } from 'Dexie';
|
2024-08-26 14:47:03 +01:00
|
|
|
import { RoomType } from "src/app/core/chat/entity/group";
|
2024-09-10 16:01:51 +01:00
|
|
|
import { MessageTableSchema } from "./message";
|
2024-09-17 16:02:12 +01:00
|
|
|
import { IDBoolean } from "../../../type";
|
2024-08-07 19:30:20 +01:00
|
|
|
|
|
|
|
|
export const RoomTableSchema = z.object({
|
2024-09-17 16:02:12 +01:00
|
|
|
$id: z.string().optional(),
|
|
|
|
|
id: z.string().optional(),
|
2025-09-04 15:40:45 +01:00
|
|
|
roomName: z.string().nullable(),
|
2024-08-07 19:30:20 +01:00
|
|
|
createdBy: z.object({
|
|
|
|
|
wxUserId: z.number(),
|
|
|
|
|
wxFullName: z.string(),
|
|
|
|
|
wxeMail: z.string().email(),
|
|
|
|
|
userPhoto: z.string().nullable().optional()// api check
|
|
|
|
|
}),
|
|
|
|
|
createdAt: z.any(),
|
2024-09-17 16:02:12 +01:00
|
|
|
expirationDate: z.string().nullable().optional(),
|
2024-08-30 15:31:29 +01:00
|
|
|
roomType: z.nativeEnum(RoomType),
|
2024-09-10 16:01:51 +01:00
|
|
|
messages: MessageTableSchema.array().optional(),
|
2024-09-17 16:02:12 +01:00
|
|
|
bold: z.number().optional(),
|
|
|
|
|
local: z.nativeEnum(IDBoolean).optional(),
|
|
|
|
|
receiverId: z.number().optional()
|
2024-08-07 19:30:20 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
export type RoomTable = z.infer<typeof RoomTableSchema>
|
2024-09-17 16:02:12 +01:00
|
|
|
export type DexieRoomsTable = EntityTable<RoomTable, '$id'>;
|
|
|
|
|
export const RoomTableColumn = '$id, id, createdBy, receiverId, roomName, roomType, expirationDate, lastMessage'
|