работаем бля работаем
This commit is contained in:
13
server/plugins/schemas/attachment.ts
Normal file
13
server/plugins/schemas/attachment.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { Type } from 'typebox'
|
||||
|
||||
export const AttachmentSchema = Type.Object({
|
||||
id: Type.String(),
|
||||
name: Type.String(),
|
||||
mimetype: Type.String(),
|
||||
size: Type.Number({ minimum: 0 }),
|
||||
createdAt: Type.String({ format: 'date-time' }),
|
||||
}, { $id: 'Attachment' })
|
||||
|
||||
export const GetAttachmentParamsSchema = Type.Object({
|
||||
id: Type.String({ format: 'uuid' }),
|
||||
}, { $id: 'GetAttachmentParams' })
|
||||
18
server/plugins/schemas/auth.ts
Normal file
18
server/plugins/schemas/auth.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Type } from 'typebox'
|
||||
|
||||
export const UserSchema = Type.Object({
|
||||
id: Type.String(),
|
||||
username: Type.String(),
|
||||
displayName: Type.String(),
|
||||
createdAt: Type.String({ format: 'date-time' }),
|
||||
}, { $id: 'User' })
|
||||
|
||||
export const CreateUserPayloadSchema = Type.Object({
|
||||
username: Type.String({ minLength: 1 }),
|
||||
password: Type.String({ minLength: 6 }),
|
||||
}, { $id: 'CreateUser' })
|
||||
|
||||
export const LoginPayloadSchema = Type.Object({
|
||||
username: Type.String({ minLength: 1 }),
|
||||
password: Type.String({ minLength: 1 }),
|
||||
}, { $id: 'Login' })
|
||||
13
server/plugins/schemas/channel.ts
Normal file
13
server/plugins/schemas/channel.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { Type } from 'typebox'
|
||||
|
||||
export const ChannelSchema = Type.Object({
|
||||
id: Type.String(),
|
||||
ownerId: Type.Union([Type.String(), Type.Null()]),
|
||||
name: Type.String(),
|
||||
persistent: Type.Boolean(),
|
||||
}, { $id: 'Channel' })
|
||||
|
||||
export const CreateChannelPayloadSchema = Type.Object({
|
||||
name: Type.String(),
|
||||
persistent: Type.Boolean(),
|
||||
}, { $id: 'CreateChannelPayload' })
|
||||
25
server/plugins/schemas/chat.ts
Normal file
25
server/plugins/schemas/chat.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { Type } from 'typebox'
|
||||
|
||||
export const ReplySchema = Type.Object({
|
||||
messageId: Type.String({ format: 'uuid' }),
|
||||
senderId: Type.String({ format: 'uuid' }),
|
||||
text: Type.String(),
|
||||
}, { $id: 'Reply' })
|
||||
|
||||
export const ChatMessageSchema = Type.Object({
|
||||
id: Type.String({ format: 'uuid' }),
|
||||
senderId: Type.String({ format: 'uuid' }),
|
||||
text: Type.String({ minLength: 1 }),
|
||||
createdAt: Type.String({ format: 'date-time' }),
|
||||
updatedAt: Type.String({ format: 'date-time' }),
|
||||
|
||||
attachments: Type.Array(Type.String({ format: 'uuid' })),
|
||||
}, { $id: 'ChatMessage' })
|
||||
|
||||
export const NewChatMessagePayloadSchema = Type.Object({
|
||||
text: Type.String({ minLength: 1 }),
|
||||
attachments: Type.Optional(Type.Array(Type.String({ format: 'uuid' }))),
|
||||
// replyTo: Type.Object({
|
||||
// messageId: Type.String({ format: 'uuid' }),
|
||||
// }),
|
||||
}, { $id: 'NewChatMessagePayload' })
|
||||
7
server/plugins/schemas/common.ts
Normal file
7
server/plugins/schemas/common.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { Type } from 'typebox'
|
||||
|
||||
export const ResponseErrorSchema = Type.Object({
|
||||
statusCode: Type.Number(),
|
||||
error: Type.String(),
|
||||
message: Type.String(),
|
||||
}, { $id: 'ResponseError' })
|
||||
6
server/plugins/schemas/index.ts
Normal file
6
server/plugins/schemas/index.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export * from './attachment.ts'
|
||||
export * from './auth.ts'
|
||||
export * from './channel.ts'
|
||||
export * from './chat.ts'
|
||||
export * from './common.ts'
|
||||
export * from './user.ts'
|
||||
19
server/plugins/schemas/user.ts
Normal file
19
server/plugins/schemas/user.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { Type } from 'typebox'
|
||||
|
||||
export const GetUserQuerySchema = Type.Partial(Type.Object({
|
||||
username: Type.String(),
|
||||
}), { $id: 'GetUserQuery' })
|
||||
|
||||
export const UserPreferencesSchema = Type.Object({
|
||||
toggleInputHotkey: Type.String(),
|
||||
toggleOutputHotkey: Type.String(),
|
||||
}, { $id: 'UserPreferences' })
|
||||
|
||||
export const UpdateUserPreferencesPayloadSchema = Type.Partial(
|
||||
UserPreferencesSchema,
|
||||
{ $id: 'UpdateUserPreferencesPayload' },
|
||||
)
|
||||
|
||||
export const UpdateUserPayloadSchema = Type.Object({
|
||||
displayName: Type.String(),
|
||||
}, { $id: 'UpdateUserPayload' })
|
||||
Reference in New Issue
Block a user