feat: create a guild (#1)
This commit is contained in:
@ -6,7 +6,7 @@ export const types = [Type.Literal('text')]
|
||||
|
||||
export const channelSchema = {
|
||||
id,
|
||||
name: Type.String({ maxLength: 255 }),
|
||||
name: Type.String({ minLength: 1, maxLength: 20 }),
|
||||
createdAt: date.createdAt,
|
||||
updatedAt: date.updatedAt,
|
||||
guildId: id
|
||||
|
@ -1,12 +1,24 @@
|
||||
import { Type } from '@sinclair/typebox'
|
||||
import { Type, Static } from '@sinclair/typebox'
|
||||
|
||||
import { channelSchema } from './Channel'
|
||||
import { memberSchema } from './Member'
|
||||
import { date, id } from './utils'
|
||||
|
||||
export const guildSchema = {
|
||||
id,
|
||||
name: Type.String({ minLength: 3, maxLength: 30 }),
|
||||
icon: Type.String({ format: 'uri-reference' }),
|
||||
description: Type.String({ maxLength: 160 }),
|
||||
name: Type.String({ minLength: 1, maxLength: 30 }),
|
||||
icon: Type.Union([Type.String({ format: 'uri-reference' }), Type.Null()]),
|
||||
description: Type.Union([Type.String({ maxLength: 160 }), Type.Null()]),
|
||||
createdAt: date.createdAt,
|
||||
updatedAt: date.updatedAt
|
||||
}
|
||||
|
||||
export const guildCompleteSchema = {
|
||||
...guildSchema,
|
||||
channels: Type.Array(Type.Object(channelSchema)),
|
||||
members: Type.Array(Type.Object(memberSchema))
|
||||
}
|
||||
|
||||
export const guildCompleteObjectSchema = Type.Object(guildCompleteSchema)
|
||||
|
||||
export type GuildComplete = Static<typeof guildCompleteObjectSchema>
|
||||
|
@ -6,10 +6,13 @@ export const types = [Type.Literal('text'), Type.Literal('file')]
|
||||
|
||||
export const messageSchema = {
|
||||
id,
|
||||
value: Type.String(),
|
||||
value: Type.String({
|
||||
minLength: 1,
|
||||
maxLength: 20_000
|
||||
}),
|
||||
type: Type.Union(types, { default: 'text' }),
|
||||
mimetype: Type.String({
|
||||
maxLength: 255,
|
||||
maxLength: 127,
|
||||
default: 'text/plain',
|
||||
format: 'mimetype'
|
||||
}),
|
||||
|
@ -7,11 +7,11 @@ import { date, id } from './utils'
|
||||
export const userSchema = {
|
||||
id,
|
||||
name: Type.String({ minLength: 1, maxLength: 30 }),
|
||||
email: Type.String({ minLength: 1, maxLength: 255, format: 'email' }),
|
||||
email: Type.String({ minLength: 1, maxLength: 254, format: 'email' }),
|
||||
password: Type.String({ minLength: 1 }),
|
||||
logo: Type.String({ format: 'uri-reference' }),
|
||||
status: Type.String({ maxLength: 255 }),
|
||||
biography: Type.String(),
|
||||
logo: Type.Union([Type.String({ format: 'uri-reference' }), Type.Null()]),
|
||||
status: Type.Union([Type.String({ maxLength: 50 }), Type.Null()]),
|
||||
biography: Type.Union([Type.String({ maxLength: 160 }), Type.Null()]),
|
||||
website: Type.String({ maxLength: 255, format: 'uri-reference' }),
|
||||
isConfirmed: Type.Boolean({ default: false }),
|
||||
temporaryToken: Type.String(),
|
||||
@ -20,32 +20,34 @@ export const userSchema = {
|
||||
updatedAt: date.updatedAt
|
||||
}
|
||||
|
||||
const userSchemaWithSettings = {
|
||||
...userSchema,
|
||||
settings: Type.Object(userSettingsSchema)
|
||||
export const userObjectSchema = Type.Object(userSchema)
|
||||
|
||||
export const userPublicWithoutSettingsSchema = {
|
||||
id,
|
||||
name: userSchema.name,
|
||||
email: Type.Union([userSchema.email, Type.Null()]),
|
||||
logo: userSchema.logo,
|
||||
status: userSchema.status,
|
||||
biography: userSchema.biography,
|
||||
website: Type.Union([userSchema.website, Type.Null()]),
|
||||
isConfirmed: userSchema.isConfirmed,
|
||||
createdAt: date.createdAt,
|
||||
updatedAt: date.updatedAt
|
||||
}
|
||||
|
||||
export const userPublicSchema = {
|
||||
id,
|
||||
name: userSchema.name,
|
||||
email: Type.Optional(userSchema.email),
|
||||
logo: Type.Optional(userSchema.logo),
|
||||
status: Type.Optional(userSchema.status),
|
||||
biography: Type.Optional(userSchema.biography),
|
||||
website: Type.Optional(userSchema.website),
|
||||
isConfirmed: userSchema.isConfirmed,
|
||||
createdAt: date.createdAt,
|
||||
updatedAt: date.updatedAt,
|
||||
settings: Type.Optional(Type.Object(userSettingsSchema))
|
||||
...userPublicWithoutSettingsSchema,
|
||||
settings: Type.Object(userSettingsSchema)
|
||||
}
|
||||
|
||||
export const userPublicObjectSchema = Type.Object(userPublicSchema)
|
||||
|
||||
export const userCurrentSchema = Type.Object({
|
||||
...userSchemaWithSettings,
|
||||
...userPublicSchema,
|
||||
currentStrategy: Type.Union([...strategiesTypebox]),
|
||||
strategies: Type.Array(Type.Union([...strategiesTypebox]))
|
||||
})
|
||||
|
||||
export type User = Static<typeof userObjectSchema>
|
||||
export type UserPublic = Static<typeof userPublicObjectSchema>
|
||||
export type UserCurrent = Static<typeof userCurrentSchema>
|
||||
|
Reference in New Issue
Block a user