brutalism design

This commit is contained in:
2026-05-22 05:08:02 +06:00
parent abf4d41c23
commit e4ed785911
51 changed files with 940 additions and 1171 deletions

1
new-client/AGENTS.md Normal file
View File

@@ -0,0 +1 @@
use context7

View File

@@ -6,10 +6,10 @@
"scripts": {
"dev": "vite",
"build": "vue-tsc -b && vite build",
"preview": "vite preview"
"preview": "vite preview",
"typegen": "npx swagger-typescript-api generate --path http://localhost:4000/reference/openapi.yaml --output ./src/shared/api --name generated-chad-api.ts"
},
"dependencies": {
"@ark-ui/vue": "^5.36.2",
"@lucide/vue": "^1.14.0",
"@tanstack/query-persist-client-core": "^5.100.10",
"@tanstack/vue-query": "^5.100.10",
@@ -20,9 +20,12 @@
"@vueuse/core": "^14.3.0",
"@zag-js/avatar": "^1.40.0",
"@zag-js/collapsible": "^1.40.0",
"@zag-js/file-utils": "^1.40.0",
"@zag-js/password-input": "^1.40.0",
"@zag-js/toggle": "^1.40.0",
"@zag-js/vue": "^1.40.0",
"date-fns": "^4.1.0",
"mediasoup-client": "^3.20.0",
"mitt": "^3.0.1",
"primevue": "^4.5.5",
"socket.io-client": "^4.8.3",

View File

@@ -1,7 +1,9 @@
import initializeApp from './bootstrap/app'
import authorize from './bootstrap/authorize'
import showError from './bootstrap/error'
import setupMediasoup from './bootstrap/mediasoup'
import preloader from './bootstrap/preloader'
import connectSignaling from './bootstrap/signaling'
import checkUpdates from './bootstrap/updater'
(async () => {
@@ -13,6 +15,9 @@ import checkUpdates from './bootstrap/updater'
await authorize()
connectSignaling()
setupMediasoup()
await initializeApp()
}
catch (error) {

View File

@@ -2,6 +2,7 @@ import { Api } from './generated-chad-api'
const api = new Api({
baseUrl: 'http://localhost:4000',
baseApiParams: { credentials: 'include' },
})
function isChadResponseError(error) {

View File

@@ -30,7 +30,7 @@ export interface Attachment {
*/
export interface Channel {
id: string;
ownerId: string | null;
ownerUsername: string | null;
name: string;
persistent: boolean;
}
@@ -42,15 +42,22 @@ export interface Channel {
export interface ChatMessage {
/** @format uuid */
id: string;
/** @format uuid */
senderId: string;
senderUsername: string;
/** @minLength 1 */
text: string;
/** @format date-time */
createdAt: string;
/** @format date-time */
updatedAt: string;
attachments: string[];
attachments: {
id: string;
name: string;
mimetype: string;
/** @min 0 */
size: number;
/** @format date-time */
createdAt: string;
}[];
}
/**
@@ -118,8 +125,7 @@ export interface NewChatMessagePayload {
export interface Reply {
/** @format uuid */
messageId: string;
/** @format uuid */
senderId: string;
senderUsername: string;
text: string;
}
@@ -164,7 +170,6 @@ export interface UserPreferences {
* User
*/
export interface User {
id: string;
username: string;
displayName: string;
/** @format date-time */
@@ -232,7 +237,7 @@ export class HttpClient<SecurityDataType = unknown> {
fetch(...fetchParams);
private baseApiParams: RequestParams = {
credentials: "include",
credentials: "same-origin",
headers: {},
redirect: "follow",
referrerPolicy: "no-referrer",
@@ -590,30 +595,8 @@ export class Api<
* @summary Send message
* @request POST:/chad/chat/send
*/
chatSend: (
data: {
/** @minLength 1 */
text: string;
attachments?: string[];
},
params: RequestParams = {},
) =>
this.request<
{
/** @format uuid */
id: string;
/** @format uuid */
senderId: string;
/** @minLength 1 */
text: string;
/** @format date-time */
createdAt: string;
/** @format date-time */
updatedAt: string;
attachments: string[];
},
ResponseError
>({
chatSend: (data: NewChatMessagePayload, params: RequestParams = {}) =>
this.request<ChatMessage, ResponseError>({
path: `/chad/chat/send`,
method: "POST",
body: data,
@@ -648,19 +631,7 @@ export class Api<
) =>
this.request<
{
messages: {
/** @format uuid */
id: string;
/** @format uuid */
senderId: string;
/** @minLength 1 */
text: string;
/** @format date-time */
createdAt: string;
/** @format date-time */
updatedAt: string;
attachments: string[];
}[];
messages: ChatMessage[];
/**
* Cursor to last message
* @format uuid

View File

@@ -8,7 +8,7 @@ export function qUser(username: MaybeRefOrGetter<string>) {
return useQuery<User, ResponseError>({
queryKey: ['user', username],
queryFn: async () => {
const response = await api.chad.userGet({ id: toValue(username) })
const response = await api.chad.userGet({ username: toValue(username) })
return response.data
},

View File

@@ -46,6 +46,10 @@ const api = computed(() => avatar.connect(service, normalizeProps))
#{$self}.highlighted & {
background-color: var(--yellow);
}
&[data-state='hidden'] {
display: none;
}
}
&__image {
@@ -53,6 +57,10 @@ const api = computed(() => avatar.connect(service, normalizeProps))
height: 100%;
object-fit: cover;
object-position: center;
&[data-state='hidden'] {
display: none;
}
}
}
</style>

View File

@@ -38,6 +38,7 @@ interface Props {
.chad-button {
@include font-display-14;
flex-shrink: 0;
border: none;
color: var(--ink);
padding-inline: var(--space-3);

View File

@@ -0,0 +1,47 @@
<template>
<div class="chad-tag" :data-type="type">
<slot />
</div>
</template>
<script setup lang="ts">
interface Props {
type: 'success' | 'error'
}
defineOptions({
name: 'ChadTag',
})
defineProps<Props>()
</script>
<style lang="scss">
.chad-tag {
@include font-micro;
display: flex;
align-items: center;
gap: var(--space-1);
color: var(--grey-3);
&::before {
content: '';
display: block;
width: 10px;
height: 10px;
}
&[data-type='success'] {
&::before {
background-color: var(--green);
}
}
&[data-type='error'] {
&::before {
background-color: var(--red);
}
}
}
</style>

View File

@@ -0,0 +1,67 @@
<template>
<button class="chad-toggle" v-bind="api.getRootProps()">
<span class="chad-toggle__indicator" v-bind="api.getIndicatorProps()" />
<slot />
</button>
</template>
<script setup lang="ts">
import type { Component } from 'vue'
import * as toggle from '@zag-js/toggle'
import { normalizeProps, useMachine } from '@zag-js/vue'
import { computed } from 'vue'
defineOptions({
name: 'ChadToggle',
})
const props = defineProps<{
disabled?: boolean
icon?: Component
}>()
const modelValue = defineModel<boolean>('modelValue')
const service = useMachine(toggle.machine, computed(() => {
return {
disabled: props.disabled,
pressed: modelValue.value,
onPressedChange: (pressed) => {
modelValue.value = pressed
},
} as toggle.Props
}))
const api = computed(() => toggle.connect(service, normalizeProps))
</script>
<style lang="scss">
.chad-toggle {
@include font-micro;
border: var(--border-w) solid var(--ink);
height: 44px;
cursor: pointer;
&:hover,
&:active {
background-color: var(--grey-2);
}
&[data-state='on'] {
background-color: var(--yellow);
}
&[data-state='off'] {
background-color: var(--paper);
color: var(--grey-3);
}
&:disabled {
cursor: not-allowed;
background-color: var(--grey-1);
color: var(--grey-3);
}
}
</style>

View File

@@ -0,0 +1,72 @@
import type { ChadClient } from '@shared/types.ts'
import { useSignaling } from '@shared/composables/use-signaling.ts'
import { createGlobalState } from '@vueuse/core'
import { computed, shallowRef } from 'vue'
import { useAuth } from './use-auth'
export const useClients = createGlobalState(() => {
const { me } = useAuth()
const signaling = useSignaling()
const clients = shallowRef<ChadClient[]>([])
function addClient(...incoming: ChadClient[]) {
const ids = new Set(incoming.map(c => c.socketId))
clients.value = [
...clients.value.filter(c => !ids.has(c.socketId)),
...incoming,
]
}
function removeClient(...socketIds: string[]) {
const ids = new Set(socketIds)
clients.value = clients.value.filter(c => !ids.has(c.socketId))
}
function updateClient(socketId: string, patch: Partial<Omit<ChadClient, 'socketId'>>) {
clients.value = clients.value.map(c =>
c.socketId === socketId ? { ...c, ...patch } : c,
)
}
function findById(socketId: string) {
return clients.value.find(c => c.socketId === socketId)
}
function findByChannel(channelId: string) {
return clients.value.filter(c => c.channelId === channelId)
}
function findByUsername(username: string) {
return clients.value.find(c => c.username === username)
}
const self = computed(() => {
return clients.value.find((client) => {
if (signaling.socket.value) {
return client.socketId === signaling.socket.value.id
}
else if (me.value) {
return client.username === me.value.username
}
return undefined
})
})
function clear() {
clients.value = []
}
return {
clients,
self,
addClient,
removeClient,
updateClient,
findById,
findByChannel,
findByUsername,
clear,
}
})

View File

@@ -1,3 +1,4 @@
import type { ChatMessage } from '@shared/api/generated-chad-api.ts'
import type { EventType } from 'mitt'
import mitt from 'mitt'
@@ -29,7 +30,7 @@ export interface AppEvents extends Record<EventType, unknown> {
'share:enabled': void
'share:disabled': void
'chat:new-message': void
'chat:new-message': ChatMessage
}
const emitter = mitt<AppEvents>()

View File

@@ -0,0 +1,3 @@
export function useSession() {
return {}
}

View File

@@ -7,7 +7,7 @@ import { useAuth } from './use-auth'
import { useEventBus } from './use-event-bus'
export const useSignaling = createSharedComposable(() => {
const { emit } = useEventBus()
const eventBus = useEventBus()
const { me } = useAuth()
const socket = shallowRef<Socket>()
@@ -44,9 +44,9 @@ export const useSignaling = createSharedComposable(() => {
watch(connected, (connected) => {
if (connected)
emit('socket:connected')
eventBus.emit('socket:connected')
else
emit('socket:disconnected')
eventBus.emit('socket:disconnected')
}, { immediate: true })
watch(me, (me) => {
@@ -56,10 +56,7 @@ export const useSignaling = createSharedComposable(() => {
}
})
onScopeDispose(() => {
socket.value?.close()
socket.value = undefined
})
onScopeDispose(disconnect)
function connect() {
if (socket.value || !me.value)
@@ -73,15 +70,18 @@ export const useSignaling = createSharedComposable(() => {
path: `${pathname}/ws`,
transports: ['websocket'],
withCredentials: true,
auth: {
userId: me.value.id,
},
})
}
function disconnect() {
socket.value?.disconnect()
socket.value = undefined
}
return {
socket,
connected,
connect,
disconnect,
}
})

View File

@@ -21,9 +21,22 @@
<aside class="sidebar">
<ChannelList class="sidebar__channel-list" />
<ChadButton style="margin: var(--space-2);" @click="logout">
Logout
</ChadButton>
<!-- <dl> -->
<!-- <template v-for="consumer in consumers.store.value.values()" :key="consumer.id"> -->
<!-- <dt>{{ consumer.id }}</dt> -->
<!-- <dd><strong>paused</strong> <i>{{ consumer.paused }}</i></dd> -->
<!-- <dd><strong>appData</strong> <i>{{ consumer.appData }}</i></dd> -->
<!-- </template> -->
<!-- </dl> -->
<!-- <ChadButton style="margin: var(&#45;&#45;space-2);" @click="toggleMic"> -->
<!-- Toggle mic -->
<!-- </ChadButton> -->
<!-- <ChadButton style="margin: var(&#45;&#45;space-2);" @click="logout"> -->
<!-- Logout -->
<!-- </ChadButton> -->
<ControlPanel />
</aside>
<div class="content">
@@ -33,17 +46,28 @@
</template>
<script setup lang="ts">
import ChadButton from '@shared/components/ui/Button.vue'
import { useApp } from '@shared/composables/use-app.js'
import { useAuth } from '@shared/composables/use-auth.ts'
import { useMediasoup } from '@shared/composables/use-mediasoup.ts'
import { useProducers } from '@shared/composables/use-producers.ts'
import ChannelList from '@widgets/channel-list/ui/ChannelList.vue'
import ControlPanel from '@widgets/control-panel/ui/ControlPanel.vue'
import { watchEffect } from 'vue'
defineOptions({
name: 'DefaultLayout',
})
const { version } = useApp()
const { logout } = useAuth()
const { sendTransport } = useMediasoup()
const { enableMic } = useProducers()
watchEffect(() => {
if (!sendTransport.value)
return
enableMic()
})
</script>
<style lang="scss">

View File

@@ -35,9 +35,18 @@ a {
color: var(--yellow);
}
}
//
//*,
//*::before,
//*::after {
// @include font-body;
//}
::-webkit-scrollbar {
color: var(--grey-2);
height: 8px;
width: 8px;
}
::-webkit-scrollbar-thumb {
background-color: var(--grey-2);
//border-right: 4px solid var(--paper);
&:hover {
background-color: var(--grey-3);
}
}

View File

@@ -1,7 +1,8 @@
export interface ChadClient {
socketId: string
userId: string
username: string
channelId: string
inputMuted?: boolean
outputMuted?: boolean
micMuted?: boolean
soundMuted?: boolean
streaming?: boolean
}

View File

@@ -5,26 +5,38 @@
</div>
<div v-bind="api.getContentProps()" class="channel__content">
Clients...
<p v-for="client in clients" :key="client.socketId">
{{ client.username }}
</p>
</div>
</li>
</template>
<script setup lang="ts">
import type { Channel } from '@shared/api/generated-chad-api.ts'
import type { ChadClient } from '@shared/types.ts'
import { useClients } from '@shared/composables/use-clients.ts'
import * as collapsible from '@zag-js/collapsible'
import { normalizeProps, useMachine } from '@zag-js/vue'
import { computed } from 'vue'
const props = defineProps<{
channel: Channel
clients: ChadClient[]
}>()
const service = useMachine(collapsible.machine, { id: '1' })
const { findByChannel } = useClients()
const service = useMachine(collapsible.machine, computed(() => {
return {
id: props.channel.id,
defaultOpen: true,
}
}))
const api = computed(() => collapsible.connect(service, normalizeProps))
const clients = computed(() => {
return findByChannel(props.channel.id)
})
</script>
<style lang="scss">

View File

@@ -1,14 +1,14 @@
<template>
<div class="channel-list">
<ul class="channel-list__list">
<ChannelItem v-for="channel in channels" :key="channel.id" :channel="channel" />
<Channel v-for="channel in channels" :key="channel.id" :channel="channel" />
</ul>
</div>
</template>
<script setup lang="ts">
import { qChannelList } from '../api/qChannelList.ts'
import ChannelItem from './ChannelItem.vue'
import Channel from './Channel.vue'
const { data: channels } = qChannelList()
</script>

View File

@@ -1,5 +1,5 @@
import type { ChatMessage, ResponseError } from '@shared/api/generated-chad-api.ts'
import type { InfiniteData, QueryKey } from '@tanstack/vue-query'
import type { QueryKey } from '@tanstack/vue-query'
import api from '@shared/api/client.ts'
import { useInfiniteQuery } from '@tanstack/vue-query'
@@ -10,10 +10,10 @@ interface Response {
type PageParam = string | undefined
export function qChatMessages() {
return useInfiniteQuery<Response, ResponseError, InfiniteData<Response, PageParam>, QueryKey, PageParam>({
return useInfiniteQuery<Response, ResponseError, ChatMessage[], QueryKey, PageParam>({
queryKey: ['chat-messages'],
queryFn: async ({ pageParam }) => {
const response = await api.chad.chatMessages({ cursor: pageParam, limit: 30 })
const response = await api.chad.chatMessages({ cursor: pageParam, limit: 25 })
return response.data
// return {
@@ -25,6 +25,9 @@ export function qChatMessages() {
// pages: [...data.pages].reverse(),
// pageParams: [...data.pageParams].reverse(),
// }),
select: (data) => {
return data.pages.flatMap(page => page.messages).toReversed()
},
initialPageParam: undefined,
getNextPageParam: (lastPage) => {
return lastPage.nextCursor

View File

@@ -0,0 +1,79 @@
import type { MaybeRefOrGetter, TemplateRef } from 'vue'
import { useEventListener, useMutationObserver } from '@vueuse/core'
import { computed, reactive, toValue, watch } from 'vue'
interface ChatScrollOptions {
startOffset?: number
endOffset?: number
}
export function useChatScroll(target: TemplateRef<HTMLElement>, options?: MaybeRefOrGetter<ChatScrollOptions>) {
const el = computed(() => toValue(target))
const arrivedState = reactive({
start: true,
end: false,
})
watch(arrivedState, () => {
console.log('arrived state', arrivedState)
})
watch(el, (el) => {
if (!el)
return
scrollToStart(true)
getArrivedState()
}, { flush: 'post' })
useMutationObserver(el, () => {
if (arrivedState.start) {
scrollToStart(true)
}
getArrivedState()
}, {
childList: true,
// subtree: true,
})
useEventListener(el, 'scroll', () => {
getArrivedState()
}, { passive: true })
useEventListener(el, 'scrollend', () => {
getArrivedState()
}, { passive: true })
function getArrivedState() {
if (!el.value) {
arrivedState.start = true
arrivedState.end = false
return
}
const { startOffset = 0, endOffset = 0 } = toValue(options) ?? {}
const offsetHeight = el.value.offsetHeight
const scrollHeight = el.value.scrollHeight
const scrollTop = Math.abs(el.value.scrollTop)
arrivedState.start = scrollTop + offsetHeight >= scrollHeight - startOffset
arrivedState.end = scrollTop <= endOffset
}
function scrollToStart(instant = false) {
if (!el.value)
return
const offset = Math.ceil(el.value.scrollHeight - el.value.offsetHeight)
el.value.scrollTo({ top: offset, behavior: instant ? 'instant' : 'smooth' })
}
return {
arrivedState,
scrollToStart,
}
}

View File

@@ -1,13 +1,24 @@
import type { ChatMessage } from '@shared/api/generated-chad-api.ts'
import { useSignaling } from '@shared/composables/use-signaling'
import { createGlobalState } from '@vueuse/core'
import { shallowRef, triggerRef, watch } from 'vue'
import { qChatMessages } from '../api/qChatMessages.ts'
export const useChat = createGlobalState(() => {
const { data: messages, hasNextPage: hasMoreMessages, fetchNextPage, isFetching } = qChatMessages()
return {
messages,
hasMoreMessages,
fetchNextPage,
isFetching,
}
const { socket, connected } = useSignaling()
const feedItems = shallowRef<ChatMessage[]>([])
watch(connected, (isConnected) => {
if (!isConnected)
return
socket.value!.on('chat:new-message', (message: ChatMessage) => {
feedItems.value.push(message)
triggerRef(feedItems)
})
})
return { messages, feedItems, hasMoreMessages, fetchNextPage, isFetching }
})

View File

@@ -4,7 +4,7 @@
<div>
<div class="chat-message__top">
<p class="chat-message__sender">
{{ !sender ? message.senderId : sender.displayName }}
{{ !sender ? message.senderUsername : sender.displayName }}
</p>
<p class="chat-message__datetime">
@@ -16,9 +16,7 @@
{{ message.text }}
</p>
<div v-if="message.attachments.length > 0" class="chat-message__attachments">
<ChatMessageAttachment v-for="attachmentId in message.attachments" :key="attachmentId" :attachment-id="attachmentId" />
</div>
<ChatMessageAttachments v-if="message.attachments.length > 0" :attachments="message.attachments" class="chat-message__attachments" />
</div>
</div>
</template>
@@ -28,7 +26,7 @@ import type { ChatMessage } from '@shared/api/generated-chad-api.ts'
import ChadAvatar from '@shared/components/ui/Avatar.vue'
import { useAuth } from '@shared/composables/use-auth.ts'
import { useUserDetails } from '@shared/composables/use-user-details.ts'
import ChatMessageAttachment from '@widgets/chat/ui/ChatMessageAttachment.vue'
import ChatMessageAttachments from '@widgets/chat/ui/ChatMessageAttachments.vue'
import { format, isThisYear, isToday } from 'date-fns'
import { computed, toRef } from 'vue'
@@ -39,12 +37,12 @@ const props = defineProps<{
const { me } = useAuth()
const isMyMessage = computed(() => {
return props.message.senderId === me.value?.id
return props.message.senderUsername === me.value?.username
})
const { user: sender, isFetching: fetchingSender } = useUserDetails(toRef(() => props.message.senderId))
const { user: sender } = useUserDetails(toRef(() => props.message.senderUsername))
const initials = computed(() => props.message.senderId.slice(props.message.senderId.length - 2))
const initials = computed(() => props.message.senderUsername.slice(props.message.senderUsername.length - 2))
const datetime = computed(() => {
let formatStr = 'd MMMM yyyy, HH:mm'
@@ -68,7 +66,8 @@ const datetime = computed(() => {
grid-template-columns: auto 1fr;
grid-template-areas: 'avatar top' 'avatar body';
column-gap: var(--space-3);
padding: var(--space-3) var(--space-6);
padding-block: var(--space-3);
padding-inline: var(--space-6);
&__avatar {
grid-area: avatar;
@@ -99,11 +98,8 @@ const datetime = computed(() => {
}
&__attachments {
//overflow-x: auto;
margin-top: var(--space-2);
> *:not(:last-child) {
margin-bottom: var(--space-1);
}
}
}
</style>

View File

@@ -1,46 +1,91 @@
<template>
<div class="chat-message-attachment">
<p v-if="isFetching">
Loading...
</p>
<template v-else-if="attachment">
<img v-if="isImage" :src="src" :alt="attachmentId" draggable="false">
</template>
<div class="chat-message-attachment" @click="download">
<div class="chat-message-attachment__extension">
{{ extension }}
</div>
<div class="chat-message-attachment__body">
<p class="chat-message-attachment__name">
{{ attachment.name }}
</p>
<p class="chat-message-attachment__size">
{{ attachment.size }} KB
</p>
</div>
</div>
</template>
<script setup lang="ts">
import { qMessageAttachment } from '@widgets/chat/api/qMessageAttachment.ts'
import { computed, toRef } from 'vue'
import type { Attachment } from '@shared/api/generated-chad-api.ts'
import api from '@shared/api/client.ts'
import { downloadFile } from '@zag-js/file-utils'
import { computed } from 'vue'
const props = defineProps<{
attachmentId: string
attachment: Attachment
}>()
const { isFetching, data: attachment } = qMessageAttachment(toRef(() => props.attachmentId))
const extension = computed(() => props.attachment.name.split('.')[1])
const isImage = computed(() => {
return attachment.value?.type.startsWith('image/')
const url = computed(() => {
return `${__API_BASE_URL__}/attachment/${props.attachment.id}`
})
const src = computed(() => {
if (!attachment.value || !isImage.value)
return undefined
async function download() {
const response = await api.chad.attachmentGet(props.attachment.id, { format: 'blob' })
return URL.createObjectURL(attachment.value)
})
downloadFile({ name: props.attachment.name, type: props.attachment.mimetype, file: response.data })
}
</script>
<style lang="scss">
.chat-message-attachment {
display: grid;
grid-template-columns: 52px 1fr;
outline: var(--border-w) solid var(--ink);
outline-offset: calc(var(--border-w) * -1);
background-color: var(--grey-1);
width: fit-content;
width: 300px;
height: 52px;
//overflow: hidden;
cursor: pointer;
> img {
max-width: 260px;
max-height: 160px;
&:hover {
background-color: var(--grey-2);
}
&__extension {
@include font-label;
overflow: hidden;
white-space: nowrap;
line-height: 52px;
text-align: center;
background-color: var(--ink);
color: var(--white);
}
&__body {
flex: 1;
padding: var(--space-3);
align-self: center;
}
&__name {
@include font-body-bold;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
&__size {
@include font-micro;
margin-top: var(--space-1);
color: var(--grey-3);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
</style>

View File

@@ -0,0 +1,51 @@
<template>
<div class="chat-message-attachments">
<div v-if="images.length > 0" class="chat-message-attachments__images">
<ChatMessageImageAttachment v-for="attachment in images" :key="attachment.id" :attachment="attachment" />
</div>
<div v-if="notImages.length > 0" class="chat-message-attachments__list">
<ChatMessageAttachment v-for="attachment in notImages" :key="attachment.id" :attachment="attachment" />
</div>
</div>
</template>
<script setup lang="ts">
import type { Attachment } from '@shared/api/generated-chad-api.ts'
import ChatMessageAttachment from '@widgets/chat/ui/ChatMessageAttachment.vue'
import ChatMessageImageAttachment from '@widgets/chat/ui/ChatMessageImageAttachment.vue'
import { computed } from 'vue'
const props = defineProps<{
attachments: Attachment[]
}>()
const images = computed(() => {
return props.attachments.filter(attachment => attachment.mimetype.startsWith('image/'))
})
const notImages = computed(() => {
return props.attachments.filter(attachment => !attachment.mimetype.startsWith('image/'))
})
</script>
<style lang="scss">
.chat-message-attachments {
> *:not(:last-child) {
margin-bottom: var(--space-3);
}
&__images {
display: flex;
gap: var(--space-2);
flex-wrap: nowrap;
overflow-x: auto;
}
&__list {
> *:not(:last-child) {
margin-bottom: var(--space-2);
}
}
}
</style>

View File

@@ -0,0 +1,33 @@
<template>
<div class="chat-message-image-attachment">
<img :src="src" :alt="attachment.name" draggable="false">
</div>
</template>
<script setup lang="ts">
import type { Attachment } from '@shared/api/generated-chad-api.ts'
import { computed } from 'vue'
const props = defineProps<{
attachment: Attachment
}>()
const src = computed(() => {
return `${__API_BASE_URL__}/attachment/${props.attachment.id}`
})
</script>
<style lang="scss">
.chat-message-image-attachment {
outline: var(--border-w) solid var(--ink);
outline-offset: calc(var(--border-w) * -1);
background-color: var(--grey-1);
width: fit-content;
height: 160px;
> img {
max-width: 260px;
height: 100%;
}
}
</style>

View File

@@ -1,38 +1,64 @@
<template>
<div class="chat-messages">
<div v-if="messages" ref="scroll" class="chat-messages__list">
<template v-for="(page, pageIdx) in messages.pages" :key="pageIdx">
<ChatMessage v-for="message in page.messages" :key="message.id" :message="message" />
</template>
<ChatMessage v-for="message in messages" :key="message.id" :message="message" />
<ChatMessage v-for="item in feedItems" :key="item.id" :message="item" />
</div>
<ChadSpinner v-if="isFetching" class="chat-messages__spinner" />
<button v-if="!arrivedState.start" class="chat-messages__scroll-to-bottom" @click="scrollToStart()">
<ArrowDown />
</button>
</div>
</template>
<script setup lang="ts">
import { ArrowDown } from '@lucide/vue'
import ChadSpinner from '@shared/components/ui/Spinner.vue'
import { useInfiniteScroll } from '@vueuse/core'
import { useEventBus } from '@shared/composables/use-event-bus.ts'
import { useChatScroll } from '@widgets/chat/composables/use-chat-scroll.ts'
import ChatMessage from '@widgets/chat/ui/ChatMessage.vue'
import { useTemplateRef } from 'vue'
import { onUnmounted, ref, useTemplateRef, watch } from 'vue'
import { useChat } from '../composables/use-chat'
const eventBus = useEventBus()
const scrollRef = useTemplateRef('scroll')
const { messages, hasMoreMessages, fetchNextPage, isFetching } = useChat()
const { messages, feedItems, hasMoreMessages, fetchNextPage, isFetching } = useChat()
useInfiniteScroll(
scrollRef,
() => {
const hasUnreadMessages = ref(false)
const { arrivedState, scrollToStart } = useChatScroll(scrollRef, {
startOffset: 100,
endOffset: 100,
})
watch(() => arrivedState.end, (arrived) => {
if (!arrived)
return
if (hasMoreMessages.value) {
fetchNextPage()
},
{
distance: 500,
direction: 'top',
interval: 300,
canLoadMore: () => hasMoreMessages.value && !isFetching.value,
},
)
}
})
watch(() => arrivedState.start, () => {
hasUnreadMessages.value = false
})
eventBus.on('chat:new-message', onNewChatMessage)
onUnmounted(() => {
eventBus.off('chat:new-message', onNewChatMessage)
})
function onNewChatMessage() {
if (!arrivedState.start) {
hasUnreadMessages.value = true
}
}
</script>
<style lang="scss">
@@ -49,11 +75,34 @@ useInfiniteScroll(
}
&__list {
overflow-x: hidden;
overflow-y: auto;
overflow-y: overlay;
display: flex;
flex-direction: column-reverse;
height: 100%;
position: relative;
max-height: 100%;
}
&__scroll-to-bottom {
position: absolute;
cursor: pointer;
width: 40px;
aspect-ratio: 1;
text-align: center;
line-height: 40px;
bottom: var(--space-4);
right: var(--space-4);
outline: var(--border-w) solid var(--ink);
outline-offset: calc(var(--border-w) * -1);
border: none;
background-color: var(--grey-1);
padding: 0;
&:hover,
&:focus,
&:active {
background-color: var(--grey-2);
}
}
}
</style>

View File

@@ -0,0 +1,63 @@
<template>
<div class="control-panel">
<ChadTag class="control-panel__status" :type="connected ? 'success' : 'error'">
{{ connected ? 'Connected' : 'Disconnected' }}
</ChadTag>
<div class="control-panel__toggles">
<ChadToggle :model-value="isMicEnabled" @update:model-value="toggleMic">
MIC
</ChadToggle>
<ChadToggle :model-value="isSoundEnabled" @update:model-value="toggleSound">
SND
</ChadToggle>
<ChadToggle :model-value="isCameraEnabled" @update:model-value="toggleCamera">
CAM
</ChadToggle>
<ChadToggle :model-value="isShareEnabled" @update:model-value="toggleShare">
SHR
</ChadToggle>
</div>
</div>
</template>
<script setup lang="ts">
import ChadTag from '@shared/components/ui/Tag.vue'
import ChadToggle from '@shared/components/ui/Toggle.vue'
import { useMediaControls } from '@shared/composables/use-media-controls.ts'
import { useSignaling } from '@shared/composables/use-signaling.ts'
const { connected } = useSignaling()
const {
isMicEnabled,
isSoundEnabled,
isCameraEnabled,
isShareEnabled,
toggleMic,
toggleSound,
toggleCamera,
toggleShare,
} = useMediaControls()
</script>
<style lang="scss">
.control-panel {
border-top: var(--border-w) solid var(--ink);
padding: var(--space-3);
background-color: var(--grey-1);
&__status {
margin-bottom: var(--space-3);
}
&__toggles {
display: grid;
grid-template-columns: repeat(4, 1fr);
align-items: center;
> *:not(:last-child) {
border-right: none;
}
}
}
</style>

View File

@@ -2,7 +2,7 @@
"extends": "@vue/tsconfig/tsconfig.dom.json",
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"lib": ["ES2023", "DOM"],
"moduleResolution": "Bundler",
"paths": {
"@app/*": ["./src/app/*"],

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,6 @@ import fp from 'fastify-plugin'
import { Lucia } from 'lucia'
interface DatabaseUserAttributes {
id: string
displayName: string
username: string
createdAt: Date

View File

@@ -1,7 +1,6 @@
import { Type } from 'typebox'
export const UserSchema = Type.Object({
id: Type.String(),
username: Type.String(),
displayName: Type.String(),
createdAt: Type.String({ format: 'date-time' }),

View File

@@ -2,7 +2,7 @@ import { Type } from 'typebox'
export const ChannelSchema = Type.Object({
id: Type.String(),
ownerId: Type.Union([Type.String(), Type.Null()]),
ownerUsername: Type.Union([Type.String(), Type.Null()]),
name: Type.String(),
persistent: Type.Boolean(),
}, { $id: 'Channel' })

View File

@@ -1,19 +1,20 @@
import { Type } from 'typebox'
import { AttachmentSchema } from './attachment.ts'
export const ReplySchema = Type.Object({
messageId: Type.String({ format: 'uuid' }),
senderId: Type.String({ format: 'uuid' }),
senderUsername: Type.String(),
text: Type.String(),
}, { $id: 'Reply' })
export const ChatMessageSchema = Type.Object({
id: Type.String({ format: 'uuid' }),
senderId: Type.String({ format: 'uuid' }),
senderUsername: Type.String(),
text: Type.String({ minLength: 1 }),
createdAt: Type.String({ format: 'date-time' }),
updatedAt: Type.String({ format: 'date-time' }),
attachments: Type.Array(Type.String({ format: 'uuid' })),
attachments: Type.Array(AttachmentSchema),
}, { $id: 'ChatMessage' })
export const NewChatMessagePayloadSchema = Type.Object({

View File

@@ -2,7 +2,6 @@ import { Type } from 'typebox'
export const GetUserQuerySchema = Type.Partial(Type.Object({
username: Type.String(),
id: Type.String(),
}), { $id: 'GetUserQuery' })
export const UserPreferencesSchema = Type.Object({

View File

@@ -4,7 +4,7 @@ import type { Channel, User } from '../../prisma/generated-client/client.ts'
export interface SerializedClient {
socketId: string
userId: User['id']
username: User['username']
channelId: Channel['id']
inputMuted: boolean
outputMuted: boolean

View File

@@ -26,7 +26,7 @@ interface ClientEvents {
export class Client extends EventEmitter<ClientEvents> {
readonly socketId: string
readonly userId: string
readonly username: string
channelId: string = ''
#inputMuted = false
@@ -38,11 +38,11 @@ export class Client extends EventEmitter<ClientEvents> {
readonly #producers = new Map<string, types.Producer>()
readonly #consumers = new Map<string, types.Consumer>()
constructor(socketId: string, userId: string, router: types.Router) {
constructor(socketId: string, username: string, router: types.Router) {
super()
this.socketId = socketId
this.userId = userId
this.username = username
this.#router = router
}
@@ -278,7 +278,7 @@ export class Client extends EventEmitter<ClientEvents> {
serialize(): SerializedClient {
return {
socketId: this.socketId,
userId: this.userId,
username: this.username,
channelId: this.channelId,
inputMuted: this.#inputMuted,
outputMuted: this.#outputMuted,

View File

@@ -23,7 +23,7 @@ export default async function (fastify: FastifyInstance) {
io.on('connection', async (socket) => {
consola.info('[WebRtc]', 'Client connected', socket.id)
const client = new Client(socket.id, socket.data.user.id, mediasoupRouter)
const client = new Client(socket.id, socket.data.user.username, mediasoupRouter)
defaultChannel.addClient(client)
socket.join(defaultChannel.id)

View File

@@ -1,3 +1,4 @@
/* !!! This is code generated by Prisma. Do not edit directly. !!! */
/* eslint-disable */
// biome-ignore-all lint: generated file
@@ -7,7 +8,7 @@
* Use it to get access to models, enums, and input types.
*
* This file does not contain a `PrismaClient` class, nor several other helpers that are intended as server-side only.
* See `Client.ts` for the standard, server-side entry point.
* See `client.ts` for the standard, server-side entry point.
*
* 🟢 You can import this file directly.
*/

File diff suppressed because one or more lines are too long

View File

@@ -1,3 +1,4 @@
/* !!! This is code generated by Prisma. Do not edit directly. !!! */
/* eslint-disable */
// biome-ignore-all lint: generated file
@@ -7,7 +8,7 @@
*
* 🛑 Under no circumstances should you import this file directly! 🛑
*
* All exports from this file are wrapped under a `Prisma` namespace object in the Client.ts file.
* All exports from this file are wrapped under a `Prisma` namespace object in the client.ts file.
* While this enables partial backward compatibility, it is not part of the stable public API.
*
* If you are looking for your Models, Enums, and Input Types, please import them from the respective
@@ -964,7 +965,6 @@ export type TransactionIsolationLevel = (typeof TransactionIsolationLevel)[keyof
export const UserScalarFieldEnum = {
id: 'id',
username: 'username',
password: 'password',
displayName: 'displayName',
@@ -985,7 +985,7 @@ export type SessionScalarFieldEnum = (typeof SessionScalarFieldEnum)[keyof typeo
export const UserPreferencesScalarFieldEnum = {
userId: 'userId',
username: 'username',
toggleInputHotkey: 'toggleInputHotkey',
toggleOutputHotkey: 'toggleOutputHotkey'
} as const
@@ -1007,7 +1007,7 @@ export type AttachmentScalarFieldEnum = (typeof AttachmentScalarFieldEnum)[keyof
export const MessageScalarFieldEnum = {
id: 'id',
text: 'text',
senderId: 'senderId',
senderUsername: 'senderUsername',
createdAt: 'createdAt',
updatedAt: 'updatedAt'
} as const
@@ -1025,7 +1025,7 @@ export type MessageAttachmentScalarFieldEnum = (typeof MessageAttachmentScalarFi
export const ChannelScalarFieldEnum = {
id: 'id',
ownerId: 'ownerId',
ownerUsername: 'ownerUsername',
name: 'name',
persistent: 'persistent'
} as const

View File

@@ -74,7 +74,6 @@ export type TransactionIsolationLevel = (typeof TransactionIsolationLevel)[keyof
export const UserScalarFieldEnum = {
id: 'id',
username: 'username',
password: 'password',
displayName: 'displayName',
@@ -95,7 +94,7 @@ export type SessionScalarFieldEnum = (typeof SessionScalarFieldEnum)[keyof typeo
export const UserPreferencesScalarFieldEnum = {
userId: 'userId',
username: 'username',
toggleInputHotkey: 'toggleInputHotkey',
toggleOutputHotkey: 'toggleOutputHotkey'
} as const
@@ -117,7 +116,7 @@ export type AttachmentScalarFieldEnum = (typeof AttachmentScalarFieldEnum)[keyof
export const MessageScalarFieldEnum = {
id: 'id',
text: 'text',
senderId: 'senderId',
senderUsername: 'senderUsername',
createdAt: 'createdAt',
updatedAt: 'updatedAt'
} as const
@@ -135,7 +134,7 @@ export type MessageAttachmentScalarFieldEnum = (typeof MessageAttachmentScalarFi
export const ChannelScalarFieldEnum = {
id: 'id',
ownerId: 'ownerId',
ownerUsername: 'ownerUsername',
name: 'name',
persistent: 'persistent'
} as const

View File

@@ -26,21 +26,21 @@ export type AggregateChannel = {
export type ChannelMinAggregateOutputType = {
id: string | null
ownerId: string | null
ownerUsername: string | null
name: string | null
persistent: boolean | null
}
export type ChannelMaxAggregateOutputType = {
id: string | null
ownerId: string | null
ownerUsername: string | null
name: string | null
persistent: boolean | null
}
export type ChannelCountAggregateOutputType = {
id: number
ownerId: number
ownerUsername: number
name: number
persistent: number
_all: number
@@ -49,21 +49,21 @@ export type ChannelCountAggregateOutputType = {
export type ChannelMinAggregateInputType = {
id?: true
ownerId?: true
ownerUsername?: true
name?: true
persistent?: true
}
export type ChannelMaxAggregateInputType = {
id?: true
ownerId?: true
ownerUsername?: true
name?: true
persistent?: true
}
export type ChannelCountAggregateInputType = {
id?: true
ownerId?: true
ownerUsername?: true
name?: true
persistent?: true
_all?: true
@@ -143,7 +143,7 @@ export type ChannelGroupByArgs<ExtArgs extends runtime.Types.Extensions.Internal
export type ChannelGroupByOutputType = {
id: string
ownerId: string | null
ownerUsername: string | null
name: string
persistent: boolean
_count: ChannelCountAggregateOutputType | null
@@ -171,7 +171,7 @@ export type ChannelWhereInput = {
OR?: Prisma.ChannelWhereInput[]
NOT?: Prisma.ChannelWhereInput | Prisma.ChannelWhereInput[]
id?: Prisma.StringFilter<"Channel"> | string
ownerId?: Prisma.StringNullableFilter<"Channel"> | string | null
ownerUsername?: Prisma.StringNullableFilter<"Channel"> | string | null
name?: Prisma.StringFilter<"Channel"> | string
persistent?: Prisma.BoolFilter<"Channel"> | boolean
owner?: Prisma.XOR<Prisma.UserNullableScalarRelationFilter, Prisma.UserWhereInput> | null
@@ -179,7 +179,7 @@ export type ChannelWhereInput = {
export type ChannelOrderByWithRelationInput = {
id?: Prisma.SortOrder
ownerId?: Prisma.SortOrderInput | Prisma.SortOrder
ownerUsername?: Prisma.SortOrderInput | Prisma.SortOrder
name?: Prisma.SortOrder
persistent?: Prisma.SortOrder
owner?: Prisma.UserOrderByWithRelationInput
@@ -190,7 +190,7 @@ export type ChannelWhereUniqueInput = Prisma.AtLeast<{
AND?: Prisma.ChannelWhereInput | Prisma.ChannelWhereInput[]
OR?: Prisma.ChannelWhereInput[]
NOT?: Prisma.ChannelWhereInput | Prisma.ChannelWhereInput[]
ownerId?: Prisma.StringNullableFilter<"Channel"> | string | null
ownerUsername?: Prisma.StringNullableFilter<"Channel"> | string | null
name?: Prisma.StringFilter<"Channel"> | string
persistent?: Prisma.BoolFilter<"Channel"> | boolean
owner?: Prisma.XOR<Prisma.UserNullableScalarRelationFilter, Prisma.UserWhereInput> | null
@@ -198,7 +198,7 @@ export type ChannelWhereUniqueInput = Prisma.AtLeast<{
export type ChannelOrderByWithAggregationInput = {
id?: Prisma.SortOrder
ownerId?: Prisma.SortOrderInput | Prisma.SortOrder
ownerUsername?: Prisma.SortOrderInput | Prisma.SortOrder
name?: Prisma.SortOrder
persistent?: Prisma.SortOrder
_count?: Prisma.ChannelCountOrderByAggregateInput
@@ -211,7 +211,7 @@ export type ChannelScalarWhereWithAggregatesInput = {
OR?: Prisma.ChannelScalarWhereWithAggregatesInput[]
NOT?: Prisma.ChannelScalarWhereWithAggregatesInput | Prisma.ChannelScalarWhereWithAggregatesInput[]
id?: Prisma.StringWithAggregatesFilter<"Channel"> | string
ownerId?: Prisma.StringNullableWithAggregatesFilter<"Channel"> | string | null
ownerUsername?: Prisma.StringNullableWithAggregatesFilter<"Channel"> | string | null
name?: Prisma.StringWithAggregatesFilter<"Channel"> | string
persistent?: Prisma.BoolWithAggregatesFilter<"Channel"> | boolean
}
@@ -225,7 +225,7 @@ export type ChannelCreateInput = {
export type ChannelUncheckedCreateInput = {
id?: string
ownerId?: string | null
ownerUsername?: string | null
name: string
persistent: boolean
}
@@ -239,14 +239,14 @@ export type ChannelUpdateInput = {
export type ChannelUncheckedUpdateInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
ownerId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
ownerUsername?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
name?: Prisma.StringFieldUpdateOperationsInput | string
persistent?: Prisma.BoolFieldUpdateOperationsInput | boolean
}
export type ChannelCreateManyInput = {
id?: string
ownerId?: string | null
ownerUsername?: string | null
name: string
persistent: boolean
}
@@ -259,7 +259,7 @@ export type ChannelUpdateManyMutationInput = {
export type ChannelUncheckedUpdateManyInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
ownerId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
ownerUsername?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
name?: Prisma.StringFieldUpdateOperationsInput | string
persistent?: Prisma.BoolFieldUpdateOperationsInput | boolean
}
@@ -276,21 +276,21 @@ export type ChannelOrderByRelationAggregateInput = {
export type ChannelCountOrderByAggregateInput = {
id?: Prisma.SortOrder
ownerId?: Prisma.SortOrder
ownerUsername?: Prisma.SortOrder
name?: Prisma.SortOrder
persistent?: Prisma.SortOrder
}
export type ChannelMaxOrderByAggregateInput = {
id?: Prisma.SortOrder
ownerId?: Prisma.SortOrder
ownerUsername?: Prisma.SortOrder
name?: Prisma.SortOrder
persistent?: Prisma.SortOrder
}
export type ChannelMinOrderByAggregateInput = {
id?: Prisma.SortOrder
ownerId?: Prisma.SortOrder
ownerUsername?: Prisma.SortOrder
name?: Prisma.SortOrder
persistent?: Prisma.SortOrder
}
@@ -383,7 +383,7 @@ export type ChannelScalarWhereInput = {
OR?: Prisma.ChannelScalarWhereInput[]
NOT?: Prisma.ChannelScalarWhereInput | Prisma.ChannelScalarWhereInput[]
id?: Prisma.StringFilter<"Channel"> | string
ownerId?: Prisma.StringNullableFilter<"Channel"> | string | null
ownerUsername?: Prisma.StringNullableFilter<"Channel"> | string | null
name?: Prisma.StringFilter<"Channel"> | string
persistent?: Prisma.BoolFilter<"Channel"> | boolean
}
@@ -416,7 +416,7 @@ export type ChannelUncheckedUpdateManyWithoutOwnerInput = {
export type ChannelSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
id?: boolean
ownerId?: boolean
ownerUsername?: boolean
name?: boolean
persistent?: boolean
owner?: boolean | Prisma.Channel$ownerArgs<ExtArgs>
@@ -424,7 +424,7 @@ export type ChannelSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs
export type ChannelSelectCreateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
id?: boolean
ownerId?: boolean
ownerUsername?: boolean
name?: boolean
persistent?: boolean
owner?: boolean | Prisma.Channel$ownerArgs<ExtArgs>
@@ -432,7 +432,7 @@ export type ChannelSelectCreateManyAndReturn<ExtArgs extends runtime.Types.Exten
export type ChannelSelectUpdateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
id?: boolean
ownerId?: boolean
ownerUsername?: boolean
name?: boolean
persistent?: boolean
owner?: boolean | Prisma.Channel$ownerArgs<ExtArgs>
@@ -440,12 +440,12 @@ export type ChannelSelectUpdateManyAndReturn<ExtArgs extends runtime.Types.Exten
export type ChannelSelectScalar = {
id?: boolean
ownerId?: boolean
ownerUsername?: boolean
name?: boolean
persistent?: boolean
}
export type ChannelOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"id" | "ownerId" | "name" | "persistent", ExtArgs["result"]["channel"]>
export type ChannelOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"id" | "ownerUsername" | "name" | "persistent", ExtArgs["result"]["channel"]>
export type ChannelInclude<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
owner?: boolean | Prisma.Channel$ownerArgs<ExtArgs>
}
@@ -463,7 +463,7 @@ export type $ChannelPayload<ExtArgs extends runtime.Types.Extensions.InternalArg
}
scalars: runtime.Types.Extensions.GetPayloadResult<{
id: string
ownerId: string | null
ownerUsername: string | null
name: string
persistent: boolean
}, ExtArgs["result"]["channel"]>
@@ -891,7 +891,7 @@ export interface Prisma__ChannelClient<T, Null = never, ExtArgs extends runtime.
*/
export interface ChannelFieldRefs {
readonly id: Prisma.FieldRef<"Channel", 'String'>
readonly ownerId: Prisma.FieldRef<"Channel", 'String'>
readonly ownerUsername: Prisma.FieldRef<"Channel", 'String'>
readonly name: Prisma.FieldRef<"Channel", 'String'>
readonly persistent: Prisma.FieldRef<"Channel", 'Boolean'>
}

View File

@@ -27,7 +27,7 @@ export type AggregateMessage = {
export type MessageMinAggregateOutputType = {
id: string | null
text: string | null
senderId: string | null
senderUsername: string | null
createdAt: Date | null
updatedAt: Date | null
}
@@ -35,7 +35,7 @@ export type MessageMinAggregateOutputType = {
export type MessageMaxAggregateOutputType = {
id: string | null
text: string | null
senderId: string | null
senderUsername: string | null
createdAt: Date | null
updatedAt: Date | null
}
@@ -43,7 +43,7 @@ export type MessageMaxAggregateOutputType = {
export type MessageCountAggregateOutputType = {
id: number
text: number
senderId: number
senderUsername: number
createdAt: number
updatedAt: number
_all: number
@@ -53,7 +53,7 @@ export type MessageCountAggregateOutputType = {
export type MessageMinAggregateInputType = {
id?: true
text?: true
senderId?: true
senderUsername?: true
createdAt?: true
updatedAt?: true
}
@@ -61,7 +61,7 @@ export type MessageMinAggregateInputType = {
export type MessageMaxAggregateInputType = {
id?: true
text?: true
senderId?: true
senderUsername?: true
createdAt?: true
updatedAt?: true
}
@@ -69,7 +69,7 @@ export type MessageMaxAggregateInputType = {
export type MessageCountAggregateInputType = {
id?: true
text?: true
senderId?: true
senderUsername?: true
createdAt?: true
updatedAt?: true
_all?: true
@@ -150,7 +150,7 @@ export type MessageGroupByArgs<ExtArgs extends runtime.Types.Extensions.Internal
export type MessageGroupByOutputType = {
id: string
text: string
senderId: string | null
senderUsername: string | null
createdAt: Date
updatedAt: Date
_count: MessageCountAggregateOutputType | null
@@ -179,7 +179,7 @@ export type MessageWhereInput = {
NOT?: Prisma.MessageWhereInput | Prisma.MessageWhereInput[]
id?: Prisma.StringFilter<"Message"> | string
text?: Prisma.StringFilter<"Message"> | string
senderId?: Prisma.StringNullableFilter<"Message"> | string | null
senderUsername?: Prisma.StringNullableFilter<"Message"> | string | null
createdAt?: Prisma.DateTimeFilter<"Message"> | Date | string
updatedAt?: Prisma.DateTimeFilter<"Message"> | Date | string
sender?: Prisma.XOR<Prisma.UserNullableScalarRelationFilter, Prisma.UserWhereInput> | null
@@ -189,7 +189,7 @@ export type MessageWhereInput = {
export type MessageOrderByWithRelationInput = {
id?: Prisma.SortOrder
text?: Prisma.SortOrder
senderId?: Prisma.SortOrderInput | Prisma.SortOrder
senderUsername?: Prisma.SortOrderInput | Prisma.SortOrder
createdAt?: Prisma.SortOrder
updatedAt?: Prisma.SortOrder
sender?: Prisma.UserOrderByWithRelationInput
@@ -202,7 +202,7 @@ export type MessageWhereUniqueInput = Prisma.AtLeast<{
OR?: Prisma.MessageWhereInput[]
NOT?: Prisma.MessageWhereInput | Prisma.MessageWhereInput[]
text?: Prisma.StringFilter<"Message"> | string
senderId?: Prisma.StringNullableFilter<"Message"> | string | null
senderUsername?: Prisma.StringNullableFilter<"Message"> | string | null
createdAt?: Prisma.DateTimeFilter<"Message"> | Date | string
updatedAt?: Prisma.DateTimeFilter<"Message"> | Date | string
sender?: Prisma.XOR<Prisma.UserNullableScalarRelationFilter, Prisma.UserWhereInput> | null
@@ -212,7 +212,7 @@ export type MessageWhereUniqueInput = Prisma.AtLeast<{
export type MessageOrderByWithAggregationInput = {
id?: Prisma.SortOrder
text?: Prisma.SortOrder
senderId?: Prisma.SortOrderInput | Prisma.SortOrder
senderUsername?: Prisma.SortOrderInput | Prisma.SortOrder
createdAt?: Prisma.SortOrder
updatedAt?: Prisma.SortOrder
_count?: Prisma.MessageCountOrderByAggregateInput
@@ -226,7 +226,7 @@ export type MessageScalarWhereWithAggregatesInput = {
NOT?: Prisma.MessageScalarWhereWithAggregatesInput | Prisma.MessageScalarWhereWithAggregatesInput[]
id?: Prisma.StringWithAggregatesFilter<"Message"> | string
text?: Prisma.StringWithAggregatesFilter<"Message"> | string
senderId?: Prisma.StringNullableWithAggregatesFilter<"Message"> | string | null
senderUsername?: Prisma.StringNullableWithAggregatesFilter<"Message"> | string | null
createdAt?: Prisma.DateTimeWithAggregatesFilter<"Message"> | Date | string
updatedAt?: Prisma.DateTimeWithAggregatesFilter<"Message"> | Date | string
}
@@ -243,7 +243,7 @@ export type MessageCreateInput = {
export type MessageUncheckedCreateInput = {
id?: string
text: string
senderId?: string | null
senderUsername?: string | null
createdAt?: Date | string
updatedAt?: Date | string
attachments?: Prisma.MessageAttachmentUncheckedCreateNestedManyWithoutMessageInput
@@ -261,7 +261,7 @@ export type MessageUpdateInput = {
export type MessageUncheckedUpdateInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
text?: Prisma.StringFieldUpdateOperationsInput | string
senderId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
senderUsername?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
attachments?: Prisma.MessageAttachmentUncheckedUpdateManyWithoutMessageNestedInput
@@ -270,7 +270,7 @@ export type MessageUncheckedUpdateInput = {
export type MessageCreateManyInput = {
id?: string
text: string
senderId?: string | null
senderUsername?: string | null
createdAt?: Date | string
updatedAt?: Date | string
}
@@ -285,7 +285,7 @@ export type MessageUpdateManyMutationInput = {
export type MessageUncheckedUpdateManyInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
text?: Prisma.StringFieldUpdateOperationsInput | string
senderId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
senderUsername?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
}
@@ -303,7 +303,7 @@ export type MessageOrderByRelationAggregateInput = {
export type MessageCountOrderByAggregateInput = {
id?: Prisma.SortOrder
text?: Prisma.SortOrder
senderId?: Prisma.SortOrder
senderUsername?: Prisma.SortOrder
createdAt?: Prisma.SortOrder
updatedAt?: Prisma.SortOrder
}
@@ -311,7 +311,7 @@ export type MessageCountOrderByAggregateInput = {
export type MessageMaxOrderByAggregateInput = {
id?: Prisma.SortOrder
text?: Prisma.SortOrder
senderId?: Prisma.SortOrder
senderUsername?: Prisma.SortOrder
createdAt?: Prisma.SortOrder
updatedAt?: Prisma.SortOrder
}
@@ -319,7 +319,7 @@ export type MessageMaxOrderByAggregateInput = {
export type MessageMinOrderByAggregateInput = {
id?: Prisma.SortOrder
text?: Prisma.SortOrder
senderId?: Prisma.SortOrder
senderUsername?: Prisma.SortOrder
createdAt?: Prisma.SortOrder
updatedAt?: Prisma.SortOrder
}
@@ -432,7 +432,7 @@ export type MessageScalarWhereInput = {
NOT?: Prisma.MessageScalarWhereInput | Prisma.MessageScalarWhereInput[]
id?: Prisma.StringFilter<"Message"> | string
text?: Prisma.StringFilter<"Message"> | string
senderId?: Prisma.StringNullableFilter<"Message"> | string | null
senderUsername?: Prisma.StringNullableFilter<"Message"> | string | null
createdAt?: Prisma.DateTimeFilter<"Message"> | Date | string
updatedAt?: Prisma.DateTimeFilter<"Message"> | Date | string
}
@@ -448,7 +448,7 @@ export type MessageCreateWithoutAttachmentsInput = {
export type MessageUncheckedCreateWithoutAttachmentsInput = {
id?: string
text: string
senderId?: string | null
senderUsername?: string | null
createdAt?: Date | string
updatedAt?: Date | string
}
@@ -480,7 +480,7 @@ export type MessageUpdateWithoutAttachmentsInput = {
export type MessageUncheckedUpdateWithoutAttachmentsInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
text?: Prisma.StringFieldUpdateOperationsInput | string
senderId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
senderUsername?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
}
@@ -549,7 +549,7 @@ export type MessageCountOutputTypeCountAttachmentsArgs<ExtArgs extends runtime.T
export type MessageSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
id?: boolean
text?: boolean
senderId?: boolean
senderUsername?: boolean
createdAt?: boolean
updatedAt?: boolean
sender?: boolean | Prisma.Message$senderArgs<ExtArgs>
@@ -560,7 +560,7 @@ export type MessageSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs
export type MessageSelectCreateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
id?: boolean
text?: boolean
senderId?: boolean
senderUsername?: boolean
createdAt?: boolean
updatedAt?: boolean
sender?: boolean | Prisma.Message$senderArgs<ExtArgs>
@@ -569,7 +569,7 @@ export type MessageSelectCreateManyAndReturn<ExtArgs extends runtime.Types.Exten
export type MessageSelectUpdateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
id?: boolean
text?: boolean
senderId?: boolean
senderUsername?: boolean
createdAt?: boolean
updatedAt?: boolean
sender?: boolean | Prisma.Message$senderArgs<ExtArgs>
@@ -578,12 +578,12 @@ export type MessageSelectUpdateManyAndReturn<ExtArgs extends runtime.Types.Exten
export type MessageSelectScalar = {
id?: boolean
text?: boolean
senderId?: boolean
senderUsername?: boolean
createdAt?: boolean
updatedAt?: boolean
}
export type MessageOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"id" | "text" | "senderId" | "createdAt" | "updatedAt", ExtArgs["result"]["message"]>
export type MessageOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"id" | "text" | "senderUsername" | "createdAt" | "updatedAt", ExtArgs["result"]["message"]>
export type MessageInclude<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
sender?: boolean | Prisma.Message$senderArgs<ExtArgs>
attachments?: boolean | Prisma.Message$attachmentsArgs<ExtArgs>
@@ -605,7 +605,7 @@ export type $MessagePayload<ExtArgs extends runtime.Types.Extensions.InternalArg
scalars: runtime.Types.Extensions.GetPayloadResult<{
id: string
text: string
senderId: string | null
senderUsername: string | null
createdAt: Date
updatedAt: Date
}, ExtArgs["result"]["message"]>
@@ -1035,7 +1035,7 @@ export interface Prisma__MessageClient<T, Null = never, ExtArgs extends runtime.
export interface MessageFieldRefs {
readonly id: Prisma.FieldRef<"Message", 'String'>
readonly text: Prisma.FieldRef<"Message", 'String'>
readonly senderId: Prisma.FieldRef<"Message", 'String'>
readonly senderUsername: Prisma.FieldRef<"Message", 'String'>
readonly createdAt: Prisma.FieldRef<"Message", 'DateTime'>
readonly updatedAt: Prisma.FieldRef<"Message", 'DateTime'>
}

View File

@@ -25,7 +25,6 @@ export type AggregateUser = {
}
export type UserMinAggregateOutputType = {
id: string | null
username: string | null
password: string | null
displayName: string | null
@@ -34,7 +33,6 @@ export type UserMinAggregateOutputType = {
}
export type UserMaxAggregateOutputType = {
id: string | null
username: string | null
password: string | null
displayName: string | null
@@ -43,7 +41,6 @@ export type UserMaxAggregateOutputType = {
}
export type UserCountAggregateOutputType = {
id: number
username: number
password: number
displayName: number
@@ -54,7 +51,6 @@ export type UserCountAggregateOutputType = {
export type UserMinAggregateInputType = {
id?: true
username?: true
password?: true
displayName?: true
@@ -63,7 +59,6 @@ export type UserMinAggregateInputType = {
}
export type UserMaxAggregateInputType = {
id?: true
username?: true
password?: true
displayName?: true
@@ -72,7 +67,6 @@ export type UserMaxAggregateInputType = {
}
export type UserCountAggregateInputType = {
id?: true
username?: true
password?: true
displayName?: true
@@ -154,7 +148,6 @@ export type UserGroupByArgs<ExtArgs extends runtime.Types.Extensions.InternalArg
}
export type UserGroupByOutputType = {
id: string
username: string
password: string
displayName: string
@@ -184,7 +177,6 @@ export type UserWhereInput = {
AND?: Prisma.UserWhereInput | Prisma.UserWhereInput[]
OR?: Prisma.UserWhereInput[]
NOT?: Prisma.UserWhereInput | Prisma.UserWhereInput[]
id?: Prisma.StringFilter<"User"> | string
username?: Prisma.StringFilter<"User"> | string
password?: Prisma.StringFilter<"User"> | string
displayName?: Prisma.StringFilter<"User"> | string
@@ -197,7 +189,6 @@ export type UserWhereInput = {
}
export type UserOrderByWithRelationInput = {
id?: Prisma.SortOrder
username?: Prisma.SortOrder
password?: Prisma.SortOrder
displayName?: Prisma.SortOrder
@@ -210,7 +201,6 @@ export type UserOrderByWithRelationInput = {
}
export type UserWhereUniqueInput = Prisma.AtLeast<{
id?: string
username?: string
AND?: Prisma.UserWhereInput | Prisma.UserWhereInput[]
OR?: Prisma.UserWhereInput[]
@@ -223,10 +213,9 @@ export type UserWhereUniqueInput = Prisma.AtLeast<{
UserPreferences?: Prisma.XOR<Prisma.UserPreferencesNullableScalarRelationFilter, Prisma.UserPreferencesWhereInput> | null
Messages?: Prisma.MessageListRelationFilter
Channels?: Prisma.ChannelListRelationFilter
}, "id" | "username">
}, "username" | "username">
export type UserOrderByWithAggregationInput = {
id?: Prisma.SortOrder
username?: Prisma.SortOrder
password?: Prisma.SortOrder
displayName?: Prisma.SortOrder
@@ -241,7 +230,6 @@ export type UserScalarWhereWithAggregatesInput = {
AND?: Prisma.UserScalarWhereWithAggregatesInput | Prisma.UserScalarWhereWithAggregatesInput[]
OR?: Prisma.UserScalarWhereWithAggregatesInput[]
NOT?: Prisma.UserScalarWhereWithAggregatesInput | Prisma.UserScalarWhereWithAggregatesInput[]
id?: Prisma.StringWithAggregatesFilter<"User"> | string
username?: Prisma.StringWithAggregatesFilter<"User"> | string
password?: Prisma.StringWithAggregatesFilter<"User"> | string
displayName?: Prisma.StringWithAggregatesFilter<"User"> | string
@@ -250,7 +238,6 @@ export type UserScalarWhereWithAggregatesInput = {
}
export type UserCreateInput = {
id?: string
username: string
password: string
displayName: string
@@ -263,7 +250,6 @@ export type UserCreateInput = {
}
export type UserUncheckedCreateInput = {
id?: string
username: string
password: string
displayName: string
@@ -276,7 +262,6 @@ export type UserUncheckedCreateInput = {
}
export type UserUpdateInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
username?: Prisma.StringFieldUpdateOperationsInput | string
password?: Prisma.StringFieldUpdateOperationsInput | string
displayName?: Prisma.StringFieldUpdateOperationsInput | string
@@ -289,7 +274,6 @@ export type UserUpdateInput = {
}
export type UserUncheckedUpdateInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
username?: Prisma.StringFieldUpdateOperationsInput | string
password?: Prisma.StringFieldUpdateOperationsInput | string
displayName?: Prisma.StringFieldUpdateOperationsInput | string
@@ -302,7 +286,6 @@ export type UserUncheckedUpdateInput = {
}
export type UserCreateManyInput = {
id?: string
username: string
password: string
displayName: string
@@ -311,7 +294,6 @@ export type UserCreateManyInput = {
}
export type UserUpdateManyMutationInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
username?: Prisma.StringFieldUpdateOperationsInput | string
password?: Prisma.StringFieldUpdateOperationsInput | string
displayName?: Prisma.StringFieldUpdateOperationsInput | string
@@ -320,7 +302,6 @@ export type UserUpdateManyMutationInput = {
}
export type UserUncheckedUpdateManyInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
username?: Prisma.StringFieldUpdateOperationsInput | string
password?: Prisma.StringFieldUpdateOperationsInput | string
displayName?: Prisma.StringFieldUpdateOperationsInput | string
@@ -329,7 +310,6 @@ export type UserUncheckedUpdateManyInput = {
}
export type UserCountOrderByAggregateInput = {
id?: Prisma.SortOrder
username?: Prisma.SortOrder
password?: Prisma.SortOrder
displayName?: Prisma.SortOrder
@@ -338,7 +318,6 @@ export type UserCountOrderByAggregateInput = {
}
export type UserMaxOrderByAggregateInput = {
id?: Prisma.SortOrder
username?: Prisma.SortOrder
password?: Prisma.SortOrder
displayName?: Prisma.SortOrder
@@ -347,7 +326,6 @@ export type UserMaxOrderByAggregateInput = {
}
export type UserMinOrderByAggregateInput = {
id?: Prisma.SortOrder
username?: Prisma.SortOrder
password?: Prisma.SortOrder
displayName?: Prisma.SortOrder
@@ -434,7 +412,6 @@ export type UserUpdateOneWithoutChannelsNestedInput = {
}
export type UserCreateWithoutSessionInput = {
id?: string
username: string
password: string
displayName: string
@@ -446,7 +423,6 @@ export type UserCreateWithoutSessionInput = {
}
export type UserUncheckedCreateWithoutSessionInput = {
id?: string
username: string
password: string
displayName: string
@@ -474,7 +450,6 @@ export type UserUpdateToOneWithWhereWithoutSessionInput = {
}
export type UserUpdateWithoutSessionInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
username?: Prisma.StringFieldUpdateOperationsInput | string
password?: Prisma.StringFieldUpdateOperationsInput | string
displayName?: Prisma.StringFieldUpdateOperationsInput | string
@@ -486,7 +461,6 @@ export type UserUpdateWithoutSessionInput = {
}
export type UserUncheckedUpdateWithoutSessionInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
username?: Prisma.StringFieldUpdateOperationsInput | string
password?: Prisma.StringFieldUpdateOperationsInput | string
displayName?: Prisma.StringFieldUpdateOperationsInput | string
@@ -498,7 +472,6 @@ export type UserUncheckedUpdateWithoutSessionInput = {
}
export type UserCreateWithoutUserPreferencesInput = {
id?: string
username: string
password: string
displayName: string
@@ -510,7 +483,6 @@ export type UserCreateWithoutUserPreferencesInput = {
}
export type UserUncheckedCreateWithoutUserPreferencesInput = {
id?: string
username: string
password: string
displayName: string
@@ -538,7 +510,6 @@ export type UserUpdateToOneWithWhereWithoutUserPreferencesInput = {
}
export type UserUpdateWithoutUserPreferencesInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
username?: Prisma.StringFieldUpdateOperationsInput | string
password?: Prisma.StringFieldUpdateOperationsInput | string
displayName?: Prisma.StringFieldUpdateOperationsInput | string
@@ -550,7 +521,6 @@ export type UserUpdateWithoutUserPreferencesInput = {
}
export type UserUncheckedUpdateWithoutUserPreferencesInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
username?: Prisma.StringFieldUpdateOperationsInput | string
password?: Prisma.StringFieldUpdateOperationsInput | string
displayName?: Prisma.StringFieldUpdateOperationsInput | string
@@ -562,7 +532,6 @@ export type UserUncheckedUpdateWithoutUserPreferencesInput = {
}
export type UserCreateWithoutMessagesInput = {
id?: string
username: string
password: string
displayName: string
@@ -574,7 +543,6 @@ export type UserCreateWithoutMessagesInput = {
}
export type UserUncheckedCreateWithoutMessagesInput = {
id?: string
username: string
password: string
displayName: string
@@ -602,7 +570,6 @@ export type UserUpdateToOneWithWhereWithoutMessagesInput = {
}
export type UserUpdateWithoutMessagesInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
username?: Prisma.StringFieldUpdateOperationsInput | string
password?: Prisma.StringFieldUpdateOperationsInput | string
displayName?: Prisma.StringFieldUpdateOperationsInput | string
@@ -614,7 +581,6 @@ export type UserUpdateWithoutMessagesInput = {
}
export type UserUncheckedUpdateWithoutMessagesInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
username?: Prisma.StringFieldUpdateOperationsInput | string
password?: Prisma.StringFieldUpdateOperationsInput | string
displayName?: Prisma.StringFieldUpdateOperationsInput | string
@@ -626,7 +592,6 @@ export type UserUncheckedUpdateWithoutMessagesInput = {
}
export type UserCreateWithoutChannelsInput = {
id?: string
username: string
password: string
displayName: string
@@ -638,7 +603,6 @@ export type UserCreateWithoutChannelsInput = {
}
export type UserUncheckedCreateWithoutChannelsInput = {
id?: string
username: string
password: string
displayName: string
@@ -666,7 +630,6 @@ export type UserUpdateToOneWithWhereWithoutChannelsInput = {
}
export type UserUpdateWithoutChannelsInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
username?: Prisma.StringFieldUpdateOperationsInput | string
password?: Prisma.StringFieldUpdateOperationsInput | string
displayName?: Prisma.StringFieldUpdateOperationsInput | string
@@ -678,7 +641,6 @@ export type UserUpdateWithoutChannelsInput = {
}
export type UserUncheckedUpdateWithoutChannelsInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
username?: Prisma.StringFieldUpdateOperationsInput | string
password?: Prisma.StringFieldUpdateOperationsInput | string
displayName?: Prisma.StringFieldUpdateOperationsInput | string
@@ -739,7 +701,6 @@ export type UserCountOutputTypeCountChannelsArgs<ExtArgs extends runtime.Types.E
export type UserSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
id?: boolean
username?: boolean
password?: boolean
displayName?: boolean
@@ -753,7 +714,6 @@ export type UserSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = r
}, ExtArgs["result"]["user"]>
export type UserSelectCreateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
id?: boolean
username?: boolean
password?: boolean
displayName?: boolean
@@ -762,7 +722,6 @@ export type UserSelectCreateManyAndReturn<ExtArgs extends runtime.Types.Extensio
}, ExtArgs["result"]["user"]>
export type UserSelectUpdateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
id?: boolean
username?: boolean
password?: boolean
displayName?: boolean
@@ -771,7 +730,6 @@ export type UserSelectUpdateManyAndReturn<ExtArgs extends runtime.Types.Extensio
}, ExtArgs["result"]["user"]>
export type UserSelectScalar = {
id?: boolean
username?: boolean
password?: boolean
displayName?: boolean
@@ -779,7 +737,7 @@ export type UserSelectScalar = {
updatedAt?: boolean
}
export type UserOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"id" | "username" | "password" | "displayName" | "createdAt" | "updatedAt", ExtArgs["result"]["user"]>
export type UserOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"username" | "password" | "displayName" | "createdAt" | "updatedAt", ExtArgs["result"]["user"]>
export type UserInclude<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
Session?: boolean | Prisma.User$SessionArgs<ExtArgs>
UserPreferences?: boolean | Prisma.User$UserPreferencesArgs<ExtArgs>
@@ -799,7 +757,6 @@ export type $UserPayload<ExtArgs extends runtime.Types.Extensions.InternalArgs =
Channels: Prisma.$ChannelPayload<ExtArgs>[]
}
scalars: runtime.Types.Extensions.GetPayloadResult<{
id: string
username: string
password: string
displayName: string
@@ -888,8 +845,8 @@ export interface UserDelegate<ExtArgs extends runtime.Types.Extensions.InternalA
* // Get first 10 Users
* const users = await prisma.user.findMany({ take: 10 })
*
* // Only select the `id`
* const userWithIdOnly = await prisma.user.findMany({ select: { id: true } })
* // Only select the `username`
* const userWithUsernameOnly = await prisma.user.findMany({ select: { username: true } })
*
*/
findMany<T extends UserFindManyArgs>(args?: Prisma.SelectSubset<T, UserFindManyArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$UserPayload<ExtArgs>, T, "findMany", GlobalOmitOptions>>
@@ -933,9 +890,9 @@ export interface UserDelegate<ExtArgs extends runtime.Types.Extensions.InternalA
* ]
* })
*
* // Create many Users and only return the `id`
* const userWithIdOnly = await prisma.user.createManyAndReturn({
* select: { id: true },
* // Create many Users and only return the `username`
* const userWithUsernameOnly = await prisma.user.createManyAndReturn({
* select: { username: true },
* data: [
* // ... provide data here
* ]
@@ -1024,9 +981,9 @@ export interface UserDelegate<ExtArgs extends runtime.Types.Extensions.InternalA
* ]
* })
*
* // Update zero or more Users and only return the `id`
* const userWithIdOnly = await prisma.user.updateManyAndReturn({
* select: { id: true },
* // Update zero or more Users and only return the `username`
* const userWithUsernameOnly = await prisma.user.updateManyAndReturn({
* select: { username: true },
* where: {
* // ... provide filter here
* },
@@ -1232,7 +1189,6 @@ export interface Prisma__UserClient<T, Null = never, ExtArgs extends runtime.Typ
* Fields of the User model
*/
export interface UserFieldRefs {
readonly id: Prisma.FieldRef<"User", 'String'>
readonly username: Prisma.FieldRef<"User", 'String'>
readonly password: Prisma.FieldRef<"User", 'String'>
readonly displayName: Prisma.FieldRef<"User", 'String'>

View File

@@ -25,19 +25,19 @@ export type AggregateUserPreferences = {
}
export type UserPreferencesMinAggregateOutputType = {
userId: string | null
username: string | null
toggleInputHotkey: string | null
toggleOutputHotkey: string | null
}
export type UserPreferencesMaxAggregateOutputType = {
userId: string | null
username: string | null
toggleInputHotkey: string | null
toggleOutputHotkey: string | null
}
export type UserPreferencesCountAggregateOutputType = {
userId: number
username: number
toggleInputHotkey: number
toggleOutputHotkey: number
_all: number
@@ -45,19 +45,19 @@ export type UserPreferencesCountAggregateOutputType = {
export type UserPreferencesMinAggregateInputType = {
userId?: true
username?: true
toggleInputHotkey?: true
toggleOutputHotkey?: true
}
export type UserPreferencesMaxAggregateInputType = {
userId?: true
username?: true
toggleInputHotkey?: true
toggleOutputHotkey?: true
}
export type UserPreferencesCountAggregateInputType = {
userId?: true
username?: true
toggleInputHotkey?: true
toggleOutputHotkey?: true
_all?: true
@@ -136,7 +136,7 @@ export type UserPreferencesGroupByArgs<ExtArgs extends runtime.Types.Extensions.
}
export type UserPreferencesGroupByOutputType = {
userId: string
username: string
toggleInputHotkey: string | null
toggleOutputHotkey: string | null
_count: UserPreferencesCountAggregateOutputType | null
@@ -163,31 +163,31 @@ export type UserPreferencesWhereInput = {
AND?: Prisma.UserPreferencesWhereInput | Prisma.UserPreferencesWhereInput[]
OR?: Prisma.UserPreferencesWhereInput[]
NOT?: Prisma.UserPreferencesWhereInput | Prisma.UserPreferencesWhereInput[]
userId?: Prisma.StringFilter<"UserPreferences"> | string
username?: Prisma.StringFilter<"UserPreferences"> | string
toggleInputHotkey?: Prisma.StringNullableFilter<"UserPreferences"> | string | null
toggleOutputHotkey?: Prisma.StringNullableFilter<"UserPreferences"> | string | null
user?: Prisma.XOR<Prisma.UserScalarRelationFilter, Prisma.UserWhereInput>
}
export type UserPreferencesOrderByWithRelationInput = {
userId?: Prisma.SortOrder
username?: Prisma.SortOrder
toggleInputHotkey?: Prisma.SortOrderInput | Prisma.SortOrder
toggleOutputHotkey?: Prisma.SortOrderInput | Prisma.SortOrder
user?: Prisma.UserOrderByWithRelationInput
}
export type UserPreferencesWhereUniqueInput = Prisma.AtLeast<{
userId?: string
username?: string
AND?: Prisma.UserPreferencesWhereInput | Prisma.UserPreferencesWhereInput[]
OR?: Prisma.UserPreferencesWhereInput[]
NOT?: Prisma.UserPreferencesWhereInput | Prisma.UserPreferencesWhereInput[]
toggleInputHotkey?: Prisma.StringNullableFilter<"UserPreferences"> | string | null
toggleOutputHotkey?: Prisma.StringNullableFilter<"UserPreferences"> | string | null
user?: Prisma.XOR<Prisma.UserScalarRelationFilter, Prisma.UserWhereInput>
}, "userId" | "userId">
}, "username" | "username">
export type UserPreferencesOrderByWithAggregationInput = {
userId?: Prisma.SortOrder
username?: Prisma.SortOrder
toggleInputHotkey?: Prisma.SortOrderInput | Prisma.SortOrder
toggleOutputHotkey?: Prisma.SortOrderInput | Prisma.SortOrder
_count?: Prisma.UserPreferencesCountOrderByAggregateInput
@@ -199,7 +199,7 @@ export type UserPreferencesScalarWhereWithAggregatesInput = {
AND?: Prisma.UserPreferencesScalarWhereWithAggregatesInput | Prisma.UserPreferencesScalarWhereWithAggregatesInput[]
OR?: Prisma.UserPreferencesScalarWhereWithAggregatesInput[]
NOT?: Prisma.UserPreferencesScalarWhereWithAggregatesInput | Prisma.UserPreferencesScalarWhereWithAggregatesInput[]
userId?: Prisma.StringWithAggregatesFilter<"UserPreferences"> | string
username?: Prisma.StringWithAggregatesFilter<"UserPreferences"> | string
toggleInputHotkey?: Prisma.StringNullableWithAggregatesFilter<"UserPreferences"> | string | null
toggleOutputHotkey?: Prisma.StringNullableWithAggregatesFilter<"UserPreferences"> | string | null
}
@@ -211,7 +211,7 @@ export type UserPreferencesCreateInput = {
}
export type UserPreferencesUncheckedCreateInput = {
userId: string
username: string
toggleInputHotkey?: string | null
toggleOutputHotkey?: string | null
}
@@ -223,13 +223,13 @@ export type UserPreferencesUpdateInput = {
}
export type UserPreferencesUncheckedUpdateInput = {
userId?: Prisma.StringFieldUpdateOperationsInput | string
username?: Prisma.StringFieldUpdateOperationsInput | string
toggleInputHotkey?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
toggleOutputHotkey?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
}
export type UserPreferencesCreateManyInput = {
userId: string
username: string
toggleInputHotkey?: string | null
toggleOutputHotkey?: string | null
}
@@ -240,7 +240,7 @@ export type UserPreferencesUpdateManyMutationInput = {
}
export type UserPreferencesUncheckedUpdateManyInput = {
userId?: Prisma.StringFieldUpdateOperationsInput | string
username?: Prisma.StringFieldUpdateOperationsInput | string
toggleInputHotkey?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
toggleOutputHotkey?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
}
@@ -251,19 +251,19 @@ export type UserPreferencesNullableScalarRelationFilter = {
}
export type UserPreferencesCountOrderByAggregateInput = {
userId?: Prisma.SortOrder
username?: Prisma.SortOrder
toggleInputHotkey?: Prisma.SortOrder
toggleOutputHotkey?: Prisma.SortOrder
}
export type UserPreferencesMaxOrderByAggregateInput = {
userId?: Prisma.SortOrder
username?: Prisma.SortOrder
toggleInputHotkey?: Prisma.SortOrder
toggleOutputHotkey?: Prisma.SortOrder
}
export type UserPreferencesMinOrderByAggregateInput = {
userId?: Prisma.SortOrder
username?: Prisma.SortOrder
toggleInputHotkey?: Prisma.SortOrder
toggleOutputHotkey?: Prisma.SortOrder
}
@@ -343,33 +343,33 @@ export type UserPreferencesUncheckedUpdateWithoutUserInput = {
export type UserPreferencesSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
userId?: boolean
username?: boolean
toggleInputHotkey?: boolean
toggleOutputHotkey?: boolean
user?: boolean | Prisma.UserDefaultArgs<ExtArgs>
}, ExtArgs["result"]["userPreferences"]>
export type UserPreferencesSelectCreateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
userId?: boolean
username?: boolean
toggleInputHotkey?: boolean
toggleOutputHotkey?: boolean
user?: boolean | Prisma.UserDefaultArgs<ExtArgs>
}, ExtArgs["result"]["userPreferences"]>
export type UserPreferencesSelectUpdateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
userId?: boolean
username?: boolean
toggleInputHotkey?: boolean
toggleOutputHotkey?: boolean
user?: boolean | Prisma.UserDefaultArgs<ExtArgs>
}, ExtArgs["result"]["userPreferences"]>
export type UserPreferencesSelectScalar = {
userId?: boolean
username?: boolean
toggleInputHotkey?: boolean
toggleOutputHotkey?: boolean
}
export type UserPreferencesOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"userId" | "toggleInputHotkey" | "toggleOutputHotkey", ExtArgs["result"]["userPreferences"]>
export type UserPreferencesOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"username" | "toggleInputHotkey" | "toggleOutputHotkey", ExtArgs["result"]["userPreferences"]>
export type UserPreferencesInclude<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
user?: boolean | Prisma.UserDefaultArgs<ExtArgs>
}
@@ -386,7 +386,7 @@ export type $UserPreferencesPayload<ExtArgs extends runtime.Types.Extensions.Int
user: Prisma.$UserPayload<ExtArgs>
}
scalars: runtime.Types.Extensions.GetPayloadResult<{
userId: string
username: string
toggleInputHotkey: string | null
toggleOutputHotkey: string | null
}, ExtArgs["result"]["userPreferences"]>
@@ -472,8 +472,8 @@ export interface UserPreferencesDelegate<ExtArgs extends runtime.Types.Extension
* // Get first 10 UserPreferences
* const userPreferences = await prisma.userPreferences.findMany({ take: 10 })
*
* // Only select the `userId`
* const userPreferencesWithUserIdOnly = await prisma.userPreferences.findMany({ select: { userId: true } })
* // Only select the `username`
* const userPreferencesWithUsernameOnly = await prisma.userPreferences.findMany({ select: { username: true } })
*
*/
findMany<T extends UserPreferencesFindManyArgs>(args?: Prisma.SelectSubset<T, UserPreferencesFindManyArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$UserPreferencesPayload<ExtArgs>, T, "findMany", GlobalOmitOptions>>
@@ -517,9 +517,9 @@ export interface UserPreferencesDelegate<ExtArgs extends runtime.Types.Extension
* ]
* })
*
* // Create many UserPreferences and only return the `userId`
* const userPreferencesWithUserIdOnly = await prisma.userPreferences.createManyAndReturn({
* select: { userId: true },
* // Create many UserPreferences and only return the `username`
* const userPreferencesWithUsernameOnly = await prisma.userPreferences.createManyAndReturn({
* select: { username: true },
* data: [
* // ... provide data here
* ]
@@ -608,9 +608,9 @@ export interface UserPreferencesDelegate<ExtArgs extends runtime.Types.Extension
* ]
* })
*
* // Update zero or more UserPreferences and only return the `userId`
* const userPreferencesWithUserIdOnly = await prisma.userPreferences.updateManyAndReturn({
* select: { userId: true },
* // Update zero or more UserPreferences and only return the `username`
* const userPreferencesWithUsernameOnly = await prisma.userPreferences.updateManyAndReturn({
* select: { username: true },
* where: {
* // ... provide filter here
* },
@@ -813,7 +813,7 @@ export interface Prisma__UserPreferencesClient<T, Null = never, ExtArgs extends
* Fields of the UserPreferences model
*/
export interface UserPreferencesFieldRefs {
readonly userId: Prisma.FieldRef<"UserPreferences", 'String'>
readonly username: Prisma.FieldRef<"UserPreferences", 'String'>
readonly toggleInputHotkey: Prisma.FieldRef<"UserPreferences", 'String'>
readonly toggleOutputHotkey: Prisma.FieldRef<"UserPreferences", 'String'>
}

View File

@@ -8,8 +8,7 @@ generator client {
}
model User {
id String @id @default(cuid())
username String @unique
username String @id @unique
password String
displayName String
createdAt DateTime @default(now())
@@ -26,17 +25,15 @@ model Session {
userId String
expiresAt DateTime
user User @relation(references: [id], fields: [userId], onDelete: Cascade)
@@index([userId])
user User @relation(references: [username], fields: [userId], onDelete: Cascade)
}
model UserPreferences {
userId String @id @unique
username String @id @unique
toggleInputHotkey String? @default("")
toggleOutputHotkey String? @default("")
user User @relation(references: [id], fields: [userId], onDelete: Cascade)
user User @relation(references: [username], fields: [username], onDelete: Cascade)
}
model Attachment {
@@ -52,11 +49,11 @@ model Attachment {
model Message {
id String @id @default(uuid())
text String
senderId String?
senderUsername String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
sender User? @relation(references: [id], fields: [senderId], onDelete: SetNull)
sender User? @relation(references: [username], fields: [senderUsername], onDelete: SetNull)
attachments MessageAttachment[]
}
@@ -72,9 +69,9 @@ model MessageAttachment {
model Channel {
id String @id @default(uuid())
ownerId String?
ownerUsername String?
name String
persistent Boolean
owner User? @relation(references: [id], fields: [ownerId], onDelete: Cascade)
owner User? @relation(references: [username], fields: [ownerUsername], onDelete: Cascade)
}

View File

@@ -33,13 +33,12 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
},
})
const session = await fastify.lucia.createSession(user.id, {})
const session = await fastify.lucia.createSession(user.username, {})
const cookie = fastify.lucia.createSessionCookie(session.id)
reply.setCookie(cookie.name, cookie.value, cookie.attributes)
return {
id: user.id,
username: user.username,
displayName: user.username,
createdAt: user.createdAt.toISOString(),
@@ -67,7 +66,6 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
const user = await fastify.prisma.user.findFirst({
where: { username: req.body.username },
select: {
id: true,
username: true,
displayName: true,
createdAt: true,
@@ -84,7 +82,7 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
return reply.notFound('Incorrect username or password')
}
const session = await fastify.lucia.createSession(user.id, {})
const session = await fastify.lucia.createSession(user.username, {})
const cookie = fastify.lucia.createSessionCookie(session.id)
reply.setCookie(cookie.name, cookie.value, cookie.attributes)
@@ -112,7 +110,6 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
const user = req.user!
return {
id: user.id,
username: user.username,
displayName: user.displayName,
createdAt: user.createdAt.toISOString(),

View File

@@ -41,7 +41,7 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
const channel = await fastify.prisma.channel.create({
data: {
name: req.body.name,
ownerId: user.id,
ownerUsername: user.username,
persistent: req.body.persistent,
},
})
@@ -73,7 +73,7 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
try {
const channel = await fastify.prisma.channel.delete({
where: { id: req.params.id, ownerId: user.id },
where: { id: req.params.id, ownerUsername: user.username },
})
fastify.bus.emit('channel:removed', channel)

View File

@@ -1,6 +1,7 @@
import type { FastifyPluginAsyncTypebox } from '@fastify/type-provider-typebox'
import { Type } from 'typebox'
import { ChatMessageSchema, NewChatMessagePayloadSchema } from '../plugins/schemas/chat.ts'
import { TypeboxRef } from '../utils/typebox-ref.ts'
const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
fastify.post(
@@ -10,9 +11,9 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
summary: 'Send message',
tags: ['Chat'],
operationId: 'chat.send',
body: NewChatMessagePayloadSchema,
body: TypeboxRef(NewChatMessagePayloadSchema),
response: {
200: ChatMessageSchema,
200: TypeboxRef(ChatMessageSchema),
},
},
},
@@ -22,7 +23,7 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
const message = await fastify.prisma.message.create({
data: {
text: req.body.text,
senderId: user.id,
senderUsername: user.username,
attachments: {
create: (req.body.attachments ?? []).map((attachmentId) => {
return {
@@ -35,6 +36,13 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
}),
},
},
include: {
attachments: {
include: {
attachment: true,
},
},
},
})
if (!message) {
@@ -43,11 +51,11 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
const response = {
id: message.id,
senderId: user.id,
senderUsername: user.username,
text: message.text,
createdAt: message.createdAt.toISOString(),
updatedAt: message.updatedAt.toISOString(),
attachments: req.body.attachments ?? [],
attachments: message.attachments.map(({ attachment }) => attachment),
}
fastify.bus.emit('chat:new-message', response)
@@ -69,7 +77,7 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
}),
response: {
200: Type.Object({
messages: Type.Array(ChatMessageSchema),
messages: Type.Array(TypeboxRef(ChatMessageSchema)),
nextCursor: Type.Optional(Type.String({ format: 'uuid', description: 'Cursor to last message' })),
}),
},
@@ -81,7 +89,7 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
const messages = await fastify.prisma.message.findMany({
orderBy: { createdAt: 'desc' },
take: req.query.limit + 1,
include: { attachments: true },
include: { attachments: { include: { attachment: true } } },
...(req.query.cursor && {
cursor: {
id: req.query.cursor,
@@ -99,7 +107,7 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
...message,
createdAt: message.createdAt.toISOString(),
updatedAt: message.updatedAt.toISOString(),
attachments: message.attachments.map(({ attachmentId }) => attachmentId),
attachments: message.attachments.map(({ attachment }) => attachment),
}
}),
nextCursor: cursorMessage?.id,

View File

@@ -19,9 +19,8 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
},
async (req, reply) => {
const user = await fastify.prisma.user.findFirst({
where: { username: req.query.username, id: req.query.id },
where: { username: req.query.username },
select: {
id: true,
username: true,
displayName: true,
createdAt: true,
@@ -55,8 +54,8 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
const user = req.user!
const preferences = await fastify.prisma.userPreferences.upsert({
where: { userId: user.id },
create: { userId: user.id },
where: { username: user.username },
create: { username: user.username },
update: {},
})
@@ -81,9 +80,9 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
const user = req.user!
return fastify.prisma.userPreferences.upsert({
where: { userId: user.id },
where: { username: user.username },
create: {
userId: user.id,
username: user.username,
...req.body,
},
update: req.body,
@@ -108,12 +107,11 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
const user = req.user!
const updatedUser = await fastify.prisma.user.update({
where: { id: user.id },
where: { username: user.username },
data: {
displayName: req.body.displayName,
},
select: {
id: true,
username: true,
displayName: true,
createdAt: true,