chore: better Prettier config for easier reviews

This commit is contained in:
2023-10-23 23:33:39 +02:00
parent a8781724d4
commit 71ea41695f
209 changed files with 4093 additions and 4114 deletions

View File

@ -1,24 +1,24 @@
import type { Static } from '@sinclair/typebox'
import { Type } from '@sinclair/typebox'
import type { Static } from "@sinclair/typebox"
import { Type } from "@sinclair/typebox"
import { date, id } from './utils'
import { date, id } from "./utils"
export const channelSchema = {
id,
name: Type.String({ minLength: 1, maxLength: 20 }),
createdAt: date.createdAt,
updatedAt: date.updatedAt,
guildId: id
guildId: id,
}
const channelObjectSchema = Type.Object(channelSchema)
export type Channel = Static<typeof channelObjectSchema>
export const channelWithDefaultChannelIdSchema = {
...channelSchema,
defaultChannelId: channelSchema.id
defaultChannelId: channelSchema.id,
}
export const channelWithDefaultChannelObjectSchema = Type.Object(
channelWithDefaultChannelIdSchema
channelWithDefaultChannelIdSchema,
)
export type ChannelWithDefaultChannelId = Static<
typeof channelWithDefaultChannelObjectSchema

View File

@ -1,27 +1,27 @@
import type { Static } from '@sinclair/typebox'
import { Type } from '@sinclair/typebox'
import type { Static } from "@sinclair/typebox"
import { Type } from "@sinclair/typebox"
import { channelSchema } from './Channel'
import { memberSchema } from './Member'
import { date, id } from './utils'
import { channelSchema } from "./Channel"
import { memberSchema } from "./Member"
import { date, id } from "./utils"
export const guildSchema = {
id,
name: Type.String({ minLength: 1, maxLength: 30 }),
icon: Type.Union([Type.String({ format: 'uri-reference' }), Type.Null()]),
icon: Type.Union([Type.String({ format: "uri-reference" }), Type.Null()]),
description: Type.String({ maxLength: 160 }),
createdAt: date.createdAt,
updatedAt: date.updatedAt
updatedAt: date.updatedAt,
}
export const guildObjectSchema = Type.Object(guildSchema)
export type Guild = Static<typeof guildObjectSchema>
export const guildWithDefaultChannelIdSchema = {
...guildSchema,
defaultChannelId: id
defaultChannelId: id,
}
export const guildWithDefaultChannelObjectSchema = Type.Object(
guildWithDefaultChannelIdSchema
guildWithDefaultChannelIdSchema,
)
export type GuildWithDefaultChannelId = Static<
typeof guildWithDefaultChannelObjectSchema
@ -30,13 +30,13 @@ export type GuildWithDefaultChannelId = Static<
export const guildCompleteSchema = {
...guildSchema,
channels: Type.Array(Type.Object(channelSchema)),
members: Type.Array(Type.Object(memberSchema))
members: Type.Array(Type.Object(memberSchema)),
}
export const guildCompleteObjectSchema = Type.Object(guildCompleteSchema)
export type GuildComplete = Static<typeof guildCompleteObjectSchema>
export const guildPublicObjectSchema = Type.Object({
...guildSchema,
membersCount: Type.Integer({ min: 1 })
membersCount: Type.Integer({ min: 1 }),
})
export type GuildPublic = Static<typeof guildPublicObjectSchema>

View File

