This repository has been archived on 2024-10-29. You can view files and clone it, but cannot push or open issues or pull requests.
website/models/Guild.ts

42 lines
1.3 KiB
TypeScript
Raw Normal View History

2021-10-26 16:38:55 +02:00
import { Type, Static } from '@sinclair/typebox'
2021-10-26 16:38:55 +02:00
import { channelSchema } from './Channel'
import { memberSchema } from './Member'
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()]),
description: Type.Union([Type.String({ maxLength: 160 }), Type.Null()]),
createdAt: date.createdAt,
updatedAt: date.updatedAt
}
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))
}
export const guildCompleteObjectSchema = Type.Object(guildCompleteSchema)
export type GuildComplete = Static<typeof guildCompleteObjectSchema>
2021-10-26 16:38:55 +02:00
export const guildPublicObjectSchema = Type.Object({
...guildSchema,
membersCount: Type.Integer({ min: 1 })
})
export type GuildPublic = Static<typeof guildPublicObjectSchema>