mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
send and receive message
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const MessageInputDTOSchema = z.object({
|
||||
roomId: z.string().uuid(),
|
||||
senderId: z.number(),
|
||||
message: z.string(),
|
||||
messageType: z.number(),
|
||||
canEdit: z.boolean(),
|
||||
oneShot: z.boolean(),
|
||||
requireUnlock: z.boolean(),
|
||||
});
|
||||
|
||||
|
||||
export type MessageInputDTO = z.infer<typeof MessageInputDTOSchema>
|
||||
@@ -0,0 +1,7 @@
|
||||
import { z } from "zod"
|
||||
|
||||
const MessageListInputDTOSchema = z.object({
|
||||
roomId: z.string(),
|
||||
});
|
||||
|
||||
export type MessageListInputDTO = z.infer<typeof MessageListInputDTOSchema>
|
||||
@@ -0,0 +1,29 @@
|
||||
import { z } from "zod"
|
||||
|
||||
const SenderSchema = z.object({
|
||||
wxUserId: z.number(),
|
||||
wxFullName: z.string(),
|
||||
wxeMail: z.string(),
|
||||
userPhoto: z.string()
|
||||
});
|
||||
|
||||
const DataSchema = z.object({
|
||||
id: z.string(),
|
||||
sender: SenderSchema,
|
||||
message: z.string(),
|
||||
messageType: z.number(),
|
||||
sentAt: z.string().datetime(),
|
||||
deliverAt: z.string().datetime().nullable(),
|
||||
canEdit: z.boolean(),
|
||||
oneShot: z.boolean(),
|
||||
requireUnlock: z.boolean()
|
||||
});
|
||||
|
||||
const MessageListOutputSchema = z.object({
|
||||
success: z.boolean(),
|
||||
message: z.string().nullable(),
|
||||
data: z.array(DataSchema)
|
||||
});
|
||||
|
||||
|
||||
export type MessageListOutput = z.infer<typeof MessageListOutputSchema>
|
||||
@@ -0,0 +1,29 @@
|
||||
import { z } from "zod"
|
||||
|
||||
const DataSchema = z.object({
|
||||
id: z.string(),
|
||||
chatRoomId: z.string(),
|
||||
wxUserId: z.number(),
|
||||
sender: z.object({
|
||||
wxUserId: z.number(),
|
||||
wxFullName: z.string(),
|
||||
wxeMail: z.string(),
|
||||
userPhoto: z.string().optional()
|
||||
}).nullable(),
|
||||
message: z.string(),
|
||||
messageType: z.number(),
|
||||
sentAt: z.string(),
|
||||
deliverAt: z.string().datetime().nullable(),
|
||||
canEdit: z.boolean(),
|
||||
oneShot: z.boolean(),
|
||||
requireUnlock: z.boolean()
|
||||
});
|
||||
|
||||
|
||||
export const MessageOutPutDTOSchema = z.object({
|
||||
success: z.boolean(),
|
||||
message: z.string(),
|
||||
data: DataSchema
|
||||
});
|
||||
|
||||
export type MessageOutPutDTO = z.infer<typeof MessageOutPutDTOSchema>
|
||||
@@ -0,0 +1,8 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const AddMemberToRoomInputDTOSchema = z.object({
|
||||
id: z.string(),
|
||||
members: z.array(z.number()),
|
||||
});
|
||||
|
||||
export type AddMemberToRoomInputDTO = z.infer<typeof AddMemberToRoomInputDTOSchema>
|
||||
@@ -0,0 +1,9 @@
|
||||
import { z } from "zod";
|
||||
|
||||
const OutPutDTOSchema = z.object({
|
||||
success: z.string(),
|
||||
message: z.string(),
|
||||
data: z.any()
|
||||
});
|
||||
|
||||
export type OutPutDTO = z.infer<typeof OutPutDTOSchema>
|
||||
@@ -0,0 +1,6 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const RoomByIdInputDTOSchema = z.string()
|
||||
|
||||
|
||||
export type RoomByIdInputDTO = z.infer<typeof RoomByIdInputDTOSchema>
|
||||
@@ -0,0 +1,32 @@
|
||||
import { z } from "zod";
|
||||
|
||||
const UserSchema = z.object({
|
||||
wxUserId: z.number(),
|
||||
wxFullName: z.string(),
|
||||
wxeMail: z.string(),
|
||||
userPhoto: z.string().nullable(),
|
||||
});
|
||||
|
||||
const MemberSchema = z.object({
|
||||
id: z.string(),
|
||||
user: UserSchema,
|
||||
joinAt: z.string(),
|
||||
});
|
||||
|
||||
export const RoomByIdOutputDTOSchema = z.object({
|
||||
success: z.boolean(),
|
||||
message: z.string(),
|
||||
data: z.object({
|
||||
id: z.string(),
|
||||
roomName: z.string(),
|
||||
createdBy: UserSchema,
|
||||
createdAt: z.string(),
|
||||
expirationDate: z.string().nullable(),
|
||||
roomType: z.number(),
|
||||
members: z.array(MemberSchema),
|
||||
}),
|
||||
})
|
||||
|
||||
|
||||
export type RoomByIdMemberItemOutputDTO = z.infer<typeof MemberSchema>
|
||||
export type RoomByIdOutputDTO = z.infer<typeof RoomByIdOutputDTOSchema>
|
||||
@@ -0,0 +1,12 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const RoomInputDTOSchema = z.object({
|
||||
roomName: z.string(),
|
||||
createdBy: z.number(),
|
||||
roomType: z.number(),
|
||||
expirationDate: z.string().datetime().nullable(),
|
||||
members: z.array(z.number())
|
||||
});
|
||||
|
||||
|
||||
export type RoomInputDTO = z.infer<typeof RoomInputDTOSchema>
|
||||
@@ -0,0 +1,29 @@
|
||||
import { z } from "zod";
|
||||
|
||||
const CreatedBySchema = z.object({
|
||||
wxUserId: z.number(),
|
||||
wxFullName: z.string(),
|
||||
wxeMail: z.string().email(),
|
||||
userPhoto: z.string().nullable()// api check
|
||||
});
|
||||
|
||||
const RoomListItemOutPutDTOSchema = z.object({
|
||||
id: z.string(),
|
||||
roomName: z.string(),
|
||||
createdBy: CreatedBySchema,
|
||||
createdAt: z.string(),
|
||||
expirationDate: z.string().nullable(), // api check
|
||||
roomType: z.number()
|
||||
})
|
||||
|
||||
|
||||
// Define the schema for the entire response
|
||||
export const RoomListOutPutDTOSchema = z.object({
|
||||
success: z.boolean(),
|
||||
message: z.string(),
|
||||
data: z.array(RoomListItemOutPutDTOSchema),
|
||||
});
|
||||
|
||||
export type RoomListItemOutPutDTO = z.infer<typeof RoomListItemOutPutDTOSchema>
|
||||
|
||||
export type RoomListOutPutDTO = z.infer<typeof RoomListOutPutDTOSchema>
|
||||
@@ -0,0 +1,16 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const RoomOutPutDTOSchema = z.object({
|
||||
success: z.boolean(),
|
||||
message: z.string(),
|
||||
data: z.object({
|
||||
id: z.string(),
|
||||
roomName: z.string(),
|
||||
createdBy: z.any().nullable(),
|
||||
createdAt: z.string(),
|
||||
expirationDate: z.string().nullable(),
|
||||
roomType: z.any()
|
||||
})
|
||||
});
|
||||
|
||||
export type RoomOutPutDTO = z.infer<typeof RoomOutPutDTOSchema>
|
||||
@@ -0,0 +1,9 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const RoomUpdateInputDTOSchema = z.object({
|
||||
roomName: z.string(),
|
||||
roomId: z.string(),
|
||||
roomType: z.number(),
|
||||
});
|
||||
|
||||
export type RoomUpdateInputDTO = z.infer<typeof RoomUpdateInputDTOSchema>
|
||||
@@ -0,0 +1,30 @@
|
||||
import { z } from "zod";
|
||||
|
||||
const UserSchema = z.object({
|
||||
wxUserId: z.number(),
|
||||
wxFullName: z.string(),
|
||||
wxeMail: z.string(),
|
||||
userPhoto: z.string().nullable(),
|
||||
});
|
||||
|
||||
const MemberSchema = z.object({
|
||||
id: z.string(),
|
||||
user: UserSchema,
|
||||
joinAt: z.string(),
|
||||
});
|
||||
|
||||
export const RoomUpdateOutputDTOSchema = z.object({
|
||||
success: z.boolean(),
|
||||
message: z.string(),
|
||||
data: z.object({
|
||||
id: z.string(),
|
||||
roomName: z.string(),
|
||||
createdBy: UserSchema,
|
||||
createdAt: z.string(),
|
||||
expirationDate: z.string().nullable(),
|
||||
roomType: z.number(),
|
||||
members: z.array(MemberSchema),
|
||||
}),
|
||||
});
|
||||
|
||||
export type RoomUpdateOutputDTO = z.infer<typeof RoomUpdateOutputDTOSchema>
|
||||
@@ -0,0 +1,9 @@
|
||||
import { z } from "zod";
|
||||
|
||||
// Define the schema for the entire response
|
||||
export const UserRemoveListInputDTOSchema = z.object({
|
||||
id: z.string(),
|
||||
members: z.array(z.number())
|
||||
});
|
||||
|
||||
export type UserRemoveListInputDTO = z.infer<typeof UserRemoveListInputDTOSchema>
|
||||
Reference in New Issue
Block a user