2021-10-26 16:38:55 +02:00
|
|
|
import { Type, Static } from '@sinclair/typebox'
|
2021-10-24 06:09:43 +02:00
|
|
|
|
2021-10-26 16:38:55 +02:00
|
|
|
import { channelSchema } from './Channel'
|
|
|
|
import { memberSchema } from './Member'
|
2021-10-24 06:09:43 +02:00
|
|
|
import { date, id } from './utils'
|
|
|
|
|
|
|
|
export const guildSchema = {
|
|
|
|
id,
|
2021-10-26 16:38:55 +02:00
|
|
|
name: Type.String({ minLength: 1, maxLength: 30 }),
|
|
|
|
icon: Type.Union([Type.String({ format: 'uri-reference' }), Type.Null()]),
|
2022-08-28 18:26:56 +02:00
|
|
|
description: Type.String({ maxLength: 160 }),
|
2021-10-24 06:09:43 +02:00
|
|
|
createdAt: date.createdAt,
|
|
|
|
updatedAt: date.updatedAt
|
|
|
|
}
|
2022-01-01 20:42:25 +01:00
|
|
|
export const guildObjectSchema = Type.Object(guildSchema)
|
|
|
|
export type Guild = Static<typeof guildObjectSchema>
|
|
|
|
|
|
|
|
export const guildWithDefaultChannelIdSchema = {
|
|
|
|
...guildSchema,
|
|
|
|
defaultChannelId: id
|
|
|
|
}
|
|
|
|
export const guildWithDefaultChannelObjectSchema = Type.Object(
|
|
|
|
guildWithDefaultChannelIdSchema
|
|
|
|
)
|
|
|
|
export type GuildWithDefaultChannelId = Static<
|
|
|
|
typeof guildWithDefaultChannelObjectSchema
|
|
|
|
>
|
2021-10-26 16:38:55 +02:00
|
|
|
|
|
|
|
export const guildCompleteSchema = {
|
|
|
|
...guildSchema,
|
|
|
|
channels: Type.Array(Type.Object(channelSchema)),
|
|
|
|
members: Type.Array(Type.Object(memberSchema))
|
|
|
|
}
|
2022-01-01 20:42:25 +01:00
|
|
|
export const guildCompleteObjectSchema = Type.Object(guildCompleteSchema)
|
|
|
|
export type GuildComplete = Static<typeof guildCompleteObjectSchema>
|
2021-10-26 16:38:55 +02:00
|
|
|
|
2021-11-13 21:50:34 +01:00
|
|
|
export const guildPublicObjectSchema = Type.Object({
|
|
|
|
...guildSchema,
|
|
|
|
membersCount: Type.Integer({ min: 1 })
|
|
|
|
})
|
|
|
|
export type GuildPublic = Static<typeof guildPublicObjectSchema>
|