@ -1,8 +1,8 @@
import type { Static } from '@sinclair/typebox'
import { Type } from '@sinclair/typebox'
import type { Static } from "@sinclair/typebox"
import { Type } from "@sinclair/typebox"
import { date, id } from './utils'
import type { UserPublicWithoutSettings } from './User'
import { date, id } from "./utils"
import type { UserPublicWithoutSettings } from "./User"
export const memberSchema = {
id,
@ -10,7 +10,7 @@ export const memberSchema = {
createdAt: date.createdAt,
updatedAt: date.updatedAt,
userId: id,
guildId: id
guildId: id,
}
const memberObjectSchema = Type.Object(memberSchema)
export type Member = Static<typeof memberObjectSchema>

View File

@ -1,27 +1,27 @@
import type { Static } from '@sinclair/typebox'
import { Type } from '@sinclair/typebox'
import type { Static } from "@sinclair/typebox"
import { Type } from "@sinclair/typebox"
import { date, id } from './utils'
import type { MemberWithPublicUser } from './Member'
import { date, id } from "./utils"
import type { MemberWithPublicUser } from "./Member"
export const types = [Type.Literal('text'), Type.Literal('file')]
export const types = [Type.Literal("text"), Type.Literal("file")]
export const messageSchema = {
id,
value: Type.String({
minLength: 1,
maxLength: 20_000
maxLength: 20_000,
}),
type: Type.Union(types, { default: 'text' }),
type: Type.Union(types, { default: "text" }),
mimetype: Type.String({
maxLength: 127,
default: 'text/plain',
format: 'mimetype'
default: "text/plain",
format: "mimetype",
}),
createdAt: date.createdAt,
updatedAt: date.updatedAt,
memberId: id,
channelId: id
channelId: id,
}
const messageObjectSchema = Type.Object(messageSchema)
export type Message = Static<typeof messageObjectSchema>

View File

@ -1,9 +1,9 @@
import { Type } from '@sinclair/typebox'
import { Type } from "@sinclair/typebox"
import { date, id } from './utils'
import { date, id } from "./utils"
export const providers = ['Google', 'GitHub', 'Discord'] as const
export const strategies = [...providers, 'Local'] as const
export const providers = ["Google", "GitHub", "Discord"] as const
export const strategies = [...providers, "Local"] as const
export const strategiesTypebox = strategies.map((strategy) => {
return Type.Literal(strategy)
@ -21,5 +21,5 @@ export const oauthSchema = {
provider: Type.Union([...providersTypebox]),
createdAt: date.createdAt,
updatedAt: date.updatedAt,
userId: id
userId: id,
}

View File

@ -1,11 +1,11 @@
import { Type } from '@sinclair/typebox'
import { Type } from "@sinclair/typebox"
import { date, id } from './utils'
import { date, id } from "./utils"
export const refreshTokensSchema = {
id,
token: Type.String(),
createdAt: date.createdAt,
updatedAt: date.updatedAt,
userId: id
userId: id,
}

View File

@ -1,40 +1,40 @@
import type { Static } from '@sinclair/typebox'
import { Type } from '@sinclair/typebox'
import type { Static } from "@sinclair/typebox"
import { Type } from "@sinclair/typebox"
import { strategiesTypebox } from './OAuth'
import { userSettingsSchema } from './UserSettings'
import { date, id } from './utils'
import { strategiesTypebox } from "./OAuth"
import { userSettingsSchema } from "./UserSettings"
import { date, id } from "./utils"
export const userSchema = {
id,
name: Type.String({ minLength: 1, maxLength: 30 }),
email: Type.String({ minLength: 1, maxLength: 254, format: 'email' }),
email: Type.String({ minLength: 1, maxLength: 254, format: "email" }),
password: Type.String({ minLength: 1 }),
logo: Type.Union([
Type.String({ minLength: 1, format: 'uri-reference' }),
Type.Null()
Type.String({ minLength: 1, format: "uri-reference" }),
Type.Null(),
]),
status: Type.Union([
Type.String({ minLength: 1, maxLength: 50 }),
Type.Null()
Type.Null(),
]),
biography: Type.Union([
Type.String({ minLength: 1, maxLength: 160 }),
Type.Null()
Type.Null(),
]),
website: Type.Union([
Type.String({
minLength: 1,
maxLength: 255,
format: 'uri'
format: "uri",
}),
Type.Null()
Type.Null(),
]),
isConfirmed: Type.Boolean({ default: false }),
temporaryToken: Type.String(),
temporaryExpirationToken: Type.String({ format: 'date-time' }),
temporaryExpirationToken: Type.String({ format: "date-time" }),
createdAt: date.createdAt,
updatedAt: date.updatedAt
updatedAt: date.updatedAt,
}
export const userObjectSchema = Type.Object(userSchema)
@ -49,15 +49,15 @@ export const userPublicWithoutSettingsSchema = {
website: userSchema.website,
isConfirmed: userSchema.isConfirmed,
createdAt: date.createdAt,
updatedAt: date.updatedAt
updatedAt: date.updatedAt,
}
export const userPublicWithoutSettingsObjectSchema = Type.Object(
userPublicWithoutSettingsSchema
userPublicWithoutSettingsSchema,
)
export const userPublicSchema = {
...userPublicWithoutSettingsSchema,
settings: Type.Object(userSettingsSchema)
settings: Type.Object(userSettingsSchema),
}
export const userPublicObjectSchema = Type.Object(userPublicSchema)
@ -65,7 +65,7 @@ export const userPublicObjectSchema = Type.Object(userPublicSchema)
export const userCurrentSchema = Type.Object({
...userPublicSchema,
currentStrategy: Type.Union([...strategiesTypebox]),
strategies: Type.Array(Type.Union([...strategiesTypebox]))
strategies: Type.Array(Type.Union([...strategiesTypebox])),
})
export type User = Static<typeof userObjectSchema>

View File

@ -1,20 +1,20 @@
import type { Static } from '@sinclair/typebox'
import { Type } from '@sinclair/typebox'
import type { Static } from "@sinclair/typebox"
import { Type } from "@sinclair/typebox"
import { date, id } from './utils'
import { date, id } from "./utils"
export const languages = [Type.Literal('fr'), Type.Literal('en')]
export const themes = [Type.Literal('light'), Type.Literal('dark')]
export const languages = [Type.Literal("fr"), Type.Literal("en")]
export const themes = [Type.Literal("light"), Type.Literal("dark")]
export const userSettingsSchema = {
id,
language: Type.Union(languages, { default: 'en' }),
theme: Type.Union(themes, { default: 'dark' }),
language: Type.Union(languages, { default: "en" }),
theme: Type.Union(themes, { default: "dark" }),
isPublicEmail: Type.Boolean({ default: false }),
isPublicGuilds: Type.Boolean({ default: false }),
createdAt: date.createdAt,
updatedAt: date.updatedAt,
userId: id
userId: id,
}
export const userSettingsSchemaType = Type.Object(userSettingsSchema)

View File

@ -1,14 +1,14 @@
import { Type } from '@sinclair/typebox'
import { Type } from "@sinclair/typebox"
export const date = {
createdAt: Type.String({
format: 'date-time',
description: 'Created date time'
format: "date-time",
description: "Created date time",
}),
updatedAt: Type.String({
format: 'date-time',
description: 'Last updated date time'
})
format: "date-time",
description: "Last updated date time",
}),
}
export const id = Type.Integer({ minimum: 1, description: 'Unique identifier' })
export const id = Type.Integer({ minimum: 1, description: "Unique identifier" })